diff --git a/src/ifcgeom/IfcGeomTree.h b/src/ifcgeom/IfcGeomTree.h index 40f02e8ce7..7d8c175c2e 100644 --- a/src/ifcgeom/IfcGeomTree.h +++ b/src/ifcgeom/IfcGeomTree.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -93,9 +94,10 @@ namespace IfcGeom { return select_box(b, completely_within); } - std::vector select_box(const gp_Pnt& p) const { + std::vector select_box(const gp_Pnt& p, double extend=0.0) const { Bnd_Box b; b.Add(p); + b.SetGap(b.GetGap() + extend); return select_box(b); } @@ -198,8 +200,8 @@ namespace IfcGeom { return ts_filtered; } - std::vector select(const gp_Pnt& p) const { - std::vector ts = select_box(p); + std::vector select(const gp_Pnt& p, double extend=0.0) const { + std::vector ts = select_box(p, extend); if (ts.empty()) { return ts; } @@ -207,17 +209,30 @@ namespace IfcGeom { std::vector ts_filtered; ts_filtered.reserve(ts.size()); + TopoDS_Vertex v; + if (extend > 0.) { + BRep_Builder B; + B.MakeVertex(v, p, Precision::Confusion()); + } + typename std::vector::const_iterator it = ts.begin(); for (it = ts.begin(); it != ts.end(); ++it) { const TopoDS_Shape& B = shapes_.find(*it)->second; - TopExp_Explorer exp(B, TopAbs_SOLID); - for (; exp.More(); exp.Next()) { - BRepClass3d_SolidClassifier cls(exp.Current(), p, 1e-5); - if (cls.State() != TopAbs_OUT) { + if (extend > 0.0) { + BRepExtrema_DistShapeShape dss(v, B); + if (dss.Perform() && dss.NbSolution() >= 1) { ts_filtered.push_back(*it); - break; } - } + } else { + TopExp_Explorer exp(B, TopAbs_SOLID); + for (; exp.More(); exp.Next()) { + BRepClass3d_SolidClassifier cls(exp.Current(), p, 1e-5); + if (cls.State() != TopAbs_OUT) { + ts_filtered.push_back(*it); + break; + } + } + } } return ts_filtered; diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 366c9f5fee..69b737fff4 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -85,8 +85,8 @@ return IfcGeom_tree_vector_to_list(ps); } - IfcEntityList::ptr select(const gp_Pnt& p) const { - std::vector ps = $self->select(p); + IfcEntityList::ptr select(const gp_Pnt& p, double extend=0.0) const { + std::vector ps = $self->select(p, extend); return IfcGeom_tree_vector_to_list(ps); }