Skip to content

Commit cdcbc2a

Browse files
committed
Fix 2d boolean check for periodic curves #6147
1 parent ba2456a commit cdcbc2a

1 file changed

Lines changed: 37 additions & 34 deletions

File tree

src/ifcgeom/kernels/opencascade/boolean_utils.cpp

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -683,42 +683,45 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
683683
BRep_Tool::Curve(e1, u21, u22)
684684
);
685685

686-
if (!ecc.Extrema().IsParallel() && ecc.NbExtrema() == 1) {
686+
if (!ecc.Extrema().IsParallel() && ecc.NbExtrema() >= 1) {
687687
// @todo: extend this to work in case of multiple extrema and curved segments.
688-
gp_Pnt p1, p2;
689-
ecc.Points(1, p1, p2);
690-
691-
// #3616 Only take into account orthogonal distance between closest points on curve
692-
// to see whether inside tolerance. Current DY is hardcoded. The sensible default
693-
// for walls.
694-
gp_Vec vec(p1, p2);
695-
Standard_Real d = vec.Dot(gp::DY());
696-
gp_Vec projected = d * gp::DY();
697-
gp_Vec ortho_remainder = vec - projected;
698-
Standard_Real ortho_distance = ortho_remainder.Magnitude();
699-
700-
const bool unbounded_intersects = ortho_distance < eps;
701-
if (unbounded_intersects) {
702-
ecc.Parameters(1, U1, U2);
703-
704-
if (u11 > u12) {
705-
std::swap(u11, u12);
706-
}
707-
if (u21 > u22) {
708-
std::swap(u21, u22);
709-
}
710688

711-
/// @todo: tfk: probably need different thresholds on non-linear curves
712-
u11 -= eps;
713-
u12 += eps;
714-
u21 -= eps;
715-
u22 += eps;
716-
717-
if (u11 < U1 && U1 < u12 && u21 < U2 && U2 < u22) {
718-
// Edge curves belonging to different operands intersect, don't process
719-
// using builder.
720-
Logger::Notice("Intersecting boundaries");
721-
return false;
689+
for (int i = 1; i <= ecc.NbExtrema(); ++i) {
690+
gp_Pnt p1, p2;
691+
ecc.Points(i, p1, p2);
692+
693+
// #3616 Only take into account orthogonal distance between closest points on curve
694+
// to see whether inside tolerance. Current DY is hardcoded. The sensible default
695+
// for walls.
696+
gp_Vec vec(p1, p2);
697+
Standard_Real d = vec.Dot(gp::DY());
698+
gp_Vec projected = d * gp::DY();
699+
gp_Vec ortho_remainder = vec - projected;
700+
Standard_Real ortho_distance = ortho_remainder.Magnitude();
701+
702+
const bool unbounded_intersects = ortho_distance < eps;
703+
if (unbounded_intersects) {
704+
ecc.Parameters(i, U1, U2);
705+
706+
if (u11 > u12) {
707+
std::swap(u11, u12);
708+
}
709+
if (u21 > u22) {
710+
std::swap(u21, u22);
711+
}
712+
713+
/// @todo: tfk: probably need different thresholds on non-linear curves
714+
u11 -= eps;
715+
u12 += eps;
716+
u21 -= eps;
717+
u22 += eps;
718+
719+
if (u11 < U1 && U1 < u12 && u21 < U2 && U2 < u22) {
720+
// Edge curves belonging to different operands intersect, don't process
721+
// using builder.
722+
Logger::Notice("Intersecting boundaries");
723+
return false;
724+
}
722725
}
723726
}
724727
}

0 commit comments

Comments
 (0)