0022373: EDF 2691 GEOM: Publish the shapes with error in Check Shape

This commit is contained in:
skv 2014-04-04 10:44:39 +04:00
parent 4e4b3762fc
commit 6833ee2b3e
20 changed files with 1808 additions and 530 deletions

View File

@ -8,8 +8,9 @@ geompy = geomBuilder.New(salome.myStudy)
# create a box # create a box
box = geompy.MakeBoxDXDYDZ(100,30,100) box = geompy.MakeBoxDXDYDZ(100,30,100)
IsValid = geompy.CheckShape(box) (IsValid, err) = geompy.CheckShape(box, 0, 2)
if IsValid == 0: if IsValid == 0:
geompy.PrintShapeError(box, err)
raise RuntimeError, "Invalid box created" raise RuntimeError, "Invalid box created"
else: else:
print "\nBox is valid" print "\nBox is valid"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -6,10 +6,35 @@
True if it is valid. Check also geometry checkbox allows to test the True if it is valid. Check also geometry checkbox allows to test the
geometry as well. geometry as well.
\n <b>Result:</b> Boolean. \n <b>Result:</b> Boolean; highlight in the viewer.
\n <b>TUI Command:</b> <em>geompy.CheckShape(theShape, theIsCheckGeom = 0),</em> \n <b>TUI Commands:</b>
where \em theShape is the shape checked for validity. <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". See also a \ref tui_check_shape_page "TUI example".
\image html measures9.png \image html measures9.png

View File

