- // groups root sub-branch
- SALOMEDS::SObject_var myGroupsBranch;
- for ( int i = GetNodeGroupsTag(); i <= GetVolumeGroupsTag(); i++ ) {
- found = gotBranch->FindSubObject( i, myGroupsBranch );
- if ( found ) {
- char name_group[ 30 ];
- if ( i == GetNodeGroupsTag() )
- strcpy( name_group, "Groups of Nodes" );
- else if ( i == GetEdgeGroupsTag() )
- strcpy( name_group, "Groups of Edges" );
- else if ( i == GetFaceGroupsTag() )
- strcpy( name_group, "Groups of Faces" );
- else if ( i == GetVolumeGroupsTag() )
- strcpy( name_group, "Groups of Volumes" );
-
- aGroup = new HDFgroup( name_group, aTopGroup );
- aGroup->CreateOnDisk();
-
- SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myGroupsBranch );
- for ( ; it->More(); it->Next() ) {
- SALOMEDS::SObject_var mySObject = it->Value();
- CORBA::Object_var aSubObject = SObjectToObject( mySObject );
- if ( !CORBA::is_nil( aSubObject ) ) {
- SMESH_GroupBase_i* myGroupImpl =
- dynamic_cast<SMESH_GroupBase_i*>( GetServant( aSubObject ).in() );
- if ( !myGroupImpl )
- continue;
-
- CORBA::String_var objStr = GetORB()->object_to_string( aSubObject );
- int anId = myStudyContext->findId( string( objStr.in() ) );
-
- // For each group, create a dataset named "Group <group_persistent_id>"
- // and store the group's user name into it
- char grpName[ 30 ];
- sprintf( grpName, "Group %d", anId );
- char* aUserName = myGroupImpl->GetName();
- aSize[ 0 ] = strlen( aUserName ) + 1;
-
- aDataset = new HDFdataset( grpName, aGroup, HDF_STRING, aSize, 1 );
- aDataset->CreateOnDisk();
- aDataset->WriteOnDisk( aUserName );
- aDataset->CloseOnDisk();
-
- // ouv : NPAL12872
- // For each group, create a dataset named "Group <group_persistent_id> Color"
- // and store the group's color into it
- char grpColorName[ 30 ];
- sprintf( grpColorName, "ColorGroup %d", anId );
- SALOMEDS::Color aColor = myGroupImpl->GetColor();
- double anRGB[3];
- anRGB[ 0 ] = aColor.R;
- anRGB[ 1 ] = aColor.G;
- anRGB[ 2 ] = aColor.B;
- aSize[ 0 ] = 3;
- aDataset = new HDFdataset( grpColorName, aGroup, HDF_FLOAT64, aSize, 1 );
- aDataset->CreateOnDisk();
- aDataset->WriteOnDisk( anRGB );
- aDataset->CloseOnDisk();
-
- // Store the group contents into MED file
- if ( myLocMesh.GetGroup( myGroupImpl->GetLocalID() ) ) {
-
- if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen_i::Save(): saving group with StoreName = "
- << grpName << " to MED file" );
- SMESHDS_GroupBase* aGrpBaseDS =
- myLocMesh.GetGroup( myGroupImpl->GetLocalID() )->GetGroupDS();
- aGrpBaseDS->SetStoreName( grpName );
-
- // Pass SMESHDS_Group to MED writer
- SMESHDS_Group* aGrpDS = dynamic_cast<SMESHDS_Group*>( aGrpBaseDS );
- if ( aGrpDS )
- myWriter.AddGroup( aGrpDS );
-
- // write reference on a shape if exists
- SMESHDS_GroupOnGeom* aGeomGrp =
- dynamic_cast<SMESHDS_GroupOnGeom*>( aGrpBaseDS );
- if ( aGeomGrp ) {
- SALOMEDS::SObject_var mySubRef, myShape;
- if (mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ) &&
- mySubRef->ReferencedObject( myShape ) &&
- !CORBA::is_nil( myShape->GetObject() ))
- {
- string myRefOnObject = myShape->GetID();
- if ( myRefOnObject.length() > 0 ) {
- char aRefName[ 30 ];
- sprintf( aRefName, "Ref on shape %d", anId);
- aSize[ 0 ] = myRefOnObject.length() + 1;
- aDataset = new HDFdataset(aRefName, aGroup, HDF_STRING, aSize, 1);
- aDataset->CreateOnDisk();
- aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
- aDataset->CloseOnDisk();
- }
- }
- else // shape ref is invalid:
- {
- // save a group on geometry as ordinary group
- myWriter.AddGroup( aGeomGrp );
- }
- }
- }
- }
- }
- aGroup->CloseOnDisk();
- }
- } // loop on groups
-
- if ( strcmp( strHasData.c_str(), "1" ) == 0 )
- {
- // Flush current mesh information into MED file
- myWriter.Perform();
-
- // maybe a shape was deleted in the study
- if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() && hasShape) {
- TopoDS_Shape nullShape;
- myLocMesh.ShapeToMesh( nullShape ); // remove shape referring data
- }
-
- if ( !mySMESHDSMesh->SubMeshes().empty() )
- {
- // Store submeshes
- // ----------------
- aGroup = new HDFgroup( "Submeshes", aTopGroup );
- aGroup->CreateOnDisk();
-
- // each element belongs to one or none submesh,
- // so for each node/element, we store a submesh ID
-
- // Make maps of submesh IDs of elements sorted by element IDs
- typedef int TElemID;
- typedef int TSubMID;
- map< TElemID, TSubMID > eId2smId, nId2smId;
- map< TElemID, TSubMID >::iterator hint; // insertion to map is done before hint
- const map<int,SMESHDS_SubMesh*>& aSubMeshes = mySMESHDSMesh->SubMeshes();
- map<int,SMESHDS_SubMesh*>::const_iterator itSubM ( aSubMeshes.begin() );
- SMDS_NodeIteratorPtr itNode;
- SMDS_ElemIteratorPtr itElem;
- for ( itSubM = aSubMeshes.begin(); itSubM != aSubMeshes.end() ; itSubM++ )
- {
- TSubMID aSubMeID = itSubM->first;
- SMESHDS_SubMesh* aSubMesh = itSubM->second;
- if ( aSubMesh->IsComplexSubmesh() )
- continue; // submesh containing other submeshs
- // nodes
- hint = nId2smId.begin(); // optimize insertion basing on increasing order of elem Ids in submesh
- for ( itNode = aSubMesh->GetNodes(); itNode->more(); ++hint)
- hint = nId2smId.insert( hint, make_pair( itNode->next()->GetID(), aSubMeID ));
+ // store submesh order if any
+ const TListOfListOfInt& theOrderIds = myLocMesh.GetMeshOrder();
+ if ( theOrderIds.size() ) {
+ char order_list[ 30 ];
+ strcpy( order_list, "Mesh Order" );
+ // count number of submesh ids
+ int nbIDs = 0;
+ TListOfListOfInt::const_iterator idIt = theOrderIds.begin();
+ for ( ; idIt != theOrderIds.end(); idIt++ )
+ nbIDs += (*idIt).size();
+ // number of values = number of IDs +
+ // number of lists (for separators) - 1
+ int* smIDs = new int [ nbIDs + theOrderIds.size() - 1 ];
+ idIt = theOrderIds.begin();
+ for ( int i = 0; idIt != theOrderIds.end(); idIt++ ) {
+ const TListOfInt& idList = *idIt;
+ if (idIt != theOrderIds.begin()) // not first list
+ smIDs[ i++ ] = -1/* *idList.size()*/; // separator between lists
+ // dump submesh ids from current list
+ TListOfInt::const_iterator id_smId = idList.begin();
+ for( ; id_smId != idList.end(); id_smId++ )
+ smIDs[ i++ ] = *id_smId;
+ }
+ // write HDF group
+ aSize[ 0 ] = nbIDs + theOrderIds.size() - 1;
+
+ aDataset = new HDFdataset( order_list, aTopGroup, HDF_INT32, aSize, 1 );
+ aDataset->CreateOnDisk();
+ aDataset->WriteOnDisk( smIDs );
+ aDataset->CloseOnDisk();
+ //
+ delete[] smIDs;
+ }
+
+ // groups root sub-branch
+ SALOMEDS::SObject_var myGroupsBranch;
+ for ( int i = GetNodeGroupsTag(); i <= GetVolumeGroupsTag(); i++ ) {
+ found = gotBranch->FindSubObject( i, myGroupsBranch );
+ if ( found ) {
+ char name_group[ 30 ];
+ if ( i == GetNodeGroupsTag() )
+ strcpy( name_group, "Groups of Nodes" );
+ else if ( i == GetEdgeGroupsTag() )
+ strcpy( name_group, "Groups of Edges" );
+ else if ( i == GetFaceGroupsTag() )
+ strcpy( name_group, "Groups of Faces" );
+ else if ( i == GetVolumeGroupsTag() )
+ strcpy( name_group, "Groups of Volumes" );
+
+ aGroup = new HDFgroup( name_group, aTopGroup );
+ aGroup->CreateOnDisk();
+
+ SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myGroupsBranch );
+ for ( ; it->More(); it->Next() ) {
+ SALOMEDS::SObject_var mySObject = it->Value();
+ CORBA::Object_var aSubObject = SObjectToObject( mySObject );
+ if ( !CORBA::is_nil( aSubObject ) ) {
+ SMESH_GroupBase_i* myGroupImpl =
+ dynamic_cast<SMESH_GroupBase_i*>( GetServant( aSubObject ).in() );
+ if ( !myGroupImpl )
+ continue;
+
+ CORBA::String_var objStr = GetORB()->object_to_string( aSubObject );
+ int anId = myStudyContext->findId( string( objStr.in() ) );
+
+ // For each group, create a dataset named "Group <group_persistent_id>"
+ // and store the group's user name into it
+ char grpName[ 30 ];
+ sprintf( grpName, "Group %d", anId );
+ char* aUserName = myGroupImpl->GetName();
+ aSize[ 0 ] = strlen( aUserName ) + 1;
+
+ aDataset = new HDFdataset( grpName, aGroup, HDF_STRING, aSize, 1 );
+ aDataset->CreateOnDisk();
+ aDataset->WriteOnDisk( aUserName );
+ aDataset->CloseOnDisk();
+
+ // ouv : NPAL12872
+ // For each group, create a dataset named "Group <group_persistent_id> Color"
+ // and store the group's color into it
+ char grpColorName[ 30 ];
+ sprintf( grpColorName, "ColorGroup %d", anId );
+ SALOMEDS::Color aColor = myGroupImpl->GetColor();
+ double anRGB[3];
+ anRGB[ 0 ] = aColor.R;
+ anRGB[ 1 ] = aColor.G;
+ anRGB[ 2 ] = aColor.B;
+ aSize[ 0 ] = 3;
+ aDataset = new HDFdataset( grpColorName, aGroup, HDF_FLOAT64, aSize, 1 );
+ aDataset->CreateOnDisk();
+ aDataset->WriteOnDisk( anRGB );
+ aDataset->CloseOnDisk();
+
+ // Store the group contents into MED file
+ if ( myLocMesh.GetGroup( myGroupImpl->GetLocalID() ) ) {
+
+ if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen_i::Save(): saving group with StoreName = "
+ << grpName << " to MED file" );
+ SMESHDS_GroupBase* aGrpBaseDS =
+ myLocMesh.GetGroup( myGroupImpl->GetLocalID() )->GetGroupDS();
+ aGrpBaseDS->SetStoreName( grpName );
+
+ // Pass SMESHDS_Group to MED writer
+ SMESHDS_Group* aGrpDS = dynamic_cast<SMESHDS_Group*>( aGrpBaseDS );
+ if ( aGrpDS )
+ myWriter.AddGroup( aGrpDS );
+
+ // write reference on a shape if exists
+ SMESHDS_GroupOnGeom* aGeomGrp =
+ dynamic_cast<SMESHDS_GroupOnGeom*>( aGrpBaseDS );
+ if ( aGeomGrp ) {
+ SALOMEDS::SObject_var mySubRef, myShape;
+ if (mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ) &&
+ mySubRef->ReferencedObject( myShape ) &&
+ !CORBA::is_nil( myShape->GetObject() ))
+ {
+ string myRefOnObject = myShape->GetID();
+ if ( myRefOnObject.length() > 0 ) {
+ char aRefName[ 30 ];
+ sprintf( aRefName, "Ref on shape %d", anId);
+ aSize[ 0 ] = myRefOnObject.length() + 1;
+ aDataset = new HDFdataset(aRefName, aGroup, HDF_STRING, aSize, 1);
+ aDataset->CreateOnDisk();
+ aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
+ aDataset->CloseOnDisk();
+ }
+ }
+ else // shape ref is invalid:
+ {
+ // save a group on geometry as ordinary group
+ myWriter.AddGroup( aGeomGrp );
+ }
+ }
+ }
+ }
+ }
+ aGroup->CloseOnDisk();
+ }
+ } // loop on groups
+
+ if ( strcmp( strHasData.c_str(), "1" ) == 0 )
+ {
+ // Flush current mesh information into MED file
+ myWriter.Perform();
+
+ // maybe a shape was deleted in the study
+ if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() && hasShape) {
+ TopoDS_Shape nullShape;
+ myLocMesh.ShapeToMesh( nullShape ); // remove shape referring data
+ }
+
+ if ( !mySMESHDSMesh->SubMeshes().empty() )
+ {
+ // Store submeshes
+ // ----------------
+ aGroup = new HDFgroup( "Submeshes", aTopGroup );
+ aGroup->CreateOnDisk();
+
+ // each element belongs to one or none submesh,
+ // so for each node/element, we store a submesh ID
+
+ // Make maps of submesh IDs of elements sorted by element IDs
+ typedef int TElemID;
+ typedef int TSubMID;
+ map< TElemID, TSubMID > eId2smId, nId2smId;
+ map< TElemID, TSubMID >::iterator hint; // insertion to map is done before hint
+ const map<int,SMESHDS_SubMesh*>& aSubMeshes = mySMESHDSMesh->SubMeshes();
+ map<int,SMESHDS_SubMesh*>::const_iterator itSubM ( aSubMeshes.begin() );
+ SMDS_NodeIteratorPtr itNode;
+ SMDS_ElemIteratorPtr itElem;
+ for ( itSubM = aSubMeshes.begin(); itSubM != aSubMeshes.end() ; itSubM++ )
+ {
+ TSubMID aSubMeID = itSubM->first;
+ SMESHDS_SubMesh* aSubMesh = itSubM->second;
+ if ( aSubMesh->IsComplexSubmesh() )
+ continue; // submesh containing other submeshs
+ // nodes
+ hint = nId2smId.begin(); // optimize insertion basing on increasing order of elem Ids in submesh
+ for ( itNode = aSubMesh->GetNodes(); itNode->more(); ++hint)
+ hint = nId2smId.insert( hint, make_pair( itNode->next()->GetID(), aSubMeID ));