]> OCCT Git - occt-copy.git/commitdiff
0025134: Extended mode for checkshape command CR25134
authornbv <nbv@opencascade.com>
Thu, 30 Jul 2015 06:20:32 +0000 (09:20 +0300)
committernbv <nbv@opencascade.com>
Thu, 30 Jul 2015 06:20:32 +0000 (09:20 +0300)
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
src/BRep/BRep_Tool.hxx
src/BRepCheck/BRepCheck.cxx
src/BRepCheck/BRepCheck_Analyzer.cxx
src/BRepCheck/BRepCheck_Face.cxx
src/BRepCheck/BRepCheck_Shell.cxx
src/BRepCheck/BRepCheck_Shell.hxx
src/BRepCheck/BRepCheck_Status.hxx
src/BRepCheck/BRepCheck_Vertex.cxx
src/BRepCheck/BRepCheck_Vertex.hxx
src/BRepTest/BRepTest_CheckCommands.cxx

index 101d93f10617e9e09dafe6034e6b13f1d914772d..6f95470bcbc3402fdd6d0b08817ac43244c5589b 100644 (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);
+}
index 03242eb834427094c2f1e8baa80dc895a31cc44e..1e285cbcd144352794bac480e5d950c0df978fbb 100644 (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:
index f5cb45ec196422c759f958b4c5af400039ce0276..380e3b2e2efdc51015728c1ed3937bd302edd3f9 100644 (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;
index da733d933351fa1f2b2fc629e6e0124bb6846dd8..cc6917561012cad6d7b68ff32ea00ac43b51dcce 100644 (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>
 #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: 
-    // 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<<endl;
 #endif
-        if ( ! myMap(S).IsNull() )
-        {
-          myMap(S)->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<<endl;
 #endif
-          if ( ! myMap(S).IsNull() )
-            myMap(S)->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<<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) 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<<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,17 +394,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) 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<<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());
           }
         }
       }
     }
     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<<endl;
+          OCC_CATCH_SIGNALS
+          myMap(aShell)->InContext(S);
+        }
+        catch(Standard_Failure)
+        {
+#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);
-                }
-            }//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) {
index 59daf7e897b8a4a139dd87f2c7256fdce1e0dec6..de9bdcf5d3869aca1a8462e899147a70c7b97c4f 100644 (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  : 
index f0d9bbda7259799ade8f6e4b57df98e374ab6df6..4c5ea6792986207214383ff4aae8edbdca150403 100644 (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();
 }
+
index aea62214897beb32fd6bd3127883f696bbea7cd6..a3026a513bfb62936b29f1bbf7510d7f943b8407 100644 (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)
index 1990d2873d05606d9a75e5d6d285841f3009f4ce..62d0152cfd537b133e10ec8e57c3127b0d85a936 100644 (file)
@@ -56,6 +56,7 @@ BRepCheck_BadOrientationOfSubshape,
 BRepCheck_InvalidPolygonOnTriangulation,
 BRepCheck_InvalidToleranceValue,
 BRepCheck_EnclosedRegion,
+BRepCheck_IncorrectFlagValue,
 BRepCheck_CheckFail
 };
 
index 8225677cdff37bce8020814075865fb79d92d228..1876972bc3bdaf7ceda934a571246c7f90b8d281 100644 (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);
+}
index c436386319a568f6d6938804df2c6d9e5119ed98..d67e5690c97dd9f217bc43627fd6cd9791c2a96a 100644 (file)
@@ -46,6 +46,8 @@ public:
   
   Standard_EXPORT Standard_Real Tolerance();
 
+  //! Sets status of the Vertex
+  Standard_EXPORT void SetStatus(const BRepCheck_Status theStatus);
 
 
 
index dd85a7025517b610b249eace6880b04d5567a1cc..0551db682aefb66194fa2d344abd40fcbed6b3e8 100644 (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";