@ -4002,23 +4002,104 @@ module GEOM
out double EdgeMin, out double EdgeMax, out double EdgeMin, out double EdgeMax,
out double VertMin, out double VertMax); 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. * \brief Check a topology of the given shape.
* \param theShape Shape to check validity of. * \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. * \return TRUE, if the shape "seems to be valid" from the topological point of view.
*/ */
boolean CheckShape (in GEOM_Object theShape, boolean CheckShape (in GEOM_Object theShape,
out string theDescription); out ShapeErrors theErrors);
/*! /*!
* \brief Check a topology and a geometry of the given shape. * \brief Check a topology and a geometry of the given shape.
* \param theShape Shape to check validity of. * \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". * \return TRUE, if the shape "seems to be valid".
*/ */
boolean CheckShapeWithGeometry (in GEOM_Object theShape, boolean CheckShapeWithGeometry (in GEOM_Object theShape,
out string theDescription); 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. * \brief Check a topology of the given shape on self-intersections presence.

View File

@ -375,6 +375,26 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES</source> <source>GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES</source>
<translation>Incriminated Sub-shapes</translation> <translation>Incriminated Sub-shapes</translation>
</message> </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> <message>
<source>GEOM_GETNONBLOCKS_TITLE</source> <source>GEOM_GETNONBLOCKS_TITLE</source>
<translation>Get non-hexahedral solids and non-quadrangular faces</translation> <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> <source>GEOM_CHECK_INFOS</source>
<translation>Object And Its Topological Information</translation> <translation>Object And Its Topological Information</translation>
</message> </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> <message>
<source>GEOM_CHECK_SELF_INTERSECTIONS</source> <source>GEOM_CHECK_SELF_INTERSECTIONS</source>
<translation>Detect Self-intersections</translation> <translation>Detect Self-intersections</translation>
@ -6314,6 +6326,161 @@ Do you want to continue?</translation>
Please specify suitable arguments.</translation> Please specify suitable arguments.</translation>
</message> </message>
</context> </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> <context>
<name>OperationGUI_ChamferDlg</name> <name>OperationGUI_ChamferDlg</name>
<message> <message>

View File

@ -20,96 +20,56 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
#include <Standard_Stream.hxx>
#include <GEOMImpl_IMeasureOperations.hxx> #include <GEOMImpl_IMeasureOperations.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_MeasureDriver.hxx>
#include <GEOMImpl_IMeasure.hxx> #include <GEOMImpl_IMeasure.hxx>
#include <GEOMImpl_IShapesOperations.hxx> #include <GEOMImpl_MeasureDriver.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOMUtils.hxx> #include <GEOMUtils.hxx>
#include <GEOMAlgo_ShapeInfo.hxx> #include <GEOMAlgo_AlgoTools.hxx>
#include <GEOMAlgo_KindOfName.hxx>
#include <GEOMAlgo_ShapeInfoFiller.hxx> #include <GEOMAlgo_ShapeInfoFiller.hxx>
#include <GEOM_Function.hxx>
#include <GEOM_PythonDump.hxx> #include <GEOM_PythonDump.hxx>
#include <Basics_OCCTVersion.hxx>
#include <utilities.h> #include <utilities.h>
#include <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx>
// OCCT Includes // OCCT Includes
#include <TFunction_DriverTable.hxx> #include <Bnd_Box.hxx>
#include <TFunction_Driver.hxx> #include <BOPAlgo_CheckerSI.hxx>
#include <TFunction_Logbook.hxx> #include <BOPCol_ListOfShape.hxx>
#include <TDF_Tool.hxx> #include <BOPDS_DS.hxx>
#include <BOPDS_MapOfPassKey.hxx>
#include <BRep_Builder.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 <BRepBndLib.hxx>
#include <BRepCheck.hxx> #include <BRepBuilderAPI_Copy.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx> #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRepCheck_Result.hxx>
#include <BRepCheck_Shell.hxx> #include <BRepCheck_Shell.hxx>
#include <BRepClass3d_SolidClassifier.hxx> #include <BRepClass3d_SolidClassifier.hxx>
#include <BRepClass_FaceClassifier.hxx> #include <BRepClass_FaceClassifier.hxx>
#include <BRepExtrema_DistShapeShape.hxx> #include <BRepExtrema_DistShapeShape.hxx>
#include <BRepGProp.hxx> #include <BRepGProp.hxx>
#include <BRepTools.hxx> #include <BRepTools.hxx>
#include <BRep_Tool.hxx>
#include <Bnd_Box.hxx> #include <Geom_Line.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 <GeomAPI_ProjectPointOnCurve.hxx> #include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx> #include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <Geom_Line.hxx>
#include <Geom_Surface.hxx>
#include <GeomLProp_CLProps.hxx> #include <GeomLProp_CLProps.hxx>
#include <GeomLProp_SLProps.hxx> #include <GeomLProp_SLProps.hxx>
#include <GProp_GProps.hxx> #include <GProp_GProps.hxx>
#include <GProp_PrincipalProps.hxx> #include <GProp_PrincipalProps.hxx>
#include <ShapeAnalysis.hxx>
#include <gp_Pln.hxx> #include <ShapeAnalysis_Surface.hxx>
#include <gp_Lin.hxx> #include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <BOPCol_ListOfShape.hxx> #include <TopoDS.hxx>
#include <BOPDS_DS.hxx> #include <TopoDS_Edge.hxx>
#include <BOPDS_MapOfPassKey.hxx> #include <TopoDS_Compound.hxx>
#include <BOPDS_PassKey.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#include <GEOMAlgo_AlgoTools.hxx> #include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx>
#include <BOPAlgo_CheckerSI.hxx> #include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
//============================================================================= //=============================================================================
@ -1298,11 +1258,12 @@ void GEOMImpl_IMeasureOperations::GetTolerance
* CheckShape * CheckShape
*/ */
//============================================================================= //=============================================================================
bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape,
const Standard_Boolean theIsCheckGeom, const Standard_Boolean theIsCheckGeom,
TCollection_AsciiString& theDump) std::list<ShapeError> &theErrors)
{ {
SetErrorCode(KO); SetErrorCode(KO);
theErrors.clear();
if (theShape.IsNull()) return false; if (theShape.IsNull()) return false;
@ -1323,10 +1284,9 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape,
#endif #endif
BRepCheck_Analyzer ana (aShape, theIsCheckGeom); BRepCheck_Analyzer ana (aShape, theIsCheckGeom);
if (ana.IsValid()) { if (ana.IsValid()) {
theDump.Clear();
isValid = true; isValid = true;
} else { } else {
StructuralDump(ana, aShape, theDump); FillErrors(ana, aShape, theErrors);
} }
} }
catch (Standard_Failure) { catch (Standard_Failure) {
@ -1339,6 +1299,223 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape,
return isValid; 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 * CheckSelfIntersections
@ -2297,362 +2474,157 @@ Standard_Real GEOMImpl_IMeasureOperations::MinSurfaceCurvatureByPoint
return getSurfaceCurvatures(aSurf, UV.X(), UV.Y(), false); return getSurfaceCurvatures(aSurf, UV.X(), UV.Y(), false);
} }
//======================================================================= //=======================================================================
//function : StructuralDump //function : FillErrorsSub
//purpose : Structural (data exchange) style of output. //purpose : Fill the errors list of subshapes on shape.
//======================================================================= //=======================================================================
void GEOMImpl_IMeasureOperations::StructuralDump (const BRepCheck_Analyzer& theAna, void GEOMImpl_IMeasureOperations::FillErrorsSub
const TopoDS_Shape& theShape, (const BRepCheck_Analyzer &theAna,
TCollection_AsciiString& theDump) const TopoDS_Shape &theShape,
const TopAbs_ShapeEnum theSubType,
TopTools_DataMapOfIntegerListOfShape &theMapErrors) const
{ {
Standard_Integer i; TopExp_Explorer anExp(theShape, theSubType);
theDump.Clear(); TopTools_MapOfShape aMapSubShapes;
theDump += " -- The Shape has problems :\n";
theDump += " Check Count\n";
theDump += " ------------------------------------------------\n";
Standard_Integer last_stat = (Standard_Integer)BRepCheck_CheckFail; for (; anExp.More(); anExp.Next()) {
Handle(TColStd_HArray1OfInteger) NbProblems = const TopoDS_Shape &aSubShape = anExp.Current();
new TColStd_HArray1OfInteger(1, last_stat);
for (i = 1; i <= last_stat; i++)
NbProblems->SetValue(i,0);
Handle(TopTools_HSequenceOfShape) sl; if (aMapSubShapes.Add(aSubShape)) {
sl = new TopTools_HSequenceOfShape(); const Handle(BRepCheck_Result) &aRes = theAna.Result(aSubShape);
TopTools_DataMapOfShapeListOfShape theMap;
theMap.Clear();
GetProblemShapes(theAna, theShape, sl, NbProblems, theMap);
theMap.Clear();
Standard_Integer count = 0; for (aRes->InitContextIterator();
count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnCurve); aRes->MoreShapeInContext();
if (count > 0) { aRes->NextShapeInContext()) {
theDump += " Invalid Point on Curve ................... "; if (aRes->ContextualShape().IsSame(theShape)) {
theDump += TCollection_AsciiString(count) + "\n"; BRepCheck_ListIteratorOfListOfStatus itl(aRes->StatusOnShape());
}
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"; if (itl.Value() != BRepCheck_NoError) {
theDump += "*** Shapes with problems : "; // Add all errors for theShape and its sub-shape.
theDump += TCollection_AsciiString(sl->Length()) + "\n"; for (;itl.More(); itl.Next()) {
const Standard_Integer aStat = (Standard_Integer)itl.Value();
Standard_Integer nbv, nbe, nbw, nbf, nbs, nbo; if (!theMapErrors.IsBound(aStat)) {
nbv = nbe = nbw = nbf = nbs = nbo = 0; TopTools_ListOfShape anEmpty;
for (i = 1; i <= sl->Length(); i++) { theMapErrors.Bind(aStat, anEmpty);
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;
}
}
if (nbv > 0) { TopTools_ListOfShape &theShapes = theMapErrors.ChangeFind(aStat);
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";
}
}
theShapes.Append(aSubShape);
//======================================================================= theShapes.Append(theShape);
//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);
}
}
}
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
//=======================================================================
static Standard_Boolean Contains (const TopTools_ListOfShape& L,
const TopoDS_Shape& S)
{
TopTools_ListIteratorOfListOfShape it;
for (it.Initialize(L); it.More(); it.Next()) {
if (it.Value().IsSame(S)) {
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : GetProblemSub
// purpose : for StructuralDump
//=======================================================================
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)
{
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; break;
} }
} }
} }
} }
//=======================================================================
//function : FillErrors
//purpose : Fill the errors list.
//=======================================================================
void GEOMImpl_IMeasureOperations::FillErrors
(const BRepCheck_Analyzer &theAna,
const TopoDS_Shape &theShape,
TopTools_DataMapOfIntegerListOfShape &theMapErrors,
TopTools_MapOfShape &theMapShapes) const
{
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;
}
}
}
//=======================================================================
//function : FillErrors
//purpose : Fill the errors list.
//=======================================================================
void GEOMImpl_IMeasureOperations::FillErrors
(const BRepCheck_Analyzer &theAna,
const TopoDS_Shape &theShape,
std::list<ShapeError> &theErrors) const
{
// 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);
}
}
}

