Salome HOME
Mantis issue 0021934: Delete the internal faces of an object
authorjfa <jfa@opencascade.com>
Fri, 14 Jun 2013 12:20:21 +0000 (12:20 +0000)
committerjfa <jfa@opencascade.com>
Fri, 14 Jun 2013 12:20:21 +0000 (12:20 +0000)
27 files changed:
doc/salome/examples/Makefile.am
doc/salome/examples/repairing_operations_ex12.py [new file with mode: 0644]
doc/salome/gui/GEOM/images/remove_webs.png [new file with mode: 0644]
doc/salome/gui/GEOM/input/remove_webs_operation.doc [new file with mode: 0644]
doc/salome/gui/GEOM/input/repairing_operations.doc
doc/salome/gui/GEOM/input/tui_repairing_operations.doc
idl/GEOM_Gen.idl
resources/Makefile.am
resources/remove_webs.png [new file with mode: 0644]
src/GEOMGUI/GEOM_images.ts
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GEOM_msg_fr.ts
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI_Operations.h
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/GEOM_TestHealing.py
src/GEOM_SWIG/geomBuilder.py
src/RepairGUI/Makefile.am
src/RepairGUI/RepairGUI.cxx
src/RepairGUI/RepairGUI_RemoveWebsDlg.cxx [new file with mode: 0755]
src/RepairGUI/RepairGUI_RemoveWebsDlg.h [new file with mode: 0755]

index 171c03674074462febf4556ae42c7d7e4824d024..211c7932efadb5cc623e93947854d6357affcb0f 100644 (file)
@@ -99,6 +99,7 @@ GOOD_TESTS = \
        repairing_operations_ex08.py \
        repairing_operations_ex10.py \
        repairing_operations_ex11.py \
+       repairing_operations_ex12.py \
        sketcher.py \
        tolerance.py \
        topological_geom_objs_ex01.py \
diff --git a/doc/salome/examples/repairing_operations_ex12.py b/doc/salome/examples/repairing_operations_ex12.py
new file mode 100644 (file)
index 0000000..80a814a
--- /dev/null
@@ -0,0 +1,26 @@
+# Remove internal(shared) faces from a compound
+
+import salome
+salome.salome_init()
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
+
+# create solids with some coincident faces
+Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
+Translation_1 = geompy.MakeTranslation(Box_1, 200, 0, 0)
+Translation_2 = geompy.MakeTranslation(Box_1, 200, 200, 0)
+
+geompy.addToStudy(Box_1, 'Box_1')
+geompy.addToStudy(Translation_1, 'Translation_1')
+geompy.addToStudy(Translation_2, 'Translation_2')
+
+# partition three solids to obtain shared faces
+Partition_1 = geompy.MakePartition([Box_1, Translation_1, Translation_2])
+geompy.addToStudy(Partition_1, 'Partition_1')
+
+# remove shared faces to obtain one solid instead of three
+Joined_1 = geompy.RemoveInternalFaces(Partition_1)
+geompy.addToStudy(Joined_1, 'Joined_1')
+
+salome.sg.updateObjBrowser(1) 
diff --git a/doc/salome/gui/GEOM/images/remove_webs.png b/doc/salome/gui/GEOM/images/remove_webs.png
new file mode 100644 (file)
index 0000000..951f5a5
Binary files /dev/null and b/doc/salome/gui/GEOM/images/remove_webs.png differ
diff --git a/doc/salome/gui/GEOM/input/remove_webs_operation.doc b/doc/salome/gui/GEOM/input/remove_webs_operation.doc
new file mode 100644 (file)
index 0000000..8c91ae2
--- /dev/null
@@ -0,0 +1,27 @@
+/*!
+
+\page remove_webs_operation_page Remove Internal Faces
+
+\n To <b>Remove internal faces</b> in the <b>Main Menu</b> select
+<b>Repair - > Remove internal faces</b>.
+
+\n This operation removes all shared faces from a compound to obtain
+one or more bigger solids from the set of smaller solids.
+
+\image html remove_webs.png
+
+\n <b>Arguments:</b> Name + one shape.
+\n <b>Advanced option:</b>
+   \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
+
+\note Only shared faces will be removed. Coincident but not shared
+faces will stay as is, use GlueFaces or MakePartition before
+RemoveInternalFaces if you need to remove them.
+
+\n <b>TUI Command:</b> <em>geompy.RemoveInternalFaces(theCompound)</em>,
+where <em>theCompound</em> is a compound 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 cf0239a6fddf8e285b5cde58f31e1ca65288cfc6..4cbb1ed1b4e0f4bf525c4dd836d2d5469a513ad7 100644 (file)
@@ -25,6 +25,9 @@ to set new tolerance value for the given shape.</li>
 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 of the faces
+that 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>
 <li>\subpage fuse_edges_operation_page "Fuse Collinear Edges within a Wire" -
index 711800caa4f7953207646991c5ac99d64828ecf2..b883afe8a1a5180b95c983366a7946f8310c5685 100644 (file)
@@ -46,4 +46,8 @@
 <br><h2>Fuse Collinear Edges within a Wire</h2>
 \tui_script{repairing_operations_ex11.py}
 
+\anchor tui_remove_webs
+<br><h2>Remove internal(shared) faces</h2>
+\tui_script{repairing_operations_ex12.py}
+
 */
