]> OCCT Git - occt.git/commitdiff
0024418: Modeling Algorithms - Wrong section curves when intersecting analytical...
authorknosulko <knosulko@opencascade.com>
Mon, 15 Nov 2021 14:02:03 +0000 (17:02 +0300)
committersmoskvin <smoskvin@opencascade.com>
Tue, 22 Feb 2022 17:07:12 +0000 (20:07 +0300)
IntPatch_ALineToWLine.cxx - setting minimal number of points in a WLine depending on step size
IntPatch_WLineTool.cxx - fix WLines connecting check condition
test cases has been changed according to new behavior

16 files changed:
src/IntPatch/IntPatch_ALineToWLine.cxx
src/IntPatch/IntPatch_WLineTool.cxx
tests/bugs/modalg_1/bug10606_1
tests/bugs/modalg_1/bug10606_2
tests/bugs/modalg_1/bug10606_3
tests/bugs/modalg_1/bug10606_4
tests/bugs/modalg_1/bug10606_5
tests/bugs/modalg_1/bug10842_5
tests/bugs/modalg_2/bug20964_1
tests/bugs/modalg_2/bug20964_2
tests/bugs/modalg_2/bug20964_3
tests/bugs/modalg_2/bug20964_4
tests/bugs/modalg_2/bug20964_5
tests/bugs/modalg_5/bug25715_3
tests/bugs/modalg_6/bug28626_3
tests/lowalgos/intss/bug24418_1

index 59cbff38ae13c6085a1c745781980df17eb395a1..8d9480f3b0abd7b081ef3f5330004181ac170fc2 100644 (file)
@@ -433,10 +433,32 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
     if(aStep < Epsilon(theLPar))
       break;
 
+    Standard_Boolean isStepReduced = Standard_False;
+    Standard_Real aLPar = theLPar;
+
+    for (Standard_Integer i = aVertexParams.Lower(); i <= aVertexParams.Upper(); i++)
+    {
+      if (hasVertexBeenChecked(i))
+        continue;
+
+      aLPar = aVertexParams(i);
+      if (Abs(aLPar - aParameter) < aPrmTol)
+        continue;
+
+      break;
+    }
+
+    if ((aStep - (aLPar - aParameter) > aPrmTol) &&
+        (Abs(aLPar - aParameter) > aPrmTol))
+    {
+      aStep = Max((aLPar - aParameter) / 5, 1.e-5); 
+      isStepReduced = Standard_True;
+    }
+
     Standard_Integer aNewVertID = 0;
     aLinOn2S = new IntSurf_LineOn2S;
     
-    const Standard_Real aStepMin = 0.1*aStep, aStepMax = 10.0*aStep;
+    Standard_Real aStepMin = 0.1 * aStep, aStepMax = 10.0 * aStep;
 
     Standard_Boolean isLast = Standard_False;
     Standard_Real aPrevParam = aParameter;
@@ -586,8 +608,12 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
       {
         if (isPointValid)
         {
-          StepComputing(theALine, aPOn2S, theLPar, aParameter, aTgMagn,
-                        aStepMin, aStepMax, myTol3D, aStep);
+          if (!isStepReduced)
+          {
+            StepComputing(theALine, aPOn2S, theLPar, aParameter, aTgMagn,
+                          aStepMin, aStepMax, myTol3D, aStep);
+          }
+
           AddPointIntoLine(aLinOn2S, anArrPeriods, aPOn2S);
           aPrevLPoint = aPOn2S;
         }
@@ -694,6 +720,38 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
 
       if ((aPrePointExist != IntPatch_SPntNone) && (aLinOn2S->NbPoints() > 1))
         break;
+
+      if (isStepReduced)
+      {
+        isStepReduced = Standard_False;
+
+        aStep = (theLPar - aParameter) / (Standard_Real)(myNbPointsInWline - 1);
+        if(aStep < Epsilon(theLPar))
+          break;
+  
+        aLPar = aVertexParams(aNbVert);
+        for (Standard_Integer i = aVertexParams.Lower(); i <= aVertexParams.Upper(); i++)
+        {
+          if (hasVertexBeenChecked(i))
+            continue;
+  
+          aLPar = aVertexParams(i);
+          if (Abs(aLPar - aParameter) < aPrmTol)
+            continue;
+  
+          break;
+        }
+
+        if ((aStep - (aLPar - aParameter) > aPrmTol) &&
+            (Abs(aLPar - aParameter) > aPrmTol))
+        {
+          aStep = Max((aLPar - aParameter) / 5, 1.e-5);
+          isStepReduced = Standard_True;
+        }
+  
+        aStepMin = 0.1 * aStep;
+        aStepMax = 10.0 * aStep;
+      }
     }//for(; !isLast; aParameter += aStep)
 
     if(aLinOn2S->NbPoints() < 2)
