mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Detect self-intersections in faceset helper and clamp bounding box eps factor to 1.
This commit is contained in:
@@ -121,6 +121,7 @@ private:
|
|||||||
MAKE_TYPE_NAME(Kernel)* kernel_;
|
MAKE_TYPE_NAME(Kernel)* kernel_;
|
||||||
std::map<int, int> vertex_mapping_;
|
std::map<int, int> vertex_mapping_;
|
||||||
std::map<std::pair<int, int>, TopoDS_Edge> edges_;
|
std::map<std::pair<int, int>, TopoDS_Edge> edges_;
|
||||||
|
double eps_;
|
||||||
|
|
||||||
template <typename Fn>
|
template <typename Fn>
|
||||||
void loop_(IfcSchema::IfcCartesianPoint::list::ptr& ps, const Fn& callback) {
|
void loop_(IfcSchema::IfcCartesianPoint::list::ptr& ps, const Fn& callback) {
|
||||||
@@ -184,11 +185,22 @@ private:
|
|||||||
});
|
});
|
||||||
if (count >= 3) {
|
if (count >= 3) {
|
||||||
wire.Closed(true);
|
wire.Closed(true);
|
||||||
|
|
||||||
|
TopTools_ListOfShape results;
|
||||||
|
if (kernel_->wire_intersections(wire, results)) {
|
||||||
|
Logger::Error("Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected", loop);
|
||||||
|
kernel_->select_largest(results, wire);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double epsilon() const {
|
||||||
|
return eps_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
double deflection_tolerance;
|
double deflection_tolerance;
|
||||||
|
|||||||
@@ -3300,7 +3300,9 @@ bool IfcGeom::Kernel::wire_intersections(const TopoDS_Wire& wire, TopTools_ListO
|
|||||||
// TopoDS_Face face = BRepBuilderAPI_MakeFace(wire, true).Face();
|
// TopoDS_Face face = BRepBuilderAPI_MakeFace(wire, true).Face();
|
||||||
// ShapeAnalysis_Wire saw(wd, face, getValue(GV_PRECISION));
|
// ShapeAnalysis_Wire saw(wd, face, getValue(GV_PRECISION));
|
||||||
|
|
||||||
const double eps = (std::min)(min_edge_length(wire) / 2., getValue(GV_PRECISION) * 10.);
|
const double eps = faceset_helper_
|
||||||
|
? faceset_helper_->epsilon()
|
||||||
|
: (std::min)(min_edge_length(wire) / 2., getValue(GV_PRECISION) * 10.);
|
||||||
|
|
||||||
for (int i = 2; i < n; ++i) {
|
for (int i = 2; i < n; ++i) {
|
||||||
|
|
||||||
@@ -3788,14 +3790,14 @@ IfcGeom::Kernel::faceset_helper::faceset_helper(Kernel* kernel, const IfcSchema:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const double eps = kernel->getValue(GV_PRECISION) * 10. * bdiff;
|
eps_ = kernel->getValue(GV_PRECISION) * 10. * (std::min)(1.0, bdiff);
|
||||||
|
|
||||||
std::map<std::pair<int, int>, int> edge_use;
|
std::map<std::pair<int, int>, int> edge_use;
|
||||||
|
|
||||||
for (int i = 0; i < pnts.size(); ++i) {
|
for (int i = 0; i < pnts.size(); ++i) {
|
||||||
if (pnts[i]) {
|
if (pnts[i]) {
|
||||||
std::set<int> vs;
|
std::set<int> vs;
|
||||||
find_neighbours(tree, pnts, vs, i, eps);
|
find_neighbours(tree, pnts, vs, i, eps_);
|
||||||
|
|
||||||
for (int v : vs) {
|
for (int v : vs) {
|
||||||
auto pt = *(points->begin() + v);
|
auto pt = *(points->begin() + v);
|
||||||
|
|||||||
Reference in New Issue
Block a user