1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

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.
This commit is contained in:
nbv
2015-07-30 09:20:32 +03:00
parent 380eaf77b9
commit 4f103fe2a8
11 changed files with 222 additions and 106 deletions

View File

@@ -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);
}

View File

@@ -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:

View File

@@ -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;

View File

@@ -24,6 +24,7 @@
#include <BRepCheck_Solid.hxx>
#include <BRepCheck_Vertex.hxx>
#include <BRepCheck_Wire.hxx>
#include <BRep_Tool.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Standard_NoSuchObject.hxx>
@@ -35,6 +36,51 @@
#include <TopoDS_Shape.hxx>
#include <TopTools_MapOfShape.hxx>
//=======================================================================
//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:
{
if(!isFlagsCorrect)
{
Handle(BRepCheck_Vertex)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue);
}
// 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
}
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<<endl;
#endif
if ( ! myMap(S).IsNull() )
{
myMap(S)->SetFailStatus(S);
}
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,8 +221,10 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
{
OCC_CATCH_SIGNALS
if (MapS.Add(aVertex))
{
myMap(aVertex)->InContext(S);
}
}
catch(Standard_Failure)
{
#ifdef OCCT_DEBUG
@@ -170,27 +232,38 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() )
myMap(S)->SetFailStatus(S);
Handle(BRepCheck_Result) aRes = myMap(aVertex);
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,18 +281,18 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() )
{
myMap(S)->SetFailStatus(S);
}
Handle(BRepCheck_Result) aRes = myMap(exp.Current());
if (!aRes.IsNull() )
{
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
}
Handle(BRepCheck_Result) aResV = myMap(exp.Current());
if (!aResV.IsNull() )
{
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<<endl;
#endif
if ( ! myMap(S).IsNull() )
if (!aRes.IsNull() )
{
myMap(S)->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,18 +394,18 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() )
{
myMap(S)->SetFailStatus(S);
}
Handle(BRepCheck_Result) aRes = myMap(exp.Current());
if (!aRes.IsNull() )
{
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
}
Handle(BRepCheck_Result) aResW = myMap(exp.Current());
if (!aResW.IsNull() )
{
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,20 +445,20 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() )
if (!aRes.IsNull() )
{
myMap(S)->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());
}
}
}
@@ -389,10 +466,22 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
break;
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())
{
@@ -404,27 +493,34 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
}
catch(Standard_Failure)
{
#ifdef OCCT_DEBUG
#ifdef DEB
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() )
{
myMap(S)->SetFailStatus(S);
}
//
Handle(BRepCheck_Result) aRes = myMap(aShell);
if (!aRes.IsNull() )
{
aRes->SetFailStatus(exp.Current());
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_COMPOUND:
default:
break;
}//switch (styp) {

View File

@@ -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 :

View File

@@ -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();
}

View File

@@ -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)

View File

@@ -56,6 +56,7 @@ BRepCheck_BadOrientationOfSubshape,
BRepCheck_InvalidPolygonOnTriangulation,
BRepCheck_InvalidToleranceValue,
BRepCheck_EnclosedRegion,
BRepCheck_IncorrectFlagValue,
BRepCheck_CheckFail
};

View File

@@ -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);
}

View File

@@ -46,6 +46,8 @@ public:
Standard_EXPORT Standard_Real Tolerance();
//! Sets status of the Vertex
Standard_EXPORT void SetStatus(const BRepCheck_Status theStatus);

View File

@@ -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........................... "<<NbProblems->Value(aProblemID)<<"\n";
aProblemID = static_cast<Standard_Integer>(BRepCheck_IncorrectFlagValue);
if(NbProblems->Value(aProblemID)>0)
theCommands<<" Flag value does not match with reality.......... "<<NbProblems->Value(aProblemID)<<"\n";
aProblemID = static_cast<Standard_Integer>(BRepCheck_CheckFail);
if(NbProblems->Value(aProblemID)>0)
theCommands<<" checkshape failure........................ "<<NbProblems->Value(aProblemID)<<"\n";
theCommands<<" ------------------------------------------------"<<"\n";
theCommands<<"*** Shapes with problems : "<<sl->Length()<<"\n";