0027773: Empty result of section operation between line and offset of a circle
authoremv <emv@opencascade.com>
Mon, 15 Aug 2016 12:08:33 +0000 (15:08 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 18 Aug 2016 11:46:20 +0000 (14:46 +0300)
In Edge/Edge intersection the Resolution for the Offset Curve based on the elementary
curve (Line/Circle/Ellipse) is computed using this basis curve.

src/IntTools/IntTools_EdgeEdge.cxx
tests/bugs/modalg_6/bug27773 [new file with mode: 0644]

index 6d212df5d43f83af6ae4ba1baf4989dd4d201e91..83ec31e9c4750247e3d219c1c077edb19c49216a 100644 (file)
 #include <ElCLib.hxx>
 #include <Geom_BezierCurve.hxx>
 #include <Geom_BSplineCurve.hxx>
+#include <Geom_Line.hxx>
 #include <Geom_Circle.hxx>
 #include <Geom_Curve.hxx>
 #include <Geom_Ellipse.hxx>
+#include <Geom_OffsetCurve.hxx>
 #include <GeomAPI_ProjectPointOnCurve.hxx>
 #include <gp_Dir.hxx>
 #include <gp_Lin.hxx>
@@ -1354,7 +1356,7 @@ Standard_Integer TypeToInteger(const GeomAbs_CurveType theCType)
 Standard_Real ResolutionCoeff(const BRepAdaptor_Curve& theBAC,
                               const IntTools_Range& theRange)
 {
-  Standard_Real aResCoeff;
+  Standard_Real aResCoeff = 0.;
   //
   const Handle(Geom_Curve)& aCurve = theBAC.Curve().Curve();
   const GeomAbs_CurveType aCurveType = theBAC.GetType();
@@ -1366,9 +1368,26 @@ Standard_Real ResolutionCoeff(const BRepAdaptor_Curve& theBAC,
   case GeomAbs_Ellipse :
     aResCoeff =  1. / Handle(Geom_Ellipse)::DownCast (aCurve)->MajorRadius();
     break;
+  case GeomAbs_OffsetCurve : {
+    const Handle(Geom_OffsetCurve)& anOffsetCurve = Handle(Geom_OffsetCurve)::DownCast(aCurve);
+    const Handle(Geom_Curve)& aBasisCurve = anOffsetCurve->BasisCurve();
+    const GeomAbs_CurveType aBCType = GeomAdaptor_Curve(aBasisCurve).GetType();
+    if (aBCType == GeomAbs_Line) {
+      break;
+    }
+    else if (aBCType == GeomAbs_Circle) {
+      aResCoeff = 1. / (2 * (anOffsetCurve->Offset() +
+        Handle(Geom_Circle)::DownCast (aBasisCurve)->Circ().Radius()));
+      break;
+    }
+    else if (aBCType == GeomAbs_Ellipse) {
+      aResCoeff = 1. / (anOffsetCurve->Offset() +
+        Handle(Geom_Ellipse)::DownCast (aBasisCurve)->MajorRadius());
+      break;
+    }
+  }
   case GeomAbs_Hyperbola :
   case GeomAbs_Parabola : 
-  case GeomAbs_OffsetCurve :
   case GeomAbs_OtherCurve :{
     Standard_Real k, kMin, aDist, aDt, aT1, aT2, aT;
     Standard_Integer aNbP, i;
@@ -1396,7 +1415,6 @@ Standard_Real ResolutionCoeff(const BRepAdaptor_Curve& theBAC,
     break;
   }
   default:
-    aResCoeff = 0.;
     break;
   }
   //
@@ -1429,6 +1447,20 @@ Standard_Real Resolution(const Handle(Geom_Curve)& theCurve,
   case GeomAbs_BSplineCurve:
     Handle(Geom_BSplineCurve)::DownCast (theCurve)->Resolution(theR3D, aRes);
     break;
+  case GeomAbs_OffsetCurve: {
+    const Handle(Geom_Curve)& aBasisCurve = 
+      Handle(Geom_OffsetCurve)::DownCast(theCurve)->BasisCurve();
+    const GeomAbs_CurveType aBCType = GeomAdaptor_Curve(aBasisCurve).GetType();
+    if (aBCType == GeomAbs_Line) {
+      aRes = theR3D;
+      break;
+    }
+    else if (aBCType == GeomAbs_Circle) {
+      Standard_Real aDt = theResCoeff * theR3D;
+      aRes = (aDt <= 1.) ? 2*ASin(aDt) : 2*M_PI;
+      break;
+    }
+  }
   default:
     aRes = theResCoeff * theR3D;
     break;
diff --git a/tests/bugs/modalg_6/bug27773 b/tests/bugs/modalg_6/bug27773
new file mode 100644 (file)
index 0000000..846856c
--- /dev/null
@@ -0,0 +1,16 @@
+puts "========"
+puts "OCC27773"
+puts "========"
+puts ""
+#################################################
+# Empty result of section operation between line and offset of a circle
+#################################################
+
+circle c 1 0 0 20
+offset c1 c 10 0 0 1
+mkedge e1 c1
+vertex v1 0 35 0
+vertex v2 0 -35 0
+edge e2 v1 v2
+bsection result e1 e2
+checknbshapes result -vertex 2