From 8b1e055f0b802af8598353ae34e22e1a7d4652b1 Mon Sep 17 00:00:00 2001 From: msv Date: Thu, 18 Aug 2016 12:12:33 +0300 Subject: [PATCH] 0027781: [Regression to 6.9.0] Exception in ShapeFix_Shape algorithm with option FixSmallAreaWireMode 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 | 20 ++++++-------------- src/ShapeAnalysis/ShapeAnalysis_Wire.hxx | 2 +- src/ShapeFix/ShapeFix_Face.cxx | 4 +--- tests/bugs/heal/bug27781 | 14 ++++++++++++++ tests/de/iges_2/G2 | 7 ++++--- tests/de/iges_2/G7 | 9 +++++---- tests/de/step_3/E6 | 4 ++-- 7 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 tests/bugs/heal/bug27781 diff --git a/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx b/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx index 8032e2f5e2..9de76014e6 100644 --- a/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx @@ -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; diff --git a/src/ShapeAnalysis/ShapeAnalysis_Wire.hxx b/src/ShapeAnalysis/ShapeAnalysis_Wire.hxx index aaaacce1ed..fb0913bbc9 100644 --- a/src/ShapeAnalysis/ShapeAnalysis_Wire.hxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Wire.hxx @@ -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 (wire or edge) can be //! connected to the wire. diff --git a/src/ShapeFix/ShapeFix_Face.cxx b/src/ShapeFix/ShapeFix_Face.cxx index 589c4feff7..b5bc649e17 100644 --- a/src/ShapeFix/ShapeFix_Face.cxx +++ b/src/ShapeFix/ShapeFix_Face.cxx @@ -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 index 0000000000..a64f20bbaf --- /dev/null +++ b/tests/bugs/heal/bug27781 @@ -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 diff --git a/tests/de/iges_2/G2 b/tests/de/iges_2/G2 index 0c4096152a..c8e11c54ad 100644 --- a/tests/de/iges_2/G2 +++ b/tests/de/iges_2/G2 @@ -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 ) diff --git a/tests/de/iges_2/G7 b/tests/de/iges_2/G7 index a5a86ff462..e933204846 100644 --- a/tests/de/iges_2/G7 +++ b/tests/de/iges_2/G7 @@ -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 ) diff --git a/tests/de/step_3/E6 b/tests/de/step_3/E6 index bcd42a93b4..2611c72da1 100755 --- a/tests/de/step_3/E6 +++ b/tests/de/step_3/E6 @@ -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 )