-// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//=============================================================================
void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy )
+{
+ setCurrentStudy( theStudy );
+}
+
+void SMESH_Gen_i::setCurrentStudy( SALOMEDS::Study_ptr theStudy,
+ bool theStudyIsBeingClosed)
{
int curStudyId = GetCurrentStudyID();
myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy );
}
// myCurrentStudy may be nil
- if ( !CORBA::is_nil( myCurrentStudy ) ) {
+ if ( !theStudyIsBeingClosed && !CORBA::is_nil( myCurrentStudy ) ) {
SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
if( !myCurrentStudy->FindComponent( "GEOM" )->_is_nil() )
aStudyBuilder->LoadWith( myCurrentStudy->FindComponent( "GEOM" ), GetGeomEngine() );
if ( strcmp(name, "historical_python_dump") == 0 )
{
myIsHistoricalPythonDump = ( value[0] == '1' || toupper(value[0]) == 'T' ); // 1 || true
- msgToGUI = "preferences:SMESH:historical_python_dump:";
+ msgToGUI = "preferences/SMESH/historical_python_dump/";
msgToGUI += myIsHistoricalPythonDump ? "true" : "false";
}
else if ( strcmp(name, "forget_mesh_on_hyp_modif") == 0 )
{
myToForgetMeshDataOnHypModif = ( value[0] == '1' || toupper(value[0]) == 'T' ); // 1 || true
- msgToGUI = "preferences:SMESH:forget_mesh_on_hyp_modif:";
+ msgToGUI = "preferences/SMESH/forget_mesh_on_hyp_modif/";
msgToGUI += myToForgetMeshDataOnHypModif ? "true" : "false";
}
int anNbEdges = 0;
int anNbFaces = 0;
int anNbVolumes = 0;
+ int aNbBalls = 0;
SMESH::long_array_var anIDsNodes = new SMESH::long_array();
SMESH::long_array_var anIDsEdges = new SMESH::long_array();
SMESH::long_array_var anIDsFaces = new SMESH::long_array();
SMESH::long_array_var anIDsVolumes = new SMESH::long_array();
+ SMESH::long_array_var anIDsBalls = new SMESH::long_array();
if( theCommonGroups ) {
anIDsNodes->length( anInitMeshDS->NbNodes() );
anIDsEdges->length( anInitMeshDS->NbEdges() );
anIDsFaces->length( anInitMeshDS->NbFaces() );
anIDsVolumes->length( anInitMeshDS->NbVolumes() );
+ anIDsBalls->length( anInitMeshDS->NbBalls() );
}
for ( int j = 0; itElems->more(); j++) {
}//nodes loop
// creates a corresponding element on existent nodes in new mesh
- if ( anElem->IsPoly() && anElemType == SMDSAbs_Volume )
+ switch ( anElem->GetEntityType() ) {
+ case SMDSEntity_Polyhedra:
+ if ( const SMDS_VtkVolume* aVolume =
+ dynamic_cast<const SMDS_VtkVolume*> (anElem))
+ {
+ aNewElem = aNewMeshDS->AddPolyhedralVolume(aNodesArray,
+ aVolume->GetQuantities());
+ elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
+ if( theCommonGroups )
+ anIDsVolumes[anNbVolumes++] = aNewElem->GetID();
+ }
+ break;
+ case SMDSEntity_Ball:
+ if ( const SMDS_BallElement* aBall =
+ dynamic_cast<const SMDS_BallElement*> (anElem))
{
- const SMDS_VtkVolume* aVolume =
- dynamic_cast<const SMDS_VtkVolume*> (anElem);
- if ( aVolume ) {
- aNewElem = aNewMeshDS->AddPolyhedralVolume(aNodesArray,
- aVolume->GetQuantities());
- elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
- if( theCommonGroups )
+ aNewElem = aNewEditor.AddElement(aNodesArray, SMDSAbs_Ball,
+ /*isPoly=*/false, /*id=*/0,
+ aBall->GetDiameter() );
+ elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
+ if( theCommonGroups )
+ anIDsBalls[aNbBalls++] = aNewElem->GetID();
+ }
+ break;
+ default:
+ {
+ aNewElem = aNewEditor.AddElement(aNodesArray,
+ anElemType,
+ anElem->IsPoly());
+ elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
+ if( theCommonGroups ) {
+ if( anElemType == SMDSAbs_Edge )
+ anIDsEdges[anNbEdges++] = aNewElem->GetID();
+ else if( anElemType == SMDSAbs_Face )
+ anIDsFaces[anNbFaces++] = aNewElem->GetID();
+ else if( anElemType == SMDSAbs_Volume )
anIDsVolumes[anNbVolumes++] = aNewElem->GetID();
}
}
- else {
-
- aNewElem = aNewEditor.AddElement(aNodesArray,
- anElemType,
- anElem->IsPoly());
- elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
- if( theCommonGroups ) {
- if( anElemType == SMDSAbs_Edge )
- anIDsEdges[anNbEdges++] = aNewElem->GetID();
- else if( anElemType == SMDSAbs_Face )
- anIDsFaces[anNbFaces++] = aNewElem->GetID();
- else if( anElemType == SMDSAbs_Volume )
- anIDsVolumes[anNbVolumes++] = aNewElem->GetID();
- }
}
}//elems loop
SMESH::ElementType aGroupType;
CORBA::String_var aGroupName;
if ( theCommonGroups ) {
- for(aGroupType=SMESH::NODE;aGroupType<=SMESH::VOLUME;aGroupType=(SMESH::ElementType)(aGroupType+1)) {
+ for(aGroupType=SMESH::NODE;aGroupType<=SMESH::BALL;aGroupType=(SMESH::ElementType)(aGroupType+1)) {
string str = "Gr";
SALOMEDS::SObject_var aMeshSObj = ObjectToSObject( myCurrentStudy, anInitMesh );
if(aMeshSObj)
anIDsVolumes->length(anNbVolumes);
anLen = anNbVolumes;
break;
+ case SMESH::BALL:
+ str += "Balls";
+ anIDsBalls->length(aNbBalls);
+ anLen = aNbBalls;
+ break;
default:
break;
}
case SMESH::VOLUME:
aNewGroup->Add( anIDsVolumes );
break;
+ case SMESH::BALL:
+ aNewGroup->Add( anIDsBalls );
+ break;
default:
break;
}
// IPAL21468 Change icon of compound because it need not be computed.
SALOMEDS::SObject_var aMeshSObj = ObjectToSObject( myCurrentStudy, aNewMesh );
- if( !aMeshSObj->_is_nil() ) {
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::StudyBuilder_var aBuilder = myCurrentStudy->NewBuilder();
- anAttr = aBuilder->FindOrCreateAttribute( aMeshSObj,"AttributePixMap" );
- SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
- aPixmap->SetPixMap("ICON_SMESH_TREE_MESH");
- }
+ SetPixMap( aMeshSObj, "ICON_SMESH_TREE_MESH" );
+
if (aNewMeshDS)
aNewMeshDS->Modified();
return aNewMesh._retn();
while ( srcElemIt->more() )
{
const SMDS_MeshElement * elem = srcElemIt->next();
+ // find / add nodes
nodes.resize( elem->NbNodes());
SMDS_ElemIteratorPtr nIt = elem->nodesIterator();
if ( toKeepIDs ) {
nodes[ iN ] = (const SMDS_MeshNode*) n2n->second;
}
}
+ // add elements
if ( elem->GetType() != SMDSAbs_Node )
{
int ID = toKeepIDs ? elem->GetID() : 0;
const SMDS_MeshElement * newElem;
- if ( elem->GetEntityType() == SMDSEntity_Polyhedra )
+ switch ( elem->GetEntityType() ) {
+ case SMDSEntity_Polyhedra:
newElem = editor.GetMeshDS()->
AddPolyhedralVolumeWithID( nodes,
static_cast<const SMDS_VtkVolume*>(elem)->GetQuantities(),
- elem->GetID());
- else
+ ID);
+ break;
+ case SMDSEntity_Ball:
+ newElem = editor.AddElement( nodes, SMDSAbs_Ball, false, ID,
+ static_cast<const SMDS_BallElement*>(elem)->GetDiameter());
+ break;
+ default:
newElem = editor.AddElement( nodes,elem->GetType(),elem->IsPoly(),ID);
if ( toCopyGroups && !toKeepIDs )
e2eMapByType[ elem->GetType() ].insert( make_pair( elem, newElem ));
+ }
}
- }
+ } // while ( srcElemIt->more() )
// 4(b). Copy free nodes
// groups root sub-branch
SALOMEDS::SObject_var myGroupsBranch;
- for ( int i = GetNodeGroupsTag(); i <= Get0DElementsGroupsTag(); i++ ) {
+ for ( int i = GetNodeGroupsTag(); i <= GetBallElementsGroupsTag(); i++ ) {
found = gotBranch->FindSubObject( i, myGroupsBranch );
if ( found ) {
char name_group[ 30 ];
strcpy( name_group, "Groups of Volumes" );
else if ( i == Get0DElementsGroupsTag() )
strcpy( name_group, "Groups of 0D Elements" );
+ else if ( i == GetBallElementsGroupsTag() )
+ strcpy( name_group, "Groups of Balls" );
aGroup = new HDFgroup( name_group, aTopGroup );
aGroup->CreateOnDisk();
}
}
- // issue 0020693. Restore _isModified flag
- if( aTopGroup->ExistInternalObject( "_isModified" ) )
- {
- aDataset = new HDFdataset( "_isModified", aTopGroup );
- aDataset->OpenOnDisk();
- size = aDataset->GetSize();
- int* isModified = new int[ size ];
- aDataset->ReadFromDisk( isModified );
- aDataset->CloseOnDisk();
- myNewMeshImpl->GetImpl().SetIsModified( bool(*isModified));
- }
-
// issue 20918. Restore Persistent Id of SMESHDS_Mesh
if( aTopGroup->ExistInternalObject( "meshPersistentId" ) )
{
}
// try to get GROUPS
- for ( int ii = GetNodeGroupsTag(); ii <= Get0DElementsGroupsTag(); ii++ ) {
+ for ( int ii = GetNodeGroupsTag(); ii <= GetBallElementsGroupsTag(); ii++ ) {
char name_group[ 30 ];
if ( ii == GetNodeGroupsTag() )
strcpy( name_group, "Groups of Nodes" );
strcpy( name_group, "Groups of Volumes" );
else if ( ii == Get0DElementsGroupsTag() )
strcpy( name_group, "Groups of 0D Elements" );
+ else if ( ii == GetBallElementsGroupsTag() )
+ strcpy( name_group, "Groups of Balls" );
if ( aTopGroup->ExistInternalObject( name_group ) ) {
aGroup = new HDFgroup( name_group, aTopGroup );
// set correct current study
SALOMEDS::Study_var study = theComponent->GetStudy();
if ( study->StudyId() != GetCurrentStudyID())
- SetCurrentStudy( study );
+ setCurrentStudy( study, /*IsBeingClosed=*/true );
// Clear study contexts data
int studyId = GetCurrentStudyID();