View File

@ -26,13 +26,13 @@
#include "GEOM_IOperations.hxx" #include "GEOM_IOperations.hxx"
#include <BRepCheck_Analyzer.hxx> #include <BRepCheck_Analyzer.hxx>
#include <BRepCheck_Status.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <TColStd_HSequenceOfInteger.hxx> #include <TColStd_HSequenceOfInteger.hxx>
#include <TColStd_HSequenceOfReal.hxx> #include <TColStd_HSequenceOfReal.hxx>
#include <gp_Ax3.hxx> #include <TopTools_DataMapOfIntegerListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
#include <Precision.hxx> #include <Precision.hxx>
@ -127,9 +127,18 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
Standard_Real& EdgeMin, Standard_Real& EdgeMax, Standard_Real& EdgeMin, Standard_Real& EdgeMax,
Standard_Real& VertMin, Standard_Real& VertMax); Standard_Real& VertMin, Standard_Real& VertMax);
Standard_EXPORT bool CheckShape (Handle(GEOM_Object) theShape, struct ShapeError {
const Standard_Boolean theIsCheckGeom, BRepCheck_Status error;
TCollection_AsciiString& theDump); 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, Standard_EXPORT bool CheckSelfIntersections (Handle(GEOM_Object) theShape,
Handle(TColStd_HSequenceOfInteger)& theIntersections); Handle(TColStd_HSequenceOfInteger)& theIntersections);
@ -177,22 +186,21 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
Handle(GEOM_Object) thePoint); Handle(GEOM_Object) thePoint);
private: private:
void StructuralDump (const BRepCheck_Analyzer& theAna,
const TopoDS_Shape& theShape,
TCollection_AsciiString& theDump);
void GetProblemShapes (const BRepCheck_Analyzer& theAna, void FillErrorsSub
const TopoDS_Shape& theShape, (const BRepCheck_Analyzer &theAna,
Handle(TopTools_HSequenceOfShape)& sl, const TopoDS_Shape &theShape,
Handle(TColStd_HArray1OfInteger)& NbProblems, const TopAbs_ShapeEnum theSubType,
TopTools_DataMapOfShapeListOfShape& theMap); TopTools_DataMapOfIntegerListOfShape &theMapErrors) const;
void FillErrors
(const BRepCheck_Analyzer &theAna,
const TopoDS_Shape &theShape,
TopTools_DataMapOfIntegerListOfShape &theMapErrors,
TopTools_MapOfShape &theMapShapes) const;
void GetProblemSub (const BRepCheck_Analyzer& theAna, void FillErrors (const BRepCheck_Analyzer &theAna,
const TopoDS_Shape& theShape, const TopoDS_Shape &theShape,
Handle(TopTools_HSequenceOfShape)& sl, std::list<ShapeError> &theErrors) const;
Handle(TColStd_HArray1OfInteger)& NbProblems,
const TopAbs_ShapeEnum Subtype,
TopTools_DataMapOfShapeListOfShape& theMap);
Standard_Real getSurfaceCurvatures (const Handle(Geom_Surface)& aSurf, Standard_Real getSurfaceCurvatures (const Handle(Geom_Surface)& aSurf,
Standard_Real theUParam, Standard_Real theUParam,

1
src/GEOM_I/GEOM_Gen_i.cc Normal file → Executable file
View File

@ -58,6 +58,7 @@
#include <TColStd_HArray1OfInteger.hxx> #include <TColStd_HArray1OfInteger.hxx>
#include <TopAbs_ShapeEnum.hxx> #include <TopAbs_ShapeEnum.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <OSD.hxx> #include <OSD.hxx>
#include <SALOMEDS_Tool.hxx> #include <SALOMEDS_Tool.hxx>

View File

@ -60,6 +60,7 @@
//#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
class TopTools_SequenceOfShape;
//===================================================================== //=====================================================================
// Generic operations creator (for plugins mechanism) // Generic operations creator (for plugins mechanism)

View File

@ -30,6 +30,291 @@
#include "GEOM_Engine.hxx" #include "GEOM_Engine.hxx"
#include "GEOM_Object.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: * constructor:
@ -332,15 +617,15 @@ void GEOM_IMeasureOperations_i::GetTolerance
* CheckShape * CheckShape
*/ */
//============================================================================= //=============================================================================
CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape (GEOM::GEOM_Object_ptr theShape, CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape
CORBA::String_out theDescription) (GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors)
{ {
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
if (CORBA::is_nil(theShape)) if (CORBA::is_nil(theShape))
{ {
theDescription = CORBA::string_dup("null");
return 0; return 0;
} }
@ -349,30 +634,26 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape (GEOM::GEOM_Object_ptr theS
if (aShape.IsNull()) if (aShape.IsNull())
{ {
theDescription = CORBA::string_dup("null2");
return 0; return 0;
} }
// Get shape parameters std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
TCollection_AsciiString aDump; bool isOk = GetOperations()->CheckShape(aShape, false, anErrList);
if (GetOperations()->CheckShape(aShape, /*check_geom = */false, aDump))
{ ConvertShapeError(anErrList, theErrors);
theDescription = CORBA::string_dup("OK");
return 1; return isOk;
}
theDescription = CORBA::string_dup(aDump.ToCString());
return 0;
} }
CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry (GEOM::GEOM_Object_ptr theShape, CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry
CORBA::String_out theDescription) (GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors)
{ {
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
if (CORBA::is_nil(theShape)) if (CORBA::is_nil(theShape))
{ {
theDescription = CORBA::string_dup("null");
return 0; return 0;
} }
@ -381,19 +662,42 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry (GEOM::GEOM_Obj
if (aShape.IsNull()) if (aShape.IsNull())
{ {
theDescription = CORBA::string_dup("null2");
return 0; return 0;
} }
// Get shape parameters std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
TCollection_AsciiString aDump; bool isOk = GetOperations()->CheckShape(aShape, true, anErrList);
if (GetOperations()->CheckShape(aShape, /*check_geom = */true, aDump))
{ ConvertShapeError(anErrList, theErrors);
theDescription = CORBA::string_dup("OK");
return 1; 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());
} }
//============================================================================= //=============================================================================

View File

@ -84,11 +84,17 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
CORBA::Double& EdgeMin, CORBA::Double& EdgeMax, CORBA::Double& EdgeMin, CORBA::Double& EdgeMax,
CORBA::Double& VertMin, CORBA::Double& VertMax); CORBA::Double& VertMin, CORBA::Double& VertMax);
CORBA::Boolean CheckShape (GEOM::GEOM_Object_ptr theShape, CORBA::Boolean CheckShape
CORBA::String_out theDescription); (GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors);
CORBA::Boolean CheckShapeWithGeometry (GEOM::GEOM_Object_ptr theShape, CORBA::Boolean CheckShapeWithGeometry
CORBA::String_out theDescription); (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, CORBA::Boolean CheckSelfIntersections (GEOM::GEOM_Object_ptr theShape,
GEOM::ListOfLong_out theIntersections); GEOM::ListOfLong_out theIntersections);

View File

@ -41,8 +41,9 @@ def TestMeasureOperations (geompy, math):
####### CheckShape ####### ####### CheckShape #######
IsValid = geompy.CheckShape(box) (IsValid, err) = geompy.CheckShape(box, 0, 2)
if IsValid == 0: if IsValid == 0:
geompy.PrintShapeError(box, err)
raise RuntimeError, "Invalid box created" raise RuntimeError, "Invalid box created"
else: else:
print "\nBox is valid" print "\nBox is valid"

View File

@ -10142,15 +10142,52 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
self._autoPublish(anObj, theName, "normal") self._autoPublish(anObj, theName, "normal")
return anObj 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. ## Check a topology of the given shape.
# @param theShape Shape to check validity of. # @param theShape Shape to check validity of.
# @param theIsCheckGeom If FALSE, only the shape's topology will be checked, \n # @param theIsCheckGeom If FALSE, only the shape's topology will be checked, \n
# if TRUE, the shape's geometry will be checked also. # if TRUE, the shape's geometry will be checked also.
# @param theReturnStatus If FALSE and if theShape is invalid, a description \n # @param theReturnStatus If 0 and if theShape is invalid, a description
# of problem is printed. # of problem is printed.
# if TRUE and if theShape is invalid, the description # If 1 isValid flag and the description of
# of problem is also returned. # problem is returned.
# If 2 isValid flag and the list of error data
# is returned.
# @return TRUE, if the shape "seems to be valid". # @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" # @ref tui_measurement_tools_page "Example"
def CheckShape(self,theShape, theIsCheckGeom = 0, theReturnStatus = 0): 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. theShape Shape to check validity of.
theIsCheckGeom If FALSE, only the shape's topology will be checked, theIsCheckGeom If FALSE, only the shape's topology will be checked,
if TRUE, the shape's geometry will be checked also. 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. of problem is printed.
if TRUE and if theShape is invalid, the description If 1 IsValid flag and the description of
of problem is returned. problem is returned.
If 2 IsValid flag and the list of error data
is returned.
Returns: Returns:
TRUE, if the shape "seems to be valid". TRUE, if the shape "seems to be valid".
If theShape is invalid, prints a description of problem. 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 # Example: see GEOM_TestMeasures.py
if theIsCheckGeom: if theIsCheckGeom:
(IsValid, Status) = self.MeasuOp.CheckShapeWithGeometry(theShape) (IsValid, ShapeErrors) = self.MeasuOp.CheckShapeWithGeometry(theShape)
RaiseIfFailed("CheckShapeWithGeometry", self.MeasuOp) RaiseIfFailed("CheckShapeWithGeometry", self.MeasuOp)
else: else:
(IsValid, Status) = self.MeasuOp.CheckShape(theShape) (IsValid, ShapeErrors) = self.MeasuOp.CheckShape(theShape)
RaiseIfFailed("CheckShape", self.MeasuOp) RaiseIfFailed("CheckShape", self.MeasuOp)
if IsValid == 0: if IsValid == 0:
if theReturnStatus == 0: if theReturnStatus == 0:
print Status Descr = self.MeasuOp.PrintShapeErrors(theShape, ShapeErrors)
print Descr
if theReturnStatus == 1: if theReturnStatus == 1:
return (IsValid, Status) Descr = self.MeasuOp.PrintShapeErrors(theShape, ShapeErrors)
return (IsValid, Descr)
elif theReturnStatus == 2:
return (IsValid, ShapeErrors)
return IsValid return IsValid
## Detect self-intersections in the given shape. ## Detect self-intersections in the given shape.

View File

@ -66,6 +66,7 @@ SET(_uic_files
MeasureGUI_1Sel12LineEdit_QTD.ui MeasureGUI_1Sel12LineEdit_QTD.ui
MeasureGUI_1Sel1TextView1Check_QTD.ui MeasureGUI_1Sel1TextView1Check_QTD.ui
MeasureGUI_1Sel1TextView2ListBox_QTD.ui MeasureGUI_1Sel1TextView2ListBox_QTD.ui
MeasureGUI_1Sel1Check1TextView2ListBox_QTD.ui
MeasureGUI_1Sel1TextView_QTD.ui MeasureGUI_1Sel1TextView_QTD.ui
MeasureGUI_1Sel3LineEdit_QTD.ui MeasureGUI_1Sel3LineEdit_QTD.ui
MeasureGUI_1Sel6LineEdit_QTD.ui MeasureGUI_1Sel6LineEdit_QTD.ui

View File

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

View File

@ -299,25 +299,19 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
aErrStr = ""; aErrStr = "";
switch ( aErrs[i].error ) { switch ( aErrs[i].error ) {
case GEOM::GEOM_IBlocksOperations::NOT_BLOCK : case GEOM::GEOM_IBlocksOperations::NOT_BLOCK :
aErrStr = "Not a Block"; aErrStr = tr("GEOM_CHECK_BLOCKS_NOT_BLOCK");
break; break;
case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE : case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE :
aErrStr = "Extra Edge"; aErrStr = tr("GEOM_CHECK_BLOCKS_EXTRA_EDGE");
break; break;
case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION : case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION :
aErrStr = "Invalid Connection"; aErrStr = tr("GEOM_CHECK_BLOCKS_INVALID_CONNECTION").arg(aConNum++);
aErrStr += aConSfx;
aErrStr += QString::number( aConNum );
aConNum++;
break; break;
case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED : case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED :
aErrStr = "Not Connected"; aErrStr = tr("GEOM_CHECK_BLOCKS_NOT_CONNECTED");
break; break;
case GEOM::GEOM_IBlocksOperations::NOT_GLUED : case GEOM::GEOM_IBlocksOperations::NOT_GLUED :
aErrStr = "Not Glued"; aErrStr = tr("GEOM_CHECK_BLOCKS_NOT_GLUED").arg(aGluedNum++);
aErrStr += aGluedSfx;
aErrStr += QString::number( aGluedNum );
aGluedNum++;
break; break;
default : default :
aErrStr = ""; aErrStr = "";

View File

@ -24,12 +24,24 @@
// File : MeasureGUI_CheckShapeDlg.cxx // File : MeasureGUI_CheckShapeDlg.cxx
// Author : Nicolas REJNERI, Open CASCADE S.A.S. // Author : Nicolas REJNERI, Open CASCADE S.A.S.
// //
#include "MeasureGUI.h"
#include "MeasureGUI_CheckShapeDlg.h" #include "MeasureGUI_CheckShapeDlg.h"
#include "MeasureGUI_Widgets.h" #include "MeasureGUI_Widgets.h"
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <GEOMImpl_Types.hxx>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SalomeApp_Tools.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_FAMILY "Courier"
#define TEXTEDIT_FONT_SIZE 11 #define TEXTEDIT_FONT_SIZE 11
@ -42,7 +54,7 @@
// true to construct a modal dialog. // true to construct a modal dialog.
//================================================================================= //=================================================================================
MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* parent ) MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* parent )
: MeasureGUI_Skeleton( GUI, parent ) : GEOMBase_Skeleton( GUI, parent, false )
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
"GEOM", tr( "ICON_DLG_CHECKSHAPE" ) ) ); "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()->GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
mainFrame()->RadioButton1->setIcon( image0 ); 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->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
myGrp->TextView1->setReadOnly( true ); myGrp->TextView1->setReadOnly( true );
@ -67,10 +83,18 @@ MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* p
myGrp->PushButton1->setIcon( image1 ); myGrp->PushButton1->setIcon( image1 );
myGrp->LineEdit1->setReadOnly( true ); 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() ); QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( myGrp ); 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"; myHelpFileName = "using_measurement_tools_page.html#check_anchor";
@ -94,32 +118,167 @@ MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
//================================================================================= //=================================================================================
void MeasureGUI_CheckShapeDlg::Init() void MeasureGUI_CheckShapeDlg::Init()
{ {
mySelBtn = myGrp->PushButton1; // signals and slots connections
mySelEdit = myGrp->LineEdit1; connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
MeasureGUI_Skeleton::Init(); 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) ), connect( myGrp->CheckBox1, SIGNAL( toggled( bool) ),
this, SLOT( SelectionIntoArgument() ) ); this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_CHECK_SHAPE_NAME") );
buttonOk()->setEnabled( false );
buttonApply()->setEnabled( false );
activateSelection();
SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : getParameters // function : ClickOnOk()
// purpose : // 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; 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() ); GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
try { try {
char* aMsg; GEOM::GEOM_IMeasureOperations::ShapeErrors_var aErrs;
bool isCheckGeometry = myGrp->CheckBox1->isChecked(); bool isCheckGeometry = myGrp->CheckBox1->isChecked();
if ( isCheckGeometry ) if ( isCheckGeometry )
theIsValid = anOper->CheckShapeWithGeometry( myObj, aMsg ); theIsValid = anOper->CheckShapeWithGeometry( myObj, aErrs );
else else
theIsValid = anOper->CheckShape( myObj, aMsg ); theIsValid = anOper->CheckShape( myObj, aErrs );
theMsg = aMsg;
if (anOper->IsDone() && aErrs->length() > 0)
theErrors = aErrs;
} }
catch( const SALOME::SALOME_Exception& e ) { catch( const SALOME::SALOME_Exception& e ) {
SalomeApp_Tools::QtCatchCorbaException( e ); SalomeApp_Tools::QtCatchCorbaException( e );
@ -138,19 +297,343 @@ bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg
void MeasureGUI_CheckShapeDlg::processObject() void MeasureGUI_CheckShapeDlg::processObject()
{ {
bool isShapeValid; bool isShapeValid;
QString aMsg; GEOM::GEOM_IMeasureOperations::ShapeErrors aErrs;
if ( !getParameters( isShapeValid, aMsg ) ) {
if ( !getErrors( isShapeValid, aErrs ) ) {
myGrp->TextView1->setText( "" ); myGrp->TextView1->setText( "" );
myGrp->ListBox1->clear();
myGrp->ListBox2->clear();
erasePreview();
return; return;
} }
if ( isShapeValid ) { if ( isShapeValid ) {
myGrp->TextView1->setText( "This Shape seems to be valid." ); myGrp->TextView1->setText(tr("GEOM_CHECK_SHAPE_VALID"));
} buttonOk()->setEnabled( false );
else { buttonApply()->setEnabled( false );
QString aDescr ( "This Shape is not valid.\n" ); } else {
aDescr += aMsg; myGrp->TextView1->setText(tr("GEOM_CHECK_SHAPE_NOT_VALID"));
myGrp->TextView1->setText( aDescr ); buttonOk()->setEnabled( true );
// myGrp->TextView1->setText("This Shape is not valid."); 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;
}

View File

@ -27,15 +27,15 @@
#ifndef MEASUREGUI_CHECKSHAPEDLG_H #ifndef MEASUREGUI_CHECKSHAPEDLG_H
#define MEASUREGUI_CHECKSHAPEDLG_H #define MEASUREGUI_CHECKSHAPEDLG_H
#include "MeasureGUI_Skeleton.h" #include <GEOMBase_Skeleton.h>
class MeasureGUI_1Sel1TextView1Check; class MeasureGUI_1Sel1Check1TextView2ListBox;
//================================================================================= //=================================================================================
// class : MeasureGUI_CheckShapeDlg // class : MeasureGUI_CheckShapeDlg
// purpose : // purpose :
//================================================================================= //=================================================================================
class MeasureGUI_CheckShapeDlg : public MeasureGUI_Skeleton class MeasureGUI_CheckShapeDlg : public GEOMBase_Skeleton
{ {
Q_OBJECT Q_OBJECT
@ -45,14 +45,32 @@ public:
protected: protected:
// redefined from GEOMBase_Helper and MeasureGUI_Skeleton // 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: private:
void Init(); void Init();
bool getParameters( bool&, QString& ); void enterEvent( QEvent* );
bool getErrors
( bool&, GEOM::GEOM_IMeasureOperations::ShapeErrors&);
private: private:
MeasureGUI_1Sel1TextView1Check* myGrp; GEOM::GEOM_Object_var myObj;
MeasureGUI_1Sel1Check1TextView2ListBox* myGrp;
GEOM::GEOM_IShapesOperations_var myShapesOper;
}; };
#endif // MEASUREGUI_CHECKSHAPEDLG_H #endif // MEASUREGUI_CHECKSHAPEDLG_H

View 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 // MeasureGUI_1Sel1TextView
////////////////////////////////////////// //////////////////////////////////////////

View File

@ -71,6 +71,22 @@ public:
~MeasureGUI_1Sel1TextView2ListBox(); ~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 // MeasureGUI_1Sel1TextView
////////////////////////////////////////// //////////////////////////////////////////