1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

Compare commits

...

1 Commits

Author SHA1 Message Date
nbv
4f103fe2a8 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.
2015-07-30 09:20:32 +03:00
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; 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. //! Returns the parameters of the vertex on the face.
Standard_EXPORT static gp_Pnt2d Parameters (const TopoDS_Vertex& V, const TopoDS_Face& F); 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: protected:

View File

@@ -45,6 +45,7 @@ void BRepCheck::Add(BRepCheck_ListOfStatus& lst, const BRepCheck_Status stat)
} }
lst.Append(stat); lst.Append(stat);
} }
//======================================================================= //=======================================================================
//function : SelfIntersection //function : SelfIntersection
//purpose : //purpose :
@@ -58,6 +59,7 @@ Standard_Boolean BRepCheck::SelfIntersection(const TopoDS_Wire& W,
BRepCheck_Status stat = chkw->SelfIntersect(myFace,RetE1,RetE2); BRepCheck_Status stat = chkw->SelfIntersect(myFace,RetE1,RetE2);
return (stat == BRepCheck_SelfIntersectingWire); return (stat == BRepCheck_SelfIntersectingWire);
} }
//======================================================================= //=======================================================================
//function : Print //function : Print
//purpose : //purpose :
@@ -169,6 +171,9 @@ void BRepCheck::Print(const BRepCheck_Status stat,
case BRepCheck_InvalidPolygonOnTriangulation: case BRepCheck_InvalidPolygonOnTriangulation:
OS << "BRepCheck_InvalidPolygonOnTriangulation\n"; OS << "BRepCheck_InvalidPolygonOnTriangulation\n";
break; break;
case BRepCheck_IncorrectFlagValue:
OS << "BRepCheck_IncorrectFlagValue\n";
break;
case BRepCheck_InvalidToleranceValue: case BRepCheck_InvalidToleranceValue:
OS << "BRepCheck_InvalidToleranceValue\n"; OS << "BRepCheck_InvalidToleranceValue\n";
break; break;

View File

@@ -24,6 +24,7 @@
#include <BRepCheck_Solid.hxx> #include <BRepCheck_Solid.hxx>
#include <BRepCheck_Vertex.hxx> #include <BRepCheck_Vertex.hxx>
#include <BRepCheck_Wire.hxx> #include <BRepCheck_Wire.hxx>
#include <BRep_Tool.hxx>
#include <Standard_ErrorHandler.hxx> #include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#include <Standard_NoSuchObject.hxx> #include <Standard_NoSuchObject.hxx>
@@ -35,6 +36,51 @@
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopTools_MapOfShape.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 //function : Init
//purpose : //purpose :
@@ -50,6 +96,7 @@ void BRepCheck_Analyzer::Init(const TopoDS_Shape& S,
Put(S,B); Put(S,B);
Perform(S); Perform(S);
} }
//======================================================================= //=======================================================================
//function : Put //function : Put
//purpose : //purpose :
@@ -93,6 +140,7 @@ void BRepCheck_Analyzer::Put(const TopoDS_Shape& S,
} }
} }
} }
//======================================================================= //=======================================================================
//function : Perform //function : Perform
//purpose : //purpose :
@@ -103,28 +151,45 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Perform(theIterator.Value()); Perform(theIterator.Value());
// //
TopAbs_ShapeEnum styp; TopAbs_ShapeEnum styp = S.ShapeType();
TopExp_Explorer exp;
// const Standard_Boolean isFlagsCorrect = CheckFlags(S);
styp = S.ShapeType();
const Handle(BRepCheck_Result)& aRes = myMap(S);
switch (styp) switch (styp)
{ {
case TopAbs_VERTEX: case TopAbs_VERTEX:
// modified by NIZHNY-MKK Wed May 19 16:56:16 2004.BEGIN {
// There is no need to check anything. if(!isFlagsCorrect)
// if (myShape.IsSame(S)) { {
// myMap(S)->Blind(); Handle(BRepCheck_Vertex)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue);
// } }
// modified by NIZHNY-MKK Wed May 19 16:56:23 2004.END
// 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; break;
case TopAbs_EDGE: 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 try
{ {
if(!isFlagsCorrect)
{
Handle(BRepCheck_Edge)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue);
}
BRepCheck_Status ste = Handle(BRepCheck_Edge):: BRepCheck_Status ste = Handle(BRepCheck_Edge)::
DownCast(aRes)->CheckPolygonOnTriangulation(TopoDS::Edge(S)); DownCast(aRes)->CheckPolygonOnTriangulation(TopoDS::Edge(S));
@@ -140,20 +205,15 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout); Standard_Failure::Caught()->Print(cout);
cout<<endl; cout<<endl;
#endif #endif
if ( ! myMap(S).IsNull() )
{
myMap(S)->SetFailStatus(S);
}
if ( ! aRes.IsNull() ) if (!aRes.IsNull())
{ {
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S); aRes->SetFailStatus(S);
} }
} }
TopTools_MapOfShape MapS; TopTools_MapOfShape MapS;
TopExp_Explorer exp;
for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next())
{ {
const TopoDS_Shape& aVertex = exp.Current(); const TopoDS_Shape& aVertex = exp.Current();
@@ -161,7 +221,9 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
{ {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
if (MapS.Add(aVertex)) if (MapS.Add(aVertex))
{
myMap(aVertex)->InContext(S); myMap(aVertex)->InContext(S);
}
} }
catch(Standard_Failure) catch(Standard_Failure)
{ {
@@ -170,27 +232,38 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout); Standard_Failure::Caught()->Print(cout);
cout<<endl; cout<<endl;
#endif #endif
if ( ! myMap(S).IsNull() ) if (!aRes.IsNull() )
myMap(S)->SetFailStatus(S);
Handle(BRepCheck_Result) aRes = myMap(aVertex);
if ( ! aRes.IsNull() )
{ {
aRes->SetFailStatus(aVertex);
aRes->SetFailStatus(S); 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; break;
case TopAbs_WIRE: case TopAbs_WIRE:
{ {
if(!isFlagsCorrect)
{
Handle(BRepCheck_Wire)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue);
}
} }
break; break;
case TopAbs_FACE: case TopAbs_FACE:
{ {
if(!isFlagsCorrect)
{
Handle(BRepCheck_Face)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue);
}
TopTools_MapOfShape MapS; TopTools_MapOfShape MapS;
TopExp_Explorer exp;
for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next())
{ {
try try
@@ -208,17 +281,17 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout); Standard_Failure::Caught()->Print(cout);
cout<<endl; cout<<endl;
#endif #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) aResV = myMap(exp.Current());
if ( ! aRes.IsNull() ) if (!aResV.IsNull() )
{ {
aRes->SetFailStatus(exp.Current()); aResV->SetFailStatus(exp.Current());
aRes->SetFailStatus(S); aResV->SetFailStatus(S);
} }
} }
} }
@@ -268,17 +341,17 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout); Standard_Failure::Caught()->Print(cout);
cout<<endl; cout<<endl;
#endif #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() ) if ( ! aRes.IsNull() )
{ {
aRes->SetFailStatus(exp.Current()); aResE->SetFailStatus(exp.Current());
aRes->SetFailStatus(S); aResE->SetFailStatus(S);
} }
} }
} }
@@ -321,17 +394,17 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout); Standard_Failure::Caught()->Print(cout);
cout<<endl; cout<<endl;
#endif #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) aResW = myMap(exp.Current());
if ( ! aRes.IsNull() ) if (!aResW.IsNull() )
{ {
aRes->SetFailStatus(exp.Current()); aResW->SetFailStatus(exp.Current());
aRes->SetFailStatus(S); aResW->SetFailStatus(S);
} }
} }
} }
@@ -353,12 +426,16 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
} }
else else
{ {
Handle(BRepCheck_Face)::DownCast(myMap(S))->SetUnorientable(); Handle(BRepCheck_Face)::
DownCast(myMap(S))->
SetStatus(BRepCheck_UnorientableShape);
} }
} }
else else
{ {
Handle(BRepCheck_Face)::DownCast(myMap(S))->SetUnorientable(); Handle(BRepCheck_Face)::
DownCast(myMap(S))->
SetStatus(BRepCheck_UnorientableShape);
} }
} }
catch(Standard_Failure) catch(Standard_Failure)
@@ -368,63 +445,82 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
Standard_Failure::Caught()->Print(cout); Standard_Failure::Caught()->Print(cout);
cout<<endl; cout<<endl;
#endif #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()) 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()); aResW->SetFailStatus(exp.Current());
aRes->SetFailStatus(S); aResW->SetFailStatus(S);
myMap(S)->SetFailStatus(exp.Current()); aResW->SetFailStatus(exp.Current());
} }
} }
} }
} }
break; break;
case TopAbs_SHELL: case TopAbs_SHELL:
{
if(!isFlagsCorrect)
{
Handle(BRepCheck_Shell)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue);
}
}
break; break;
case TopAbs_SOLID: case TopAbs_SOLID:
{ {
//if(!isFlagsCorrect)
//{
// Handle(BRepCheck_Solid)::DownCast(aRes)->SetStatus(BRepCheck_IncorrectFlagValue);
//}
TopExp_Explorer exp;
exp.Init(S,TopAbs_SHELL); exp.Init(S,TopAbs_SHELL);
for (; exp.More(); exp.Next()) for (; exp.More(); exp.Next())
{
const TopoDS_Shape& aShell=exp.Current();
try
{ {
const TopoDS_Shape& aShell=exp.Current(); OCC_CATCH_SIGNALS
try myMap(aShell)->InContext(S);
{ }
OCC_CATCH_SIGNALS catch(Standard_Failure)
myMap(aShell)->InContext(S); {
} #ifdef DEB
catch(Standard_Failure) cout<<"BRepCheck_Analyzer : ";
{ Standard_Failure::Caught()->Print(cout);
#ifdef OCCT_DEBUG cout<<endl;
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif #endif
if ( ! myMap(S).IsNull() ) if (!aRes.IsNull() )
{ {
myMap(S)->SetFailStatus(S); aRes->SetFailStatus(S);
} }
// Handle(BRepCheck_Result) aResSh = myMap(aShell);
Handle(BRepCheck_Result) aRes = myMap(aShell); if (!aResSh.IsNull())
if (!aRes.IsNull() ) {
{ aResSh->SetFailStatus(exp.Current());
aRes->SetFailStatus(exp.Current()); aResSh->SetFailStatus(S);
aRes->SetFailStatus(S); }
} }//catch(Standard_Failure)
}//catch(Standard_Failure) }//for (; exp.More(); exp.Next())
}//for (; exp.More(); exp.Next())
} }
break;//case TopAbs_SOLID break;//case TopAbs_SOLID
case TopAbs_COMPSOLID:
{
}
break;//case TopAbs_COMPSOLID:
case TopAbs_COMPOUND:
{
}
break;//case TopAbs_COMPOUND:
default: default:
break; break;
}//switch (styp) { }//switch (styp) {

