From 07756ab2da5d109bbaab7daa99949769710205f2 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 12 Jan 2020 14:40:27 +0100 Subject: [PATCH] Renable wire segmentation for #468 and #674 --- src/ifcgeom/IfcGeomShapes.cpp | 87 ++++++++++++++--------------------- 1 file changed, 34 insertions(+), 53 deletions(-) diff --git a/src/ifcgeom/IfcGeomShapes.cpp b/src/ifcgeom/IfcGeomShapes.cpp index afd620f73d..7e76e1ac12 100644 --- a/src/ifcgeom/IfcGeomShapes.cpp +++ b/src/ifcgeom/IfcGeomShapes.cpp @@ -1253,21 +1253,42 @@ namespace { // @todo make this generic for other sweeps not just swept disk void process_sweep(const TopoDS_Wire& wire, double radius, TopoDS_Shape& result) { - gp_Ax2 directrix; - if (!wire_to_ax(wire, directrix)) { - return; + std::vector wires; + segment_adjacent_non_linear(wire, wires); + + TopoDS_Compound C; + BRep_Builder B; + if (wires.size() > 1) { + B.MakeCompound(C); } - Handle(Geom_Circle) circle = new Geom_Circle(directrix, radius); - TopoDS_Wire section = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle)); - if (is_single_circular_edge(wire)) { - process_sweep_as_revolution(wire, section, result); - } else if (is_single_linear_edge(wire)) { - process_sweep_as_extrusion(wire, section, result); - } else { - process_sweep_as_pipe(wire, section, result); - } - return; + for (auto& w : wires) { + TopoDS_Shape part; + + gp_Ax2 directrix; + if (!wire_to_ax(w, directrix)) { + continue; + } + Handle(Geom_Circle) circle = new Geom_Circle(directrix, radius); + TopoDS_Wire section = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle)); + + if (is_single_circular_edge(w)) { + process_sweep_as_revolution(w, section, part); + } else if (is_single_linear_edge(w)) { + process_sweep_as_extrusion(w, section, part); + } else { + process_sweep_as_pipe(w, section, part); + } + if (wires.size() > 1) { + B.Add(C, part); + } else { + result = part; + } + } + + if (wires.size() > 1) { + result = C; + } /* // Eliminate Swept Surfaces? @@ -1291,46 +1312,6 @@ namespace { } result = sbrs.Apply(result); */ - - /* - // This code is no longer active, as with the BRepBuilderAPI_Transformed - // transitioning mode on the pipe, issues no longer seem to occur. - - std::vector wires; - segment_adjacent_non_linear(wire, wires); - - TopoDS_Compound C; - BRep_Builder B; - if (wires.size() > 1) { - B.MakeCompound(C); - } - - for (auto& w : wires) { - TopoDS_Shape part; - - gp_Ax2 directrix; - if (!wire_to_ax(w, directrix)) { - continue; - } - Handle(Geom_Circle) circle = new Geom_Circle(directrix, radius); - TopoDS_Wire section = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle)); - - if (is_single_linear_edge(w)) { - process_sweep_as_extrusion(w, section, part); - } else { - process_sweep_as_pipe(w, section, part); - } - if (wires.size() > 1) { - B.Add(C, part); - } else { - result = part; - } - } - - if (wires.size() > 1) { - result = C; - } - */ } }