From a4ab454c0f50496cea07eee93d06e596eb3beb83 Mon Sep 17 00:00:00 2001 From: oan Date: Fri, 15 Apr 2016 17:12:28 +0300 Subject: [PATCH] 0027356: BRepTools::Clean() does not clean free edges from Poly_Polygon3D Added code to clean 3D polygons on edges in BRepTools::Clean(). --- src/BRepTools/BRepTools.cxx | 15 +++++++++++++++ tests/bugs/moddata_3/bug27356 | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/bugs/moddata_3/bug27356 diff --git a/src/BRepTools/BRepTools.cxx b/src/BRepTools/BRepTools.cxx index ae2cb9dce4..7efc932feb 100644 --- a/src/BRepTools/BRepTools.cxx +++ b/src/BRepTools/BRepTools.cxx @@ -874,6 +874,21 @@ void BRepTools::Clean(const TopoDS_Shape& theShape) aBuilder.UpdateFace(aFace, aNullTriangulation); } + + // Iterate over all edges seeking for 3d polygons + Handle (Poly_Polygon3D) aNullPoly3d; + TopExp_Explorer aEdgeIt (theShape, TopAbs_EDGE); + for (; aEdgeIt.More (); aEdgeIt.Next ()) + { + const TopoDS_Edge& aEdge = TopoDS::Edge (aEdgeIt.Current ()); + + TopLoc_Location aLoc; + Handle (Poly_Polygon3D) aPoly3d = BRep_Tool::Polygon3D (aEdge, aLoc); + if (aPoly3d.IsNull ()) + continue; + + aBuilder.UpdateEdge (aEdge, aNullPoly3d); + } } //======================================================================= diff --git a/tests/bugs/moddata_3/bug27356 b/tests/bugs/moddata_3/bug27356 new file mode 100644 index 0000000000..72c3a6a1d0 --- /dev/null +++ b/tests/bugs/moddata_3/bug27356 @@ -0,0 +1,18 @@ +puts "# =============================================================" +puts "# 0027356: BRepTools::Clean() does not clean free edges from Poly_Polygon3D" +puts "# =============================================================" +puts "" + +puts "Create simple straight edge and tessellate it" +vertex v1 0 0 0 +vertex v2 1 0 0 +edge e v1 v2 +incmesh e 0.01 + +puts "Clean triangulation and check that there are no Polygon3Ds remained" +tclean e +if { ! [regexp {Dump of ([0-9]+) Polygon3Ds} [dump e] res count] } { + puts "Error: Cannot find number of Polygon3Ds in output of trinfo command" +} elseif { $count != 0 } { + puts "Error: $count Polygon3Ds are found (zero expected)!" +} \ No newline at end of file