]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
22749: [EDF] Improvement of Remove Internal Faces operation
authoreap <eap@opencascade.com>
Thu, 16 Oct 2014 10:36:46 +0000 (14:36 +0400)
committereap <eap@opencascade.com>
Thu, 16 Oct 2014 10:36:46 +0000 (14:36 +0400)
14 files changed:
doc/salome/gui/GEOM/images/remove_webs.png
doc/salome/gui/GEOM/input/remove_webs_operation.doc
doc/salome/gui/GEOM/input/repairing_operations.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/GEOM_I/GEOM_IHealingOperations_i.cc
src/GEOM_I/GEOM_IHealingOperations_i.hh
src/GEOM_SWIG/geomBuilder.py
src/RepairGUI/RepairGUI_RemoveWebsDlg.cxx
src/RepairGUI/RepairGUI_RemoveWebsDlg.h

index 951f5a5c5cf15596f3b527cc6100f8f590e0fb0d..7f677f423881d0f75895d46ab0c8567758096451 100644 (file)
Binary files a/doc/salome/gui/GEOM/images/remove_webs.png and b/doc/salome/gui/GEOM/images/remove_webs.png differ
index a2dc780262b52443858f4afae1656ef0f6a7f273..eb9fefa03fc5c643b74c08da01e428164c14459d 100644 (file)
@@ -5,12 +5,12 @@
 \n To <b>Remove internal faces</b> in the <b>Main Menu</b> select
 <b>Repair - > Remove internal faces</b>.
 
-This operation removes all shared faces from a compound to obtain
+This operation removes all shared faces from given solids to obtain
 one or more bigger solids from a set of smaller solids.
 
 \image html remove_webs.png
 
-\n <b>Arguments:</b> Name + one shape.
+\n <b>Arguments:</b> Name + one or more shapes containing solids.
 \n <b>Advanced option:</b>
    \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
 
@@ -19,8 +19,8 @@ faces will stay as is, use \ref glue_faces_operation_page or \ref partition_page
 <b>Remove Internal Faces</b> if you need to remove them.
 
 \n <b>TUI Command:</b> <br>
-<em>geompy.RemoveInternalFaces( theCompound )</em>,<br>
-where <em>theCompound</em> is a compound of solids.
+<em>geompy.RemoveInternalFaces( theSolids )</em>,<br>
+where <em>theSolids</em> is either a compound or a list of solids.
 
 \n Our <b>TUI Scripts</b> provide you with useful examples of the
 \ref tui_remove_webs "Remove Internal Faces" functionality usage.
index 28bf44819a05487b8217eb2457c1be2e00b35aa3..b53ed10d01203be4d4d8bc390be81a03eb7423cd 100644 (file)
@@ -26,7 +26,7 @@ splits an edge in two.</li>
 <li>\subpage change_orientation_operation_page "Change orientation" -
 reverses the normals of the selected faces.</li>
 <li>\subpage remove_webs_operation_page "Remove internal faces" -
-rebuilds the topology of a compound of solids by removing the faces
+rebuilds the topology of solids by removing the faces
 are shared by several solids.</li>
 <li>\subpage remove_extra_edges_operation_page "Remove extra edges" -
 removes seam and degenerated edges from the given shape.</li>
index 7679626b7c7a5f6af0cc4c21c32d4323b2be18d6..4de99775d9d29316919a23102cafc76ee0703e14 100644 (file)
@@ -3637,12 +3637,12 @@ module GEOM
     GEOM_Object SewAllowNonManifold(in ListOfGO theObjects, in double theTolerance);
 
     /*!
-     *  Rebuild the topology of theCompound of solids by removing
-     *  of the faces that are shared by several solids.
-     *  \param theCompound Shape to be processed.
+     *  Rebuild the topology of theSolids by removing
+     *  the faces that are shared by several solids.
+     *  \param theSolids A list of shapes containing solids to be processed.
      *  \return New GEOM_Object, containing processed shape.
      */
