From: mbs Date: Fri, 8 Mar 2024 22:36:58 +0000 (+0000) Subject: [bos #40619][CEA] Add Fuzzy parameter to partition and boolean operators X-Git-Tag: V9_13_0a1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Ftlpr%2F16%2Fhead;p=modules%2Fgeom.git [bos #40619][CEA] Add Fuzzy parameter to partition and boolean operators --- diff --git a/doc/salome/gui/GEOM/images/bool1.png b/doc/salome/gui/GEOM/images/bool1.png index c259c3fcc..0a54bc2b3 100644 Binary files a/doc/salome/gui/GEOM/images/bool1.png and b/doc/salome/gui/GEOM/images/bool1.png differ diff --git a/doc/salome/gui/GEOM/images/bool2.png b/doc/salome/gui/GEOM/images/bool2.png index c19607ee0..f3c67be5b 100644 Binary files a/doc/salome/gui/GEOM/images/bool2.png and b/doc/salome/gui/GEOM/images/bool2.png differ diff --git a/doc/salome/gui/GEOM/images/bool3.png b/doc/salome/gui/GEOM/images/bool3.png index 57f52be6c..e9e71ad0d 100644 Binary files a/doc/salome/gui/GEOM/images/bool3.png and b/doc/salome/gui/GEOM/images/bool3.png differ diff --git a/doc/salome/gui/GEOM/images/neo-section.png b/doc/salome/gui/GEOM/images/neo-section.png index 137bdebf5..83eadf084 100644 Binary files a/doc/salome/gui/GEOM/images/neo-section.png and b/doc/salome/gui/GEOM/images/neo-section.png differ diff --git a/doc/salome/gui/GEOM/input/common_operation.doc b/doc/salome/gui/GEOM/input/common_operation.doc index 804fcfafb..bd58a15e2 100644 --- a/doc/salome/gui/GEOM/input/common_operation.doc +++ b/doc/salome/gui/GEOM/input/common_operation.doc @@ -12,6 +12,8 @@ In this dialog: - Input or accept the default \b Name of the resulting shape. - Click the arrow button and select in the Object Browser or in the Viewer the Objects the common part which of should be found. - Activate the corresponding check-box if you wish to Detect Self-intersections +- Activate the corresponding check-box if you wish to use a fuzzy parameter . + If activated, you can define the fuzzy tolerance in the fuzzy parameter input box. - Activate \ref restore_presentation_parameters_page "Advanced options" if required. - Press "Apply" or "Apply & Close" button to get the result (GEOM_Object). @@ -26,15 +28,15 @@ In this dialog: This operation can be performed using a TUI Command: -geompy.MakeCommonList(theShapesList, checkSelfInte) +geompy.MakeCommonList(theShapesList, checkSelfInte, name, fuzzyParam) -Arguments: Name + a list of shapes + an optional flag for self-intersection check. +Arguments: a list of shapes + an optional flag for self-intersection check + an optional name + an optional fuzzy parameter. There is also a special TUI Command for the Common operation on two shapes : -geompy.MakeCommon(s1, s2, checkSelfInte) +geompy.MakeCommon(s1, s2, checkSelfInte, name, fuzzyParam) -Arguments: Name + 2 shapes + an optional flag for self-intersection check. +Arguments: 2 shapes + an optional flag for self-intersection check + an optional name + an optional fuzzy parameter. Example: diff --git a/doc/salome/gui/GEOM/input/cut_operation.doc b/doc/salome/gui/GEOM/input/cut_operation.doc index 30235d6de..bbe25cccc 100644 --- a/doc/salome/gui/GEOM/input/cut_operation.doc +++ b/doc/salome/gui/GEOM/input/cut_operation.doc @@ -13,6 +13,8 @@ In this dialog: - Click the arrow button and select in the Object Browser or in the Viewer the Main Object, which will be cut by tool objects. - Select the Tool objects, which will cut the main object. - Activate the corresponding check-box if you wish to Detect Self-intersections . +- Activate the corresponding check-box if you wish to use a fuzzy parameter . + If activated, you can define the fuzzy tolerance in the fuzzy parameter input box. - Activate \ref restore_presentation_parameters_page "Advanced options" if required. - Press "Apply" or "Apply & Close" button to get the result (GEOM_Object). @@ -25,15 +27,17 @@ In this dialog: This operation can be performed using a TUI Command: -geompy.MakeCutList(theMainShape, theShapesList, checkSelfInte) +geompy.MakeCutList(theMainShape, theShapesList, checkSelfInte, name, fuzzyParam) -Arguments: Name + a main shape + a list of other shapes + an optional flag for self-intersection check. +Arguments: a main shape + a list of other shapes + an optional flag for self-intersection +check + an optional name + an optional fuzzy parameter. There is also a special TUI Command: for the Cut operation on two shapes (object and tool) : -geompy.MakeCut(s1, s2, checkSelfInte) +geompy.MakeCut(s1, s2, checkSelfInte, name, fuzzyParam) -Arguments: Name + the object + the tool + an optional flag for self-intersection check. +Arguments: the object + the tool + an optional flag for self-intersection check + an +optional name + an optional fuzzy parameter. Example: diff --git a/doc/salome/gui/GEOM/input/fuse_operation.doc b/doc/salome/gui/GEOM/input/fuse_operation.doc index e0a31b777..b01449428 100644 --- a/doc/salome/gui/GEOM/input/fuse_operation.doc +++ b/doc/salome/gui/GEOM/input/fuse_operation.doc @@ -13,6 +13,8 @@ In this dialog: - Click the arrow button and select in the Object Browser or in the Viewer the Objects to be fused. - Activate the corresponding check-box if you wish to Detect Self-intersections . - Activate the corresponding check-box if you wish to remove extra edges . +- Activate the corresponding check-box if you wish to use a fuzzy parameter . + If activated, you can define the fuzzy tolerance in the fuzzy parameter input box. - Activate \ref restore_presentation_parameters_page "Advanced options" if required. - Press "Apply" or "Apply & Close" button to get the result (GEOM_Object). @@ -25,17 +27,17 @@ In this dialog: This operation can be performed using a TUI Command: -geompy.MakeFuseList(theShapesList, checkSelfInte, rmExtraEdges) +geompy.MakeFuseList(theShapesList, checkSelfInte, rmExtraEdges, name, fuzzyParam) -Arguments: Name + a list of shapes + an optional flag for -self-intersection check + an optional flag to remove extra edges. +Arguments: a list of shapes + an optional flag for self-intersection +check + an optional flag to remove extra edges + an optional name + an optional fuzzy parameter. There is also a special TUI Command for \b Fuse operation on two shapes : -geompy.MakeFuse(s1, s2, checkSelfInte, rmExtraEdges) +geompy.MakeFuse(s1, s2, checkSelfInte, rmExtraEdges, name, fuzzyParam) -Arguments: Name + 2 shapes + an optional flag for self-intersection -check + an optional flag to remove extra edges. +Arguments: 2 shapes + an optional flag for self-intersection +check + an optional flag to remove extra edges + an optional name + an optional fuzzy parameter. Example: diff --git a/doc/salome/gui/GEOM/input/partition.doc b/doc/salome/gui/GEOM/input/partition.doc index e6e2db8b9..ad73a3cc7 100644 --- a/doc/salome/gui/GEOM/input/partition.doc +++ b/doc/salome/gui/GEOM/input/partition.doc @@ -62,6 +62,10 @@ If self-intersection is detected, the operation is aborted. all self-intersections please use \ref check_self_intersections_page "Detect Self-intersection tool". +Use Fuzzy Parameter check box is used to enable the usage of the fuzzy tolerance +inside the partition algorithm. The fuzzy tolerance itself can be given in the Fuzzy +Parameter input box. + - Activate \ref restore_presentation_parameters_page "Advanced options" if required. \note Partition is a complex operation, so its result of it depends @@ -74,13 +78,13 @@ If self-intersection is detected, the operation is aborted. geompy.MakePartition(ListOfShapes, ListOfTools, ListOfKeepInside, ListOfRemoveInside, Limit, RemoveWebs, ListOfMaterials, -KeepNonlimitShapes) +KeepNonlimitShapes, fuzzyParam) TUI Command (without sub-shapes intersection): geompy.MakePartitionNonSelfIntersectedShape(ListOfShapes, ListOfTools, ListOfKeepInside, ListOfRemoveInside, Limit, RemoveWebs, -ListOfMaterials, KeepNonlimitShapes, checkSelfInte) +ListOfMaterials, KeepNonlimitShapes, checkSelfInte, fuzzyParam) Here, - \em ListOfShapes is a list of shapes to be intersected @@ -91,6 +95,8 @@ Here, shapes of low dimension (than \em Limit) in the result. - \em checkSelfInte is a flag that indicates if the arguments should be checked for self-intersection prior to the operation. +- \em fuzzyParam is the used fuzzy tolerance inside the partition algorithm. +This tolerance is ignored, if this parameter is omitted or not positive. - Other parameters are obsolete and kept only for compatibility with previous versions of SALOME. diff --git a/doc/salome/gui/GEOM/input/section_operation.doc b/doc/salome/gui/GEOM/input/section_operation.doc index 0832ea886..cc0cf6bc4 100644 --- a/doc/salome/gui/GEOM/input/section_operation.doc +++ b/doc/salome/gui/GEOM/input/section_operation.doc @@ -1,6 +1,6 @@ /*! -\page section_opeartion_page Intersection +\page section_operation_page Intersection \b Intersection operation creates a vertex, an edge, a wire or a compound of them representing the intersection of two shapes. @@ -13,6 +13,8 @@ In this dialog: - Input or accept the default \b Name of the resulting shape. - Click the arrow button and select in the Object Browser or in the Viewer the intersecting Objects. - Activate the corresponding check-box if you wish to Detect Self-intersections. If a self-intersection detected the operation fails. +- Activate the corresponding check-box if you wish to use a fuzzy parameter . + If activated, you can define the fuzzy tolerance in the fuzzy parameter input box. - Activate \ref restore_presentation_parameters_page "Advanced options" if required. - Press "Apply" or "Apply & Close" button to get the result (VERTEX, EDGE, WIRE or COMPOUND). @@ -26,9 +28,9 @@ of the GUI module's documentation. This operation can be performed using a TUI Command: -geompy.MakeSection(s1, s2, checkSelfInte) +geompy.MakeSection(s1, s2, checkSelfInte, name, fuzzyParam) -Arguments: Name + 2 shapes + an optional flag for self-intersection check. +Arguments: 2 shapes + an optional flag for self-intersection check + an optional name + an optional fuzzy parameter. Example: diff --git a/doc/salome/gui/GEOM/input/using_boolean_operations.doc b/doc/salome/gui/GEOM/input/using_boolean_operations.doc index f5e8f0509..63351b45d 100644 --- a/doc/salome/gui/GEOM/input/using_boolean_operations.doc +++ b/doc/salome/gui/GEOM/input/using_boolean_operations.doc @@ -17,7 +17,7 @@ complex geometrical objects (2D & 3D elements): of a list of objects into an independent object.
  • \subpage cut_operation_page "Cut" - cuts one shape with a list of others.
  • -
  • \subpage section_opeartion_page "Intersection" - performs an intersection between two shapes.
  • +
  • \subpage section_operation_page "Intersection" - performs an intersection between two shapes.
  • You can use advanced TUI commands performing these operations diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 531f97cd9..b177871d9 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -3397,6 +3397,190 @@ module GEOM */ GEOM_Object MakeHalfPartition (in GEOM_Object theShape, in GEOM_Object thePlane); + + /*! + * [bos#40619] [CEA] Add Fuzzy parameter to partition and boolean operators + * New interface methods were added to support a fuzzy parameter in + * all boolean and partition operations: + * - MakeBooleanWithFuzzy + * - MakeFuseWithFuzzy + * - MakeFuseListWithFuzzy + * - MakeCommonListWithFuzzy + * - MakeCutListWithFuzzy + * - MakePartitionWithFuzzy + * - MakePartitionNonSelfIntersectedShapeWithFuzzy + * - MakeHalfPartitionWithFuzzy + */ + + /*! + * \brief Perform one of boolean operations on two given shapes. + * \param theShape1 First argument for boolean operation. + * \param theShape2 Second argument for boolean operation. + * \param theOperation Indicates the operation to be done: + * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section. + * \param IsCheckSelfInte If TRUE, perform check self intersection + * of arguments before an operation. + * \param theFuzzyParam The fuzzy tolerance to be used in the boolean + * algorithm, if the value is positive. + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeBooleanWithFuzzy (in GEOM_Object theShape1, + in GEOM_Object theShape2, + in long theOperation, + in boolean IsCheckSelfInte, + in double theFuzzyParam); + /*! + * \brief Perform fusion boolean operation on two given shapes. + * \param theShape1 First argument for fuse operation. + * \param theShape2 Second argument for fuse operation. + * \param IsCheckSelfInte If TRUE, perform check self intersection + * of arguments before an operation. + * \param IsRmExtraEdges If TRUE, perform removal of extra edges + * during an operation. + * \param theFuzzyParam The fuzzy tolerance to be used in the boolean + * algorithm, if the value is positive. + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeFuseWithFuzzy (in GEOM_Object theShape1, + in GEOM_Object theShape2, + in boolean IsCheckSelfInte, + in boolean IsRmExtraEdges, + in double theFuzzyParam); + + /*! + * \brief Perform fusion boolean operation on list of objects. + * \param theShapes Shapes to be fused. + * \param IsCheckSelfInte If TRUE, perform check self intersection + * of arguments before an operation. + * \param IsRmExtraEdges If TRUE, perform removal of extra edges + * during an operation. + * \param theFuzzyParam The fuzzy tolerance to be used in the boolean + * algorithm, if the value is positive. + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeFuseListWithFuzzy (in ListOfGO theShapes, + in boolean IsCheckSelfInte, + in boolean IsRmExtraEdges, + in double theFuzzyParam); + + /*! + * \brief Perform common boolean operation on list of objects. + * \param theShapes Shapes for common operation. + * \param IsCheckSelfInte If TRUE, perform check self intersection + * of arguments before an operation. + * \param theFuzzyParam The fuzzy tolerance to be used in the boolean + * algorithm, if the value is positive. + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeCommonListWithFuzzy (in ListOfGO theShapes, + in boolean IsCheckSelfInte, + in double theFuzzyParam); + + /*! + * \brief Perform cutting of list of objects from theMainShape. + * \param theMainShape the object for cut operation. + * \param theShapes Shapes to be cut from theMainShape (tools). + * \param IsCheckSelfInte If TRUE, perform check self intersection + * of arguments before an operation. + * \param theFuzzyParam The fuzzy tolerance to be used in the boolean + * algorithm, if the value is positive. + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeCutListWithFuzzy (in GEOM_Object theMainShape, + in ListOfGO theShapes, + in boolean IsCheckSelfInte, + in double theFuzzyParam); + + /*! + * \brief Perform partition operation. + * + * \param theShapes Shapes to be intersected. + * \param theTools Shapes to intersect theShapes. + * \note Each compound from ListShapes and ListTools will be exploded in order + * to avoid possible intersection between shapes from this compound. + * \param theLimit Type of resulting shapes (corresponding to TopAbs_ShapeEnum). + * \param theKeepNonlimitShapes: if this parameter == 0, then only shapes of + * target type (equal to Limit) are kept in the result, + * else standalone shapes of lower dimension + * are kept also (if they exist). + * \param theFuzzyParam The fuzzy tolerance to be used in the partition + * algorithm, if the value is positive. + * + * After implementation new version of PartitionAlgo (October 2006) + * other parameters are ignored by current functionality. They are kept + * in this function only for supporting old versions. + * Ignored parameters: + * \param theKeepInside Shapes, outside which the results will be deleted. + * Each shape from theKeepInside must belong to theShapes also. + * \param theRemoveInside Shapes, inside which the results will be deleted. + * 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 sense, only if theRemoveWebs is TRUE. + * + * \return New GEOM_Object, containing the result shapes. + */ + GEOM_Object MakePartitionWithFuzzy (in ListOfGO theShapes, + in ListOfGO theTools, + in ListOfGO theKeepInside, + in ListOfGO theRemoveInside, + in short theLimit, + in boolean theRemoveWebs, + in ListOfLong theMaterials, + in short theKeepNonlimitShapes, + in double theFuzzyParam); + + /*! + * \brief Perform partition operation. + * + * This method may be useful if it is needed to make a partition for + * a compound containing nonintersected shapes. Performance will be better + * since intersection between shapes from compound is not performed. + * + * Description of all parameters as in previous method MakePartition(). + * One additional parameter is provided: + * \param IsCheckSelfInte If TRUE, perform check self intersection + * of arguments before an operation. + * \param theFuzzyParam The fuzzy tolerance to be used in the partition + * algorithm, if the value is positive. + * + * \note Passed compounds (via ListShapes or via ListTools) + * have to consist of nonintersecting shapes. + * + * \return New GEOM_Object, containing the result shapes. + */ + GEOM_Object MakePartitionNonSelfIntersectedShapeWithFuzzy (in ListOfGO theShapes, + in ListOfGO theTools, + in ListOfGO theKeepInside, + in ListOfGO theRemoveInside, + in short theLimit, + in boolean theRemoveWebs, + in ListOfLong theMaterials, + in short theKeepNonlimitShapes, + in boolean IsCheckSelfInte, + in double theFuzzyParam); + + /*! + * \brief Perform partition of the Shape with the Plane + * \param theShape Shape to be intersected. + * \param thePlane Tool shape, to intersect theShape. + * \param theFuzzyParam The fuzzy tolerance to be used in the partition + * algorithm, if the value is positive. + * \return New GEOM_Object, containing the result shape. + * + * \note This operation is a shortcut to the more general \ref MakePartition + * operation, where \a theShape specifies single "object" (shape being partitioned) + * and \a thePlane specifies single "tool" (intersector shape). Other parameters of + * \ref MakePartition operation have default values: + * - \a theLimit: GEOM::SHAPE (shape limit corresponds to the type of \a theShape) + * - \a theKeepNonlimitShapes: 0 + * - \a theKeepInside, \a theRemoveInside, \a theRemoveWebs, + * \a theMaterials (obsolete parameters): empty + * + * \sa MakePartition, MakePartitionNonSelfIntersectedShape + */ + GEOM_Object MakeHalfPartitionWithFuzzy (in GEOM_Object theShape, + in GEOM_Object thePlane, + in double theFuzzyParam); }; // # GEOM_ICurvesOperations: diff --git a/src/BooleanGUI/BooleanGUI_Dialog.cxx b/src/BooleanGUI/BooleanGUI_Dialog.cxx index 073fc5d96..4a007557d 100644 --- a/src/BooleanGUI/BooleanGUI_Dialog.cxx +++ b/src/BooleanGUI/BooleanGUI_Dialog.cxx @@ -41,6 +41,9 @@ // Comment next line to enable preview in BOP dialog box #define NO_PREVIEW +#define DEFAULT_FUZZY_VALUE 1e-5 + + //================================================================================= // class : BooleanGUI_Dialog() // purpose : Constructs a BooleanGUI_Dialog which is a child of 'parent', with the @@ -78,7 +81,7 @@ BooleanGUI_Dialog::BooleanGUI_Dialog (const int theOperation, GeometryGUI* theGe image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SECTION"))); aTitle = tr("GEOM_SECTION"); aCaption = tr("GEOM_SECTION_TITLE"); - setHelpFileName("section_opeartion_page.html"); + setHelpFileName("section_operation_page.html"); break; } QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); @@ -130,9 +133,21 @@ BooleanGUI_Dialog::BooleanGUI_Dialog (const int theOperation, GeometryGUI* theGe myGroup->TextLabel4->hide(); myGroup->SpinBox_DX->hide(); myGroup->SpinBox_DY->hide(); - myGroup->CheckBox3->hide(); myGroup->CheckBox1->setText(tr("GEOM_CHECK_SELF_INTERSECTIONS")); + // Add all "fuzzy parameter" related widgets + myGroup->CheckBox3->setText(tr("GEOM_USE_FUZZY_PARAMETER")); + + myFuzzyLbl = new QLabel(myGroup->GroupBox1); + myFuzzyLbl->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + myFuzzyLbl->setText(tr("GEOM_FUZZY_PARAMETER")); + myGroup->gridLayout1->addWidget(myFuzzyLbl, 7, 0, 1, 2); + + myFuzzyEdt = new SalomeApp_DoubleSpinBox(myGroup->GroupBox1); + initSpinBox( myFuzzyEdt, 1.e-7, 10.0, DEFAULT_FUZZY_VALUE, "length_tol_precision" ); + myFuzzyEdt->setValue(DEFAULT_FUZZY_VALUE); + myGroup->gridLayout1->addWidget(myFuzzyEdt, 7, 2); + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); layout->setMargin(0); layout->setSpacing(6); layout->addWidget(myGroup); @@ -173,6 +188,11 @@ void BooleanGUI_Dialog::Init() myGroup->CheckBox2->setChecked(true); } + // Do not use Fuzzy parameter by default + myGroup->CheckBox3->setChecked(false); + myFuzzyLbl->setEnabled(false); + myFuzzyEdt->setEnabled(false); + myObject1.nullify(); reset(); @@ -186,6 +206,10 @@ void BooleanGUI_Dialog::Init() connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); } + if (!myGroup->CheckBox3->isHidden()) { + connect(myGroup->CheckBox3, SIGNAL(stateChanged(int)), this, SLOT(UseFuzzyChanged(int))); + } + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()), Qt::UniqueConnection); @@ -314,6 +338,21 @@ void BooleanGUI_Dialog::SelectionIntoArgument() processPreview(); } +//================================================================================= +// function : UseFuzzyChanged() +// purpose : This slot is called whenever the status of CheckButton3 has changed +//================================================================================= +void BooleanGUI_Dialog::UseFuzzyChanged(int state) +{ + QCheckBox* send = (QCheckBox*)sender(); + + if (send == myGroup->CheckBox3) { + bool isChecked = (state != Qt::Unchecked); + myFuzzyLbl->setEnabled(isChecked); + myFuzzyEdt->setEnabled(isChecked); + } +} + //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -417,6 +456,8 @@ bool BooleanGUI_Dialog::execute (ObjectList& objects) GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation()); const bool isCheckSelfInte = myGroup->CheckBox1->isChecked(); + const bool useFuzzyParam = myGroup->CheckBox3->isChecked(); + const double fuzzyValue = (useFuzzyParam ? myFuzzyEdt->value() : -1); GEOM::ListOfGO_var anObjects = new GEOM::ListOfGO(); anObjects->length( myObjects.count() ); @@ -427,24 +468,20 @@ bool BooleanGUI_Dialog::execute (ObjectList& objects) case BooleanGUI::FUSE: { const bool isRmExtraEdges = myGroup->CheckBox2->isChecked(); - - anObj = anOper->MakeFuseList - (anObjects, isCheckSelfInte, isRmExtraEdges); + anObj = anOper->MakeFuseListWithFuzzy(anObjects, isCheckSelfInte, isRmExtraEdges, fuzzyValue); } - break; + break; case BooleanGUI::COMMON: - anObj = anOper->MakeCommonList(anObjects, isCheckSelfInte); - break; - case BooleanGUI::CUT: - anObj = - anOper->MakeCutList(myObject1.get(), anObjects, isCheckSelfInte); - break; - case BooleanGUI::SECTION: - anObj = anOper->MakeBoolean - (myObject1.get(), anObjects[0], myOperation, isCheckSelfInte); - break; - default: - break; + anObj = anOper->MakeCommonListWithFuzzy(anObjects, isCheckSelfInte, fuzzyValue); + break; + case BooleanGUI::CUT: + anObj = anOper->MakeCutListWithFuzzy(myObject1.get(), anObjects, isCheckSelfInte, fuzzyValue); + break; + case BooleanGUI::SECTION: + anObj = anOper->MakeBooleanWithFuzzy(myObject1.get(), anObjects[0], myOperation, isCheckSelfInte, fuzzyValue); + break; + default: + break; } if (!anObj->_is_nil()) diff --git a/src/BooleanGUI/BooleanGUI_Dialog.h b/src/BooleanGUI/BooleanGUI_Dialog.h index dc7d66d73..71eb2667b 100644 --- a/src/BooleanGUI/BooleanGUI_Dialog.h +++ b/src/BooleanGUI/BooleanGUI_Dialog.h @@ -31,6 +31,8 @@ #include "GEOM_GenericObjPtr.h" class DlgRef_2Sel2Spin3Check; +class QLabel; +class SalomeApp_DoubleSpinBox; //================================================================================= // class : BooleanGUI_Dialog @@ -68,10 +70,13 @@ private: QList myObjects; DlgRef_2Sel2Spin3Check* myGroup; + QLabel* myFuzzyLbl; + SalomeApp_DoubleSpinBox* myFuzzyEdt; private slots: void ClickOnOk(); bool ClickOnApply(); + void UseFuzzyChanged(int state); void SetEditCurrentArgument(); void SelectionIntoArgument(); void ActivateThisDialog(); diff --git a/src/DlgRef/DlgRef_2Sel2Spin3Check_QTD.ui b/src/DlgRef/DlgRef_2Sel2Spin3Check_QTD.ui index 1d7620087..19442ef92 100644 --- a/src/DlgRef/DlgRef_2Sel2Spin3Check_QTD.ui +++ b/src/DlgRef/DlgRef_2Sel2Spin3Check_QTD.ui @@ -36,7 +36,7 @@ - + 9 diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index ba2b35507..41c3fa5de 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -427,6 +427,14 @@ Please, select face, shell or solid and try again GEOM_CHECK_SELF_INTERSECTIONS Detect Self-intersections + + GEOM_USE_FUZZY_PARAMETER + Use Fuzzy Parameter + + + GEOM_FUZZY_PARAMETER + Fuzzy Parameter + GEOM_FAST_CHECK_INTERSECTIONS Fast intersection diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index b61174223..6605a135e 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -427,6 +427,14 @@ Choisissez une face, une coque ou un solide et essayez de nouveau GEOM_CHECK_SELF_INTERSECTIONS Détecter les auto-intersections + + GEOM_USE_FUZZY_PARAMETER + Utiliser le paramètre flou + + + GEOM_FUZZY_PARAMETER + Paramètre flou + GEOM_FAST_CHECK_INTERSECTIONS Intersection rapide diff --git a/src/GEOMGUI/GEOM_msg_ja.ts b/src/GEOMGUI/GEOM_msg_ja.ts index a485d6a7d..46a0ea135 100644 --- a/src/GEOMGUI/GEOM_msg_ja.ts +++ b/src/GEOMGUI/GEOM_msg_ja.ts @@ -423,6 +423,14 @@ GEOM_CHECK_SELF_INTERSECTIONS 自己交差の検出 + + GEOM_USE_FUZZY_PARAMETER + ファジーパラメータを使用する + + + GEOM_FUZZY_PARAMETER + ファジーパラメータ + GEOM_FAST_CHECK_INTERSECTIONS クイック交点 diff --git a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx index d61ee7603..4e55b8220 100644 --- a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx @@ -123,6 +123,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(Handle(TFunction_Logbook)& log) Standard_Integer aType = aFunction->GetType(); const Standard_Boolean isCheckSelfInte = aCI.GetCheckSelfIntersection(); const Standard_Boolean isRmExtraEdges = aCI.GetRmExtraEdges(); + const Standard_Real aFuzzyParam = aCI.GetFuzzyParameter(); TopoDS_Shape aShape; @@ -165,7 +166,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(Handle(TFunction_Logbook)& log) TNaming_CopyShape::CopyTool(aShape1, aMapTShapes, aShapeCopy1); TNaming_CopyShape::CopyTool(aShape2, aMapTShapes, aShapeCopy2); - aShape = performOperation (aShapeCopy1, aShapeCopy2, aType); + aShape = performOperation (aShapeCopy1, aShapeCopy2, aType, aFuzzyParam); if (isRmExtraEdges) { aShape = RemoveExtraEdges(aShape); @@ -229,7 +230,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(Handle(TFunction_Logbook)& log) aList2.Append(aShape2); aCSI.SetArguments(aList2); aCSI.Perform(); - if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { + if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is self-intersected"); } } @@ -237,7 +238,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(Handle(TFunction_Logbook)& log) // Copy shape aShapeCopy.Nullify(); TNaming_CopyShape::CopyTool(aShape2, aMapTShapes, aShapeCopy); - aShape = performOperation (aShape, aShapeCopy, aSimpleType); + aShape = performOperation (aShape, aShapeCopy, aSimpleType, aFuzzyParam); if (isRmExtraEdges) { aShape = RemoveExtraEdges(aShape); @@ -270,7 +271,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(Handle(TFunction_Logbook)& log) aList1.Append(aShape); aCSI.SetArguments(aList1); aCSI.Perform(); - if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { + if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is self-intersected"); } } @@ -300,7 +301,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(Handle(TFunction_Logbook)& log) aList2.Append(aTool); aCSI.SetArguments(aList2); aCSI.Perform(); - if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { + if (aCSI.HasErrors() || aCSI.DS().Interferences().Extent() > 0) { StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is self-intersected"); } } @@ -308,7 +309,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(Handle(TFunction_Logbook)& log) // Copy shape aShapeCopy.Nullify(); TNaming_CopyShape::CopyTool(aTool, aMapTShapes, aShapeCopy); - aShape = performOperation (aShape, aShapeCopy, BOOLEAN_CUT); + aShape = performOperation (aShape, aShapeCopy, BOOLEAN_CUT, aFuzzyParam); if (aShape.IsNull()) { return 0; @@ -391,7 +392,8 @@ TopoDS_Shape GEOMImpl_BooleanDriver::makeCompoundShellFromFaces TopoDS_Shape GEOMImpl_BooleanDriver::performOperation (const TopoDS_Shape theShape1, const TopoDS_Shape theShape2, - const Standard_Integer theType)const + const Standard_Integer theType, + const Standard_Real theFuzzyParam) const { TopoDS_Shape aShape; @@ -414,7 +416,15 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation TopTools_ListIteratorOfListOfShape itSub2 (listShape2); for (; itSub2.More(); itSub2.Next()) { TopoDS_Shape aValue2 = itSub2.Value(); - BRepAlgoAPI_Common BO (aValue1, aValue2); + BRepAlgoAPI_Common BO; + TopTools_ListOfShape aArgShapes, aToolShapes; + aArgShapes.Append(aValue1); + aToolShapes.Append(aValue2); + BO.SetArguments(aArgShapes); + BO.SetTools(aToolShapes); + if (theFuzzyParam > 0) + BO.SetFuzzyValue(theFuzzyParam); + BO.Build(); if (!BO.IsDone()) { StdFail_NotDone::Raise("Common operation can not be performed on the given shapes"); } @@ -475,7 +485,15 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation TopTools_ListIteratorOfListOfShape itSub2 (listTools); for (; itSub2.More(); itSub2.Next()) { TopoDS_Shape aTool = itSub2.Value(); - BRepAlgoAPI_Cut BO (aCut, aTool); + BRepAlgoAPI_Cut BO; + TopTools_ListOfShape aArgShapes, aToolShapes; + aArgShapes.Append(aCut); + aToolShapes.Append(aTool); + BO.SetArguments(aArgShapes); + BO.SetTools(aToolShapes); + if (theFuzzyParam > 0) + BO.SetFuzzyValue(theFuzzyParam); + BO.Build(); if (!BO.IsDone()) { StdFail_NotDone::Raise("Cut operation can not be performed on the given shapes"); } @@ -537,7 +555,15 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation } // Perform - BRepAlgoAPI_Fuse BO (theShape1, theShape2); + BRepAlgoAPI_Fuse BO; + TopTools_ListOfShape aArgShapes, aToolShapes; + aArgShapes.Append(theShape1); + aToolShapes.Append(theShape2); + BO.SetArguments(aArgShapes); + BO.SetTools(aToolShapes); + if (theFuzzyParam > 0) + BO.SetFuzzyValue(theFuzzyParam); + BO.Build(); if (!BO.IsDone()) { StdFail_NotDone::Raise("Fuse operation can not be performed on the given shapes"); } @@ -566,6 +592,9 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation for (; itSub2.More(); itSub2.Next()) { TopoDS_Shape aValue2 = itSub2.Value(); BRepAlgoAPI_Section BO (aValue1, aValue2, Standard_False); + // Set the fuzzy parameter, if it is valid (negative value <=> do not use fuzzy tolerance) + if (theFuzzyParam > 0) + BO.SetFuzzyValue(theFuzzyParam); // Set approximation to have an attached 3D BSpline geometry to each edge, // where analytic curve is not possible. Without this flag in some cases // we obtain BSpline curve of degree 1 (C0), which is slowly @@ -652,6 +681,7 @@ GetCreationInformation(std::string& theOperationName, GEOMImpl_IBoolean aCI (function); Standard_Integer aType = function->GetType(); Standard_Boolean isCheckSelfInte = aCI.GetCheckSelfIntersection(); + Standard_Real aFuzzyParam = aCI.GetFuzzyParameter(); switch ( aType ) { case BOOLEAN_COMMON: @@ -700,6 +730,9 @@ GetCreationInformation(std::string& theOperationName, return false; } + if (aFuzzyParam > 0) + AddParam( theParams, "Fuzzy Parameter", aFuzzyParam ); + return true; } diff --git a/src/GEOMImpl/GEOMImpl_BooleanDriver.hxx b/src/GEOMImpl/GEOMImpl_BooleanDriver.hxx index 2b8efef4f..e9c412e5c 100644 --- a/src/GEOMImpl/GEOMImpl_BooleanDriver.hxx +++ b/src/GEOMImpl/GEOMImpl_BooleanDriver.hxx @@ -50,7 +50,8 @@ private: TopoDS_Shape performOperation(const TopoDS_Shape theShape1, const TopoDS_Shape theShape2, - const Standard_Integer theType) const; + const Standard_Integer theType, + const Standard_Real theFuzzyParam) const; TopoDS_Shape makeCompoundShellFromFaces(const TopoDS_Shape theShape) const; diff --git a/src/GEOMImpl/GEOMImpl_IBoolean.hxx b/src/GEOMImpl/GEOMImpl_IBoolean.hxx index bb1e4285c..c33c42a4a 100644 --- a/src/GEOMImpl/GEOMImpl_IBoolean.hxx +++ b/src/GEOMImpl/GEOMImpl_IBoolean.hxx @@ -30,6 +30,7 @@ #define BOOL_ARG_SHAPES 3 #define BOOL_ARG_CHECK_SELF_INTERSECTION 4 #define BOOL_ARG_RM_EXTRA_EDGES 5 +#define BOOL_ARG_FUZZY_PARAMETER 6 class GEOMImpl_IBoolean { @@ -45,6 +46,8 @@ class GEOMImpl_IBoolean { _func->SetInteger(BOOL_ARG_CHECK_SELF_INTERSECTION, theFlag ? 1 : 0); } void SetRmExtraEdges (Standard_Boolean theFlag) { _func->SetInteger(BOOL_ARG_RM_EXTRA_EDGES, theFlag ? 1 : 0); } + void SetFuzzyParameter (Standard_Real theValue) + { _func->SetReal(BOOL_ARG_FUZZY_PARAMETER, theValue); } Handle(GEOM_Function) GetShape1() { return _func->GetReference(BOOL_ARG_SHAPE1); } Handle(GEOM_Function) GetShape2() { return _func->GetReference(BOOL_ARG_SHAPE2); } @@ -54,6 +57,8 @@ class GEOMImpl_IBoolean { return (_func->GetInteger(BOOL_ARG_CHECK_SELF_INTERSECTION) != 0); } Standard_Boolean GetRmExtraEdges() { return (_func->GetInteger(BOOL_ARG_RM_EXTRA_EDGES) != 0); } + Standard_Real GetFuzzyParameter() + { return _func->GetReal(BOOL_ARG_FUZZY_PARAMETER); } private: diff --git a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx index 51c234f49..5e1abd28e 100644 --- a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx @@ -73,7 +73,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2, const Standard_Integer theOp, - const Standard_Boolean IsCheckSelfInte) + const Standard_Boolean IsCheckSelfInte, + const Standard_Real theFuzzyParam) { SetErrorCode(KO); @@ -109,6 +110,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean aCI.SetShape1(aRef1); aCI.SetShape2(aRef2); aCI.SetCheckSelfIntersection(IsCheckSelfInte); + aCI.SetFuzzyParameter(theFuzzyParam); //Compute the Boolean value try { @@ -137,6 +139,11 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean pd << ", True"; } + if (theFuzzyParam > 0) { + // Use named argument for the fuzzy parameter + pd << ", theFuzzyParam=" << theFuzzyParam; + } + pd << ")"; SetErrorCode(OK); @@ -152,7 +159,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuse (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2, const bool IsCheckSelfInte, - const bool IsRmExtraEdges) + const bool IsRmExtraEdges, + const Standard_Real theFuzzyParam) { SetErrorCode(KO); @@ -181,6 +189,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuse aCI.SetShape2(aRef2); aCI.SetCheckSelfIntersection(IsCheckSelfInte); aCI.SetRmExtraEdges(IsRmExtraEdges); + aCI.SetFuzzyParameter(theFuzzyParam); //Compute the Boolean value try { @@ -200,7 +209,12 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuse pd << aBool << " = geompy.MakeFuse("; pd << theShape1 << ", " << theShape2 << ", " - << IsCheckSelfInte << ", " << IsRmExtraEdges << ")"; + << IsCheckSelfInte << ", " << IsRmExtraEdges; + if (theFuzzyParam > 0) { + // Use named argument for the fuzzy parameter + pd << ", theFuzzyParam=" << theFuzzyParam; + } + pd << ")"; SetErrorCode(OK); return aBool; @@ -214,7 +228,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuse Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuseList (const Handle(TColStd_HSequenceOfTransient)& theShapes, const bool IsCheckSelfInte, - const bool IsRmExtraEdges) + const bool IsRmExtraEdges, + const Standard_Real theFuzzyParam) { SetErrorCode(KO); @@ -243,6 +258,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuseList aCI.SetShapes(aShapesSeq); aCI.SetCheckSelfIntersection(IsCheckSelfInte); aCI.SetRmExtraEdges(IsRmExtraEdges); + aCI.SetFuzzyParameter(theFuzzyParam); //Compute the Boolean value try { @@ -261,7 +277,12 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuseList GEOM::TPythonDump pd (aFunction); pd << aBool << " = geompy.MakeFuseList([" << aDescription.ToCString() << "], " - << IsCheckSelfInte << ", " << IsRmExtraEdges << ")"; + << IsCheckSelfInte << ", " << IsRmExtraEdges; + if (theFuzzyParam > 0) { + // Use named argument for the fuzzy parameter + pd << ", theFuzzyParam=" << theFuzzyParam; + } + pd << ")"; SetErrorCode(OK); return aBool; @@ -274,7 +295,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuseList //============================================================================= Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCommonList (const Handle(TColStd_HSequenceOfTransient)& theShapes, - const Standard_Boolean IsCheckSelfInte) + const Standard_Boolean IsCheckSelfInte, + const Standard_Real theFuzzyParam) { SetErrorCode(KO); @@ -302,6 +324,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCommonList aCI.SetShapes(aShapesSeq); aCI.SetCheckSelfIntersection(IsCheckSelfInte); + aCI.SetFuzzyParameter(theFuzzyParam); //Compute the Boolean value try { @@ -325,7 +348,10 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCommonList if (IsCheckSelfInte) { pd << ", True"; } - + if (theFuzzyParam > 0) { + // Use named argument for the fuzzy parameter + pd << ", theFuzzyParam=" << theFuzzyParam; + } pd << ")"; SetErrorCode(OK); @@ -340,7 +366,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCommonList Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCutList (Handle(GEOM_Object) theMainShape, const Handle(TColStd_HSequenceOfTransient)& theShapes, - const Standard_Boolean IsCheckSelfInte) + const Standard_Boolean IsCheckSelfInte, + const Standard_Real theFuzzyParam) { SetErrorCode(KO); @@ -372,6 +399,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCutList aCI.SetShape1(aMainRef); aCI.SetShapes(aShapesSeq); aCI.SetCheckSelfIntersection(IsCheckSelfInte); + aCI.SetFuzzyParameter(theFuzzyParam); //Compute the Boolean value try { @@ -396,6 +424,11 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCutList pd << ", True"; } + if (theFuzzyParam > 0) { + // Use named argument for the fuzzy parameter + pd << ", theFuzzyParam=" << theFuzzyParam; + } + pd << ")"; SetErrorCode(OK); @@ -417,7 +450,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition const Handle(TColStd_HArray1OfInteger)& theMaterials, const Standard_Integer theKeepNonlimitShapes, const Standard_Boolean thePerformSelfIntersections, - const Standard_Boolean IsCheckSelfInte) + const Standard_Boolean IsCheckSelfInte, + const Standard_Real theFuzzyParam) { SetErrorCode(KO); @@ -497,6 +531,9 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition } } + // Fuzzy parameter + aCI.SetFuzzyParameter(theFuzzyParam); + //Compute the Partition try { OCC_CATCH_SIGNALS; @@ -537,6 +574,11 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition if (IsCheckSelfInte && !thePerformSelfIntersections) { pd << ", True"; } + + if (theFuzzyParam > 0) { + // Use named argument for the fuzzy parameter + pd << ", theFuzzyParam=" << theFuzzyParam; + } pd << ")"; @@ -550,7 +592,9 @@ 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_Real theFuzzyParam) { SetErrorCode(KO); @@ -576,6 +620,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition aCI.SetShape(aRef1); aCI.SetPlane(aRef2); + aCI.SetFuzzyParameter(theFuzzyParam); //Compute the Partition value try { @@ -593,7 +638,12 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition //Make a Python command GEOM::TPythonDump pd (aFunction); pd << aPart << " = geompy.MakeHalfPartition(" - << theShape << ", " << thePlane << ")"; + << theShape << ", " << thePlane; + if (theFuzzyParam > 0) { + // Use named argument for the fuzzy parameter + pd << ", theFuzzyParam=" << theFuzzyParam; + } + pd << ")"; SetErrorCode(OK); return aPart; diff --git a/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx b/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx index d9c548cc5..01c30eab6 100644 --- a/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx @@ -40,27 +40,32 @@ class GEOMImpl_IBooleanOperations : public GEOM_IOperations { (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2, const Standard_Integer theOp, - const Standard_Boolean IsCheckSelfInte); + const Standard_Boolean IsCheckSelfInte, + const Standard_Real theFuzzyParam = -1.); Standard_EXPORT Handle(GEOM_Object) MakeFuse (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2, const bool IsCheckSelfInte, - const bool IsRmExtraEdges); + const bool IsRmExtraEdges, + const Standard_Real theFuzzyParam = -1.); Standard_EXPORT Handle(GEOM_Object) MakeFuseList (const Handle(TColStd_HSequenceOfTransient)& theShapes, const bool IsCheckSelfInte, - const bool IsRmExtraEdges); + const bool IsRmExtraEdges, + const Standard_Real theFuzzyParam = -1.); Standard_EXPORT Handle(GEOM_Object) MakeCommonList (const Handle(TColStd_HSequenceOfTransient)& theShapes, - const Standard_Boolean IsCheckSelfInte); + const Standard_Boolean IsCheckSelfInte, + const Standard_Real theFuzzyParam = -1.); Standard_EXPORT Handle(GEOM_Object) MakeCutList - (Handle(GEOM_Object) theMainShape, + (Handle(GEOM_Object) theMainShape, const Handle(TColStd_HSequenceOfTransient)& theShapes, - const Standard_Boolean IsCheckSelfInte); + const Standard_Boolean IsCheckSelfInte, + const Standard_Real theFuzzyParam = -1.); Standard_EXPORT Handle(GEOM_Object) MakePartition (const Handle(TColStd_HSequenceOfTransient)& theShapes, @@ -70,12 +75,14 @@ class GEOMImpl_IBooleanOperations : public GEOM_IOperations { const Standard_Integer theLimit, const Standard_Boolean theRemoveWebs, const Handle(TColStd_HArray1OfInteger)& theMaterials, - const Standard_Integer theKeepNonlimitShapes, - const Standard_Boolean thePerformSelfIntersections, - const Standard_Boolean IsCheckSelfInte); - - Standard_EXPORT Handle(GEOM_Object) MakeHalfPartition (Handle(GEOM_Object) theShape, - Handle(GEOM_Object) thePlane); + const Standard_Integer theKeepNonlimitShapes, + const Standard_Boolean thePerformSelfIntersections, + const Standard_Boolean IsCheckSelfInte, + const Standard_Real theFuzzyParam = -1.); + + Standard_EXPORT Handle(GEOM_Object) MakeHalfPartition (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) thePlane, + const Standard_Real theFuzzyParam = -1.); private: diff --git a/src/GEOMImpl/GEOMImpl_IPartition.hxx b/src/GEOMImpl/GEOMImpl_IPartition.hxx index 6975ea463..1b49e268c 100644 --- a/src/GEOMImpl/GEOMImpl_IPartition.hxx +++ b/src/GEOMImpl/GEOMImpl_IPartition.hxx @@ -40,6 +40,7 @@ #define PART_ARG_KEEP_NONLIMIT_SHAPES 9 #define PART_ARG_CHECK_SELF_INTERSECTION 10 +#define PART_ARG_FUZZY_PARAMETER 11 class GEOMImpl_IPartition { @@ -70,6 +71,9 @@ class GEOMImpl_IPartition void SetCheckSelfIntersection (Standard_Boolean theFlag) { _func->SetInteger(PART_ARG_CHECK_SELF_INTERSECTION, theFlag ? 1 : 0); } + void SetFuzzyParameter (Standard_Real theValue) + { _func->SetReal(PART_ARG_FUZZY_PARAMETER, theValue); } + int GetLimit() { return _func->GetInteger(PART_ARG_LIMIT); } int GetKeepNonlimitShapes() { return _func->GetInteger(PART_ARG_KEEP_NONLIMIT_SHAPES); } @@ -91,6 +95,9 @@ class GEOMImpl_IPartition Standard_Boolean GetCheckSelfIntersection() { return (_func->GetInteger(PART_ARG_CHECK_SELF_INTERSECTION) != 0); } + Standard_Real GetFuzzyParameter() + { return _func->GetReal(PART_ARG_FUZZY_PARAMETER); } + private: Handle(GEOM_Function) _func; diff --git a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx index c9d2f12f9..9bee2250f 100644 --- a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx @@ -125,6 +125,7 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(Handle(TFunction_Logbook)& lo GEOMImpl_IPartition aCI (aFunction); Standard_Integer aType = aFunction->GetType(); const Standard_Boolean isCheckSelfInte = aCI.GetCheckSelfIntersection(); + const Standard_Real aFuzzyParam = aCI.GetFuzzyParameter(); TopoDS_Shape aShape; GEOMAlgo_Splitter PS; @@ -311,6 +312,10 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(Handle(TFunction_Logbook)& lo PS.SetLimitMode(aCI.GetKeepNonlimitShapes()); PS.SetLimit((TopAbs_ShapeEnum)aCI.GetLimit()); + if (aFuzzyParam > 0) { + PS.SetFuzzyValue(aFuzzyParam); + } + // Set parallel processing mode (default is false) Standard_Boolean bRunParallel = Standard_True; PS.SetRunParallel(bRunParallel); @@ -406,6 +411,10 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(Handle(TFunction_Logbook)& lo PS.AddTool(aPlaneArg_copy); //PS.AddTool(aPlaneArg); + if (aFuzzyParam > 0) { + PS.SetFuzzyValue(aFuzzyParam); + } + //skl PS.Compute(); PS.Perform(); //PS.SetRemoveWebs(Standard_False); @@ -523,6 +532,7 @@ GetCreationInformation(std::string& theOperationName, GEOMImpl_IPartition aCI( function ); Standard_Integer aType = function->GetType(); + Standard_Real aFuzzyParam = aCI.GetFuzzyParameter(); theOperationName = "PARTITION"; @@ -557,6 +567,9 @@ GetCreationInformation(std::string& theOperationName, default: return false; } + + if (aFuzzyParam > 0) + AddParam( theParams, "Fuzzy Parameter", aFuzzyParam ); return true; } diff --git a/src/GEOM_I/GEOM_IBooleanOperations_i.cc b/src/GEOM_I/GEOM_IBooleanOperations_i.cc index 33c8f99ea..1fe76bd3f 100644 --- a/src/GEOM_I/GEOM_IBooleanOperations_i.cc +++ b/src/GEOM_I/GEOM_IBooleanOperations_i.cc @@ -66,6 +66,127 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean GEOM::GEOM_Object_ptr theShape2, CORBA::Long theOp, CORBA::Boolean IsCheckSelfInte) +{ + return MakeBooleanWithFuzzy(theShape1, theShape2, theOp, IsCheckSelfInte, -1.0); +} + +//============================================================================= +/*! + * MakeFuse + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuse + (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Boolean IsCheckSelfInte, + CORBA::Boolean IsRmExtraEdges) +{ + return MakeFuseWithFuzzy(theShape1, theShape2, IsCheckSelfInte, IsRmExtraEdges, -1.0); +} + +//============================================================================= +/*! + * MakeFuseList + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseList + (const GEOM::ListOfGO& theShapes, + CORBA::Boolean IsCheckSelfInte, + CORBA::Boolean IsRmExtraEdges) +{ + return MakeFuseListWithFuzzy(theShapes, IsCheckSelfInte, IsRmExtraEdges, -1.0); +} + +//============================================================================= +/*! + * MakeCommonList + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonList + (const GEOM::ListOfGO& theShapes, + CORBA::Boolean IsCheckSelfInte) +{ + return MakeCommonListWithFuzzy(theShapes, IsCheckSelfInte, -1.0); +} + +//============================================================================= +/*! + * MakeCutList + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutList + (GEOM::GEOM_Object_ptr theMainShape, + const GEOM::ListOfGO& theShapes, + CORBA::Boolean IsCheckSelfInte) +{ + return MakeCutListWithFuzzy(theMainShape, theShapes, IsCheckSelfInte, -1.0); +} + +//============================================================================= +/*! + * MakePartition + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition + (const GEOM::ListOfGO& theShapes, + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepIns, + const GEOM::ListOfGO& theRemoveIns, + CORBA::Short theLimit, + CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials, + CORBA::Short theKeepNonlimitShapes) +{ + return MakePartitionWithFuzzy(theShapes, theTools, theKeepIns, theRemoveIns, theLimit, + theRemoveWebs, theMaterials, theKeepNonlimitShapes, -1.0); +} + +//============================================================================= +/*! + * MakePartitionNonSelfIntersectedShape + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShape + (const GEOM::ListOfGO& theShapes, + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepIns, + const GEOM::ListOfGO& theRemoveIns, + CORBA::Short theLimit, + CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials, + CORBA::Short theKeepNonlimitShapes, + CORBA::Boolean IsCheckSelfInte) +{ + return MakePartitionNonSelfIntersectedShapeWithFuzzy(theShapes, theTools, theKeepIns, theRemoveIns, + theLimit, theRemoveWebs, theMaterials, + theKeepNonlimitShapes, IsCheckSelfInte, -1.0); +} + +//============================================================================= +/*! + * MakeHalfPartition + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition + (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePlane) +{ + return MakeHalfPartitionWithFuzzy(theShape, thePlane, -1.0); +} + + + +//============================================================================= +/*! + * MakeBooleanWithFuzzy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBooleanWithFuzzy + (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Long theOp, + CORBA::Boolean IsCheckSelfInte, + CORBA::Double theFuzzyParam) { GEOM::GEOM_Object_var aGEOMObject; @@ -80,7 +201,7 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean // Make Boolean Handle(::GEOM_Object) anObject = - GetOperations()->MakeBoolean(aSh1, aSh2, theOp, IsCheckSelfInte); + GetOperations()->MakeBoolean(aSh1, aSh2, theOp, IsCheckSelfInte, theFuzzyParam); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -89,14 +210,15 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean //============================================================================= /*! - * MakeFuse + * MakeFuseWithFuzzy */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuse +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseWithFuzzy (GEOM::GEOM_Object_ptr theShape1, GEOM::GEOM_Object_ptr theShape2, CORBA::Boolean IsCheckSelfInte, - CORBA::Boolean IsRmExtraEdges) + CORBA::Boolean IsRmExtraEdges, + CORBA::Double theFuzzyParam) { GEOM::GEOM_Object_var aGEOMObject; @@ -111,7 +233,7 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuse // Make Boolean Handle(::GEOM_Object) anObject = GetOperations()->MakeFuse - (aSh1, aSh2, IsCheckSelfInte, IsRmExtraEdges); + (aSh1, aSh2, IsCheckSelfInte, IsRmExtraEdges, theFuzzyParam); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -121,13 +243,14 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuse //============================================================================= /*! - * MakeFuseList + * MakeFuseListWithFuzzy */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseList +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseListWithFuzzy (const GEOM::ListOfGO& theShapes, CORBA::Boolean IsCheckSelfInte, - CORBA::Boolean IsRmExtraEdges) + CORBA::Boolean IsRmExtraEdges, + CORBA::Double theFuzzyParam) { GEOM::GEOM_Object_var aGEOMObject; @@ -143,7 +266,7 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseList // Make fusion Handle(::GEOM_Object) anObject = - GetOperations()->MakeFuseList(aShapes, IsCheckSelfInte, IsRmExtraEdges); + GetOperations()->MakeFuseList(aShapes, IsCheckSelfInte, IsRmExtraEdges, theFuzzyParam); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -153,12 +276,13 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseList //============================================================================= /*! - * MakeCommonList + * MakeCommonListWithFuzzy */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonList +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonListWithFuzzy (const GEOM::ListOfGO& theShapes, - CORBA::Boolean IsCheckSelfInte) + CORBA::Boolean IsCheckSelfInte, + CORBA::Double theFuzzyParam) { GEOM::GEOM_Object_var aGEOMObject; @@ -174,7 +298,7 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonList // Make fusion Handle(::GEOM_Object) anObject = - GetOperations()->MakeCommonList(aShapes, IsCheckSelfInte); + GetOperations()->MakeCommonList(aShapes, IsCheckSelfInte, theFuzzyParam); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -184,13 +308,14 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonList //============================================================================= /*! - * MakeCutList + * MakeCutListWithFuzzy */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutList +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutListWithFuzzy (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theShapes, - CORBA::Boolean IsCheckSelfInte) + CORBA::Boolean IsCheckSelfInte, + CORBA::Double theFuzzyParam) { GEOM::GEOM_Object_var aGEOMObject; @@ -212,7 +337,7 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutList // Make fusion Handle(::GEOM_Object) anObject = - GetOperations()->MakeCutList(aMainShape, aShapes, IsCheckSelfInte); + GetOperations()->MakeCutList(aMainShape, aShapes, IsCheckSelfInte, theFuzzyParam); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -222,10 +347,10 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutList //============================================================================= /*! - * MakePartition + * MakePartitionWithFuzzy */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionWithFuzzy (const GEOM::ListOfGO& theShapes, const GEOM::ListOfGO& theTools, const GEOM::ListOfGO& theKeepIns, @@ -233,7 +358,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::Double theFuzzyParam) { GEOM::GEOM_Object_var aGEOMObject; @@ -267,7 +393,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition theLimit, theRemoveWebs, aMaterials, theKeepNonlimitShapes, /*PerformSelfIntersections*/Standard_True, - /*IsCheckSelfInte*/Standard_False); + /*IsCheckSelfInte*/Standard_False, + theFuzzyParam); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -276,10 +403,10 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition //============================================================================= /*! - * MakePartitionNonSelfIntersectedShape + * MakePartitionNonSelfIntersectedShapeWithFuzzy */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShape +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShapeWithFuzzy (const GEOM::ListOfGO& theShapes, const GEOM::ListOfGO& theTools, const GEOM::ListOfGO& theKeepIns, @@ -288,7 +415,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersected CORBA::Boolean theRemoveWebs, const GEOM::ListOfLong& theMaterials, CORBA::Short theKeepNonlimitShapes, - CORBA::Boolean IsCheckSelfInte) + CORBA::Boolean IsCheckSelfInte, + CORBA::Double theFuzzyParam) { GEOM::GEOM_Object_var aGEOMObject; @@ -322,7 +450,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersected theLimit, theRemoveWebs, aMaterials, theKeepNonlimitShapes, /*PerformSelfIntersections*/Standard_False, - IsCheckSelfInte); + IsCheckSelfInte, + theFuzzyParam); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -331,12 +460,13 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersected //============================================================================= /*! - * MakeHalfPartition + * MakeHalfPartitionWithFuzzy */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartitionWithFuzzy (GEOM::GEOM_Object_ptr theShape, - GEOM::GEOM_Object_ptr thePlane) + GEOM::GEOM_Object_ptr thePlane, + CORBA::Double theFuzzyParam) { GEOM::GEOM_Object_var aGEOMObject; @@ -351,7 +481,7 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition // Make Half Partition Handle(::GEOM_Object) anObject = - GetOperations()->MakeHalfPartition(aSh, aPl); + GetOperations()->MakeHalfPartition(aSh, aPl, theFuzzyParam); 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 521640d7b..55b96af18 100644 --- a/src/GEOM_I/GEOM_IBooleanOperations_i.hh +++ b/src/GEOM_I/GEOM_IBooleanOperations_i.hh @@ -43,12 +43,12 @@ class GEOM_I_EXPORT GEOM_IBooleanOperations_i : ~GEOM_IBooleanOperations_i(); GEOM::GEOM_Object_ptr MakeBoolean (GEOM::GEOM_Object_ptr theShape1, - GEOM::GEOM_Object_ptr theShape2, - CORBA::Long theOp, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Long theOp, CORBA::Boolean IsCheckSelfInte); GEOM::GEOM_Object_ptr MakeFuse (GEOM::GEOM_Object_ptr theShape1, - GEOM::GEOM_Object_ptr theShape2, + GEOM::GEOM_Object_ptr theShape2, CORBA::Boolean IsCheckSelfInte, CORBA::Boolean IsRmExtraEdges); @@ -64,27 +64,79 @@ class GEOM_I_EXPORT GEOM_IBooleanOperations_i : CORBA::Boolean IsCheckSelfInte); GEOM::GEOM_Object_ptr MakePartition (const GEOM::ListOfGO& theShapes, - const GEOM::ListOfGO& theTools, - const GEOM::ListOfGO& theKeepInside, - const GEOM::ListOfGO& theRemoveInside, - CORBA::Short theLimit, - CORBA::Boolean theRemoveWebs, - const GEOM::ListOfLong& theMaterials, - CORBA::Short theKeepNonlimitShapes); + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepInside, + const GEOM::ListOfGO& theRemoveInside, + CORBA::Short theLimit, + CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials, + CORBA::Short theKeepNonlimitShapes); GEOM::GEOM_Object_ptr MakePartitionNonSelfIntersectedShape (const GEOM::ListOfGO& theShapes, - const GEOM::ListOfGO& theTools, - const GEOM::ListOfGO& theKeepInside, - const GEOM::ListOfGO& theRemoveInside, - CORBA::Short theLimit, - CORBA::Boolean theRemoveWebs, - const GEOM::ListOfLong& theMaterials, - CORBA::Short theKeepNonlimitShapes, + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepInside, + const GEOM::ListOfGO& theRemoveInside, + CORBA::Short theLimit, + CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials, + 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); + + // New interface methods with "Fuzzy parameter" support + + GEOM::GEOM_Object_ptr MakeBooleanWithFuzzy (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Long theOp, + CORBA::Boolean IsCheckSelfInte, + CORBA::Double theFuzzyParam); + + GEOM::GEOM_Object_ptr MakeFuseWithFuzzy (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Boolean IsCheckSelfInte, + CORBA::Boolean IsRmExtraEdges, + CORBA::Double theFuzzyParam); + + GEOM::GEOM_Object_ptr MakeFuseListWithFuzzy (const GEOM::ListOfGO& theShapes, + CORBA::Boolean IsCheckSelfInte, + CORBA::Boolean IsRmExtraEdges, + CORBA::Double theFuzzyParam); + + GEOM::GEOM_Object_ptr MakeCommonListWithFuzzy (const GEOM::ListOfGO& theShapes, + CORBA::Boolean IsCheckSelfInte, + CORBA::Double theFuzzyParam); + + GEOM::GEOM_Object_ptr MakeCutListWithFuzzy (GEOM::GEOM_Object_ptr theMainShape, + const GEOM::ListOfGO& theShapes, + CORBA::Boolean IsCheckSelfInte, + CORBA::Double theFuzzyParam); + + GEOM::GEOM_Object_ptr MakePartitionWithFuzzy (const GEOM::ListOfGO& theShapes, + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepInside, + const GEOM::ListOfGO& theRemoveInside, + CORBA::Short theLimit, + CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials, + CORBA::Short theKeepNonlimitShapes, + CORBA::Double theFuzzyParam); + + GEOM::GEOM_Object_ptr MakePartitionNonSelfIntersectedShapeWithFuzzy (const GEOM::ListOfGO& theShapes, + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepInside, + const GEOM::ListOfGO& theRemoveInside, + CORBA::Short theLimit, + CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials, + CORBA::Short theKeepNonlimitShapes, + CORBA::Boolean IsCheckSelfInte, + CORBA::Double theFuzzyParam); + + GEOM::GEOM_Object_ptr MakeHalfPartitionWithFuzzy (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePlane, + CORBA::Double theFuzzyParam); ::GEOMImpl_IBooleanOperations* GetOperations() { return (::GEOMImpl_IBooleanOperations*)GetImpl(); } diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 9ff29d8b8..d1fee65e2 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -7762,6 +7762,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @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. + # @param theFuzzyParam The fuzzy parameter to be used for the boolean + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the boolean operation. # # @note This algorithm doesn't find all types of self-intersections. # It is tuned to detect vertex/vertex, vertex/edge, edge/edge, @@ -7775,7 +7778,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # # @ref tui_fuse "Example" @ManageTransactions("BoolOp") - def MakeBoolean(self, theShape1, theShape2, theOperation, checkSelfInte=False, theName=None): + def MakeBoolean(self, theShape1, theShape2, theOperation, checkSelfInte=False, theName=None, theFuzzyParam=-1): """ Perform one of boolean operations on two given shapes. @@ -7790,6 +7793,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): 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. + theFuzzyParam The fuzzy parameter to be used for the boolean operation. + If the value is not positive, no fuzzy tolerance will be + considered for the boolean operation. Note: This algorithm doesn't find all types of self-intersections. @@ -7804,7 +7810,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestAll.py - anObj = self.BoolOp.MakeBoolean(theShape1, theShape2, theOperation, checkSelfInte) + anObj = self.BoolOp.MakeBooleanWithFuzzy(theShape1, theShape2, theOperation, checkSelfInte, theFuzzyParam) RaiseIfFailed("MakeBoolean", self.BoolOp) def_names = { 1: "common", 2: "cut", 3: "fuse", 4: "section" } self._autoPublish(anObj, theName, def_names[theOperation]) @@ -7818,6 +7824,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @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. + # @param theFuzzyParam The fuzzy parameter to be used for the boolean + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the boolean operation. # # @note This algorithm doesn't find all types of self-intersections. # It is tuned to detect vertex/vertex, vertex/edge, edge/edge, @@ -7831,7 +7840,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # # @ref tui_common "Example 1" # \n @ref swig_MakeCommon "Example 2" - def MakeCommon(self, theShape1, theShape2, checkSelfInte=False, theName=None): + def MakeCommon(self, theShape1, theShape2, checkSelfInte=False, theName=None, theFuzzyParam=-1): """ Perform Common boolean operation on two given shapes. @@ -7844,6 +7853,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): 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. + theFuzzyParam The fuzzy parameter to be used for the boolean operation. + If the value is not positive, no fuzzy tolerance will be + considered for the boolean operation. Note: This algorithm doesn't find all types of self-intersections. @@ -7859,7 +7871,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): """ # Example: see GEOM_TestOthers.py # note: auto-publishing is done in self.MakeBoolean() - return self.MakeBoolean(theShape1, theShape2, 1, checkSelfInte, theName) + return self.MakeBoolean(theShape1, theShape2, 1, checkSelfInte, theName, theFuzzyParam) ## Perform Cut boolean operation on two given shapes. # @param theShape1 First argument for boolean operation. @@ -7869,6 +7881,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @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. + # @param theFuzzyParam The fuzzy parameter to be used for the boolean + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the boolean operation. # # @note This algorithm doesn't find all types of self-intersections. # It is tuned to detect vertex/vertex, vertex/edge, edge/edge, @@ -7882,7 +7897,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # # @ref tui_cut "Example 1" # \n @ref swig_MakeCommon "Example 2" - def MakeCut(self, theShape1, theShape2, checkSelfInte=False, theName=None): + def MakeCut(self, theShape1, theShape2, checkSelfInte=False, theName=None, theFuzzyParam=-1): """ Perform Cut boolean operation on two given shapes. @@ -7895,6 +7910,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): 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. + theFuzzyParam The fuzzy parameter to be used for the boolean operation. + If the value is not positive, no fuzzy tolerance will be + considered for the boolean operation. Note: This algorithm doesn't find all types of self-intersections. @@ -7911,7 +7929,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): """ # Example: see GEOM_TestOthers.py # note: auto-publishing is done in self.MakeBoolean() - return self.MakeBoolean(theShape1, theShape2, 2, checkSelfInte, theName) + return self.MakeBoolean(theShape1, theShape2, 2, checkSelfInte, theName, theFuzzyParam) ## Perform Fuse boolean operation on two given shapes. # @param theShape1 First argument for boolean operation. @@ -7923,6 +7941,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @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. + # @param theFuzzyParam The fuzzy parameter to be used for the boolean + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the boolean operation. # # @note This algorithm doesn't find all types of self-intersections. # It is tuned to detect vertex/vertex, vertex/edge, edge/edge, @@ -7938,7 +7959,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # \n @ref swig_MakeCommon "Example 2" @ManageTransactions("BoolOp") def MakeFuse(self, theShape1, theShape2, checkSelfInte=False, - rmExtraEdges=False, theName=None): + rmExtraEdges=False, theName=None, theFuzzyParam=-1): """ Perform Fuse boolean operation on two given shapes. @@ -7953,6 +7974,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): 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. + theFuzzyParam The fuzzy parameter to be used for the boolean operation. + If the value is not positive, no fuzzy tolerance will be + considered for the boolean operation. Note: This algorithm doesn't find all types of self-intersections. @@ -7968,8 +7992,8 @@ class geomBuilder(GEOM._objref_GEOM_Gen): """ # Example: see GEOM_TestOthers.py - anObj = self.BoolOp.MakeFuse(theShape1, theShape2, - checkSelfInte, rmExtraEdges) + anObj = self.BoolOp.MakeFuseWithFuzzy(theShape1, theShape2, checkSelfInte, + rmExtraEdges, theFuzzyParam) RaiseIfFailed("MakeFuse", self.BoolOp) self._autoPublish(anObj, theName, "fuse") return anObj @@ -7983,11 +8007,14 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @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. + # @param theFuzzyParam The fuzzy parameter to be used for the boolean + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the boolean operation. # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_section "Example 1" # \n @ref swig_MakeCommon "Example 2" - def MakeSection(self, theShape1, theShape2, checkSelfInte=False, theName=None): + def MakeSection(self, theShape1, theShape2, checkSelfInte=False, theName=None, theFuzzyParam=-1): """ Perform Section boolean operation on two given shapes. @@ -8000,13 +8027,16 @@ class geomBuilder(GEOM._objref_GEOM_Gen): 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. + theFuzzyParam The fuzzy parameter to be used for the boolean operation. + If the value is not positive, no fuzzy tolerance will be + considered for the boolean operation. Returns: New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestOthers.py # note: auto-publishing is done in self.MakeBoolean() - return self.MakeBoolean(theShape1, theShape2, 4, checkSelfInte, theName) + return self.MakeBoolean(theShape1, theShape2, 4, checkSelfInte, theName, theFuzzyParam) ## Perform Fuse boolean operation on the list of shapes. # @param theShapesList Shapes to be fused. @@ -8017,6 +8047,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @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. + # @param theFuzzyParam The fuzzy parameter to be used for the boolean + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the boolean operation. # # @note This algorithm doesn't find all types of self-intersections. # It is tuned to detect vertex/vertex, vertex/edge, edge/edge, @@ -8032,7 +8065,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # \n @ref swig_MakeCommon "Example 2" @ManageTransactions("BoolOp") def MakeFuseList(self, theShapesList, checkSelfInte=False, - rmExtraEdges=False, theName=None): + rmExtraEdges=False, theName=None, theFuzzyParam=-1): """ Perform Fuse boolean operation on the list of shapes. @@ -8046,6 +8079,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): 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. + theFuzzyParam The fuzzy parameter to be used for the boolean operation. + If the value is not positive, no fuzzy tolerance will be + considered for the boolean operation. Note: This algorithm doesn't find all types of self-intersections. @@ -8061,8 +8097,8 @@ class geomBuilder(GEOM._objref_GEOM_Gen): """ # Example: see GEOM_TestOthers.py - anObj = self.BoolOp.MakeFuseList(theShapesList, checkSelfInte, - rmExtraEdges) + anObj = self.BoolOp.MakeFuseListWithFuzzy(theShapesList, checkSelfInte, + rmExtraEdges, theFuzzyParam) RaiseIfFailed("MakeFuseList", self.BoolOp) self._autoPublish(anObj, theName, "fuse") return anObj @@ -8074,6 +8110,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @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. + # @param theFuzzyParam The fuzzy parameter to be used for the boolean + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the boolean operation. # # @note This algorithm doesn't find all types of self-intersections. # It is tuned to detect vertex/vertex, vertex/edge, edge/edge, @@ -8088,7 +8127,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @ref tui_common "Example 1" # \n @ref swig_MakeCommon "Example 2" @ManageTransactions("BoolOp") - def MakeCommonList(self, theShapesList, checkSelfInte=False, theName=None): + def MakeCommonList(self, theShapesList, checkSelfInte=False, theName=None, theFuzzyParam=-1): """ Perform Common boolean operation on the list of shapes. @@ -8100,6 +8139,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): 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. + theFuzzyParam The fuzzy parameter to be used for the boolean operation. + If the value is not positive, no fuzzy tolerance will be + considered for the boolean operation. Note: This algorithm doesn't find all types of self-intersections. @@ -8115,7 +8157,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): """ # Example: see GEOM_TestOthers.py - anObj = self.BoolOp.MakeCommonList(theShapesList, checkSelfInte) + anObj = self.BoolOp.MakeCommonListWithFuzzy(theShapesList, checkSelfInte, theFuzzyParam) RaiseIfFailed("MakeCommonList", self.BoolOp) self._autoPublish(anObj, theName, "common") return anObj @@ -8128,6 +8170,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @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. + # @param theFuzzyParam The fuzzy parameter to be used for the boolean + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the boolean operation. # # @note This algorithm doesn't find all types of self-intersections. # It is tuned to detect vertex/vertex, vertex/edge, edge/edge, @@ -8142,7 +8187,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @ref tui_cut "Example 1" # \n @ref swig_MakeCommon "Example 2" @ManageTransactions("BoolOp") - def MakeCutList(self, theMainShape, theShapesList, checkSelfInte=False, theName=None): + def MakeCutList(self, theMainShape, theShapesList, checkSelfInte=False, theName=None, theFuzzyParam=-1): """ Perform Cut boolean operation on one object and the list of tools. @@ -8155,6 +8200,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): 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. + theFuzzyParam The fuzzy parameter to be used for the boolean operation. + If the value is not positive, no fuzzy tolerance will be + considered for the boolean operation. Note: This algorithm doesn't find all types of self-intersections. @@ -8170,7 +8218,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): """ # Example: see GEOM_TestOthers.py - anObj = self.BoolOp.MakeCutList(theMainShape, theShapesList, checkSelfInte) + anObj = self.BoolOp.MakeCutListWithFuzzy(theMainShape, theShapesList, checkSelfInte, theFuzzyParam) RaiseIfFailed("MakeCutList", self.BoolOp) self._autoPublish(anObj, theName, "cut") return anObj @@ -8191,10 +8239,12 @@ class geomBuilder(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 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. + # @param theFuzzyParam The fuzzy parameter to be used for the partition + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the partition operation. # # @note Each compound from ListShapes and ListTools will be exploded # in order to avoid possible intersection between shapes from this compound. @@ -8216,7 +8266,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): @ManageTransactions("BoolOp") def MakePartition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[], - KeepNonlimitShapes=0, theName=None): + KeepNonlimitShapes=0, theName=None, theFuzzyParam=-1): """ Perform partition operation. @@ -8261,10 +8311,10 @@ class geomBuilder(GEOM._objref_GEOM_Gen): for s in ListShapes: lim = min(lim, s.GetMaxShapeType()) Limit = EnumToLong(lim) pass - anObj = self.BoolOp.MakePartition(ListShapes, ListTools, - ListKeepInside, ListRemoveInside, - Limit, RemoveWebs, ListMaterials, - KeepNonlimitShapes); + anObj = self.BoolOp.MakePartitionWithFuzzy(ListShapes, ListTools, + ListKeepInside, ListRemoveInside, + Limit, RemoveWebs, ListMaterials, + KeepNonlimitShapes, theFuzzyParam) RaiseIfFailed("MakePartition", self.BoolOp) self._autoPublish(anObj, theName, "partition") return anObj @@ -8278,6 +8328,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # One additional parameter is provided: # @param checkSelfInte The flag that tells if the arguments should # be checked for self-intersection prior to the operation. + # @param theFuzzyParam The fuzzy parameter to be used for the partition + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the partition operation. # # @note This algorithm doesn't find all types of self-intersections. # It is tuned to detect vertex/vertex, vertex/edge, edge/edge, @@ -8298,7 +8351,8 @@ class geomBuilder(GEOM._objref_GEOM_Gen): ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[], KeepNonlimitShapes=0, - checkSelfInte=False, theName=None): + checkSelfInte=False, theName=None, + theFuzzyParam=-1): """ Perform partition operation. This method may be useful if it is needed to make a partition for @@ -8334,10 +8388,11 @@ class geomBuilder(GEOM._objref_GEOM_Gen): for s in ListShapes: lim = min(lim, s.GetMaxShapeType()) Limit = EnumToLong(lim) pass - anObj = self.BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools, - ListKeepInside, ListRemoveInside, - Limit, RemoveWebs, ListMaterials, - KeepNonlimitShapes, checkSelfInte); + anObj = self.BoolOp.MakePartitionNonSelfIntersectedShapeWithFuzzy(ListShapes, ListTools, + ListKeepInside, ListRemoveInside, + Limit, RemoveWebs, ListMaterials, + KeepNonlimitShapes, checkSelfInte, + theFuzzyParam) RaiseIfFailed("MakePartitionNonSelfIntersectedShape", self.BoolOp) self._autoPublish(anObj, theName, "partition") return anObj @@ -8348,7 +8403,7 @@ class geomBuilder(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, theName=None, theFuzzyParam=-1): """ See method geompy.MakePartition for more information. """ @@ -8357,7 +8412,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): anObj = self.MakePartition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit, RemoveWebs, ListMaterials, - KeepNonlimitShapes, theName); + KeepNonlimitShapes, theName, theFuzzyParam) return anObj ## Perform partition of the Shape with the Plane @@ -8366,6 +8421,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # @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. + # @param theFuzzyParam The fuzzy parameter to be used for the partition + # operation. If the value is not positive, no fuzzy tolerance will + # be considered for the partition operation. # # @return New GEOM.GEOM_Object, containing the result shape. # @@ -8388,7 +8446,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): # # @ref tui_partition "Example" @ManageTransactions("BoolOp") - def MakeHalfPartition(self, theShape, thePlane, theName=None): + def MakeHalfPartition(self, theShape, thePlane, theName=None, theFuzzyParam=-1): """ Perform partition of the Shape with the Plane @@ -8415,7 +8473,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen): Result = geompy.MakePartition([Object], [Plane]) """ # Example: see GEOM_TestAll.py - anObj = self.BoolOp.MakeHalfPartition(theShape, thePlane) + anObj = self.BoolOp.MakeHalfPartitionWithFuzzy(theShape, thePlane, theFuzzyParam) 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 69b6a3839..df00065f4 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -46,6 +46,9 @@ // Comment next line to enable preview in Partition dialog box #define NO_PREVIEW +#define DEFAULT_FUZZY_VALUE 1e-5 + + //================================================================================= // class : OperationGUI_PartitionDlg() // purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the @@ -91,6 +94,21 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU mySelfInte->setText(tr("GEOM_CHECK_SELF_INTERSECTIONS")); GroupPoints->gridLayout1->addWidget(mySelfInte, 5, 0, 1, 3); + // Add all "fuzzy parameter" related widgets + myFuzzyChk = new QCheckBox(GroupPoints->GroupBox1); + myFuzzyChk->setText(tr("GEOM_USE_FUZZY_PARAMETER")); + GroupPoints->gridLayout1->addWidget(myFuzzyChk, 6, 0, 1, 3); + + myFuzzyLbl = new QLabel(GroupPoints->GroupBox1); + myFuzzyLbl->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + myFuzzyLbl->setText(tr("GEOM_FUZZY_PARAMETER")); + GroupPoints->gridLayout1->addWidget(myFuzzyLbl, 7, 0, 1, 2); + + myFuzzyEdt = new SalomeApp_DoubleSpinBox(GroupPoints->GroupBox1); + initSpinBox( myFuzzyEdt, 1.e-7, 10.0, DEFAULT_FUZZY_VALUE, "length_tol_precision" ); + myFuzzyEdt->setValue(DEFAULT_FUZZY_VALUE); + GroupPoints->gridLayout1->addWidget(myFuzzyEdt, 7, 2); + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( GroupPoints ); @@ -148,6 +166,11 @@ void OperationGUI_PartitionDlg::Init() GroupPoints->CheckButton1->setChecked( false ); mySelfInte->setChecked(false); + // Do not use Fuzzy parameter by default + myFuzzyChk->setChecked(false); + myFuzzyLbl->setEnabled(false); + myFuzzyEdt->setEnabled(false); + mainFrame()->GroupBoxPublish->show(); /* signals and slots connections */ @@ -172,6 +195,8 @@ void OperationGUI_PartitionDlg::Init() connect( GroupPoints->CheckButton2, SIGNAL(toggled(bool)), mySelfInte, SLOT(setEnabled(bool)) ); connect( mySelfInte, SIGNAL(toggled(bool)), this, SLOT(processPreview()) ); + connect( myFuzzyChk, SIGNAL(stateChanged(int)), this, SLOT(UseFuzzyChanged(int))); + mySelfInte->setEnabled(GroupPoints->CheckButton2->isChecked()); initName( tr( "GEOM_PARTITION" ) ); @@ -189,12 +214,6 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); globalSelection(); - //myListShapes.length( 0 ); - //myListTools.length( 0 ); - //myListKeepInside.length( 0 ); // obsolete - //myListRemoveInside.length( 0 ); // obsolete - //myListMaterials.length( 0 ); // obsolete - switch ( constructorId ) { case 0: /*Full partition */ GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) ); @@ -268,6 +287,22 @@ bool OperationGUI_PartitionDlg::ClickOnApply() } +//================================================================================= +// function : UseFuzzyChanged() +// purpose : This slot is called whenever the status of CheckButton3 has changed +//================================================================================= +void OperationGUI_PartitionDlg::UseFuzzyChanged(int state) +{ + QCheckBox* send = (QCheckBox*)sender(); + + if (send == myFuzzyChk) { + bool isChecked = (state != Qt::Unchecked); + myFuzzyLbl->setEnabled(isChecked); + myFuzzyEdt->setEnabled(isChecked); + } +} + + //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case @@ -455,6 +490,9 @@ bool OperationGUI_PartitionDlg::execute (ObjectList& objects) GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation()); + bool useFuzzyParam = myFuzzyChk->isChecked(); + double aFuzzyParam = (useFuzzyParam ? myFuzzyEdt->value() : -1.0); + switch ( getConstructorId() ) { case 0: { @@ -464,19 +502,19 @@ bool OperationGUI_PartitionDlg::execute (ObjectList& objects) bool aNoSelfIntersection = GroupPoints->CheckButton2->isChecked(); anObj = aNoSelfIntersection ? - anOper->MakePartitionNonSelfIntersectedShape(myListShapes, myListTools, - myListKeepInside, myListRemoveInside, - aLimit, false, myListMaterials, aKeepNonlimitShapes, - isDetectSelfInte) : - anOper->MakePartition(myListShapes, myListTools, - myListKeepInside, myListRemoveInside, - aLimit, false, myListMaterials, aKeepNonlimitShapes); + anOper->MakePartitionNonSelfIntersectedShapeWithFuzzy(myListShapes, myListTools, + myListKeepInside, myListRemoveInside, + aLimit, false, myListMaterials, aKeepNonlimitShapes, + isDetectSelfInte, aFuzzyParam) : + anOper->MakePartitionWithFuzzy(myListShapes, myListTools, + myListKeepInside, myListRemoveInside, + aLimit, false, myListMaterials, aKeepNonlimitShapes, aFuzzyParam); res = true; } break; case 1: { - anObj = anOper->MakeHalfPartition(myListShapes[0].in(), myListTools[0].in()); + anObj = anOper->MakeHalfPartitionWithFuzzy(myListShapes[0].in(), myListTools[0].in(), aFuzzyParam); res = true; } break; @@ -522,13 +560,6 @@ void OperationGUI_PartitionDlg::restoreSubShapes( SALOMEDS::SObject_ptr theSObje //======================================================================= void OperationGUI_PartitionDlg::ComboTextChanged() { - //bool IsEnabled = GroupPoints->ComboBox1->currentItem() < 3; - //GroupPoints->LineEdit3->setEnabled(IsEnabled); - //GroupPoints->LineEdit4->setEnabled(IsEnabled); - //GroupPoints->TextLabel4->setEnabled(IsEnabled); - //GroupPoints->TextLabel5->setEnabled(IsEnabled); - //GroupPoints->PushButton3->setEnabled(IsEnabled); - //GroupPoints->PushButton4->setEnabled(IsEnabled); processPreview(); } diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.h b/src/OperationGUI/OperationGUI_PartitionDlg.h index cfa65f776..317dc68a4 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.h +++ b/src/OperationGUI/OperationGUI_PartitionDlg.h @@ -29,6 +29,8 @@ class DlgRef_2Sel1List2Check; class QCheckBox; +class QLabel; +class SalomeApp_DoubleSpinBox; //================================================================================= // class : OperationGUI_PartitionDlg @@ -66,11 +68,15 @@ private: GEOM::ListOfGO myListKeepInside; DlgRef_2Sel1List2Check* GroupPoints; - QCheckBox *mySelfInte; + QCheckBox* mySelfInte; + QCheckBox* myFuzzyChk; + QLabel* myFuzzyLbl; + SalomeApp_DoubleSpinBox* myFuzzyEdt; private slots: void ClickOnOk(); bool ClickOnApply(); + void UseFuzzyChanged(int state); void ActivateThisDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); diff --git a/test/test_boolean_fuzzy.py b/test/test_boolean_fuzzy.py new file mode 100644 index 000000000..737b8a287 --- /dev/null +++ b/test/test_boolean_fuzzy.py @@ -0,0 +1,146 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import salome +### +salome.salome_init() + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + +geompy = geomBuilder.New() + +import unittest + +def HasSameSubShapes( shape, expected_info ): + """ + Compare topology information about shape with expected data + param shape - shape to be checked + param expected_info - expected WhatIsInformation for the shape + return True, if number of shapes are equal - False, otherwise + """ + name = shape.GetName() + if name: + name = '"%s"' % name + what_is = geompy.WhatIs( shape ) + what_is_list = what_is.strip().split( "\n" ) + # Remove flat content + if what_is_list.count( " Flat content : " ): + wIndex = what_is_list.index( " Flat content : " ) + what_is_list = what_is_list[:( wIndex - len( what_is_list ) - 1 )] + got_info_dict = {} + for item in what_is_list: + pair = item.split( ":" ) + if len(pair)==2: + type = item.split( ":" )[0].strip() + value = item.split( ":" )[1].strip() + if type.find( "Number of sub-shapes" ) == -1: + got_info_dict[type] = value + if len( expected_info ) > len( got_info_dict ): + print( "ERROR!!! Got topology information about shape %s isn't complete..." % name ) + return False + for key in expected_info: + if key not in got_info_dict: + print( "ERROR!!! There is no information about number of " + key + "(s) in %s shape!!!" % name ) + return False + elif str( expected_info[key] ).find( str( got_info_dict[key] )) == -1 or len( str( expected_info[key] )) != len( str( got_info_dict[key] )): + print( "ERROR!!! The number of " + key + "(s) is incorrect in %s shape!!! ( " % name + str( got_info_dict[key] ) + " instead of " + str( expected_info[key] ) + " )" ) + return False + return True + + +class GEOMTestBooleanFuzzy(unittest.TestCase): + def testFuse(self): + Vertex_1 = geompy.MakeVertex(10, 0, 0) + Vertex_2 = geompy.MakeVertex(20, 10.0001, 10.0001) + Box_1 = geompy.MakeBoxDXDYDZ(10, 10, 10) + Box_2 = geompy.MakeBoxTwoPnt(Vertex_1, Vertex_2) + # Fuse without fuzzy parameter + Fuse_1 = geompy.MakeFuse(Box_1, Box_2, True, True) + WHAT_IS_1={"VERTEX":14, "EDGE":21, "WIRE":9, "FACE":9, "SHELL":1, "SOLID":1, "COMPSOLID":0, "COMPOUND":0, "SHAPE":55} + assert(HasSameSubShapes(Fuse_1, WHAT_IS_1)) + # Fuse with fuzzy parameter + Fuse_2 = geompy.MakeFuse(Box_1, Box_2, True, True, None, 1.e-4) + WHAT_IS_2={"VERTEX":11, "EDGE":17, "WIRE":8, "FACE":8, "SHELL":1, "SOLID":1, "COMPSOLID":0, "COMPOUND":0, "SHAPE":46} + assert(HasSameSubShapes(Fuse_2, WHAT_IS_2)) + + def testCommon(self): + Vertex_1 = geompy.MakeVertex(0, 9.999995, 0) + Sphere_1 = geompy.MakeSphereR(5) + Sphere_2 = geompy.MakeSpherePntR(Vertex_1, 5) + # Common without fuzzy parameter + Common_1 = geompy.MakeCommon(Sphere_1, Sphere_2, True) + WHAT_IS_1={"VERTEX":1, "EDGE":1, "WIRE":2, "FACE":2, "SHELL":1, "SOLID":1, "COMPSOLID":0, "COMPOUND":0, "SHAPE":8} + assert(HasSameSubShapes(Common_1, WHAT_IS_1)) + # Common with fuzzy parameter + Common_2 = geompy.MakeCommon(Sphere_1, Sphere_2, True, None, 1.e-5) + WHAT_IS_2={"VERTEX":0, "EDGE":0, "WIRE":0, "FACE":0, "SHELL":0, "SOLID":0, "COMPSOLID":0, "COMPOUND":1, "SHAPE":1} + assert(HasSameSubShapes(Common_2, WHAT_IS_2)) + + def testCut(self): + OX = geompy.MakeVectorDXDYDZ(1, 0, 0) + Vertex_1 = geompy.MakeVertex(5.e-5, 5, 5) + Box_1 = geompy.MakeBoxDXDYDZ(10, 10, 10) + Cylinder_1 = geompy.MakeCylinder(Vertex_1, OX, 6, 13) + # Cut with low fuzzy parameter + Cut_1 = geompy.MakeCut(Box_1, Cylinder_1, True, None, 1.e-5) + WHAT_IS_1={"VERTEX":24, "EDGE":36, "WIRE":14, "FACE":14, "SHELL":1, "SOLID":1, "COMPSOLID":0, "COMPOUND":0, "SHAPE":90} + assert(HasSameSubShapes(Cut_1, WHAT_IS_1)) + # Cut with high fuzzy parameter + Cut_2 = geompy.MakeCut(Box_1, Cylinder_1, True, None, 5.e-5) + WHAT_IS_2={"VERTEX":24, "EDGE":36, "WIRE":20, "FACE":20, "SHELL":4, "SOLID":4, "COMPSOLID":0, "COMPOUND":1, "SHAPE":109} + assert(HasSameSubShapes(Cut_2, WHAT_IS_2)) + + def testBoolean(self): + Vertex_1 = geompy.MakeVertex(0, 9.999995, 0) + Sphere_1 = geompy.MakeSphereR(5) + Sphere_2 = geompy.MakeSpherePntR(Vertex_1, 5) + # Common without fuzzy parameter + Common_1 = geompy.MakeBoolean(Sphere_1, Sphere_2, 1, True) + WHAT_IS_1={"VERTEX":1, "EDGE":1, "WIRE":2, "FACE":2, "SHELL":1, "SOLID":1, "COMPSOLID":0, "COMPOUND":0, "SHAPE":8} + assert(HasSameSubShapes(Common_1, WHAT_IS_1)) + # Common with fuzzy parameter + Common_2 = geompy.MakeBoolean(Sphere_1, Sphere_2, 1, True, None, 1.e-5) + WHAT_IS_2={"VERTEX":0, "EDGE":0, "WIRE":0, "FACE":0, "SHELL":0, "SOLID":0, "COMPSOLID":0, "COMPOUND":1, "SHAPE":1} + assert(HasSameSubShapes(Common_2, WHAT_IS_2)) + + def testPartition(self): + Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) + Cylinder_1 = geompy.MakeCylinderRH(100, 300) + Box_2 = geompy.MakeBoxDXDYDZ(200, 200, 200) + Box_translated_slightly_inside = geompy.MakeTranslation(Box_2, 0, -199.9999, 0) + Box_translated_slightly_outside = geompy.MakeTranslation(Box_2, 0, -200.0001, 0) + Partitition_small_intersection = geompy.MakePartition([Box_1, Cylinder_1, Box_translated_slightly_inside]) + WHAT_IS_1={"VERTEX":25, "EDGE":49, "WIRE":32, "FACE":32, "SHELL":7, "SOLID":7, "COMPSOLID":0, "COMPOUND":1, "SHAPE":153} + assert(HasSameSubShapes(Partitition_small_intersection, WHAT_IS_1)) + Partitition_small_intersection_fixed_by_fuzzy = geompy.MakePartition([Box_1, Cylinder_1, Box_translated_slightly_inside], theFuzzyParam=0.0001) + WHAT_IS_2={"VERTEX":19, "EDGE":36, "WIRE":23, "FACE":23, "SHELL":5, "SOLID":5, "COMPSOLID":0, "COMPOUND":1, "SHAPE":112} + assert(HasSameSubShapes(Partitition_small_intersection_fixed_by_fuzzy, WHAT_IS_2)) + Partitition_small_gap = geompy.MakePartition([Box_1, Cylinder_1, Box_translated_slightly_outside]) + WHAT_IS_3={"VERTEX":25, "EDGE":44, "WIRE":25, "FACE":25, "SHELL":5, "SOLID":5, "COMPSOLID":0, "COMPOUND":1, "SHAPE":130} + assert(HasSameSubShapes(Partitition_small_gap, WHAT_IS_3)) + Partitition_small_gap_fixed_by_fuzzy = geompy.MakePartition([Box_1, Cylinder_1, Box_translated_slightly_inside], theFuzzyParam=0.0001) + WHAT_IS_4={"VERTEX":19, "EDGE":36, "WIRE":23, "FACE":23, "SHELL":5, "SOLID":5, "COMPSOLID":0, "COMPOUND":1, "SHAPE":112} + assert(HasSameSubShapes(Partitition_small_gap_fixed_by_fuzzy, WHAT_IS_4)) + +if __name__ == '__main__': + unittest.main() diff --git a/test/tests.set b/test/tests.set index 15aa6d2b7..5e264b447 100644 --- a/test/tests.set +++ b/test/tests.set @@ -30,5 +30,6 @@ IF(${OpenCASCADE_VERSION}.${OpenCASCADE_SP_VERSION} VERSION_GREATER "7.5.3.3") test_kind_of_shape.py test_proximity_edge_edge.py test_proximity_face_face.py + test_boolean_fuzzy.py ) ENDIF()