From: jfa Date: Fri, 14 Jun 2013 12:20:21 +0000 (+0000) Subject: Mantis issue 0021934: Delete the internal faces of an object X-Git-Tag: BR_hydro_v_0_3_1~203 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8fe997ae8897c5945c15e276f82f143dbdfb9321;p=modules%2Fgeom.git Mantis issue 0021934: Delete the internal faces of an object --- diff --git a/doc/salome/examples/Makefile.am b/doc/salome/examples/Makefile.am index 171c03674..211c7932e 100644 --- a/doc/salome/examples/Makefile.am +++ b/doc/salome/examples/Makefile.am @@ -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 index 000000000..80a814a30 --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex12.py @@ -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 index 000000000..951f5a5c5 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 index 000000000..8c91ae20b --- /dev/null +++ b/doc/salome/gui/GEOM/input/remove_webs_operation.doc @@ -0,0 +1,27 @@ +/*! + +\page remove_webs_operation_page Remove Internal Faces + +\n To Remove internal faces in the Main Menu select +Repair - > Remove internal faces. + +\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 Arguments: Name + one shape. +\n Advanced option: + \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 TUI Command: geompy.RemoveInternalFaces(theCompound), +where theCompound is a compound of solids. + +\n Our TUI Scripts provide you with useful examples of the +\ref tui_remove_webs "Remove Internal Faces" functionality usage. + +*/ diff --git a/doc/salome/gui/GEOM/input/repairing_operations.doc b/doc/salome/gui/GEOM/input/repairing_operations.doc index cf0239a6f..4cbb1ed1b 100644 --- a/doc/salome/gui/GEOM/input/repairing_operations.doc +++ b/doc/salome/gui/GEOM/input/repairing_operations.doc @@ -25,6 +25,9 @@ to set new tolerance value for the given shape. splits an edge in two.
  • \subpage change_orientation_operation_page "Change orientation" - reverses the normals of the selected faces.
  • +
  • \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.
  • \subpage remove_extra_edges_operation_page "Remove extra edges" - removes seam and degenerated edges from the given shape.
  • \subpage fuse_edges_operation_page "Fuse Collinear Edges within a Wire" - diff --git a/doc/salome/gui/GEOM/input/tui_repairing_operations.doc b/doc/salome/gui/GEOM/input/tui_repairing_operations.doc index 711800caa..b883afe8a 100644 --- a/doc/salome/gui/GEOM/input/tui_repairing_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_repairing_operations.doc @@ -46,4 +46,8 @@

    Fuse Collinear Edges within a Wire

    \tui_script{repairing_operations_ex11.py} +\anchor tui_remove_webs +

    Remove internal(shared) faces

    +\tui_script{repairing_operations_ex12.py} + */ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index edfbc0d77..2ed2f671c 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -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. diff --git a/resources/Makefile.am b/resources/Makefile.am index ee3fe1bff..b36757b3b 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -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 index 000000000..80b4b4758 Binary files /dev/null and b/resources/remove_webs.png differ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 973909fdd..1ff0697a7 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -151,6 +151,10 @@ ICON_DLG_CHANGE_DIRECTION change_direction.png + + ICON_DLG_REMOVE_WEBS + remove_webs.png + ICON_DLG_REMOVE_EXTRA_EDGES remove_extra_edges.png @@ -1015,6 +1019,10 @@ ICO_PLANE plane.png + + ICO_REMOVE_WEBS + remove_webs.png + ICO_REMOVE_EXTRA_EDGES remove_extra_edges.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 0c5eef603..a9fd206ed 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -1576,10 +1576,6 @@ Please, select face, shell or solid and try again GEOM_REMOVE_INTERNAL_WIRES_TITLE Suppress internal wires - - GEOM_REMOVE_WEBS - Remove webs - GEOM_REQUIRED_DEGREE Required degree @@ -4508,6 +4504,30 @@ Please, select face, shell or solid and try again GEOM_CENTER_2POINTS Center and two points + + GEOM_REMOVE_WEBS_TITLE + Remove internal faces + + + GEOM_REMOVE_WEBS + Compound of solids + + + REMOVE_WEBS_NEW_OBJ_NAME + NoInternalFaces + + + TOP_REMOVE_WEBS + Remove internal faces + + + MEN_REMOVE_WEBS + Remove Internal Faces + + + STB_REMOVE_WEBS + Remove internal faces + GEOM_REMOVE_EXTRA_EDGES_TITLE Remove extra edges diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index 677b77742..2a5a9ce62 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -1574,10 +1574,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau GEOM_REMOVE_INTERNAL_WIRES_TITLE Supprimer les contours internes - - GEOM_REMOVE_WEBS - Supprimer les toiles - GEOM_REQUIRED_DEGREE Degré nécessaire @@ -4506,6 +4502,30 @@ Choisissez une face, une coque ou un solide et essayez de nouveau GEOM_CENTER_2POINTS Centre et deux points + + GEOM_REMOVE_WEBS_TITLE + Remove internal faces + + + GEOM_REMOVE_WEBS + Compound of solids + + + REMOVE_WEBS_NEW_OBJ_NAME + NoInternalFaces + + + TOP_REMOVE_WEBS + Remove internal faces + + + MEN_REMOVE_WEBS + Remove Internal Faces + + + STB_REMOVE_WEBS + Remove internal faces + GEOM_REMOVE_EXTRA_EDGES_TITLE Supprimer les arêtes inutiles diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 19f277735..4404927c4 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -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 ); diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index bdfed0980..04b339917 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -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 diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx index d77e25f20..7010b0e33 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx @@ -30,6 +30,9 @@ #include #include +#include +#include + #include #include #include @@ -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 : diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.hxx b/src/GEOMImpl/GEOMImpl_HealingDriver.hxx index d75796612..83dacd6fa 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.hxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.hxx @@ -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; diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index 98f56bf19..e0dd6ba6e 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -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 diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx index 37f1b90f4..b194c61e4 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx @@ -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, diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 2a4a2e91f..77b8a880e 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -301,8 +301,9 @@ #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 diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.cc b/src/GEOM_I/GEOM_IHealingOperations_i.cc index 195b4a3a0..c7363fe9e 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.cc +++ b/src/GEOM_I/GEOM_IHealingOperations_i.cc @@ -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 diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.hh b/src/GEOM_I/GEOM_IHealingOperations_i.hh index 45a85df62..929028005 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.hh +++ b/src/GEOM_I/GEOM_IHealingOperations_i.hh @@ -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, diff --git a/src/GEOM_SWIG/GEOM_TestHealing.py b/src/GEOM_SWIG/GEOM_TestHealing.py index e503ab297..9d711ed68 100644 --- a/src/GEOM_SWIG/GEOM_TestHealing.py +++ b/src/GEOM_SWIG/GEOM_TestHealing.py @@ -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) diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index b60b70532..7f309b0f2 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -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 diff --git a/src/RepairGUI/Makefile.am b/src/RepairGUI/Makefile.am index 6b267669a..adec8540e 100644 --- a/src/RepairGUI/Makefile.am +++ b/src/RepairGUI/Makefile.am @@ -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 = \ diff --git a/src/RepairGUI/RepairGUI.cxx b/src/RepairGUI/RepairGUI.cxx index e2a8dc187..860459574 100644 --- a/src/RepairGUI/RepairGUI.cxx +++ b/src/RepairGUI/RepairGUI.cxx @@ -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 index 000000000..56fcf6d50 --- /dev/null +++ b/src/RepairGUI/RepairGUI_RemoveWebsDlg.cxx @@ -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 +#include +#include + +#include +#include +#include +#include + +#include + +#include + +//================================================================================= +// 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 index 000000000..9aee4d9ae --- /dev/null +++ b/src/RepairGUI/RepairGUI_RemoveWebsDlg.h @@ -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 + +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