]> OCCT Git - occt-copy.git/commitdiff
0024800: Point of intersection was not found for 2d offset curve.
authorgka <gka@opencascade.com>
Thu, 10 Apr 2014 11:45:18 +0000 (15:45 +0400)
committerabv <abv@opencascade.com>
Wed, 23 Apr 2014 11:45:38 +0000 (15:45 +0400)
For fix this case in method Geom2dInt_Geom2dCurveTool::NBSamples() number of samples for 2d offset and trimmed curve is computed as max value from number of samples for other curve and number of samples for basis curve.

Test case for issue CR24800

src/Adaptor2d/Adaptor2d_Curve2d.cdl
src/Adaptor2d/Adaptor2d_Curve2d.cxx
src/Geom2dAdaptor/Geom2dAdaptor_Curve.cdl
src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx
src/Geom2dInt/Geom2dInt_CurveTool.gxx
tests/bugs/moddata_3/bug24800 [new file with mode: 0755]

index 9e2676134317871c018d44142b61e1a3397bfc56..ec83a3870d0606c43feb915beef358c368cd1278 100644 (file)
@@ -218,7 +218,8 @@ is
        NoSuchObject from Standard
      is virtual;     
           
-     
+     NbSamples(me) returns Integer from Standard is virtual;
+
      Bezier(me) returns BezierCurve from Geom2d
      raises 
        NoSuchObject from Standard
index 6b6589cb67b5470119754ab1ed6074c6be399671..7a0a83e0146b608792a8113590070a46e1a84f04 100644 (file)
@@ -373,5 +373,12 @@ Handle(Geom2d_BSplineCurve) Adaptor2d_Curve2d::BSpline() const
   return Handle(Geom2d_BSplineCurve)();
 }
 
-
+//=======================================================================
+//function : NbSamples
+//purpose  : 
+//=======================================================================
+Standard_Integer Adaptor2d_Curve2d::NbSamples() const
+{
+  return 20;  
+}
 
index c34f0120822e4b613f337aa9c234c2b3bd9961b7..b53c131f67b7534a24880350937d9992bf88185f 100644 (file)
@@ -226,7 +226,7 @@ is
        NoSuchObject from Standard
      is redefined static;     
           
-
+    NbSamples(me) returns Integer from Standard is redefined;
 
     Bezier(me) returns BezierCurve from Geom2d
     raises 
index b538739d87b8174efaa1eeb606b717b20c702186..56ca5099a9ee83f7bc6ce1eac7275c36a29ee6b5 100644 (file)
@@ -860,3 +860,40 @@ Handle(Geom2d_BSplineCurve) Geom2dAdaptor_Curve::BSpline() const
   return *((Handle(Geom2d_BSplineCurve)*)&myCurve);
 }
 
+static Standard_Integer nbPoints(const Handle(Geom2d_Curve)& theCurve) 
+{
+  Standard_Integer nbs = 10;
+  
+  if(theCurve->IsKind(STANDARD_TYPE( Geom2d_Line)) )
+    nbs = 2;
+  else if(theCurve->IsKind(STANDARD_TYPE( Geom2d_BezierCurve))) 
+  {
+    nbs = 3 + (*((Handle(Geom2d_BezierCurve)*)&theCurve))->NbPoles();
+  }
+  else if(theCurve->IsKind(STANDARD_TYPE( Geom2d_BSplineCurve))) { 
+    nbs =  (*((Handle(Geom2d_BSplineCurve)*)&theCurve))->NbKnots();
+    nbs*= (*((Handle(Geom2d_BSplineCurve)*)&theCurve))->Degree();
+    if(nbs < 2.0) nbs=2;
+  }
+  else if (theCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)))
+  {
+    Handle(Geom2d_Curve) aCurve = (*((Handle(Geom2d_OffsetCurve)*)&theCurve))->BasisCurve();
+    return Max(nbs, nbPoints(aCurve));
+  }
+
+  else if (theCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)))
+  {
+    Handle(Geom2d_Curve) aCurve = (*((Handle(Geom2d_TrimmedCurve)*)&theCurve))->BasisCurve();
+    return Max(nbs, nbPoints(aCurve));
+  }
+  if(nbs>300)
+    nbs = 300;
+  return nbs;
+  
+}
+
+Standard_Integer Geom2dAdaptor_Curve::NbSamples() const
+{
+  return  nbPoints(myCurve);
+}
index cb6bd67694bcb0899d5a6fe77b6dbbc97ce002f5..0959ff5ae9512610473ead28819bde110a64dbfa 100644 (file)
 
 //============================================================
 Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C,
-                                                const Standard_Real U0,
-                                                const Standard_Real U1) {
+  const Standard_Real U0,
+  const Standard_Real U1) 
+{
   GeomAbs_CurveType typC = C.GetType();
-  static Standard_Real nbsOther = 10.0;
-  Standard_Real nbs = nbsOther;
+  Standard_Integer nbs = C.NbSamples();
 
-  if(typC == GeomAbs_Line) 
-    nbs = 2;
-  else if(typC == GeomAbs_BezierCurve) 
-    nbs = 3 + C.NbPoles();
-  else if(typC == GeomAbs_BSplineCurve) { 
+  if(typC == GeomAbs_BSplineCurve) { 
     Standard_Real t=C.LastParameter()-C.FirstParameter();
     Standard_Real t1=U1-U0;
     if(t1<0.0) t1=-t1;
     nbs = C.NbKnots();
     nbs*= C.Degree();
-    nbs*= (t1/t);
+    Standard_Real anb = t1/t * nbs;
+    nbs = (Standard_Integer)anb;
     if(nbs < 4.0) nbs=4;
   }
-  //// modified by jgv, 20.02.02 for bug OCC165 ////
-  else if (typC == GeomAbs_OtherCurve)
-    nbs = 20;
-  //////////////////////////////////////////////////
 
   if(nbs>300)
     nbs = 300;
-  return((Standard_Integer)nbs);
+  return nbs;
+
 }
 //============================================================
 Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C) { 
-  GeomAbs_CurveType typC = C.GetType();
-  static Standard_Real nbsOther = 10.0;
-  Standard_Real nbs = nbsOther;
-  
-  if(typC == GeomAbs_Line) 
-    nbs = 2;
-  else if(typC == GeomAbs_BezierCurve) 
-    nbs = 3 + C.NbPoles();
-  else if(typC == GeomAbs_BSplineCurve) { 
-    nbs = C.NbKnots();
-    nbs*= C.Degree();
-    if(nbs < 2.0) nbs=2;
-  }
-  //// modified by jgv, 20.02.02 for bug OCC165 ////
-  else if (typC == GeomAbs_OtherCurve)
-    nbs = 20;
-  //////////////////////////////////////////////////
-
-  if(nbs>300)
-    nbs = 300;
-  return((Standard_Integer)nbs);
-}
+    return C.NbSamples();
+ }
 
 
 
diff --git a/tests/bugs/moddata_3/bug24800 b/tests/bugs/moddata_3/bug24800
new file mode 100755 (executable)
index 0000000..7c2677d
--- /dev/null
@@ -0,0 +1,22 @@
+puts "============"
+puts "CR24800"
+puts "==========="
+puts ""
+###############################################################################
+# Point of intersection was not found for 2d offset curve.
+###############################################################################
+
+restore [locate_data_file bug24800_curve2.brep] c2
+
+set inter1 [2dintersect c2]
+
+set int1 [regexp {Intersection point 1} ${inter1}]
+
+if { ${int1} == 0 } {
+    puts "Error : Intersection is not found"
+} 
+
+av2d
+2dfit
+
+xwd ${imagedir}/${test_image}.png