0022749: [EDF] Improvement of Remove Internal Faces operation

This commit is contained in:
eap 2014-10-16 14:36:46 +04:00 committed by vsr
parent dff9617e4b
commit 8345fbb56c
14 changed files with 94 additions and 66 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -5,12 +5,12 @@
\n To <b>Remove internal faces</b> in the <b>Main Menu</b> select
<b>Repair - > Remove internal faces</b>.
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 <b>Arguments:</b> Name + one shape.
\n <b>Arguments:</b> Name + one or more shapes containing solids.
\n <b>Advanced option:</b>
\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
<b>Remove Internal Faces</b> if you need to remove them.
\n <b>TUI Command:</b> <br>
<em>geompy.RemoveInternalFaces( theCompound )</em>,<br>
where <em>theCompound</em> is a compound of solids.
<em>geompy.RemoveInternalFaces( theSolids )</em>,<br>
where <em>theSolids</em> is either a compound or a list of solids.
\n Our <b>TUI Scripts</b> provide you with useful examples of the
\ref tui_remove_webs "Remove Internal Faces" functionality usage.

View File

@ -26,7 +26,7 @@ splits an edge in two.</li>
<li>\subpage change_orientation_operation_page "Change orientation" -
reverses the normals of the selected faces.</li>
<li>\subpage remove_webs_operation_page "Remove internal faces" -
rebuilds the topology of a compound of solids by removing the faces
rebuilds the topology of solids by removing the faces
are shared by several solids.</li>
<li>\subpage remove_extra_edges_operation_page "Remove extra edges" -
removes seam and degenerated edges from the given shape.</li>

View File

@ -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.

View File

@ -4590,7 +4590,7 @@ Please, select face, shell or solid and try again</translation>
</message>
<message>
<source>GEOM_REMOVE_WEBS</source>
<translation>Compound of solids</translation>
<translation>Solids</translation>
</message>
<message>
<source>REMOVE_WEBS_NEW_OBJ_NAME</source>

View File

@ -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,
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;

View File

@ -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;

View File

@ -652,21 +652,26 @@ GEOMImpl_IHealingOperations::Sew (std::list<Handle(GEOM_Object)>& 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
Handle(GEOM_Function)
aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INTERNAL_FACES);
if (aFunction.IsNull()) return NULL;
@ -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;

View File

@ -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,

View File

@ -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();

View File

@ -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,

View File

@ -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

View File

@ -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)
myObjects.clear();
myOkObject = false;
return;
}
}
// nbSel == 1
GEOM::GEOM_Object_ptr aSelectedObject =
GEOMBase::ConvertIOinGEOMObject(aSelList.First());
myObjects = getSelected( TopAbs_SHAPE, -1 );
if (CORBA::is_nil(aSelectedObject))
return;
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());

View File

@ -52,7 +52,7 @@ private:
void activateSelection();
private:
GEOM::GEOM_Object_var myObject;
QList<GEOM::GeomObjPtr> myObjects;
bool myOkObject;
DlgRef_1Sel* GroupPoints;