From: isn Date: Fri, 15 Jan 2016 13:22:32 +0000 (+0300) Subject: 0027085: ShapeUpgrade_UnifySameDomain very large performance difference for seemingly... X-Git-Tag: V7_0_0rc~84 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=26ca3bd5490401b0d175856471e698d76497f976 0027085: ShapeUpgrade_UnifySameDomain very large performance difference for seemingly similar shapes Performance of the algorithm ShapeUpgrade_UnifySameDomain has been improved by avoiding of multiple calls of ShapeBuild_ReShape::Apply() method. New test cases have been added. --- diff --git a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index ec8e54e6d2..51e6f55e6a 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -1168,6 +1168,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() B.MakeFace(aResult,aBaseSurface,aBaseLocation,0); Standard_Integer nbWires = 0; + TopoDS_Face tmpF = TopoDS::Face(myContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); // connecting wires while (edges.Length()>0) { @@ -1215,7 +1216,6 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() aWire.Closed (BRep_Tool::IsClosed (aWire)); aWire = TopoDS::Wire(myContext->Apply(aWire)); - TopoDS_Face tmpF = TopoDS::Face(myContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); sfw->FixReorder(); Standard_Boolean isDegRemoved = Standard_False; @@ -1515,6 +1515,15 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() MergeSeq(SeqEdges, Tol, myConcatBSplines, myContext, myOldShapes, SharedVert, NewEdges2OldEdges); } + TopTools_DataMapOfShapeShape oldFaces2NewFaces; + for (exp.Init(myShape, TopAbs_FACE); exp.More(); exp.Next()) + { + const TopoDS_Face& f = TopoDS::Face(exp.Current()); + TopoDS_Face NewF = TopoDS::Face(myContext->Apply(f)); + if (!NewF.IsNull()) + oldFaces2NewFaces.Bind(f, NewF); + } + // processing each face for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) { //TopoDS_Face aFace = TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); @@ -1529,7 +1538,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() Standard_Integer NbFacesPerEdge = aList.Extent(); for ( ; anIter.More(); anIter.Next()) { TopoDS_Face face = TopoDS::Face(anIter.Value()); - TopoDS_Face face1 = TopoDS::Face(myContext->Apply(anIter.Value())); + TopoDS_Face face1 = TopoDS::Face(oldFaces2NewFaces(anIter.Value())); if (face1.IsSame(aFace) && NbFacesPerEdge != 1) continue; if (NbFacesPerEdge == 1) diff --git a/tests/bugs/heal/bug26219_1 b/tests/bugs/heal/bug26219_1 index 41306b24c5..4f64225595 100644 --- a/tests/bugs/heal/bug26219_1 +++ b/tests/bugs/heal/bug26219_1 @@ -33,15 +33,15 @@ unifysamedom p p set nbshapes_after_simplify " Number of shapes in shape - VERTEX : 130 - EDGE : 194 + VERTEX : 128 + EDGE : 192 WIRE : 66 FACE : 66 SHELL : 1 SOLID : 1 COMPSOLID : 0 COMPOUND : 1 - SHAPE : 459 + SHAPE : 455 " checknbshapes p -ref ${nbshapes_after_simplify} -t -m "result after attempt to simplify the model" diff --git a/tests/bugs/modalg_6/bug27085_1 b/tests/bugs/modalg_6/bug27085_1 new file mode 100644 index 0000000000..b2a55994ee --- /dev/null +++ b/tests/bugs/modalg_6/bug27085_1 @@ -0,0 +1,28 @@ +puts "============" +puts "OCC27085" +puts "============" +puts "" +############################### +## ShapeUpgrade_UnifySameDomain very large performance difference for seemingly similar shapes +############################### + +restore [locate_data_file bug27085_fused_primitive.fast.brep] fp + +dchrono h reset +dchrono h start + +unifysamedom res fp + +dchrono h stop +set q [dchrono h show] + +regexp {CPU user time: ([-0-9.+eE]+) seconds} $q full z +puts "$z" + +set max_time 5 + +if { $z > ${max_time} } { + puts "Elapsed time is more than ${max_time} seconds - Faulty" +} else { + puts "Elapsed time is less than ${max_time} seconds - OK" +} diff --git a/tests/bugs/modalg_6/bug27085_2 b/tests/bugs/modalg_6/bug27085_2 new file mode 100644 index 0000000000..1809422ae8 --- /dev/null +++ b/tests/bugs/modalg_6/bug27085_2 @@ -0,0 +1,28 @@ +puts "============" +puts "OCC27085" +puts "============" +puts "" +############################### +## ShapeUpgrade_UnifySameDomain very large performance difference for seemingly similar shapes +############################### + +restore [locate_data_file bug27085_fused_primitive.slow.brep] sp + +dchrono h reset +dchrono h start + +unifysamedom res sp + +dchrono h stop +set q [dchrono h show] + +regexp {CPU user time: ([-0-9.+eE]+) seconds} $q full z +puts "$z" + +set max_time 8 + +if { $z > ${max_time} } { + puts "Elapsed time is more than ${max_time} seconds - Faulty" +} else { + puts "Elapsed time is less than ${max_time} seconds - OK" +}