]> OCCT Git - occt.git/commitdiff
0027781: [Regression to 6.9.0] Exception in ShapeFix_Shape algorithm with option...
authormsv <msv@opencascade.com>
Thu, 18 Aug 2016 09:12:33 +0000 (12:12 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 1 Sep 2016 10:19:09 +0000 (13:19 +0300)
The matter was that during checking wires of a shape for small area, non-outer wires were checked with constructing a new face with BRepBuilderAPI_MakeFace. If a face has location an edge from original face has no pcurve on the constructed face, which leads to exception in BRepGProp::SurfaceProperties. The fix constructs new face using EmptyCopy.

The method ShapeAnalysis_Wire::CheckSmallArea() has been changed so as to check area of the outer wire without hole-wires. API of this method has been changed, as the second argument theIsOuterWire is not needed any more.

The test cases have been updated, below are explanations of changes:

test de iges_2 G7
The fixed version leaves a wire in a face, but the master version considered it small and removed. The master version works wrong. It is because the face built with this wire has negative area, but the code in CheckSmallArea function does not get absolute value before comparing area with the tolerance. The left wire leads to splitting of the face on two, checkshape error in the face, and statshape faulty due to increased number of faces in the second pass.

test de iges_2 G2
The fixed version leaves a wire that is removed in the master version. The cause is the same as in G7 test case. However, here the problematic wire has very big tolerance. So, when the fixed version left it in the shape, the overall maximal tolerance became much greater than in reference data.

test de step_3 E6
In fixed version a really bad small wire is removed from the face, while in master version it is left and produces an error in checkshape report. So, it is an improvement.

src/ShapeAnalysis/ShapeAnalysis_Wire.cxx
src/ShapeAnalysis/ShapeAnalysis_Wire.hxx
src/ShapeFix/ShapeFix_Face.cxx
tests/bugs/heal/bug27781 [new file with mode: 0644]
tests/de/iges_2/G2
tests/de/iges_2/G7
tests/de/step_3/E6

index 8032e2f5e2b841be9c22441b74e9706f1e64cb6c..9de76014e69067f5bc8c39a4379bbd69a5d84302 100644 (file)
@@ -1716,8 +1716,7 @@ Standard_Boolean ShapeAnalysis_Wire::CheckNotchedEdges(const Standard_Integer nu
 //function : CheckSmallArea
 //purpose  : 
 //=======================================================================
-Standard_Boolean ShapeAnalysis_Wire::CheckSmallArea(const TopoDS_Wire& theWire,
-                                                    const Standard_Boolean theIsOuterWire)
+Standard_Boolean ShapeAnalysis_Wire::CheckSmallArea(const TopoDS_Wire& theWire)
 {
   myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL1);
   const Standard_Integer aNbControl = 23;
@@ -1793,20 +1792,13 @@ Standard_Boolean ShapeAnalysis_Wire::CheckSmallArea(const TopoDS_Wire& theWire,
     // check real area in 3D
     GProp_GProps aProps;
     GProp_GProps aLProps;
-    if (theIsOuterWire)
-    {
-      BRepGProp::SurfaceProperties(myFace, aProps);
-      BRepGProp::LinearProperties(myFace, aLProps);
-    }
-    else
-    {
-      BRepBuilderAPI_MakeFace aFace(mySurf->Surface(), theWire);
-      BRepGProp::SurfaceProperties(aFace.Face(), aProps);
-      BRepGProp::LinearProperties(aFace.Face(), aLProps);
-    }
+    TopoDS_Face aFace = TopoDS::Face(myFace.EmptyCopied());
+    BRep_Builder().Add(aFace, theWire);
+    BRepGProp::SurfaceProperties(aFace, aProps);
+    BRepGProp::LinearProperties(aFace, aLProps);
 
     Standard_Real aNewTolerance = aLProps.Mass() * myPrecision;
-    if ( aProps.Mass() < 0.5 * aNewTolerance )
+    if ( Abs(aProps.Mass()) < 0.5 * aNewTolerance )
     {
       myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
       return Standard_True;
index aaaacce1edbe5af60554430b03372ea05414c0f8..fb0913bbc9677f0bdebc93f3816bde5c6402c41e 100644 (file)
@@ -421,7 +421,7 @@ public:
   Standard_EXPORT Standard_Boolean CheckNotchedEdges (const Standard_Integer num, Standard_Integer& shortNum, Standard_Real& param, const Standard_Real Tolerance = 0.0);
   
   //! Checks if wire has parametric area less than precision.
-  Standard_EXPORT Standard_Boolean CheckSmallArea (const TopoDS_Wire& theWire, const Standard_Boolean theIsOuterWire);
+  Standard_EXPORT Standard_Boolean CheckSmallArea (const TopoDS_Wire& theWire);
   
   //! Checks with what orientation <shape> (wire or edge) can be
   //! connected to the wire.
index 589c4feff7a8ac477125c89337cec926b9474b1a..b5bc649e17deea0ec2974e8fd78d59d98592f86b 100644 (file)
@@ -1889,7 +1889,6 @@ Standard_Boolean ShapeFix_Face::FixSmallAreaWire(const Standard_Boolean theIsRem
   TopoDS_Shape anEmptyCopy = myFace.EmptyCopied();
   TopoDS_Face  aFace = TopoDS::Face(anEmptyCopy);
 
-  const TopoDS_Wire   anOuterWire  = BRepTools::OuterWire(myFace);
   const Standard_Real aTolerance3d = ShapeFix_Root::Precision();
   for (TopoDS_Iterator aWIt(myFace, Standard_False); aWIt.More(); aWIt.Next())
   {
@@ -1902,9 +1901,8 @@ Standard_Boolean ShapeFix_Face::FixSmallAreaWire(const Standard_Boolean theIsRem
     }
 
     const TopoDS_Wire&         aWire       = TopoDS::Wire(aShape);
-    const Standard_Boolean     isOuterWire = anOuterWire.IsEqual(aWire);
     Handle(ShapeAnalysis_Wire) anAnalyzer  = new ShapeAnalysis_Wire(aWire, myFace, aTolerance3d);
-    if ( anAnalyzer->CheckSmallArea(aWire, isOuterWire) )
+    if ( anAnalyzer->CheckSmallArea(aWire) )
     {
       // Null area wire detected, wire skipped
       SendWarning(aWire, Message_Msg("FixAdvFace.FixSmallAreaWire.MSG0"));
diff --git a/tests/bugs/heal/bug27781 b/tests/bugs/heal/bug27781
new file mode 100644 (file)
index 0000000..a64f20b
--- /dev/null
@@ -0,0 +1,14 @@
+puts "========"
+puts "OCC27781"
+puts "========"
+puts ""
+#############################################
+# Exception in ShapeFix_Shape algorithm with option FixSmallAreaWireMode
+#############################################
+
+restore [locate_data_file bug27781_face_with_small_wires.brep] a
+
+fixshape result a +s
+
+checkshape result
+checkview -display result -2d -path ${imagedir}/${test_image}.png
index 0c4096152a58d35e856e7978a55b998c8c9b0b9e..c8e11c54ad18870b2672be9ab30e7c271c623f65 100644 (file)
@@ -1,5 +1,6 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: TPSTAT : Faulty" 
+puts "TODO CR23096 ALL: TOLERANCE : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 
 
@@ -9,9 +10,9 @@ set ref_data {
 DATA        : Faulties = 0  ( 0 )  Warnings = 0  ( 1 )  Summary  = 0  ( 1 )
 TPSTAT      : Faulties = 2  ( 0 )  Warnings = 174  ( 940 )  Summary  = 176  ( 940 )
 CHECKSHAPE  : Wires    = 8  ( 8 )  Faces    = 5  ( 5 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
-NBSHAPES    : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 346  ( 346 )   Summary  = 25253  ( 25254 )
-STATSHAPE   : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 346  ( 346 )   FreeWire = 84  ( 84 )   FreeEdge  = 1563 ( 1563 )   SharedEdge = 12102  ( 12103 )
-TOLERANCE   : MaxTol   =  0.08971322527  (   0.2157335194 )  AvgTol   =  0.001218977908  (   0.00125488316 )
+NBSHAPES    : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 346  ( 346 )   Summary  = 25259  ( 25254 )
+STATSHAPE   : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 346  ( 346 )   FreeWire = 84  ( 84 )   FreeEdge  = 1563 ( 1563 )   SharedEdge = 12104  ( 12103 )
+TOLERANCE   : MaxTol   =  0.4314224119  (   0.2157335194 )  AvgTol   =  0.001277618654  (   0.00125488316 )
 LABELS      : N0Labels = 560  ( 560 )  N1Labels = 94  ( 90 )  N2Labels = 0  ( 0 )   TotalLabels = 654  ( 650 )   NameLabels = 648  ( 650 )   ColorLabels = 554  ( 640 )   LayerLabels = 554  ( 640 )
 PROPS       : Centroid = 0  ( 0 )  Volume   = 0  ( 0 )  Area     = 0  ( 0 )
 NCOLORS     : NColors  = 3  ( 3 )
index a5a86ff46290d6dae7e7f9aea5a62989562c8f1f..e9332048465fe448b322c3ecd2e7db8e28a11589 100644 (file)
@@ -1,6 +1,7 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" 
 puts "TODO CR23096 ALL: NBSHAPES : Faulty" 
+puts "TODO CR23096 ALL: STATSHAPE : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
 
@@ -10,11 +11,11 @@ set filename PRO18777-3.igs
 set ref_data {
 DATA        : Faulties = 0  ( 0 )  Warnings = 0  ( 0 )  Summary  = 0  ( 0 )
 TPSTAT      : Faulties = 0  ( 0 )  Warnings = 83  ( 1468 )  Summary  = 83  ( 1468 )
-CHECKSHAPE  : Wires    = 1  ( 0 )  Faces    = 1  ( 0 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
-NBSHAPES    : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 1568  ( 1568 )   Summary  = 19278  ( 19295 )
-STATSHAPE   : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 1568  ( 1568 )   FreeWire = 0  ( 14 )   FreeEdge  = 28 ( 28 )   SharedEdge = 8144  ( 8146 )
+CHECKSHAPE  : Wires    = 2  ( 0 )  Faces    = 2  ( 1 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
+NBSHAPES    : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 1569  ( 1568 )   Summary  = 19295  ( 19301 )
+STATSHAPE   : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 1569  ( 1568 )   FreeWire = 0  ( 14 )   FreeEdge  = 28 ( 28 )   SharedEdge = 8152  ( 8150 )
 TOLERANCE   : MaxTol   =   0.9978911708  (   0.9978911666 )  AvgTol   =   0.01211223258  (   0.01212850169 )
-LABELS      : N0Labels = 1  ( 1 )  N1Labels = 1596  ( 5183 )  N2Labels = 0  ( 0 )   TotalLabels = 1597  ( 5184 )   NameLabels = 1597  ( 2711 )   ColorLabels = 1596  ( 5183 )   LayerLabels = 1596  ( 5183 )
+LABELS      : N0Labels = 1  ( 1 )  N1Labels = 1596  ( 5187 )  N2Labels = 0  ( 0 )   TotalLabels = 1597  ( 5188 )   NameLabels = 1597  ( 2711 )   ColorLabels = 1596  ( 5187 )   LayerLabels = 1596  ( 5187 )
 PROPS       : Centroid = 0  ( 0 )  Volume   = 0  ( 0 )  Area     = 0  ( 0 )
 NCOLORS     : NColors  = 2  ( 7 )
 COLORS      : Colors   = BLUE1 WHITE  ( BLUE1 CYAN1 GREEN MAGENTA1 RED WHITE YELLOW )
index bcd42a93b4b2cc947cfc9cc850499964112e4f1a..2611c72da189fdaceb688cfec803436cdf06540f 100755 (executable)
@@ -8,8 +8,8 @@ set ref_data {
 DATA        : Faulties = 0  ( 0 )  Warnings = 0  ( 0 )  Summary  = 0  ( 0 )
 TPSTAT      : Faulties = 0  ( 0 )  Warnings = 940  ( 3170 )  Summary  = 940  ( 3170 )
 CHECKSHAPE  : Wires    = 49  ( 43 )  Faces    = 50  ( 49 )  Shells   = 0  ( 2 )   Solids   = 0 ( 0 )
-NBSHAPES    : Solid    = 28  ( 28 )  Shell    = 768  ( 30 )  Face     = 3240  ( 3239 )   Summary  = 29373  ( 28626 )
-STATSHAPE   : Solid    = 28  ( 28 )  Shell    = 768  ( 30 )  Face     = 3240  ( 3239 )   FreeWire = 0  ( 0 )   FreeEdge  = 0 ( 0 )   SharedEdge = 12585  ( 12577 )
+NBSHAPES    : Solid    = 28  ( 28 )  Shell    = 768  ( 30 )  Face     = 3240  ( 3239 )   Summary  = 29365  ( 28618 )
+STATSHAPE   : Solid    = 28  ( 28 )  Shell    = 768  ( 30 )  Face     = 3240  ( 3239 )   FreeWire = 0  ( 0 )   FreeEdge  = 0 ( 0 )   SharedEdge = 12581  ( 12573 )
 TOLERANCE   : MaxTol   =    15.00300076  (    20.46526799 )  AvgTol   =   0.02248945623  (   0.03724082116 )
 LABELS      : N0Labels = 3  ( 3 )  N1Labels = 2  ( 2 )  N2Labels = 0  ( 0 )   TotalLabels = 5  ( 5 )   NameLabels = 5  ( 5 )   ColorLabels = 0  ( 0 )   LayerLabels = 0  ( 0 )
 PROPS       : Centroid = 0  ( 0 )  Volume   = 0  ( 0 )  Area     = 0  ( 0 )