Regression of SMESH_SRC/doc/salome/examples/measurements_ex01.py

Manage temporary SMESH_IDSource created by MeshEditor::MakeIDSource()
This commit is contained in:
eap 2013-08-07 14:06:39 +00:00
parent 18efd0cad1
commit 5c95ba9078
7 changed files with 99 additions and 17 deletions

View File

@ -58,6 +58,7 @@
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_MeshEditor) #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
@ -352,14 +353,17 @@ bool SMESHGUI_Add0DElemsOnAllNodesOp::onApply()
return false; return false;
// get a mesh // get a mesh
SMESH::SMESH_IDSource_var meshObject; SMESH::SMESH_IDSource_wrap meshObject;
SMESH::SMESH_Mesh_var mesh; SMESH::SMESH_Mesh_var mesh;
if ( !myIO.IsNull() ) if ( !myIO.IsNull() )
{ {
CORBA::Object_var obj = SMESH::IObjectToObject( myIO ); CORBA::Object_var obj = SMESH::IObjectToObject( myIO );
meshObject = SMESH::SMESH_IDSource::_narrow( obj ); meshObject = SMESH::SMESH_IDSource::_narrow( obj );
if ( !meshObject->_is_nil() ) if ( !meshObject->_is_nil() )
{
mesh = meshObject->GetMesh(); mesh = meshObject->GetMesh();
meshObject->Register();
}
} }
if ( mesh->_is_nil() ) if ( mesh->_is_nil() )
{ {

View File

@ -308,10 +308,11 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
try try
{ {
SUIT_OverrideCursor aWaitCursor; SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_IDSource_var aPartToCopy; SMESH::SMESH_IDSource_wrap aPartToCopy;
if ( myIdSourceCheck->isChecked()) if ( myIdSourceCheck->isChecked())
{ {
aPartToCopy = mySelectedObject; aPartToCopy = mySelectedObject;
aPartToCopy->Register();
} }
else else
{ {

View File

@ -519,8 +519,8 @@ void SMESHGUI_MinDistance::secondEdited()
void SMESHGUI_MinDistance::compute() void SMESHGUI_MinDistance::compute()
{ {
SUIT_OverrideCursor wc; SUIT_OverrideCursor wc;
SMESH::SMESH_IDSource_var s1; SMESH::SMESH_IDSource_wrap s1;
SMESH::SMESH_IDSource_var s2; SMESH::SMESH_IDSource_wrap s2;
bool isOrigin = mySecond->checkedId() == OriginTgt; bool isOrigin = mySecond->checkedId() == OriginTgt;
// process first target // process first target
@ -538,6 +538,7 @@ void SMESHGUI_MinDistance::compute()
} }
else { else {
s1 = myFirstSrc; s1 = myFirstSrc;
s1->Register();
} }
} }
@ -556,6 +557,7 @@ void SMESHGUI_MinDistance::compute()
} }
else { else {
s2 = mySecondSrc; s2 = mySecondSrc;
s2->Register();
} }
} }
@ -1035,14 +1037,17 @@ void SMESHGUI_BoundingBox::compute()
} }
else { else {
srcList->length( mySrc.count() ); srcList->length( mySrc.count() );
for( int i = 0; i < mySrc.count(); i++ ) for( int i = 0; i < mySrc.count(); i++ ) {
srcList[i] = mySrc[i]; srcList[i] = mySrc[i];
mySrc[i]->Register();
}
} }
if ( srcList->length() > 0 ) { if ( srcList->length() > 0 ) {
// compute bounding box // compute bounding box
int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 ); int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
SMESH::Measurements_var measure = SMESHGUI::GetSMESHGen()->CreateMeasurements(); SMESH::Measurements_var measure = SMESHGUI::GetSMESHGen()->CreateMeasurements();
SMESH::Measure result = measure->BoundingBox( srcList.in() ); SMESH::Measure result = measure->BoundingBox( srcList.in() );
SALOME::UnRegister( srcList );
measure->UnRegister(); measure->UnRegister();
myXmin->setText( QString::number( result.minX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); myXmin->setText( QString::number( result.minX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
myXmax->setText( QString::number( result.maxX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); myXmax->setText( QString::number( result.maxX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );

View File

@ -1212,7 +1212,7 @@ bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
{ {
if ( hasObj ) if ( hasObj )
return theEditor->QuadTo4Tri( obj ), true; return theEditor->QuadTo4Tri( obj ), true;
SMESH::SMESH_IDSource_var elems = theEditor->MakeIDSource( theIds, SMESH::FACE ); SMESH::SMESH_IDSource_wrap elems = theEditor->MakeIDSource( theIds, SMESH::FACE );
theEditor->QuadTo4Tri( elems ); theEditor->QuadTo4Tri( elems );
return true; return true;
} }
@ -1466,9 +1466,11 @@ bool SMESHGUI_CuttingIntoTetraDlg::process (SMESH::SMESH_MeshEditor_ptr theEdito
const SMESH::long_array& theIds, const SMESH::long_array& theIds,
SMESH::SMESH_IDSource_ptr theObj) SMESH::SMESH_IDSource_ptr theObj)
{ {
SMESH::SMESH_IDSource_var obj = theObj; SMESH::SMESH_IDSource_wrap obj = theObj;
if ( CORBA::is_nil( obj )) if ( CORBA::is_nil( obj ))
obj = theEditor->MakeIDSource( theIds, myEntityType ? SMESH::VOLUME : SMESH::FACE ); obj = theEditor->MakeIDSource( theIds, myEntityType ? SMESH::VOLUME : SMESH::FACE );
else
obj->Register();
try { try {
theEditor->SplitVolumesIntoTetra( obj, myGroupChoice->checkedId()+1 ); theEditor->SplitVolumesIntoTetra( obj, myGroupChoice->checkedId()+1 );
} }
@ -1476,5 +1478,8 @@ bool SMESHGUI_CuttingIntoTetraDlg::process (SMESH::SMESH_MeshEditor_ptr theEdito
SalomeApp_Tools::QtCatchCorbaException( S_ex ); SalomeApp_Tools::QtCatchCorbaException( S_ex );
return false; return false;
} }
catch(...) {
return false;
}
return true; return true;
} }

View File

@ -485,8 +485,9 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL);
myMeshes[0]->SetParameters( aParameters.join( ":" ).toLatin1().constData() ); myMeshes[0]->SetParameters( aParameters.join( ":" ).toLatin1().constData() );
aMeshEditor->Scale(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact, false); aMeshEditor->Scale( src, aPoint, aScaleFact, false);
} }
break; break;
@ -501,8 +502,9 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL);
myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
groups = aMeshEditor->ScaleMakeGroups(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact); groups = aMeshEditor->ScaleMakeGroups( src, aPoint, aScaleFact);
} }
} }
else { else {
@ -515,8 +517,9 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL);
myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
aMeshEditor->Scale(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact, true); aMeshEditor->Scale( src, aPoint, aScaleFact, true);
} }
} }
break; break;
@ -537,7 +540,8 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
mesh = aMeshEditor->ScaleMakeMesh(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact, makeGroups, SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL);
mesh = aMeshEditor->ScaleMakeMesh( src, aPoint, aScaleFact, makeGroups,
LineEditNewMesh->text().toLatin1().data()); LineEditNewMesh->text().toLatin1().data());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
@ -1142,7 +1146,8 @@ void SMESHGUI_ScaleDlg::onDisplaySimulation( bool toDisplayPreview ) {
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer();
aMeshEditor->Scale(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact, copy); SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL);
aMeshEditor->Scale( src, aPoint, aScaleFact, copy);
aMeshPreviewStruct << aMeshEditor->GetPreviewData(); aMeshPreviewStruct << aMeshEditor->GetPreviewData();
} }
setSimulationPreview(aMeshPreviewStruct); setSimulationPreview(aMeshPreviewStruct);

