0026609: Wrong result obtained by solid classifier algorithm.
authorifv <ifv@opencascade.com>
Thu, 8 Oct 2015 10:26:15 +0000 (13:26 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 8 Oct 2015 10:29:04 +0000 (13:29 +0300)
Test case for issue CR26609

Correction of test cases for issue CR26609

src/BRepClass3d/BRepClass3d_SolidExplorer.cxx
src/IntCurvesFace/IntCurvesFace_Intersector.cxx
src/IntCurvesFace/IntCurvesFace_Intersector.hxx
tests/boolean/gdml_private/T2
tests/boolean/gdml_private/ZJ3
tests/boolean/gdml_private/ZJ4
tests/boolean/volumemaker/D4
tests/bugs/modalg_6/bug26609 [new file with mode: 0755]

index 99b60c9..051eac5 100644 (file)
@@ -247,13 +247,23 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace
   Standard_Real v,dv = (V2-V1)/6.0;
   if(du<1e-12) du=1e-12;
   if(dv<1e-12) dv=1e-12;
   Standard_Real v,dv = (V2-V1)/6.0;
   if(du<1e-12) du=1e-12;
   if(dv<1e-12) dv=1e-12;
+  Standard_Boolean IsNotUper = !surf->IsUPeriodic(), IsNotVper = !surf->IsVPeriodic();
   Standard_Integer NbPntCalc=0;
   if(myMapOfInter.IsBound(Face)) { 
     void *ptr = (void*)(myMapOfInter.Find(Face));
   Standard_Integer NbPntCalc=0;
   if(myMapOfInter.IsBound(Face)) { 
     void *ptr = (void*)(myMapOfInter.Find(Face));
+    Standard_Boolean IsInside = Standard_True;
+    if(IsNotUper)
+    {
+      IsInside = (u_ >= U1) && (u_ <= U2);
+    }
+    if(IsNotVper)
+    {
+      IsInside &= (v_ >= V1) && (v_ <= V2);
+    }
     if(ptr) { 
       const IntCurvesFace_Intersector& TheIntersector = (*((IntCurvesFace_Intersector *)ptr));
       // Check if the point is already in the face
     if(ptr) { 
       const IntCurvesFace_Intersector& TheIntersector = (*((IntCurvesFace_Intersector *)ptr));
       // Check if the point is already in the face
-      if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u_,v_))==TopAbs_IN) {
+      if(IsInside && (TheIntersector.ClassifyUVPoint(gp_Pnt2d(u_,v_))==TopAbs_IN)) {
         gp_Pnt aPnt;
         surf->D1(u_, v_, aPnt, theVecD1U, theVecD1V);
         if (aPnt.SquareDistance(APoint_) < Precision::Confusion() * Precision::Confusion())
         gp_Pnt aPnt;
         surf->D1(u_, v_, aPnt, theVecD1U, theVecD1V);
         if (aPnt.SquareDistance(APoint_) < Precision::Confusion() * Precision::Confusion())
@@ -429,6 +439,8 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
   Standard_Integer IndexPoint=0;
   Standard_Integer NbPointsOK=0;
   Standard_Integer NbFacesInSolid=0;
   Standard_Integer IndexPoint=0;
   Standard_Integer NbPointsOK=0;
   Standard_Integer NbFacesInSolid=0;
+  Standard_Boolean aRestr = Standard_True;
+  Standard_Boolean aTestInvert = Standard_False;
 
   for(;;) { 
     myFirstFace++; 
 
   for(;;) { 
     myFirstFace++; 
@@ -436,6 +448,7 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
     // look for point on face starting from myFirstFace
 //  Modified by skv - Thu Sep  4 14:31:12 2003 OCC578 Begin
 //     while (faceexplorer.More()) {
     // look for point on face starting from myFirstFace
 //  Modified by skv - Thu Sep  4 14:31:12 2003 OCC578 Begin
 //     while (faceexplorer.More()) {
+    NbFacesInSolid = 0;
     for (; faceexplorer.More(); faceexplorer.Next()) {
 //  Modified by skv - Thu Sep  4 14:31:12 2003 OCC578 End
       NbFacesInSolid++;
     for (; faceexplorer.More(); faceexplorer.Next()) {
 //  Modified by skv - Thu Sep  4 14:31:12 2003 OCC578 End
       NbFacesInSolid++;
@@ -443,7 +456,26 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
       face = TopoDS::Face(faceexplorer.Current());
 
       Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
       face = TopoDS::Face(faceexplorer.Current());
 
       Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
-      surf->ChangeSurface().Initialize(face);
+      if(aTestInvert)
+      {
+        BRepTopAdaptor_FClass2d aClass(face, Precision::Confusion());
+        if(aClass.PerformInfinitePoint() == TopAbs_IN)
+        {
+          aRestr = Standard_False;
+          if(myMapOfInter.IsBound(face))
+          {
+            myMapOfInter.UnBind(face);
+            void *ptr = (void *)(new IntCurvesFace_Intersector(face, Precision::Confusion(),
+                                                               aRestr));
+            myMapOfInter.Bind(face,ptr);
+          }
+        }
+        else
+        {
+          aRestr = Standard_True;
+        }
+      }
+      surf->ChangeSurface().Initialize(face, aRestr);
       Standard_Real U1,V1,U2,V2;
       U1 = surf->FirstUParameter();
       V1 = surf->FirstVParameter();
       Standard_Real U1,V1,U2,V2;
       U1 = surf->FirstUParameter();
       V1 = surf->FirstVParameter();
@@ -452,7 +484,10 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
       face.Orientation(TopAbs_FORWARD);
       //
       //avoid process faces from uncorrected shells
       face.Orientation(TopAbs_FORWARD);
       //
       //avoid process faces from uncorrected shells
-      if( Abs (U2 - U1) < 1.e-12 || Abs(V2 - V1) < 1.e-12) {
+      const Standard_Real eps = Precision::PConfusion();
+      Standard_Real epsU = Max(eps * Max(Abs(U2), Abs(U1)), eps);
+      Standard_Real epsV = Max(eps * Max(Abs(V2), Abs(V1)), eps);
+      if( Abs (U2 - U1) < epsU || Abs(V2 - V1) < epsV) {
         return 2;
       }
       //
         return 2;
       }
       //
@@ -622,6 +657,7 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
         return 0;
       }
     }
         return 0;
       }
     }
+    aTestInvert = Standard_True;
   } //-- for(;;) { ...  } 
 }
 
   } //-- for(;;) { ...  } 
 }
 
