From: skv Date: Fri, 24 May 2013 08:52:30 +0000 (+0000) Subject: 0022179: [CEA 800] Suppress common edges on two continuous faces without using Remove... X-Git-Tag: BR_hydro_v_0_3_1~220 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3282e6d3b3ebc2a33c0ff2ce1dcfb31ae06f6571;p=modules%2Fgeom.git 0022179: [CEA 800] Suppress common edges on two continuous faces without using RemoveExtraEdges --- diff --git a/doc/salome/gui/GEOM/images/union_faces.png b/doc/salome/gui/GEOM/images/union_faces.png new file mode 100644 index 000000000..f5a620b65 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 index 000000000..3737f97f4 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 index 000000000..3302eb1be Binary files /dev/null and b/doc/salome/gui/GEOM/images/union_faces2.png differ diff --git a/doc/salome/gui/GEOM/input/repairing_operations.doc b/doc/salome/gui/GEOM/input/repairing_operations.doc index 8fd31bab1..cf0239a6f 100644 --- a/doc/salome/gui/GEOM/input/repairing_operations.doc +++ b/doc/salome/gui/GEOM/input/repairing_operations.doc @@ -30,6 +30,8 @@ removes seam and degenerated edges from the given shape.
  • \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.
  • +
  • \subpage union_faces_operation_page "Union faces" - +unites all faces sharing one surface on a given shape.
  • */ diff --git a/doc/salome/gui/GEOM/input/tui_test_others.doc b/doc/salome/gui/GEOM/input/tui_test_others.doc index e89f89957..701a1b52b 100644 --- a/doc/salome/gui/GEOM/input/tui_test_others.doc +++ b/doc/salome/gui/GEOM/input/tui_test_others.doc @@ -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 index 000000000..65cbd4307 --- /dev/null +++ b/doc/salome/gui/GEOM/input/union_faces_operation.doc @@ -0,0 +1,29 @@ +/*! + +\page union_faces_operation_page Union Faces + +\n To Union Faces in the Main Menu select +Repair - > Union Faces. +\n This operation unites all faces sharing one surface on a given +shape. + +\n TUI Command: geompy.UnionFaces(theShape), +where theShape is a compound or a single solid. +\n Arguments: Name + one shape + a flag. +\n Advanced option: + \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments". + +\image html union_faces.png + +\n Example: + +\image html union_faces1.png +
    Shape with not united faces
    + +\image html union_faces2.png +
    Improved shape
    + +Our TUI Scripts provide you with useful examples of the +\ref swig_UnionFaces "Union Faces" functionality usage. + +*/ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index f8642857c..874f7d606 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -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. * diff --git a/resources/Makefile.am b/resources/Makefile.am index dbc53af18..8051b27a0 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -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 index 000000000..bdb821e09 Binary files /dev/null and b/resources/union_faces.png differ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index f0bfad5a7..20236ddfc 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -159,6 +159,10 @@ ICON_DLG_FUSE_EDGES fuse_collinear_edges.png + + ICON_DLG_UNION_FACES + union_faces.png + ICON_DLG_CHECKSHAPE check.png @@ -1019,6 +1023,10 @@ ICO_FUSE_EDGES fuse_collinear_edges.png + + ICO_UNION_FACES + union_faces.png + ICO_NORMALE normale.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 42cd00013..b35e64ea1 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -4554,6 +4554,30 @@ Please, select face, shell or solid and try again STB_FUSE_EDGES Fuse collinear edges within a wire + + GEOM_UNION_FACES_TITLE + Union faces + + + GEOM_UNION_FACES + Object to unite faces + + + UNION_FACES_NEW_OBJ_NAME + UnionFaces + + + TOP_UNION_FACES + Union faces + + + MEN_UNION_FACES + Union Faces + + + STB_UNION_FACES + Union faces + TOP_NORMALE Normal to a face diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index de3a7b815..4e4517aa7 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -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 ); diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index d170eec02..e6af05e8b 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -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 diff --git a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx index b0838a1b0..19aec6cec 100644 --- a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx @@ -39,6 +39,7 @@ #include //#include #include +#include #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; } diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx index 274c82e00..7f6149da3 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -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 diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx index 1ede9b6db..86c8a0380 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx @@ -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, diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 7a116ddf4..105de5d2a 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -342,6 +342,7 @@ #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 diff --git a/src/GEOM_I/GEOM_IBlocksOperations_i.cc b/src/GEOM_I/GEOM_IBlocksOperations_i.cc index b25c0d164..59fd46546 100644 --- a/src/GEOM_I/GEOM_IBlocksOperations_i.cc +++ b/src/GEOM_I/GEOM_IBlocksOperations_i.cc @@ -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 diff --git a/src/GEOM_I/GEOM_IBlocksOperations_i.hh b/src/GEOM_I/GEOM_IBlocksOperations_i.hh index a66e64458..c6e23ae96 100644 --- a/src/GEOM_I/GEOM_IBlocksOperations_i.hh +++ b/src/GEOM_I/GEOM_IBlocksOperations_i.hh @@ -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 diff --git a/src/GEOM_SWIG/GEOM_TestOthers.py b/src/GEOM_SWIG/GEOM_TestOthers.py index 0a8ab0413..4153bb6a6 100644 --- a/src/GEOM_SWIG/GEOM_TestOthers.py +++ b/src/GEOM_SWIG/GEOM_TestOthers.py @@ -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"]) diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 05e3d674f..249379505 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -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. diff --git a/src/RepairGUI/Makefile.am b/src/RepairGUI/Makefile.am index f81255c8f..6b267669a 100644 --- a/src/RepairGUI/Makefile.am +++ b/src/RepairGUI/Makefile.am @@ -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 = \ diff --git a/src/RepairGUI/RepairGUI.cxx b/src/RepairGUI/RepairGUI.cxx index 5def07491..e2a8dc187 100644 --- a/src/RepairGUI/RepairGUI.cxx +++ b/src/RepairGUI/RepairGUI.cxx @@ -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 index 000000000..e9b4ceabb --- /dev/null +++ b/src/RepairGUI/RepairGUI_UnionFacesDlg.cxx @@ -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 +#include +#include + +#include +#include +#include +#include + +#include + +#include + +//================================================================================= +// 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 index 000000000..ea00f50e6 --- /dev/null +++ b/src/RepairGUI/RepairGUI_UnionFacesDlg.h @@ -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 + +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