mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Hacky way to return distances in the tree with extend>0
This commit is contained in:
@@ -56,6 +56,9 @@ namespace IfcGeom {
|
||||
if (extend > 0.) {
|
||||
BRepExtrema_DistShapeShape dss(A, B);
|
||||
if (dss.Perform() && dss.NbSolution() >= 1) {
|
||||
if (dss.Value() <= extend) {
|
||||
distances_.push_back(dss.Value());
|
||||
}
|
||||
return dss.Value() <= extend;
|
||||
}
|
||||
} else if (completely_within) {
|
||||
@@ -76,6 +79,11 @@ namespace IfcGeom {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// @todo this is ugly, embed this in the return type
|
||||
mutable std::vector<double> distances_;
|
||||
|
||||
public:
|
||||
|
||||
void add(const T& t, const Bnd_Box& b) {
|
||||
@@ -144,6 +152,8 @@ namespace IfcGeom {
|
||||
}
|
||||
|
||||
std::vector<T> select(const T& t, bool completely_within = false, double extend = 0.0) const {
|
||||
distances_.clear();
|
||||
|
||||
std::vector<T> ts = select_box(t, completely_within, extend);
|
||||
if (ts.empty()) {
|
||||
return ts;
|
||||
@@ -174,6 +184,8 @@ namespace IfcGeom {
|
||||
}
|
||||
|
||||
std::vector<T> select(const TopoDS_Shape& s, bool completely_within = false, double extend = -1.e-5) const {
|
||||
distances_.clear();
|
||||
|
||||
Bnd_Box bb;
|
||||
BRepBndLib::AddClose(s, bb);
|
||||
bb.SetGap(bb.GetGap() + extend);
|
||||
@@ -213,6 +225,8 @@ namespace IfcGeom {
|
||||
}
|
||||
|
||||
std::vector<T> select(const gp_Pnt& p, double extend=0.0) const {
|
||||
distances_.clear();
|
||||
|
||||
std::vector<T> ts = select_box(p, extend);
|
||||
if (ts.empty()) {
|
||||
return ts;
|
||||
@@ -233,6 +247,7 @@ namespace IfcGeom {
|
||||
if (extend > 0.0) {
|
||||
BRepExtrema_DistShapeShape dss(v, B);
|
||||
if (dss.Perform() && dss.NbSolution() >= 1 && dss.Value() <= extend) {
|
||||
distances_.push_back(dss.Value());
|
||||
ts_filtered.push_back(*it);
|
||||
}
|
||||
} else {
|
||||
@@ -361,6 +376,10 @@ namespace IfcGeom {
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<double>& distances() const {
|
||||
return distances_;
|
||||
}
|
||||
|
||||
std::vector<IfcGeom::ray_intersection_result> select_ray(const gp_Pnt& p0, const gp_Dir& d, double length = 1000.) const {
|
||||
gp_Pnt p1 = p0.XYZ() + d.XYZ() * length;
|
||||
auto E = BRepBuilderAPI_MakeEdge(p0, p1).Edge();
|
||||
|
||||
Reference in New Issue
Block a user