index 5e9e0103cc4a50c3afdc6586b87fd94ae733de9c..9132bf33e04f397c36a8db3052a94f02e19fb22c 100644 (file)
@@ -1717,6 +1717,38 @@ void IntPatch_WLineTool::JoinWLines(IntPatch_SequenceOfLine& theSlin,
   }
 }
 
+//=======================================================================
+//function : IsNeedSkipWL
+//purpose  : Detect is WLine need to skip.
+//=======================================================================
+static Standard_Boolean IsNeedSkipWL(const Handle(IntPatch_WLine)& theWL,
+                                     const Bnd_Box2d& theBoxS1,
+                                     const Bnd_Box2d& theBoxS2,
+                                     const Standard_Real* const theArrPeriods)
+{
+  Standard_Real aFirstp, aLastp;
+  Standard_Integer aNbVtx = theWL->NbVertex();
+  Standard_Boolean isNeedSkip = Standard_True;
+
+  for (Standard_Integer i = 1; i < aNbVtx; i++) {
+    aFirstp = theWL->Vertex (i).ParameterOnLine();
+    aLastp  = theWL->Vertex (i + 1).ParameterOnLine();
+
+    Standard_Real aU1, aV1, aU2, aV2;
+    const Standard_Integer pmid = (Standard_Integer)((aFirstp + aLastp) / 2);
+    const IntSurf_PntOn2S& aPmid = theWL->Point (pmid);
+    aPmid.Parameters (aU1, aV1, aU2, aV2);
+
+    if (!IsOutOfDomain (theBoxS1, theBoxS2, aPmid, theArrPeriods))
+    {
+      isNeedSkip = Standard_False;
+      break;
+    }
+  }
+
+  return isNeedSkip;
+}
+
 //=======================================================================
 //function : ExtendTwoWLines
 //purpose  : Performs extending theWLine1 and theWLine2 through their
@@ -1737,8 +1769,17 @@ void IntPatch_WLineTool::
 
   gp_Vec aVec1, aVec2, aVec3;
 