View File

@ -35,6 +35,7 @@
// SALOME KERNEL includes // SALOME KERNEL includes
#include <SALOMEDSClient_definitions.hxx> #include <SALOMEDSClient_definitions.hxx>
#include <SALOME_GenericObj_wrap.hxx>
// SALOME GUI includes // SALOME GUI includes
#include <SALOME_InteractiveObject.hxx> #include <SALOME_InteractiveObject.hxx>
@ -176,6 +177,10 @@ SMESHGUI_EXPORT
SMESHGUI_EXPORT SMESHGUI_EXPORT
gp_XYZ getNormale( const SMDS_MeshFace* theFace ); gp_XYZ getNormale( const SMDS_MeshFace* theFace );
// type to use instead of SMESH_IDSource_var for automatic UnRegister()
typedef SALOME::GenericObj_wrap<SMESH_IDSource> SMESH_IDSource_wrap;
} }
#endif // SMESHGUI_UTILS_H #endif // SMESHGUI_UTILS_H

View File

@ -982,6 +982,7 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
if not hasattr(src1, "_narrow"): return None if not hasattr(src1, "_narrow"): return None
src1 = src1._narrow(SMESH.SMESH_IDSource) src1 = src1._narrow(SMESH.SMESH_IDSource)
if not src1: return None if not src1: return None
unRegister = genObjUnRegister()
if id1 != 0: if id1 != 0:
m = src1.GetMesh() m = src1.GetMesh()
e = m.GetMeshEditor() e = m.GetMeshEditor()
@ -989,6 +990,7 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
src1 = e.MakeIDSource([id1], SMESH.FACE) src1 = e.MakeIDSource([id1], SMESH.FACE)
else: else:
src1 = e.MakeIDSource([id1], SMESH.NODE) src1 = e.MakeIDSource([id1], SMESH.NODE)
unRegister.set( src1 )
pass pass
if hasattr(src2, "_narrow"): if hasattr(src2, "_narrow"):
src2 = src2._narrow(SMESH.SMESH_IDSource) src2 = src2._narrow(SMESH.SMESH_IDSource)
@ -999,11 +1001,12 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
src2 = e.MakeIDSource([id2], SMESH.FACE) src2 = e.MakeIDSource([id2], SMESH.FACE)
else: else:
src2 = e.MakeIDSource([id2], SMESH.NODE) src2 = e.MakeIDSource([id2], SMESH.NODE)
unRegister.set( src2 )
pass pass
pass pass
aMeasurements = self.CreateMeasurements() aMeasurements = self.CreateMeasurements()
unRegister.set( aMeasurements )
result = aMeasurements.MinDistance(src1, src2) result = aMeasurements.MinDistance(src1, src2)
aMeasurements.UnRegister()
return result return result
## Get bounding box of the specified object(s) ## Get bounding box of the specified object(s)
@ -1579,8 +1582,10 @@ class Mesh:
def ExportMED(self, f, auto_groups=0, version=MED_V2_2, def ExportMED(self, f, auto_groups=0, version=MED_V2_2,
overwrite=1, meshPart=None, autoDimension=True): overwrite=1, meshPart=None, autoDimension=True):
if meshPart: if meshPart:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ): if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL ) meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite, autoDimension) self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite, autoDimension)
else: else:
self.mesh.ExportToMEDX(f, auto_groups, version, overwrite, autoDimension) self.mesh.ExportToMEDX(f, auto_groups, version, overwrite, autoDimension)
@ -1600,8 +1605,10 @@ class Mesh:
# @ingroup l2_impexp # @ingroup l2_impexp
def ExportDAT(self, f, meshPart=None): def ExportDAT(self, f, meshPart=None):
if meshPart: if meshPart:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ): if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL ) meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
self.mesh.ExportPartToDAT( meshPart, f ) self.mesh.ExportPartToDAT( meshPart, f )
else: else:
self.mesh.ExportDAT(f) self.mesh.ExportDAT(f)
@ -1612,8 +1619,10 @@ class Mesh:
# @ingroup l2_impexp # @ingroup l2_impexp
def ExportUNV(self, f, meshPart=None): def ExportUNV(self, f, meshPart=None):
if meshPart: if meshPart:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ): if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL ) meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
self.mesh.ExportPartToUNV( meshPart, f ) self.mesh.ExportPartToUNV( meshPart, f )
else: else:
self.mesh.ExportUNV(f) self.mesh.ExportUNV(f)
@ -1625,8 +1634,10 @@ class Mesh:
# @ingroup l2_impexp # @ingroup l2_impexp
def ExportSTL(self, f, ascii=1, meshPart=None): def ExportSTL(self, f, ascii=1, meshPart=None):
if meshPart: if meshPart:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ): if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL ) meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
self.mesh.ExportPartToSTL( meshPart, f, ascii ) self.mesh.ExportPartToSTL( meshPart, f, ascii )
else: else:
self.mesh.ExportSTL(f, ascii) self.mesh.ExportSTL(f, ascii)
@ -1637,8 +1648,10 @@ class Mesh:
# @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
# @ingroup l2_impexp # @ingroup l2_impexp
def ExportCGNS(self, f, overwrite=1, meshPart=None): def ExportCGNS(self, f, overwrite=1, meshPart=None):
unRegister = genObjUnRegister()
if isinstance( meshPart, list ): if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL ) meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
if isinstance( meshPart, Mesh ): if isinstance( meshPart, Mesh ):
meshPart = meshPart.mesh meshPart = meshPart.mesh
elif not meshPart: elif not meshPart:
@ -1652,8 +1665,10 @@ class Mesh:
# @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
# @ingroup l2_impexp # @ingroup l2_impexp
def ExportGMF(self, f, meshPart=None): def ExportGMF(self, f, meshPart=None):
unRegister = genObjUnRegister()
if isinstance( meshPart, list ): if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL ) meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
if isinstance( meshPart, Mesh ): if isinstance( meshPart, Mesh ):
meshPart = meshPart.mesh meshPart = meshPart.mesh
elif not meshPart: elif not meshPart:
@ -2438,7 +2453,7 @@ class Mesh:
aMeasurements = self.smeshpyD.CreateMeasurements() aMeasurements = self.smeshpyD.CreateMeasurements()
aMeasure = aMeasurements.MinDistance(id1, id2) aMeasure = aMeasurements.MinDistance(id1, id2)
aMeasurements.UnRegister() genObjUnRegister([aMeasurements,id1, id2])
return aMeasure return aMeasure
## Get bounding box of the specified object(s) ## Get bounding box of the specified object(s)
@ -2471,6 +2486,7 @@ class Mesh:
if len(IDs) > 0 and isinstance(IDs[0], int): if len(IDs) > 0 and isinstance(IDs[0], int):
IDs = [IDs] IDs = [IDs]
srclist = [] srclist = []
unRegister = genObjUnRegister()
for o in IDs: for o in IDs:
if isinstance(o, Mesh): if isinstance(o, Mesh):
srclist.append(o.mesh) srclist.append(o.mesh)
@ -2483,11 +2499,12 @@ class Mesh:
srclist.append(self.editor.MakeIDSource(o, SMESH.FACE)) srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
else: else:
srclist.append(self.editor.MakeIDSource(o, SMESH.NODE)) srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
unRegister.set( srclist[-1] )
pass pass
pass pass
aMeasurements = self.smeshpyD.CreateMeasurements() aMeasurements = self.smeshpyD.CreateMeasurements()
unRegister.set( aMeasurements )
aMeasure = aMeasurements.BoundingBox(srclist) aMeasure = aMeasurements.BoundingBox(srclist)
aMeasurements.UnRegister()
return aMeasure return aMeasure
# Mesh edition (SMESH_MeshEditor functionality): # Mesh edition (SMESH_MeshEditor functionality):
@ -2540,10 +2557,12 @@ class Mesh:
# can be retrieved from the returned object by calling GetIDs() # can be retrieved from the returned object by calling GetIDs()
# @ingroup l2_modif_add # @ingroup l2_modif_add
def Add0DElementsToAllNodes(self, theObject, theGroupName=""): def Add0DElementsToAllNodes(self, theObject, theGroupName=""):
unRegister = genObjUnRegister()
if isinstance( theObject, Mesh ): if isinstance( theObject, Mesh ):
theObject = theObject.GetMesh() theObject = theObject.GetMesh()
if isinstance( theObject, list ): if isinstance( theObject, list ):
theObject = self.GetIDSource( theObject, SMESH.ALL ) theObject = self.GetIDSource( theObject, SMESH.ALL )
unRegister.set( theObject )
return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName ) return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName )
## Creates a ball element on a node with given ID. ## Creates a ball element on a node with given ID.
@ -2813,11 +2832,13 @@ class Mesh:
# @return number of reoriented faces # @return number of reoriented faces
# @ingroup l2_modif_changori # @ingroup l2_modif_changori
def Reorient2D(self, the2DObject, theDirection, theFaceOrPoint ): def Reorient2D(self, the2DObject, theDirection, theFaceOrPoint ):
unRegister = genObjUnRegister()
# check the2DObject # check the2DObject
if isinstance( the2DObject, Mesh ): if isinstance( the2DObject, Mesh ):
the2DObject = the2DObject.GetMesh() the2DObject = the2DObject.GetMesh()
if isinstance( the2DObject, list ): if isinstance( the2DObject, list ):
the2DObject = self.GetIDSource( the2DObject, SMESH.FACE ) the2DObject = self.GetIDSource( the2DObject, SMESH.FACE )
unRegister.set( the2DObject )
# check theDirection # check theDirection
if isinstance( theDirection, geomBuilder.GEOM._objref_GEOM_Object): if isinstance( theDirection, geomBuilder.GEOM._objref_GEOM_Object):
theDirection = self.smeshpyD.GetDirStruct( theDirection ) theDirection = self.smeshpyD.GetDirStruct( theDirection )
@ -2907,12 +2928,14 @@ class Mesh:
# group or a list of face IDs. By default all quadrangles are split # group or a list of face IDs. By default all quadrangles are split
# @ingroup l2_modif_cutquadr # @ingroup l2_modif_cutquadr
def QuadTo4Tri (self, theElements=[]): def QuadTo4Tri (self, theElements=[]):
unRegister = genObjUnRegister()
if isinstance( theElements, Mesh ): if isinstance( theElements, Mesh ):
theElements = theElements.mesh theElements = theElements.mesh
elif not theElements: elif not theElements:
theElements = self.mesh theElements = self.mesh
elif isinstance( theElements, list ): elif isinstance( theElements, list ):
theElements = self.GetIDSource( theElements, SMESH.FACE ) theElements = self.GetIDSource( theElements, SMESH.FACE )
unRegister.set( theElements )
return self.editor.QuadTo4Tri( theElements ) return self.editor.QuadTo4Tri( theElements )
## Splits quadrangles into triangles. ## Splits quadrangles into triangles.
@ -2952,10 +2975,12 @@ class Mesh:
# Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
# @ingroup l2_modif_cutquadr # @ingroup l2_modif_cutquadr
def SplitVolumesIntoTetra(self, elemIDs, method=smeshBuilder.Hex_5Tet ): def SplitVolumesIntoTetra(self, elemIDs, method=smeshBuilder.Hex_5Tet ):
unRegister = genObjUnRegister()
if isinstance( elemIDs, Mesh ): if isinstance( elemIDs, Mesh ):
elemIDs = elemIDs.GetMesh() elemIDs = elemIDs.GetMesh()
if ( isinstance( elemIDs, list )): if ( isinstance( elemIDs, list )):
elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME) elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
unRegister.set( elemIDs )
self.editor.SplitVolumesIntoTetra(elemIDs, method) self.editor.SplitVolumesIntoTetra(elemIDs, method)
## Splits quadrangle faces near triangular facets of volumes ## Splits quadrangle faces near triangular facets of volumes
@ -3226,12 +3251,14 @@ class Mesh:
# @ingroup l2_modif_edit # @ingroup l2_modif_edit
def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="", def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
toCopyElements=False, toCopyExistingBondary=False): toCopyElements=False, toCopyExistingBondary=False):
unRegister = genObjUnRegister()
if isinstance( elements, Mesh ): if isinstance( elements, Mesh ):
elements = elements.GetMesh() elements = elements.GetMesh()
if ( isinstance( elements, list )): if ( isinstance( elements, list )):
elemType = SMESH.ALL elemType = SMESH.ALL
if elements: elemType = self.GetElementType( elements[0], iselem=True) if elements: elemType = self.GetElementType( elements[0], iselem=True)
elements = self.editor.MakeIDSource(elements, elemType) elements = self.editor.MakeIDSource(elements, elemType)
unRegister.set( elements )
mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName, mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
toCopyElements,toCopyExistingBondary) toCopyElements,toCopyExistingBondary)
if mesh: mesh = self.smeshpyD.Mesh(mesh) if mesh: mesh = self.smeshpyD.Mesh(mesh)
@ -3914,10 +3941,12 @@ class Mesh:
# @return list of created groups (SMESH_GroupBase) if MakeGroups=True, # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
# empty list otherwise # empty list otherwise
def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False): def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
unRegister = genObjUnRegister()
if ( isinstance( theObject, Mesh )): if ( isinstance( theObject, Mesh )):
theObject = theObject.GetMesh() theObject = theObject.GetMesh()
if ( isinstance( theObject, list )): if ( isinstance( theObject, list )):
theObject = self.GetIDSource(theObject, SMESH.ALL) theObject = self.GetIDSource(theObject, SMESH.ALL)
unRegister.set( theObject )
if ( isinstance( theScaleFact, float )): if ( isinstance( theScaleFact, float )):
theScaleFact = [theScaleFact] theScaleFact = [theScaleFact]
if ( isinstance( theScaleFact, int )): if ( isinstance( theScaleFact, int )):
@ -3938,10 +3967,12 @@ class Mesh:
# @param NewMeshName - the name of the newly created mesh # @param NewMeshName - the name of the newly created mesh
# @return instance of Mesh class # @return instance of Mesh class
def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""): def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
unRegister = genObjUnRegister()
if (isinstance(theObject, Mesh)): if (isinstance(theObject, Mesh)):
theObject = theObject.GetMesh() theObject = theObject.GetMesh()
if ( isinstance( theObject, list )): if ( isinstance( theObject, list )):
theObject = self.GetIDSource(theObject,SMESH.ALL) theObject = self.GetIDSource(theObject,SMESH.ALL)
unRegister.set( theObject )
if ( isinstance( theScaleFact, float )): if ( isinstance( theScaleFact, float )):
theScaleFact = [theScaleFact] theScaleFact = [theScaleFact]
if ( isinstance( theScaleFact, int )): if ( isinstance( theScaleFact, int )):
@ -4050,12 +4081,14 @@ class Mesh:
# @return the list of groups of nodes # @return the list of groups of nodes
# @ingroup l2_modif_trsf # @ingroup l2_modif_trsf
def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]): def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
unRegister = genObjUnRegister()
if (isinstance( SubMeshOrGroup, Mesh )): if (isinstance( SubMeshOrGroup, Mesh )):
SubMeshOrGroup = SubMeshOrGroup.GetMesh() SubMeshOrGroup = SubMeshOrGroup.GetMesh()
if not isinstance( exceptNodes, list): if not isinstance( exceptNodes, list):
exceptNodes = [ exceptNodes ] exceptNodes = [ exceptNodes ]
if exceptNodes and isinstance( exceptNodes[0], int): if exceptNodes and isinstance( exceptNodes[0], int):
exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)] exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
unRegister.set( exceptNodes )
return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes) return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
## Merges nodes ## Merges nodes
@ -4166,10 +4199,12 @@ class Mesh:
# @return a group where the new elements are added. None if theGroupName == "". # @return a group where the new elements are added. None if theGroupName == "".
# @ingroup l2_modif_edit # @ingroup l2_modif_edit
def DoubleElements(self, theElements, theGroupName=""): def DoubleElements(self, theElements, theGroupName=""):
unRegister = genObjUnRegister()
if isinstance( theElements, Mesh ): if isinstance( theElements, Mesh ):
theElements = theElements.mesh theElements = theElements.mesh
elif isinstance( theElements, list ): elif isinstance( theElements, list ):
theElements = self.GetIDSource( theElements, SMESH.ALL ) theElements = self.GetIDSource( theElements, SMESH.ALL )
unRegister.set( theElements )
return self.editor.DoubleElements(theElements, theGroupName) return self.editor.DoubleElements(theElements, theGroupName)
## Creates a hole in a mesh by doubling the nodes of some particular elements ## Creates a hole in a mesh by doubling the nodes of some particular elements
@ -4525,6 +4560,28 @@ class hypMethodWrapper:
raise ValueError, detail # wrong variable name raise ValueError, detail # wrong variable name
return result return result
pass
# A helper class that call UnRegister() of SALOME.GenericObj'es stored in it
class genObjUnRegister:
def __init__(self, genObj=None):
self.genObjList = []
self.set( genObj )
return
def set(self, genObj):
"Store one or a list of of SALOME.GenericObj'es"
if isinstance( genObj, list ):
self.genObjList.extend( genObj )
else:
self.genObjList.append( genObj )
return
def __del__(self):
for genObj in self.genObjList:
if genObj and hasattr( genObj, "UnRegister" ):
genObj.UnRegister()
for pluginName in os.environ[ "SMESH_MeshersList" ].split( ":" ): for pluginName in os.environ[ "SMESH_MeshersList" ].split( ":" ):
# #