X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_IMeasureOperations.cxx;h=fb2320ea5cef74e4d237a89c1b6be2ba9d7a1005;hb=ed87a1f7c81ec39992aff1f463d73dc81e5791e0;hp=5a191cd6bcc4c13e09edb0441532a901eb37a0d3;hpb=7d880c6a8262b6d670ed70ee2b9ec25c199a46d4;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index 5a191cd6b..fb2320ea5 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -20,96 +20,54 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include - #include - -#include -#include #include -#include +#include +#include #include -#include +#include +#include #include -#include #include -#include - #include -#include -#include // OCCT Includes -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include +#include #include -#include #include #include #include #include #include #include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include +#include +#include #include #include - -#include - -#include -#include - #include #include - #include #include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= @@ -163,7 +121,7 @@ GEOMImpl_IMeasureOperations::ShapeKind GEOMImpl_IMeasureOperations::KindOfShape int geom_type = theShape->GetType(); // check if it's advanced shape - if ( geom_type > ADVANCED_BASE ) { + if ( geom_type > USER_TYPE ) { SetErrorCode(OK); return SK_ADVANCED; } @@ -784,9 +742,7 @@ void GEOMImpl_IMeasureOperations::GetPosition } try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif gp_Ax3 anAx3 = GEOMUtils::GetPosition(aShape); @@ -840,9 +796,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass //Compute the CentreOfMass value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Measure driver failed to compute centre of mass"); return NULL; @@ -894,9 +848,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex //Compute try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Vertex by index driver failed."); return NULL; @@ -953,9 +905,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetNormal //Compute the Normale value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Measure driver failed to compute normake of face"); return NULL; @@ -1005,9 +955,7 @@ void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theSha //Compute the parameters GProp_GProps LProps, SProps; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif BRepGProp::LinearProperties(aShape, LProps); theLength = LProps.Mass(); @@ -1061,9 +1009,7 @@ void GEOMImpl_IMeasureOperations::GetInertia GProp_GProps System; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (aShape.ShapeType() == TopAbs_VERTEX || aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE) { @@ -1129,9 +1075,7 @@ void GEOMImpl_IMeasureOperations::GetBoundingBox Bnd_Box B; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif BRepBuilderAPI_Copy aCopyTool (aShape); if (!aCopyTool.IsDone()) { SetErrorCode("GetBoundingBox Error: Bad shape detected"); @@ -1197,9 +1141,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetBoundingBox //Compute the BoundingBox value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Measure driver failed to compute a bounding box"); return NULL; @@ -1256,9 +1198,7 @@ void GEOMImpl_IMeasureOperations::GetTolerance FaceMax = EdgeMax = VertMax = -RealLast(); try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif for (TopExp_Explorer ExF (aShape, TopAbs_FACE); ExF.More(); ExF.Next()) { TopoDS_Face Face = TopoDS::Face(ExF.Current()); T = BRep_Tool::Tolerance(Face); @@ -1298,11 +1238,12 @@ void GEOMImpl_IMeasureOperations::GetTolerance * CheckShape */ //============================================================================= -bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, - const Standard_Boolean theIsCheckGeom, - TCollection_AsciiString& theDump) +bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, + const Standard_Boolean theIsCheckGeom, + std::list &theErrors) { SetErrorCode(KO); + theErrors.clear(); if (theShape.IsNull()) return false; @@ -1318,15 +1259,12 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, //Compute the parameters bool isValid = false; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif BRepCheck_Analyzer ana (aShape, theIsCheckGeom); if (ana.IsValid()) { - theDump.Clear(); isValid = true; } else { - StructuralDump(ana, aShape, theDump); + FillErrors(ana, aShape, theErrors); } } catch (Standard_Failure) { @@ -1339,6 +1277,223 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, return isValid; } +//============================================================================= +/*! + * PrintShapeErrors + */ +//============================================================================= +TCollection_AsciiString GEOMImpl_IMeasureOperations::PrintShapeErrors + (Handle(GEOM_Object) theShape, + const std::list &theErrors) +{ + TCollection_AsciiString aDump; + + if (theShape.IsNull()) { + return aDump; + } + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + + if (aRefShape.IsNull()) { + return aDump; + } + + TopoDS_Shape aShape = aRefShape->GetValue(); + + if (aShape.IsNull()) { + SetErrorCode("The Objects has NULL Shape"); + return aDump; + } + + if (!theErrors.empty()) { + // The shape is not valid. Prepare errors for dump. + TopTools_IndexedMapOfShape anIndices; + std::list::const_iterator anIter = theErrors.begin(); + Standard_Integer nbv, nbe, nbw, nbf, nbs, nbo; + nbv = nbe = nbw = nbf = nbs = nbo = 0; + + // Map sub-shapes and their indices + TopExp::MapShapes(aShape, anIndices); + + const Standard_Integer aNbSubShapes = anIndices.Extent(); + TColStd_MapOfInteger aMapPbInd; + + aDump += " -- The Shape has problems :\n"; + aDump += " Check Count\n"; + aDump += " ------------------------------------------------\n"; + + for (; anIter != theErrors.end(); anIter++) { + Standard_Integer aNbShapes = anIter->incriminated.size(); + + switch(anIter->error) { + case BRepCheck_InvalidPointOnCurve: + aDump += " Invalid Point on Curve ................... "; + break; + case BRepCheck_InvalidPointOnCurveOnSurface: + aDump += " Invalid Point on CurveOnSurface .......... "; + break; + case BRepCheck_InvalidPointOnSurface: + aDump += " Invalid Point on Surface ................. "; + break; + case BRepCheck_No3DCurve: + aDump += " No 3D Curve .............................. "; + break; + case BRepCheck_Multiple3DCurve: + aDump += " Multiple 3D Curve ........................ "; + break; + case BRepCheck_Invalid3DCurve: + aDump += " Invalid 3D Curve ......................... "; + break; + case BRepCheck_NoCurveOnSurface: + aDump += " No Curve on Surface ...................... "; + break; + case BRepCheck_InvalidCurveOnSurface: + aDump += " Invalid Curve on Surface ................. "; + break; + case BRepCheck_InvalidCurveOnClosedSurface: + aDump += " Invalid Curve on closed Surface .......... "; + break; + case BRepCheck_InvalidSameRangeFlag: + aDump += " Invalid SameRange Flag ................... "; + break; + case BRepCheck_InvalidSameParameterFlag: + aDump += " Invalid SameParameter Flag ............... "; + break; + case BRepCheck_InvalidDegeneratedFlag: + aDump += " Invalid Degenerated Flag ................. "; + break; + case BRepCheck_FreeEdge: + aDump += " Free Edge ................................ "; + break; + case BRepCheck_InvalidMultiConnexity: + aDump += " Invalid MultiConnexity ................... "; + break; + case BRepCheck_InvalidRange: + aDump += " Invalid Range ............................ "; + break; + case BRepCheck_EmptyWire: + aDump += " Empty Wire ............................... "; + break; + case BRepCheck_RedundantEdge: + aDump += " Redundant Edge ........................... "; + break; + case BRepCheck_SelfIntersectingWire: + aDump += " Self Intersecting Wire ................... "; + break; + case BRepCheck_NoSurface: + aDump += " No Surface ............................... "; + break; + case BRepCheck_InvalidWire: + aDump += " Invalid Wire ............................. "; + break; + case BRepCheck_RedundantWire: + aDump += " Redundant Wire ........................... "; + break; + case BRepCheck_IntersectingWires: + aDump += " Intersecting Wires ....................... "; + break; + case BRepCheck_InvalidImbricationOfWires: + aDump += " Invalid Imbrication of Wires ............. "; + break; + case BRepCheck_EmptyShell: + aDump += " Empty Shell .............................. "; + break; + case BRepCheck_RedundantFace: + aDump += " Redundant Face ........................... "; + break; + case BRepCheck_UnorientableShape: + aDump += " Unorientable Shape ....................... "; + break; + case BRepCheck_NotClosed: + aDump += " Not Closed ............................... "; + break; + case BRepCheck_NotConnected: + aDump += " Not Connected ............................ "; + break; + case BRepCheck_SubshapeNotInShape: + aDump += " Sub-shape not in Shape ................... "; + break; + case BRepCheck_BadOrientation: + aDump += " Bad Orientation .......................... "; + break; + case BRepCheck_BadOrientationOfSubshape: + aDump += " Bad Orientation of Sub-shape ............. "; + break; + case BRepCheck_InvalidToleranceValue: + aDump += " Invalid Tolerance Value .................. "; + break; + case BRepCheck_CheckFail: + aDump += " Check Shape Failure ...................... "; + break; + default: + break; + } + + aDump += TCollection_AsciiString(aNbShapes) + "\n"; + + // Count types of shape. + std::list::const_iterator aShIter = anIter->incriminated.begin(); + + for (; aShIter != anIter->incriminated.end(); aShIter++) { + const Standard_Integer anIndex = *aShIter; + + if (anIndex > 0 && anIndex <= aNbSubShapes && aMapPbInd.Add(anIndex)) { + const TopoDS_Shape &aSubShape = anIndices.FindKey(anIndex); + const TopAbs_ShapeEnum aType = aSubShape.ShapeType(); + + switch (aType) { + case TopAbs_VERTEX : nbv++; break; + case TopAbs_EDGE : nbe++; break; + case TopAbs_WIRE : nbw++; break; + case TopAbs_FACE : nbf++; break; + case TopAbs_SHELL : nbs++; break; + case TopAbs_SOLID : nbo++; break; + default : break; + } + } + } + } + + const Standard_Integer aNbFaultyShapes = nbv + nbe + nbw + nbf + nbs + nbo; + aDump += " ------------------------------------------------\n"; + aDump += "*** Shapes with problems : "; + aDump += TCollection_AsciiString(aNbFaultyShapes) + "\n"; + + if (nbv > 0) { + aDump += "VERTEX : "; + if (nbv < 10) aDump += " "; + aDump += TCollection_AsciiString(nbv) + "\n"; + } + if (nbe > 0) { + aDump += "EDGE : "; + if (nbe < 10) aDump += " "; + aDump += TCollection_AsciiString(nbe) + "\n"; + } + if (nbw > 0) { + aDump += "WIRE : "; + if (nbw < 10) aDump += " "; + aDump += TCollection_AsciiString(nbw) + "\n"; + } + if (nbf > 0) { + aDump += "FACE : "; + if (nbf < 10) aDump += " "; + aDump += TCollection_AsciiString(nbf) + "\n"; + } + if (nbs > 0) { + aDump += "SHELL : "; + if (nbs < 10) aDump += " "; + aDump += TCollection_AsciiString(nbs) + "\n"; + } + if (nbo > 0) { + aDump += "SOLID : "; + if (nbo < 10) aDump += " "; + aDump += TCollection_AsciiString(nbo) + "\n"; + } + } + + return aDump; +} + //============================================================================= /*! * CheckSelfIntersections @@ -1346,6 +1501,7 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, //============================================================================= bool GEOMImpl_IMeasureOperations::CheckSelfIntersections (Handle(GEOM_Object) theShape, + const SICheckLevel theCheckLevel, Handle(TColStd_HSequenceOfInteger)& theIntersections) { SetErrorCode(KO); @@ -1366,8 +1522,6 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections if (aShape.IsNull()) return isGood; // 0. Prepare data - BRep_Builder aBB; - TopoDS_Compound aCS; TopoDS_Shape aScopy; // GEOMAlgo_AlgoTools::CopyShape(aShape, aScopy); @@ -1376,21 +1530,16 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections TopTools_IndexedMapOfShape anIndices; TopExp::MapShapes(aScopy, anIndices); - aBB.MakeCompound(aCS); - aBB.Add(aCS, aScopy); - BOPCol_ListOfShape aLCS; aLCS.Append(aScopy); // BOPAlgo_CheckerSI aCSI; // checker of self-interferences aCSI.SetArguments(aLCS); + aCSI.SetLevelOfCheck(theCheckLevel); // 1. Launch the checker aCSI.Perform(); Standard_Integer iErr = aCSI.ErrorStatus(); - if (iErr) { - return false; // Error - } isGood = true; // @@ -1419,7 +1568,10 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections isGood = false; } - SetErrorCode(OK); + if (!iErr) { + SetErrorCode(OK); + } + return isGood; } @@ -1503,12 +1655,12 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object) Astr = Astr + " Number of sub-shapes : \n"; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif - int iType, nbTypes [TopAbs_SHAPE]; - for (iType = 0; iType < TopAbs_SHAPE; ++iType) + int iType, nbTypes [TopAbs_SHAPE], nbFlatType [TopAbs_SHAPE]; + for (iType = 0; iType < TopAbs_SHAPE; ++iType) { nbTypes[iType] = 0; + nbFlatType[iType] = 0; + } nbTypes[aShape.ShapeType()]++; TopTools_MapOfShape aMapOfShape; @@ -1518,12 +1670,16 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object) TopTools_ListIteratorOfListOfShape itL (aListOfShape); for (; itL.More(); itL.Next()) { - TopoDS_Iterator it (itL.Value()); + TopoDS_Shape sp = itL.Value(); + TopoDS_Iterator it (sp); for (; it.More(); it.Next()) { TopoDS_Shape s = it.Value(); if (aMapOfShape.Add(s)) { aListOfShape.Append(s); nbTypes[s.ShapeType()]++; + if ((sp.ShapeType() == TopAbs_COMPOUND) || (sp.ShapeType() == TopAbs_COMPSOLID)) { + nbFlatType[s.ShapeType()]++; + } } } } @@ -1536,7 +1692,23 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object) Astr = Astr + " SOLID : " + TCollection_AsciiString(nbTypes[TopAbs_SOLID]) + "\n"; Astr = Astr + " COMPSOLID : " + TCollection_AsciiString(nbTypes[TopAbs_COMPSOLID]) + "\n"; Astr = Astr + " COMPOUND : " + TCollection_AsciiString(nbTypes[TopAbs_COMPOUND]) + "\n"; - Astr = Astr + " SHAPE : " + TCollection_AsciiString(aMapOfShape.Extent()); + Astr = Astr + " SHAPE : " + TCollection_AsciiString(aMapOfShape.Extent()) + "\n"; + + if ((aShape.ShapeType() == TopAbs_COMPOUND) || (aShape.ShapeType() == TopAbs_COMPSOLID)){ + Astr = Astr + " --------------------- \n Flat content : \n"; + if (nbFlatType[TopAbs_VERTEX] > 0) + Astr = Astr + " VERTEX : " + TCollection_AsciiString(nbFlatType[TopAbs_VERTEX]) + "\n"; + if (nbFlatType[TopAbs_EDGE] > 0) + Astr = Astr + " EDGE : " + TCollection_AsciiString(nbFlatType[TopAbs_EDGE]) + "\n"; + if (nbFlatType[TopAbs_WIRE] > 0) + Astr = Astr + " WIRE : " + TCollection_AsciiString(nbFlatType[TopAbs_WIRE]) + "\n"; + if (nbFlatType[TopAbs_FACE] > 0) + Astr = Astr + " FACE : " + TCollection_AsciiString(nbFlatType[TopAbs_FACE]) + "\n"; + if (nbFlatType[TopAbs_SHELL] > 0) + Astr = Astr + " SHELL : " + TCollection_AsciiString(nbFlatType[TopAbs_SHELL]) + "\n"; + if (nbFlatType[TopAbs_SOLID] > 0) + Astr = Astr + " SOLID : " + TCollection_AsciiString(nbFlatType[TopAbs_SOLID]) + "\n"; + } } catch (Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); @@ -1698,9 +1870,7 @@ GEOMImpl_IMeasureOperations::GetMinDistance (Handle(GEOM_Object) theShape1, //Compute the parameters try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif gp_Pnt aPnt1, aPnt2; @@ -1750,9 +1920,7 @@ Standard_Integer GEOMImpl_IMeasureOperations::ClosestPoints (Handle(GEOM_Object) // Compute the extremities try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif // skl 30.06.2008 // additional workaround for bugs 19899, 19908 and 19910 from Mantis @@ -1826,9 +1994,7 @@ void GEOMImpl_IMeasureOperations::PointCoordinates (Handle(GEOM_Object) theShape } try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); theX = aPnt.X(); theY = aPnt.Y(); @@ -1878,9 +2044,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngle (Handle(GEOM_Object) theLine } try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Edge E1 = TopoDS::Edge(aLine1); TopoDS_Edge E2 = TopoDS::Edge(aLine2); @@ -1956,9 +2120,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngleBtwVectors (Handle(GEOM_Objec } try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Edge aE1 = TopoDS::Edge(aVec1); TopoDS_Edge aE2 = TopoDS::Edge(aVec2); @@ -2018,9 +2180,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByParam //Compute curvature try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif GeomLProp_CLProps Prop = GeomLProp_CLProps (aCurve, aP, 2, Precision::Confusion()); aRes = fabs(Prop.Curvature()); @@ -2072,9 +2232,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByPoint //Compute curvature try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif GeomAPI_ProjectPointOnCurve PPCurve(aPoint, aCurve, aFP, aLP); if(PPCurve.NbPoints()>0) { GeomLProp_CLProps Prop = GeomLProp_CLProps @@ -2115,9 +2273,7 @@ Standard_Real GEOMImpl_IMeasureOperations::getSurfaceCurvatures if (aSurf.IsNull()) return aRes; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif GeomLProp_SLProps Prop = GeomLProp_SLProps (aSurf, theUParam, theVParam, 2, Precision::Confusion()); if(Prop.IsCurvatureDefined()) { @@ -2297,362 +2453,157 @@ Standard_Real GEOMImpl_IMeasureOperations::MinSurfaceCurvatureByPoint return getSurfaceCurvatures(aSurf, UV.X(), UV.Y(), false); } - //======================================================================= -//function : StructuralDump -//purpose : Structural (data exchange) style of output. +//function : FillErrorsSub +//purpose : Fill the errors list of subshapes on shape. //======================================================================= -void GEOMImpl_IMeasureOperations::StructuralDump (const BRepCheck_Analyzer& theAna, - const TopoDS_Shape& theShape, - TCollection_AsciiString& theDump) +void GEOMImpl_IMeasureOperations::FillErrorsSub + (const BRepCheck_Analyzer &theAna, + const TopoDS_Shape &theShape, + const TopAbs_ShapeEnum theSubType, + TopTools_DataMapOfIntegerListOfShape &theMapErrors) const { - Standard_Integer i; - theDump.Clear(); - theDump += " -- The Shape has problems :\n"; - theDump += " Check Count\n"; - theDump += " ------------------------------------------------\n"; - - Standard_Integer last_stat = (Standard_Integer)BRepCheck_CheckFail; - Handle(TColStd_HArray1OfInteger) NbProblems = - new TColStd_HArray1OfInteger(1, last_stat); - for (i = 1; i <= last_stat; i++) - NbProblems->SetValue(i,0); - - Handle(TopTools_HSequenceOfShape) sl; - sl = new TopTools_HSequenceOfShape(); - TopTools_DataMapOfShapeListOfShape theMap; - theMap.Clear(); - GetProblemShapes(theAna, theShape, sl, NbProblems, theMap); - theMap.Clear(); - - Standard_Integer count = 0; - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnCurve); - if (count > 0) { - theDump += " Invalid Point on Curve ................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnCurveOnSurface); - if (count > 0) { - theDump += " Invalid Point on CurveOnSurface .......... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnSurface); - if (count > 0) { - theDump += " Invalid Point on Surface ................. "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_No3DCurve); - if (count > 0) { - theDump += " No 3D Curve .............................. "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_Multiple3DCurve); - if (count > 0) { - theDump += " Multiple 3D Curve ........................ "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_Invalid3DCurve); - if (count > 0) { - theDump += " Invalid 3D Curve ......................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_NoCurveOnSurface); - if (count > 0) { - theDump += " No Curve on Surface ...................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidCurveOnSurface); - if (count > 0) { - theDump += " Invalid Curve on Surface ................. "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidCurveOnClosedSurface); - if (count > 0) { - theDump += " Invalid Curve on closed Surface .......... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidSameRangeFlag); - if (count > 0) { - theDump += " Invalid SameRange Flag ................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidSameParameterFlag); - if (count > 0) { - theDump += " Invalid SameParameter Flag ............... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidDegeneratedFlag); - if (count > 0) { - theDump += " Invalid Degenerated Flag ................. "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_FreeEdge); - if (count > 0) { - theDump += " Free Edge ................................ "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidMultiConnexity); - if (count > 0) { - theDump += " Invalid MultiConnexity ................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidRange); - if (count > 0) { - theDump += " Invalid Range ............................ "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_EmptyWire); - if (count > 0) { - theDump += " Empty Wire ............................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantEdge); - if (count > 0) { - theDump += " Redundant Edge ........................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_SelfIntersectingWire); - if (count > 0) { - theDump += " Self Intersecting Wire ................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_NoSurface); - if (count > 0) { - theDump += " No Surface ............................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidWire); - if (count > 0) { - theDump += " Invalid Wire ............................. "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantWire); - if (count > 0) { - theDump += " Redundant Wire ........................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_IntersectingWires); - if (count > 0) { - theDump += " Intersecting Wires ....................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidImbricationOfWires); - if (count > 0) { - theDump += " Invalid Imbrication of Wires ............. "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_EmptyShell); - if (count > 0) { - theDump += " Empty Shell .............................. "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantFace); - if (count > 0) { - theDump += " Redundant Face ........................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_UnorientableShape); - if (count > 0) { - theDump += " Unorientable Shape ....................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_NotClosed); - if (count > 0) { - theDump += " Not Closed ............................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_NotConnected); - if (count > 0) { - theDump += " Not Connected ............................ "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_SubshapeNotInShape); - if (count > 0) { - theDump += " Sub-shape not in Shape .................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_BadOrientation); - if (count > 0) { - theDump += " Bad Orientation .......................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_BadOrientationOfSubshape); - if (count > 0) { - theDump += " Bad Orientation of Sub-shape .............. "; - theDump += TCollection_AsciiString(count) + "\n"; - } - count = NbProblems->Value((Standard_Integer)BRepCheck_CheckFail); - if (count > 0) { - theDump += " checkshape failure ....................... "; - theDump += TCollection_AsciiString(count) + "\n"; - } - - theDump += " ------------------------------------------------\n"; - theDump += "*** Shapes with problems : "; - theDump += TCollection_AsciiString(sl->Length()) + "\n"; - - Standard_Integer nbv, nbe, nbw, nbf, nbs, nbo; - nbv = nbe = nbw = nbf = nbs = nbo = 0; - - for (i = 1; i <= sl->Length(); i++) { - TopoDS_Shape shi = sl->Value(i); - TopAbs_ShapeEnum sti = shi.ShapeType(); - switch (sti) { - case TopAbs_VERTEX : nbv++; break; - case TopAbs_EDGE : nbe++; break; - case TopAbs_WIRE : nbw++; break; - case TopAbs_FACE : nbf++; break; - case TopAbs_SHELL : nbs++; break; - case TopAbs_SOLID : nbo++; break; - default : break; - } - } + TopExp_Explorer anExp(theShape, theSubType); + TopTools_MapOfShape aMapSubShapes; - if (nbv > 0) { - theDump += "VERTEX : "; - if (nbv < 10) theDump += " "; - theDump += TCollection_AsciiString(nbv) + "\n"; - } - if (nbe > 0) { - theDump += "EDGE : "; - if (nbe < 10) theDump += " "; - theDump += TCollection_AsciiString(nbe) + "\n"; - } - if (nbw > 0) { - theDump += "WIRE : "; - if (nbw < 10) theDump += " "; - theDump += TCollection_AsciiString(nbw) + "\n"; - } - if (nbf > 0) { - theDump += "FACE : "; - if (nbf < 10) theDump += " "; - theDump += TCollection_AsciiString(nbf) + "\n"; - } - if (nbs > 0) { - theDump += "SHELL : "; - if (nbs < 10) theDump += " "; - theDump += TCollection_AsciiString(nbs) + "\n"; - } - if (nbo > 0) { - theDump += "SOLID : "; - if (nbo < 10) theDump += " "; - theDump += TCollection_AsciiString(nbo) + "\n"; - } -} + for (; anExp.More(); anExp.Next()) { + const TopoDS_Shape &aSubShape = anExp.Current(); + if (aMapSubShapes.Add(aSubShape)) { + const Handle(BRepCheck_Result) &aRes = theAna.Result(aSubShape); -//======================================================================= -//function : GetProblemShapes -// purpose : for StructuralDump -//======================================================================= -void GEOMImpl_IMeasureOperations::GetProblemShapes (const BRepCheck_Analyzer& theAna, - const TopoDS_Shape& theShape, - Handle(TopTools_HSequenceOfShape)& sl, - Handle(TColStd_HArray1OfInteger)& NbProblems, - TopTools_DataMapOfShapeListOfShape& theMap) -{ - for (TopoDS_Iterator iter(theShape); iter.More(); iter.Next()) { - GetProblemShapes(theAna, iter.Value(), sl, NbProblems, theMap); - } - TopAbs_ShapeEnum styp = theShape.ShapeType(); - BRepCheck_ListIteratorOfListOfStatus itl; - TopTools_ListOfShape empty; - if (!theMap.IsBound(theShape)) { - theMap.Bind(theShape,empty); - - if (!theAna.Result(theShape).IsNull()) { - itl.Initialize(theAna.Result(theShape)->Status()); - // !!! May be, we have to print all the problems, not only the first one ? - if (itl.Value() != BRepCheck_NoError) { - sl->Append(theShape); - BRepCheck_Status stat = itl.Value(); - NbProblems->SetValue((Standard_Integer)stat, - NbProblems->Value((Standard_Integer)stat) + 1); + for (aRes->InitContextIterator(); + aRes->MoreShapeInContext(); + aRes->NextShapeInContext()) { + if (aRes->ContextualShape().IsSame(theShape)) { + BRepCheck_ListIteratorOfListOfStatus itl(aRes->StatusOnShape()); + + if (itl.Value() != BRepCheck_NoError) { + // Add all errors for theShape and its sub-shape. + for (;itl.More(); itl.Next()) { + const Standard_Integer aStat = (Standard_Integer)itl.Value(); + + if (!theMapErrors.IsBound(aStat)) { + TopTools_ListOfShape anEmpty; + + theMapErrors.Bind(aStat, anEmpty); + } + + TopTools_ListOfShape &theShapes = theMapErrors.ChangeFind(aStat); + + theShapes.Append(aSubShape); + theShapes.Append(theShape); + } + } + } + + break; } } } - - switch (styp) { - case TopAbs_EDGE: - GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_VERTEX, theMap); - break; - case TopAbs_FACE: - GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_WIRE, theMap); - GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_EDGE, theMap); - GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_VERTEX, theMap); - break; - case TopAbs_SHELL: - break; - case TopAbs_SOLID: - GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_SHELL, theMap); - break; - default: - break; - } } //======================================================================= -//function : Contains +//function : FillErrors +//purpose : Fill the errors list. //======================================================================= -static Standard_Boolean Contains (const TopTools_ListOfShape& L, - const TopoDS_Shape& S) +void GEOMImpl_IMeasureOperations::FillErrors + (const BRepCheck_Analyzer &theAna, + const TopoDS_Shape &theShape, + TopTools_DataMapOfIntegerListOfShape &theMapErrors, + TopTools_MapOfShape &theMapShapes) const { - TopTools_ListIteratorOfListOfShape it; - for (it.Initialize(L); it.More(); it.Next()) { - if (it.Value().IsSame(S)) { - return Standard_True; + if (theMapShapes.Add(theShape)) { + // Fill errors of child shapes. + for (TopoDS_Iterator iter(theShape); iter.More(); iter.Next()) { + FillErrors(theAna, iter.Value(), theMapErrors, theMapShapes); + } + + // Fill errors of theShape. + const Handle(BRepCheck_Result) &aRes = theAna.Result(theShape); + + if (!aRes.IsNull()) { + BRepCheck_ListIteratorOfListOfStatus itl(aRes->Status()); + + if (itl.Value() != BRepCheck_NoError) { + // Add all errors for theShape. + for (;itl.More(); itl.Next()) { + const Standard_Integer aStat = (Standard_Integer)itl.Value(); + + if (!theMapErrors.IsBound(aStat)) { + TopTools_ListOfShape anEmpty; + + theMapErrors.Bind(aStat, anEmpty); + } + + theMapErrors.ChangeFind(aStat).Append(theShape); + } + } + } + + // Add errors of subshapes on theShape. + const TopAbs_ShapeEnum aType = theShape.ShapeType(); + + switch (aType) { + case TopAbs_EDGE: + FillErrorsSub(theAna, theShape, TopAbs_VERTEX, theMapErrors); + break; + case TopAbs_FACE: + FillErrorsSub(theAna, theShape, TopAbs_WIRE, theMapErrors); + FillErrorsSub(theAna, theShape, TopAbs_EDGE, theMapErrors); + FillErrorsSub(theAna, theShape, TopAbs_VERTEX, theMapErrors); + break; + case TopAbs_SOLID: + FillErrorsSub(theAna, theShape, TopAbs_SHELL, theMapErrors); + break; + default: + break; } } - return Standard_False; } //======================================================================= -//function : GetProblemSub -// purpose : for StructuralDump +//function : FillErrors +//purpose : Fill the errors list. //======================================================================= -void GEOMImpl_IMeasureOperations::GetProblemSub (const BRepCheck_Analyzer& theAna, - const TopoDS_Shape& theShape, - Handle(TopTools_HSequenceOfShape)& sl, - Handle(TColStd_HArray1OfInteger)& NbProblems, - const TopAbs_ShapeEnum Subtype, - TopTools_DataMapOfShapeListOfShape& theMap) +void GEOMImpl_IMeasureOperations::FillErrors + (const BRepCheck_Analyzer &theAna, + const TopoDS_Shape &theShape, + std::list &theErrors) const { - BRepCheck_ListIteratorOfListOfStatus itl; - TopExp_Explorer exp; - for (exp.Init(theShape, Subtype); exp.More(); exp.Next()) { - const TopoDS_Shape& sub = exp.Current(); - - const Handle(BRepCheck_Result)& res = theAna.Result(sub); - for (res->InitContextIterator(); - res->MoreShapeInContext(); - res->NextShapeInContext()) { - if (res->ContextualShape().IsSame(theShape) && !Contains(theMap(sub), theShape)) { - theMap(sub).Append(theShape); - itl.Initialize(res->StatusOnShape()); - - if (itl.Value() != BRepCheck_NoError) { - Standard_Integer ii = 0; - - for (ii = 1; ii <= sl->Length(); ii++) - if (sl->Value(ii).IsSame(sub)) break; - - if (ii > sl->Length()) { - sl->Append(sub); - BRepCheck_Status stat = itl.Value(); - NbProblems->SetValue((Standard_Integer)stat, - NbProblems->Value((Standard_Integer)stat) + 1); - } - for (ii = 1; ii <= sl->Length(); ii++) - if (sl->Value(ii).IsSame(theShape)) break; - if (ii > sl->Length()) { - sl->Append(theShape); - BRepCheck_Status stat = itl.Value(); - NbProblems->SetValue((Standard_Integer)stat, - NbProblems->Value((Standard_Integer)stat) + 1); - } - } - break; + // Fill the errors map. + TopTools_DataMapOfIntegerListOfShape aMapErrors; + TopTools_MapOfShape aMapShapes; + + FillErrors(theAna, theShape, aMapErrors, aMapShapes); + + // Map sub-shapes and their indices + TopTools_IndexedMapOfShape anIndices; + + TopExp::MapShapes(theShape, anIndices); + + TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape aMapIter(aMapErrors); + + for (; aMapIter.More(); aMapIter.Next()) { + ShapeError anError; + + anError.error = (BRepCheck_Status)aMapIter.Key(); + + TopTools_ListIteratorOfListOfShape aListIter(aMapIter.Value()); + TopTools_MapOfShape aMapUnique; + + for (; aListIter.More(); aListIter.Next()) { + const TopoDS_Shape &aShape = aListIter.Value(); + + if (aMapUnique.Add(aShape)) { + const Standard_Integer anIndex = anIndices.FindIndex(aShape); + + anError.incriminated.push_back(anIndex); } } + + if (!anError.incriminated.empty()) { + theErrors.push_back(anError); + } } }