]> OCCT Git - occt.git/commitdiff
0032850: Modeling Algorithms - Surface Surface Intersect Lost one line
authorgelin <gelin@qunhemail.com>
Mon, 28 Feb 2022 06:13:31 +0000 (09:13 +0300)
committersmoskvin <smoskvin@opencascade.com>
Mon, 31 Oct 2022 15:09:15 +0000 (18:09 +0300)
IntStart_SearchOnBoundaries.gxx - improving tangent criteria

src/IntPatch/IntPatch_ALineToWLine.cxx
src/IntStart/IntStart_SearchOnBoundaries.gxx
tests/evolved/voluved/HMC010
tests/lowalgos/intss/bug32850 [new file with mode: 0644]

index 001d901a59dfb171a92b86c1015eef3aca8bd808..54f8f0745324444e7bf50fd29cc6e910df67d16d 100644 (file)
@@ -714,7 +714,8 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
       }
 
       IntPatch_Point aVtx = theALine->Vertex(aVertexNumber);
-      const Standard_Real aNewVertexParam = aLinOn2S->NbPoints() + 1;
+      Standard_Real aNewVertexParam = aLinOn2S->NbPoints() + 1;
+      Standard_Integer aNbPointsPrev = aLinOn2S->NbPoints();
 
       //ATTENTION!!!
       // IsPoleOrSeam inserts new point in aLinOn2S if aVtx respects
@@ -748,6 +749,7 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
 
       aPrePointExist = IsPoleOrSeam(myS1, myS2, aPrefIso, aLinOn2S, aVtx,
                                 anArrPeriods, aTol, aSingularSurfaceID);