View File

@@ -475,17 +475,6 @@ BRepCheck_Status BRepCheck_Face::OrientationOfWires
return myOrires; return myOrires;
} }
//=======================================================================
//function : SetUnorientable
//purpose :
//=======================================================================
void BRepCheck_Face::SetUnorientable()
{
BRepCheck::Add(myMap(myShape),BRepCheck_UnorientableShape);
}
//======================================================================= //=======================================================================
//function : SetStatus //function : SetStatus
//purpose : //purpose :

View File

@@ -823,16 +823,14 @@ BRepCheck_Status BRepCheck_Shell::Orientation(const Standard_Boolean Update)
} }
//======================================================================= //=======================================================================
//function : SetUnorientable //function : SetStatus
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepCheck_Shell::SetStatus(const BRepCheck_Status theStatus)
void BRepCheck_Shell::SetUnorientable()
{ {
BRepCheck::Add(myMap(myShape),BRepCheck_UnorientableShape); BRepCheck::Add(myMap(myShape),theStatus);
} }
//======================================================================= //=======================================================================
//function : IsUnorientable //function : IsUnorientable
//purpose : //purpose :
@@ -932,3 +930,4 @@ Standard_Integer BRepCheck_Shell::NbConnectedSet(TopTools_ListOfShape& theSets)
} }
return theSets.Extent(); return theSets.Extent();
} }

