Salome HOME
0022373: EDF 2691 GEOM: Publish the shapes with error in Check Shape
authorskv <skv@opencascade.com>
Fri, 4 Apr 2014 06:44:39 +0000 (10:44 +0400)
committerskv <skv@opencascade.com>
Fri, 4 Apr 2014 06:44:39 +0000 (10:44 +0400)
20 files changed:
doc/salome/examples/check_shape.py
doc/salome/gui/GEOM/images/measures9.png
doc/salome/gui/GEOM/input/check_shape.doc
idl/GEOM_Gen.idl
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx
src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx
src/GEOM_I/GEOM_Gen_i.cc [changed mode: 0644->0755]
src/GEOM_I/GEOM_Gen_i.hh
src/GEOM_I/GEOM_IMeasureOperations_i.cc
src/GEOM_I/GEOM_IMeasureOperations_i.hh
src/GEOM_SWIG/GEOM_TestMeasures.py
src/GEOM_SWIG/geomBuilder.py
src/MeasureGUI/CMakeLists.txt
src/MeasureGUI/MeasureGUI_1Sel1Check1TextView2ListBox_QTD.ui [new file with mode: 0644]
src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx
src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx
src/MeasureGUI/MeasureGUI_CheckShapeDlg.h
src/MeasureGUI/MeasureGUI_Widgets.cxx
src/MeasureGUI/MeasureGUI_Widgets.h

index 30793345e0b8bab8f1aea3be88b700cadde67b5f..a0e72896798f7dcf8fff52a9a0111d5808ce69e0 100644 (file)
@@ -8,8 +8,9 @@ geompy = geomBuilder.New(salome.myStudy)
 
 # create a box
 box = geompy.MakeBoxDXDYDZ(100,30,100)
-IsValid = geompy.CheckShape(box)
+(IsValid, err) = geompy.CheckShape(box, 0, 2)
 if IsValid == 0:
+    geompy.PrintShapeError(box, err)
     raise RuntimeError, "Invalid box created"
 else:
     print "\nBox is valid"
index 38a29bb171abc2e51a1c41814920cb1d69b987da..c5d7d331d33658ff289db3a69b01c143c9208a1b 100755 (executable)
Binary files a/doc/salome/gui/GEOM/images/measures9.png and b/doc/salome/gui/GEOM/images/measures9.png differ
index 9ffbf5b9aa244d012ccec960a3667475066bd8ad..2d5e1dd374d0deee86c90cbe8381a6ec6f896918 100644 (file)
@@ -6,10 +6,35 @@
 True if it is valid. Check also geometry checkbox allows to test the
 geometry as well.
 
-\n <b>Result:</b> Boolean.
-\n <b>TUI Command:</b> <em>geompy.CheckShape(theShape, theIsCheckGeom = 0),</em>
-where \em theShape is the shape checked for validity.
-
+\n <b>Result:</b> Boolean; highlight in the viewer.
+\n <b>TUI Commands:</b>
+<UL>
+<LI>
+<em>geompy.CheckShape(theShape, theIsCheckGeom = 0, theReturnStatus = 0),</em> \n
+where \n
+\em theShape is the shape checked for validity. \n
+\em theIsCheckGeom is the flag that tells if geometry should be checked also.\n
+\em theReturnStatus is the flag that can have the following values:
+<UL>
+<LI>0 - Means that if theShape is invalid, a description of problem is printed.
+IsValid status is returned.</LI>
+<LI>1 - Means that IsValid status and the description of problem are returned.</LI>
+<LI>2 - Means that IsValid status and the list of error data are returned.</LI>
+</UL>
+</LI>
+<LI>
+<em>geompy.PrintShapeErrors(self, theShape, theShapeErrors, theReturnStatus = 0),</em> \n
+where \n
+\em theShape Shape that was checked. \n
+\em theShapeErrors the shape errors obtained by CheckShape. \n
+\em theReturnStatus is the flag that can have the following values:
+<UL>
+<LI>0 - Means that a description of problem is printed.
+IsValid status is returned.</LI>
+<LI>1 - Means that the description of problem is returned.</LI>
+</UL>
+</LI>
+</UL>
 See also a \ref tui_check_shape_page "TUI example".
 
 \image html measures9.png
index 9950494cbc06c0656dc1efa25db7b08afa841770..ecf0308db10df3dfd07a65e1f09b8d6f1782a3b2 100644 (file)
@@ -4002,23 +4002,104 @@ module GEOM
                        out double EdgeMin, out double EdgeMax,
                        out double VertMin, out double VertMax);
 
+    /*!
+     *  \brief Enumeration of Shape defects coming from CheckShape algorithms.
+     */
+    enum ShapeErrorType
+    {
+      /* for vertices */
+      InvalidPointOnCurve,
+      InvalidPointOnCurveOnSurface,
+      InvalidPointOnSurface,
+
+      /* for edges */
+      No3DCurve,
+      Multiple3DCurve,
+      Invalid3DCurve,
+      NoCurveOnSurface,
+      InvalidCurveOnSurface,
+      InvalidCurveOnClosedSurface,
+      InvalidSameRangeFlag,
+      InvalidSameParameterFlag,
+      InvalidDegeneratedFlag,
+
+      FreeEdge,
+      InvalidMultiConnexity,
+      InvalidRange,
+
+      /* for wires */
+      EmptyWire,
+      RedundantEdge,
+      SelfIntersectingWire, /* on a face */
+
+      /* for faces */
+      NoSurface,
+      InvalidWire,
+      RedundantWire,
+      IntersectingWires,
+      InvalidImbricationOfWires,
+
+      /* for shells */
+      EmptyShell,
+      RedundantFace,
+
+      /* for shapes */
+      UnorientableShape,
+      NotClosed,
+      NotConnected,
+
+      SubshapeNotInShape,
+
+      BadOrientation,
+      BadOrientationOfSubshape,
+
+      InvalidToleranceValue,
+
+      /* for exception */
+      CheckFail
+    };
+
+    /*!
+     *  \brief Description of a shape defect: type and incriminated sub-shapes.
+     */
+    struct ShapeError
+    {
+      ShapeErrorType error;
+      ListOfLong     incriminated;
+    };
+
+    /*!
+     *  \brief Sequence of all shape defects.
+     */
+    typedef sequence<ShapeError> ShapeErrors;
+
     /*!
      *  \brief Check a topology of the given shape.
      *  \param theShape Shape to check validity of.
-     *  \param theDescription Output. Description of problems in the shape, if they are.
+     *  \param theErrors Structure, containing discovered errors and incriminated sub-shapes.
      *  \return TRUE, if the shape "seems to be valid" from the topological point of view.
      */
-    boolean CheckShape (in GEOM_Object theShape,
-                        out string     theDescription);
+    boolean CheckShape (in GEOM_Object  theShape,
+                        out ShapeErrors theErrors);
 
     /*!
      *  \brief Check a topology and a geometry of the given shape.
      *  \param theShape Shape to check validity of.
-     *  \param theDescription Output. Description of problems in the shape, if they are.
+     *  \param theErrors Structure, containing discovered errors and incriminated sub-shapes.
      *  \return TRUE, if the shape "seems to be valid".
      */
