]> OCCT Git - occt.git/commitdiff
0032424: [Regression] Mesh - Slow triangulation of a simple shape.
authoroan <oan@opencascade.com>
Thu, 8 Jul 2021 10:07:05 +0000 (13:07 +0300)
committerjfa <jfa@opencascade.com>
Mon, 30 Aug 2021 08:39:36 +0000 (11:39 +0300)
Check links produced by splitting of an initial link by the middle point for MinSize requirement.

Conflicts:
tests/bugs/mesh/bug30008_1
tests/bugs/moddata_2/bug428
tests/hlr/poly_hlr/C14

20 files changed:
src/BRepMesh/BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx
tests/bugs/iges/buc60820_2
tests/bugs/mesh/bug23513
tests/bugs/mesh/bug27384_2
tests/bugs/mesh/bug30008_1
tests/bugs/mesh/bug31251
tests/bugs/mesh/bug32424 [new file with mode: 0644]
tests/bugs/moddata_2/bug428
tests/hlr/poly_hlr/C13
tests/hlr/poly_hlr/C14
tests/hlr/poly_hlr/C4
tests/hlr/poly_hlr/bug23625_2
tests/hlr/poly_hlr/bug23625_3
tests/hlr/poly_hlr/bug27979_3
tests/hlr/poly_hlr/bug27979_5
tests/hlr/poly_hlr/bug27979_7
tests/perf/mesh/bug26889_1
tests/perf/mesh/bug26889_2
tests/perf/mesh/bug26889_3
tests/perf/mesh/bug26965

index cc496f20ca089ecbfa9b0756e5218ab540d74a6a..5f59ab9c464c86e696e10d93d39d033a5e8870da 100644 (file)
@@ -34,6 +34,7 @@ public:
   //! Constructor.
   BRepMesh_DelaunayDeflectionControlMeshAlgo()
     : myMaxSqDeflection(-1.),
+      mySqMinSize(-1.),
       myIsAllDegenerated(Standard_False),
       myCircles(NULL)
   {
@@ -77,10 +78,11 @@ protected:
     Handle(NCollection_IncAllocator) aTmpAlloc =
       new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE);
 
+    mySqMinSize    = this->getParameters().MinSize * this->getParameters().MinSize;
     myCouplesMap   = new IMeshData::MapOfOrientedEdges(3 * this->getStructure()->ElementsOfDomain().Extent(), aTmpAlloc);
     myControlNodes = new IMeshData::ListOfPnt2d(aTmpAlloc);
     myCircles      = &theMesher.Circles();
-
+    
     const Standard_Integer aIterationsNb = 11;
     Standard_Boolean isInserted = Standard_True;
     Message_ProgressScope aPS(theRange, "Iteration", aIterationsNb);
@@ -339,22 +341,38 @@ private:
         if (!usePoint (aMidPnt2d, LineDeviation (theNodesInfo[i].Point, 
                                                  theNodesInfo[j].Point)))
         {
-          if (!checkLinkEndsForAngularDeviation(theNodesInfo[i], 
-                                                theNodesInfo[j],
-                                                aMidPnt2d))
+          if (!rejectSplitLinksForMinSize (theNodesInfo[i],
+                                           theNodesInfo[j],
+                                           aMidPnt2d))
           {
-            myControlNodes->Append(aMidPnt2d);
+            if (!checkLinkEndsForAngularDeviation (theNodesInfo[i],
+                                                   theNodesInfo[j],
+                                                   aMidPnt2d))
+            {
+              myControlNodes->Append(aMidPnt2d);
+            }
           }
         }
       }
     }
   }
 
+  //! Checks that two links produced as the result of a split of 
+  //! the given link by the middle point fit MinSize requirement.
+  Standard_Boolean rejectSplitLinksForMinSize (const TriangleNodeInfo& theNodeInfo1,
+                                               const TriangleNodeInfo& theNodeInfo2,
+                                               const gp_XY&            theMidPoint)
+  {
+    const gp_Pnt aPnt = getPoint3d (theMidPoint);
+    return ((theNodeInfo1.Point - aPnt.XYZ()).SquareModulus() < mySqMinSize ||
+            (theNodeInfo2.Point - aPnt.XYZ()).SquareModulus() < mySqMinSize);
+  }
+
   //! Checks the given point (located between the given nodes)
   //! for specified angular deviation.
   Standard_Boolean checkLinkEndsForAngularDeviation(const TriangleNodeInfo& theNodeInfo1,
                                                     const TriangleNodeInfo& theNodeInfo2,
-                                                    const gp_XY& /*theMidPoint*/)
+                                                    const gp_XY&          /*theMidPoint*/)
   {
     gp_Dir aNorm1, aNorm2;
     const Handle(Geom_Surface)& aSurf = 
@@ -365,7 +383,9 @@ private:
     {
       Standard_Real anAngle = aNorm1.Angle(aNorm2);
       if (anAngle > this->getParameters().AngleInterior)
+      {
         return Standard_False;
+      }
     }
 #if 0
     else if (GeomLib::NormEstim(aSurf, theMidPoint, Precision::Confusion(), aNorm1) != 0)
@@ -381,6 +401,14 @@ private:
     return Standard_True;
   }
 
