From 3f50e94e339e21741dee91b9e9820cb4075725c5 Mon Sep 17 00:00:00 2001 From: drazmyslovich Date: Mon, 23 Apr 2018 17:38:32 +0300 Subject: [PATCH] 0029717: Shape Healing - ShapeFix_Face::FixSmallAreaWire delivers a face with wrong-oriented wires + 1 small crash-fix - Fix FixSmallAreaWire for the reversed faces. - Add nullptr check for FixOrient... - Test bugs heal bug25923 is corrected to avoid relying on wrong orientation of face after fixing small wire --- src/ShapeFix/ShapeFix_Face.cxx | 10 ++++++++-- tests/bugs/heal/bug25923 | 23 ++++------------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/ShapeFix/ShapeFix_Face.cxx b/src/ShapeFix/ShapeFix_Face.cxx index a4529252f5..0854b5b736 100644 --- a/src/ShapeFix/ShapeFix_Face.cxx +++ b/src/ShapeFix/ShapeFix_Face.cxx @@ -1156,6 +1156,10 @@ Standard_Boolean ShapeFix_Face::FixOrientation(TopTools_DataMapOfShapeListOfShap for(;ew.More(); ew.Next()) { TopoDS_Edge ed = TopoDS::Edge (ew.Value()); Handle(Geom2d_Curve) cw = BRep_Tool::CurveOnSurface (ed,myFace,cf,cl); + if (cw.IsNull ()) + { + continue; + } Geom2dAdaptor_Curve gac; Standard_Real aFirst = cw->FirstParameter(); Standard_Real aLast = cw->LastParameter(); @@ -1888,6 +1892,7 @@ Standard_Boolean ShapeFix_Face::FixSmallAreaWire(const Standard_Boolean theIsRem TopoDS_Shape anEmptyCopy = myFace.EmptyCopied(); TopoDS_Face aFace = TopoDS::Face(anEmptyCopy); + aFace.Orientation (TopAbs_FORWARD); const Standard_Real aTolerance3d = ShapeFix_Root::Precision(); for (TopoDS_Iterator aWIt(myFace, Standard_False); aWIt.More(); aWIt.Next()) @@ -1931,8 +1936,9 @@ Standard_Boolean ShapeFix_Face::FixSmallAreaWire(const Standard_Boolean theIsRem #ifdef OCCT_DEBUG std::cout << "Warning: ShapeFix_Face: " << nbRemoved << " small area wire(s) removed" << std::endl; #endif - if ( !Context().IsNull() ) - Context()->Replace(myFace, aFace); + aFace.Orientation (myFace.Orientation ()); + if (!Context ().IsNull ()) + Context ()->Replace (myFace, aFace); myFace = aFace; return Standard_True; diff --git a/tests/bugs/heal/bug25923 b/tests/bugs/heal/bug25923 index bc082d1046..3b8b390112 100644 --- a/tests/bugs/heal/bug25923 +++ b/tests/bugs/heal/bug25923 @@ -1,28 +1,13 @@ -puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_" puts "========" -puts "OCC25923" +puts "0025923: Remove small wires on face read from STEP" puts "========" puts "" -############################################# -# Remove small wires on face read from STEP -############################################# -smallview restore [locate_data_file OCC25923_FixSmallWire_Orientation.brep] a -fit checkshape a -fixshape r1 a +s +o 1e-3 +fixshape r a +s +o 1e-3 -fixshape r2 r1 +o - -if {[regexp {This shape seems to be valid} [checkshape r1] ]} { - puts "ERRROR: OCC25923 is reproduced. Algorythm of removing small wires on face does not work." -} - -if {![regexp {This shape seems to be valid} [checkshape r2] ]} { - puts "ERRROR: OCC25923 is reproduced. Algorythm of removing small wires on face does not work." -} - -checkview -screenshot -2d -path ${imagedir}/${test_image}.png +checkshape r +checknbshapes r -face 1 -wire 2 -edge 32 -vertex 32