mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Fix 2d boolean check for periodic curves #6147
This commit is contained in:
@@ -683,42 +683,45 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
|
|||||||
BRep_Tool::Curve(e1, u21, u22)
|
BRep_Tool::Curve(e1, u21, u22)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!ecc.Extrema().IsParallel() && ecc.NbExtrema() == 1) {
|
if (!ecc.Extrema().IsParallel() && ecc.NbExtrema() >= 1) {
|
||||||
// @todo: extend this to work in case of multiple extrema and curved segments.
|
// @todo: extend this to work in case of multiple extrema and curved segments.
|
||||||
gp_Pnt p1, p2;
|
|
||||||
ecc.Points(1, p1, p2);
|
|
||||||
|
|
||||||
// #3616 Only take into account orthogonal distance between closest points on curve
|
for (int i = 1; i <= ecc.NbExtrema(); ++i) {
|
||||||
// to see whether inside tolerance. Current DY is hardcoded. The sensible default
|
gp_Pnt p1, p2;
|
||||||
// for walls.
|
ecc.Points(i, p1, p2);
|
||||||
gp_Vec vec(p1, p2);
|
|
||||||
Standard_Real d = vec.Dot(gp::DY());
|
|
||||||
gp_Vec projected = d * gp::DY();
|
|
||||||
gp_Vec ortho_remainder = vec - projected;
|
|
||||||
Standard_Real ortho_distance = ortho_remainder.Magnitude();
|
|
||||||
|
|
||||||
const bool unbounded_intersects = ortho_distance < eps;
|
// #3616 Only take into account orthogonal distance between closest points on curve
|
||||||
if (unbounded_intersects) {
|
// to see whether inside tolerance. Current DY is hardcoded. The sensible default
|
||||||
ecc.Parameters(1, U1, U2);
|
// for walls.
|
||||||
|
gp_Vec vec(p1, p2);
|
||||||
|
Standard_Real d = vec.Dot(gp::DY());
|
||||||
|
gp_Vec projected = d * gp::DY();
|
||||||
|
gp_Vec ortho_remainder = vec - projected;
|
||||||
|
Standard_Real ortho_distance = ortho_remainder.Magnitude();
|
||||||
|
|
||||||
if (u11 > u12) {
|
const bool unbounded_intersects = ortho_distance < eps;
|
||||||
std::swap(u11, u12);
|
if (unbounded_intersects) {
|
||||||
}
|
ecc.Parameters(i, U1, U2);
|
||||||
if (u21 > u22) {
|
|
||||||
std::swap(u21, u22);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @todo: tfk: probably need different thresholds on non-linear curves
|
if (u11 > u12) {
|
||||||
u11 -= eps;
|
std::swap(u11, u12);
|
||||||
u12 += eps;
|
}
|
||||||
u21 -= eps;
|
if (u21 > u22) {
|
||||||
u22 += eps;
|
std::swap(u21, u22);
|
||||||
|
}
|
||||||
|
|
||||||
if (u11 < U1 && U1 < u12 && u21 < U2 && U2 < u22) {
|
/// @todo: tfk: probably need different thresholds on non-linear curves
|
||||||
// Edge curves belonging to different operands intersect, don't process
|
u11 -= eps;
|
||||||
// using builder.
|
u12 += eps;
|
||||||
Logger::Notice("Intersecting boundaries");
|
u21 -= eps;
|
||||||
return false;
|
u22 += eps;
|
||||||
|
|
||||||
|
if (u11 < U1 && U1 < u12 && u21 < U2 && U2 < u22) {
|
||||||
|
// Edge curves belonging to different operands intersect, don't process
|
||||||
|
// using builder.
|
||||||
|
Logger::Notice("Intersecting boundaries");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user