+  //! Returns 3d point corresponding to the given one in 2d space.
+  gp_Pnt getPoint3d (const gp_XY& thePnt2d)
+  {
+    gp_Pnt aPnt;
+    this->getDFace()->GetSurface()->D0(thePnt2d.X(), thePnt2d.Y(), aPnt);
+    return aPnt;
+  }
+
   //! Computes deflection of the given point and caches it for
   //! insertion in case if it overflows deflection.
   //! @return True if point has been cached for insertion.
@@ -389,8 +417,7 @@ private:
     const gp_XY&             thePnt2d,
     const DeflectionFunctor& theDeflectionFunctor)
   {
-    gp_Pnt aPnt;
-    this->getDFace()->GetSurface()->D0(thePnt2d.X(), thePnt2d.Y(), aPnt);
+    const gp_Pnt aPnt = getPoint3d (thePnt2d);
     if (!checkDeflectionOfPointAndUpdateCache(thePnt2d, aPnt, theDeflectionFunctor.SquareDeviation(aPnt)))
     {
       myControlNodes->Append(thePnt2d);
@@ -422,14 +449,14 @@ private:
     return rejectByMinSize(thePnt2d, thePnt3d);
   }
 
-  //! Checks the given node for 
+  //! Checks distance between the given node and nodes of triangles 
+  //! shot by it for MinSize criteria.
+  //! This check is expected to roughly estimate and prevent 
+  //! generation of triangles with sides smaller than MinSize.
   Standard_Boolean rejectByMinSize(
     const gp_XY&  thePnt2d,
     const gp_Pnt& thePnt3d)
   {
-    const Standard_Real aSqMinSize = 
-      this->getParameters().MinSize * this->getParameters().MinSize;
-
     IMeshData::MapOfInteger aUsedNodes;
     IMeshData::ListOfInteger& aCirclesList =
       const_cast<BRepMesh_CircleTool&>(*myCircles).Select(
@@ -451,7 +478,7 @@ private:
           const BRepMesh_Vertex& aVertex = this->getStructure()->GetNode(aNodes[i]);
           const gp_Pnt& aPoint = this->getNodesMap()->Value(aVertex.Location3d());
 
-          if (thePnt3d.SquareDistance(aPoint) < aSqMinSize)
+          if (thePnt3d.SquareDistance(aPoint) < mySqMinSize)
           {
             return Standard_True;
           }
@@ -464,6 +491,7 @@ private:
 
 private:
   Standard_Real                         myMaxSqDeflection;
+  Standard_Real                         mySqMinSize;
   Standard_Boolean                      myIsAllDegenerated;
   Handle(IMeshData::MapOfOrientedEdges) myCouplesMap;
   Handle(IMeshData::ListOfPnt2d)        myControlNodes;
index af459d8f62476b4281d40aec2490742edef18b8f..2ceebe03c0c7a779480bff22141fc64f588483dd 100755 (executable)
@@ -13,6 +13,6 @@ vdisplay result
 vsetdispmode result 1
 vfit
 
-checktrinfo result -tri 244 -nod 237
+checktrinfo result -tri 200 -nod 215
 
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index ab612f14f39a3eee62530c31d8a106c5478a6cc9..fa1c1aa12f03be56ee7404165ca50ecd5a6164f9 100644 (file)
@@ -12,7 +12,7 @@ vfit
  
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
 
-checktrinfo result -tri 323820 -nod 161951 -defl 0.00096399964870812682
+checktrinfo result -tri 62936 -nod 31509 -defl 0.00096399964870812682
 
 set log [tricheck result]
 if { [llength $log] != 0 } {
index 84ab562c6a71071c5ce2143d6d8e57caa4ec763f..e80517c6e09223b614a82ea1c3d6ef89dd7dd69a 100644 (file)
@@ -17,7 +17,7 @@ vdefaults -autoTriang 0
 vdisplay result
 vfit
 
-set rel_tol 0.035439456401028344
+set rel_tol 0.6928018366802983
 set max_rel_tol_diff 0.001
 set area_eps 1
 
index 1beebc5f401fcfed035b7bf083f7d2d84a7fd2b4..1143910dad6c137e9df795dae2554758b9d80831 100644 (file)
@@ -12,6 +12,6 @@ vdisplay result
 vviewparams -scale 8.46292 -proj 0.653203 -0.644806 0.396926 -up -0.0109833 0.51609 0.856464 -at 347.559 1026.89 219.262 -eye 2080.75 -684.022 1272.45
 
 tricheck result
-checktrinfo result -tri 11826 -nod 7310 -defl 7.6167024939147652
+checktrinfo result -tri 6978 -nod 4890 -defl 7.6167024939147652
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 242d2e13e112cfdd69aa5ea9ae3039c25e07593f..2ef84b14ebcbff65cca856f99ac1e73f9ed92cb7 100644 (file)
@@ -15,7 +15,7 @@ vdefaults -autoTriang 0
 
 tclean result
 incmesh result 0.004 -a 14
-checktrinfo result -tri 70560 -nod 39946 -defl 0.22962869401103247
+checktrinfo result -tri 70556 -nod 39944 -defl 0.22962869401103247
 
 vdisplay result -redisplay
 vfit
@@ -23,7 +23,7 @@ checkview -screenshot -3d -path ${imagedir}/${test_image}_default.png
 
 tclean result
 incmesh result 0.004 -a 14 -force_face_def
-checktrinfo result -tri 292560 -nod 150946 -defl 0.04579460790575135
+checktrinfo result -tri 292556 -nod 150944 -defl 0.04579460790575135
 
 vdisplay result -redisplay
 vfit
diff --git a/tests/bugs/mesh/bug32424 b/tests/bugs/mesh/bug32424
new file mode 100644 (file)
index 0000000..f5e1230
--- /dev/null
@@ -0,0 +1,18 @@
+puts "======="
+puts "0032424: Mesh - Slow triangulation of a simple shape."
+puts "======="
+puts ""
+cpulimit 3
+
+restore [locate_data_file bug32424.brep] result
+
+incmesh result 0.17 -a 20
+
+checktrinfo result -tri 16168 -nod 8206
+
+vinit
+vdefaults -autoTriang 0
+vsetdispmode 1
+vdisplay result
+vfit
+checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 7140f02607083b874a9a53281bbba71141e42fab..c1a4c9d0df07426ac798762dc01af6a713bbbc36 100755 (executable)
@@ -19,5 +19,5 @@ isos result 0
 triangles result
 fit
 
-checktrinfo result -tri 10924 -nod 7869
+checktrinfo result -tri 7863 -nod 6342
 checkview -screenshot -2d -path ${imagedir}/${test_image}_axo.png
index 255ff26e64a2a8b4bef21449eebfa190dabbe7f2..3b9c705210fe70b6662ec6f51a86fc99cfa73010 100644 (file)
@@ -1,5 +1,5 @@
 set viewname "vright"
-set length 9547.11
+set length 9546.99
 
 testreadstep [locate_data_file bug27341_Assembly_ABS_1_CAD.stp] a
 COMPUTE_HLR $viewname $algotype
index 857e48713261f56e74fb24d355937e9b4cdac929..5fde7169f647d9329895c94dbceca2436190fe5b 100644 (file)
@@ -1,4 +1,4 @@
-puts "TODO OCC30286 ALL: Error : The length of result shape is 5496.05, expected 5934.34"
+puts "TODO OCC30286 ALL: Error : The length of result shape is 5499.*, expected 5934.34"
 
 set viewname "vright"
 set length 5934.34
index 38b7efc96651cb5e534ecdc42dd4de066aa13836..be7953c784eceba3bd51ad99722a6f93deeed57d 100644 (file)
@@ -1,4 +1,4 @@
-puts "TODO OCC30286 ALL: Error : The length of result shape is 2707.33, expected 2765.47"
+puts "TODO OCC30286 ALL: Error : The length of result shape is 2705.91, expected 2765.47"
 
 set viewname "vright"
 set length 2765.47
index 568c972e7a464efe4b88726469cd6f7f959e0948..10b31c6352a95544e7ccba7ceca1648f4b85afca 100644 (file)
@@ -4,7 +4,7 @@ puts "============"
 puts ""
 
 set viewname "vfront"
-set length 28991.6
+set length 29113.3
 
 restore [locate_data_file bug23625_a2.brep] a
 COMPUTE_HLR $viewname $algotype
index 697e06a3965d1d49010ca29e6be620190157891f..264015f5c83580f9283a4dbb44a8d61824731e43 100644 (file)
@@ -4,7 +4,7 @@ puts "============"
 puts ""
 
 set viewname "vtop"
-set length 19620.9
+set length 19604.4
 
 restore [locate_data_file bug23625_a3.brep] a
 COMPUTE_HLR $viewname $algotype
index 022d82b732f44a6aa6bb80711728df6a2c3e98d7..865d4d5064e9f0f751c2f3d8744e15aba15a1c92 100644 (file)
@@ -1,4 +1,4 @@
-puts "TODO OCC30286 ALL: Error : The length of result shape is 4.6692, expected 4."
+puts "TODO OCC30286 ALL: Error : The length of result shape is 4.*, expected 4."
 
 puts "========================================================================"
 puts "OCC27979: Parasolid converted BREP shows weird lines on hidden line Algo"
index 052c5adc7834f8d0de94898748d04b71171d7eb5..5b324fcf4e8d9eabf0c4a35154d0d48191a83ef8 100644 (file)
@@ -1,4 +1,4 @@
-puts "TODO OCC30286 ALL: Error : The length of result shape is 4.15911, expected 4."
+puts "TODO OCC30286 ALL: Error : The length of result shape is 4.*, expected 4."
 
 puts "========================================================================"
 puts "OCC27979: Parasolid converted BREP shows weird lines on hidden line Algo"
index a59e3a80cdde3a77048e004f827d6af7a9e8ee63..0a25d5b41782d05c3104c552ad50302652a1b338 100644 (file)
@@ -1,4 +1,4 @@
-puts "TODO OCC30286 ALL: Error : The length of result shape is 3.2349, expected 3."
+puts "TODO OCC30286 ALL: Error : The length of result shape is 3.*, expected 3."
 
 puts "========================================================================"
 puts "OCC27979: Parasolid converted BREP shows weird lines on hidden line Algo"
index 4413cc1d5041f949c2aba5985ff6c51ab30036b4..10b03c6a373c750044859235d050799fee974ffa 100644 (file)
@@ -11,7 +11,7 @@ dchrono t restart
 incmesh a_1 0.01 1
 dchrono t stop counter incmesh
 
-checktrinfo a_1 -tri 743149 -nod 372395 -defl 0.081028355715069861
+checktrinfo a_1 -tri 525271 -nod 263456 -defl 0.081028355715069861
 
 set log [tricheck a_1]
 if { [llength $log] != 0 } {
index 658c263edaf6ab976cc202843a711da0e464863c..878f636c123c758763d90528e39d20689023f6b8 100644 (file)
@@ -11,7 +11,7 @@ dchrono t restart
 incmesh a_1 0.1 1
 dchrono t stop counter incmesh
 
-checktrinfo a_1 -tri 182273 -nod 91484 -defl 0.11671770612283024
+checktrinfo a_1 -tri 68779 -nod 34737 -defl 0.11671770612283024
 
 set log [tricheck a_1]
 if { [llength $log] != 0 } {
index 7810bcc210f827ed2ded41229c9318b71c79e6e6..d4525bb9b3e9ed29e27c701e0c4f91d6d2244c7d 100644 (file)
@@ -11,7 +11,7 @@ dchrono t restart
 incmesh a_1 1.0 1
 dchrono t stop counter incmesh
 
-checktrinfo a_1 -tri 73119 -nod 36828 -defl 1.0
+checktrinfo a_1 -tri 12469 -nod 6503 -defl 1.0
 
 set log [tricheck a_1]
 if { [llength $log] != 0 } {
index 0b08bbfac635611117160a0e1cad8379eecc5079..8203f5ed545b920dcb33e9e2b0312593bce3b495 100644 (file)
@@ -16,4 +16,4 @@ dchrono h
 vfit
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
 
-checktrinfo a -tri 217070 -nod 108740 -defl 0.098772787476728782
\ No newline at end of file
+checktrinfo a -tri 14764 -nod 7587 -defl 0.098772787476728782
\ No newline at end of file