]> OCCT Git - occt-copy.git/commitdiff
0026038: Wrong result done by extrema for the circle and plane
authorifv <ifv@opencascade.com>
Thu, 16 Apr 2015 11:00:57 +0000 (14:00 +0300)
committernbv <nbv@opencascade.com>
Mon, 18 Jul 2016 07:22:45 +0000 (10:22 +0300)
Test cases for issue CR26038

(cherry picked from commit 9dfbbfe67358bcddfbc511f4e5de8641dccaf31f)

src/Extrema/Extrema_ExtCS.cxx
src/Extrema/Extrema_ExtElCS.cxx
src/Extrema/Extrema_POnSurf.cdl
src/Extrema/Extrema_POnSurf.lxx
tests/bugs/moddata_3/bug26038_1 [new file with mode: 0755]
tests/bugs/moddata_3/bug26038_2 [new file with mode: 0755]

index 56f315724a41efa7e12b8fdc3365287668b7ea7b..eec8eb001413606dd8ca873b20f656bfad9bf369 100644 (file)
@@ -38,6 +38,7 @@
 #include <Extrema_ExtPElS.hxx>
 #include <TColStd_Array1OfReal.hxx>
 #include <Extrema_ExtPS.hxx>
+#include <ElSLib.hxx>
 
 Extrema_ExtCS::Extrema_ExtCS() 
 {
@@ -218,6 +219,11 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
         myExtElCS.Perform(C.Circle(), myS->Cylinder());
         break;
       }
+      else if(myStype == GeomAbs_Plane)
+      {
+        myExtElCS.Perform(C.Circle(), myS->Plane());
+        break;
+      }
     }
   case GeomAbs_Hyperbola: 
     {
@@ -341,6 +347,30 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
         PS.Parameter(U, V);
         AddSolution(C, Ucurve, U, V, PC.Value(), PS.Value(), myExtElCS.SquareDistance(i));
       }
+      if(mySqDist.Length() == 0 && NbExt > 0)
+      {
+        //Analytical extremas seem to be out of curve/surface boundaries.
+        //For plane it is possible to add extremity points of curve
+        if(myStype == GeomAbs_Plane)
+        {
+          gp_Pln aPln = myS->Plane();
+          gp_Pnt PC, PP;
+          if(!Precision::IsInfinite(myucinf))
+          {
+            PC = C.Value(myucinf);
+            ElSLib::PlaneParameters(aPln.Position(), PC, U, V);
+            PP = ElSLib::PlaneValue(U, V, aPln.Position());
+            AddSolution(C, myucinf, U, V, PC, PP, PC.SquareDistance(PP));
+          }
+          if(!Precision::IsInfinite(myucsup))
+          {
+            PC = C.Value(myucsup);
+            ElSLib::PlaneParameters(aPln.Position(), PC, U, V);
+            PP = ElSLib::PlaneValue(U, V, aPln.Position());
+            AddSolution(C, myucsup, U, V, PC, PP, PC.SquareDistance(PP));
+          }
+        }
+      }
     }
   }
 
