sub-shapes will not be performed. In this case the Partition algorithm
will work faster, but the result might differ from the default behavior.
+<b>Detect Self-intersections</b> 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.
+
<b>Advanced option:</b>
\ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
<em>geompy.MakePartition(ListOfShapes, ListOfTools, ListOfKeepInside,
ListOfRemoveInside, Limit, RemoveWebs, ListOfMaterials,
-KeepNonlimitShapes)</em>
+KeepNonlimitShapes, checkSelfInte)</em>
<b>TUI Command (without sub-shapes intersection):</b>
<em>geompy.MakePartitionNonSelfIntersectedShape(ListOfShapes,
ListOfTools, ListOfKeepInside, ListOfRemoveInside, Limit, RemoveWebs,
-ListOfMaterials, KeepNonlimitShapes)</em>
+ListOfMaterials, KeepNonlimitShapes, checkSelfInte)</em>
Here,
- \em ListOfShapes is a list of shapes to be intersected
- \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.
<em>geompy.MakeHalfPartition(Shape, Plane)</em>, 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.
<b>Examples:</b>
* 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.
*/
in short theLimit,
in boolean theRemoveWebs,
in ListOfLong theMaterials,
- in short theKeepNonlimitShapes);
+ in short theKeepNonlimitShapes,
+ in boolean IsCheckSelfInte);
/*!
* \brief Perform partition operation.
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:
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;
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);
// Limit
aCI.SetLimit(theLimit);
aCI.SetKeepNonlimitShapes(theKeepNonlimitShapes);
+ aCI.SetCheckSelfIntersection(IsCheckSelfInte);
// Materials
if (theRemoveWebs) {
pd << ", " << theMaterials->Value(i);
}
}
- pd << "], " << theKeepNonlimitShapes <<")";
+ pd << "], " << theKeepNonlimitShapes;
+
+ if (IsCheckSelfInte) {
+ pd << ", True";
+ }
+
+ pd << ")";
SetErrorCode(OK);
return aPartition;
*/
//=============================================================================
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);
aCI.SetShape(aRef1);
aCI.SetPlane(aRef2);
+ aCI.SetCheckSelfIntersection(IsCheckSelfInte);
//Compute the Partition value
try {
}
//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;
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:
#define PART_ARG_PLANE 8
#define PART_ARG_KEEP_NONLIMIT_SHAPES 9
+#define BOOL_ARG_CHECK_SELF_INTERSECTION 10
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); }
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;
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <Standard_NullObject.hxx>
+#include <StdFail_NotDone.hxx>
#include <Precision.hxx>
#include <gp_Pnt.hxx>
+#include <BOPAlgo_CheckerSI.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPCol_ListOfShape.hxx>
+#include <BOPDS_DS.hxx>
+
+// 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
}
}
+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 :
GEOMImpl_IPartition aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
+ const Standard_Boolean isCheckSelfInte = aCI.GetCheckSelfIntersection();
TopoDS_Shape aShape;
GEOMAlgo_Splitter PS;
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);
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;
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;
{
CORBA::Short theLimit,
CORBA::Boolean theRemoveWebs,
const GEOM::ListOfLong& theMaterials,
- CORBA::Short theKeepNonlimitShapes)
+ CORBA::Short theKeepNonlimitShapes,
+ CORBA::Boolean IsCheckSelfInte)
{
GEOM::GEOM_Object_var aGEOMObject;
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();
CORBA::Short theLimit,
CORBA::Boolean theRemoveWebs,
const GEOM::ListOfLong& theMaterials,
- CORBA::Short theKeepNonlimitShapes)
+ CORBA::Short theKeepNonlimitShapes,
+ CORBA::Boolean IsCheckSelfInte)
{
GEOM::GEOM_Object_var aGEOMObject;
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();
//=============================================================================
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;
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();
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,
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(); }
myBoolOp->MakePartition(aListImplS->GetList(), aListImplT->GetList(),
aListImplKI->GetList(), aListImplRI->GetList(),
theLimit, theRemoveWebs, aListImplM->GetList(),
- theKeepNonlimitShapes);
+ theKeepNonlimitShapes, false);
endService( " GEOM_Superv_i::MakePartition" );
return anObj;
}
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;
}
# 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.
# @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.
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.
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
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
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
# \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.
"""
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.
# @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.
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
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 );
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();
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" ) );
{
bool res = false;
GEOM::GEOM_Object_var anObj;
+ bool isDetectSelfInte = mySelfInte->isChecked();
GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation());
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;
#include <GEOMBase_Skeleton.h>
class DlgRef_2Sel1List2Check;
+class QCheckBox;
//=================================================================================
// class : OperationGUI_PartitionDlg
GEOM::ListOfGO myListKeepInside;
DlgRef_2Sel1List2Check* GroupPoints;
+ QCheckBox *mySelfInte;
private slots:
void ClickOnOk();