+
       if (aPrePointExist == IntPatch_SPntPole ||
           aPrePointExist == IntPatch_SPntPoleSeamU)
       {
@@ -761,6 +763,11 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
       const Standard_Real aCurVertParam = aVtx.ParameterOnLine();
       if(aPrePointExist != IntPatch_SPntNone)
       {
+        if (aNbPointsPrev == aLinOn2S->NbPoints())
+        {
+          //Vertex coinsides any point of line and was not added into line
+          aNewVertexParam = aNbPointsPrev;
+        }
         aPrevParam = aParameter = aCurVertParam;
       }
       else
index 8c013fbce1360353a8ee6f2b42ddb4c7d5ba851d..59bac003464ff02f43b080485c0505e054a3a412 100644 (file)
@@ -354,6 +354,7 @@ void BoundedArc (const TheArc& A,
   {
     const IntSurf_Quadric& aQuadric = Func.Quadric();
     GeomAbs_SurfaceType TypeQuad = aQuadric.TypeQuadric();
+    GeomAbs_CurveType TypeConS = GeomAbs_OtherCurve;
     
     IntCurveSurface_HInter IntCS;
     Standard_Boolean IsIntCSdone = Standard_False;
@@ -387,7 +388,7 @@ void BoundedArc (const TheArc& A,
       //Exact solution
       Handle(Adaptor3d_Surface) aSurf = Func.Surface();
       Adaptor3d_CurveOnSurface ConS(A, aSurf);
-      GeomAbs_CurveType TypeConS = ConS.GetType();
+      TypeConS = ConS.GetType();
 #ifdef OCCT_DEBUG
       Handle(Geom_Curve) CurveConS;
       switch(TypeConS)
@@ -608,13 +609,27 @@ void BoundedArc (const TheArc& A,
           para = aSI(i).Value();
 
           Standard_Real param=(para+parap1)*0.5;
-          Standard_Real ym;
-          if(Func.Value(param,ym)) {
-            if(Abs(ym)<maxdist) { 
+          Standard_Real yf = 0.0;
+          Standard_Real ym = 0.0;
+          Standard_Real yl = 0.0;
+          if(Func.Value(param,ym) && Abs(ym) < maxdist) {
+            Standard_Real sm = Sign(1., ym);
+            Standard_Boolean aTang = Func.Value(para,yf) && Func.Value(parap1,yl);
+            if (aTang) {
+              //Line can be tangent surface if all distances less then maxdist
+              aTang = aTang && Abs(yf) < maxdist && Abs(yl) < maxdist;
+            }
+            if (aTang && IsIntCSdone && TypeConS == GeomAbs_Line) {
+              //Interval is got by exact intersection
+              //Line can be tangent if all points are on the same side of surface
+              //it means that signs of all distances are the same
+              Standard_Real sf = Sign(1., yf), sl = Sign(1., yl);
+              aTang = aTang && (sm == sf) && (sm == sl);
+            }
+            if(aTang) { 
               //  Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 Begin
               // Consider this interval as tangent one. Treat it to find
               // parameter with the lowest function value.
-
               // Compute the number of nodes.
               Standard_Real    aTol = TolBoundary*1000.0;
               if(aTol > 0.001)
@@ -627,6 +642,7 @@ void BoundedArc (const TheArc& A,
               Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para)/aTol));
 
               Standard_Real    aVal     = RealLast();
+              Standard_Real aValMax = 0.;
               //Standard_Integer aNbNodes = 23;
               Standard_Real    aDelta   = (parap1 - para)/(aNbNodes + 1.);
               Standard_Integer ii;
@@ -637,17 +653,29 @@ void BoundedArc (const TheArc& A,
                 aCurPar = (ii < aNbNodes + 1) ? para + ii*aDelta : parap1;
 
                 if (Func.Value(aCurPar, aCurVal)) {
-                  //if (aCurVal < aVal) {
-                  if (Abs(aCurVal) < aVal) {
-                    //aVal  = aCurVal;
-                    aVal  = Abs(aCurVal);
+                  Standard_Real anAbsVal = Abs(aCurVal);
+                  if (anAbsVal < aVal) {
+                    aVal  = anAbsVal;
                     param = aCurPar;
                   }
+                  if (anAbsVal > aValMax)
+                  {
+                    aValMax = anAbsVal;
+                  }
                 }
               }
-              //  Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 End
-              aSI(i).ChangeValue() = Pdeb - 1;
-              aSI(i + 1).ChangeValue() = param;
+              // At last, interval got by exact intersection can be considered as tangent if
+              // minimal distance is inside interval and
+              // minimal and maximal values are almost the same
+              if (IsIntCSdone && aNbNodes > 1) {
+                aTang = Abs(param - para) > EpsX && Abs(parap1 - param) > EpsX &&
+                  0.01*aValMax <= aVal;
+              }
+              if (aTang)
+              {
+                aSI(i).ChangeValue() = Pdeb - 1;
+                aSI(i + 1).ChangeValue() = param;
+              }
             }
           }
         }
index 6ea24a3b5e4912f2375f6c05eb598b3b0f8ecf25..dd63f25b95838778fe5de62559ffb61f6761fe83 100644 (file)
@@ -2,7 +2,7 @@ puts "=========="
 puts "OCC29523"
 puts "=========="
 
-cpulimit 60
+cpulimit 120
 
 restore [locate_data_file bug29523_cut_extrudewire09.brep] sw 
 restore [locate_data_file bug29523_cut_toolwire09.brep] tw
diff --git a/tests/lowalgos/intss/bug32850 b/tests/lowalgos/intss/bug32850
new file mode 100644 (file)
index 0000000..8312243
--- /dev/null
@@ -0,0 +1,19 @@
+puts "========"
+puts "0032850: Modeling Algorithms - Surface Surface Intersect Lost one line"
+puts "========"
+puts ""
+
+cylinder s1 25.8071575178163 0 -373.974517822281 0 1 0 -1.73024882663956e-06 0 0.999999999998503 408.974517822893
+trim  s1 s1 0 0.0225015452057227 -146.010003766057 2146.01000376606
+cylinder s2 0 1974.19284248218 -373.974517822281 1 0 0 -0 1.73024882663956e-06 0.999999999998503 408.974517822893
+trim s2 s2 0 0.0225015452057227 -146.010003766057 946.010003766057
+mkface f1 s1;
+mkface f2 s2;
+set log [bopcurves f1 f2]
+regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} $log full Toler NbCurv
+if {$NbCurv != 4} {
+  puts "Error: Number of curves is wrong"
+}
+if { $Toler > 1.0e-12} {
+  puts "Error: Big tolerance value"  
+}
\ No newline at end of file