-    boolean CheckShapeWithGeometry (in GEOM_Object theShape,
-                                    out string     theDescription);
+    boolean CheckShapeWithGeometry (in GEOM_Object  theShape,
+                                    out ShapeErrors theErrors);
+
+    /*!
+     *  \brief Convert sequence of shape errors, returned by
+     *  <VAR>CheckShape()</VAR> or <VAR>CheckShapeWithGeometry()</VAR>, into string.
+     *  \param theShape the invalid shape.
+     *  \param theErrors The sequence of \a theShape errors.
+     *  \return String, describing all the errors in form, suitable for printing.
+     */
+    string PrintShapeErrors (in GEOM_Object theShape,
+                             in ShapeErrors theErrors);
 
     /*!
      *  \brief Check a topology of the given shape on self-intersections presence.
index 35cf49d7f48af55d34cf9b3d97901f9df53d039d..797c629ffbc4018d373cf22778f861e6d24e5e04 100644 (file)
@@ -375,6 +375,26 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES</source>
         <translation>Incriminated Sub-shapes</translation>
     </message>
+    <message>
+        <source>GEOM_CHECK_BLOCKS_NOT_BLOCK</source>
+        <translation>Not a Block</translation>
+    </message>
+    <message>
+        <source>GEOM_CHECK_BLOCKS_EXTRA_EDGE</source>
+        <translation>Extra Edge</translation>
+    </message>
+    <message>
+        <source>GEOM_CHECK_BLOCKS_INVALID_CONNECTION</source>
+        <translation>Invalid Connection # %1</translation>
+    </message>
+    <message>
+        <source>GEOM_CHECK_BLOCKS_NOT_CONNECTED</source>
+        <translation>Not Connected</translation>
+    </message>
+    <message>
+        <source>GEOM_CHECK_BLOCKS_NOT_GLUED</source>
+        <translation>Not Glued # %1</translation>
+    </message>
     <message>
         <source>GEOM_GETNONBLOCKS_TITLE</source>
         <translation>Get non-hexahedral solids and non-quadrangular faces</translation>
@@ -391,14 +411,6 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_CHECK_INFOS</source>
         <translation>Object And Its Topological Information</translation>
     </message>
-    <message>
-        <source>GEOM_CHECK_SHAPE</source>
-        <translation>Check Shape</translation>
-    </message>
-    <message>
-        <source>GEOM_CHECK_TITLE</source>
-        <translation>Check Shape Information</translation>
-    </message>
     <message>
         <source>GEOM_CHECK_SELF_INTERSECTIONS</source>
         <translation>Detect Self-intersections</translation>
@@ -6314,6 +6326,161 @@ Do you want to continue?</translation>
 Please specify suitable arguments.</translation>
     </message>
 </context>
+<context>
+    <name>MeasureGUI_CheckShapeDlg</name>
+    <message>
+        <source>GEOM_CHECK_TITLE</source>
+        <translation>Check Shape Information</translation>
+    </message>
+    <message>
+        <source>GEOM_CHECK_SHAPE</source>
+        <translation>Check Shape</translation>
+    </message>
+    <message>
+        <source>GEOM_CHECK_SHAPE_NAME</source>
+        <translation>Faulty</translation>
+    </message>
+    <message>
+        <source>GEOM_CHECK_SHAPE_VALID</source>
+        <translation>This Shape seems to be valid</translation>
+    </message>
+    <message>
+        <source>GEOM_CHECK_SHAPE_NOT_VALID</source>
+        <translation>This Shape has errors:</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_POINT_ON_CURVE</source>
+        <translation>Invalid Point on Curve</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_POINT_ON_CURVE_ON_SURFACE</source>
+        <translation>Invalid Point on Curve on Surface</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_POINT_ON_SURFACE</source>
+        <translation>Invalid Point on Surface</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_NO_3D_CURVE</source>
+        <translation>No 3D Curve</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_MULTIPLE_3D_CURVE</source>
+        <translation>Multiple 3D Curve</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_3D_CURVE</source>
+        <translation>Invalid 3D Curve</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_NO_CURVE_ON_SURFACE</source>
+        <translation>No Curve on Surface</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_CURVE_ON_SURFACE</source>
+        <translation>Invalid Curve on Surface</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_CURVE_ON_CLOSED_SURFACE</source>
+        <translation>Invalid Curve on Closed Surface</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_SAME_RANGE_FLAG</source>
+        <translation>Invalid Same Range Flag</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_SAME_PARAMETER_FLAG</source>
+        <translation>Invalid Same Parameter Flag</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_DEGENERATED_FLAG</source>
+        <translation>Invalid Degenerated Flag</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_FREE_EDGE</source>
+        <translation>Free Edge</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_MULTI_CONNEXITY</source>
+        <translation>Invalid Multi Connexity</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_RANGE</source>
+        <translation>Invalid Range</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_EMPTY_WIRE</source>
+        <translation>Empty Wire</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_REDUNDANT_EDGE</source>
+        <translation>Redundant Edge</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_SELF_INTERSECTING_WIRE</source>
+        <translation>Self-Intersecting Wire</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_NO_SURFACE</source>
+        <translation>No Surface</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_WIRE</source>
+        <translation>Invalid Wire</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_REDUNDANT_WIRE</source>
+        <translation>Redundant Wire</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INTERSECTING_WIRES</source>
+        <translation>Intersecting Wires</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_IMBRICATION_OF_WIRES</source>
+        <translation>Invalid Imbrication of Wires</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_EMPTY_SHELL</source>
+        <translation>Empty Shell</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_REDUNDANT_FACE</source>
+        <translation>Redundant Face</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_UNORIENTABLE_SHAPE</source>
+        <translation>Unorientable Shape</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_NOT_CLOSED</source>
+        <translation>Not Closed</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_NOT_CONNECTED</source>
+        <translation>Not Connected</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_SUBSHAPE_NOT_IN_SHAPE</source>
+        <translation>Subshape not in Shape</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_BAD_ORIENTATION</source>
+        <translation>Bad Orientation</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_BAD_ORIENTATION_OF_SUBSHAPE</source>
+        <translation>Bad Orientation of Subshape</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_INVALID_TOLERANCE_VALUE</source>
+        <translation>Invalid Tolerance Value</translation>
+    </message>
+    <message>
+        <source>CHECK_ERROR_CHECK_FAIL</source>
+        <translation>Check Fail</translation>
+    </message>
+</context>
 <context>
     <name>OperationGUI_ChamferDlg</name>
     <message>
index 5a191cd6bcc4c13e09edb0441532a901eb37a0d3..bc7111cb27d006521c9a71ee61b97dc727e89b92 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include <Standard_Stream.hxx>
-
 #include <GEOMImpl_IMeasureOperations.hxx>
-
-#include <GEOMImpl_Types.hxx>
-#include <GEOMImpl_MeasureDriver.hxx>
 #include <GEOMImpl_IMeasure.hxx>
-#include <GEOMImpl_IShapesOperations.hxx>
+#include <GEOMImpl_MeasureDriver.hxx>
+#include <GEOMImpl_Types.hxx>
 
 #include <GEOMUtils.hxx>
 
-#include <GEOMAlgo_ShapeInfo.hxx>
+#include <GEOMAlgo_AlgoTools.hxx>
+#include <GEOMAlgo_KindOfName.hxx>
 #include <GEOMAlgo_ShapeInfoFiller.hxx>
 
-#include <GEOM_Function.hxx>
 #include <GEOM_PythonDump.hxx>
 
-#include <Basics_OCCTVersion.hxx>
-
 #include <utilities.h>
-#include <OpUtil.hxx>
-#include <Utils_ExceptHandlers.hxx>
 
 // OCCT Includes
-#include <TFunction_DriverTable.hxx>
-#include <TFunction_Driver.hxx>
-#include <TFunction_Logbook.hxx>
-#include <TDF_Tool.hxx>
-
+#include <Bnd_Box.hxx>
+#include <BOPAlgo_CheckerSI.hxx>
+#include <BOPCol_ListOfShape.hxx>
+#include <BOPDS_DS.hxx>
+#include <BOPDS_MapOfPassKey.hxx>
 #include <BRep_Builder.hxx>
-#include <BRep_TFace.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepBuilderAPI_Copy.hxx>
 #include <BRepBndLib.hxx>
-#include <BRepCheck.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
 #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
-#include <BRepCheck_Result.hxx>
 #include <BRepCheck_Shell.hxx>
 #include <BRepClass3d_SolidClassifier.hxx>
 #include <BRepClass_FaceClassifier.hxx>
 #include <BRepExtrema_DistShapeShape.hxx>
 #include <BRepGProp.hxx>
 #include <BRepTools.hxx>
-
-#include <Bnd_Box.hxx>
-
-#include <TopAbs.hxx>
-#include <TopExp.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-
-#include <ShapeAnalysis.hxx>
-#include <ShapeAnalysis_Surface.hxx>
-
-#include <GeomAPI_IntSS.hxx>
+#include <BRep_Tool.hxx>
+#include <Geom_Line.hxx>
 #include <GeomAPI_ProjectPointOnCurve.hxx>
 #include <GeomAPI_ProjectPointOnSurf.hxx>
-
-#include <GeomAbs_SurfaceType.hxx>
-
-#include <Geom_Line.hxx>
-#include <Geom_Surface.hxx>
-
 #include <GeomLProp_CLProps.hxx>
 #include <GeomLProp_SLProps.hxx>
-
 #include <GProp_GProps.hxx>
 #include <GProp_PrincipalProps.hxx>
-
-#include <gp_Pln.hxx>
-#include <gp_Lin.hxx>
-
-#include <BOPCol_ListOfShape.hxx>
-#include <BOPDS_DS.hxx>
-#include <BOPDS_MapOfPassKey.hxx>
-#include <BOPDS_PassKey.hxx>
-#include <GEOMAlgo_AlgoTools.hxx>
-#include <BOPAlgo_CheckerSI.hxx>
-
-#include <Standard_Failure.hxx>
+#include <ShapeAnalysis.hxx>
+#include <ShapeAnalysis_Surface.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
 
 //=============================================================================
@@ -1298,11 +1258,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<ShapeError>  &theErrors)
 {
   SetErrorCode(KO);
+  theErrors.clear();
 
   if (theShape.IsNull()) return false;
 
@@ -1323,10 +1284,9 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object)      theShape,
 #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 +1299,223 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object)      theShape,
   return isValid;
 }
 
+//=============================================================================
+/*!
+ *  PrintShapeErrors
+ */
+//=============================================================================
+TCollection_AsciiString GEOMImpl_IMeasureOperations::PrintShapeErrors
+                                 (Handle(GEOM_Object)          theShape,
+                                  const std::list<ShapeError> &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<ShapeError>::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<int>::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
@@ -2297,362 +2474,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<ShapeError> &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);
+    }
   }
 }