index 6253a9f5611ffaa98d6332dfd6e1b2fa08335241..8a322491401b4f335d8bbffdfc0df714b1e0d66d 100644 (file)
@@ -261,13 +261,90 @@ Extrema_ExtElCS::Extrema_ExtElCS(const gp_Circ& C,
 
 
 
-//void Extrema_ExtElCS::Perform(const gp_Circ& C,
-//                           const gp_Pln& S)
-void Extrema_ExtElCS::Perform(const gp_Circ& ,
-                             const gp_Pln& )
+void Extrema_ExtElCS::Perform(const gp_Circ& C,
+                              const gp_Pln& S)
 {
-  Standard_NotImplemented::Raise();
+  myDone = Standard_True;
+  myIsPar = Standard_False;
+
+  gp_Ax2 Pos = C.Position();
+  gp_Dir NCirc = Pos.Direction();
+  gp_Dir NPln = S.Axis().Direction();
+
+  if (NCirc.IsParallel(NPln, Precision::Angular())) {
+
+    mySqDist = new TColStd_HArray1OfReal(1, 1);
+    mySqDist->SetValue(1, S.SquareDistance(C.Location()));
+    myIsPar = Standard_True;
+
+  }
+  else {
 
+    gp_Dir ExtLine = NCirc ^ NPln;
+    ExtLine = ExtLine ^ NCirc;
+    //
+    gp_Dir XDir = Pos.XDirection();
+    Standard_Real T[2];
+    T[0] = XDir.AngleWithRef(ExtLine, NCirc);
+    if(T[0] < 0.)
+    {
+      //Put in period
+      T[0] += M_PI;
+    }
+    T[1] = T[0] + M_PI;
+    //
+    myNbExt = 2;
+    //Check intersection 
+    IntAna_IntConicQuad anInter(C, S,
+                                Precision::Angular(),
+                                Precision::Confusion());
+    if(anInter.IsDone())
+    {
+      if(anInter.NbPoints() > 1)
+      {
+        myNbExt += anInter.NbPoints();
+      }
+    }
+
+    myPoint1 = new Extrema_HArray1OfPOnCurv(1, myNbExt);
+    mySqDist = new TColStd_HArray1OfReal(1, myNbExt);
+    myPoint2 = new Extrema_HArray1OfPOnSurf(1, myNbExt);
+
+    Standard_Integer i;
+    gp_Pnt PC, PP;
+    Standard_Real U, V;
+    Extrema_POnCurv POnC;
+    Extrema_POnSurf POnS;
+    for(i = 0; i < 2; ++i)
+    {
+      PC = ElCLib::CircleValue(T[i], C.Position(), C.Radius());
+      POnC.SetValues(T[i], PC);
+      myPoint1->SetValue(i+1, POnC);
+      ElSLib::PlaneParameters(S.Position(), PC, U, V);
+      PP = ElSLib::PlaneValue(U, V, S.Position());
+      POnS.SetParameters(U, V, PP);
+      myPoint2->SetValue(i+1, POnS);
+      mySqDist->SetValue(i+1, PC.SquareDistance(PP));
+    }
+    //
+    if(myNbExt > 2)
+    {
+      //Add intersection points
+      for(i = 1; i <= anInter.NbPoints(); ++i)
+      {
+        Standard_Real t = anInter.ParamOnConic(i);
+        PC = ElCLib::CircleValue(t, C.Position(), C.Radius());
+        POnC.SetValues(t, PC);
+        myPoint1->SetValue(i+2, POnC);
+        ElSLib::PlaneParameters(S.Position(), PC, U, V);
+        PP = ElSLib::PlaneValue(U, V, S.Position());
+        POnS.SetParameters(U, V, PP);
+        myPoint2->SetValue(i+2, POnS);
+        mySqDist->SetValue(i+2, PC.SquareDistance(PP));
+      }
+    }
+  }
+  //  
 }
 
 
index b87a7de10d52946d65b8f62b6814a1952f7b14b6..059a490d74650cacb9fc9c423abc0313218511c0 100644 (file)
@@ -40,6 +40,13 @@ is
        ---C++: inline
        is static;          
     
+    Parameter (me : mutable; theU, theV: Real from Standard; theP : Pnt from gp) 
+       ---Purpose: Sets the params of current POnSurf instance.
+       --         (e.g. to the point to be projected).
+       ---C++: inline
+       is static;          
+    
+    
 fields
     myU: Real;
     myV: Real;
index 3aac68d12136de510b2a751a498d5de4a3204df8..09acb31bd46ced68785df72515cde4e4ae52e20c 100644 (file)
@@ -29,3 +29,12 @@ inline void Extrema_POnSurf::Parameter ( Standard_Real& U, Standard_Real& V) con
 
 
 inline const gp_Pnt& Extrema_POnSurf::Value () const { return myP; }
+
+inline void Extrema_POnSurf::SetParameters (const Standard_Real U,
+                                            const Standard_Real V,
+                                            const gp_Pnt& P)
+{
+  myU = U;
+  myV = V;
+  myP = P;
+}
diff --git a/tests/bugs/moddata_3/bug26038_1 b/tests/bugs/moddata_3/bug26038_1
new file mode 100755 (executable)
index 0000000..44e2bcb
--- /dev/null
@@ -0,0 +1,39 @@
+puts "========="
+puts "CR26038"
+puts "========="
+puts ""
+###############################
+## Wrong result done by extrema for the circle and plane
+###############################
+
+restore [locate_data_file  bug26038_f.brep] f
+restore [locate_data_file  bug26038_e.brep] e
+
+mksurface s f
+mkcurve c e
+
+extrema c s
+regexp {The length ext_1 is +([-0-9.+eE]+)} [length ext_1] full ext_1_length
+set good_length 1.0e-7
+set tol_abs 1.0e-6
+set tol_rel 1.0e-6
+checkreal "length of ext_1" ${ext_1_length} ${good_length} ${tol_abs} ${tol_rel}
+
+trim ct c 3.0050016686511065 3.2781836385284797
+extrema ct s
+regexp {The length ext_1 is +([-0-9.+eE]+)} [length ext_1] full ext_1_length
+set good_length 1.0e-7
+set tol_abs 1.0e-6
+set tol_rel 1.0e-6
+checkreal "length of ext_1" ${ext_1_length} ${good_length} ${tol_abs} ${tol_rel}
+
+dlog reset
+dlog on
+xdistcs c s 3.140212946671221 3.142972360508366 10
+set Log [dlog get]
+
+set List [split ${Log} {TD= \t\n}]
+set Tolerance 1.0e-6
+set D_good 0.
+set Limit_Tol 1.0e-6
+checkList ${List} ${Tolerance} ${D_good} ${Limit_Tol}
diff --git a/tests/bugs/moddata_3/bug26038_2 b/tests/bugs/moddata_3/bug26038_2
new file mode 100755 (executable)
index 0000000..f39adbf
--- /dev/null
@@ -0,0 +1,31 @@
+puts "========="
+puts "CR26038"
+puts "========="
+puts ""
+###############################
+## Wrong result done by extrema for the circle and plane
+###############################
+
+restore [locate_data_file  bug26038_f1.brep] f
+restore [locate_data_file  bug26038_e1.brep] e
+
+mksurface s f
+mkcurve c e
+
+extrema c s
+regexp {The length ext_1 is +([-0-9.+eE]+)} [length ext_1] full ext_1_length
+set good_length 1.0e-7
+set tol_abs 1.0e-6
+set tol_rel 1.0e-6
+checkreal "length of ext_1" ${ext_1_length} ${good_length} ${tol_abs} ${tol_rel}
+
+dlog reset
+dlog on
+xdistcs c s 1.57079 1.5708 10
+set Log [dlog get]
+
+set List [split ${Log} {TD= \t\n}]
+set Tolerance 1.0e-6
+set D_good 0.
+set Limit_Tol 1.0e-6
+checkList ${List} ${Tolerance} ${D_good} ${Limit_Tol}