index edfbc0d7761e1a1276000938d29c654464a4a9d9..2ed2f671ccbc91200640970f57e9317d02fbf806 100644 (file)
@@ -3331,6 +3331,14 @@ module GEOM
      */
     GEOM_Object SewAllowNonManifold(in GEOM_Object theObject, 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.
+     *  \return New GEOM_Object, containing processed shape.
+     */
+    GEOM_Object RemoveInternalFaces (in GEOM_Object theCompound);
+
     /*!
      *  \brief Addition of a point to a given edge object.
      *  \param theObject Shape to be processed.
index ee3fe1bff267b7181f2c41751ad1f811d62b66ee..b36757b3bea6fe67a96e25e88256c6efad512f2a 100644 (file)
@@ -239,8 +239,9 @@ propagate.png                       \
 redo.png                       \
 undo.png                       \
 glue2.png                      \
+remove_webs.png                        \
 remove_extra_edges.png         \
-union_faces.png                \
+union_faces.png                        \
 coordsys.png                   \
 translation.png
 
diff --git a/resources/remove_webs.png b/resources/remove_webs.png
new file mode 100644 (file)
index 0000000..80b4b47
Binary files /dev/null and b/resources/remove_webs.png differ
index 973909fdd78eea2b7bf61f6d2c1bf506a8b58d6a..1ff0697a77d2eaf0677c14b71b74751454e1027d 100644 (file)
             <source>ICON_DLG_CHANGE_DIRECTION</source>
             <translation>change_direction.png</translation>
         </message>
+        <message>
+            <source>ICON_DLG_REMOVE_WEBS</source>
+            <translation>remove_webs.png</translation>
+        </message>
         <message>
             <source>ICON_DLG_REMOVE_EXTRA_EDGES</source>
             <translation>remove_extra_edges.png</translation>
             <source>ICO_PLANE</source>
             <translation>plane.png</translation>
         </message>
+        <message>
+            <source>ICO_REMOVE_WEBS</source>
+            <translation>remove_webs.png</translation>
+        </message>
         <message>
             <source>ICO_REMOVE_EXTRA_EDGES</source>
             <translation>remove_extra_edges.png</translation>
index 0c5eef60341c2cc96d582f9fb3892df10e6a10eb..a9fd206edf25bc75bd5dc7776c31c17227cd4d17 100644 (file)
@@ -1576,10 +1576,6 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_REMOVE_INTERNAL_WIRES_TITLE</source>
         <translation>Suppress internal wires</translation>
     </message>
-    <message>
-        <source>GEOM_REMOVE_WEBS</source>
-        <translation>Remove webs</translation>
-    </message>
     <message>
         <source>GEOM_REQUIRED_DEGREE</source>
         <translation>Required degree</translation>
@@ -4508,6 +4504,30 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_CENTER_2POINTS</source>
         <translation>Center and two points</translation>
     </message>
+    <message>
+        <source>GEOM_REMOVE_WEBS_TITLE</source>
+        <translation type="unfinished">Remove internal faces</translation>
+    </message>
+    <message>
+        <source>GEOM_REMOVE_WEBS</source>
+        <translation type="unfinished">Compound of solids</translation>
+    </message>
+    <message>
+        <source>REMOVE_WEBS_NEW_OBJ_NAME</source>
+        <translation type="unfinished">NoInternalFaces</translation>
+    </message>
+    <message>
+        <source>TOP_REMOVE_WEBS</source>
+        <translation type="unfinished">Remove internal faces</translation>
+    </message>
+    <message>
+        <source>MEN_REMOVE_WEBS</source>
+        <translation type="unfinished">Remove Internal Faces</translation>
+    </message>
+    <message>
+        <source>STB_REMOVE_WEBS</source>
+        <translation type="unfinished">Remove internal faces</translation>
+    </message>
     <message>
         <source>GEOM_REMOVE_EXTRA_EDGES_TITLE</source>
         <translation>Remove extra edges</translation>
index 677b777424b22575f832479d87b12e9bc7c776a6..2a5a9ce62b2417a8d3e9725d1425f61061ab005a 100644 (file)
@@ -1574,10 +1574,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>GEOM_REMOVE_INTERNAL_WIRES_TITLE</source>
         <translation>Supprimer les contours internes</translation>
     </message>
-    <message>
-        <source>GEOM_REMOVE_WEBS</source>
-        <translation>Supprimer les toiles</translation>
-    </message>
     <message>
         <source>GEOM_REQUIRED_DEGREE</source>
         <translation>Degré nécessaire</translation>
@@ -4506,6 +4502,30 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>GEOM_CENTER_2POINTS</source>
         <translation>Centre et deux points</translation>
     </message>
+    <message>
+        <source>GEOM_REMOVE_WEBS_TITLE</source>
+        <translation type="unfinished">Remove internal faces</translation>
+    </message>
+    <message>
+        <source>GEOM_REMOVE_WEBS</source>
+        <translation type="unfinished">Compound of solids</translation>
+    </message>
+    <message>
+        <source>REMOVE_WEBS_NEW_OBJ_NAME</source>
+        <translation type="unfinished">NoInternalFaces</translation>
+    </message>
+    <message>
+        <source>TOP_REMOVE_WEBS</source>
+        <translation type="unfinished">Remove internal faces</translation>
+    </message>
+    <message>
+        <source>MEN_REMOVE_WEBS</source>
+        <translation type="unfinished">Remove Internal Faces</translation>
+    </message>
+    <message>
+        <source>STB_REMOVE_WEBS</source>
+        <translation type="unfinished">Remove internal faces</translation>
+    </message>
     <message>
         <source>GEOM_REMOVE_EXTRA_EDGES_TITLE</source>
         <translation>Supprimer les arêtes inutiles</translation>
index 19f27773506fd85d67044d82987321e0e3dce30a..4404927c4764efb85113c7a01ecb3d58ab8fac3b 100644 (file)
@@ -542,6 +542,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
   case GEOMOp::OpGlueFaces:          // MENU REPAIR - GLUE FACES
   case GEOMOp::OpGlueEdges:          // MENU REPAIR - GLUE EDGES
   case GEOMOp::OpLimitTolerance:     // MENU REPAIR - LIMIT TOLERANCE
+  case GEOMOp::OpRemoveWebs:         // MENU REPAIR - REMOVE INTERNAL FACES
   case GEOMOp::OpRemoveExtraEdges:   // MENU REPAIR - REMOVE EXTRA EDGES
   case GEOMOp::OpFuseEdges:          // MENU REPAIR - FUSE COLLINEAR EDGES
   case GEOMOp::OpUnionFaces:         // MENU REPAIR - UNION FACES
@@ -823,6 +824,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( GEOMOp::OpFreeBoundaries,   "CHECK_FREE_BNDS" );
   createGeomAction( GEOMOp::OpFreeFaces,        "CHECK_FREE_FACES" );
   createGeomAction( GEOMOp::OpOrientation,      "CHANGE_ORIENTATION" );
+  createGeomAction( GEOMOp::OpRemoveWebs,       "REMOVE_WEBS" );
   createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
   createGeomAction( GEOMOp::OpFuseEdges,        "FUSE_EDGES" );
   createGeomAction( GEOMOp::OpUnionFaces,       "UNION_FACES" );
@@ -1055,6 +1057,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   //createMenu( GEOMOp::OpFreeBoundaries,  repairId, -1 );
   //createMenu( GEOMOp::OpFreeFaces,       repairId, -1 );
   createMenu( GEOMOp::OpOrientation,      repairId, -1 );
+  createMenu( GEOMOp::OpRemoveWebs,       repairId, -1 );
   createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
   createMenu( GEOMOp::OpFuseEdges,        repairId, -1 );
   createMenu( GEOMOp::OpUnionFaces,       repairId, -1 );
index bdfed09801f87dd50b9fef4f6f5f5b05c34b954c..04b33991713387746cb7fe7970646c0810033751 100644 (file)
@@ -162,6 +162,7 @@ namespace GEOMOp {
     OpGlueEdges           = 4013,   // MENU REPAIR - GLUE EDGES
     OpFuseEdges           = 4014,   // MENU REPAIR - FUSE COLLINEAR EDGES
     OpUnionFaces          = 4015,   // MENU REPAIR - UNION FACES
+    OpRemoveWebs          = 4016,   // MENU REPAIR - REMOVE INTERNAL FACES
     // MeasureGUI ------------------//--------------------------------
     OpProperties          = 5000,   // MENU MEASURES - PROPERTIES
     OpCenterMass          = 5001,   // MENU MEASURES - CENTRE OF MASS
index d77e25f2059455a41fd589c9726518f0442dfb8b..7010b0e33191d594edf273d3fa6413f710a64c3f 100644 (file)
@@ -30,6 +30,9 @@
 #include <GEOMImpl_GlueDriver.hxx>
 #include <GEOMImpl_ShapeDriver.hxx>
 
+#include <GEOMUtils.hxx>
+#include <GEOMAlgo_RemoverWebs.hxx>
+
 #include <ShHealOper_ShapeProcess.hxx>
 #include <ShHealOper_RemoveFace.hxx>
 #include <ShHealOper_CloseContour.hxx>
@@ -138,6 +141,9 @@ Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
   case SEWING_NON_MANIFOLD:
     Sew(&HI, anOriginalShape, aShape, true);
     break;
+  case REMOVE_INTERNAL_FACES:
+    RemoveInternalFaces(anOriginalShape, aShape);
+    break;
   case DIVIDE_EDGE:
     AddPointOnEdge(&HI, anOriginalShape, aShape);
     break;
@@ -441,6 +447,33 @@ Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI,
   return aResult;
 }
 
+//=======================================================================
+//function : RemoveInternalFaces
+//purpose  :
+//=======================================================================
+Standard_Boolean GEOMImpl_HealingDriver::RemoveInternalFaces (const TopoDS_Shape& theOriginalShape,
+                                                              TopoDS_Shape& theOutShape) const
+{
+  GEOMAlgo_RemoverWebs aTool;
+  aTool.SetShape(theOriginalShape);
+  aTool.Perform();
+
+  if (aTool.ErrorStatus() != 0)
+    StdFail_NotDone::Raise("GEOMAlgo_RemoverWebs failed!");
+
+  theOutShape = aTool.Result();
+
+  // as GEOMAlgo_RemoverWebs always produces compound, lets simplify it
+  // for the case, if it contains only one sub-shape
+  TopTools_ListOfShape listShapeRes;
+  GEOMUtils::AddSimpleShapes(theOutShape, listShapeRes);
+  if (listShapeRes.Extent() == 1) {
+    theOutShape = listShapeRes.First();
+  }
+
+  return Standard_True;
+}
+
 //=======================================================================
 //function :  AddPointOnEdge
 //purpose  :
index d7579661231b342edd8719b87f2861d2fcd5d9e3..83dacd6fa89922ca166cc4af4ec0f27708ffd885 100644 (file)
@@ -172,6 +172,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 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 98f56bf19f4b88f89d3c6c86fa94d92015bbc646..e0dd6ba6efdc7d1f03675c69d3fad13fa576507b 100644 (file)
@@ -626,7 +626,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj
   HI.SetTolerance( theTolerance );
   HI.SetOriginal( aLastFunction );
 
-  //Compute the translation
+  //Compute the result
   try {
 #if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
@@ -637,9 +637,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj
       return NULL;
     }
   }
-  catch (Standard_Failure)
-  {
-        Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
     SetErrorCode(aFail->GetMessageString());
     return NULL;
   }
@@ -659,6 +658,60 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj
   return aNewObject;
 }
 
+//=============================================================================
+/*!
+ *  RemoveInternalFaces
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveInternalFaces (Handle(GEOM_Object) theObject)
+{
+  // set error code, check parameters
+  SetErrorCode(KO);
+
+  if (theObject.IsNull())
+    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
+
+  // 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);
+  if (aFunction.IsNull()) return NULL;
+
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
+
+  // prepare "data container" class IHealing
+  GEOMImpl_IHealing HI (aFunction);
+  HI.SetOriginal(aLastFunction);
+
+  //Compute the result
+  try {
+#if OCC_VERSION_LARGE > 0x06010000
+    OCC_CATCH_SIGNALS;
+#endif
+    if (!GetSolver()->ComputeFunction(aFunction))
+    {
+      SetErrorCode("Healing driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.RemoveInternalFaces(" << theObject << ")";
+
+  SetErrorCode(OK);
+  return aNewObject;
+}
+
 //=============================================================================
 /*!
  *  DivideEdge
index 37f1b90f42d23f22b423b7dd43f43a4476a4808f..b194c61e412e6699e1c34077b4dc162d3ca383f0 100644 (file)
@@ -74,6 +74,8 @@ 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) DivideEdge( Handle(GEOM_Object) theObject,
                                                   int theIndex,
                                                   double theValue,
index 2a4a2e91f688deb4d3e5ae7478fa0579257a8d0a..77b8a880e97446f8cfe2877d0a66841e32d46d74 100755 (executable)
 #define DIVIDE_EDGE        7
 #define CHANGE_ORIENTATION 8
 #define LIMIT_TOLERANCE    9
-#define FUSE_COLLINEAR_EDGES 10
-#define SEWING_NON_MANIFOLD  11
+#define FUSE_COLLINEAR_EDGES  10
+#define SEWING_NON_MANIFOLD   11
+#define REMOVE_INTERNAL_FACES 12
 
 #define BASIC_FILLING 1
 
index 195b4a3a0384d92c6feedc55166ecb841ed16938..c7363fe9e22c7e9959c82362d4c6ce369ad2e40e 100644 (file)
@@ -394,6 +394,31 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::SewAllowNonManifold (GEOM::GEOM
   return GetObject(aNewObject);
 }
 
+//=============================================================================
+/*!
+ *  RemoveInternalFaces
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::RemoveInternalFaces (GEOM::GEOM_Object_ptr theCompound)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  // Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Get the object
+  Handle(GEOM_Object) anObject = GetObjectImpl(theCompound);
+  if (anObject.IsNull())
+    return aGEOMObject._retn();
+
+  // Perform
+  Handle(GEOM_Object) aNewObject = GetOperations()->RemoveInternalFaces(anObject);
+  if (!GetOperations()->IsDone() || aNewObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(aNewObject);
+}
+
 //=============================================================================
 /*!
  *  DivideEdge
index 45a85df6291dd8c5ea35c96cbb8077a785019a89..92902800566703374413ed2d6933030eae2a9896 100644 (file)
@@ -78,6 +78,8 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i :
    GEOM::GEOM_Object_ptr SewAllowNonManifold (GEOM::GEOM_Object_ptr theObject,
                                               CORBA::Double theTolerance);
 
+   GEOM::GEOM_Object_ptr RemoveInternalFaces (GEOM::GEOM_Object_ptr theCompound);
+
    GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject,
                                      CORBA::Short theIndex,
                                      CORBA::Double theValue,
index e503ab297bc6adaff26687d931089dbda7b9320a..9d711ed6864c43ba77173f0114cf592f964938d0 100644 (file)
@@ -368,6 +368,25 @@ def TestFuseEdges (geompy):
     ii = ii + 1
     pass
 
+def TestRemoveWebs (geompy):
+
+  # create solids with some coincident faces
+  Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
+  Translation_1 = geompy.MakeTranslation(Box_1, 200, 0, 0)
+  Translation_2 = geompy.MakeTranslation(Box_1, 200, 200, 0)
+
+  geompy.addToStudy(Box_1, 'Box_1')
+  geompy.addToStudy(Translation_1, 'Translation_1')
+  geompy.addToStudy(Translation_2, 'Translation_2')
+
+  # partition three solids to obtain shared faces
+  Partition_1 = geompy.MakePartition([Box_1, Translation_1, Translation_2])
+  geompy.addToStudy(Partition_1, 'Partition_1')
+
+  # remove shared faces to obtain one solid instead of three
+  Joined_1 = geompy.RemoveInternalFaces(Partition_1)
+  geompy.addToStudy(Joined_1, 'Joined_1')
+
 def TestHealingOperations (geompy, math):
 
   TestMakeSewing(geompy, math)
@@ -378,3 +397,4 @@ def TestHealingOperations (geompy, math):
   TestSuppressFaces(geompy)
   TestProcessShape(geompy)
   TestFuseEdges(geompy)
+  TestRemoveWebs(geompy)
index b60b705327658b8d806ffe59a6887f3bc74726e9..7f309b0f2cf3487fcf6c26bca044d8c929070039 100644 (file)
@@ -5996,6 +5996,36 @@ 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.
+        #  @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.
+        #
+        #  @ref tui_remove_webs "Example"
+        def RemoveInternalFaces (self, theCompound, theName=None):
+            """
+            Rebuild the topology of theCompound of solids by removing
+            of the faces that are shared by several solids.
+
+            Parameters:
+                theCompound Shape 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.
+
+            Returns:
+                New GEOM.GEOM_Object, containing processed shape.
+            """
+            # Example: see GEOM_TestHealing.py
+            anObj = self.HealOp.RemoveInternalFaces(theCompound)
+            RaiseIfFailed("RemoveInternalFaces", self.HealOp)
+            self._autoPublish(anObj, theName, "removeWebs")
+            return anObj
+
         ## Remove internal wires and edges from the given object (face).
         #  @param theObject Shape to be processed.
         #  @param theWires Indices of wires to be removed, if EMPTY then the method
index 6b267669a6c7866b8465b7fcea290d1d7b19d690..adec8540e08166109dd2efe08c856ed260e20010 100644 (file)
@@ -38,6 +38,7 @@ salomeinclude_HEADERS =                               \
        RepairGUI_ChangeOrientationDlg.h        \
        RepairGUI_GlueDlg.h                     \
        RepairGUI_LimitToleranceDlg.h           \
+       RepairGUI_RemoveWebsDlg.h               \
        RepairGUI_RemoveExtraEdgesDlg.h         \
        RepairGUI_UnionFacesDlg.h               \
        RepairGUI_FuseEdgesDlg.h
@@ -59,6 +60,7 @@ dist_libRepairGUI_la_SOURCES =                        \
        RepairGUI_ChangeOrientationDlg.h        \
        RepairGUI_GlueDlg.h                     \
        RepairGUI_LimitToleranceDlg.h           \
+       RepairGUI_RemoveWebsDlg.h               \
        RepairGUI_RemoveExtraEdgesDlg.h         \
        RepairGUI_UnionFacesDlg.h               \
        RepairGUI_FuseEdgesDlg.h                \
@@ -76,6 +78,7 @@ dist_libRepairGUI_la_SOURCES =                        \
        RepairGUI_ChangeOrientationDlg.cxx      \
        RepairGUI_GlueDlg.cxx                   \
        RepairGUI_LimitToleranceDlg.cxx         \
+       RepairGUI_RemoveWebsDlg.cxx             \
        RepairGUI_RemoveExtraEdgesDlg.cxx       \
        RepairGUI_UnionFacesDlg.cxx             \
        RepairGUI_FuseEdgesDlg.cxx
@@ -93,8 +96,9 @@ MOC_FILES =                                   \
        RepairGUI_ChangeOrientationDlg_moc.cxx  \
        RepairGUI_GlueDlg_moc.cxx               \
        RepairGUI_LimitToleranceDlg_moc.cxx     \
+       RepairGUI_RemoveWebsDlg_moc.cxx         \
        RepairGUI_RemoveExtraEdgesDlg_moc.cxx   \
-       RepairGUI_UnionFacesDlg_moc.cxx     \
+       RepairGUI_UnionFacesDlg_moc.cxx         \
        RepairGUI_FuseEdgesDlg_moc.cxx
 
 nodist_libRepairGUI_la_SOURCES =               \
index e2a8dc1876cf48fbb4c5daa18c86e01c382bdbb7..860459574772341f93ef98db8afc9d10d10c8ae0 100644 (file)
@@ -43,6 +43,7 @@
 #include "RepairGUI_GlueDlg.h"          // Method GLUE FACES
 #include "RepairGUI_LimitToleranceDlg.h"    // Method LIMIT TOLERANCE
 #include "RepairGUI_ChangeOrientationDlg.h" // Method CHANGE ORIENTATION
+#include "RepairGUI_RemoveWebsDlg.h"        // Method REMOVE INTERNAL FACES
 #include "RepairGUI_RemoveExtraEdgesDlg.h"  // Method REMOVE EXTRA EDGES
 #include "RepairGUI_FuseEdgesDlg.h"         // Method FUSE COLLINEAR EDGES
 #include "RepairGUI_UnionFacesDlg.h"        // Method UNION FACES
@@ -91,6 +92,7 @@ bool RepairGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
   case GEOMOp::OpFreeBoundaries:   aDlg = new RepairGUI_FreeBoundDlg         (getGeometryGUI(), parent); break;
   case GEOMOp::OpFreeFaces:        aDlg = new RepairGUI_FreeFacesDlg         (getGeometryGUI(), parent); break;
   case GEOMOp::OpOrientation:      aDlg = new RepairGUI_ChangeOrientationDlg (getGeometryGUI(), parent); break;
+  case GEOMOp::OpRemoveWebs:       aDlg = new RepairGUI_RemoveWebsDlg        (getGeometryGUI(), parent); break;
   case GEOMOp::OpRemoveExtraEdges: aDlg = new RepairGUI_RemoveExtraEdgesDlg  (getGeometryGUI(), parent); break;
   case GEOMOp::OpFuseEdges:        aDlg = new RepairGUI_FuseEdgesDlg         (getGeometryGUI(), parent); break;
   case GEOMOp::OpUnionFaces:       aDlg = new RepairGUI_UnionFacesDlg        (getGeometryGUI(), parent); break;
diff --git a/src/RepairGUI/RepairGUI_RemoveWebsDlg.cxx b/src/RepairGUI/RepairGUI_RemoveWebsDlg.cxx
new file mode 100755 (executable)
index 0000000..56fcf6d
--- /dev/null
@@ -0,0 +1,296 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, 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.
+//
+// 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
+
+//  GEOM RepairGUI : GUI for Geometry component
+//  File   : RepairGUI_RemoveWebsDlg.cxx
+
+#include "RepairGUI_RemoveWebsDlg.h"
+
+#include <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
+#include <GEOMImpl_Types.hxx>
+
+#include <TColStd_MapOfInteger.hxx>
+
+//=================================================================================
+// class    : RepairGUI_RemoveWebsDlg()
+// purpose  : Constructs a RepairGUI_RemoveWebsDlg which is a child of 'parent', with the
+//            name 'name' and widget flags set to 'f'.
+//            The dialog will by default be modeless, unless you set 'modal' to
+//            TRUE to construct a modal dialog.
+//=================================================================================
+RepairGUI_RemoveWebsDlg::RepairGUI_RemoveWebsDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
+                                                  bool modal)
+  : GEOMBase_Skeleton(theGeometryGUI, parent, modal)
+{
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_REMOVE_WEBS")));
+  QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
+
+  setWindowTitle(tr("GEOM_REMOVE_WEBS_TITLE"));
+
+  /***************************************************************/
+  mainFrame()->GroupConstructors->setTitle(tr("GEOM_REMOVE_WEBS_TITLE"));
+  mainFrame()->RadioButton1->setIcon( image0 );
+  mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
+  mainFrame()->RadioButton2->close();
+  mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+  mainFrame()->RadioButton3->close();
+
+  GroupPoints = new DlgRef_1Sel( centralWidget() );
+
+  GroupPoints->GroupBox1->setTitle( tr( "GEOM_REMOVE_WEBS" ) );
+  GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
+  GroupPoints->PushButton1->setIcon( image1 );
+  GroupPoints->LineEdit1->setReadOnly( true );
+
+  QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
+  layout->setMargin( 0 ); layout->setSpacing( 6 );
+  layout->addWidget( GroupPoints );
+
+  /***************************************************************/
+
+  setHelpFileName( "remove_webs_operation_page.html" );
+
+  Init();
+}
+
+//=================================================================================
+// function : ~RepairGUI_RemoveWebsDlg()
+// purpose  : Destroys the object and frees any allocated resources
+//=================================================================================
+RepairGUI_RemoveWebsDlg::~RepairGUI_RemoveWebsDlg()
+{
+}
+
+//=================================================================================
+// function : Init()
+// purpose  :
+//=================================================================================
+void RepairGUI_RemoveWebsDlg::Init()
+{
+  /* init variables */
+  myEditCurrentArgument = GroupPoints->LineEdit1;
+
+  myOkObject = false;
+
+  activateSelection();
+
+  mainFrame()->GroupBoxPublish->show();
+  //Hide preview checkbox
+  mainFrame()->CheckBoxPreview->hide();
+
+  /* signals and slots connections */
+  connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+  connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+
+  connect(GroupPoints->PushButton1, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
+  connect(GroupPoints->LineEdit1,   SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
+
+  initName(tr("REMOVE_WEBS_NEW_OBJ_NAME"));
+  resize(100,100);
+  SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose  : Same than click on apply but close this dialog.
+//=================================================================================
+void RepairGUI_RemoveWebsDlg::ClickOnOk()
+{
+  setIsApplyAndClose(true);
+  if (ClickOnApply())
+    ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose  :
+//=================================================================================
+bool RepairGUI_RemoveWebsDlg::ClickOnApply()
+{
+  if (!onAccept())
+    return false;
+
+  initName();
+
+  myEditCurrentArgument->setText("");
+  myObject = GEOM::GEOM_Object::_nil();
+
+  myOkObject = false;
+
+  activateSelection();
+
+  return true;
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose  : Called when selection as changed or other case
+//          : used only by SelectButtonC1A1 (LineEditC1A1)
+//=================================================================================
+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());
+
+  if (CORBA::is_nil(aSelectedObject))
+    return;
+
+  if (myEditCurrentArgument == GroupPoints->LineEdit1) {
+    myObject = aSelectedObject;
+    myOkObject = true;
+  }
+
+  myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose  :
+//=================================================================================
+void RepairGUI_RemoveWebsDlg::SetEditCurrentArgument()
+{
+  if (sender() == GroupPoints->PushButton1) {
+    GroupPoints->LineEdit1->setFocus();
+    myEditCurrentArgument = GroupPoints->LineEdit1;
+  }
+  SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose  :
+//=================================================================================
+void RepairGUI_RemoveWebsDlg::LineEditReturnPressed()
+{
+  if (sender() == GroupPoints->LineEdit1) {
+    myEditCurrentArgument = GroupPoints->LineEdit1;
+    GEOMBase_Skeleton::LineEditReturnPressed();
+  }
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose  :
+//=================================================================================
+void RepairGUI_RemoveWebsDlg::ActivateThisDialog()
+{
+  GEOMBase_Skeleton::ActivateThisDialog();
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
+
+  activateSelection();
+}
+
+//=================================================================================
+// function : enterEvent()
+// purpose  : Mouse enter onto the dialog to activate it
+//=================================================================================
+void RepairGUI_RemoveWebsDlg::enterEvent (QEvent* e)
+{
+  if (!mainFrame()->GroupConstructors->isEnabled())
+    ActivateThisDialog();
+}
+
+//=================================================================================
+// function : activateSelection
+// purpose  : activate selection of solids and compounds
+//=================================================================================
+void RepairGUI_RemoveWebsDlg::activateSelection()
+{
+  TColStd_MapOfInteger aTypes;
+  //aTypes.Add( GEOM_SOLID );
+  aTypes.Add( GEOM_COMPOUND );
+  globalSelection( aTypes );
+}
+
+//=================================================================================
+// function : createOperation
+// purpose  :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr RepairGUI_RemoveWebsDlg::createOperation()
+{
+  return getGeomEngine()->GetIHealingOperations(getStudyId());
+}
+
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+bool RepairGUI_RemoveWebsDlg::isValid (QString& msg)
+{
+  return myOkObject;
+}
+
+//=================================================================================
+// function : execute
+// purpose  :
+//=================================================================================
+bool RepairGUI_RemoveWebsDlg::execute (ObjectList& objects)
+{
+  GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
+  GEOM::GEOM_Object_var anObj = anOper->RemoveInternalFaces(myObject);
+
+  if (!anObj->_is_nil())
+    objects.push_back(anObj._retn());
+
+  return true;
+}
+
+//=================================================================================
+// function : restoreSubShapes
+// purpose  :
+//=================================================================================
+void RepairGUI_RemoveWebsDlg::restoreSubShapes (SALOMEDS::Study_ptr   theStudy,
+                                                SALOMEDS::SObject_ptr theSObject)
+{
+  if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
+    // empty list of arguments means that all arguments should be restored
+    getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
+                                        /*theFindMethod=*/GEOM::FSM_GetInPlace, // ? GetInPlaceByHistory
+                                        /*theInheritFirstArg=*/true,
+                                        mainFrame()->CheckBoxAddPrefix->isChecked());
+  }
+}
diff --git a/src/RepairGUI/RepairGUI_RemoveWebsDlg.h b/src/RepairGUI/RepairGUI_RemoveWebsDlg.h
new file mode 100755 (executable)
index 0000000..9aee4d9
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, 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.
+//
+// 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
+
+//  GEOM GEOMGUI : GUI for Geometry component
+//  File   : RepairGUI_RemoveWebsDlg.h
+
+#ifndef REPAIRGUI_REMOVEWEBSDLG_H
+#define REPAIRGUI_REMOVEWEBSDLG_H
+
+#include <GEOMBase_Skeleton.h>
+
+class DlgRef_1Sel;
+
+//=================================================================================
+// class    : RepairGUI_RemoveWebsDlg
+// purpose  : Unites faces of a given shape.
+//=================================================================================
+class RepairGUI_RemoveWebsDlg : public GEOMBase_Skeleton
+{
+  Q_OBJECT
+
+public:
+  RepairGUI_RemoveWebsDlg (GeometryGUI*, QWidget* = 0, bool = false);
+  ~RepairGUI_RemoveWebsDlg();
+
+protected:
+  // redefined from GEOMBase_Helper
+  virtual GEOM::GEOM_IOperations_ptr createOperation();
+  virtual bool                       isValid (QString&);
+  virtual bool                       execute (ObjectList&);
+  virtual void                       restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
+
+private:
+  void                               Init();
+  void                               enterEvent (QEvent*);
+  void                               activateSelection();
+
+private:
+  GEOM::GEOM_Object_var              myObject;
+  bool                               myOkObject;
+
+  DlgRef_1Sel*                       GroupPoints;
+
+private slots:
+  void                               ClickOnOk();
+  bool                               ClickOnApply();
+
+  void                               ActivateThisDialog();
+
+  void                               LineEditReturnPressed();
+  void                               SelectionIntoArgument();
+  void                               SetEditCurrentArgument();
+};
+
+#endif // REPAIRGUI_REMOVEWEBSDLG_H