]> OCCT Git - occt.git/commitdiff
0029441: Modeling Algorithms - Incorrect intersection curves between faces
authorifv <ifv@opencascade.com>
Tue, 24 Nov 2020 11:17:03 +0000 (14:17 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 17 Dec 2020 18:05:04 +0000 (21:05 +0300)
ApproxInt/ApproxInt_SvSurfaces.hxx : adding field myUseSolver in order to manage calculations of characteristics of intersection points.
ApproxInt/ApproxInt_MultiLine.gxx : implementation of using myUseSolver for treatment points of MultiLine.
ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx : implementation of using myUseSolver for case intersection of implicit and parametric surfaces.

Test cases added

src/ApproxInt/ApproxInt_Approx.gxx
src/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx
src/ApproxInt/ApproxInt_MultiLine.gxx
src/ApproxInt/ApproxInt_SvSurfaces.hxx
tests/lowalgos/intss/bug29441_1 [new file with mode: 0644]
tests/lowalgos/intss/bug29441_2 [new file with mode: 0644]

index 63cec229868a1fa593bea36041a76651d4cbb8bf..7be8911cf0d6d93555a8a243f5575923ce7dc073 100644 (file)
@@ -359,6 +359,8 @@ void ApproxInt_Approx::Perform(const TheISurface& ISurf,
                           isTheQuadFirst? ApproxInt_TheImpPrmSvSurfaces(ISurf, PSurf):
                                           ApproxInt_TheImpPrmSvSurfaces(PSurf, ISurf);
 
+  myImpPrmSvSurfaces.SetUseSolver(Standard_False);
+
   const Standard_Integer nbpntbez = indicemax-indicemin;
   if(nbpntbez < aMinNbPointsForApprox)
   {
index 985e8e72bf1d98b3647496ff6d5bc6efa71cc8d5..f2c7ea979859a23757afb4671aa3d398a45ec7e4 100644 (file)
@@ -336,6 +336,7 @@ ApproxInt_ImpPrmSvSurfaces::ApproxInt_ImpPrmSvSurfaces( const TheISurface& ISurf
        MyImplicitFirst(Standard_True),
        MyZerImpFunc(PSurf,ISurf)
 { 
+  SetUseSolver(Standard_True);
 }
 //--------------------------------------------------------------------------------
 ApproxInt_ImpPrmSvSurfaces::ApproxInt_ImpPrmSvSurfaces( const ThePSurface& PSurf
@@ -347,6 +348,7 @@ ApproxInt_ImpPrmSvSurfaces::ApproxInt_ImpPrmSvSurfaces( const ThePSurface& PSurf
        MyImplicitFirst(Standard_False),
        MyZerImpFunc(PSurf,ISurf)
 { 
+  SetUseSolver(Standard_True);
 }
 //--------------------------------------------------------------------------------
 void ApproxInt_ImpPrmSvSurfaces::Pnt(const Standard_Real u1,
@@ -517,15 +519,21 @@ Standard_Boolean ApproxInt_ImpPrmSvSurfaces::Compute( Standard_Real& u1,
     return(Standard_False);
   }
 
+  Standard_Boolean aRsnldIsDone = Standard_False;
   Standard_Real PourTesterU = X(1);
   Standard_Real PourTesterV = X(2);
-
-  math_FunctionSetRoot  Rsnld(MyZerImpFunc);
-  Rsnld.SetTolerance(Tolerance);
-  Rsnld.Perform(MyZerImpFunc,X,BornInf,BornSup);
-  if(Rsnld.IsDone()) { 
+  if (GetUseSolver())
+  {
+    math_FunctionSetRoot  Rsnld(MyZerImpFunc);
+    Rsnld.SetTolerance(Tolerance);
+    Rsnld.Perform(MyZerImpFunc, X, BornInf, BornSup);
+    aRsnldIsDone = Rsnld.IsDone();
+    if (aRsnldIsDone)
+      Rsnld.Root(X);
+  }
+  if(aRsnldIsDone || !GetUseSolver()) 
+  {
     MyHasBeenComputed = Standard_True;
-    Rsnld.Root(X);
     
     Standard_Real DistAvantApresU = Abs(PourTesterU-X(1));
     Standard_Real DistAvantApresV = Abs(PourTesterV-X(2));
@@ -907,10 +915,15 @@ ApproxInt_ImpPrmSvSurfaces::FillInitialVectorOfSolution(const Standard_Real u1,
   //----------------------------------------------------
   //Make a small step from boundaries in order to avoid
   //finding "outboundaried" solution (Rsnld -> NotDone).
-  if(X(1)-0.0000000001 <= binfu) X(1)=X(1)+0.0000001;
-  if(X(1)+0.0000000001 >= bsupu) X(1)=X(1)-0.0000001;
-  if(X(2)-0.0000000001 <= binfv) X(2)=X(2)+0.0000001;
-  if(X(2)+0.0000000001 >= bsupv) X(2)=X(2)-0.0000001;
+  if (GetUseSolver())
+  {
+    Standard_Real du = Max(Precision::Confusion(), ThePSurfaceTool::UResolution(aPSurf, Precision::Confusion()));
+    Standard_Real dv = Max(Precision::Confusion(), ThePSurfaceTool::VResolution(aPSurf, Precision::Confusion()));
+    if (X(1) - 0.0000000001 <= binfu) X(1) = X(1) + du;
+    if (X(1) + 0.0000000001 >= bsupu) X(1) = X(1) - du;
+    if (X(2) - 0.0000000001 <= binfv) X(2) = X(2) + dv;
+    if (X(2) + 0.0000000001 >= bsupv) X(2) = X(2) - dv;
+  }
   
   return Standard_True;
 }
index ad8472b2213ce4bb619ec4c5aecb5bc3d7f9b762..323c445668fa840d9eed35279f2f97b76c044403 100644 (file)
@@ -317,6 +317,11 @@ ApproxInt_MultiLine
     //-- return(*this);
   }
 
+  Standard_Boolean aSaveUseSolver = ((TheSvSurfaces *)PtrOnmySvSurfaces)->GetUseSolver();
+  if (!aSaveUseSolver)
+  {
+    ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(Standard_True);
+  }
   Standard_Integer NbPntsToInsert=aNbPntsToInsert;
   if(NbPntsToInsert<(High-Low)) NbPntsToInsert=(High-Low);
   Standard_Integer NbPnts = NbPntsToInsert + High - Low + 1;
@@ -564,6 +569,7 @@ ApproxInt_MultiLine
 
   if((temp->NbPnts() >= NbPntsToInsert + High - Low + 1) && (CodeErreur==0))
   {
+    ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
     return (ApproxInt_MultiLine( temp, 
                                  (High-Low>10)? PtrOnmySvSurfaces : NULL,
                                  nbp3d,
@@ -579,6 +585,7 @@ ApproxInt_MultiLine
   {
     //-- cout<<" ApproxInt_MultiLine "<<endl;
     //-- cout<<" Pas de Rajout de points ds1min =  "<<minds1<<" ds2min = "<<minds2<<endl;
+    ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
     Handle(IntSurf_LineOn2S) vide1 = new IntSurf_LineOn2S();
     Handle(TheLine) vide = new TheLine(vide1,Standard_False);
     return (ApproxInt_MultiLine( vide,
@@ -607,7 +614,13 @@ Standard_Boolean
   Standard_Boolean OtherLineMade = Standard_False;
   if(PtrOnmySvSurfaces==NULL)
     return Standard_False;
-  
+
+  Standard_Boolean aSaveUseSolver = ((TheSvSurfaces *)PtrOnmySvSurfaces)->GetUseSolver();
+  if (!aSaveUseSolver)
+  {
+    ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(Standard_True);
+  }
+
   const Standard_Real SqTol3d = Precision::SquareConfusion();
   math_Vector tolerance(1,2);
   tolerance(1) = tolerance(2) = 1.e-8;
@@ -682,7 +695,10 @@ Standard_Boolean
   }
 
   if (!OtherLineMade)
+  {
+    ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
     return Standard_False;
+  }
 
 #ifdef DRAW
   char* name = new char[100];
@@ -700,6 +716,7 @@ Standard_Boolean
   }
 #endif
   Handle(TheLine) temp = new TheLine(ResultPntOn2SLine,Standard_False);
+  ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
   theNewMultiLine = ApproxInt_MultiLine( temp, 
                                          PtrOnmySvSurfaces,
                                          nbp3d,
index f2ad4fd1c7dff9f2980a2baded3de67d538948d9..33e145c0a656b418f6591b3e0808f0226ce9b939 100644 (file)
@@ -28,6 +28,18 @@ class gp_Vec;
 class gp_Vec2d;
 class IntSurf_PntOn2S;
 
+//! This class is root class for classes dedicated to calculate 
+//! 2d and 3d points and tangents of intersection lines of two surfaces of different types
+//! for given u, v parameters of intersection point on two surfaces.
+//! 
+//! The field myUseSolver is used to manage type of calculation:
+//! if myUseSolver = true, input parameters u1, v1, u2, v2 are considered as first approximation of 
+//! exact intersection point, then coordinates u1, v1, u2, v2 are refined with help of 
+//! the solver used in intersection algorithm and required values are calculated.
+//! if myUseSolver = false, u1, v1, u2, v2 are considered as "exact" intersection points on two surfaces
+//! and required values are calculated directly using u1, v1, u2, v2
+//! 
+
 
 class ApproxInt_SvSurfaces 
 {
@@ -70,18 +82,26 @@ public:
                                                             gp_Vec2d& Tg) = 0;
   Standard_EXPORT virtual ~ApproxInt_SvSurfaces();
 
+  Standard_EXPORT virtual void SetUseSolver(const Standard_Boolean theUseSol)
+  {
+    myUseSolver = theUseSol;
+  }
 
+  Standard_EXPORT virtual Standard_Boolean GetUseSolver() const
+  {
+    return myUseSolver;
+  }
 
 
 protected:
 
-
+  
 
 
 
 private:
 
-
+Standard_Boolean myUseSolver;
 
 
 
diff --git a/tests/lowalgos/intss/bug29441_1 b/tests/lowalgos/intss/bug29441_1
new file mode 100644 (file)
index 0000000..d1f2ff7
--- /dev/null
@@ -0,0 +1,48 @@
+puts "============"
+puts "0029441: Modeling Algorithms - Incorrect intersection curves between faces"
+puts "============"
+puts ""
+
+binrestore [locate_data_file bug28984_faces.bin] f
+
+set OK 1
+explode f
+bopcurves f_1 f_2 -2d
+
+if {[isdraw c2d1_1]} {
+  puts "check extremity of 1-st pcurve x ~ 1.012680192, |dx| ~ 0, |dy| >> |dx|"
+  2dcvalue c2d1_1 1 x y dx dy
+  set ex [expr abs([dval (x-1.012680192)])]
+  set edxdy [expr abs([dval dx/dy])]
+  if {$ex > 1.e-8 || $edxdy > 1.e-10} {
+    puts "Extremities of 1-st pcurve are wrong"
+    set OK 0
+  } else {
+    puts "Extremities of 1-st pcurve are valid"
+  }
+} else {
+  set OK 0
+  puts "Error: 1-st pcurve is not exist"
+}
+
+if { $OK > 0 } {
+  if {[isdraw c2d1_2]} {
+    puts "check extremity of 2-nd pcurve x ~ 1.0117170137, |dx| ~ 0, |dy| >> |dx|"
+    2dcvalue c2d1_2 1 x y dx dy
+    set ex [expr abs([dval (x-1.0117170137)])]
+    set edxdy [expr abs([dval dx/dy])]
+    if {$ex > 1.e-8 || $edxdy > 1.e-10} {
+      puts "Extremities of 2-nd pcurve are wrong"
+      set OK 0
+    } else {
+      puts "Extremities of 2-nd pcurve are valid"
+    }
+  } else {
+    set OK 0
+    puts "Error: 2-nd pcurve is not exist"
+  }
+} 
+
+if { $OK < 1 } {
+  puts "Error: bad pcurves"
+}
diff --git a/tests/lowalgos/intss/bug29441_2 b/tests/lowalgos/intss/bug29441_2
new file mode 100644 (file)
index 0000000..d2d2090
--- /dev/null
@@ -0,0 +1,51 @@
+puts "============"
+puts "0029441: Modeling Algorithms - Incorrect intersection curves between faces"
+puts "============"
+puts ""
+
+binrestore [locate_data_file bug28892_tools.bin] b
+
+set OK 1
+explode b so
+explode b_8 f; copy b_8_1 f1
+explode b_13 f; copy b_13_5 f2
+don f1 f2
+bopcurves f1 f2 -2d
+
+if {[isdraw c2d1_1]} {
+  puts "check extremity of 1-st pcurve x ~ 5.2714710662, |dx| ~ 0, |dy| >> |dx|"
+  2dcvalue c2d1_1 1 x y dx dy
+  set ex [expr abs([dval (x-5.2714710662)])]
+  set edxdy [expr abs([dval dx/dy])]
+  if {$ex > 1.e-8 || $edxdy > 1.e-10} {
+    puts "Extremities of 1-st pcurve are wrong"
+    set OK 0
+  } else {
+    puts "Extremities of 1-st pcurve are valid"
+  }
+} else {
+  set OK 0
+  puts "Error: 1-st pcurve is not exist"
+}
+
+if { $OK > 0 } {
+  if {[isdraw c2d1_2]} {
+    puts "check extremity of 2-nd pcurve x ~ 5.2705066089, |dx| ~ 0, |dy| >> |dx|"
+    2dcvalue c2d1_2 1 x y dx dy
+    set ex [expr abs([dval (x-5.2705066089)])]
+    set edxdy [expr abs([dval dx/dy])]
+    if {$ex > 1.e-8 || $edxdy > 1.e-10} {
+      puts "Extremities of 2-nd pcurve are wrong"
+      set OK 0
+    } else {
+      puts "Extremities of 2-nd pcurve are valid"
+    }
+  } else {
+    set OK 0
+    puts "Error: 2-nd pcurve is not exist"
+  }
+} 
+
+if { $OK < 1 } {
+  puts "Error: bad pcurves"
+}