Salome HOME
0022179: [CEA 800] Suppress common edges on two continuous faces without using Remove...
authorskv <skv@opencascade.com>
Fri, 24 May 2013 08:52:30 +0000 (08:52 +0000)
committerskv <skv@opencascade.com>
Fri, 24 May 2013 08:52:30 +0000 (08:52 +0000)
25 files changed:
doc/salome/gui/GEOM/images/union_faces.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/union_faces1.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/union_faces2.png [new file with mode: 0644]
doc/salome/gui/GEOM/input/repairing_operations.doc
doc/salome/gui/GEOM/input/tui_test_others.doc
doc/salome/gui/GEOM/input/union_faces_operation.doc [new file with mode: 0755]
idl/GEOM_Gen.idl
resources/Makefile.am
resources/union_faces.png [new file with mode: 0644]
src/GEOMGUI/GEOM_images.ts
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI_Operations.h
src/GEOMImpl/GEOMImpl_BlockDriver.cxx
src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx
src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOM_I/GEOM_IBlocksOperations_i.cc
src/GEOM_I/GEOM_IBlocksOperations_i.hh
src/GEOM_SWIG/GEOM_TestOthers.py
src/GEOM_SWIG/geomBuilder.py
src/RepairGUI/Makefile.am
src/RepairGUI/RepairGUI.cxx
src/RepairGUI/RepairGUI_UnionFacesDlg.cxx [new file with mode: 0755]
src/RepairGUI/RepairGUI_UnionFacesDlg.h [new file with mode: 0755]

diff --git a/doc/salome/gui/GEOM/images/union_faces.png b/doc/salome/gui/GEOM/images/union_faces.png
new file mode 100644 (file)
index 0000000..f5a620b
Binary files /dev/null and b/doc/salome/gui/GEOM/images/union_faces.png differ
diff --git a/doc/salome/gui/GEOM/images/union_faces1.png b/doc/salome/gui/GEOM/images/union_faces1.png
new file mode 100644 (file)
index 0000000..3737f97
Binary files /dev/null and b/doc/salome/gui/GEOM/images/union_faces1.png differ
diff --git a/doc/salome/gui/GEOM/images/union_faces2.png b/doc/salome/gui/GEOM/images/union_faces2.png
new file mode 100644 (file)
index 0000000..3302eb1
Binary files /dev/null and b/doc/salome/gui/GEOM/images/union_faces2.png differ
index 8fd31bab135a633dff6b95a8da085f70d252ce0c..cf0239a6fddf8e285b5cde58f31e1ca65288cfc6 100644 (file)
@@ -30,6 +30,8 @@ removes seam and degenerated edges from the given shape.</li>
 <li>\subpage fuse_edges_operation_page "Fuse Collinear Edges within a Wire" -
 removes selected vertices from a given wire in case if adjacent edges
 are C1 continuous.</li>
+<li>\subpage union_faces_operation_page "Union faces" -
+unites all faces sharing one surface on a given shape.</li>
 </ul>
 
 */
index e89f8995785fd25352681be1541ebee094d81c6a..701a1b52be3eb69d8a7493ecb471634c6b000cce 100644 (file)
@@ -90,6 +90,9 @@
 \anchor swig_RemoveExtraEdges
 \until "freeFacesWithoutExtra"
 
+\anchor swig_UnionFaces
+\until "unitedFaces"
+
 \anchor swig_GetSharedShapes
 \until "sharedEdge_"
 
diff --git a/doc/salome/gui/GEOM/input/union_faces_operation.doc b/doc/salome/gui/GEOM/input/union_faces_operation.doc
new file mode 100755 (executable)
index 0000000..65cbd43
--- /dev/null
@@ -0,0 +1,29 @@
+/*!
+
+\page union_faces_operation_page Union Faces
+
+\n To <b>Union Faces</b> in the <b>Main Menu</b> select
+<b>Repair - > Union Faces</b>.
+\n This operation unites all faces sharing one surface on a given
+shape.
+
+\n <b>TUI Command:</b> <em>geompy.UnionFaces(theShape)</em>,
+where <em>theShape</em> is a compound or a single solid.
+\n <b>Arguments:</b> Name + one shape + a flag.
+\n <b>Advanced option:</b>
+   \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
+
+\image html union_faces.png
+
+\n <b>Example:</b>
+
+\image html union_faces1.png
+<center><em>Shape with not united faces</em></center>
+
+\image html union_faces2.png
+<center><em>Improved shape</em></center>
+
+Our <b>TUI Scripts</b> provide you with useful examples of the
+\ref swig_UnionFaces "Union Faces" functionality usage.
+
+*/
index f8642857cca1c9aa37ea48eb734f52bcf55a189a..874f7d6069fa9dc0f720b9b728d49dfef39494d0 100644 (file)
@@ -2556,6 +2556,15 @@ module GEOM
     GEOM_Object RemoveExtraEdges (in GEOM_Object theShape,
                                   in long        theOptimumNbFaces);
 
