From: eap Date: Thu, 16 Oct 2014 10:36:46 +0000 (+0400) Subject: 0022749: [EDF] Improvement of Remove Internal Faces operation X-Git-Tag: V7_6_0a1~60^2~34 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8345fbb56c53324efd8c305b71b4fe63fe16b77e;p=modules%2Fgeom.git 0022749: [EDF] Improvement of Remove Internal Faces operation --- diff --git a/doc/salome/gui/GEOM/images/remove_webs.png b/doc/salome/gui/GEOM/images/remove_webs.png index 951f5a5c5..7f677f423 100644 Binary files a/doc/salome/gui/GEOM/images/remove_webs.png 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 index a2dc78026..eb9fefa03 100644 --- a/doc/salome/gui/GEOM/input/remove_webs_operation.doc +++ b/doc/salome/gui/GEOM/input/remove_webs_operation.doc @@ -5,12 +5,12 @@ \n To Remove internal faces in the Main Menu select Repair - > Remove internal faces. -This operation removes all shared faces from a compound to obtain +This operation removes all shared faces from given solids to obtain one or more bigger solids from a set of smaller solids. \image html remove_webs.png -\n Arguments: Name + one shape. +\n Arguments: Name + one or more shapes containing solids. \n Advanced option: \ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments". @@ -19,8 +19,8 @@ faces will stay as is, use \ref glue_faces_operation_page or \ref partition_page Remove Internal Faces if you need to remove them. \n TUI Command:
-geompy.RemoveInternalFaces( theCompound ),
-where theCompound is a compound of solids. +geompy.RemoveInternalFaces( theSolids ),
+where theSolids is either a compound or a list 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 28bf44819..b53ed10d0 100644 --- a/doc/salome/gui/GEOM/input/repairing_operations.doc +++ b/doc/salome/gui/GEOM/input/repairing_operations.doc @@ -26,7 +26,7 @@ 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 the faces +rebuilds the topology of solids by removing the faces are shared by several solids.
  • \subpage remove_extra_edges_operation_page "Remove extra edges" - removes seam and degenerated edges from the given shape.
  • diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index e4a539f91..354aa3a7a 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -3705,12 +3705,12 @@ module GEOM GEOM_Object SewAllowNonManifold(in ListOfGO theObjects, in double theTolerance); /*! - * Rebuild the topology of theCompound of solids by removing - * of the faces that are shared by several solids. - * \param theCompound Shape to be processed. + * Rebuild the topology of theSolids by removing + * the faces that are shared by several solids. + * \param theSolids A list of shapes containing solids to be processed. * \return New GEOM_Object, containing processed shape. */ - GEOM_Object RemoveInternalFaces (in GEOM_Object theCompound); + GEOM_Object RemoveInternalFaces (in ListOfGO theSolids); /*! * \brief Addition of a point to a given edge object. diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 5d7d875bc..b710fb019 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -4590,7 +4590,7 @@ Please, select face, shell or solid and try again GEOM_REMOVE_WEBS - Compound of solids + Solids REMOVE_WEBS_NEW_OBJ_NAME diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx index 0678df2c7..5cb3b922c 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx @@ -142,7 +142,7 @@ Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const Sew(&HI, anOriginalShape, aShape, true); break; case REMOVE_INTERNAL_FACES: - RemoveInternalFaces(anOriginalShape, aShape); + RemoveInternalFaces(&HI, anOriginalShape, aShape); break; case DIVIDE_EDGE: AddPointOnEdge(&HI, anOriginalShape, aShape); @@ -470,11 +470,44 @@ Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI, //function : RemoveInternalFaces //purpose : //======================================================================= -Standard_Boolean GEOMImpl_HealingDriver::RemoveInternalFaces (const TopoDS_Shape& theOriginalShape, - TopoDS_Shape& theOutShape) const +Standard_Boolean +GEOMImpl_HealingDriver::RemoveInternalFaces (GEOMImpl_IHealing* theHI, + const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) const { + // get all input shapes + TopTools_SequenceOfShape shapeSeq; + shapeSeq.Append( theOriginalShape ); + Handle(TColStd_HSequenceOfTransient) otherObjs = theHI->GetShapes(); + if ( !otherObjs.IsNull() ) + for ( int ind = 1; ind <= otherObjs->Length(); ind++) + { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(otherObjs->Value(ind)); + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) + Standard_NullObject::Raise("Null object given"); + shapeSeq.Append( aShape ); + } + + // pass input shapes to the algorithm GEOMAlgo_RemoverWebs aTool; - aTool.SetShape(theOriginalShape); + if ( shapeSeq.Length() == 1 ) + { + aTool.SetShape( shapeSeq.First() ); + } + else + { + TopoDS_Compound solidCompound; + BRep_Builder builder; + builder.MakeCompound( solidCompound ); + for ( int ind = 1; ind <= shapeSeq.Length(); ++ind ) + for ( TopExp_Explorer so( shapeSeq( ind ), TopAbs_SOLID ); so.More(); so.Next() ) + builder.Add( solidCompound, so.Current() ); + + aTool.SetShape( solidCompound ); + } + + // run the algorithm aTool.Perform(); if (aTool.ErrorStatus() == 0) { // OK @@ -929,7 +962,7 @@ GetCreationInformation(std::string& theOperationName, break; case REMOVE_INTERNAL_FACES: theOperationName = "REMOVE_WEBS"; - AddParam( theParams, "Selected shape", aCI.GetOriginal() ); + AddParam( theParams, "Selected shapes", aCI.GetOriginalAndShapes() ); break; default: return false; diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.hxx b/src/GEOMImpl/GEOMImpl_HealingDriver.hxx index 2da99fa4f..5784acd14 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.hxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.hxx @@ -103,7 +103,7 @@ private: Standard_Boolean RemoveIntWires( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; Standard_Boolean RemoveHoles ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; Standard_Boolean Sew ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape&, Standard_Boolean ) const; - Standard_Boolean RemoveInternalFaces ( const TopoDS_Shape&, TopoDS_Shape& ) const; + Standard_Boolean RemoveInternalFaces ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; Standard_Boolean AddPointOnEdge( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; Standard_Boolean ChangeOrientation( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; void LimitTolerance( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index 9c5d71fff..ab4975aa2 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -652,22 +652,27 @@ GEOMImpl_IHealingOperations::Sew (std::list& theObjects, * RemoveInternalFaces */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveInternalFaces (Handle(GEOM_Object) theObject) +Handle(GEOM_Object) +GEOMImpl_IHealingOperations::RemoveInternalFaces (std::list< Handle(GEOM_Object)> & theSolids) { // set error code, check parameters SetErrorCode(KO); - if (theObject.IsNull()) + if (theSolids.empty()) return NULL; - Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); - if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed + Handle(TColStd_HSequenceOfTransient) objects = GEOM_Object::GetLastFunctions( theSolids ); + if ( objects.IsNull() || objects->IsEmpty() ) { + SetErrorCode("NULL argument shape"); + return NULL; + } // Add a new object Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), GEOM_COPY); //Add the function - aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INTERNAL_FACES); + Handle(GEOM_Function) + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INTERNAL_FACES); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly @@ -675,7 +680,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveInternalFaces (Handle(GEO // prepare "data container" class IHealing GEOMImpl_IHealing HI (aFunction); - HI.SetOriginal(aLastFunction); + HI.SetOriginal( theSolids.front()->GetLastFunction() ); objects->Remove(1); + HI.SetShapes( objects ); //Compute the result try { @@ -693,7 +699,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveInternalFaces (Handle(GEO } //Make a Python command - GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.RemoveInternalFaces(" << theObject << ")"; + GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.RemoveInternalFaces(" << theSolids << ")"; SetErrorCode(OK); return aNewObject; diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx index 7dd25d87f..f8b17b371 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx @@ -74,7 +74,7 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations { double theTolerance, bool isAllowNonManifold); - Standard_EXPORT Handle(GEOM_Object) RemoveInternalFaces (Handle(GEOM_Object) theObject); + Standard_EXPORT Handle(GEOM_Object) RemoveInternalFaces (std::list< Handle(GEOM_Object)> & theSolids); Standard_EXPORT Handle(GEOM_Object) DivideEdge( Handle(GEOM_Object) theObject, int theIndex, diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.cc b/src/GEOM_I/GEOM_IHealingOperations_i.cc index 3876b8159..366875588 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.cc +++ b/src/GEOM_I/GEOM_IHealingOperations_i.cc @@ -377,20 +377,21 @@ GEOM_IHealingOperations_i::SewAllowNonManifold (const GEOM::ListOfGO& theObjects * RemoveInternalFaces */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::RemoveInternalFaces (GEOM::GEOM_Object_ptr theCompound) +GEOM::GEOM_Object_ptr +GEOM_IHealingOperations_i::RemoveInternalFaces (const GEOM::ListOfGO& theSolids) { GEOM::GEOM_Object_var aGEOMObject; // Set a not done flag GetOperations()->SetNotDone(); - // Get the object - Handle(GEOM_Object) anObject = GetObjectImpl(theCompound); - if (anObject.IsNull()) + // Get the objects + std::list< Handle(GEOM_Object) > aShapes; + if (! GetListOfObjectsImpl( theSolids, aShapes )) return aGEOMObject._retn(); // Perform - Handle(GEOM_Object) aNewObject = GetOperations()->RemoveInternalFaces(anObject); + Handle(GEOM_Object) aNewObject = GetOperations()->RemoveInternalFaces(aShapes); if (!GetOperations()->IsDone() || aNewObject.IsNull()) return aGEOMObject._retn(); diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.hh b/src/GEOM_I/GEOM_IHealingOperations_i.hh index 7cbc08d78..04802f639 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.hh +++ b/src/GEOM_I/GEOM_IHealingOperations_i.hh @@ -75,7 +75,7 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i : GEOM::GEOM_Object_ptr SewAllowNonManifold (const GEOM::ListOfGO & theObject, CORBA::Double theTolerance); - GEOM::GEOM_Object_ptr RemoveInternalFaces (GEOM::GEOM_Object_ptr theCompound); + GEOM::GEOM_Object_ptr RemoveInternalFaces (const GEOM::ListOfGO& theSolids); GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject, CORBA::Short theIndex, diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 7d1ab412d..8890b42ca 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -6399,9 +6399,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(anObj, theName, "sewed") return anObj - ## Rebuild the topology of theCompound of solids by removing - # of the faces that are shared by several solids. - # @param theCompound Shape to be processed. + ## Rebuild the topology of theSolids by removing + # the faces that are shared by several solids. + # @param theSolids A compound or a list of solids to be processed. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. @@ -6410,13 +6410,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_remove_webs "Example" @ManageTransactions("HealOp") - def RemoveInternalFaces (self, theCompound, theName=None): + def RemoveInternalFaces (self, theSolids, theName=None): """ - Rebuild the topology of theCompound of solids by removing - of the faces that are shared by several solids. + Rebuild the topology of theSolids by removing + the faces that are shared by several solids. Parameters: - theCompound Shape to be processed. + theSolids A compound or a list of solids to be processed. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. @@ -6425,7 +6425,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing processed shape. """ # Example: see GEOM_TestHealing.py - anObj = self.HealOp.RemoveInternalFaces(theCompound) + anObj = self.HealOp.RemoveInternalFaces(ToList(theSolids)) RaiseIfFailed("RemoveInternalFaces", self.HealOp) self._autoPublish(anObj, theName, "removeWebs") return anObj diff --git a/src/RepairGUI/RepairGUI_RemoveWebsDlg.cxx b/src/RepairGUI/RepairGUI_RemoveWebsDlg.cxx index a0e186719..0d0158646 100755 --- a/src/RepairGUI/RepairGUI_RemoveWebsDlg.cxx +++ b/src/RepairGUI/RepairGUI_RemoveWebsDlg.cxx @@ -63,7 +63,7 @@ RepairGUI_RemoveWebsDlg::RepairGUI_RemoveWebsDlg (GeometryGUI* theGeometryGUI, Q GroupPoints = new DlgRef_1Sel( centralWidget() ); GroupPoints->GroupBox1->setTitle( tr( "GEOM_REMOVE_WEBS" ) ); - GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) ); + GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPES" ) ); GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->LineEdit1->setReadOnly( true ); @@ -141,7 +141,7 @@ bool RepairGUI_RemoveWebsDlg::ClickOnApply() initName(); myEditCurrentArgument->setText(""); - myObject = GEOM::GEOM_Object::_nil(); + myObjects.clear(); myOkObject = false; @@ -158,33 +158,16 @@ bool RepairGUI_RemoveWebsDlg::ClickOnApply() void RepairGUI_RemoveWebsDlg::SelectionIntoArgument() { myEditCurrentArgument->setText( "" ); - QString aName; - - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) - myOkObject = false; - return; - } - } - - // nbSel == 1 - GEOM::GEOM_Object_ptr aSelectedObject = - GEOMBase::ConvertIOinGEOMObject(aSelList.First()); + myObjects.clear(); + myOkObject = false; - if (CORBA::is_nil(aSelectedObject)) - return; + myObjects = getSelected( TopAbs_SHAPE, -1 ); - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - myObject = aSelectedObject; + if ( !myObjects.isEmpty() ) { + QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() ); myOkObject = true; + myEditCurrentArgument->setText( aName ); } - - myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); } //================================================================================= @@ -242,7 +225,7 @@ void RepairGUI_RemoveWebsDlg::enterEvent (QEvent* e) void RepairGUI_RemoveWebsDlg::activateSelection() { TColStd_MapOfInteger aTypes; - //aTypes.Add( GEOM_SOLID ); + aTypes.Add( GEOM_SOLID ); aTypes.Add( GEOM_COMPOUND ); globalSelection( aTypes ); } @@ -271,8 +254,13 @@ bool RepairGUI_RemoveWebsDlg::isValid (QString& msg) //================================================================================= bool RepairGUI_RemoveWebsDlg::execute (ObjectList& objects) { + GEOM::ListOfGO_var objList = new GEOM::ListOfGO; + objList->length( myObjects.count() ); + for ( int i = 0; i < myObjects.count(); ++i ) + objList[i] = myObjects[i].copy(); + GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation()); - GEOM::GEOM_Object_var anObj = anOper->RemoveInternalFaces(myObject); + GEOM::GEOM_Object_var anObj = anOper->RemoveInternalFaces(objList); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); diff --git a/src/RepairGUI/RepairGUI_RemoveWebsDlg.h b/src/RepairGUI/RepairGUI_RemoveWebsDlg.h index 72fd49937..7f04037e5 100755 --- a/src/RepairGUI/RepairGUI_RemoveWebsDlg.h +++ b/src/RepairGUI/RepairGUI_RemoveWebsDlg.h @@ -52,7 +52,7 @@ private: void activateSelection(); private: - GEOM::GEOM_Object_var myObject; + QList myObjects; bool myOkObject; DlgRef_1Sel* GroupPoints;