0023405: BOP common produces one face instead of a solid
authorpkv <pkv@opencascade.com>
Fri, 7 Sep 2012 10:11:06 +0000 (14:11 +0400)
committerpkv <pkv@opencascade.com>
Fri, 7 Sep 2012 10:11:06 +0000 (14:11 +0400)
Modified class :IntTools_FaceFace
   - method: void IntTools_FaceFace::ComputeTolReached3d()
The goal is:
to give more precise definition to the value of tolerance of intersection curves in 3D for the case plane/sphere.

Added test case boolean/bopcommon_complex/M7
Added test case boolean/bopcommon_simple/ZP9 for verified bug CR23374

src/IntTools/IntTools_FaceFace.cxx
tests/boolean/bopcommon_complex/M7 [new file with mode: 0755]
tests/boolean/bopcommon_simple/ZP9 [new file with mode: 0755]

index ed1f19b..6ee4bf7 100755 (executable)
@@ -315,8 +315,8 @@ static
                                       const Handle(Geom_Curve)& aC3D,
                                       const Handle(Geom2d_Curve)& aC2D1,
                                       const Handle(Geom2d_Curve)& aC2D2,
-                                      const Handle(GeomAdaptor_HSurface) myHS1,
-                                      const Handle(GeomAdaptor_HSurface) myHS2,
+                                      const Handle(GeomAdaptor_HSurface)& myHS1,
+                                      const Handle(GeomAdaptor_HSurface)& myHS2,
                                       const TopoDS_Face& aF1,
                                       const TopoDS_Face& aF2,
                                       const Handle(IntTools_Context)& aCtx);
@@ -783,6 +783,7 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
       Standard_Real aT1, aT2, dT, aD2, aD2Max, aEps, aT11, aT12;
       //
       aD2Max=0.;
+      aNbP=10;
       aNbLin=mySeqOfCurve.Length();
       //
       for (i=1; i<=aNbLin; ++i) {
@@ -804,7 +805,6 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
        aT2=aBC->LastParameter();
        //
        aEps=0.01*(aT2-aT1);
-       aNbP=10;
        dT=(aT2-aT1)/aNbP;
        for (j=1; j<aNbP; ++j) {
          aT11=aT1+j*dT;
@@ -978,6 +978,65 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts)
       myTolReached3d=sqrt(aD2max);
     }
   }//if((aType1==GeomAbs_SurfaceOfRevolution ...
+  //modified by NIZNHY-PKV Thu Aug 30 13:31:10 2012f
+  else if ((aType1==GeomAbs_Plane && aType2==GeomAbs_Sphere) ||
+          (aType2==GeomAbs_Plane && aType1==GeomAbs_Sphere)) {
+    Standard_Integer i, j, aNbP;
+    Standard_Real aT, aT1, aT2, dT, aD2max, aD2, aEps, aT11, aT12;
+    //
+    aNbLin=mySeqOfCurve.Length();
+    aD2max=0.;
+    aNbP=10;
+    //
+    for (i=1; i<=aNbLin; ++i) {
+      const IntTools_Curve& aIC=mySeqOfCurve(i);
+      const Handle(Geom_Curve)& aC3D=aIC.Curve();
+      const Handle(Geom2d_Curve)& aC2D1=aIC.FirstCurve2d();
+      const Handle(Geom2d_Curve)& aC2D2=aIC.SecondCurve2d();
+      //
+      const Handle(Geom2d_BSplineCurve)& aBC2D1=
+       Handle(Geom2d_BSplineCurve)::DownCast(aC2D1);
+      const Handle(Geom2d_BSplineCurve)& aBC2D2=
+       Handle(Geom2d_BSplineCurve)::DownCast(aC2D2);
+      //
+      if (aBC2D1.IsNull() && aBC2D2.IsNull()) {
+       return;
+      }
+      //
+      if (!aBC2D1.IsNull()) {
+       aT1=aBC2D1->FirstParameter();
+       aT2=aBC2D1->LastParameter();
+      }
+      else {
+       aT1=aBC2D2->FirstParameter();
+       aT2=aBC2D2->LastParameter();
+      }
+      //
+      aEps=0.01*(aT2-aT1);
+      dT=(aT2-aT1)/(aNbP-1);
+      for (j=0; j<aNbP; ++j) {
+       aT=aT1+j*dT;
+       aT11=aT1+j*dT;
+       aT12=aT11+dT;
+       if (j==aNbP-1) {
+         aT12=aT2;
+       }
+       //
+       aD2=FindMaxSquareDistance(aT11, aT12, aEps, aC3D, aC2D1, aC2D2,
+                                 myHS1, myHS2, myFace1, myFace2, myContext);
+       if (aD2>aD2max) {
+         aD2max=aD2;
+       }
+      }//for (j=0; j<aNbP; ++j) {
+     
+    }//for (i=1; i<=aNbLin; ++i) {
+    //
+    aD2=myTolReached3d*myTolReached3d;
+    if (aD2max > aD2) {
+      myTolReached3d=sqrt(aD2max);
+    }
+  }//else if ((aType1==GeomAbs_Plane && aType2==GeomAbs_Sphere) ...
+  //modified by NIZNHY-PKV Thu Aug 30 13:31:12 2012t
 }
 //=======================================================================
 //function : MakeCurve
@@ -4677,8 +4736,8 @@ Standard_Real FindMaxSquareDistance (const Standard_Real aT1,
                                     const Handle(Geom_Curve)& aC3D,
                                     const Handle(Geom2d_Curve)& aC2D1,
                                     const Handle(Geom2d_Curve)& aC2D2,
-                                    const Handle(GeomAdaptor_HSurface) myHS1,
-                                    const Handle(GeomAdaptor_HSurface) myHS2,
+                                    const Handle(GeomAdaptor_HSurface)& myHS1,
+                                    const Handle(GeomAdaptor_HSurface)& myHS2,
                                     const TopoDS_Face& myFace1,
                                     const TopoDS_Face& myFace2,
                                     const Handle(IntTools_Context)& myContext)
diff --git a/tests/boolean/bopcommon_complex/M7 b/tests/boolean/bopcommon_complex/M7
new file mode 100755 (executable)
index 0000000..c59f0a1
--- /dev/null
@@ -0,0 +1,13 @@
+puts "=================================================="
+puts "BOP common produces one face instead of a solid"
+puts "=================================================="
+
+restore [locate_data_file CR23405-Box_1.brep] bb
+restore [locate_data_file CR23405-Rotation_1.brep] rr
+
+bop bb rr
+bopcommon result
+
+set square 2435.25
+
+
diff --git a/tests/boolean/bopcommon_simple/ZP9 b/tests/boolean/bopcommon_simple/ZP9
new file mode 100755 (executable)
index 0000000..2c94093
--- /dev/null
@@ -0,0 +1,11 @@
+box bb 100 100 100
+plane pl1 98.946735014, 46.491265177, 17.092869659
+plane pl2 -1.053264986, 46.491265177, 17.092869659
+psphere s1 pl1 7.5
+psphere s2 pl2 7.5
+
+bop bb s1
+bopcommon result
+
+set square 576.293
+