View File

@@ -66,7 +66,8 @@ public:
Standard_EXPORT Standard_Integer NbConnectedSet (TopTools_ListOfShape& theSets); 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) DEFINE_STANDARD_RTTI(BRepCheck_Shell,BRepCheck_Result)

View File

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

View File

@@ -363,4 +363,11 @@ Standard_Real BRepCheck_Vertex::Tolerance()
return sqrt(Tol*1.05); 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(); 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 //Number of BRepCheck_Statuses in BRepCheck_Status.hxx file
//(BRepCheck_NoError is not considered, i.e. general status //(BRepCheck_NoError is not considered, i.e. general status
//is smaller by one specified in file) //is smaller by one specified in file)
static const Standard_Integer NumberOfStatus = 36; static const Standard_Integer NumberOfStatus = 37;
static char* checkfaultyname = NULL; static char* checkfaultyname = NULL;
Standard_EXPORT void BRepTest_CheckCommands_SetFaultyName(const char* name) Standard_EXPORT void BRepTest_CheckCommands_SetFaultyName(const char* name)
@@ -762,12 +762,13 @@ void StructuralDump(Draw_Interpretor& theCommands,
if(NbProblems->Value(aProblemID)>0) if(NbProblems->Value(aProblemID)>0)
theCommands<<" Enclosed Region........................... "<<NbProblems->Value(aProblemID)<<"\n"; 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); aProblemID = static_cast<Standard_Integer>(BRepCheck_CheckFail);
if(NbProblems->Value(aProblemID)>0) if(NbProblems->Value(aProblemID)>0)
theCommands<<" checkshape failure........................ "<<NbProblems->Value(aProblemID)<<"\n"; theCommands<<" checkshape failure........................ "<<NbProblems->Value(aProblemID)<<"\n";
theCommands<<" ------------------------------------------------"<<"\n"; theCommands<<" ------------------------------------------------"<<"\n";
theCommands<<"*** Shapes with problems : "<<sl->Length()<<"\n"; theCommands<<"*** Shapes with problems : "<<sl->Length()<<"\n";