0023708: The correct shape is interpreted as invalid
authorpdn <pdn@opencascade.com>
Thu, 28 Nov 2013 06:35:31 +0000 (10:35 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 28 Nov 2013 06:37:03 +0000 (10:37 +0400)
Added test case bugs/modalg_5/bug23708
Improvements in test case de/step_3/B8 (problem in second TODO is not reproduced)
Modified test case de/iges_2/H1 regarding to new reference data

src/BRepCheck/BRepCheck_Face.cxx
tests/bugs/modalg_5/bug23708 [new file with mode: 0644]
tests/de/iges_2/H1
tests/de/step_3/B8

index bfc9e45..024f912 100755 (executable)
@@ -41,6 +41,7 @@
 #include <BRepClass_FaceClassifier.hxx>
 //#include <Geom2dInt_GInter.hxx>
 #include <Geom2d_Curve.hxx>
+#include <Geom_Curve.hxx>
 #include <GProp_GProps.hxx>
 
 #include <IntRes2d_Domain.hxx>
@@ -650,50 +651,83 @@ static Standard_Boolean Intersect(const TopoDS_Wire& wir1,
 //purpose  : 
 //=======================================================================
 
-static Standard_Boolean IsInside(const TopoDS_Wire& wir,
+static Standard_Boolean IsInside(const TopoDS_Wire& theWire,
                                 const Standard_Boolean WireBienOriente,
                                 const BRepTopAdaptor_FClass2d& FClass2d,
-                                const TopoDS_Face& F)
+                                const TopoDS_Face& theFace)
 {
-  // Standard_Real U,V;
-  TopExp_Explorer exp;
-  exp.Init(wir,TopAbs_EDGE);
-  if (exp.More()) {
+  Standard_Real aParameter, aFirst, aLast;
+
+  TopExp_Explorer anExplorer(theWire, TopAbs_EDGE);
+  for( ; anExplorer.More(); anExplorer.Next() )
+  {
+    const TopoDS_Edge& anEdge = TopoDS::Edge( anExplorer.Current() );
+    Handle(Geom2d_Curve) aCurve2D =
+      BRep_Tool::CurveOnSurface( anEdge, theFace, aFirst, aLast );
+
+    // Selects the parameter of point on the curve
+    if( !Precision::IsNegativeInfinite(aFirst) &&
+        !Precision::IsPositiveInfinite(aLast) )
+    {
+      aParameter = (aFirst + aLast) * 0.5;
 
-    const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
-    Standard_Real f,l;
-    Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(edg,F,f,l);
-    Standard_Real prm;
+      // Edge is skipped if its parametric range is too small
+      if( Abs(aParameter - aFirst) < Precision::PConfusion() )
+      {
+        continue;
+      }
 
-    if (!Precision::IsNegativeInfinite(f) && 
-       !Precision::IsPositiveInfinite(l)) {
-      prm = (f+l)/2.;
+         //Edge is skipped if its length is too small
+         Standard_Real aFirst3D, aLast3D;
+         Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aFirst3D, aLast3D );      
+      if ( aCurve.IsNull() )
+      {
+        continue;
+      }
+
+      gp_Pnt aPoints[2];
+      // Compute start point of edge
+      aCurve->D0( aFirst, aPoints[0] );
+      // Compute middle point of edge 
+      aCurve->D0( (aFirst3D+aLast3D)/2., aPoints[1] );
+      if( aPoints[0].Distance(aPoints[1]) < Precision::Confusion() )
+      {
+        continue;
+      }
     }
-    else {
-      if (Precision::IsNegativeInfinite(f) && 
-         Precision::IsPositiveInfinite(l)){
-       prm = 0.;
+    else
+    {
+      if( Precision::IsNegativeInfinite(aFirst) &&
+          Precision::IsPositiveInfinite(aLast) )
+      {
+        aParameter = 0.;
       }
-      else if (Precision::IsNegativeInfinite(f)) {
-       prm = l-1.;
+      else if( Precision::IsNegativeInfinite(aFirst) )
+      {
+        aParameter = aLast - 1.;
       }
-      else {
-       prm = f+1.;
+      else
+      {
+        aParameter = aFirst + 1.;
       }
     }
 
-    gp_Pnt2d pt2d(C2d->Value(prm));
-    
-    if(WireBienOriente) { 
-      return(FClass2d.Perform(pt2d,Standard_False) == TopAbs_OUT);     
+    // Find point on curve (edge)
+    gp_Pnt2d aPoint2D(aCurve2D->Value(aParameter));
+    // Compute the topological position of a point relative to face
+    TopAbs_State aState = FClass2d.Perform(aPoint2D, Standard_False);
+
+    if( WireBienOriente )
+    {
+      return aState == TopAbs_OUT;
     }
-    else { 
-      return(FClass2d.Perform(pt2d,Standard_False) == TopAbs_IN);
+    else
+    {
+      return aState == TopAbs_IN;
     }
   }
   return Standard_False;
 }
-
 Standard_Boolean CheckThin(const TopoDS_Shape& w, const TopoDS_Shape& f)
 {
   TopoDS_Face aF = TopoDS::Face(f);
diff --git a/tests/bugs/modalg_5/bug23708 b/tests/bugs/modalg_5/bug23708
new file mode 100644 (file)
index 0000000..c0625c6
--- /dev/null
@@ -0,0 +1,12 @@
+puts "============"
+puts "OCC23708"
+puts "============"
+puts ""
+############################################################################
+# The correct shape is interpreted as invalid
+############################################################################
+
+restore [locate_data_file bug23708_invalidface.brep] result
+checkshape result
+
+set 2dviewer 1
index 64c8b77..c09f1c0 100755 (executable)
@@ -1,13 +1,10 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
-puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" 
-
-
 set filename waaier_para.igs
 
 set ref_data {
 DATA        : Faulties = 0  ( 1 )  Warnings = 0  ( 1 )  Summary  = 0  ( 2 )
 TPSTAT      : Faulties = 0  ( 0 )  Warnings = 40  ( 617 )  Summary  = 40  ( 617 )
-CHECKSHAPE  : Wires    = 2  ( 2 )  Faces    = 3  ( 2 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
+CHECKSHAPE  : Wires    = 2  ( 2 )  Faces    = 3  ( 3 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
 NBSHAPES    : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 162  ( 162 )   Summary  = 4900  ( 4895 )
 STATSHAPE   : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 162  ( 162 )   FreeWire = 0  ( 0 )   FreeEdge  = 0 ( 0 )   SharedEdge = 2291  ( 2288 )
 TOLERANCE   : MaxTol   =   0.9221218176  (   0.9410156556 )  AvgTol   =   0.01501963159  (   0.01437988687 )
index 665209a..550ead6 100644 (file)
@@ -1,6 +1,5 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: TPSTAT : Faulty" 
-puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" 
 
 set filename gehaeuse_solid.stp