From 34e923b5c20a626fc86c660784704cab0f6830b8 Mon Sep 17 00:00:00 2001 From: gka Date: Fri, 21 Nov 2014 14:51:01 +0300 Subject: [PATCH] 0025455: fixshape works at the second attempt Added check and fix of tolerances of all vertices after performing all fixes. It is necessary to avoid situation when point of vertex belonging a few faces was changed for current face but edges containing this vertex belonging before fixed face are not taking into account. Mode FixVertexTolMode to manage check tolerance of vertices was added in ShapeFix_Shape class. (default value is equal to -1) Method to change FixVertexTolMode mode FixVertexTolMode() was added in ShapeFix_Shape class Test case for CR25455 --- src/ShapeFix/ShapeFix_Shape.cdl | 7 +++++++ src/ShapeFix/ShapeFix_Shape.cxx | 27 +++++++++++++++++++++++++-- src/ShapeFix/ShapeFix_Shape.lxx | 10 ++++++++++ tests/bugs/heal/bug25455 | 21 +++++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 tests/bugs/heal/bug25455 diff --git a/src/ShapeFix/ShapeFix_Shape.cdl b/src/ShapeFix/ShapeFix_Shape.cdl index 6f29f0d170..dc5fb1d59b 100644 --- a/src/ShapeFix/ShapeFix_Shape.cdl +++ b/src/ShapeFix/ShapeFix_Shape.cdl @@ -135,6 +135,12 @@ is ---C++: inline ---Purpose: Returns (modifiable) the mode for applying -- ShapeFix::FixVertexPosition before all fixes, by default False. + + FixVertexTolMode (me: mutable) returns Integer; + ---C++: return & + ---C++: inline + ---Purpose: Returns (modifiable) the mode for fixing tolerances of vertices on whole shape + -- after performing all fixes fields myResult : Shape from TopoDS is protected; @@ -147,6 +153,7 @@ fields myFixWireMode : Integer is protected; myFixSameParameterMode : Integer is protected; myFixVertexPositionMode : Integer is protected; + myFixVertexTolMode : Integer is protected; myStatus : Integer is protected; end Shape; diff --git a/src/ShapeFix/ShapeFix_Shape.cxx b/src/ShapeFix/ShapeFix_Shape.cxx index 432995ee5b..4a7d57528d 100644 --- a/src/ShapeFix/ShapeFix_Shape.cxx +++ b/src/ShapeFix/ShapeFix_Shape.cxx @@ -53,6 +53,7 @@ ShapeFix_Shape::ShapeFix_Shape() myFixWireMode = -1; myFixSameParameterMode = -1; myFixVertexPositionMode =0; + myFixVertexTolMode = -1; myFixSolid = new ShapeFix_Solid; } @@ -71,6 +72,7 @@ ShapeFix_Shape::ShapeFix_Shape(const TopoDS_Shape& shape) myFixSameParameterMode = -1; myFixSolid = new ShapeFix_Solid; myFixVertexPositionMode =0; + myFixVertexTolMode = -1; Init(shape); } @@ -97,7 +99,7 @@ void ShapeFix_Shape::Init(const TopoDS_Shape& shape) Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator)& theProgress) { Standard_Integer savFixSmallAreaWireMode = 0; - + Standard_Integer savFixVertexTolMode = myFixVertexTolMode; Handle(ShapeFix_Face) fft = Handle(ShapeFix_Face)::DownCast( FixFaceTool() ); if ( !fft.IsNull() ) { savFixSmallAreaWireMode = fft->FixSmallAreaWireMode(); @@ -142,7 +144,7 @@ Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator) TopoDS_Shape shape = myShape; Standard_Boolean savFixSameParameterMode = myFixSameParameterMode; myFixSameParameterMode = Standard_False; - + myFixVertexTolMode = Standard_False; Standard_Integer aShapesNb = 0; for ( TopoDS_Iterator anIter(S); anIter.More(); anIter.Next() ) ++aShapesNb; @@ -159,6 +161,7 @@ Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator) return Standard_False; // aborted execution myFixSameParameterMode = savFixSameParameterMode; + myFixVertexTolMode = savFixVertexTolMode; myShape = shape; break; } @@ -242,6 +245,26 @@ Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator) { SameParameter(myResult, Standard_False, theProgress); } + if( NeedFix( myFixVertexTolMode)) + { + Standard_Integer nbF = 0; + TopExp_Explorer anExpF(myResult, TopAbs_FACE); + for( ; anExpF.More() && nbF <= 1; anExpF.Next()) + nbF++; + if( nbF > 1) + { + //fix for bug 0025455 + // for case when vertex belong to the different faces it is necessary to check vertices tolerances + //after all fixes. + //This fix it should be performed for example for case when cutting edge was performed. + + Handle(ShapeFix_Edge) sfe = FixEdgeTool(); + TopExp_Explorer anExpE (myResult, TopAbs_EDGE); + for ( ; anExpE.More(); anExpE.Next()) + sfe->FixVertexTolerance( TopoDS::Edge (anExpE.Current())); + + } + } if ( !fft.IsNull() ) fft->FixSmallAreaWireMode() = savFixSmallAreaWireMode; diff --git a/src/ShapeFix/ShapeFix_Shape.lxx b/src/ShapeFix/ShapeFix_Shape.lxx index 54b6cadb13..c694bbabba 100644 --- a/src/ShapeFix/ShapeFix_Shape.lxx +++ b/src/ShapeFix/ShapeFix_Shape.lxx @@ -122,3 +122,13 @@ inline Standard_Integer& ShapeFix_Shape::FixVertexPositionMode() { return myFixVertexPositionMode; } + +//======================================================================= +//function : FixVertexTolMode +//purpose : +//======================================================================= + +inline Standard_Integer& ShapeFix_Shape::FixVertexTolMode() +{ + return myFixVertexTolMode; +} \ No newline at end of file diff --git a/tests/bugs/heal/bug25455 b/tests/bugs/heal/bug25455 new file mode 100644 index 0000000000..f58039c6bc --- /dev/null +++ b/tests/bugs/heal/bug25455 @@ -0,0 +1,21 @@ +puts "============" +puts "OCC25455" +puts "============" +puts "" +###################################################### +# fixshape works at the second attempt +###################################################### + +restore [locate_data_file bug25455_rx.brep] rx + +fixshape rx rx + +set info [checkshape rx] + +# Resume +puts "" +if { [regexp {This shape seems to be valid} ${info}] } { + puts "OK: fixshape works properly" +} else { + puts "Error: fixshape works bad" +}