From 7a3849106297406af9bda3a46ffd5ad1daded9e5 Mon Sep 17 00:00:00 2001 From: skv Date: Tue, 26 Nov 2013 07:06:56 +0000 Subject: [PATCH] 0022338: EDF GEOM: Regression when partitoning a compound by a plane --- doc/salome/gui/GEOM/input/partition.doc | 14 ++++++- idl/GEOM_Gen.idl | 13 ++++-- .../GEOMImpl_IAdvancedOperations.cxx | 2 +- src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx | 27 +++++++++--- src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx | 8 ++-- src/GEOMImpl/GEOMImpl_IPartition.hxx | 6 +++ src/GEOMImpl/GEOMImpl_PartitionDriver.cxx | 41 +++++++++++++++++++ src/GEOM_I/GEOM_IBooleanOperations_i.cc | 18 +++++--- src/GEOM_I/GEOM_IBooleanOperations_i.hh | 9 ++-- src/GEOM_I_Superv/GEOM_Superv_i.cc | 5 ++- src/GEOM_SWIG/geomBuilder.py | 27 ++++++++---- .../OperationGUI_PartitionDlg.cxx | 16 ++++++-- src/OperationGUI/OperationGUI_PartitionDlg.h | 2 + 13 files changed, 152 insertions(+), 36 deletions(-) diff --git a/doc/salome/gui/GEOM/input/partition.doc b/doc/salome/gui/GEOM/input/partition.doc index dfee4899f..27fdc0dad 100644 --- a/doc/salome/gui/GEOM/input/partition.doc +++ b/doc/salome/gui/GEOM/input/partition.doc @@ -54,6 +54,12 @@ computed. If this option is switched on, the intersection between sub-shapes will not be performed. In this case the Partition algorithm will work faster, but the result might differ from the default behavior. +Detect Self-intersections check box is used to check arguments +self-intersections. If this option is switched on (default behavior) +each input shape is checked for self-intersection. In case of its detection +the operation is aborted. If this option is switched off, the partition +algorithm is performed without self-intersection checks. + Advanced option: \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments". @@ -67,13 +73,13 @@ will work faster, but the result might differ from the default behavior. geompy.MakePartition(ListOfShapes, ListOfTools, ListOfKeepInside, ListOfRemoveInside, Limit, RemoveWebs, ListOfMaterials, -KeepNonlimitShapes) +KeepNonlimitShapes, checkSelfInte) TUI Command (without sub-shapes intersection): geompy.MakePartitionNonSelfIntersectedShape(ListOfShapes, ListOfTools, ListOfKeepInside, ListOfRemoveInside, Limit, RemoveWebs, -ListOfMaterials, KeepNonlimitShapes) +ListOfMaterials, KeepNonlimitShapes, checkSelfInte) Here, - \em ListOfShapes is a list of shapes to be intersected @@ -82,6 +88,8 @@ Here, - \em Limit is a Type of resulting shapes - \em KeepNonlimitShapes is a flag that allows to preserve standalone shapes of low dimension (than \em Limit) in the result. +- \em checkSelfInte is a flag that tells if the arguments should +be checked for self-intersection prior to the operation. - Other parameters are obsolete and kept only for compatibility with previous versions of SALOME. @@ -99,6 +107,8 @@ previous versions of SALOME. geompy.MakeHalfPartition(Shape, Plane), where: - \em Shape is a source shape to be intersected by the \em Plane - \em Plane is a tool shape, to intersect the \em Shape. +- \em checkSelfInte is a flag that tells if the arguments should +be checked for self-intersection prior to the operation. Examples: diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index a9ad919b6..5149fd622 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2968,6 +2968,8 @@ module GEOM * Each shape from theRemoveInside must belong to theShapes also. * \param theRemoveWebs If TRUE, perform Glue 3D algorithm. * \param theMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE. + * \param IsCheckSelfInte If TRUE, perform check self intersection + * of arguments before an operation. * * \return New GEOM_Object, containing the result shapes. */ @@ -2978,7 +2980,8 @@ module GEOM in short theLimit, in boolean theRemoveWebs, in ListOfLong theMaterials, - in short theKeepNonlimitShapes); + in short theKeepNonlimitShapes, + in boolean IsCheckSelfInte); /*! * \brief Perform partition operation. @@ -3001,16 +3004,20 @@ module GEOM in short theLimit, in boolean theRemoveWebs, in ListOfLong theMaterials, - in short theKeepNonlimitShapes); + in short theKeepNonlimitShapes, + in boolean IsCheckSelfInte); /*! * \brief Perform partition of the Shape with the Plane * \param theShape Shape to be intersected. * \param thePlane Tool shape, to intersect theShape. + * \param IsCheckSelfInte If TRUE, perform check self intersection + * of arguments before an operation. * \return New GEOM_Object, containing the result shape. */ GEOM_Object MakeHalfPartition (in GEOM_Object theShape, - in GEOM_Object thePlane); + in GEOM_Object thePlane, + in boolean IsCheckSelfInte); }; // # GEOM_ICurvesOperations: diff --git a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx b/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx index 36961c7e6..065776d63 100644 --- a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx +++ b/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx @@ -1574,7 +1574,7 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t Te3 = myBooleanOperations->MakePartition (partitionShapes, theTools, theKeepInside, theRemoveInside, - TopAbs_SOLID, false, theMaterials, 0, false); + TopAbs_SOLID, false, theMaterials, 0, false, Standard_False); if (Te3.IsNull()) { SetErrorCode("Impossible to build partition of TShape"); return false; diff --git a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx index be4bfb3d3..9cd7b2005 100644 --- a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx @@ -371,7 +371,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition const Standard_Boolean theRemoveWebs, const Handle(TColStd_HArray1OfInteger)& theMaterials, const Standard_Integer theKeepNonlimitShapes, - const Standard_Boolean thePerformSelfIntersections) + const Standard_Boolean thePerformSelfIntersections, + const Standard_Boolean IsCheckSelfInte) { SetErrorCode(KO); @@ -437,6 +438,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition // Limit aCI.SetLimit(theLimit); aCI.SetKeepNonlimitShapes(theKeepNonlimitShapes); + aCI.SetCheckSelfIntersection(IsCheckSelfInte); // Materials if (theRemoveWebs) { @@ -488,7 +490,13 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition pd << ", " << theMaterials->Value(i); } } - pd << "], " << theKeepNonlimitShapes <<")"; + pd << "], " << theKeepNonlimitShapes; + + if (IsCheckSelfInte) { + pd << ", True"; + } + + pd << ")"; SetErrorCode(OK); return aPartition; @@ -500,7 +508,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition */ //============================================================================= Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition - (Handle(GEOM_Object) theShape, Handle(GEOM_Object) thePlane) + (Handle(GEOM_Object) theShape, Handle(GEOM_Object) thePlane, + const Standard_Boolean IsCheckSelfInte) { SetErrorCode(KO); @@ -526,6 +535,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition aCI.SetShape(aRef1); aCI.SetPlane(aRef2); + aCI.SetCheckSelfIntersection(IsCheckSelfInte); //Compute the Partition value try { @@ -544,8 +554,15 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition } //Make a Python command - GEOM::TPythonDump(aFunction) << aPart << " = geompy.MakeHalfPartition(" - << theShape << ", " << thePlane << ")"; + GEOM::TPythonDump pd (aFunction); + pd << aPart << " = geompy.MakeHalfPartition(" + << theShape << ", " << thePlane; + + if (IsCheckSelfInte) { + pd << ", True"; + } + + pd << ")"; SetErrorCode(OK); return aPart; diff --git a/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx b/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx index ad3f9e5b8..a3c321e38 100644 --- a/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx @@ -64,10 +64,12 @@ class GEOMImpl_IBooleanOperations : public GEOM_IOperations { const Standard_Boolean theRemoveWebs, const Handle(TColStd_HArray1OfInteger)& theMaterials, const Standard_Integer theKeepNonlimitShapes, - const Standard_Boolean thePerformSelfIntersections); + const Standard_Boolean thePerformSelfIntersections, + const Standard_Boolean IsCheckSelfInte); - Standard_EXPORT Handle(GEOM_Object) MakeHalfPartition (Handle(GEOM_Object) theShape, - Handle(GEOM_Object) thePlane); + Standard_EXPORT Handle(GEOM_Object) MakeHalfPartition (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) thePlane, + const Standard_Boolean IsCheckSelfInte); private: diff --git a/src/GEOMImpl/GEOMImpl_IPartition.hxx b/src/GEOMImpl/GEOMImpl_IPartition.hxx index 14f08e695..d0c202206 100644 --- a/src/GEOMImpl/GEOMImpl_IPartition.hxx +++ b/src/GEOMImpl/GEOMImpl_IPartition.hxx @@ -39,6 +39,7 @@ #define PART_ARG_PLANE 8 #define PART_ARG_KEEP_NONLIMIT_SHAPES 9 +#define BOOL_ARG_CHECK_SELF_INTERSECTION 10 class GEOMImpl_IPartition { @@ -66,6 +67,8 @@ class GEOMImpl_IPartition void SetMaterials(const Handle(TColStd_HArray1OfInteger)& theMaterials) { _func->SetIntegerArray(PART_ARG_MATERIALS, theMaterials); } + void SetCheckSelfIntersection (Standard_Boolean theFlag) + { _func->SetInteger(BOOL_ARG_CHECK_SELF_INTERSECTION, theFlag ? 1 : 0); } int GetLimit() { return _func->GetInteger(PART_ARG_LIMIT); } @@ -85,6 +88,9 @@ class GEOMImpl_IPartition Handle(GEOM_Function) GetShape() { return _func->GetReference(PART_ARG_SHAPE); } Handle(GEOM_Function) GetPlane() { return _func->GetReference(PART_ARG_PLANE); } + Standard_Boolean GetCheckSelfIntersection() + { return (_func->GetInteger(BOOL_ARG_CHECK_SELF_INTERSECTION) != 0); } + private: Handle(GEOM_Function) _func; diff --git a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx index ed632e060..641a122af 100644 --- a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx @@ -58,10 +58,18 @@ #include #include #include +#include #include #include +#include #include #include +#include + +// Depth of self-intersection check (see BOPAlgo_CheckerSI::SetLevelOfCheck() for more details) +// Default value for BOPAlgo_CheckerSI gives very long computation when checking face-to-face intersections; +// here check level is decreased to more appropriate value to avoid problems with performance). +#define BOP_SELF_INTERSECTIONS_LEVEL 4 //======================================================================= //function : GetID @@ -107,6 +115,21 @@ static void PrepareShapes (const TopoDS_Shape& theShape, } } +static void CheckSelfIntersection(const TopoDS_Shape &theShape) +{ + BOPAlgo_CheckerSI aCSI; // checker of self-interferences + BOPCol_ListOfShape aList; + + aList.Append(theShape); + aCSI.SetLevelOfCheck(BOP_SELF_INTERSECTIONS_LEVEL); + aCSI.SetArguments(aList); + aCSI.Perform(); + + if (aCSI.ErrorStatus() || aCSI.DS().Interferences().Extent() > 0) { + StdFail_NotDone::Raise("Partition operation will not be performed, because argument shape is self-intersected"); + } +} + //======================================================================= //function : Execute //purpose : @@ -118,6 +141,7 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const GEOMImpl_IPartition aCI (aFunction); Standard_Integer aType = aFunction->GetType(); + const Standard_Boolean isCheckSelfInte = aCI.GetCheckSelfIntersection(); TopoDS_Shape aShape; GEOMAlgo_Splitter PS; @@ -149,6 +173,11 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const Standard_NullObject::Raise("In Partition a shape is null"); } + // Check self-intersection. + if (isCheckSelfInte) { + CheckSelfIntersection(aShape_i); + } + TopoDS_Shape aShape_i_copy; TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy); @@ -185,6 +214,12 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const if (aShape_i.IsNull()) { Standard_NullObject::Raise("In Partition a tool shape is null"); } + + // Check self-intersection. + if (isCheckSelfInte) { + CheckSelfIntersection(aShape_i); + } + // //BRepBuilderAPI_Copy aCopyTool (aShape_i); TopoDS_Shape aShape_i_copy; @@ -324,6 +359,12 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const Standard_NullObject::Raise("In Half Partition a shape or a plane is null"); } + // Check self-intersection. + if (isCheckSelfInte) { + CheckSelfIntersection(aShapeArg); + CheckSelfIntersection(aPlaneArg); + } + TopoDS_Shape aShapeArg_copy; TopoDS_Shape aPlaneArg_copy; { diff --git a/src/GEOM_I/GEOM_IBooleanOperations_i.cc b/src/GEOM_I/GEOM_IBooleanOperations_i.cc index 84c513815..f21a9ee72 100644 --- a/src/GEOM_I/GEOM_IBooleanOperations_i.cc +++ b/src/GEOM_I/GEOM_IBooleanOperations_i.cc @@ -200,7 +200,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition CORBA::Short theLimit, CORBA::Boolean theRemoveWebs, const GEOM::ListOfLong& theMaterials, - CORBA::Short theKeepNonlimitShapes) + CORBA::Short theKeepNonlimitShapes, + CORBA::Boolean IsCheckSelfInte) { GEOM::GEOM_Object_var aGEOMObject; @@ -233,7 +234,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns, theLimit, theRemoveWebs, aMaterials, theKeepNonlimitShapes, - /*PerformSelfIntersections*/Standard_True); + /*PerformSelfIntersections*/Standard_True, + IsCheckSelfInte); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -253,7 +255,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersected CORBA::Short theLimit, CORBA::Boolean theRemoveWebs, const GEOM::ListOfLong& theMaterials, - CORBA::Short theKeepNonlimitShapes) + CORBA::Short theKeepNonlimitShapes, + CORBA::Boolean IsCheckSelfInte) { GEOM::GEOM_Object_var aGEOMObject; @@ -286,7 +289,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersected GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns, theLimit, theRemoveWebs, aMaterials, theKeepNonlimitShapes, - /*PerformSelfIntersections*/Standard_False); + /*PerformSelfIntersections*/Standard_False, + IsCheckSelfInte); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -300,7 +304,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersected //============================================================================= GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition (GEOM::GEOM_Object_ptr theShape, - GEOM::GEOM_Object_ptr thePlane) + GEOM::GEOM_Object_ptr thePlane, + CORBA::Boolean IsCheckSelfInte) { GEOM::GEOM_Object_var aGEOMObject; @@ -314,7 +319,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition if (aSh.IsNull() || aPl.IsNull()) return aGEOMObject._retn(); // Make Half Partition - Handle(GEOM_Object) anObject = GetOperations()->MakeHalfPartition(aSh, aPl); + Handle(GEOM_Object) anObject = + GetOperations()->MakeHalfPartition(aSh, aPl, IsCheckSelfInte); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); diff --git a/src/GEOM_I/GEOM_IBooleanOperations_i.hh b/src/GEOM_I/GEOM_IBooleanOperations_i.hh index e8381d085..3f3a73b8b 100644 --- a/src/GEOM_I/GEOM_IBooleanOperations_i.hh +++ b/src/GEOM_I/GEOM_IBooleanOperations_i.hh @@ -64,7 +64,8 @@ class GEOM_I_EXPORT GEOM_IBooleanOperations_i : CORBA::Short theLimit, CORBA::Boolean theRemoveWebs, const GEOM::ListOfLong& theMaterials, - CORBA::Short theKeepNonlimitShapes); + CORBA::Short theKeepNonlimitShapes, + CORBA::Boolean IsCheckSelfInte); GEOM::GEOM_Object_ptr MakePartitionNonSelfIntersectedShape (const GEOM::ListOfGO& theShapes, const GEOM::ListOfGO& theTools, @@ -73,11 +74,13 @@ class GEOM_I_EXPORT GEOM_IBooleanOperations_i : CORBA::Short theLimit, CORBA::Boolean theRemoveWebs, const GEOM::ListOfLong& theMaterials, - CORBA::Short theKeepNonlimitShapes); + CORBA::Short theKeepNonlimitShapes, + CORBA::Boolean IsCheckSelfInte); GEOM::GEOM_Object_ptr MakeHalfPartition (GEOM::GEOM_Object_ptr theShape, - GEOM::GEOM_Object_ptr thePlane); + GEOM::GEOM_Object_ptr thePlane, + CORBA::Boolean IsCheckSelfInte); ::GEOMImpl_IBooleanOperations* GetOperations() { return (::GEOMImpl_IBooleanOperations*)GetImpl(); } diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 946f958d2..ce29d33a7 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -1528,7 +1528,7 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePartition (GEOM::GEOM_List_ptr theSha myBoolOp->MakePartition(aListImplS->GetList(), aListImplT->GetList(), aListImplKI->GetList(), aListImplRI->GetList(), theLimit, theRemoveWebs, aListImplM->GetList(), - theKeepNonlimitShapes); + theKeepNonlimitShapes, false); endService( " GEOM_Superv_i::MakePartition" ); return anObj; } @@ -1545,7 +1545,8 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeHalfPartition (GEOM::GEOM_Object_ptr th beginService( " GEOM_Superv_i::MakeHalfPartition" ); MESSAGE("GEOM_Superv_i::MakeHalfPartition"); getBoolOp(); - GEOM::GEOM_Object_ptr anObj = myBoolOp->MakeHalfPartition(theShape, thePlane); + GEOM::GEOM_Object_ptr anObj = + myBoolOp->MakeHalfPartition(theShape, thePlane, false); endService( " GEOM_Superv_i::MakeHalfPartition" ); return anObj; } diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index a0d60cb5f..82dd7ac1b 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -6939,6 +6939,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # target type (equal to Limit) are kept in the result, # else standalone shapes of lower dimension # are kept also (if they exist). + # @param checkSelfInte The flag that tells if the arguments should + # be checked for self-intersection prior to the operation. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. @@ -6962,7 +6964,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @ref tui_partition "Example" def MakePartition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[], - KeepNonlimitShapes=0, theName=None): + KeepNonlimitShapes=0, checkSelfInte=False, theName=None): """ Perform partition operation. @@ -6976,6 +6978,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): target type (equal to Limit) are kept in the result, else standalone shapes of lower dimension are kept also (if they exist). + checkSelfInte The flag that tells if the arguments should + be checked for self-intersection prior to + the operation. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. @@ -7009,7 +7014,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): anObj = self.BoolOp.MakePartition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit, RemoveWebs, ListMaterials, - KeepNonlimitShapes); + KeepNonlimitShapes, checkSelfInte); RaiseIfFailed("MakePartition", self.BoolOp) self._autoPublish(anObj, theName, "partition") return anObj @@ -7031,7 +7036,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[], KeepNonlimitShapes=0, - theName=None): + checkSelfInte=False, theName=None): """ Perform partition operation. This method may be useful if it is needed to make a partition for @@ -7057,7 +7062,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): anObj = self.BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit, RemoveWebs, ListMaterials, - KeepNonlimitShapes); + KeepNonlimitShapes, checkSelfInte); RaiseIfFailed("MakePartitionNonSelfIntersectedShape", self.BoolOp) self._autoPublish(anObj, theName, "partition") return anObj @@ -7068,7 +7073,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # \n @ref swig_Partition "Example 2" def Partition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[], - KeepNonlimitShapes=0, theName=None): + KeepNonlimitShapes=0, checkSelfInte=False, theName=None): """ See method geompy.MakePartition for more information. """ @@ -7077,12 +7082,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): anObj = self.MakePartition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit, RemoveWebs, ListMaterials, - KeepNonlimitShapes, theName); + KeepNonlimitShapes, checkSelfInte, + theName); return anObj ## Perform partition of the Shape with the Plane # @param theShape Shape to be intersected. # @param thePlane Tool shape, to intersect theShape. + # @param checkSelfInte The flag that tells if the arguments should + # be checked for self-intersection prior to the operation. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. @@ -7090,13 +7098,16 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_partition "Example" - def MakeHalfPartition(self, theShape, thePlane, theName=None): + def MakeHalfPartition(self, theShape, thePlane, checkSelfInte=False, theName=None): """ Perform partition of the Shape with the Plane Parameters: theShape Shape to be intersected. thePlane Tool shape, to intersect theShape. + checkSelfInte The flag that tells if the arguments should + be checked for self-intersection prior to + the operation. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. @@ -7105,7 +7116,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestAll.py - anObj = self.BoolOp.MakeHalfPartition(theShape, thePlane) + anObj = self.BoolOp.MakeHalfPartition(theShape, thePlane, checkSelfInte) RaiseIfFailed("MakeHalfPartition", self.BoolOp) self._autoPublish(anObj, theName, "partition") return anObj diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx index b51d7b488..a6a989e96 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -85,6 +85,10 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU GroupPoints->CheckButton1->setText( tr( "GEOM_KEEP_NONLIMIT_SHAPES" ) ); GroupPoints->CheckButton2->setText( tr( "GEOM_NO_SELF_INTERSECTION" ) ); + mySelfInte = new QCheckBox(GroupPoints->GroupBox1); + mySelfInte->setText(tr("GEOM_CHECK_SELF_INTERSECTIONS")); + GroupPoints->gridLayout1->addWidget(mySelfInte, 5, 0, 1, 3); + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( GroupPoints ); @@ -140,6 +144,7 @@ void OperationGUI_PartitionDlg::Init() GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) ); GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::VERTEX); GroupPoints->CheckButton1->setChecked( false ); + mySelfInte->setChecked(true); mainFrame()->GroupBoxPublish->show(); @@ -162,6 +167,7 @@ void OperationGUI_PartitionDlg::Init() connect( GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(processPreview()) ); connect( GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(processPreview()) ); + connect( mySelfInte, SIGNAL(toggled(bool)), this, SLOT(processPreview()) ); initName( tr( "GEOM_PARTITION" ) ); @@ -440,6 +446,7 @@ bool OperationGUI_PartitionDlg::execute (ObjectList& objects) { bool res = false; GEOM::GEOM_Object_var anObj; + bool isDetectSelfInte = mySelfInte->isChecked(); GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation()); @@ -453,16 +460,19 @@ bool OperationGUI_PartitionDlg::execute (ObjectList& objects) anObj = aNoSelfIntersection ? anOper->MakePartitionNonSelfIntersectedShape(myListShapes, myListTools, myListKeepInside, myListRemoveInside, - aLimit, false, myListMaterials, aKeepNonlimitShapes) : + aLimit, false, myListMaterials, aKeepNonlimitShapes, + isDetectSelfInte) : anOper->MakePartition(myListShapes, myListTools, myListKeepInside, myListRemoveInside, - aLimit, false, myListMaterials, aKeepNonlimitShapes); + aLimit, false, myListMaterials, aKeepNonlimitShapes, + isDetectSelfInte); res = true; } break; case 1: { - anObj = anOper->MakeHalfPartition( myListShapes[0].in(), myListTools[0].in() ); + anObj = anOper->MakeHalfPartition( myListShapes[0].in(), myListTools[0].in(), + isDetectSelfInte ); res = true; } break; diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.h b/src/OperationGUI/OperationGUI_PartitionDlg.h index dcfdf80da..2363b4d9a 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.h +++ b/src/OperationGUI/OperationGUI_PartitionDlg.h @@ -28,6 +28,7 @@ #include class DlgRef_2Sel1List2Check; +class QCheckBox; //================================================================================= // class : OperationGUI_PartitionDlg @@ -64,6 +65,7 @@ private: GEOM::ListOfGO myListKeepInside; DlgRef_2Sel1List2Check* GroupPoints; + QCheckBox *mySelfInte; private slots: void ClickOnOk(); -- 2.30.2