From: skv Date: Fri, 24 May 2013 10:40:50 +0000 (+0000) Subject: 0022178: [CEA 798] Sewing: Make option NonManifoldMode available in GEOM X-Git-Tag: BR_hydro_v_0_3_1~219 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ca3e17352aba851df996d7e45aabf6f154a2b89f;p=modules%2Fgeom.git 0022178: [CEA 798] Sewing: Make option NonManifoldMode available in GEOM --- diff --git a/doc/salome/gui/GEOM/input/sewing_operation.doc b/doc/salome/gui/GEOM/input/sewing_operation.doc index 9ee5eff67..2af3989cd 100644 --- a/doc/salome/gui/GEOM/input/sewing_operation.doc +++ b/doc/salome/gui/GEOM/input/sewing_operation.doc @@ -8,9 +8,9 @@ \n The \b Result will be a \b GEOM_Object. -\n TUI Command: geompy.MakeSewing(ListOfShape, Precision), +\n TUI Command: geompy.MakeSewing(ListOfShape, Precision, AllowNonManifold=False), where \em ListOfShape is list of faces or shells to be sewed, \em Precision is a -precision for sewing. +precision for sewing, \em AllowNonManifold flag that allows non-manifold sewing. \image html repair6.png diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 874f7d606..7a93994ac 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -3323,6 +3323,14 @@ module GEOM */ GEOM_Object Sew (in GEOM_Object theObject, in double theTolerance); + /*! + * Sewing of the given object. Allows non-manifold sewing. + * \param theObject Shape to be processed. + * \param theTolerance Required tolerance value. + * \return New GEOM_Object, containing processed shape. + */ + GEOM_Object SewAllowNonManifold(in GEOM_Object theObject, in double theTolerance); + /*! * \brief Addition of a point to a given edge object. * \param theObject Shape to be processed. diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index b35e64ea1..17b30d6e7 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -1674,6 +1674,10 @@ Please, select face, shell or solid and try again GEOM_SEWING_TITLE Topological sewing + + GEOM_ALLOW_NON_MANIFOLD + Allow Non Manifold + GEOM_SHAPE Shape diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx index 75107e9ea..d77e25f20 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx @@ -133,7 +133,10 @@ Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const RemoveHoles(&HI, anOriginalShape, aShape); break; case SEWING: - Sew(&HI, anOriginalShape, aShape); + Sew(&HI, anOriginalShape, aShape, false); + break; + case SEWING_NON_MANIFOLD: + Sew(&HI, anOriginalShape, aShape, true); break; case DIVIDE_EDGE: AddPointOnEdge(&HI, anOriginalShape, aShape); @@ -418,12 +421,16 @@ Standard_Boolean GEOMImpl_HealingDriver::RemoveHoles (GEOMImpl_IHealing* theHI, //======================================================================= Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI, const TopoDS_Shape& theOriginalShape, - TopoDS_Shape& theOutShape) const + TopoDS_Shape& theOutShape, + Standard_Boolean isAllowNonManifold) const { Standard_Real aTol = theHI->GetTolerance(); ShHealOper_Sewing aHealer (theOriginalShape, aTol); + // Set non-manifold mode. + aHealer.SetNonManifoldMode(isAllowNonManifold); + Standard_Boolean aResult = aHealer.Perform(); if (aResult) diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.hxx b/src/GEOMImpl/GEOMImpl_HealingDriver.hxx index c13caf83b..d75796612 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.hxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.hxx @@ -171,7 +171,7 @@ private: Standard_Boolean CloseContour ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; Standard_Boolean RemoveIntWires( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; Standard_Boolean RemoveHoles ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; - Standard_Boolean Sew ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; + Standard_Boolean Sew ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape&, Standard_Boolean ) const; Standard_Boolean AddPointOnEdge( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; Standard_Boolean ChangeOrientation( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; void LimitTolerance( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index 8d47e67b3..98f56bf19 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -596,7 +596,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) */ //============================================================================= Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject, - double theTolerance) + double theTolerance, + bool isAllowNonManifold) { // set error code, check parameters SetErrorCode(KO); @@ -611,7 +612,9 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); //Add the function - aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING); + int aFunctionType = (isAllowNonManifold ? SEWING_NON_MANIFOLD : SEWING); + + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), aFunctionType); if (aFunction.IsNull()) return NULL; @@ -642,8 +645,15 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj } //Make a Python command - GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew(" - << theObject << ", " << theTolerance << ")"; + GEOM::TPythonDump pd(aFunction); + + pd << aNewObject << " = geompy.Sew(" << theObject << ", " << theTolerance; + + if (isAllowNonManifold) { + pd << ", true"; + } + + pd << ")"; SetErrorCode(OK); return aNewObject; diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx index b946861ee..37f1b90f4 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx @@ -71,7 +71,8 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations { const Handle(TColStd_HArray1OfInteger)& theWires); Standard_EXPORT Handle(GEOM_Object) Sew( Handle(GEOM_Object) theObject, - double theTolerance ); + double theTolerance, + bool isAllowNonManifold); Standard_EXPORT Handle(GEOM_Object) DivideEdge( Handle(GEOM_Object) theObject, int theIndex, diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 105de5d2a..886b613a8 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -302,6 +302,7 @@ #define CHANGE_ORIENTATION 8 #define LIMIT_TOLERANCE 9 #define FUSE_COLLINEAR_EDGES 10 +#define SEWING_NON_MANIFOLD 11 #define BASIC_FILLING 1 diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.cc b/src/GEOM_I/GEOM_IHealingOperations_i.cc index 449e73302..195b4a3a0 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.cc +++ b/src/GEOM_I/GEOM_IHealingOperations_i.cc @@ -356,7 +356,38 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theO // Perform Handle(GEOM_Object) aNewObject = - GetOperations()->Sew( anObject, theTolerance ); + GetOperations()->Sew( anObject, theTolerance, false ); + if (!GetOperations()->IsDone() || aNewObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(aNewObject); +} + +//============================================================================= +/*! + * SewAllowNonManifold + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::SewAllowNonManifold (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theTolerance) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if (theTolerance < 0) + return aGEOMObject._retn(); + + // Get the object itself + Handle(GEOM_Object) anObject = GetObjectImpl(theObject); + if (anObject.IsNull()) + return aGEOMObject._retn(); + + // Perform + Handle(GEOM_Object) aNewObject = + GetOperations()->Sew( anObject, theTolerance, true ); if (!GetOperations()->IsDone() || aNewObject.IsNull()) return aGEOMObject._retn(); diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.hh b/src/GEOM_I/GEOM_IHealingOperations_i.hh index 53a498a89..45a85df62 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.hh +++ b/src/GEOM_I/GEOM_IHealingOperations_i.hh @@ -75,6 +75,9 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i : GEOM::GEOM_Object_ptr Sew (GEOM::GEOM_Object_ptr theObject, CORBA::Double theTolerance); + GEOM::GEOM_Object_ptr SewAllowNonManifold (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theTolerance); + GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject, CORBA::Short theIndex, CORBA::Double theValue, diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 249379505..e99209521 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -5912,6 +5912,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Sewing of some shapes into single shape. # @param ListShape Shapes to be processed. # @param theTolerance Required tolerance value. + # @param AllowNonManifold Flag that allows non-manifold sewing. # @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. @@ -5919,13 +5920,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_sewing "Example" - def MakeSewing(self, ListShape, theTolerance, theName=None): + def MakeSewing(self, ListShape, theTolerance, AllowNonManifold=False, theName=None): """ Sewing of some shapes into single shape. Parameters: ListShape Shapes to be processed. theTolerance Required tolerance value. + AllowNonManifold Flag that allows non-manifold sewing. 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. @@ -5936,24 +5938,26 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # Example: see GEOM_TestHealing.py comp = self.MakeCompound(ListShape) # note: auto-publishing is done in self.Sew() - anObj = self.Sew(comp, theTolerance, theName) + anObj = self.Sew(comp, theTolerance, AllowNonManifold, theName) return anObj ## Sewing of the given object. # @param theObject Shape to be processed. # @param theTolerance Required tolerance value. + # @param AllowNonManifold Flag that allows non-manifold sewing. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # # @return New GEOM.GEOM_Object, containing processed shape. - def Sew(self, theObject, theTolerance, theName=None): + def Sew(self, theObject, theTolerance, AllowNonManifold=False, theName=None): """ Sewing of the given object. Parameters: theObject Shape to be processed. theTolerance Required tolerance value. + AllowNonManifold Flag that allows non-manifold sewing. 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. @@ -5963,7 +5967,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ # Example: see MakeSewing() above theTolerance,Parameters = ParseParameters(theTolerance) - anObj = self.HealOp.Sew(theObject, theTolerance) + if AllowNonManifold: + anObj = self.HealOp.SewAllowNonManifold(theObject, theTolerance) + else: + anObj = self.HealOp.Sew(theObject, theTolerance) RaiseIfFailed("Sew", self.HealOp) anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "sewed") diff --git a/src/RepairGUI/RepairGUI_SewingDlg.cxx b/src/RepairGUI/RepairGUI_SewingDlg.cxx index df3258135..96777b357 100644 --- a/src/RepairGUI/RepairGUI_SewingDlg.cxx +++ b/src/RepairGUI/RepairGUI_SewingDlg.cxx @@ -76,15 +76,17 @@ RepairGUI_SewingDlg::RepairGUI_SewingDlg( GeometryGUI* theGeometryGUI, QWidget* QGridLayout* aLay = new QGridLayout( GroupPoints->Box ); aLay->setMargin( 0 ); aLay->setSpacing( 6 ); + myAllowNonManifoldChk = new QCheckBox (tr("GEOM_ALLOW_NON_MANIFOLD"), GroupPoints->Box); myTolEdt = new SalomeApp_DoubleSpinBox( GroupPoints->Box ); initSpinBox( myTolEdt, 0.0, 100.0, DEFAULT_TOLERANCE_VALUE, "len_tol_precision" ); myTolEdt->setValue( DEFAULT_TOLERANCE_VALUE ); QLabel* aLbl1 = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints->Box ); myFreeBoundBtn = new QPushButton( tr( "GEOM_DETECT" ) + QString( " [%1]" ).arg( tr( "GEOM_FREE_BOUNDARIES" ) ), GroupPoints->Box ); - aLay->addWidget( aLbl1, 0, 0 ); - aLay->addWidget( myTolEdt, 0, 1 ); - aLay->addWidget( myFreeBoundBtn, 1, 0, 1, 2 ); + aLay->addWidget( myAllowNonManifoldChk, 0, 0 ); + aLay->addWidget( aLbl1, 1, 0 ); + aLay->addWidget( myTolEdt, 1, 1 ); + aLay->addWidget( myFreeBoundBtn, 2, 0, 1, 2 ); QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); @@ -301,7 +303,14 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects ) myClosed = -1; } else { - GEOM::GEOM_Object_var anObj = anOper->Sew( myObject, myTolEdt->value() ); + GEOM::GEOM_Object_var anObj; + + if (myAllowNonManifoldChk->isChecked()) { + anObj = anOper->SewAllowNonManifold( myObject, myTolEdt->value() ); + } else { + anObj = anOper->Sew( myObject, myTolEdt->value() ); + } + aResult = !anObj->_is_nil(); if ( aResult ) { diff --git a/src/RepairGUI/RepairGUI_SewingDlg.h b/src/RepairGUI/RepairGUI_SewingDlg.h index 1e40fd7c4..9fc41014c 100644 --- a/src/RepairGUI/RepairGUI_SewingDlg.h +++ b/src/RepairGUI/RepairGUI_SewingDlg.h @@ -30,6 +30,7 @@ #include class DlgRef_1SelExt; +class QCheckBox; class SalomeApp_DoubleSpinBox; class QPushButton; @@ -60,6 +61,7 @@ private: GEOM::GEOM_Object_var myObject; DlgRef_1SelExt* GroupPoints; + QCheckBox* myAllowNonManifoldChk; SalomeApp_DoubleSpinBox* myTolEdt; QPushButton* myFreeBoundBtn;