]> OCCT Git - occt-copy.git/commitdiff
0027085: ShapeUpgrade_UnifySameDomain very large performance difference for seemingly...
authorisn <isn@opencascade.com>
Fri, 15 Jan 2016 13:22:32 +0000 (16:22 +0300)
committerisn <isn@opencascade.com>
Tue, 19 Jan 2016 13:23:09 +0000 (16:23 +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.

Conflicts:
tests/bugs/heal/bug26219_1

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

index 89017ca4f37f3826ff60d8c1d3a33003b9d23b52..5d0dceb01e1176c2332d59c5bbc245ee000f4ecf 100644 (file)
@@ -1127,6 +1127,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) {
 
@@ -1174,7 +1175,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;
@@ -1474,6 +1474,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)));
@@ -1488,7 +1497,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
new file mode 100644 (file)
index 0000000..4f64225
--- /dev/null
@@ -0,0 +1,48 @@
+puts "========================"
+puts " OCC26219"
+puts "========================"
+puts ""
+###########################################################
+## ShapeUpgrade_UnifySameDomain fails with StdFail_NotDone exception
+###########################################################
+
+restore [locate_data_file bug26219_unifysamedomain.valid_input.brep] p
+
+# -----------------------------------------------------------------------------
+# Attempt to simplify the model
+# -----------------------------------------------------------------------------
+
+set nbshapes_before_simplify "
+Number of shapes in shape
+ VERTEX    : 200
+ EDGE      : 348
+ WIRE      : 150
+ FACE      : 150
+ SHELL     : 1
+ SOLID     : 1
+ COMPSOLID : 0
+ COMPOUND  : 1
+ SHAPE     : 851
+"
+checknbshapes p -ref ${nbshapes_before_simplify} -t -m "result before attempt to simplify the model"
+
+axo; donly p; fit
+xwd ${imagedir}/${casename}_1.png
+
+unifysamedom p p
+
+set nbshapes_after_simplify "
+Number of shapes in shape
+ VERTEX    : 128
+ EDGE      : 192
+ WIRE      : 66
+ FACE      : 66
+ SHELL     : 1
+ SOLID     : 1
+ COMPSOLID : 0
+ COMPOUND  : 1
+ SHAPE     : 455
+"
+checknbshapes p -ref ${nbshapes_after_simplify} -t -m "result after attempt to simplify the model"
+
+xwd ${imagedir}/${casename}_2.png
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"
+}