-    GEOM_Object RemoveInternalFaces (in GEOM_Object theCompound);
+    GEOM_Object RemoveInternalFaces (in ListOfGO theSolids);
 
     /*!
      *  \brief Addition of a point to a given edge object.
index 5b5c8bb6388d2ba8bc67dd15b4e298f78b00b9e2..6fb47650740c7f7dcf5e56319c4cef414baaf874 100644 (file)
@@ -4590,7 +4590,7 @@ Please, select face, shell or solid and try again</translation>
     </message>
     <message>
         <source>GEOM_REMOVE_WEBS</source>
-        <translation>Compound of solids</translation>
+        <translation>Solids</translation>
     </message>
     <message>
         <source>REMOVE_WEBS_NEW_OBJ_NAME</source>
index 0678df2c7c1b676b10349456fe74a35cb88cc7c9..5cb3b922c1f159560de7e2a54820a1b06851718f 100644 (file)
@@ -142,7 +142,7 @@ Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
     Sew(&HI, anOriginalShape, aShape, true);
     break;
   case REMOVE_INTERNAL_FACES:
-    RemoveInternalFaces(anOriginalShape, aShape);
+    RemoveInternalFaces(&HI, anOriginalShape, aShape);
     break;
   case DIVIDE_EDGE:
     AddPointOnEdge(&HI, anOriginalShape, aShape);
@@ -470,11 +470,44 @@ Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing*  theHI,
 //function : RemoveInternalFaces
 //purpose  :
 //=======================================================================
-Standard_Boolean GEOMImpl_HealingDriver::RemoveInternalFaces (const TopoDS_Shape& theOriginalShape,
-                                                              TopoDS_Shape& theOutShape) const
+Standard_Boolean
+GEOMImpl_HealingDriver::RemoveInternalFaces (GEOMImpl_IHealing*  theHI,
+                                             const TopoDS_Shape& theOriginalShape,
+                                             TopoDS_Shape&       theOutShape) const
 {
+  // get all input shapes
+  TopTools_SequenceOfShape shapeSeq;
+  shapeSeq.Append( theOriginalShape );
+  Handle(TColStd_HSequenceOfTransient) otherObjs = theHI->GetShapes();
+  if ( !otherObjs.IsNull() )
+    for ( int ind = 1; ind <= otherObjs->Length(); ind++)
+    {
+      Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(otherObjs->Value(ind));
+      TopoDS_Shape aShape = aRefShape->GetValue();
+      if (aShape.IsNull())
+        Standard_NullObject::Raise("Null object given");
+      shapeSeq.Append( aShape );
+    }
+
+  // pass input shapes to the algorithm
   GEOMAlgo_RemoverWebs aTool;
-  aTool.SetShape(theOriginalShape);
+  if ( shapeSeq.Length() == 1 )
+  {
+    aTool.SetShape( shapeSeq.First() );
+  }
+  else
+  {
+    TopoDS_Compound solidCompound;
+    BRep_Builder builder;
+    builder.MakeCompound( solidCompound );
+    for ( int ind = 1; ind <= shapeSeq.Length(); ++ind )
+      for ( TopExp_Explorer so( shapeSeq( ind ), TopAbs_SOLID ); so.More(); so.Next() )
+        builder.Add( solidCompound, so.Current() );
+
+    aTool.SetShape( solidCompound );
+  }
+
+  // run the algorithm
   aTool.Perform();
 
   if (aTool.ErrorStatus() == 0) { // OK
@@ -929,7 +962,7 @@ GetCreationInformation(std::string&             theOperationName,
     break;
   case REMOVE_INTERNAL_FACES:
     theOperationName = "REMOVE_WEBS";
-    AddParam( theParams, "Selected shape", aCI.GetOriginal() );
+    AddParam( theParams, "Selected shapes", aCI.GetOriginalAndShapes() );
     break;
   default:
     return false;
index 2da99fa4f1e2a2a1bdef92a1fe4fead45350c6cb..5784acd1459abb0543b3a6f9938d9f57b31566eb 100644 (file)
@@ -103,7 +103,7 @@ private:
   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&, Standard_Boolean ) const;
-  Standard_Boolean RemoveInternalFaces ( const TopoDS_Shape&, TopoDS_Shape& ) const;
+  Standard_Boolean RemoveInternalFaces ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) 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 9c5d71fffaba829e3b083c86da7cacc34e558317..ab4975aa2055a84eaba5c26589134d95c85290b0 100644 (file)
@@ -652,22 +652,27 @@ GEOMImpl_IHealingOperations::Sew (std::list<Handle(GEOM_Object)>& theObjects,
  *  RemoveInternalFaces
  */
 //=============================================================================
-Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveInternalFaces (Handle(GEOM_Object) theObject)
+Handle(GEOM_Object)
+GEOMImpl_IHealingOperations::RemoveInternalFaces (std::list< Handle(GEOM_Object)> & theSolids)
 {
   // set error code, check parameters
   SetErrorCode(KO);
 
-  if (theObject.IsNull())
+  if (theSolids.empty())
     return NULL;
 
-  Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
-  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
+  Handle(TColStd_HSequenceOfTransient) objects = GEOM_Object::GetLastFunctions( theSolids );
+  if ( objects.IsNull() || objects->IsEmpty() ) {
+    SetErrorCode("NULL argument shape");
+    return NULL;
+  }
 
   // Add a new object
   Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
 
   //Add the function
-  aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INTERNAL_FACES);
+  Handle(GEOM_Function)
+    aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INTERNAL_FACES);
   if (aFunction.IsNull()) return NULL;
 
   //Check if the function is set correctly