index 45015b8cb86a4be85de17f3a80356f9ec36d4426..86d0a9c7b2b83125f67acb9e36dda8658b4c5ab4 100644 (file)
 #include "GEOM_IOperations.hxx"
 
 #include <BRepCheck_Analyzer.hxx>
+#include <BRepCheck_Status.hxx>
 #include <TopoDS_Shape.hxx>
-#include <TopTools_HSequenceOfShape.hxx>
-#include <TopTools_DataMapOfShapeListOfShape.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TColStd_HSequenceOfInteger.hxx>
 #include <TColStd_HSequenceOfReal.hxx>
-#include <gp_Ax3.hxx>
+#include <TopTools_DataMapOfIntegerListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
 #include <Geom_Surface.hxx>
 #include <Precision.hxx>
 
@@ -127,9 +127,18 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
                                      Standard_Real& EdgeMin, Standard_Real& EdgeMax,
                                      Standard_Real& VertMin, Standard_Real& VertMax);
 
-  Standard_EXPORT bool CheckShape (Handle(GEOM_Object)      theShape,
-                                   const Standard_Boolean   theIsCheckGeom,
-                                   TCollection_AsciiString& theDump);
+  struct ShapeError {
+    BRepCheck_Status error;
+    std::list<int>   incriminated;
+  };
+
+  Standard_EXPORT bool CheckShape (Handle(GEOM_Object)     theShape,
+                                   const Standard_Boolean  theIsCheckGeom,
+                                   std::list<ShapeError>  &theErrors);
+
+  Standard_EXPORT TCollection_AsciiString PrintShapeErrors
+                                  (Handle(GEOM_Object)          theShape,
+                                   const std::list<ShapeError> &theErrors);
 
   Standard_EXPORT bool CheckSelfIntersections (Handle(GEOM_Object) theShape,
                                                Handle(TColStd_HSequenceOfInteger)& theIntersections);
@@ -177,22 +186,21 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
                                                             Handle(GEOM_Object) thePoint);
 
  private:
