From 999d2599eab1393d17ec7e37bb4e6d58980803d5 Mon Sep 17 00:00:00 2001 From: DBV <> Date: Fri, 16 Dec 2011 11:18:18 +0000 Subject: [PATCH] 0022767: Extension of DRAW command fixshape --- src/SHMessage/SHAPE.fr | 9 ++-- src/SHMessage/SHAPE.us | 11 ++--- src/SWDRAW/SWDRAW_ShapeFix.cxx | 78 ++++++++++++++++++++++----------- src/ShapeFix/ShapeFix_Face.cxx | 46 +++++++++---------- src/ShapeFix/ShapeFix_Shell.cxx | 8 ++-- src/ShapeFix/ShapeFix_Wire.cxx | 51 +++++++-------------- 6 files changed, 102 insertions(+), 101 deletions(-) diff --git a/src/SHMessage/SHAPE.fr b/src/SHMessage/SHAPE.fr index a48e2ab8ee..f1ab94b00e 100755 --- a/src/SHMessage/SHAPE.fr +++ b/src/SHMessage/SHAPE.fr @@ -86,10 +86,10 @@ L'arete n0 %d etait petite, supprimee Auto-intersection corrigee ! .FixAdvWire.FixIntersection.MSG5 -L'arete %d etait auto-intersectante, corrigee +L'arete etait auto-intersectante, corrigee ! .FixAdvWire.FixIntersection.MSG10 -Les aretes n0 %d et %d s'intersectaient, corrigees +Les aretes s'intersectent, corrigees ! .FixAdvWire.FixLacking.MSG0 Insertion d'arete(s) manquante(s) @@ -118,11 +118,8 @@ Face creee avec bords naturels .FixAdvFace.FixOrientation.MSG5 Contour sur face inverse ! -.FixAdvFace.FixOrientation.MSG10 -Le Contour n0 %d parmi %d de la face a ete inverse -! .FixAdvFace.FixOrientation.MSG11 -Impossible d'orienter les contour n0 %d parmi %d +Impossible d'orienter le contour ! .FixAdvShell.FixOrientation.MSG20 Impossible d'orienter les faces dans le shell, creation de plusieurs shells diff --git a/src/SHMessage/SHAPE.us b/src/SHMessage/SHAPE.us index 36d4ef2eee..ff4a0bbb67 100755 --- a/src/SHMessage/SHAPE.us +++ b/src/SHMessage/SHAPE.us @@ -94,10 +94,10 @@ Edge %d was small, removed Self-intersection corrected ! .FixAdvWire.FixIntersection.MSG5 -Edge %d was self-intersecting, corrected +Edge was self-intersecting, corrected ! .FixAdvWire.FixIntersection.MSG10 -Edges %d and %d were intersecting, corrected +Edges were intersecting, corrected ! .FixAdvWire.FixLacking.MSG0 Lacking edge(s) inserted @@ -126,11 +126,8 @@ Face created with natural bounds .FixAdvFace.FixOrientation.MSG5 Wire on face was reversed ! -.FixAdvFace.FixOrientation.MSG10 -Wire %d of %d on face was reversed -! .FixAdvFace.FixOrientation.MSG11 -Cannot orient wire %d of %d +Cannot orient wire ! .FixAdvShell.FixOrientation.MSG20 Impossible to orient faces in shell, several shells created @@ -148,7 +145,7 @@ Orientation of shell(s) in solid was corrected Improperly connected solid split into several parts ! .FixAdvFace.FixLoopWire.MSG0 -Wire was splitted on %d wires +Wire was splitted on several wires ! .FixAdvFace..MSG5 ! diff --git a/src/SWDRAW/SWDRAW_ShapeFix.cxx b/src/SWDRAW/SWDRAW_ShapeFix.cxx index 451087bb67..6c8ea3e11d 100755 --- a/src/SWDRAW/SWDRAW_ShapeFix.cxx +++ b/src/SWDRAW/SWDRAW_ShapeFix.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,8 @@ #include #include #include +#include +#include #include #include #include @@ -395,15 +398,15 @@ static Standard_Integer fixshape (Draw_Interpretor& di, Standard_Integer argc, c if ( argv[i][0] == '-' || argv[i][0] == '+' || argv[i][0] == '*' ) { Standard_Integer val = ( argv[i][0] == '-' ? 0 : argv[i][0] == '+' ? 1 : -1 ); switch ( argv[i][1] ) { - case 'l': sfs->FixWireTool()->FixLackingMode() = val; - case 'o': sfs->FixFaceTool()->FixOrientationMode() = val; - case 'h': sfs->FixWireTool()->FixShiftedMode() = val; - case 'm': sfs->FixFaceTool()->FixMissingSeamMode() = val; - case 'd': sfs->FixWireTool()->FixDegeneratedMode() = val; - case 's': sfs->FixWireTool()->FixSmallMode() = val; - case 'i': sfs->FixWireTool()->FixSelfIntersectionMode() = val; - case 'n': sfs->FixWireTool()->FixNotchedEdgesMode() = val; - case '?': mess = val; + case 'l': sfs->FixWireTool()->FixLackingMode() = val; break; + case 'o': sfs->FixFaceTool()->FixOrientationMode() = val; break; + case 'h': sfs->FixWireTool()->FixShiftedMode() = val; break; + case 'm': sfs->FixFaceTool()->FixMissingSeamMode() = val; break; + case 'd': sfs->FixWireTool()->FixDegeneratedMode() = val; break; + case 's': sfs->FixWireTool()->FixSmallMode() = val; break; + case 'i': sfs->FixWireTool()->FixSelfIntersectionMode() = val; break; + case 'n': sfs->FixWireTool()->FixNotchedEdgesMode() = val; break; + case '?': mess = val; break; } continue; } @@ -444,24 +447,49 @@ static Standard_Integer fixshape (Draw_Interpretor& di, Standard_Integer argc, c sfs->Perform (aProgress); DBRep::Set (res,sfs->Shape()); - if ( mess ) { - Standard_Integer num = 0; + if ( mess ) + { + TColStd_DataMapOfAsciiStringInteger aMapOfNumberOfFixes; + Standard_SStream aSStream; + TopoDS_Compound aCompound; + BRep_Builder aBuilder; + aBuilder.MakeCompound (aCompound); const ShapeExtend_DataMapOfShapeListOfMsg &map = msg->MapShape(); - for ( ShapeExtend_DataMapIteratorOfDataMapOfShapeListOfMsg it(map); it.More(); it.Next() ) { - //cout << it.Key().TShape()->DynamicType()->Name() << " " << *(void**)&it.Key().TShape(); - Standard_SStream aSStream; - aSStream << it.Key().TShape()->DynamicType()->Name() << " " << *(void**)&it.Key().TShape(); - di << aSStream; - - if ( mess <0 ) { - char buff[256]; - sprintf ( buff, "%s_%d", res, ++num ); - di << " (saved in DRAW shape " << buff << ")"; - DBRep::Set (buff,it.Key()); + // Counting the number of each type of fixes. If the switch '*?' store all modified shapes in compound. + for ( ShapeExtend_DataMapIteratorOfDataMapOfShapeListOfMsg it ( map ); it.More(); it.Next() ) + { + for ( Message_ListIteratorOfListOfMsg iter ( it.Value() ); iter.More(); iter.Next() ) + { + if ( aMapOfNumberOfFixes.IsBound ( iter.Value().Value() ) ) + { + aMapOfNumberOfFixes ( iter.Value().Value() )++; + } + else + { + aMapOfNumberOfFixes.Bind ( iter.Value().Value(), 1 ); + } } - di << ":" << "\n"; - for (Message_ListIteratorOfListOfMsg iter (it.Value()); iter.More(); iter.Next()) - di << " " << TCollection_AsciiString(iter.Value().Value()).ToCString() << "\n"; + if ( mess < 0 ) + { + aBuilder.Add ( aCompound, it.Key() ); + } + } + + aSStream << " Fix" << setw (58) << "Count\n"; + aSStream << " ------------------------------------------------------------\n"; + for ( TColStd_DataMapIteratorOfDataMapOfAsciiStringInteger anIter ( aMapOfNumberOfFixes ); anIter.More(); anIter.Next() ) + { + aSStream << " " << anIter.Key() << setw ( 60 - anIter.Key().Length() ) << anIter.Value() << "\n"; + } + aSStream << " ------------------------------------------------------------\n"; + di << aSStream; + + if ( mess < 0 ) + { + char buff[256]; + sprintf ( buff, "%s_%s", res, "m" ); + di << " Modified shapes saved in compound: " << buff; + DBRep::Set (buff, aCompound); } } diff --git a/src/ShapeFix/ShapeFix_Face.cxx b/src/ShapeFix/ShapeFix_Face.cxx index 5cc19873f4..2c6255bbc8 100755 --- a/src/ShapeFix/ShapeFix_Face.cxx +++ b/src/ShapeFix/ShapeFix_Face.cxx @@ -517,7 +517,8 @@ Standard_Boolean ShapeFix_Face::Perform() //fix for loop of wire TopTools_SequenceOfShape aLoopWires; if(NeedFix ( myFixLoopWiresMode) && FixLoopWire(aLoopWires)) { - + if (aLoopWires.Length() > 1) + SendWarning ( wire, Message_Msg ( "FixAdvFace.FixLoopWire.MSG0" ) );// Wire was splitted on several wires myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE7 ); fixed = Standard_True; Standard_Integer k=1; @@ -776,7 +777,7 @@ Standard_Boolean ShapeFix_Face::FixAddNaturalBound() } // B.UpdateFace (myFace,myPrecision); - SendWarning (Message_Msg ("FixAdvFace.FixOrientation.MSG0"));//Face created with natural bounds + SendWarning ( myFace, Message_Msg ( "FixAdvFace.FixOrientation.MSG0" ) );// Face created with natural bounds BRepTools::Update(myFace); return Standard_True; } @@ -926,7 +927,7 @@ Standard_Boolean ShapeFix_Face::FixAddNaturalBound() #ifdef DEBUG cout<<"Natural bound on sphere or torus with holes added"<Reverse ( myFace ); ws.SetValue ( 1, sbdw->Wire() ); - SendWarning (Message_Msg ("FixAdvFace.FixOrientation.MSG5"));//Wire on face was reversed + SendWarning ( sbdw->Wire(), Message_Msg ( "FixAdvFace.FixOrientation.MSG5" ) );// Wire on face was reversed done = Standard_True; #ifdef DEBUG cout<<"Wire reversed"<CheckSmallArea(prec) ) nbRemoved++; - else { + if ( saw->CheckSmallArea(prec) ) + { + SendWarning ( wire, Message_Msg ("FixAdvFace.FixSmallAreaWire.MSG0") );// Null area wire detected, wire skipped + nbRemoved++; + } + else + { B.Add(face,wire); nbWires++; } @@ -1698,7 +1701,6 @@ Standard_Boolean ShapeFix_Face::FixSmallAreaWire() #endif if ( ! Context().IsNull() ) Context()->Replace ( myFace, face ); myFace = face; - SendWarning (Message_Msg ("FixAdvFace.FixSmallAreaWire.MSG0"));//Null area wire detected, wire skipped return Standard_True; } //======================================================================= @@ -1907,12 +1909,10 @@ Standard_Boolean ShapeFix_Face::FixLoopWire(TopTools_SequenceOfShape& aResWires) } Standard_Boolean isDone =(aResWires.Length() && isClosed); - if(isDone && aResWires.Length() >1) { - - Message_Msg MSG ("FixAdvFace.FixLoopWire.MSG0"); //Wire was splitted on %d wires - MSG.Arg (aResWires.Length()); + if(isDone && aResWires.Length() >1) + { #ifdef DEBUG - cout<<"Wire was splitted on "<1) { @@ -958,10 +958,10 @@ Standard_Boolean ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell,co myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); if(!Context().IsNull()) Context()->Replace(shell, myShape); - if( myNbShells == 1) - SendWarning (Message_Msg ("FixAdvShell.FixOrientation.MSG0"));//Faces were incorrectly oriented in the shell, corrected + if ( myNbShells == 1 ) + SendWarning ( Message_Msg ( "FixAdvShell.FixOrientation.MSG0" ) );// Faces were incorrectly oriented in the shell, corrected else - SendWarning (Message_Msg ("FixAdvShell.FixOrientation.MSG30"));//Bad connected shell ,a few shells were created. + SendWarning ( Message_Msg ( "FixAdvShell.FixOrientation.MSG30" ) );// Improperly connected shell split into parts return Standard_True; } else return Standard_False; diff --git a/src/ShapeFix/ShapeFix_Wire.cxx b/src/ShapeFix/ShapeFix_Wire.cxx index a3eae03c27..428ef6ffdd 100755 --- a/src/ShapeFix/ShapeFix_Wire.cxx +++ b/src/ShapeFix/ShapeFix_Wire.cxx @@ -442,10 +442,7 @@ Standard_Integer ShapeFix_Wire::FixSmall (const Standard_Boolean lockvtx, FixSmall ( i, lockvtx, precsmall ); myStatusSmall |= myLastFixStatus; } - - if ( StatusSmall ( ShapeExtend_DONE ) && ! myShape.IsNull() ) { - SendWarning (Message_Msg ("FixAdvWire.FixSmall.MSG0"));//Small edge(s) removed - } + return StatusSmall ( ShapeExtend_DONE ); } @@ -673,12 +670,12 @@ Standard_Boolean ShapeFix_Wire::FixEdgeCurves() TopLoc_Location L; Standard_Real first, last; BRep_Tool::CurveOnSurface ( sbwd->Edge(i), C, S, L, first, last ); - if ( C.IsNull() ) { + if ( C.IsNull() ) + { + SendWarning ( sbwd->Edge ( i ), Message_Msg ( "FixWire.FixCurve3d.Removed" ) );// Incomplete edge (with no pcurves or 3d curve) removed sbwd->Remove ( i-- ); nb--; myStatusEdgeCurves |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE5 ); - if ( ! myShape.IsNull() ) - SendWarning (Message_Msg ("FixWire.FixCurve3d.Removed")); // Incomplete edge (with no pcurves or 3d curve) removed } myStatusEdgeCurves |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL5 ); } @@ -776,10 +773,6 @@ Standard_Boolean ShapeFix_Wire::FixDegenerated() } else prevcoded = coded; } - - if ( StatusDegenerated ( ShapeExtend_DONE ) && ! myShape.IsNull() ) { - SendWarning (Message_Msg ("FixWire.FixDegenerated.MSG0")); //Degenerated edge(s) detected - } return StatusDegenerated ( ShapeExtend_DONE ); } @@ -935,9 +928,6 @@ Standard_Boolean ShapeFix_Wire::FixSelfIntersection() */ } - if ( StatusSelfIntersection ( ShapeExtend_DONE ) && ! myShape.IsNull() ) { - SendWarning (Message_Msg ("FixAdvWire.FixIntersection.MSG0")); // Self-intersection corrected - } return StatusSelfIntersection ( ShapeExtend_DONE ); } @@ -1077,7 +1067,9 @@ Standard_Boolean ShapeFix_Wire::FixSmall (const Standard_Integer num, else myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 ); // action: remove edge - if ( ! Context().IsNull() ) Context()->Remove(WireData()->Edge(n)); + if ( ! Context().IsNull() ) + Context()->Remove(WireData()->Edge(n)); + SendWarning ( WireData()->Edge ( n ), Message_Msg ( "FixAdvWire.FixSmall.MSG0" ) ); //Small edge(s) removed WireData()->Remove ( n ); // call FixConnected in the case if vertices of the small edge were not the same @@ -1089,12 +1081,7 @@ Standard_Boolean ShapeFix_Wire::FixSmall (const Standard_Integer num, savLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL3 ); myLastFixStatus = savLastFixStatus; } - - if ( ! myShape.IsNull() ) { - Message_Msg MSG ("FixAdvWire.FixSmall.MSG0"); //Small edge %d removed - MSG.Arg (n); - SendWarning (MSG); - } + return Standard_True; } @@ -1633,10 +1620,10 @@ Standard_Boolean ShapeFix_Wire::FixDegenerated (const Standard_Integer num) sbwd->Set ( degEdge, n2 ); myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 ); } -//: abv 28.08.01 - commented to avoid extra messages -// Message_Msg MSG ("FixWire.FixDegenerated.MSG5"); //Degenerated edge %d detected -// MSG.Arg (n2); -// SendWarning (MSG); + +// commented to avoid extra messages +// SendWarning ( degEdge, Message_Msg ( "FixWire.FixDegenerated.MSG0" ) );// Degenerated edge(s) detected + return Standard_True; } @@ -2214,9 +2201,7 @@ Standard_Boolean ShapeFix_Wire::FixSelfIntersectingEdge (const Standard_Integer } if ( LastFixStatus ( ShapeExtend_DONE ) && ! myShape.IsNull() ) { - Message_Msg MSG ("FixAdvWire.FixIntersection.MSG5"); //Edge %d was self-intersecting, corrected - MSG.Arg (num); - SendWarning (MSG); + SendWarning ( E, Message_Msg ( "FixAdvWire.FixIntersection.MSG5" ) );// Edge was self-intersecting, corrected } return LastFixStatus ( ShapeExtend_DONE ); @@ -2418,10 +2403,7 @@ Standard_Boolean ShapeFix_Wire::FixIntersectingEdges (const Standard_Integer num myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE7 ); } if ( ! myShape.IsNull() ) { - Message_Msg MSG ("FixAdvWire.FixIntersection.MSG10"); //Edges %d and %d were intersecting, corrected - MSG.Arg (n1); - MSG.Arg (n2); - SendWarning (MSG); + SendWarning ( Message_Msg ( "FixAdvWire.FixIntersection.MSG10" ) );// Edges were intersecting, corrected } return Standard_True; } @@ -2600,10 +2582,7 @@ Standard_Boolean ShapeFix_Wire::FixIntersectingEdges (const Standard_Integer num if(newTolers(i)>0) B.UpdateVertex(TopoDS::Vertex(vertices(i)),newTolers(i)); if ( ! myShape.IsNull() ) { - Message_Msg MSG ("FixAdvWire.FixIntersection.MSG10"); //Edges %d and %d were intersecting, corrected - MSG.Arg (n1); - MSG.Arg (n2); - SendWarning (MSG); + SendWarning ( Message_Msg ( "FixAdvWire.FixIntersection.MSG10" ) );// Edges were intersecting, corrected } return Standard_True; }