index 9b7d6be..a1bc431 100644 (file)
@@ -55,7 +55,8 @@ GeomAbs_SurfaceType IntCurvesFace_Intersector::SurfaceType() const
 //purpose  : 
 //=======================================================================
 IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
 //purpose  : 
 //=======================================================================
 IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
-                                                    const Standard_Real aTol)
+                                                     const Standard_Real aTol,
+                                                     const Standard_Boolean aRestr)
 : 
   Tol(aTol),
   done(Standard_False),
 : 
   Tol(aTol),
   done(Standard_False),
@@ -65,7 +66,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
 { 
   BRepAdaptor_Surface surface;
   face = Face;
 { 
   BRepAdaptor_Surface surface;
   face = Face;
-  surface.Initialize(Face,Standard_True);
+  surface.Initialize(Face, aRestr);
   Hsurface = new BRepAdaptor_HSurface(surface);
   myTopolTool = new BRepTopAdaptor_TopolTool(Hsurface);
   
   Hsurface = new BRepAdaptor_HSurface(surface);
   myTopolTool = new BRepTopAdaptor_TopolTool(Hsurface);
   
index f53346a..d853d39 100644 (file)
@@ -56,7 +56,11 @@ public:
   //! first point of the segment is near the face. In
   //! that case, the parameter of the intersection point
   //! on the line can be a negative value (greater than -Tol).
   //! first point of the segment is near the face. In
   //! that case, the parameter of the intersection point
   //! on the line can be a negative value (greater than -Tol).
-  Standard_EXPORT IntCurvesFace_Intersector(const TopoDS_Face& F, const Standard_Real aTol);
+  //! If aRestr = true UV bounding box of face is used to restrict 
+  //! it's underlined surface,
+  //! otherwise surface is not restricted
+  Standard_EXPORT IntCurvesFace_Intersector(const TopoDS_Face& F, const Standard_Real aTol, 
+                                            const Standard_Boolean aRestr = Standard_True);
   
   //! Perform the intersection between the
   //! segment L and the loaded face.
   
   //! Perform the intersection between the
   //! segment L and the loaded face.
index d79c76b..374516f 100644 (file)
@@ -1,3 +1,3 @@
-puts "TODO OCC26018 ALL: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC26018 Windows: Faulty shapes in variables faulty_1 to faulty_"
 source [locate_data_file 20000_salle-experience.asm.4.gdml.tcl]
 
 source [locate_data_file 20000_salle-experience.asm.4.gdml.tcl]
 
index 1d235aa..d7be5dc 100644 (file)
@@ -1,3 +1,3 @@
-puts "TODO OCC26018 ALL: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC26018 Windows: Faulty shapes in variables faulty_1 to faulty_"
 source [locate_data_file mos2014-po-modif.prt.1.gdml.tcl]
 
 source [locate_data_file mos2014-po-modif.prt.1.gdml.tcl]
 
index c134b6f..c514598 100644 (file)
@@ -1,3 +1,3 @@
-puts "TODO OCC26018 ALL: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC26018 Windows: Faulty shapes in variables faulty_1 to faulty_"
 source [locate_data_file mos2014-po-modif.prt.15.gdml.tcl]
 
 source [locate_data_file mos2014-po-modif.prt.15.gdml.tcl]
 
index e66854d..09f0aea 100644 (file)
@@ -47,5 +47,5 @@ mkface f8 cyl_f8 0 6.2831853071795862 -1000000 1000000
 # make volume operation 
 mkvolume result f1 f2 f3 f4 f5 f6 f7 f8
 
 # make volume operation 
 mkvolume result f1 f2 f3 f4 f5 f6 f7 f8
 
-set square 5.00014e+007
+set square 1.99784e+007
 
 
diff --git a/tests/bugs/modalg_6/bug26609 b/tests/bugs/modalg_6/bug26609
new file mode 100755 (executable)
index 0000000..6db9909
--- /dev/null
@@ -0,0 +1,21 @@
+puts "============"
+puts "OCC26609"
+puts "============"
+puts ""
+############################################################################
+# Wrong result obtained by solid classifier algorithm.
+############################################################################
+
+restore [locate_data_file bug26609_p.draw] p
+restore [locate_data_file bug26609_z.brep] z
+
+set cls1 [bclassify z p]
+if { [regexp {OUT} $cls1] } {
+    puts "Error : Wrong result obtained by solid classifier algorithm"
+} else {
+    puts "OK : Good result obtained by solid classifier algorithm"
+}
+
+smallview
+fit
+set only_screen_axo 1