-  void StructuralDump (const BRepCheck_Analyzer& theAna,
-                       const TopoDS_Shape&       theShape,
-                       TCollection_AsciiString&  theDump);
-
-  void GetProblemShapes (const BRepCheck_Analyzer&           theAna,
-                         const TopoDS_Shape&                 theShape,
-                         Handle(TopTools_HSequenceOfShape)&  sl,
-                         Handle(TColStd_HArray1OfInteger)&   NbProblems,
-                         TopTools_DataMapOfShapeListOfShape& theMap);
-
-  void 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 FillErrorsSub
+           (const BRepCheck_Analyzer                   &theAna,
+            const TopoDS_Shape                         &theShape,
+            const TopAbs_ShapeEnum                     theSubType,
+                  TopTools_DataMapOfIntegerListOfShape &theMapErrors) const;
+   void FillErrors
+             (const BRepCheck_Analyzer                   &theAna,
+              const TopoDS_Shape                         &theShape,
+                    TopTools_DataMapOfIntegerListOfShape &theMapErrors,
+                    TopTools_MapOfShape                  &theMapShapes) const;
+
+  void FillErrors (const BRepCheck_Analyzer &theAna,
+                   const TopoDS_Shape       &theShape,
+                   std::list<ShapeError>    &theErrors) const;
 
   Standard_Real getSurfaceCurvatures (const Handle(Geom_Surface)& aSurf,
                                       Standard_Real theUParam,
old mode 100644 (file)
new mode 100755 (executable)
index f51456c..4732c1f
@@ -58,6 +58,7 @@
 #include <TColStd_HArray1OfInteger.hxx>
 #include <TopAbs_ShapeEnum.hxx>
 #include <TopExp.hxx>
+#include <TopTools_SequenceOfShape.hxx>
 #include <OSD.hxx>
 
 #include <SALOMEDS_Tool.hxx>
index 4f12a3301f87b45b0ac0dc56d0a50ef3a1e1e783..81771124bb7fcf643e311f1c648d8c69bd3061e4 100644 (file)
@@ -60,6 +60,7 @@
 
 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
 
+class TopTools_SequenceOfShape;
 
 //=====================================================================
 // Generic operations creator (for plugins mechanism)
index 7f0d3cac4198e3ff51fca8ea099634ed87f382d6..b6785bda922a9edf0836974fa0a7b9698892d460 100644 (file)
 #include "GEOM_Engine.hxx"
 #include "GEOM_Object.hxx"
 
+/**
+ * This function converts shape errors from theErrorsFrom to theErrorsTo.
+ * Note that theErrorsTo is not cleared at first.
+ *
+ * \param theErrorsFrom errors to be converted.
+ * \param theErrorsTo result errors.
+ */
+static void ConvertShapeError
+    (const GEOM::GEOM_IMeasureOperations::ShapeErrors         &theErrorsFrom,
+           std::list<GEOMImpl_IMeasureOperations::ShapeError> &theErrorsTo)
+{
+  int aNbErr = theErrorsFrom.length();
+  int i = 0;
+
+  for (; i < aNbErr; i++) {
+    const GEOM::GEOM_IMeasureOperations::ShapeError anErr = theErrorsFrom[i];
+    const GEOM::GEOM_IMeasureOperations::ShapeErrorType aType = anErr.error;
+    const GEOM::ListOfLong anIncrims = anErr.incriminated;
+    GEOMImpl_IMeasureOperations::ShapeError anErrStruct;
+
+    switch (aType) {
+    case GEOM::GEOM_IMeasureOperations::InvalidPointOnCurve:
+      anErrStruct.error = BRepCheck_InvalidPointOnCurve;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidPointOnCurveOnSurface:
+      anErrStruct.error = BRepCheck_InvalidPointOnCurveOnSurface;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidPointOnSurface:
+      anErrStruct.error = BRepCheck_InvalidPointOnSurface;
+      break;
+    case GEOM::GEOM_IMeasureOperations::No3DCurve:
+      anErrStruct.error = BRepCheck_No3DCurve;
+      break;
+    case GEOM::GEOM_IMeasureOperations::Multiple3DCurve:
+      anErrStruct.error = BRepCheck_Multiple3DCurve;
+      break;
+    case GEOM::GEOM_IMeasureOperations::Invalid3DCurve:
+      anErrStruct.error = BRepCheck_Invalid3DCurve;
+      break;
+    case GEOM::GEOM_IMeasureOperations::NoCurveOnSurface:
+      anErrStruct.error = BRepCheck_NoCurveOnSurface;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidCurveOnSurface:
+      anErrStruct.error = BRepCheck_InvalidCurveOnSurface;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidCurveOnClosedSurface:
+      anErrStruct.error = BRepCheck_InvalidCurveOnClosedSurface;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidSameRangeFlag:
+      anErrStruct.error = BRepCheck_InvalidSameRangeFlag;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidSameParameterFlag:
+      anErrStruct.error = BRepCheck_InvalidSameParameterFlag;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidDegeneratedFlag:
+      anErrStruct.error = BRepCheck_InvalidDegeneratedFlag;
+      break;
+    case GEOM::GEOM_IMeasureOperations::FreeEdge:
+      anErrStruct.error = BRepCheck_FreeEdge;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidMultiConnexity:
+      anErrStruct.error = BRepCheck_InvalidMultiConnexity;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidRange:
+      anErrStruct.error = BRepCheck_InvalidRange;
+      break;
+    case GEOM::GEOM_IMeasureOperations::EmptyWire:
+      anErrStruct.error = BRepCheck_EmptyWire;
+      break;
+    case GEOM::GEOM_IMeasureOperations::RedundantEdge:
+      anErrStruct.error = BRepCheck_RedundantEdge;
+      break;
+    case GEOM::GEOM_IMeasureOperations::SelfIntersectingWire:
+      anErrStruct.error = BRepCheck_SelfIntersectingWire;
+      break;
+    case GEOM::GEOM_IMeasureOperations::NoSurface:
+      anErrStruct.error = BRepCheck_NoSurface;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidWire:
+      anErrStruct.error = BRepCheck_InvalidWire;
+      break;
+    case GEOM::GEOM_IMeasureOperations::RedundantWire:
+      anErrStruct.error = BRepCheck_RedundantWire;
+      break;
+    case GEOM::GEOM_IMeasureOperations::IntersectingWires:
+      anErrStruct.error = BRepCheck_IntersectingWires;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidImbricationOfWires:
+      anErrStruct.error = BRepCheck_InvalidImbricationOfWires;
+      break;
+    case GEOM::GEOM_IMeasureOperations::EmptyShell:
+      anErrStruct.error = BRepCheck_EmptyShell;
+      break;
+    case GEOM::GEOM_IMeasureOperations::RedundantFace:
+      anErrStruct.error = BRepCheck_RedundantFace;
+      break;
+    case GEOM::GEOM_IMeasureOperations::UnorientableShape:
+      anErrStruct.error = BRepCheck_UnorientableShape;
+      break;
+    case GEOM::GEOM_IMeasureOperations::NotClosed:
+      anErrStruct.error = BRepCheck_NotClosed;
+      break;
+    case GEOM::GEOM_IMeasureOperations::NotConnected:
+      anErrStruct.error = BRepCheck_NotConnected;
+      break;
+    case GEOM::GEOM_IMeasureOperations::SubshapeNotInShape:
+      anErrStruct.error = BRepCheck_SubshapeNotInShape;
+      break;
+    case GEOM::GEOM_IMeasureOperations::BadOrientation:
+      anErrStruct.error = BRepCheck_BadOrientation;
+      break;
+    case GEOM::GEOM_IMeasureOperations::BadOrientationOfSubshape:
+      anErrStruct.error = BRepCheck_BadOrientationOfSubshape;
+      break;
+    case GEOM::GEOM_IMeasureOperations::InvalidToleranceValue:
+      anErrStruct.error = BRepCheck_InvalidToleranceValue;
+      break;
+    case GEOM::GEOM_IMeasureOperations::CheckFail:
+      anErrStruct.error = BRepCheck_CheckFail;
+      break;
+    default:
+      break;
+    }
+
+    int ii = 0;
+    int aLen = anIncrims.length();
+
+    for (; ii < aLen; ii++) {
+      anErrStruct.incriminated.push_back(anIncrims[ii]);
+    }
+
+    theErrorsTo.push_back(anErrStruct);
+  }
+}
+
+/**
+ * This function converts shape errors from theErrorsFrom to theErrorsTo.
+ * Note that theErrorsTo is not cleared at first.
+ *
+ * \param theErrorsFrom errors to be converted.
+ * \param theErrorsTo result errors.
+ */
+static void ConvertShapeError
+    (const std::list<GEOMImpl_IMeasureOperations::ShapeError> &theErrorsFrom,
+           GEOM::GEOM_IMeasureOperations::ShapeErrors_out     &theErrorsTo)
+{
+  const int aNbErr = theErrorsFrom.size();
+  GEOM::GEOM_IMeasureOperations::ShapeErrors_var anErrArray =
+    new GEOM::GEOM_IMeasureOperations::ShapeErrors;
+
+  anErrArray->length(aNbErr);
+
+  // fill the local CORBA array with values from lists
+  std::list<GEOMImpl_IMeasureOperations::ShapeError>::const_iterator
+    anIt = theErrorsFrom.begin();
+  int i = 0;
+
+  for (; anIt != theErrorsFrom.end(); i++, anIt++) {
+    GEOM::GEOM_IMeasureOperations::ShapeError_var anErrStruct =
+      new GEOM::GEOM_IMeasureOperations::ShapeError;
+
+    switch (anIt->error) {
+    case BRepCheck_InvalidPointOnCurve:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidPointOnCurve;
+      break;
+    case BRepCheck_InvalidPointOnCurveOnSurface:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidPointOnCurveOnSurface;
+      break;
+    case BRepCheck_InvalidPointOnSurface:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidPointOnSurface;
+      break;
+    case BRepCheck_No3DCurve:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::No3DCurve;
+      break;
+    case BRepCheck_Multiple3DCurve:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::Multiple3DCurve;
+      break;
+    case BRepCheck_Invalid3DCurve:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::Invalid3DCurve;
+      break;
+    case BRepCheck_NoCurveOnSurface:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::NoCurveOnSurface;
+      break;
+    case BRepCheck_InvalidCurveOnSurface:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidCurveOnSurface;
+      break;
+    case BRepCheck_InvalidCurveOnClosedSurface:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidCurveOnClosedSurface;
+      break;
+    case BRepCheck_InvalidSameRangeFlag:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidSameRangeFlag;
+      break;
+    case BRepCheck_InvalidSameParameterFlag:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidSameParameterFlag;
+      break;
+    case BRepCheck_InvalidDegeneratedFlag:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidDegeneratedFlag;
+      break;
+    case BRepCheck_FreeEdge:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::FreeEdge;
+      break;
+    case BRepCheck_InvalidMultiConnexity:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidMultiConnexity;
+      break;
+    case BRepCheck_InvalidRange:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidRange;
+      break;
+    case BRepCheck_EmptyWire:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::EmptyWire;
+      break;
+    case BRepCheck_RedundantEdge:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::RedundantEdge;
+      break;
+    case BRepCheck_SelfIntersectingWire:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::SelfIntersectingWire;
+      break;
+    case BRepCheck_NoSurface:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::NoSurface;
+      break;
+    case BRepCheck_InvalidWire:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidWire;
+      break;
+    case BRepCheck_RedundantWire:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::RedundantWire;
+      break;
+    case BRepCheck_IntersectingWires:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::IntersectingWires;
+      break;
+    case BRepCheck_InvalidImbricationOfWires:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidImbricationOfWires;
+      break;
+    case BRepCheck_EmptyShell:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::EmptyShell;
+      break;
+    case BRepCheck_RedundantFace:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::RedundantFace;
+      break;
+    case BRepCheck_UnorientableShape:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::UnorientableShape;
+      break;
+    case BRepCheck_NotClosed:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::NotClosed;
+      break;
+    case BRepCheck_NotConnected:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::NotConnected;
+      break;
+    case BRepCheck_SubshapeNotInShape:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::SubshapeNotInShape;
+      break;
+    case BRepCheck_BadOrientation:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::BadOrientation;
+      break;
+    case BRepCheck_BadOrientationOfSubshape:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::BadOrientationOfSubshape;
+      break;
+    case BRepCheck_InvalidToleranceValue:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidToleranceValue;
+      break;
+    case BRepCheck_CheckFail:
+      anErrStruct->error = GEOM::GEOM_IMeasureOperations::CheckFail;
+      break;
+    default:
+      break;
+    }
+
+    std::list<int> aIndList = anIt->incriminated;
+    GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
+    anIncrims->length(aIndList.size());
+
+    std::list<int>::iterator anIndIt = aIndList.begin();
+    int jj = 0;
+
+    for (; anIndIt != aIndList.end(); jj++, anIndIt++) {
+      anIncrims[jj] = *anIndIt;
+    }
+
+    anErrStruct->incriminated = anIncrims;
+
+    anErrArray[i] = anErrStruct;
+  }
+
+  // initialize out-parameter with local array
+  theErrorsTo = anErrArray._retn();
+}
+
 //=============================================================================
 /*!
  *   constructor:
@@ -332,15 +617,15 @@ void GEOM_IMeasureOperations_i::GetTolerance
  *  CheckShape
  */
 //=============================================================================
-CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape (GEOM::GEOM_Object_ptr theShape,
-                                                      CORBA::String_out     theDescription)
+CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape
+             (GEOM::GEOM_Object_ptr                          theShape,
+              GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors)
 {
   //Set a not done flag
   GetOperations()->SetNotDone();
 
   if (CORBA::is_nil(theShape))
   {
-    theDescription = CORBA::string_dup("null");
     return 0;
   }
 
@@ -349,30 +634,26 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape (GEOM::GEOM_Object_ptr theS
 
   if (aShape.IsNull())
   {
-    theDescription = CORBA::string_dup("null2");
     return 0;
   }
 
-  // Get shape parameters
-  TCollection_AsciiString aDump;
-  if (GetOperations()->CheckShape(aShape, /*check_geom = */false, aDump))
-  {
-    theDescription = CORBA::string_dup("OK");
-    return 1;
-  }
-  theDescription = CORBA::string_dup(aDump.ToCString());
-  return 0;
+  std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
+  bool isOk = GetOperations()->CheckShape(aShape, false, anErrList);
+
+  ConvertShapeError(anErrList, theErrors);
+
+  return isOk;
 }
 
-CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry (GEOM::GEOM_Object_ptr theShape,
-                                                                  CORBA::String_out     theDescription)
+CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry
+             (GEOM::GEOM_Object_ptr                          theShape,
+              GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors)
 {
   //Set a not done flag
   GetOperations()->SetNotDone();
 
   if (CORBA::is_nil(theShape))
   {
-    theDescription = CORBA::string_dup("null");
     return 0;
   }
 
@@ -381,19 +662,42 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry (GEOM::GEOM_Obj
 
   if (aShape.IsNull())
   {
-    theDescription = CORBA::string_dup("null2");
     return 0;
   }
 
-  // Get shape parameters
-  TCollection_AsciiString aDump;
-  if (GetOperations()->CheckShape(aShape, /*check_geom = */true, aDump))
-  {
-    theDescription = CORBA::string_dup("OK");
-    return 1;
+  std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
+  bool isOk = GetOperations()->CheckShape(aShape, true, anErrList);
+
+  ConvertShapeError(anErrList, theErrors);
+
+  return isOk;
+}
+
+//=============================================================================
+/*!
+ *  PrintShapeErrors
+ */
+//=============================================================================
+char* GEOM_IMeasureOperations_i::PrintShapeErrors
+             (      GEOM::GEOM_Object_ptr                       theShape,
+              const GEOM::GEOM_IMeasureOperations::ShapeErrors &theErrors)
+{
+  //Get the reference shape
+  Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
+
+  if (aShape.IsNull()) {
+    return NULL;
   }
-  theDescription = CORBA::string_dup(aDump.ToCString());
-  return 0;
+
+  // Convert the errors sequence
+  std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
+
+  ConvertShapeError(theErrors, anErrList);
+
+  TCollection_AsciiString aDescr =
+    GetOperations()->PrintShapeErrors(aShape, anErrList);
+
+  return CORBA::string_dup(aDescr.ToCString());
 }
 
 //=============================================================================
index caa3de2515c7a177860c15487e9480881bbe87d9..690ac5390fb0b31d2df461519b7dfbe4321c5b2f 100644 (file)
@@ -84,11 +84,17 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
                      CORBA::Double& EdgeMin, CORBA::Double& EdgeMax,
                      CORBA::Double& VertMin, CORBA::Double& VertMax);
 
-  CORBA::Boolean CheckShape (GEOM::GEOM_Object_ptr theShape,
-                             CORBA::String_out     theDescription);
+  CORBA::Boolean CheckShape
+             (GEOM::GEOM_Object_ptr                          theShape,
+              GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors);
 
-  CORBA::Boolean CheckShapeWithGeometry (GEOM::GEOM_Object_ptr theShape,
-                                         CORBA::String_out     theDescription);
+  CORBA::Boolean CheckShapeWithGeometry
+             (GEOM::GEOM_Object_ptr                          theShape,
+              GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors);
+
+  char* PrintShapeErrors
+             (      GEOM::GEOM_Object_ptr                       theShape,
+              const GEOM::GEOM_IMeasureOperations::ShapeErrors &theErrors);
 
   CORBA::Boolean CheckSelfIntersections (GEOM::GEOM_Object_ptr theShape,
                                          GEOM::ListOfLong_out  theIntersections);
index 817a73082603e2dfdb693aee3d83751e91895e4f..2aed6d6a5a2c3c4bb7c1454883956a1998f7c126 100644 (file)
@@ -41,8 +41,9 @@ def TestMeasureOperations (geompy, math):
 
   ####### CheckShape #######
 
-  IsValid = geompy.CheckShape(box)
+  (IsValid, err) = geompy.CheckShape(box, 0, 2)
   if IsValid == 0:
+    geompy.PrintShapeError(box, err)
     raise RuntimeError, "Invalid box created"
   else:
     print "\nBox is valid"
index 057e6b06440d920690b1cd57c9703bb100697d57..74d835d0aaed5d84e18f4b79c9b9317188578f86 100644 (file)
@@ -10142,15 +10142,52 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self._autoPublish(anObj, theName, "normal")
             return anObj
 
+        ## Print shape errors obtained from CheckShape.
+        #  @param theShape Shape that was checked.
+        #  @param theShapeErrors the shape errors obtained by CheckShape.
+        #  @param theReturnStatus If 0 the description of problem is printed.
+        #                         If 1 the description of problem is returned.
+        #  @return If theReturnStatus is equal to 1 the description is returned.
+        #          Otherwise doesn't return anything.
+        #
+        #  @ref tui_measurement_tools_page "Example"
+        def PrintShapeErrors(self, theShape, theShapeErrors, theReturnStatus = 0):
+            """
+            Print shape errors obtained from CheckShape.
+
+            Parameters:
+                theShape Shape that was checked.
+                theShapeErrors the shape errors obtained by CheckShape.
+                theReturnStatus If 0 the description of problem is printed.
+                                If 1 the description of problem is returned.
+
+            Returns:
+                If theReturnStatus is equal to 1 the description is returned.
+                  Otherwise doesn't return anything.
+            """
+            # Example: see GEOM_TestMeasures.py
+            Descr = self.MeasuOp.PrintShapeErrors(theShape, theShapeErrors)
+            if theReturnStatus == 1:
+                return Descr
+            print Descr
+            pass
+
         ## Check a topology of the given shape.
         #  @param theShape Shape to check validity of.
         #  @param theIsCheckGeom If FALSE, only the shape's topology will be checked, \n
         #                        if TRUE, the shape's geometry will be checked also.
-        #  @param theReturnStatus If FALSE and if theShape is invalid, a description \n
-        #                        of problem is printed.
-        #                        if TRUE and if theShape is invalid, the description 
-        #                        of problem is also returned.
+        #  @param theReturnStatus If 0 and if theShape is invalid, a description
+        #                         of problem is printed.
+        #                         If 1 isValid flag and the description of
+        #                         problem is returned.
+        #                         If 2 isValid flag and the list of error data
+        #                         is returned.
         #  @return TRUE, if the shape "seems to be valid".
+        #          If theShape is invalid, prints a description of problem.
+        #          If theReturnStatus is equal to 1 the description is returned
+        #          along with IsValid flag.
+        #          If theReturnStatus is equal to 2 the list of error data is
+        #          returned along with IsValid flag.
         #
         #  @ref tui_measurement_tools_page "Example"
         def CheckShape(self,theShape, theIsCheckGeom = 0, theReturnStatus = 0):
@@ -10161,28 +10198,37 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 theShape Shape to check validity of.
                 theIsCheckGeom If FALSE, only the shape's topology will be checked,
                                if TRUE, the shape's geometry will be checked also.
-                theReturnStatus If FALSE and if theShape is invalid, a description
+                theReturnStatus If 0 and if theShape is invalid, a description
                                 of problem is printed.
-                                if TRUE and if theShape is invalid, the description 
-                                of problem is returned.
+                                If 1 IsValid flag and the description of
+                                problem is returned.
+                                If 2 IsValid flag and the list of error data
+                                is returned.
 
             Returns:   
                 TRUE, if the shape "seems to be valid".
                 If theShape is invalid, prints a description of problem.
-                This description can also be returned.
+                If theReturnStatus is equal to 1 the description is returned
+                along with IsValid flag.
+                If theReturnStatus is equal to 2 the list of error data is
+                returned along with IsValid flag.
             """
             # Example: see GEOM_TestMeasures.py
             if theIsCheckGeom:
-                (IsValid, Status) = self.MeasuOp.CheckShapeWithGeometry(theShape)
+                (IsValid, ShapeErrors) = self.MeasuOp.CheckShapeWithGeometry(theShape)
                 RaiseIfFailed("CheckShapeWithGeometry", self.MeasuOp)
             else:
-                (IsValid, Status) = self.MeasuOp.CheckShape(theShape)
+                (IsValid, ShapeErrors) = self.MeasuOp.CheckShape(theShape)
                 RaiseIfFailed("CheckShape", self.MeasuOp)
             if IsValid == 0:
                 if theReturnStatus == 0:
-                    print Status
+                    Descr = self.MeasuOp.PrintShapeErrors(theShape, ShapeErrors)
+                    print Descr
             if theReturnStatus == 1:
-              return (IsValid, Status)
+              Descr = self.MeasuOp.PrintShapeErrors(theShape, ShapeErrors)
+              return (IsValid, Descr)
+            elif theReturnStatus == 2:
+              return (IsValid, ShapeErrors)
             return IsValid
 
         ## Detect self-intersections in the given shape.
index 20bacd2093eeb0ef8bb1ea2d6b45c37e0d4651f7..8f57e40ad500c0f97f5b50fdf178d37611007604 100755 (executable)
@@ -66,6 +66,7 @@ SET(_uic_files
   MeasureGUI_1Sel12LineEdit_QTD.ui
   MeasureGUI_1Sel1TextView1Check_QTD.ui
   MeasureGUI_1Sel1TextView2ListBox_QTD.ui
+  MeasureGUI_1Sel1Check1TextView2ListBox_QTD.ui
   MeasureGUI_1Sel1TextView_QTD.ui
   MeasureGUI_1Sel3LineEdit_QTD.ui
   MeasureGUI_1Sel6LineEdit_QTD.ui
diff --git a/src/MeasureGUI/MeasureGUI_1Sel1Check1TextView2ListBox_QTD.ui b/src/MeasureGUI/MeasureGUI_1Sel1Check1TextView2ListBox_QTD.ui
new file mode 100644 (file)
index 0000000..aa6a3fa
--- /dev/null
@@ -0,0 +1,138 @@
+<ui version="4.0" >
+ <class>MeasureGUI_1Sel1Check1TextView2ListBox_QTD</class>
+ <widget class="QWidget" name="MeasureGUI_1Sel1Check1TextView2ListBox_QTD" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>235</width>
+    <height>274</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string/>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="leftMargin" >
+    <number>0</number>
+   </property>
+   <property name="topMargin" >
+    <number>0</number>
+   </property>
+   <property name="rightMargin" >
+    <number>0</number>
+   </property>
+   <property name="bottomMargin" >
+    <number>0</number>
+   </property>
+   <property name="horizontalSpacing" >
+    <number>6</number>
+   </property>
+   <property name="verticalSpacing" >
+    <number>6</number>
+   </property>
+   <item row="0" column="0" >
+    <widget class="QGroupBox" name="GroupBox1" >
+     <property name="title" >
+      <string/>
+     </property>
+     <layout class="QGridLayout" >
+      <property name="leftMargin" >
+       <number>9</number>
+      </property>
+      <property name="topMargin" >
+       <number>9</number>
+      </property>
+      <property name="rightMargin" >
+       <number>9</number>
+      </property>
+      <property name="bottomMargin" >
+       <number>9</number>
+      </property>
+      <property name="horizontalSpacing" >
+       <number>6</number>
+      </property>
+      <property name="verticalSpacing" >
+       <number>6</number>
+      </property>
+      <item row="4" column="2" >
+       <widget class="QListWidget" name="ListBox2" />
+      </item>
+      <item row="4" column="0" colspan="2" >
+       <widget class="QListWidget" name="ListBox1" />
+      </item>
+      <item row="0" column="2" >
+       <widget class="QLineEdit" name="LineEdit1" >
+        <property name="minimumSize" >
+         <size>
+          <width>100</width>
+          <height>0</height>
+         </size>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0" colspan="3" >
+       <widget class="QCheckBox" name="CheckBox1" >
+        <property name="text" >
+         <string>Check also geometry</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0" colspan="3" >
+       <widget class="QTextBrowser" name="TextView1" >
+        <property name="minimumSize" >
+         <size>
+          <width>300</width>
+          <height>0</height>
+         </size>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0" >
+       <widget class="QLabel" name="TextLabel2" >
+        <property name="text" >
+         <string>TL2</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="2" >
+       <widget class="QLabel" name="TextLabel3" >
+        <property name="text" >
+         <string>TL3</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0" >
+       <widget class="QLabel" name="TextLabel1" >
+        <property name="text" >
+         <string>TL1</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" >
+       <widget class="QPushButton" name="PushButton1" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string/>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>PushButton1</tabstop>
+  <tabstop>LineEdit1</tabstop>
+  <tabstop>CheckBox1</tabstop>
+  <tabstop>TextView1</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
index a0900cbc43bbfd96158c97cfdd572c254fc54df7..26763b814c6fdafb806d62096f70f049828cc767 100644 (file)
@@ -299,25 +299,19 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
     aErrStr = "";
     switch ( aErrs[i].error ) {
       case GEOM::GEOM_IBlocksOperations::NOT_BLOCK :
-        aErrStr = "Not a Block";
+        aErrStr = tr("GEOM_CHECK_BLOCKS_NOT_BLOCK");
         break;
       case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE :
-        aErrStr = "Extra Edge";
+        aErrStr = tr("GEOM_CHECK_BLOCKS_EXTRA_EDGE");
         break;
       case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION :
-        aErrStr = "Invalid Connection";
-        aErrStr += aConSfx;
-        aErrStr += QString::number( aConNum );
-        aConNum++;
+        aErrStr = tr("GEOM_CHECK_BLOCKS_INVALID_CONNECTION").arg(aConNum++);
         break;
       case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED :
-        aErrStr = "Not Connected";
+        aErrStr = tr("GEOM_CHECK_BLOCKS_NOT_CONNECTED");
         break;
       case GEOM::GEOM_IBlocksOperations::NOT_GLUED :
-        aErrStr = "Not Glued";
-        aErrStr += aGluedSfx;
-        aErrStr += QString::number( aGluedNum );
-        aGluedNum++;
+        aErrStr = tr("GEOM_CHECK_BLOCKS_NOT_GLUED").arg(aGluedNum++);
         break;
       default :
         aErrStr = "";
index 48836f74c2557afbc7c06709cb2078b7149f92a2..42b9e3abd60bfbac4ff325a0314c5878374231d2 100644 (file)
 // File   : MeasureGUI_CheckShapeDlg.cxx
 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
 //
+#include "MeasureGUI.h"
 #include "MeasureGUI_CheckShapeDlg.h"
 #include "MeasureGUI_Widgets.h"
+#include <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+#include <GEOMImpl_Types.hxx>
 
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
 #include <SalomeApp_Tools.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
 
 #define TEXTEDIT_FONT_FAMILY "Courier"
 #define TEXTEDIT_FONT_SIZE 11
@@ -42,7 +54,7 @@
 //            true to construct a modal dialog.
 //=================================================================================
 MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* parent )
-  : MeasureGUI_Skeleton( GUI, parent )
+  : GEOMBase_Skeleton( GUI, parent, false )
 {
   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
     "GEOM", tr( "ICON_DLG_CHECKSHAPE" ) ) );
@@ -55,8 +67,12 @@ MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* p
 
   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
   mainFrame()->RadioButton1->setIcon( image0 );
+  mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
+  mainFrame()->RadioButton2->close();
+  mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+  mainFrame()->RadioButton3->close();
 
-  myGrp = new MeasureGUI_1Sel1TextView1Check( centralWidget() );
+  myGrp = new MeasureGUI_1Sel1Check1TextView2ListBox( centralWidget() );
   myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
   myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
   myGrp->TextView1->setReadOnly( true );
@@ -67,10 +83,18 @@ MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* p
   myGrp->PushButton1->setIcon( image1 );
   myGrp->LineEdit1->setReadOnly( true );
 
+  myGrp->TextLabel2->setText( tr( "GEOM_CHECK_BLOCKS_COMPOUND_ERRORS" ) );
+  myGrp->TextLabel3->setText( tr( "GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES" ) );
+
+  myGrp->ListBox2->setSelectionMode( QAbstractItemView::ExtendedSelection );
+
   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
   layout->setMargin( 0 ); layout->setSpacing( 6 );
   layout->addWidget( myGrp );
 
+  connect( myGrp->ListBox1, SIGNAL( itemSelectionChanged() ), SLOT( onErrorsListSelectionChanged() ) );
+  connect( myGrp->ListBox2, SIGNAL( itemSelectionChanged() ), SLOT( onSubShapesListSelectionChanged() ) );
+
   /***************************************************************/
 
   myHelpFileName = "using_measurement_tools_page.html#check_anchor";
@@ -94,32 +118,167 @@ MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
 //=================================================================================
 void MeasureGUI_CheckShapeDlg::Init()
 {
-  mySelBtn = myGrp->PushButton1;
-  mySelEdit = myGrp->LineEdit1;
-  MeasureGUI_Skeleton::Init();
+  // signals and slots connections
+  connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+  connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+
+  connect( myGrp->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
+
+  connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+           this, SLOT( SelectionIntoArgument() ) );
 
   connect( myGrp->CheckBox1, SIGNAL( toggled( bool) ), 
            this, SLOT( SelectionIntoArgument() ) );
+
+  initName( tr( "GEOM_CHECK_SHAPE_NAME") );
+  buttonOk()->setEnabled( false );
+  buttonApply()->setEnabled( false );
+  activateSelection();
+  SelectionIntoArgument();
 }
 
 //=================================================================================
-// function : getParameters
+// function : ClickOnOk()
 // purpose  :
 //=================================================================================
-bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg )
+void MeasureGUI_CheckShapeDlg::ClickOnOk()
 {
-  if ( myObj->_is_nil() )
+  if ( ClickOnApply() )
+    ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose  :
+//=================================================================================
+bool MeasureGUI_CheckShapeDlg::ClickOnApply()
+{
+  if ( !onAccept() )
     return false;
-  else {
+
+  initName();
+  return true;
+}
+
+//=================================================================================
+// function : SelectionIntoArgument
+// purpose  :
+//=================================================================================
+bool MeasureGUI_CheckShapeDlg::extractPrefix() const
+{
+  return true;
+}
+
+//=================================================================================
+// function : SelectionIntoArgument
+// purpose  :
+//=================================================================================
+void MeasureGUI_CheckShapeDlg::SelectionIntoArgument()
+{
+  erasePreview();
+  myObj = GEOM::GEOM_Object::_nil();
+
+  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+  SALOME_ListIO aSelList;
+  aSelMgr->selectedObjects(aSelList);
+
+  if (aSelList.Extent() != 1) {
+    myGrp->LineEdit1->setText( "" );
+    processObject();
+    return;
+  }
+
+  GEOM::GEOM_Object_var aSelectedObject =
+    GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
+
+  if ( aSelectedObject->_is_nil() ) {
+    myGrp->LineEdit1->setText( "" );
+    processObject();
+    return;
+  }
+
+  myObj = aSelectedObject;
+  myGrp->LineEdit1->setText( GEOMBase::GetName( myObj ) );
+  processObject();
+  DISPLAY_PREVIEW_MACRO;
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument
+// purpose  :
+//=================================================================================
+void MeasureGUI_CheckShapeDlg::SetEditCurrentArgument()
+{
+  myGrp->LineEdit1->setFocus();
+  SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose  :
+//=================================================================================
+void MeasureGUI_CheckShapeDlg::ActivateThisDialog()
+{
+  GEOMBase_Skeleton::ActivateThisDialog();
+
+  LightApp_SelectionMgr* aSel = myGeomGUI->getApp()->selectionMgr();
+  if ( aSel )
+    connect( aSel, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+
+  activateSelection();
+  DISPLAY_PREVIEW_MACRO
+}
+
+//=================================================================================
+// function : activateSelection
+// purpose  : activate selection of faces, shells, and solids
+//=================================================================================
+void MeasureGUI_CheckShapeDlg::activateSelection()
+{
+  globalSelection( GEOM_ALLSHAPES );
+}
+
+//=================================================================================
+// function : enterEvent()
+// purpose  :
+//=================================================================================
+void MeasureGUI_CheckShapeDlg::enterEvent( QEvent* )
+{
+  if ( !mainFrame()->GroupConstructors->isEnabled() )
+    ActivateThisDialog();
+}
+
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+bool MeasureGUI_CheckShapeDlg::isValid( QString& )
+{
+  return !myObj->_is_nil();
+}
+
+//=================================================================================
+// function : getErrors
+// purpose  :
+//=================================================================================
+bool MeasureGUI_CheckShapeDlg::getErrors
+                    ( bool& theIsValid,
+                      GEOM::GEOM_IMeasureOperations::ShapeErrors& theErrors )
+{
+  if ( myObj->_is_nil() ) {
+    return false;
+  } else {
     GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
     try {
-      char* aMsg;
+      GEOM::GEOM_IMeasureOperations::ShapeErrors_var aErrs;
       bool isCheckGeometry = myGrp->CheckBox1->isChecked();
       if ( isCheckGeometry )
-        theIsValid = anOper->CheckShapeWithGeometry( myObj, aMsg );
+        theIsValid = anOper->CheckShapeWithGeometry( myObj, aErrs );
       else
-        theIsValid = anOper->CheckShape( myObj, aMsg );
-      theMsg = aMsg;
+        theIsValid = anOper->CheckShape( myObj, aErrs );
+
+      if (anOper->IsDone() && aErrs->length() > 0)
+        theErrors = aErrs;
     }
     catch( const SALOME::SALOME_Exception& e ) {
       SalomeApp_Tools::QtCatchCorbaException( e );
@@ -138,19 +297,343 @@ bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg
 void MeasureGUI_CheckShapeDlg::processObject()
 {
   bool isShapeValid;
-  QString aMsg;
-  if ( !getParameters( isShapeValid, aMsg ) ) {
+  GEOM::GEOM_IMeasureOperations::ShapeErrors aErrs;
+
+  if ( !getErrors( isShapeValid, aErrs ) ) {
     myGrp->TextView1->setText( "" );
+    myGrp->ListBox1->clear();
+    myGrp->ListBox2->clear();
+    erasePreview();
+
     return;
   }
 
   if ( isShapeValid ) {
-    myGrp->TextView1->setText( "This Shape seems to be valid." );
-  } 
-  else {
-    QString aDescr ( "This Shape is not valid.\n" );
-    aDescr += aMsg;
-    myGrp->TextView1->setText( aDescr );
-//    myGrp->TextView1->setText("This Shape is not valid.");
+    myGrp->TextView1->setText(tr("GEOM_CHECK_SHAPE_VALID"));
+    buttonOk()->setEnabled( false );
+    buttonApply()->setEnabled( false );
+  } else {
+    myGrp->TextView1->setText(tr("GEOM_CHECK_SHAPE_NOT_VALID"));
+    buttonOk()->setEnabled( true );
+    buttonApply()->setEnabled( true );
+  }
+
+  // Add Error groups
+  QStringList aErrList;
+
+  for ( int i = 0, n = aErrs.length(); i < n; i++ ) {
+    QString aErrStr("CHECK_ERROR_");
+
+    switch ( aErrs[i].error ) {
+      case GEOM::GEOM_IMeasureOperations::InvalidPointOnCurve:
+        aErrStr += "INVALID_POINT_ON_CURVE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidPointOnCurveOnSurface:
+        aErrStr += "INVALID_POINT_ON_CURVE_ON_SURFACE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidPointOnSurface:
+        aErrStr += "INVALID_POINT_ON_SURFACE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::No3DCurve:
+        aErrStr += "NO_3D_CURVE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::Multiple3DCurve:
+        aErrStr += "MULTIPLE_3D_CURVE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::Invalid3DCurve:
+        aErrStr += "INVALID_3D_CURVE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::NoCurveOnSurface:
+        aErrStr += "NO_CURVE_ON_SURFACE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidCurveOnSurface:
+        aErrStr += "INVALID_CURVE_ON_SURFACE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidCurveOnClosedSurface:
+        aErrStr += "INVALID_CURVE_ON_CLOSED_SURFACE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidSameRangeFlag:
+        aErrStr += "INVALID_SAME_RANGE_FLAG";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidSameParameterFlag:
+        aErrStr += "INVALID_SAME_PARAMETER_FLAG";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidDegeneratedFlag:
+        aErrStr += "INVALID_DEGENERATED_FLAG";
+        break;
+      case GEOM::GEOM_IMeasureOperations::FreeEdge:
+        aErrStr += "FREE_EDGE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidMultiConnexity:
+        aErrStr += "INVALID_MULTI_CONNEXITY";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidRange:
+        aErrStr += "INVALID_RANGE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::EmptyWire:
+        aErrStr += "EMPTY_WIRE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::RedundantEdge:
+        aErrStr += "REDUNDANT_EDGE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::SelfIntersectingWire:
+        aErrStr += "SELF_INTERSECTING_WIRE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::NoSurface:
+        aErrStr += "NO_SURFACE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidWire:
+        aErrStr += "INVALID_WIRE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::RedundantWire:
+        aErrStr += "REDUNDANT_WIRE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::IntersectingWires:
+        aErrStr += "INTERSECTING_WIRES";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidImbricationOfWires:
+        aErrStr += "INVALID_IMBRICATION_OF_WIRES";
+        break;
+      case GEOM::GEOM_IMeasureOperations::EmptyShell:
+        aErrStr += "EMPTY_SHELL";
+        break;
+      case GEOM::GEOM_IMeasureOperations::RedundantFace:
+        aErrStr += "REDUNDANT_FACE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::UnorientableShape:
+        aErrStr += "UNORIENTABLE_SHAPE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::NotClosed:
+        aErrStr += "NOT_CLOSED";
+        break;
+      case GEOM::GEOM_IMeasureOperations::NotConnected:
+        aErrStr += "NOT_CONNECTED";
+        break;
+      case GEOM::GEOM_IMeasureOperations::SubshapeNotInShape:
+        aErrStr += "SUBSHAPE_NOT_IN_SHAPE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::BadOrientation:
+        aErrStr += "BAD_ORIENTATION";
+        break;
+      case GEOM::GEOM_IMeasureOperations::BadOrientationOfSubshape:
+        aErrStr += "BAD_ORIENTATION_OF_SUBSHAPE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::InvalidToleranceValue:
+        aErrStr += "INVALID_TOLERANCE_VALUE";
+        break;
+      case GEOM::GEOM_IMeasureOperations::CheckFail:
+        aErrStr += "CHECK_FAIL";
+        break;
+      default:
+        aErrStr.clear();
+        break;
+    }
+
+    if (!aErrStr.isEmpty()) {
+      aErrList.append(tr(aErrStr.toLatin1().constData()));
+    }
   }
+
+  myGrp->ListBox1->clear();
+  myGrp->ListBox2->clear();
+  myGrp->ListBox1->addItems( aErrList );
+}
+
+//=================================================================================
+// function : createOperation
+// purpose  :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr MeasureGUI_CheckShapeDlg::createOperation()
+{
+  return getGeomEngine()->GetIMeasureOperations( getStudyId() );
+}
+
+//=================================================================================
+// function : onErrorsListSelectionChanged
+// purpose  :
+//=================================================================================
+void MeasureGUI_CheckShapeDlg::onErrorsListSelectionChanged()
+{
+  erasePreview();
+
+  int aCurItem = myGrp->ListBox1->currentRow();
+
+  if ( aCurItem < 0 ) {
+    return;
+  }
+
+  bool isShapeValid;
+  GEOM::GEOM_IMeasureOperations::ShapeErrors aErrs;
+
+  if ( !getErrors( isShapeValid, aErrs ) ) {
+    myGrp->TextView1->setText( "" );
+    myGrp->ListBox1->clear();
+    myGrp->ListBox2->clear();
+
+    return;
+  }
+
+  myGrp->ListBox2->clear();
+
+  if (aCurItem < aErrs.length()) {
+    GEOM::GEOM_IMeasureOperations::ShapeError aErr = aErrs[aCurItem];
+    GEOM::ListOfLong aObjLst = aErr.incriminated;
+    QStringList aSubShapeList;
+    TopoDS_Shape aSelShape;
+
+    if ( !myObj->_is_nil() && GEOMBase::GetShape( myObj, aSelShape ) ) {
+      TopTools_IndexedMapOfShape anIndices;
+
+      TopExp::MapShapes( aSelShape, anIndices );
+
+      for ( int i = 0, n = aObjLst.length(); i < n; i++ ) {
+        TopoDS_Shape aSubShape = anIndices.FindKey( aObjLst[i] );
+        QString aType = GEOMBase::GetShapeTypeString( aSubShape );
+
+        if ( !aType.isEmpty() ) {
+          aSubShapeList.append( QString( "%1_%2" ).arg( aType ).arg( aObjLst[i] ) );
+        }
+      }
+    }
+
+    myGrp->ListBox2->addItems( aSubShapeList );
+  }
+}
+
+//=================================================================================
+// function : onSubShapesListSelectionChanged
+// purpose  :
+//=================================================================================
+void MeasureGUI_CheckShapeDlg::onSubShapesListSelectionChanged()
+{
+  erasePreview();
+
+  int aErrCurItem = myGrp->ListBox1->currentRow();
+
+  if (aErrCurItem < 0) {
+    return;
+  }
+
+  QList<int> aIds;
+
+  for (int i = 0, n = myGrp->ListBox2->count(); i < n; i++) {
+    if (myGrp->ListBox2->item( i )->isSelected()) {
+      aIds.append(i);
+    }
+  }
+
+  if (aIds.count() < 1) {
+    return;
+  }
+
+  bool isShapeValid;
+  GEOM::GEOM_IMeasureOperations::ShapeErrors aErrs;
+
+  if (!getErrors(isShapeValid, aErrs)) {
+    myGrp->TextView1->setText("");
+    myGrp->ListBox1->clear();
+    myGrp->ListBox2->clear();
+
+    return;
+  }
+
+  GEOM::GEOM_IMeasureOperations::ShapeError aErr = aErrs[aErrCurItem];
+  GEOM::ListOfLong aObjLst = aErr.incriminated;
+  TopoDS_Shape aSelShape;
+  TopoDS_Shape aSubShape;
+  TopTools_IndexedMapOfShape anIndices;
+
+  if (!myObj->_is_nil() && GEOMBase::GetShape(myObj, aSelShape)) {
+    QString aMess;
+
+    if (!isValid(aMess)) {
+      return;
+    }
+
+    SALOME_Prs* aPrs = 0;
+    QList<int>::iterator it;
+
+    TopExp::MapShapes(aSelShape, anIndices);
+
+    for (it = aIds.begin(); it != aIds.end(); ++it) {
+      SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+      int w = resMgr->integerValue("Geometry", "measures_line_width", 1);
+
+      aSubShape = anIndices.FindKey(aObjLst[(*it)]);
+
+      try {
+        getDisplayer()->SetColor( Quantity_NOC_RED );
+        getDisplayer()->SetWidth( w );
+        getDisplayer()->SetToActivate( false );
+        aPrs = !aSubShape.IsNull() ? getDisplayer()->BuildPrs(aSubShape) : 0;
+
+        if (aPrs) {
+          displayPreview(aPrs, true);
+        }
+      }
+      catch (const SALOME::SALOME_Exception& e) {
+        SalomeApp_Tools::QtCatchCorbaException(e);
+      }
+    }
+  }
+}
+
+//=================================================================================
+// function : execute
+// purpose  :
+//=================================================================================
+bool MeasureGUI_CheckShapeDlg::execute( ObjectList& objects )
+{
+  bool isShapeValid;
+  GEOM::GEOM_IMeasureOperations::ShapeErrors aErrs;
+
+  if (!getErrors(isShapeValid, aErrs)) {
+    return false;
+  }
+
+  const int  aNbErrsSelected    = myGrp->ListBox1->selectedItems().size();
+  const bool isPublishAllErrors = (aNbErrsSelected < 1);
+  const bool isPublishAllShapes =
+    (aNbErrsSelected != 1 || myGrp->ListBox2->selectedItems().empty());
+  TColStd_IndexedMapOfInteger aMapIndex;
+  const int aNbErrs = aErrs.length();
+  int i;
+
+  // Collect indices of shapes to be published.
+  for (i = 0; i < aNbErrs; i++) {
+    if (isPublishAllErrors || myGrp->ListBox1->item(i)->isSelected()) {
+      GEOM::ListOfLong aObjLst = aErrs[i].incriminated;
+      const int aNbShapes = aObjLst.length();
+      int j;
+
+      for (j = 0; j < aNbShapes; j++) {
+        if (isPublishAllShapes || myGrp->ListBox2->item(j)->isSelected()) {
+          aMapIndex.Add(aObjLst[j]);
+        }
+      }
+    }
+  }
+
+  // Create objects.
+  GEOM::ListOfLong_var anArray   = new GEOM::ListOfLong;
+  const int            aNbShapes = aMapIndex.Extent();
+
+  anArray->length(aNbShapes);
+
+  for (i = 1; i <= aNbShapes; i++) {
+    anArray[i - 1] = aMapIndex.FindKey(i);
+  }
+
+  if (myShapesOper->_is_nil()) {
+    myShapesOper = getGeomEngine()->GetIShapesOperations(getStudyId());
+  }
+
+  GEOM::ListOfGO_var aList = myShapesOper->MakeSubShapes(myObj, anArray);
+  const int aNbObj = aList->length();
+
+  for (i = 0; i < aNbObj; i++) {
+    objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
+  }
+
+  return true;
 }
index ade60714d7c2bf693451fe07c4fc624a898da1dd..a2ace0ae2a97417422642b7b3e65a5b45e2e9aad 100644 (file)
 #ifndef MEASUREGUI_CHECKSHAPEDLG_H
 #define MEASUREGUI_CHECKSHAPEDLG_H
 
-#include "MeasureGUI_Skeleton.h"
+#include <GEOMBase_Skeleton.h>
 
-class MeasureGUI_1Sel1TextView1Check;
+class MeasureGUI_1Sel1Check1TextView2ListBox;
 
 //=================================================================================
 // class    : MeasureGUI_CheckShapeDlg
 // purpose  :
 //=================================================================================
-class MeasureGUI_CheckShapeDlg : public MeasureGUI_Skeleton
+class MeasureGUI_CheckShapeDlg : public GEOMBase_Skeleton
 {
   Q_OBJECT
 
@@ -45,14 +45,32 @@ public:
 
 protected:
   // redefined from GEOMBase_Helper and MeasureGUI_Skeleton
-  virtual void                    processObject();
+  virtual GEOM::GEOM_IOperations_ptr  createOperation();
+  virtual bool                        execute( ObjectList& );
+  virtual void                        processObject();
+  virtual void                        activateSelection();
+  virtual bool                        isValid( QString& );
+  virtual bool extractPrefix() const;
+
+private slots:
+  void                                SelectionIntoArgument();
+  void                                ClickOnOk();
+  bool                                ClickOnApply();
+  void                                ActivateThisDialog();
+  void                                SetEditCurrentArgument();
+  void                                onErrorsListSelectionChanged();
+  void                                onSubShapesListSelectionChanged();
 
 private:
-  void                            Init();
-  bool                            getParameters( bool&, QString& );
+  void                                Init();
+  void                                enterEvent( QEvent* );
+  bool                                getErrors
+        ( bool&, GEOM::GEOM_IMeasureOperations::ShapeErrors&);
 
 private:
-  MeasureGUI_1Sel1TextView1Check* myGrp;
+  GEOM::GEOM_Object_var                   myObj;
+  MeasureGUI_1Sel1Check1TextView2ListBox* myGrp;
+  GEOM::GEOM_IShapesOperations_var        myShapesOper;
 };
 
 #endif // MEASUREGUI_CHECKSHAPEDLG_H
index 2cbbeec46a2e629efe8be34a3da235adc5a897ee..77cdd68f38d523d5a8fe047e424e830ff53d2b8c 100644 (file)
@@ -65,6 +65,21 @@ MeasureGUI_1Sel1TextView2ListBox::~MeasureGUI_1Sel1TextView2ListBox()
 {
 }
 
+//////////////////////////////////////////
+// MeasureGUI_1Sel1Check1TextView2ListBox
+//////////////////////////////////////////
+
+MeasureGUI_1Sel1Check1TextView2ListBox::MeasureGUI_1Sel1Check1TextView2ListBox( QWidget* parent, 
+                                                                                Qt::WindowFlags f )
+: QWidget( parent, f )
+{
+  setupUi( this );
+}
+
+MeasureGUI_1Sel1Check1TextView2ListBox::~MeasureGUI_1Sel1Check1TextView2ListBox()
+{
+}
+
 //////////////////////////////////////////
 // MeasureGUI_1Sel1TextView
 //////////////////////////////////////////
index 02fe6ea9260e85e9eb6d260f7f219de3c98cfe00..1f1f388247a51e9108ba461730a77690d7fff363 100644 (file)
@@ -71,6 +71,22 @@ public:
   ~MeasureGUI_1Sel1TextView2ListBox();
 };
 
+//////////////////////////////////////////
+// MeasureGUI_1Sel1Check1TextView2ListBox
+//////////////////////////////////////////
+
+#include "ui_MeasureGUI_1Sel1Check1TextView2ListBox_QTD.h"
+
+class MeasureGUI_1Sel1Check1TextView2ListBox : public QWidget,
+                                               public Ui::MeasureGUI_1Sel1Check1TextView2ListBox_QTD
+{
+  Q_OBJECT
+
+public:
+  MeasureGUI_1Sel1Check1TextView2ListBox( QWidget* = 0, Qt::WindowFlags = 0 );
+  ~MeasureGUI_1Sel1Check1TextView2ListBox();
+};
+
 //////////////////////////////////////////
 // MeasureGUI_1Sel1TextView
 //////////////////////////////////////////