+    /*!
+     *  \brief Performs union faces of \a theShape.
+     *
+     *  Unite faces sharing one surface.
+     *  \param theShape The compound or single solid that contains faces to perform union.
+     *  \return Improved shape.
+     */
+    GEOM_Object UnionFaces (in GEOM_Object theShape);
+
     /*!
      *  \brief Check, if the given shape is a blocks compound.
      *
index dbc53af18bb222f159058f2b460eeb66772c115a..8051b27a04dbf009e16ad57dcc7ffd83ee11dad6 100644 (file)
@@ -240,6 +240,7 @@ redo.png                    \
 undo.png                       \
 glue2.png                      \
 remove_extra_edges.png         \
+union_faces.png                \
 coordsys.png                   \
 translation.png
 
diff --git a/resources/union_faces.png b/resources/union_faces.png
new file mode 100644 (file)
index 0000000..bdb821e
Binary files /dev/null and b/resources/union_faces.png differ
index f0bfad5a7f0d69a70ea832f7e4cb4282a66416f6..20236ddfc57d15ab8d43d691d7ac657c7e5fa3c1 100644 (file)
             <source>ICON_DLG_FUSE_EDGES</source>
             <translation>fuse_collinear_edges.png</translation>
         </message>
+        <message>
+            <source>ICON_DLG_UNION_FACES</source>
+            <translation>union_faces.png</translation>
+        </message>
         <message>
             <source>ICON_DLG_CHECKSHAPE</source>
             <translation>check.png</translation>
             <source>ICO_FUSE_EDGES</source>
             <translation>fuse_collinear_edges.png</translation>
         </message>
+        <message>
+            <source>ICO_UNION_FACES</source>
+            <translation>union_faces.png</translation>
+        </message>
         <message>
             <source>ICO_NORMALE</source>
             <translation>normale.png</translation>
index 42cd00013f2982e6e6c4c1abe9c9f85b63e8bec4..b35e64ea1362e0529aa34e7af14cf3e61cb6023e 100644 (file)
@@ -4554,6 +4554,30 @@ Please, select face, shell or solid and try again</translation>
         <source>STB_FUSE_EDGES</source>
         <translation>Fuse collinear edges within a wire</translation>
     </message>
+    <message>
+        <source>GEOM_UNION_FACES_TITLE</source>
+        <translation>Union faces</translation>
+    </message>
+    <message>
+        <source>GEOM_UNION_FACES</source>
+        <translation>Object to unite faces</translation>
+    </message>
+    <message>
+        <source>UNION_FACES_NEW_OBJ_NAME</source>
+        <translation>UnionFaces</translation>
+    </message>
+    <message>
+        <source>TOP_UNION_FACES</source>
+        <translation>Union faces</translation>
+    </message>
+    <message>
+        <source>MEN_UNION_FACES</source>
+        <translation>Union Faces</translation>
+    </message>
+    <message>
+        <source>STB_UNION_FACES</source>
+        <translation>Union faces</translation>
+    </message>
     <message>
         <source>TOP_NORMALE</source>
         <translation>Normal to a face</translation>
index de3a7b815e9083854b086673fc7067441e38da52..4e4517aa78474c843f4eccafb51d005c607f26ab 100644 (file)
@@ -544,6 +544,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
   case GEOMOp::OpLimitTolerance:     // MENU REPAIR - LIMIT TOLERANCE
   case GEOMOp::OpRemoveExtraEdges:   // MENU REPAIR - REMOVE EXTRA EDGES
   case GEOMOp::OpFuseEdges:          // MENU REPAIR - FUSE COLLINEAR EDGES
+  case GEOMOp::OpUnionFaces:         // MENU REPAIR - UNION FACES
     libName = "RepairGUI";
     break;
   case GEOMOp::OpProperties:         // MENU MEASURE - PROPERTIES
@@ -823,6 +824,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( GEOMOp::OpOrientation,      "CHANGE_ORIENTATION" );
   createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
   createGeomAction( GEOMOp::OpFuseEdges,        "FUSE_EDGES" );
+  createGeomAction( GEOMOp::OpUnionFaces,       "UNION_FACES" );
 
   createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
   createGeomAction( GEOMOp::OpProperties,       "BASIC_PROPS" );
@@ -1053,6 +1055,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createMenu( GEOMOp::OpOrientation,      repairId, -1 );
   createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
   createMenu( GEOMOp::OpFuseEdges,        repairId, -1 );
+  createMenu( GEOMOp::OpUnionFaces,       repairId, -1 );
 
   int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
   createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
index d170eec027a653b9ed8f1cd58fdef432b6d17451..e6af05e8b439bb15774d14f19c66b3e7c4081862 100644 (file)
@@ -161,6 +161,7 @@ namespace GEOMOp {
     OpLimitTolerance      = 4012,   // MENU REPAIR - LIMIT TOLERANCE
     OpGlueEdges           = 4013,   // MENU REPAIR - GLUE EDGES
     OpFuseEdges           = 4014,   // MENU REPAIR - FUSE COLLINEAR EDGES
+    OpUnionFaces          = 4015,   // MENU REPAIR - UNION FACES
     // MeasureGUI ------------------//--------------------------------
     OpProperties          = 5000,   // MENU MEASURES - PROPERTIES
     OpCenterMass          = 5001,   // MENU MEASURES - CENTRE OF MASS
index b0838a1b045a0117f13251c791cf93b01361eeb3..19aec6ceca10e8aa1c723205180d91c9024d30ae 100644 (file)
@@ -39,6 +39,7 @@
 #include <ShHealOper_ShapeProcess.hxx>
 //#include <GEOMAlgo_Gluer.hxx>
 #include <BlockFix_BlockFixAPI.hxx>
+#include <BlockFix_UnionFaces.hxx>
 
 #include "utilities.h"
 
@@ -733,6 +734,18 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
       // Glue faces of the multi-block
       aShape = GEOMImpl_GlueDriver::GlueFaces(aMulti, aTol, Standard_False);
 
+    } else if (aType == BLOCK_UNION_FACES) {
+      GEOMImpl_IBlockTrsf aCI (aFunction);
+      Handle(GEOM_Function) aRefShape = aCI.GetOriginal();
+      TopoDS_Shape aBlockOrComp = aRefShape->GetValue();
+      if (aBlockOrComp.IsNull()) {
+        Standard_NullObject::Raise("Null Shape given");
+      }
+
+      BlockFix_UnionFaces aFaceUnifier;
+  
+      aFaceUnifier.GetOptimumNbFaces() = 0; // To force union faces.
+      aShape = aFaceUnifier.Perform(aBlockOrComp);
     } else { // unknown function type
       return 0;
     }
index 274c82e00031a6f3d15778257fdb887ec165befe..7f6149da3f3988501f172d0368c48cfe4f320a49 100644 (file)
@@ -2654,6 +2654,58 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges
   return aCopy;
 }
 
+//=============================================================================
+/*!
+ *  UnionFaces
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IBlocksOperations::UnionFaces
+                                     (Handle(GEOM_Object) theObject)
+{
+  SetErrorCode(KO);
+
+  if (theObject.IsNull()) return NULL;
+
+  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
+  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be fixed
+
+  //Add a new Copy object
+  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
+
+  //Add a function
+  Handle(GEOM_Function) aFunction =
+    aCopy->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_UNION_FACES);
+
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL;
+
+  GEOMImpl_IBlockTrsf aTI (aFunction);
+  aTI.SetOriginal(aLastFunction);
+
+  //Compute the fixed shape
+  try {
+#if OCC_VERSION_LARGE > 0x06010000
+    OCC_CATCH_SIGNALS;
+#endif
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Block driver failed to remove extra edges of the given shape");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOM::TPythonDump(aFunction) << aCopy << " = geompy.UnionFaces("
+                               << theObject << ")";
+
+  SetErrorCode(OK);
+  return aCopy;
+}
+
 //=============================================================================
 /*!
  *  CheckAndImprove
index 1ede9b6db5c07b9c3813a8cc05b18841cd25eae3..86c8a038090d9f4020ef7d34fa216879a62614fb 100644 (file)
@@ -140,6 +140,8 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape,
                                                         const Standard_Integer theOptimumNbFaces = 6);
 
+  Standard_EXPORT Handle(GEOM_Object) UnionFaces (Handle(GEOM_Object) theShape);
+
   Standard_EXPORT Handle(GEOM_Object) CheckAndImprove (Handle(GEOM_Object) theCompound);
 
   Standard_EXPORT static void AddBlocksFrom (const TopoDS_Shape&   theShape,
index 7a116ddf4d9f1f161471201c26bb8099b9f091b4..105de5d2a2418612655f453a70a01c7933cac254 100755 (executable)
 #define BLOCK_COMPOUND_GLUE       8
 #define BLOCK_REMOVE_EXTRA        9
 #define BLOCK_COMPOUND_IMPROVE    10
+#define BLOCK_UNION_FACES         11
 
 // Marker
 #define MARKER_CS      1
index b25c0d164748a6c895f838376a81150ae37ff752..59fd4654628a7f13a535986d38dacf91058ef66f 100644 (file)
@@ -801,6 +801,31 @@ GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  UnionFaces
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::UnionFaces
+                                      (GEOM::GEOM_Object_ptr theShape)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference Objects
+  Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return aGEOMObject._retn();
+
+  //Get the result
+  Handle(GEOM_Object) anObject = GetOperations()->UnionFaces(aShape);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
 //=============================================================================
 /*!
  *  CheckAndImprove
index a66e644589114fca2c56f1659d7ceb4145c1b8b8..c6e23ae9638307089107510f0460820a016281ed 100644 (file)
@@ -127,6 +127,8 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i :
   GEOM::GEOM_Object_ptr RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape,
                                           CORBA::Long           theOptimumNbFaces);
 
+  GEOM::GEOM_Object_ptr UnionFaces (GEOM::GEOM_Object_ptr theShape);
+
   GEOM::GEOM_Object_ptr CheckAndImprove (GEOM::GEOM_Object_ptr theCompound);
 
   // Extract blocks from blocks compounds
index 0a8ab0413dbb624c3bb8fe2a9cf5f0c1af59f859..4153bb6a6ccc79e727caa8ed600bc8eec10538d6 100644 (file)
@@ -208,7 +208,7 @@ def TestOtherOperations (geompy, math):
   geompy.addToStudy(MultiRot1Dt, "MakeMultiRotation1DNbTimes")
   geompy.addToStudy(MultiRot1Ds, "MakeMultiRotation1DByStep")
   geompy.addToStudy(MultiRot2Dt, "MakeMultiRotation2DNbTimes")
-  geompy.addToStudy(MultiRot2Ds, "MakeMultiRotation2DByStep")
+  id_MultiRot2D = geompy.addToStudy(MultiRot2Ds, "MakeMultiRotation2DByStep")
 
   # MakeFilletAll
   radius_fillet = 10.
@@ -540,6 +540,11 @@ def TestOtherOperations (geompy, math):
 
   geompy.addToStudy(freeFacesWithoutExtra, "freeFacesWithoutExtra")
 
+  # UnionFaces
+  unitedFaces = geompy.UnionFaces(freeFaces)
+
+  geompy.addToStudy(unitedFaces, "unitedFaces")
+
   # GetSharedShapes
   sharedFaces = geompy.GetSharedShapes(part, freeFaces,
                                        geompy.ShapeType["FACE"])
index 05e3d674f6ccff57bfa5ae71bd96731f45c57134..249379505cc5a1a824527a6fc11f07990dbb2f84 100644 (file)
@@ -10740,6 +10740,40 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self._autoPublish(anObj, theName, "removeExtraEdges")
             return anObj
 
+        ## Performs union faces of \a theShape
+        #  Unite faces sharing one surface. It means that
+        #  these faces must have references to one C++ surface object (handle).
+        #  @param theShape The compound or single solid that contains faces
+        #         to perform union.
+        #  @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 Improved shape.
+        #
+        #  @ref swig_UnionFaces "Example"
+        def UnionFaces(self, theShape, theName=None):
+            """
+            Performs union faces of theShape.
+            Unite faces sharing one surface. It means that
+            these faces must have references to one C++ surface object (handle).
+
+            Parameters:
+                theShape The compound or single solid that contains faces
+                         to perform union.
+                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: 
+                Improved shape.
+            """
+            # Example: see GEOM_TestOthers.py
+            anObj = self.BlocksOp.UnionFaces(theShape)
+            RaiseIfFailed("UnionFaces", self.BlocksOp)
+            self._autoPublish(anObj, theName, "unionFaces")
+            return anObj
+
         ## Check, if the given shape is a blocks compound.
         #  Fix all detected errors.
         #    \note Single block can be also fixed by this method.
index f81255c8fff5c6d3507cbc9ff681274f42cbe54e..6b267669a6c7866b8465b7fcea290d1d7b19d690 100644 (file)
@@ -39,6 +39,7 @@ salomeinclude_HEADERS =                               \
        RepairGUI_GlueDlg.h                     \
        RepairGUI_LimitToleranceDlg.h           \
        RepairGUI_RemoveExtraEdgesDlg.h         \
+       RepairGUI_UnionFacesDlg.h               \
        RepairGUI_FuseEdgesDlg.h
 
 # Libraries targets
@@ -59,6 +60,7 @@ dist_libRepairGUI_la_SOURCES =                        \
        RepairGUI_GlueDlg.h                     \
        RepairGUI_LimitToleranceDlg.h           \
        RepairGUI_RemoveExtraEdgesDlg.h         \
+       RepairGUI_UnionFacesDlg.h               \
        RepairGUI_FuseEdgesDlg.h                \
                                                \
        RepairGUI.cxx                           \
@@ -75,6 +77,7 @@ dist_libRepairGUI_la_SOURCES =                        \
        RepairGUI_GlueDlg.cxx                   \
        RepairGUI_LimitToleranceDlg.cxx         \
        RepairGUI_RemoveExtraEdgesDlg.cxx       \
+       RepairGUI_UnionFacesDlg.cxx             \
        RepairGUI_FuseEdgesDlg.cxx
 
 MOC_FILES =                                    \
@@ -91,6 +94,7 @@ MOC_FILES =                                   \
        RepairGUI_GlueDlg_moc.cxx               \
        RepairGUI_LimitToleranceDlg_moc.cxx     \
        RepairGUI_RemoveExtraEdgesDlg_moc.cxx   \
+       RepairGUI_UnionFacesDlg_moc.cxx     \
        RepairGUI_FuseEdgesDlg_moc.cxx
 
 nodist_libRepairGUI_la_SOURCES =               \
index 5def074918d0048c5b881f89e3cc9b2a8b7e38b1..e2a8dc1876cf48fbb4c5daa18c86e01c382bdbb7 100644 (file)
@@ -45,6 +45,7 @@
 #include "RepairGUI_ChangeOrientationDlg.h" // Method CHANGE ORIENTATION
 #include "RepairGUI_RemoveExtraEdgesDlg.h"  // Method REMOVE EXTRA EDGES
 #include "RepairGUI_FuseEdgesDlg.h"         // Method FUSE COLLINEAR EDGES
+#include "RepairGUI_UnionFacesDlg.h"        // Method UNION FACES
 
 //=======================================================================
 // function : RepairGUI()
@@ -92,6 +93,7 @@ bool RepairGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
   case GEOMOp::OpOrientation:      aDlg = new RepairGUI_ChangeOrientationDlg (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;
   default:
     app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
     break;
diff --git a/src/RepairGUI/RepairGUI_UnionFacesDlg.cxx b/src/RepairGUI/RepairGUI_UnionFacesDlg.cxx
new file mode 100755 (executable)
index 0000000..e9b4cea
--- /dev/null
@@ -0,0 +1,307 @@
+// 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_UnionFacesDlg.cxx
+//  Author : Michael Zorin, Open CASCADE S.A.S.
+//
+#include "RepairGUI_UnionFacesDlg.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_UnionFacesDlg()
+// purpose  : Constructs a RepairGUI_UnionFacesDlg 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_UnionFacesDlg::RepairGUI_UnionFacesDlg( 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_UNION_FACES" ) ) );
+  QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+    
+  setWindowTitle( tr( "GEOM_UNION_FACES_TITLE" ) );
+
+  /***************************************************************/
+  mainFrame()->GroupConstructors->setTitle(tr("GEOM_UNION_FACES_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_UNION_FACES" ) );
+  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( "union_faces_operation_page.html" );
+
+  Init();
+}
+
+
+//=================================================================================
+// function : ~RepairGUI_UnionFacesDlg()
+// purpose  : Destroys the object and frees any allocated resources
+//=================================================================================
+RepairGUI_UnionFacesDlg::~RepairGUI_UnionFacesDlg()
+{
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose  :
+//=================================================================================
+void RepairGUI_UnionFacesDlg::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( "UNION_FACES_NEW_OBJ_NAME" ) );
+  resize(100,100);
+  SelectionIntoArgument();
+}
+
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose  : Same than click on apply but close this dialog.
+//=================================================================================
+void RepairGUI_UnionFacesDlg::ClickOnOk()
+{
+  setIsApplyAndClose( true );
+  if ( ClickOnApply() )
+    ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose  :
+//=================================================================================
+bool RepairGUI_UnionFacesDlg::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_UnionFacesDlg::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_UnionFacesDlg::SetEditCurrentArgument()
+{
+  if( sender() == GroupPoints->PushButton1 ) {
+    GroupPoints->LineEdit1->setFocus();
+    myEditCurrentArgument = GroupPoints->LineEdit1;
+  }
+  SelectionIntoArgument();
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose  :
+//=================================================================================
+void RepairGUI_UnionFacesDlg::LineEditReturnPressed()
+{
+  if ( sender() == GroupPoints->LineEdit1 ) {
+    myEditCurrentArgument = GroupPoints->LineEdit1;
+    GEOMBase_Skeleton::LineEditReturnPressed();
+  }
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose  :
+//=================================================================================
+void RepairGUI_UnionFacesDlg::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_UnionFacesDlg::enterEvent(QEvent* e)
+{
+  if ( !mainFrame()->GroupConstructors->isEnabled() )
+    ActivateThisDialog();
+}
+
+
+//=================================================================================
+// function : activateSelection
+// purpose  : activate selection of solids and compounds
+//=================================================================================
+void RepairGUI_UnionFacesDlg::activateSelection()
+{
+  TColStd_MapOfInteger aTypes;
+  aTypes.Add( GEOM_SHELL );
+  aTypes.Add( GEOM_SOLID );
+  aTypes.Add( GEOM_COMPOUND );
+  globalSelection( aTypes );
+}
+
+//=================================================================================
+// function : createOperation
+// purpose  :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr RepairGUI_UnionFacesDlg::createOperation()
+{
+  return getGeomEngine()->GetIBlocksOperations( getStudyId() );
+}
+
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+bool RepairGUI_UnionFacesDlg::isValid( QString& msg )
+{
+  return myOkObject;
+}
+
+//=================================================================================
+// function : execute
+// purpose  :
+//=================================================================================
+bool RepairGUI_UnionFacesDlg::execute( ObjectList& objects )
+{
+  GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation());
+  GEOM::GEOM_Object_var anObj = anOper->UnionFaces(myObject);
+
+  if (!anObj->_is_nil())
+    objects.push_back(anObj._retn());
+
+  return true;
+}
+
+//=================================================================================
+// function : restoreSubShapes
+// purpose  :
+//=================================================================================
+void RepairGUI_UnionFacesDlg::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_UnionFacesDlg.h b/src/RepairGUI/RepairGUI_UnionFacesDlg.h
new file mode 100755 (executable)
index 0000000..ea00f50
--- /dev/null
@@ -0,0 +1,72 @@
+// 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_UnionFacesDlg.h
+//  Author : Michael ZORIN, Open CASCADE S.A.S.
+//
+#ifndef REPAIRGUI_UNIONFACESDLG_H
+#define REPAIRGUI_UNIONFACESDLG_H
+
+#include <GEOMBase_Skeleton.h>
+
+class DlgRef_1Sel;
+
+//=================================================================================
+// class    : RepairGUI_UnionFacesDlg
+// purpose  : Unites faces of a given shape.
+//=================================================================================
+class RepairGUI_UnionFacesDlg : public GEOMBase_Skeleton
+{ 
+  Q_OBJECT
+
+public:
+  RepairGUI_UnionFacesDlg( GeometryGUI*, QWidget* = 0, bool = false );
+  ~RepairGUI_UnionFacesDlg();
+
+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_UNIONFACESDLG_H