0027085: ShapeUpgrade_UnifySameDomain very large performance difference for seemingly...
authorisn <isn@opencascade.com>
Fri, 15 Jan 2016 13:22:32 +0000 (16:22 +0300)
committerabv <abv@opencascade.com>
Thu, 21 Jan 2016 12:50:28 +0000 (15:50 +0300)
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.

src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx
tests/bugs/heal/bug26219_1
tests/bugs/modalg_6/bug27085_1 [new file with mode: 0644]
tests/bugs/modalg_6/bug27085_2 [new file with mode: 0644]

index ec8e54e..51e6f55 100644 (file)
@@ -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)
index 41306b2..4f64225 100644 (file)
@@ -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 (file)
index 0000000..b2a5599
--- /dev/null
@@ -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 (file)
index 0000000..1809422
--- /dev/null
@@ -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"
+}