@@ -675,7 +680,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveInternalFaces (Handle(GEO
 
   // prepare "data container" class IHealing
   GEOMImpl_IHealing HI (aFunction);
-  HI.SetOriginal(aLastFunction);
+  HI.SetOriginal( theSolids.front()->GetLastFunction() ); objects->Remove(1);
+  HI.SetShapes( objects );
 
   //Compute the result
   try {
@@ -693,7 +699,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveInternalFaces (Handle(GEO
   }
 
   //Make a Python command
-  GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.RemoveInternalFaces(" << theObject << ")";
+  GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.RemoveInternalFaces(" << theSolids << ")";
 
   SetErrorCode(OK);
   return aNewObject;
index 7dd25d87fc7c2529fca148e38b36ac06a8c6113b..f8b17b37120452a3f23e3a0ce3264bfd4a9687ee 100644 (file)
@@ -74,7 +74,7 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
                                            double                           theTolerance,
                                            bool                             isAllowNonManifold);
 
-  Standard_EXPORT Handle(GEOM_Object) RemoveInternalFaces (Handle(GEOM_Object) theObject);
+  Standard_EXPORT Handle(GEOM_Object) RemoveInternalFaces (std::list< Handle(GEOM_Object)> & theSolids);
 
   Standard_EXPORT Handle(GEOM_Object) DivideEdge( Handle(GEOM_Object) theObject,
                                                   int theIndex,
index 9b9b21cc8efb9794f875774c50eb2249bbc2acf0..d286fcf36522109b4529f2c6f635e7d682c44c35 100644 (file)
@@ -395,20 +395,21 @@ GEOM_IHealingOperations_i::SewAllowNonManifold (const GEOM::ListOfGO& theObjects
  *  RemoveInternalFaces
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::RemoveInternalFaces (GEOM::GEOM_Object_ptr theCompound)
+GEOM::GEOM_Object_ptr
+GEOM_IHealingOperations_i::RemoveInternalFaces (const GEOM::ListOfGO& theSolids)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
   // Set a not done flag
   GetOperations()->SetNotDone();
 
-  // Get the object
-  Handle(GEOM_Object) anObject = GetObjectImpl(theCompound);
-  if (anObject.IsNull())
+  // Get the objects
+  std::list< Handle(GEOM_Object) > aShapes;
+  if (! GetListOfObjectsImpl( theSolids, aShapes ))
     return aGEOMObject._retn();
 
   // Perform
-  Handle(GEOM_Object) aNewObject = GetOperations()->RemoveInternalFaces(anObject);
+  Handle(GEOM_Object) aNewObject = GetOperations()->RemoveInternalFaces(aShapes);
   if (!GetOperations()->IsDone() || aNewObject.IsNull())
     return aGEOMObject._retn();
 
index 2e2f8c665ecd2dc622eb65b6f99a01a3ce933f78..8531871394f8834c1b5191b21541460f7dd96103 100644 (file)
@@ -78,7 +78,7 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i :
    GEOM::GEOM_Object_ptr SewAllowNonManifold (const GEOM::ListOfGO & theObject,
                                               CORBA::Double theTolerance);
 
-   GEOM::GEOM_Object_ptr RemoveInternalFaces (GEOM::GEOM_Object_ptr theCompound);
+   GEOM::GEOM_Object_ptr RemoveInternalFaces (const GEOM::ListOfGO& theSolids);
 
    GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject,
                                      CORBA::Short theIndex,
index 976f9e9fbcc74e1827efe4f1c9e58184cae6e9b4..bd6a68a24ff631224314c74aeaa50780dadc76dc 100644 (file)
@@ -6380,9 +6380,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self._autoPublish(anObj, theName, "sewed")
             return anObj
 
-        ## Rebuild the topology of theCompound of solids by removing
-        #  of the faces that are shared by several solids.
-        #  @param theCompound Shape to be processed.
+        ## Rebuild the topology of theSolids by removing
+        #  the faces that are shared by several solids.
+        #  @param theSolids A compound or a list of solids to be processed.
         #  @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.
@@ -6391,13 +6391,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #
         #  @ref tui_remove_webs "Example"
         @ManageTransactions("HealOp")
-        def RemoveInternalFaces (self, theCompound, theName=None):
+        def RemoveInternalFaces (self, theSolids, theName=None):
             """
-            Rebuild the topology of theCompound of solids by removing
-            of the faces that are shared by several solids.
+            Rebuild the topology of theSolids by removing
+            the faces that are shared by several solids.
 
             Parameters:
-                theCompound Shape to be processed.
+                theSolids A compound or a list of solids to be processed.
                 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.
@@ -6406,7 +6406,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
                 New GEOM.GEOM_Object, containing processed shape.
             """
             # Example: see GEOM_TestHealing.py
-            anObj = self.HealOp.RemoveInternalFaces(theCompound)
+            anObj = self.HealOp.RemoveInternalFaces(ToList(theSolids))
             RaiseIfFailed("RemoveInternalFaces", self.HealOp)
             self._autoPublish(anObj, theName, "removeWebs")
             return anObj
index a0e18671986d72db93edd159fb906e56fd95acc1..0d015864614ebb4fa2622296faf6db5979152ca2 100755 (executable)
@@ -63,7 +63,7 @@ RepairGUI_RemoveWebsDlg::RepairGUI_RemoveWebsDlg (GeometryGUI* theGeometryGUI, Q
   GroupPoints = new DlgRef_1Sel( centralWidget() );
 
   GroupPoints->GroupBox1->setTitle( tr( "GEOM_REMOVE_WEBS" ) );
-  GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
+  GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPES" ) );
   GroupPoints->PushButton1->setIcon( image1 );
   GroupPoints->LineEdit1->setReadOnly( true );
 
@@ -141,7 +141,7 @@ bool RepairGUI_RemoveWebsDlg::ClickOnApply()
   initName();
 
   myEditCurrentArgument->setText("");
-  myObject = GEOM::GEOM_Object::_nil();
+  myObjects.clear();
 
   myOkObject = false;
 
@@ -158,33 +158,16 @@ bool RepairGUI_RemoveWebsDlg::ClickOnApply()
 void RepairGUI_RemoveWebsDlg::SelectionIntoArgument()
 {
   myEditCurrentArgument->setText( "" );
-  QString aName;
-
-  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
-  SALOME_ListIO aSelList;
-  aSelMgr->selectedObjects(aSelList);
-
-  if (myEditCurrentArgument == GroupPoints->LineEdit1) {
-    if (aSelList.Extent() != 1) {
-      if (myEditCurrentArgument == GroupPoints->LineEdit1)
-        myOkObject = false;
-      return;
-    }
-  }
-
-  // nbSel == 1
-  GEOM::GEOM_Object_ptr aSelectedObject =
-    GEOMBase::ConvertIOinGEOMObject(aSelList.First());
+  myObjects.clear();
+  myOkObject = false;
 
-  if (CORBA::is_nil(aSelectedObject))
-    return;
+  myObjects = getSelected( TopAbs_SHAPE, -1 );
 
-  if (myEditCurrentArgument == GroupPoints->LineEdit1) {
-    myObject = aSelectedObject;
+  if ( !myObjects.isEmpty() ) {
+    QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
     myOkObject = true;
+    myEditCurrentArgument->setText( aName );
   }
-
-  myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
 }
 
 //=================================================================================
@@ -242,7 +225,7 @@ void RepairGUI_RemoveWebsDlg::enterEvent (QEvent* e)
 void RepairGUI_RemoveWebsDlg::activateSelection()
 {
   TColStd_MapOfInteger aTypes;
-  //aTypes.Add( GEOM_SOLID );
+  aTypes.Add( GEOM_SOLID );
   aTypes.Add( GEOM_COMPOUND );
   globalSelection( aTypes );
 }
@@ -271,8 +254,13 @@ bool RepairGUI_RemoveWebsDlg::isValid (QString& msg)
 //=================================================================================
 bool RepairGUI_RemoveWebsDlg::execute (ObjectList& objects)
 {
+  GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
+  objList->length( myObjects.count() );
+  for ( int i = 0; i < myObjects.count(); ++i )
+    objList[i] = myObjects[i].copy();
+
   GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
-  GEOM::GEOM_Object_var anObj = anOper->RemoveInternalFaces(myObject);
+  GEOM::GEOM_Object_var anObj = anOper->RemoveInternalFaces(objList);
 
   if (!anObj->_is_nil())
     objects.push_back(anObj._retn());
index 72fd4993706673f9a669f42f2bce72af5258e627..7f04037e5916da3fe491b1b74e281b277b3eb42b 100755 (executable)
@@ -52,7 +52,7 @@ private:
   void                               activateSelection();
 
 private:
-  GEOM::GEOM_Object_var              myObject;
+  QList<GEOM::GeomObjPtr>            myObjects;
   bool                               myOkObject;
 
   DlgRef_1Sel*                       GroupPoints;