From 4f103fe2a851eabf061d2a33641e547b6d06c49e Mon Sep 17 00:00:00 2001 From: nbv Date: Thu, 30 Jul 2015 09:20:32 +0300 Subject: [PATCH] 0025134: Extended mode for checkshape command 1. New status BRepCheck_IncorrectFlagValue was created. 2. Now checkshape checks if shape flags, which are set, matches real state of this shape. Now this checking is done for "closed" flag only. --- src/BRep/BRep_Tool.cxx | 13 ++ src/BRep/BRep_Tool.hxx | 4 +- src/BRepCheck/BRepCheck.cxx | 5 + src/BRepCheck/BRepCheck_Analyzer.cxx | 262 ++++++++++++++++-------- src/BRepCheck/BRepCheck_Face.cxx | 11 - src/BRepCheck/BRepCheck_Shell.cxx | 9 +- src/BRepCheck/BRepCheck_Shell.hxx | 3 +- src/BRepCheck/BRepCheck_Status.hxx | 1 + src/BRepCheck/BRepCheck_Vertex.cxx | 9 +- src/BRepCheck/BRepCheck_Vertex.hxx | 2 + src/BRepTest/BRepTest_CheckCommands.cxx | 9 +- 11 files changed, 222 insertions(+), 106 deletions(-) diff --git a/src/BRep/BRep_Tool.cxx b/src/BRep/BRep_Tool.cxx index 101d93f106..6f95470bcb 100644 --- a/src/BRep/BRep_Tool.cxx +++ b/src/BRep/BRep_Tool.cxx @@ -1538,3 +1538,16 @@ Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS) return bRet; } +//======================================================================= +//function : SetClosedFlag +//purpose : +//======================================================================= +void BRep_Tool::SetClosedFlag(TopoDS_Shape& theShape) +{ + if(theShape.IsNull()) + return; + + const Standard_Boolean isClosed = IsClosed(theShape); + + theShape.Closed(isClosed); +} diff --git a/src/BRep/BRep_Tool.hxx b/src/BRep/BRep_Tool.hxx index 03242eb834..1e285cbcd1 100644 --- a/src/BRep/BRep_Tool.hxx +++ b/src/BRep/BRep_Tool.hxx @@ -241,7 +241,9 @@ public: //! Returns the parameters of the vertex on the face. Standard_EXPORT static gp_Pnt2d Parameters (const TopoDS_Vertex& V, const TopoDS_Face& F); - + //! Checks if theShape is really closed. + //! If that is TRUE, method sets "Closed" flag for it. + Standard_EXPORT static void BRep_Tool::SetClosedFlag(TopoDS_Shape& theShape); protected: diff --git a/src/BRepCheck/BRepCheck.cxx b/src/BRepCheck/BRepCheck.cxx index f5cb45ec19..380e3b2e2e 100644 --- a/src/BRepCheck/BRepCheck.cxx +++ b/src/BRepCheck/BRepCheck.cxx @@ -45,6 +45,7 @@ void BRepCheck::Add(BRepCheck_ListOfStatus& lst, const BRepCheck_Status stat) } lst.Append(stat); } + //======================================================================= //function : SelfIntersection //purpose : @@ -58,6 +59,7 @@ Standard_Boolean BRepCheck::SelfIntersection(const TopoDS_Wire& W, BRepCheck_Status stat = chkw->SelfIntersect(myFace,RetE1,RetE2); return (stat == BRepCheck_SelfIntersectingWire); } + //======================================================================= //function : Print //purpose : @@ -169,6 +171,9 @@ void BRepCheck::Print(const BRepCheck_Status stat, case BRepCheck_InvalidPolygonOnTriangulation: OS << "BRepCheck_InvalidPolygonOnTriangulation\n"; break; + case BRepCheck_IncorrectFlagValue: + OS << "BRepCheck_IncorrectFlagValue\n"; + break; case BRepCheck_InvalidToleranceValue: OS << "BRepCheck_InvalidToleranceValue\n"; break; diff --git a/src/BRepCheck/BRepCheck_Analyzer.cxx b/src/BRepCheck/BRepCheck_Analyzer.cxx index da733d9333..cc69175610 100644 --- a/src/BRepCheck/BRepCheck_Analyzer.cxx +++ b/src/BRepCheck/BRepCheck_Analyzer.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,51 @@ #include #include +//======================================================================= +//function : CheckFlags +//purpose : +//======================================================================= +static Standard_Boolean CheckFlags( const TopoDS_Shape& theS) +{ + Standard_Boolean aFlagValue = Standard_True; + Standard_Boolean aCurrentState = Standard_True; + + + //Check "Free" flag + //aFlagValue = theS.Free(); + + //Check "Modified" flag + //aFlagValue = theS.Modified(); + + //Check "Modified" flag + //aFlagValue = theS.Modified(); + + //Check "Checked" flag + //aFlagValue = theS.Checked(); + + //Check "Orientable" flag + //aFlagValue = theS.Orientable(); + + //Check "Closed" flag + aFlagValue = theS.Closed(); + aCurrentState = BRep_Tool::IsClosed(theS); + + if(aFlagValue != aCurrentState) + return Standard_False; + + + //Check "Infinite" flag + //aFlagValue = theS.Infinite(); + + //Check "Convex" flag + //aFlagValue = theS.Convex(); + + //Check "Locked" flag + //aFlagValue = theS.Locked(); + + return (aFlagValue == aCurrentState); +} + //======================================================================= //function : Init //purpose : @@ -50,6 +96,7 @@ void BRepCheck_Analyzer::Init(const TopoDS_Shape& S, Put(S,B); Perform(S); } + //======================================================================= //function : Put //purpose : @@ -93,6 +140,7 @@ void BRepCheck_Analyzer::Put(const TopoDS_Shape& S, } } } + //======================================================================= //function : Perform //purpose : @@ -103,28 +151,45 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) Perform(theIterator.Value()); // - TopAbs_ShapeEnum styp; - TopExp_Explorer exp; - // - styp = S.ShapeType(); - + TopAbs_ShapeEnum styp = S.ShapeType(); + + const Standard_Boolean isFlagsCorrect = CheckFlags(S); + + const Handle(BRepCheck_Result)& aRes = myMap(S); + switch (styp) { - case TopAbs_VERTEX: - // modified by NIZHNY-MKK Wed May 19 16:56:16 2004.BEGIN - // There is no need to check anything. - // if (myShape.IsSame(S)) { - // myMap(S)->Blind(); - // } - // modified by NIZHNY-MKK Wed May 19 16:56:23 2004.END + case TopAbs_VERTEX: + { + if(!isFlagsCorrect) + { + Handle(BRepCheck_Vertex)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue); + } + + // modified by NIZHNY-MKK Wed May 19 16:56:16 2004.BEGIN + // if (myShape.IsSame(S)) { + // myMap(S)->Blind(); + // } + // modified by NIZHNY-MKK Wed May 19 16:56:23 2004.END + } break; case TopAbs_EDGE: { - Handle(BRepCheck_Result)& aRes = myMap(S); + // Modified by skv - Tue Apr 27 11:38:08 2004 Begin + // There is no need to check anything except vertices on single edge. + // if (myShape.IsSame(S)) { + // myMap(S)->Blind(); + // } + // Modified by skv - Tue Apr 27 11:38:09 2004 End try { + if(!isFlagsCorrect) + { + Handle(BRepCheck_Edge)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue); + } + BRepCheck_Status ste = Handle(BRepCheck_Edge):: DownCast(aRes)->CheckPolygonOnTriangulation(TopoDS::Edge(S)); @@ -140,20 +205,15 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) Standard_Failure::Caught()->Print(cout); cout<SetFailStatus(S); - } - if ( ! aRes.IsNull() ) + if (!aRes.IsNull()) { - aRes->SetFailStatus(exp.Current()); aRes->SetFailStatus(S); } } TopTools_MapOfShape MapS; - + TopExp_Explorer exp; for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) { const TopoDS_Shape& aVertex = exp.Current(); @@ -161,7 +221,9 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) { OCC_CATCH_SIGNALS if (MapS.Add(aVertex)) + { myMap(aVertex)->InContext(S); + } } catch(Standard_Failure) { @@ -170,27 +232,38 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) Standard_Failure::Caught()->Print(cout); cout<SetFailStatus(S); - - Handle(BRepCheck_Result) aRes = myMap(aVertex); - - if ( ! aRes.IsNull() ) + if (!aRes.IsNull() ) { - aRes->SetFailStatus(aVertex); aRes->SetFailStatus(S); } - }//catch(Standard_Failure) - }//for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) + + Handle(BRepCheck_Result) aResV = myMap(aVertex); + if ( ! aResV.IsNull() ) + { + aResV->SetFailStatus(aVertex); + aResV->SetFailStatus(S); + } + } + } } break; case TopAbs_WIRE: { + if(!isFlagsCorrect) + { + Handle(BRepCheck_Wire)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue); + } } break; case TopAbs_FACE: { + if(!isFlagsCorrect) + { + Handle(BRepCheck_Face)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue); + } + TopTools_MapOfShape MapS; + TopExp_Explorer exp; for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) { try @@ -208,17 +281,17 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) Standard_Failure::Caught()->Print(cout); cout<SetFailStatus(S); + aRes->SetFailStatus(S); } - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + Handle(BRepCheck_Result) aResV = myMap(exp.Current()); - if ( ! aRes.IsNull() ) + if (!aResV.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); + aResV->SetFailStatus(exp.Current()); + aResV->SetFailStatus(S); } } } @@ -268,17 +341,17 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) Standard_Failure::Caught()->Print(cout); cout<SetFailStatus(S); + aRes->SetFailStatus(S); } - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + Handle(BRepCheck_Result) aResE = myMap(exp.Current()); if ( ! aRes.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); + aResE->SetFailStatus(exp.Current()); + aResE->SetFailStatus(S); } } } @@ -321,17 +394,17 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) Standard_Failure::Caught()->Print(cout); cout<SetFailStatus(S); + aRes->SetFailStatus(S); } - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + Handle(BRepCheck_Result) aResW = myMap(exp.Current()); - if ( ! aRes.IsNull() ) + if (!aResW.IsNull() ) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); + aResW->SetFailStatus(exp.Current()); + aResW->SetFailStatus(S); } } } @@ -353,12 +426,16 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) } else { - Handle(BRepCheck_Face)::DownCast(myMap(S))->SetUnorientable(); + Handle(BRepCheck_Face):: + DownCast(myMap(S))-> + SetStatus(BRepCheck_UnorientableShape); } } else { - Handle(BRepCheck_Face)::DownCast(myMap(S))->SetUnorientable(); + Handle(BRepCheck_Face):: + DownCast(myMap(S))-> + SetStatus(BRepCheck_UnorientableShape); } } catch(Standard_Failure) @@ -368,63 +445,82 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) Standard_Failure::Caught()->Print(cout); cout<SetFailStatus(S); + aRes->SetFailStatus(S); } for (exp.Init(S,TopAbs_WIRE);exp.More(); exp.Next()) { - Handle(BRepCheck_Result) aRes = myMap(exp.Current()); + Handle(BRepCheck_Result) aResW = myMap(exp.Current()); - if ( ! aRes.IsNull() ) + if (!aResW.IsNull()) { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); - myMap(S)->SetFailStatus(exp.Current()); + aResW->SetFailStatus(exp.Current()); + aResW->SetFailStatus(S); + aResW->SetFailStatus(exp.Current()); } } } } break; - case TopAbs_SHELL: + case TopAbs_SHELL: + { + if(!isFlagsCorrect) + { + Handle(BRepCheck_Shell)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue); + } + } break; case TopAbs_SOLID: { + //if(!isFlagsCorrect) + //{ + // Handle(BRepCheck_Solid)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue); + //} + + TopExp_Explorer exp; exp.Init(S,TopAbs_SHELL); for (; exp.More(); exp.Next()) + { + const TopoDS_Shape& aShell=exp.Current(); + try { - const TopoDS_Shape& aShell=exp.Current(); - try - { - OCC_CATCH_SIGNALS - myMap(aShell)->InContext(S); - } - catch(Standard_Failure) - { -#ifdef OCCT_DEBUG - cout<<"BRepCheck_Analyzer : "; - Standard_Failure::Caught()->Print(cout); - cout<InContext(S); + } + catch(Standard_Failure) + { +#ifdef DEB + cout<<"BRepCheck_Analyzer : "; + Standard_Failure::Caught()->Print(cout); + cout<SetFailStatus(S); - } - - // - Handle(BRepCheck_Result) aRes = myMap(aShell); - if (!aRes.IsNull() ) - { - aRes->SetFailStatus(exp.Current()); - aRes->SetFailStatus(S); - } - }//catch(Standard_Failure) - }//for (; exp.More(); exp.Next()) + if (!aRes.IsNull() ) + { + aRes->SetFailStatus(S); + } + + Handle(BRepCheck_Result) aResSh = myMap(aShell); + if (!aResSh.IsNull()) + { + aResSh->SetFailStatus(exp.Current()); + aResSh->SetFailStatus(S); + } + }//catch(Standard_Failure) + }//for (; exp.More(); exp.Next()) + } + break;//case TopAbs_SOLID + case TopAbs_COMPSOLID: + { + } + break;//case TopAbs_COMPSOLID: + case TopAbs_COMPOUND: + { } - break;//case TopAbs_SOLID + break;//case TopAbs_COMPOUND: default: break; }//switch (styp) { diff --git a/src/BRepCheck/BRepCheck_Face.cxx b/src/BRepCheck/BRepCheck_Face.cxx index 59daf7e897..de9bdcf5d3 100644 --- a/src/BRepCheck/BRepCheck_Face.cxx +++ b/src/BRepCheck/BRepCheck_Face.cxx @@ -475,17 +475,6 @@ BRepCheck_Status BRepCheck_Face::OrientationOfWires return myOrires; } - -//======================================================================= -//function : SetUnorientable -//purpose : -//======================================================================= - -void BRepCheck_Face::SetUnorientable() -{ - BRepCheck::Add(myMap(myShape),BRepCheck_UnorientableShape); -} - //======================================================================= //function : SetStatus //purpose : diff --git a/src/BRepCheck/BRepCheck_Shell.cxx b/src/BRepCheck/BRepCheck_Shell.cxx index f0d9bbda72..4c5ea67929 100644 --- a/src/BRepCheck/BRepCheck_Shell.cxx +++ b/src/BRepCheck/BRepCheck_Shell.cxx @@ -823,16 +823,14 @@ BRepCheck_Status BRepCheck_Shell::Orientation(const Standard_Boolean Update) } //======================================================================= -//function : SetUnorientable +//function : SetStatus //purpose : //======================================================================= - -void BRepCheck_Shell::SetUnorientable() +void BRepCheck_Shell::SetStatus(const BRepCheck_Status theStatus) { - BRepCheck::Add(myMap(myShape),BRepCheck_UnorientableShape); + BRepCheck::Add(myMap(myShape),theStatus); } - //======================================================================= //function : IsUnorientable //purpose : @@ -932,3 +930,4 @@ Standard_Integer BRepCheck_Shell::NbConnectedSet(TopTools_ListOfShape& theSets) } return theSets.Extent(); } + diff --git a/src/BRepCheck/BRepCheck_Shell.hxx b/src/BRepCheck/BRepCheck_Shell.hxx index aea6221489..a3026a513b 100644 --- a/src/BRepCheck/BRepCheck_Shell.hxx +++ b/src/BRepCheck/BRepCheck_Shell.hxx @@ -66,7 +66,8 @@ public: Standard_EXPORT Standard_Integer NbConnectedSet (TopTools_ListOfShape& theSets); - + //! Sets status of the Shell + Standard_EXPORT void SetStatus(const BRepCheck_Status theStatus); DEFINE_STANDARD_RTTI(BRepCheck_Shell,BRepCheck_Result) diff --git a/src/BRepCheck/BRepCheck_Status.hxx b/src/BRepCheck/BRepCheck_Status.hxx index 1990d2873d..62d0152cfd 100644 --- a/src/BRepCheck/BRepCheck_Status.hxx +++ b/src/BRepCheck/BRepCheck_Status.hxx @@ -56,6 +56,7 @@ BRepCheck_BadOrientationOfSubshape, BRepCheck_InvalidPolygonOnTriangulation, BRepCheck_InvalidToleranceValue, BRepCheck_EnclosedRegion, +BRepCheck_IncorrectFlagValue, BRepCheck_CheckFail }; diff --git a/src/BRepCheck/BRepCheck_Vertex.cxx b/src/BRepCheck/BRepCheck_Vertex.cxx index 8225677cdf..1876972bc3 100644 --- a/src/BRepCheck/BRepCheck_Vertex.cxx +++ b/src/BRepCheck/BRepCheck_Vertex.cxx @@ -363,4 +363,11 @@ Standard_Real BRepCheck_Vertex::Tolerance() return sqrt(Tol*1.05); } - +//======================================================================= +//function : SetStatus +//purpose : +//======================================================================= +void BRepCheck_Vertex::SetStatus(const BRepCheck_Status theStatus) +{ + BRepCheck::Add(myMap(myShape),theStatus); +} diff --git a/src/BRepCheck/BRepCheck_Vertex.hxx b/src/BRepCheck/BRepCheck_Vertex.hxx index c436386319..d67e5690c9 100644 --- a/src/BRepCheck/BRepCheck_Vertex.hxx +++ b/src/BRepCheck/BRepCheck_Vertex.hxx @@ -46,6 +46,8 @@ public: Standard_EXPORT Standard_Real Tolerance(); + //! Sets status of the Vertex + Standard_EXPORT void SetStatus(const BRepCheck_Status theStatus); diff --git a/src/BRepTest/BRepTest_CheckCommands.cxx b/src/BRepTest/BRepTest_CheckCommands.cxx index dd85a70255..0551db682a 100644 --- a/src/BRepTest/BRepTest_CheckCommands.cxx +++ b/src/BRepTest/BRepTest_CheckCommands.cxx @@ -72,7 +72,7 @@ //Number of BRepCheck_Statuses in BRepCheck_Status.hxx file //(BRepCheck_NoError is not considered, i.e. general status //is smaller by one specified in file) -static const Standard_Integer NumberOfStatus = 36; +static const Standard_Integer NumberOfStatus = 37; static char* checkfaultyname = NULL; Standard_EXPORT void BRepTest_CheckCommands_SetFaultyName(const char* name) @@ -762,12 +762,13 @@ void StructuralDump(Draw_Interpretor& theCommands, if(NbProblems->Value(aProblemID)>0) theCommands<<" Enclosed Region........................... "<Value(aProblemID)<<"\n"; + aProblemID = static_cast(BRepCheck_IncorrectFlagValue); + if(NbProblems->Value(aProblemID)>0) + theCommands<<" Flag value does not match with reality.......... "<Value(aProblemID)<<"\n"; + aProblemID = static_cast(BRepCheck_CheckFail); if(NbProblems->Value(aProblemID)>0) theCommands<<" checkshape failure........................ "<Value(aProblemID)<<"\n"; - - - theCommands<<" ------------------------------------------------"<<"\n"; theCommands<<"*** Shapes with problems : "<Length()<<"\n"; -- 2.39.5