::SMESH_Mesh & mesh = meshServant->GetImpl();
SMESHDS_Mesh* meshDS = mesh.GetMeshDS();
// find the element in mesh
- if ( const SMDS_MeshElement * elem = meshDS->FindElement( theElementID ) )
+ if ( const SMDS_MeshElement * elem = meshDS->FindElement( theElementID ) ) {
// find a shape id by the element
if ( int shapeID = ::SMESH_MeshEditor( &mesh ).FindShape( elem )) {
// get a geom object by the shape id
GEOM::GEOM_Object_var geom = ShapeToGeomObject( meshDS->IndexToShape( shapeID ));
if ( geom->_is_nil() ) {
+ // try to find a published sub-shape
+ SALOMEDS::SObject_var mainSO = ObjectToSObject( myCurrentStudy, mainShape );
+ SALOMEDS::ChildIterator_var it;
+ if ( !mainSO->_is_nil() )
+ it = myCurrentStudy->NewChildIterator( mainSO );
+ if ( !it->_is_nil() ) {
+ for ( it->InitEx(true); it->More(); it->Next() ) {
+ GEOM::GEOM_Object_var subGeom =
+ GEOM::GEOM_Object::_narrow( SObjectToObject( it->Value() ));
+ if ( !subGeom->_is_nil() ) {
+ GEOM::ListOfLong_var subList = subGeom->GetSubShapeIndices();
+ if ( subList->length() == 1 && shapeID == subList[0] ) {
+ geom = subGeom;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if ( geom->_is_nil() ) {
+ // explode
GEOM::GEOM_IShapesOperations_var op =
geomGen->GetIShapesOperations( GetCurrentStudyID() );
if ( !op->_is_nil() )
return geom._retn();
}
}
+ }
}
return GEOM::GEOM_Object::_nil();
}
aDataset->WriteOnDisk( ( char* )( strHasData.c_str() ) );
aDataset->CloseOnDisk();
+ // ouv : NPAL12872
+ // for each mesh open the HDF group basing on its auto color parameter
+ char meshAutoColorName[ 30 ];
+ sprintf( meshAutoColorName, "AutoColorMesh %d", id );
+ int anAutoColor[1];
+ anAutoColor[0] = myImpl->GetAutoColor();
+ aSize[ 0 ] = 1;
+ aDataset = new HDFdataset( meshAutoColorName, aTopGroup, HDF_INT32, aSize, 1 );
+ aDataset->CreateOnDisk();
+ aDataset->WriteOnDisk( anAutoColor );
+ aDataset->CloseOnDisk();
+
// write reference on a shape if exists
SALOMEDS::SObject_var myRef;
bool shapeRefFound = false;
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() ) ) {
int newId = myStudyContext->findId( iorString );
myStudyContext->mapOldToNew( id, newId );
+ // ouv : NPAL12872
+ // try to read and set auto color flag
+ char aMeshAutoColorName[ 30 ];
+ sprintf( aMeshAutoColorName, "AutoColorMesh %d", id);
+ if( aTopGroup->ExistInternalObject( aMeshAutoColorName ) )
+ {
+ aDataset = new HDFdataset( aMeshAutoColorName, aTopGroup );
+ aDataset->OpenOnDisk();
+ size = aDataset->GetSize();
+ int* anAutoColor = new int[ size ];
+ aDataset->ReadFromDisk( anAutoColor );
+ aDataset->CloseOnDisk();
+ myNewMeshImpl->SetAutoColor( (bool)anAutoColor[0] );
+ }
+
// try to read and set reference to shape
GEOM::GEOM_Object_var aShapeObject;
if ( aTopGroup->ExistInternalObject( "Ref on shape" ) ) {
SMESHDS_GroupBase* aGroupBaseDS = aLocalGroup->GetGroupDS();
aGroupBaseDS->SetStoreName( name_dataset );
+ // ouv : NPAL12872
+ // Read color of the group
+ char aGroupColorName[ 30 ];
+ sprintf( aGroupColorName, "ColorGroup %d", subid);
+ if ( aGroup->ExistInternalObject( aGroupColorName ) )
+ {
+ aDataset = new HDFdataset( aGroupColorName, aGroup );
+ aDataset->OpenOnDisk();
+ size = aDataset->GetSize();
+ double* anRGB = new double[ size ];
+ aDataset->ReadFromDisk( anRGB );
+ aDataset->CloseOnDisk();
+ SALOMEDS::Color aColor;
+ aColor.R = anRGB[0];
+ aColor.G = anRGB[1];
+ aColor.B = anRGB[2];
+ aGroupBaseDS->SetColor( aColor );
+ }
+
// Fill group with contents from MED file
SMESHDS_Group* aGrp = dynamic_cast<SMESHDS_Group*>( aGroupBaseDS );
if ( aGrp )
delete myStudyContextMap[ studyId ];
myStudyContextMap.erase( studyId );
}
+
+ // delete SMESH_Mesh's
+ StudyContextStruct* context = myGen.GetStudyContext( studyId );
+ map< int, SMESH_Mesh* >::iterator i_mesh = context->mapMesh.begin();
+ for ( ; i_mesh != context->mapMesh.end(); ++i_mesh )
+ delete i_mesh->second;
+ // delete SMESHDS_Mesh's
+ // it's too long on big meshes
+// if ( context->myDocument ) {
+// delete context->myDocument;
+// context->myDocument = 0;
+// }
+
return;
}