+  unsigned int hasBeenJoinedCounter = 0;
+
   for(Standard_Integer aNumOfLine1 = 1; aNumOfLine1 <= theSlin.Length(); aNumOfLine1++)
   {
+    if (hasBeenJoinedCounter > 0)
+    {
+      aNumOfLine1--;
+    }
+
+    hasBeenJoinedCounter = 0;
+
     Handle(IntPatch_WLine) aWLine1 (Handle(IntPatch_WLine)::
                                     DownCast(theSlin.Value(aNumOfLine1)));
 
@@ -1761,6 +1802,11 @@ void IntPatch_WLineTool::
     const IntSurf_PntOn2S& aPntLWL1 = aWLine1->Point(aNbPntsWL1);
     const IntSurf_PntOn2S& aPntLm1WL1 = aWLine1->Point(aNbPntsWL1-1);
 
+    if (IsNeedSkipWL(aWLine1, theBoxS1, theBoxS2, theArrPeriods))
+    {
+      continue;
+    }
+
     //Enable/Disable of some ckeck. Bit-mask is used for it.
     //E.g. if 1st point of aWLine1 matches with
     //1st point of aWLine2 then we do not need in check
@@ -1781,16 +1827,24 @@ void IntPatch_WLineTool::
       const IntSurf_PntOn2S& aPntFWL2 = aWLine2->Point(1);
       const IntSurf_PntOn2S& aPntLWL2 = aWLine2->Point(aWLine2->NbPnts());
 
-      if( aPntFWL1.IsSame(aPntFWL2, theToler3D) ||
-          aPntFWL1.IsSame(aPntLWL2, theToler3D) )
+      if (!(aPntFWL1.IsSame(aPntFWL2, theToler3D, Precision::PConfusion())) &&
+          !(aPntFWL1.IsSame(aPntLWL2, theToler3D, Precision::PConfusion())))
       {
-        aCheckResult |= IntPatchWT_DisFirstFirst | IntPatchWT_DisFirstLast;
+        if (aPntFWL1.IsSame(aPntFWL2, theToler3D) ||
+            aPntFWL1.IsSame(aPntLWL2, theToler3D))
+        {
+          aCheckResult |= IntPatchWT_DisFirstFirst | IntPatchWT_DisFirstLast;
+        }
       }
 
-      if( aPntLWL1.IsSame(aPntFWL2, theToler3D) ||
-          aPntLWL1.IsSame(aPntFWL2, theToler3D))
+      if (!(aPntLWL1.IsSame(aPntFWL2, theToler3D, Precision::PConfusion())) &&
+          !(aPntLWL1.IsSame(aPntLWL2, theToler3D, Precision::PConfusion())))
       {
-        aCheckResult |= IntPatchWT_DisLastFirst | IntPatchWT_DisLastLast;
+        if (aPntLWL1.IsSame(aPntFWL2, theToler3D) ||
+            aPntLWL1.IsSame(aPntLWL2, theToler3D))
+        {
+          aCheckResult |= IntPatchWT_DisLastFirst | IntPatchWT_DisLastLast;
+        }
       }
 
       if (!theListOfCriticalPoints.IsEmpty())
@@ -1862,8 +1916,13 @@ void IntPatch_WLineTool::
 
       const IntSurf_PntOn2S& aPntLWL2 = aWLine2->Point(aNbPntsWL2);
       const IntSurf_PntOn2S& aPntLm1WL2 = aWLine2->Point(aNbPntsWL2-1);
-      
-      //if(!(aCheckResult & IntPatchWT_DisFirstFirst))
+
+      if (IsNeedSkipWL(aWLine2, theBoxS1, theBoxS2, theArrPeriods))
+      {
+        continue;
+      }
+
+      if(!(aCheckResult & IntPatchWT_DisFirstFirst))
       {// First/First
         aVec1.SetXYZ(aPntFp1WL1.Value().XYZ() - aPntFWL1.Value().XYZ());
         aVec2.SetXYZ(aPntFWL2.Value().XYZ() - aPntFp1WL2.Value().XYZ());
@@ -1909,6 +1968,7 @@ void IntPatch_WLineTool::
 
       if(hasBeenJoined)
       {
+        hasBeenJoinedCounter++;
         theSlin.Remove(aNumOfLine2);
         aNumOfLine2--;
       }
index b54e243bfb9c49f83f41860bff58c40a295b5802..d6b7c4e0b964deaeed5b11f7f8c347bfc0d7fa15 100755 (executable)
@@ -22,5 +22,5 @@ checkprops result -s 66.672
 checkshape result
 
 # Analysis of "nbshapes res"
-checknbshapes result -vertex 6 -edge 8 -wire 2 -face 2 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 21
+checknbshapes result -vertex 5 -edge 7 -wire 2 -face 2 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 19
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index fb9d06c59ef008af88314dd88635a952a2af7608..a8a1b8e52e65f544295efb38abb4c623c4fa2950 100755 (executable)
@@ -22,5 +22,5 @@ checkprops result -s 1450.22
 checkshape result
 
 # Analysis of "nbshapes res"
-checknbshapes result -vertex 6 -edge 8 -wire 4 -face 4 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 25
+checknbshapes result -vertex 5 -edge 7 -wire 4 -face 4 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 23
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index e3b85ede1cd4a49786316f8fc6412551aaa5fedc..e93912ca4121047a6c9c5b1421cbb59eff1b676e 100755 (executable)
@@ -22,5 +22,5 @@ checkprops result -s 761.355
 checkshape result
 
 # Analysis of "nbshapes res"
-checknbshapes result -vertex 6 -edge 8 -wire 3 -face 3 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 23
+checknbshapes result -vertex 5 -edge 7 -wire 3 -face 3 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 21
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index 4e482e6203aabc8529b4838ffec81029f64598e0..fd7e0db5dd9f5b4fb30e06b8bbca538f7bd068a3 100755 (executable)
@@ -22,5 +22,5 @@ checkprops result -s 755.54
 checkshape result
 
 # Analysis of "nbshapes res"
-checknbshapes result -vertex 6 -edge 8 -wire 3 -face 3 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 23
+checknbshapes result -vertex 5 -edge 7 -wire 3 -face 3 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 21
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index 93e561ba854ad81ee593e94c7333f3d94b2e2541..494b5a317f6f85aa33e57b0010b73b825c374763 100755 (executable)
@@ -22,5 +22,5 @@ checkprops result -l 18.3861
 checkshape result
 checksection result
 # Analysis of "nbshapes res"
-checknbshapes result -vertex 4 -edge 4 -wire 0 -face 0 -shell 0 -solid 0 -compsolid 0 -compound 1 -shape 9
+checknbshapes result -vertex 3 -edge 3 -wire 0 -face 0 -shell 0 -solid 0 -compsolid 0 -compound 1 -shape 7
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index 26ec4e68eea1b143e447bb6a3bada0b0635f3022..6257e9a92a58fe17a9512b60ec07dd322a2347c9 100755 (executable)
@@ -22,5 +22,5 @@ checkprops result -l 122.816
 checkshape result
 checksection result
 # Analysis of "nbshapes res"
-checknbshapes result -vertex 6 -edge 6 -wire 0 -face 0 -shell 0 -solid 0 -compsolid 0 -compound 1 -shape 13
+checknbshapes result -vertex 5 -edge 5 -wire 0 -face 0 -shell 0 -solid 0 -compsolid 0 -compound 1 -shape 11
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index 5498d877c72b74ce76d429f29dd0e7a6eec714b2..defacfb9abf6ec76641a1b46ecf8fd98458f3c89 100755 (executable)
@@ -33,6 +33,6 @@ Number of shapes in .*
 "
 
 checknbshapes result -ref $NbShapesRef
-checkmaxtol result -ref 0.013928665225777443
+checkmaxtol result -ref 2.0849512334752456e-05
 
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index 3b80f1addbe2bdeb1da780095b9b473f2e1d28ac..e21e43dab477f6105f7e2b6e4aa1dc5b48c61cbc 100755 (executable)
@@ -33,7 +33,7 @@ Number of shapes in .*
 
 checknbshapes result -ref $NbShapesRef
 
-checkmaxtol result -ref 0.013928665225777443
+checkmaxtol result -ref 2.0849512334752456e-05
 
 checkview -display result -2d -path ${imagedir}/${test_image}_axo.png
 
index 54e744cd786a09d7ea1c2698380cbff389a065d7..960c5b9cb17850808c7b6df923c9e4c9f75026f8 100755 (executable)
@@ -33,7 +33,7 @@ Number of shapes in .*
 
 checknbshapes result -ref $NbShapesRef
 
-checkmaxtol result -ref 0.013928665225777443
+checkmaxtol result -ref 2.0849512334752456e-05
 
 checkview -display result -2d -path ${imagedir}/${test_image}_axo.png
 
index d803d4e56b8fc3b8f8020e6898418da9448ae837..9ad925f323a9a7b522edde9c68add48c21170754 100755 (executable)
@@ -32,7 +32,7 @@ Number of shapes in .*
 "
 
 checknbshapes result -ref $NbShapesRef
-checkmaxtol result -ref 0.013928665225777443
+checkmaxtol result -ref 2.0849512334752456e-05
 
 checkview -display result -2d -path ${imagedir}/${test_image}_axo.png
 
index 4601eaf834b69f01d5e8ff8af36b9b5b2687d162..11abf56981af72ee3a8edfc04596a5aa670da0ed 100755 (executable)
@@ -33,7 +33,7 @@ Number of shapes in .*
 
 checknbshapes result -ref $NbShapesRef
 
-checkmaxtol result -ref 0.013928665225777443
+checkmaxtol result -ref 2.0849512334752456e-05
 
 checkview -display result -2d -path ${imagedir}/${test_image}_axo.png
 
index f48acb8d9feda293ed588f24b7aeb4156a604ba5..851f92dedd7bf2c2771449a9f29957fa7998953b 100644 (file)
@@ -1,4 +1,3 @@
-puts "TODO OCC24418 ALL: Error :  is WRONG because number of"
 puts "=========="
 puts "OCC25715"
 puts "=========="
@@ -11,6 +10,7 @@ puts ""
 restore [locate_data_file bug25715_p02c3s1.brep] s1
 restore [locate_data_file bug25715_p02c3s3.brep] s3
 bfuse result s1 s3
+unifysamedom result result +b
 
-checknbshapes result -vertex 8 -edge 14 -wire 6 -face 5 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 36
+checknbshapes result -vertex 6 -edge 9 -wire 5 -face 4 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 27
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index 893aa7d0f834d52da639f9cba34c7e75f283e239..1a25d0ec8c9d99692b5b10148eaf6b50275341c0 100644 (file)
@@ -20,7 +20,7 @@ bopsection result
 
 checkshape result
 
-checknbshapes result -edge 5 -vertex 6
+checknbshapes result -edge 4 -vertex 5
 
 checkmaxtol result -ref 6.02982e-007
 
index 6c058615df6b08933c5d5ad5f679a571c755fa36..e85f3cee76ed182356e2eb3f2656ac75652b1605 100644 (file)
@@ -1,5 +1,3 @@
-puts "TODO OCC24418 ALL: Error in ii_2: T="
-
 puts "========"
 puts "OCC24418"
 puts "========"