mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-30 08:33:10 +00:00
tree select(gp_Pnt) also with extend
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include <NCollection_UBTree.hxx>
|
#include <NCollection_UBTree.hxx>
|
||||||
#include <BRepBndLib.hxx>
|
#include <BRepBndLib.hxx>
|
||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
#include <BRepAlgoAPI_Common.hxx>
|
#include <BRepAlgoAPI_Common.hxx>
|
||||||
#include <BRepAlgoAPI_Cut.hxx>
|
#include <BRepAlgoAPI_Cut.hxx>
|
||||||
#include <BRepExtrema_DistShapeShape.hxx>
|
#include <BRepExtrema_DistShapeShape.hxx>
|
||||||
@@ -93,9 +94,10 @@ namespace IfcGeom {
|
|||||||
return select_box(b, completely_within);
|
return select_box(b, completely_within);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<T> select_box(const gp_Pnt& p) const {
|
std::vector<T> select_box(const gp_Pnt& p, double extend=0.0) const {
|
||||||
Bnd_Box b;
|
Bnd_Box b;
|
||||||
b.Add(p);
|
b.Add(p);
|
||||||
|
b.SetGap(b.GetGap() + extend);
|
||||||
return select_box(b);
|
return select_box(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,8 +200,8 @@ namespace IfcGeom {
|
|||||||
return ts_filtered;
|
return ts_filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<T> select(const gp_Pnt& p) const {
|
std::vector<T> select(const gp_Pnt& p, double extend=0.0) const {
|
||||||
std::vector<T> ts = select_box(p);
|
std::vector<T> ts = select_box(p, extend);
|
||||||
if (ts.empty()) {
|
if (ts.empty()) {
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
@@ -207,15 +209,28 @@ namespace IfcGeom {
|
|||||||
std::vector<T> ts_filtered;
|
std::vector<T> ts_filtered;
|
||||||
ts_filtered.reserve(ts.size());
|
ts_filtered.reserve(ts.size());
|
||||||
|
|
||||||
|
TopoDS_Vertex v;
|
||||||
|
if (extend > 0.) {
|
||||||
|
BRep_Builder B;
|
||||||
|
B.MakeVertex(v, p, Precision::Confusion());
|
||||||
|
}
|
||||||
|
|
||||||
typename std::vector<T>::const_iterator it = ts.begin();
|
typename std::vector<T>::const_iterator it = ts.begin();
|
||||||
for (it = ts.begin(); it != ts.end(); ++it) {
|
for (it = ts.begin(); it != ts.end(); ++it) {
|
||||||
const TopoDS_Shape& B = shapes_.find(*it)->second;
|
const TopoDS_Shape& B = shapes_.find(*it)->second;
|
||||||
TopExp_Explorer exp(B, TopAbs_SOLID);
|
if (extend > 0.0) {
|
||||||
for (; exp.More(); exp.Next()) {
|
BRepExtrema_DistShapeShape dss(v, B);
|
||||||
BRepClass3d_SolidClassifier cls(exp.Current(), p, 1e-5);
|
if (dss.Perform() && dss.NbSolution() >= 1) {
|
||||||
if (cls.State() != TopAbs_OUT) {
|
|
||||||
ts_filtered.push_back(*it);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,8 +85,8 @@
|
|||||||
return IfcGeom_tree_vector_to_list(ps);
|
return IfcGeom_tree_vector_to_list(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcEntityList::ptr select(const gp_Pnt& p) const {
|
IfcEntityList::ptr select(const gp_Pnt& p, double extend=0.0) const {
|
||||||
std::vector<IfcUtil::IfcBaseEntity*> ps = $self->select(p);
|
std::vector<IfcUtil::IfcBaseEntity*> ps = $self->select(p, extend);
|
||||||
return IfcGeom_tree_vector_to_list(ps);
|
return IfcGeom_tree_vector_to_list(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user