Salome HOME
0022178: [CEA 798] Sewing: Make option NonManifoldMode available in GEOM
authorskv <skv@opencascade.com>
Fri, 24 May 2013 10:40:50 +0000 (10:40 +0000)
committerskv <skv@opencascade.com>
Fri, 24 May 2013 10:40:50 +0000 (10:40 +0000)
13 files changed:
doc/salome/gui/GEOM/input/sewing_operation.doc
idl/GEOM_Gen.idl
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMImpl/GEOMImpl_HealingDriver.cxx
src/GEOMImpl/GEOMImpl_HealingDriver.hxx
src/GEOMImpl/GEOMImpl_IHealingOperations.cxx
src/GEOMImpl/GEOMImpl_IHealingOperations.hxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOM_I/GEOM_IHealingOperations_i.cc
src/GEOM_I/GEOM_IHealingOperations_i.hh
src/GEOM_SWIG/geomBuilder.py
src/RepairGUI/RepairGUI_SewingDlg.cxx
src/RepairGUI/RepairGUI_SewingDlg.h

index 9ee5eff67b5c5cac0fb7be2fdb59bf7c305fed1f..2af3989cd3bf1071ab5e52dd311f016c41850932 100644 (file)
@@ -8,9 +8,9 @@
 
 \n The \b Result will be a \b GEOM_Object. 
 
-\n <b>TUI Command:</b> <em>geompy.MakeSewing(ListOfShape, Precision),</em>
+\n <b>TUI Command:</b> <em>geompy.MakeSewing(ListOfShape, Precision, AllowNonManifold=False),</em>
  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
 
index 874f7d6069fa9dc0f720b9b728d49dfef39494d0..7a93994ac2f53bcf293c4d4f7b9de9e16ea44489 100644 (file)
@@ -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.
index b35e64ea1362e0529aa34e7af14cf3e61cb6023e..17b30d6e77176c6240a2d237ec64ed69455cd36c 100644 (file)
@@ -1674,6 +1674,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_SEWING_TITLE</source>
         <translation>Topological sewing</translation>
     </message>
+    <message>
+        <source>GEOM_ALLOW_NON_MANIFOLD</source>
+        <translation>Allow Non Manifold</translation>
+    </message>
     <message>
         <source>GEOM_SHAPE</source>
         <translation>Shape</translation>
index 75107e9eac86d98660127c49f7311ec7c6708c0d..d77e25f2059455a41fd589c9726518f0442dfb8b 100644 (file)
@@ -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)
index c13caf83b35234cbe60e59806a10e1134c2ebf47..d7579661231b342edd8719b87f2861d2fcd5d9e3 100644 (file)
@@ -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;
index 8d47e67b384a3a22c19a0f21d5c2002dd136913d..98f56bf19f4b88f89d3c6c86fa94d92015bbc646 100644 (file)
@@ -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;
index b946861ee4852e772380c118556cce8be774c577..37f1b90f42d23f22b423b7dd43f43a4476a4808f 100644 (file)
@@ -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,
index 105de5d2a2418612655f453a70a01c7933cac254..886b613a8fb94bd8a61f9bb36f9869cd8c9b9e2b 100755 (executable)
 #define CHANGE_ORIENTATION 8
 #define LIMIT_TOLERANCE    9
 #define FUSE_COLLINEAR_EDGES 10
+#define SEWING_NON_MANIFOLD  11
 
 #define BASIC_FILLING 1
 
index 449e733026d2931fee3e3c453814ede970bdd93c..195b4a3a0384d92c6feedc55166ecb841ed16938 100644 (file)
@@ -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();
 
index 53a498a8972d8798466dd3526f4b75199b747212..45a85df6291dd8c5ea35c96cbb8077a785019a89 100644 (file)
@@ -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,
index 249379505cc5a1a824527a6fc11f07990dbb2f84..e99209521a5602659e764c191cd577affd966c46 100644 (file)
@@ -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")
index df32581354150aa574ecf1f84733e697d1ee2310..96777b35733ea41687d9687a70cf156361341262 100644 (file)
@@ -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 )
     {
index 1e40fd7c4b3a6a1dad24b9924531c873674c4981..9fc41014c8e3367f70adfc8cc3a9f7ca3d4d3074 100644 (file)
@@ -30,6 +30,7 @@
 #include <GEOMBase_Skeleton.h>
 
 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;