BR_OCC_For_3_1_0b1).
_NS = SINGLETON_<SALOME_NamingService>::Instance() ;
ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
_NS->init_orb( _orb ) ;
+
+ _myMedI = 0;
}
//=============================================================================
/*!
}
}
-
+ return SALOME_MED::FIELD::_nil();
}
aName += myMesh->getName();
aName += ".med";
MESSAGE("Save mesh with name "<<aName.ToCString());
+ // Remove existing file
+ if (isMultiFile) {
+ aSeq->length(1);
+ aSeq[0]=CORBA::string_dup( aName.ToCString() );
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ aSeq->length(0);
+ }
long driverId = myMesh->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myMesh->getName());
myMesh->write(driverId,"");
aFileNames.Append(aName);
}
}
+ // temporary: until info that mesh is distant is written
+ MED_EN::medFileVersion curVersion = DRIVERFACTORY::getMedFileVersionForWriting();
+ DRIVERFACTORY::setMedFileVersionForWriting( MED_EN::V21 );
+
SALOMEDS::SObject_var aMedFieldFather = theComponent->GetStudy()->FindObject("MEDFIELD");
if (!CORBA::is_nil(aMedFieldFather)) {
SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedFieldFather);
aName += "_ITER_";
aName += (char*)(b.str().c_str());
aName += ".med";
- MESSAGE("Save mesh with name "<<aName.ToCString());
+ // Remove existing file
+ if (isMultiFile) {
+ aSeq->length(1);
+ aSeq[0]=CORBA::string_dup( aName.ToCString() );
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ aSeq->length(0);
+ }
+ MESSAGE("Save field with name "<<aName.ToCString());
long driverId = myField->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myField->getName());
myField->write(driverId,"");
aFileNames.Append(aName);
}
}
}
+ DRIVERFACTORY::setMedFileVersionForWriting( curVersion );
int i;
aSeq->length(aFileNames.Length());
- for(i = aFileNames.Length(); i > 0; i--) aSeq[i-1] = CORBA::string_dup(aFileNames.Value(i).ToCString());
+ for(i = aFileNames.Length(); i > 0; i--)
+ aSeq[i-1] = CORBA::string_dup(aFileNames.Value(i).ToCString());
// Conver a file to the byte stream
aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
// Remove the created file and tmp directory
END_OF(LOC);
}
-
SALOMEDS::TMPFile* Med_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
const char* theURL,
bool isMultiFile) {
aName += myMesh->getName();
aName += ".med";
MESSAGE("Save mesh with name "<<aName.ToCString());
+ // Remove existing file
+ if (isMultiFile) {
+ aSeq->length(1);
+ aSeq[0]=CORBA::string_dup( aName.ToCString() );
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ aSeq->length(0);
+ }
long driverId = myMesh->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myMesh->getName());
myMesh->write(driverId,"");
HDFascii::ConvertFromHDFToASCII((aTmpDir+aName).ToCString(), true);
}
}
+ // temporary: until info that mesh is distant is written
+ MED_EN::medFileVersion curVersion = DRIVERFACTORY::getMedFileVersionForWriting();
+ DRIVERFACTORY::setMedFileVersionForWriting( MED_EN::V21 );
+
SALOMEDS::SObject_var aMedFieldFather = theComponent->GetStudy()->FindObject("MEDFIELD");
if (!CORBA::is_nil(aMedFieldFather)) {
SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedFieldFather);
aName += "_ITER_";
aName += (char*)(b.str().c_str());
aName += ".med";
- MESSAGE("Save mesh with name "<<aName.ToCString());
+ MESSAGE("Save field with name "<<aName.ToCString());
+ // Remove existing file
+ if (isMultiFile) {
+ aSeq->length(1);
+ aSeq[0]=CORBA::string_dup( aName.ToCString() );
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ aSeq->length(0);
+ }
long driverId = myField->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myField->getName());
myField->write(driverId,"");
HDFascii::ConvertFromHDFToASCII((aTmpDir+aName).ToCString(), true);
}
}
}
+ DRIVERFACTORY::setMedFileVersionForWriting( curVersion );
int i;
aSeq->length(aFileNames.Length());
- for(i = aFileNames.Length(); i > 0; i--) aSeq[i-1] = CORBA::string_dup(aFileNames.Value(i).ToCString());
- // Conver a file to the byte stream
+ for(i = aFileNames.Length(); i > 0; i--)
+ aSeq[i-1] = CORBA::string_dup(aFileNames.Value(i).ToCString());
+ // Convert a file to the byte stream
aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
// Remove the created file and tmp directory
if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
return CORBA::string_dup("_MED");
}
+//=======================================================================
+//function : getFieldNameAndDtIt
+//purpose :
+//=======================================================================
+
+static void getFieldNameAndDtIt( const char* aLocalPersistentID,
+ string & aFieldName,
+ CORBA::Long & aNumOrdre,
+ CORBA::Long & anIterNumber)
+{
+ // aLocalPersistentID(("_MEDFIELD_"+ myField->getName() +
+ // "_ORDRE_"+a.str()+
+ // "_ITER_"+b.str()+".med"
+ int aLPIdLen = strlen(aLocalPersistentID);
+ const int _MEDFIELD_Len = strlen("_MEDFIELD_");
+ const int _ORDRE_Len = strlen("_ORDRE_");
+ const int _ITER_Len = strlen("_ITER_");
+
+ // Get field name: look for _ORDRE_ in aLocalPersistentID
+ int aFieldNameLen = 0, aFieldNameBeg = _MEDFIELD_Len, _ORDRE_Beg;
+ for ( _ORDRE_Beg = aFieldNameBeg; _ORDRE_Beg < aLPIdLen; ++aFieldNameLen,++_ORDRE_Beg )
+ if ( strncmp( &aLocalPersistentID[ _ORDRE_Beg ], "_ORDRE_", _ORDRE_Len ) == 0 )
+ break;
+ aFieldName = string( &(aLocalPersistentID[aFieldNameBeg]), aFieldNameLen);
+
+ // Get orderNumber
+ int anOrderNumberBeg = _ORDRE_Beg + _ORDRE_Len;
+ aNumOrdre = atoi( & aLocalPersistentID[ anOrderNumberBeg ]);
+
+ // Get iterationNumber: look for _ITER_ in aLocalPersistentID
+ int _ITER_Beg = anOrderNumberBeg;
+ for ( ; _ITER_Beg < aLPIdLen; ++_ITER_Beg )
+ if ( strncmp( &aLocalPersistentID[ _ITER_Beg ], "_ITER_", _ITER_Len ) == 0 )
+ break;
+ anIterNumber = atoi( & aLocalPersistentID[ _ITER_Beg + _ITER_Len ]);
+}
+
//=============================================================================
/*!
* CORBA: give a transient reference (when loading an object, opening study)
{
const char * LOC = "Med_Gen_i::LocalPersistentIDToIOR" ;
BEGIN_OF(LOC) ;
- TCollection_AsciiString aTmpDir((char*)(_saveFileName.c_str()));
+ bool isMesh, isField;
+ isMesh = isField = false;
+
+ if (strcmp(aLocalPersistentID, "_MED Objet Med + /OBJ_MED/") == 0) { // MED
+ _myMedI = new MED_i();
+ SALOME_MED::MED_ptr myMedIOR = _myMedI->_this();
+ return(CORBA::string_dup(_orb->object_to_string(myMedIOR)));
+ }
+ else if (strncmp(aLocalPersistentID, "_MEDMESH_",9) == 0) // MESH
+ isMesh = true;
+ else if (strncmp(aLocalPersistentID, "_MED/FAS/",9) == 0) // SUPPORT
+ return (CORBA::string_dup( theSObject->GetIOR() )); // is loaded along with MESH
+ else if (strncmp(aLocalPersistentID, "_MEDFIELD_",10) == 0) // FIELD
+ isField = true;
+ else
+ return CORBA::string_dup("");
+
+ // Get file name
+ char* aFileName;
+ TCollection_AsciiString aTmpDir((char*)(_saveFileName.c_str()));
TCollection_AsciiString aSaveStudyName("");
- if (isMultiFile) aSaveStudyName = (char*)SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL()).c_str();
+ if (isMultiFile)
+ aSaveStudyName = (char*)SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL()).c_str();
+ if (isASCII)
+ {
+ char* aResultPath = HDFascii::ConvertFromASCIIToHDF((aTmpDir + aSaveStudyName + (char*)aLocalPersistentID).ToCString());
+ aFileName = new char[strlen(aResultPath) + 19];
+ sprintf(aFileName, "%shdf_from_ascii.hdf", aResultPath);
+ delete(aResultPath);
+ }
+ else
+ aFileName = CORBA::string_dup((aTmpDir + aSaveStudyName + (char*)aLocalPersistentID).ToCString());
+
+ // Read file structure
+ try
+ {
+ ASSERT( _myMedI );
+ CORBA::Long drvId = _myMedI->addDriver( SALOME_MED::MED_DRIVER, aFileName );
+ _myMedI->readFileStruct( drvId );
+ }
+ catch (const std::exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to read a hdf file",SALOME::BAD_PARAM);
+ };
- if (strcmp(aLocalPersistentID, "Objet Med + /OBJ_MED/") == 0) return CORBA::string_dup(""); // MED
+ CORBA::Object_ptr anIOR;
- if (strncmp(aLocalPersistentID, "_MEDMESH_",9) == 0) {// MESH
- MESH * myMesh= new MESH() ;
+ if ( isMesh ) {// MESH
+ // Get mesh name
int aMeshNameLen = strlen(aLocalPersistentID) - 12;
- char* aMeshName = new char[aMeshNameLen];
- strncpy(aMeshName, &(aLocalPersistentID[9]), aMeshNameLen-1);
+ string aMeshName( &(aLocalPersistentID[9]), aMeshNameLen);
aMeshName[aMeshNameLen-1] = 0;
- myMesh->setName(aMeshName);
-
- char* aFileName;
- if (isASCII) {
- char* aResultPath = HDFascii::ConvertFromASCIIToHDF((aTmpDir + aSaveStudyName + (char*)aLocalPersistentID).ToCString());
- aFileName = new char[strlen(aResultPath) + 19];
- sprintf(aFileName, "%shdf_from_ascii.hdf", aResultPath);
- delete(aResultPath);
- } else aFileName = CORBA::string_dup((aTmpDir + aSaveStudyName + (char*)aLocalPersistentID).ToCString());
- MED_MESH_RDONLY_DRIVER myMeshDriver(aFileName,myMesh);
+
+ // Read mesh
+ SALOME_MED::MESH_ptr mesh;
try
- {
- myMeshDriver.setMeshName(aMeshName);
- myMeshDriver.open();
- }
+ {
+ mesh = _myMedI->getMeshByName( aMeshName.c_str() );
+ mesh->read( 0 );
+ _myMedI->updateSupportIORs( theSObject->GetStudy(), aMeshName.c_str() );
+ }
catch (const std::exception & ex)
- {
- MESSAGE("Exception Interceptee : ");
- SCRUTE(ex.what());
- THROW_SALOME_CORBA_EXCEPTION("Unable to find this mesh in this file",SALOME::BAD_PARAM);
- };
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to read this mesh in this file",
+ SALOME::INTERNAL_ERROR);
+ }
+
+ anIOR = mesh;
+ }
+
+ if ( isField ) { // FIELD
+
+ // Field Name
+ string aFieldName;
+ CORBA::Long aNumOrdre, anIterNumber;
+ getFieldNameAndDtIt( aLocalPersistentID, aFieldName, aNumOrdre, anIterNumber );
+
+ // Read field
+ SALOME_MED::FIELD_ptr field;
try
- {
- myMeshDriver.read();
- MESSAGE("apres read");
- myMeshDriver.close();
- }
+ {
+ field = _myMedI->getField( aFieldName.c_str(), anIterNumber, aNumOrdre );
+ field->read( 0 );
+ }
catch (const std::exception & ex)
- {
- MESSAGE("Exception Interceptee : ");
- SCRUTE(ex.what());
- THROW_SALOME_CORBA_EXCEPTION("Unable to read this mesh in this file",SALOME::BAD_PARAM);
- }
- MESH_i * meshi = new MESH_i(myMesh);
- //SALOME_MED::MESH_var mesh = SALOME_MED::MESH::_narrow(meshi->_this());
- SALOME_MED::MESH_ptr mesh = meshi->_this();
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- aSeq->length(1);
- aSeq[0]=CORBA::string_dup(aLocalPersistentID);
- if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
- if (isASCII) {
- SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
- aFilesToRemove->length(1);
- aFilesToRemove[0] = CORBA::string_dup(&(aFileName[strlen(SALOMEDS_Tool::GetDirFromPath(aFileName).c_str())]));
- SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aFileName).c_str(), aFilesToRemove, true);
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to read this field in this file",
+ SALOME::INTERNAL_ERROR);
}
- delete(aFileName);
- return(CORBA::string_dup(_orb->object_to_string(mesh)));
- } else if (strncmp(aLocalPersistentID, "_MEDFIELD_",14) == 0) { // FIELD
- return(CORBA::string_dup("")); // not implemented yet
+
+ anIOR = field;
+
+ }
+
+ // Remove tmp files
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(1);
+ aSeq[0]=CORBA::string_dup(aLocalPersistentID);
+ if (!isMultiFile)
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ if (isASCII)
+ {
+ SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
+ aFilesToRemove->length(1);
+ aFilesToRemove[0] = CORBA::string_dup(&(aFileName[strlen(SALOMEDS_Tool::GetDirFromPath(aFileName).c_str())]));
+ SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aFileName).c_str(), aFilesToRemove, true);
}
- return CORBA::string_dup("");
+ delete(aFileName);
+
+ if ( CORBA::is_nil( anIOR ))
+ return CORBA::string_dup("");
+
+ return(CORBA::string_dup(_orb->object_to_string( anIOR )));
}
//=============================================================================
//=============================================================================
bool Med_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) {
SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(theIOR);
- return !(aMesh->_is_nil());
+ if ( !aMesh->_is_nil())
+ return true;
+ SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(theIOR);
+ if ( !aField->_is_nil())
+ return true;
+// SALOME_MED::SUPPORT_var aSupport = SALOME_MED::SUPPORT::_narrow(theIOR);
+// if ( !aSupport->_is_nil())
+// return true;
+ return false;
}
//=============================================================================
if (CORBA::is_nil(theSObject)) {
SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(theObject);
- aMesh->addInStudy(theStudy, aMesh);
- SALOMEDS::SObject_var aResultSO = theStudy->FindObjectIOR(_orb->object_to_string(theObject));
+ if ( !aMesh->_is_nil() )
+ aMesh->addInStudy(theStudy, aMesh);
+ SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(theObject);
+ if ( !aField->_is_nil())
+ aField->addInStudy(theStudy, aField);
+// SALOME_MED::SUPPORT_var aSupport = SALOME_MED::SUPPORT::_narrow(theObject);
+// if ( !aSupport->_is_nil())
+// aSupport->addInStudy(theStudy, aSupport);
+ aResultSO = theStudy->FindObjectIOR(_orb->object_to_string(theObject));
} else {
- if (!theSObject->ReferencedObject(aResultSO))
- THROW_SALOME_CORBA_EXCEPTION("Publish in study MED object error",SALOME::BAD_PARAM);
+// if (!theSObject->ReferencedObject(aResultSO))
+// THROW_SALOME_CORBA_EXCEPTION("Publish in study MED object error",SALOME::BAD_PARAM);
}
// aBuilder->Addreference(theObject, aResultSO);
return aResultSO._retn();
char* aFullName = new char[strlen(aTmpDir)+strlen(aSeq[0])+1];
strcpy(aFullName, aTmpDir);
strcpy(aFullName+strlen(aTmpDir), aSeq[0]);
+
long driverId = aMesh->addDriver(SALOME_MED::MED_DRIVER,aFullName , aMesh->getName());
aMesh->write(driverId,"");
};
try {
myMeshDriver.read();
- ("apres read");
+ MESSAGE("apres read");
myMeshDriver.close();
} catch (const std::exception & ex) {
MESSAGE("Exception Interceptee : ");
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+namespace MEDMEM {
+ class MED_i;
+}
+
class Med_Gen_i:
public POA_SALOME_MED::MED_Gen,
public Engines_Component_i
int myCounter;
SALOME_NamingService *_NS;
-
+ MEDMEM::MED_i* _myMedI; // used while loading a study
};
#endif
MESSAGE("Computing path to Support");
- char * supportEntryPath;
- lenName = 28 + 15 + strlen(meshName.c_str()) + 1 +
- strlen(supportName.c_str()) + 1;
- supportEntryPath = new char[lenName];
- supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/MEDSUPPORTS_OF_");
- supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str());
- supportEntryPath = strcat(supportEntryPath,"/");
- supportEntryPath = strcat(supportEntryPath,supportName.c_str());
-
+ string supportEntryPath = SUPPORT_i::getEntryPath( meshNameStudy,
+ _fieldTptr->getSupport() );
SCRUTE(supportEntryPath);
- MESSAGE("supportEntryPath in field " << supportEntryPath << " length " << lenName);
+ MESSAGE("supportEntryPath in field " << supportEntryPath /*<< " length " << lenName*/);
// SALOMEDS::SObject_var supportObject = myStudy->FindObject(supportName.c_str());
- SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath);
+ SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath.c_str());
SCRUTE(supportObject);
myBuilder->CommitCommand();
- delete [] supportEntryPath;
+ //delete [] supportEntryPath;
delete [] fieldEntryName;
// register the Corba pointer: increase the referrence count
#include "MEDMEM_Family_i.hxx"
#include "MEDMEM_Group_i.hxx"
#include "MEDMEM_convert.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
#include "MEDMEM_DriversDef.hxx"
#include "utilities.h"
MED_i::MED_i():_med((::MED*)NULL)
{
BEGIN_OF("Default Constructor MED_i");
+ _med = new ::MED();
END_OF("Default Constructor MED_i");
}
//=============================================================================
BEGIN_OF(LOC);
// we create all IOR from _med
- _med = new ::MED(driverType,fileName);
+ if ( _med )
+ delete _med;
+ _med = new ::MED(driverType,fileName);
// MESHES :
deque<string> meshesNames = _med->getMeshNames();
SCRUTE(driverType);
SCRUTE(fileName)
- _med = new ::MED(driverType,fileName);
+ if ( _med )
+ delete _med;
+ _med = new ::MED(driverType,fileName);
int numberOfMeshes = _med->getNumberOfMeshes();
SCRUTE(numberOfMeshes);
//=============================================================================
MED_i::~MED_i()
{
+ //delete _med;
}
+
+//=======================================================================
+//function : updateSupportIORs
+//purpose :
+//=======================================================================
+
+void MED_i::updateSupportIORs(SALOMEDS::Study_ptr myStudy, const char* meshName)
+{
+ vector<FAMILY*> familyVector;
+ vector<FAMILY*>::iterator familyVectorIt;
+ vector<GROUP*> groupVector;
+ vector<GROUP*>::iterator groupVectorIt;
+ string supportEntryPath;
+
+ ::MESH * ptrMesh = _med->getMesh(meshName);
+
+ MED_EN::MESH_ENTITIES::const_iterator currentEntity;
+
+ for (currentEntity = MED_EN::meshEntities.begin();
+ currentEntity != MED_EN::meshEntities.end();
+ currentEntity++)
+ {
+ // family :
+ familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first);
+ int nb = familyVector.size();
+ for (familyVectorIt = familyVector.begin();
+ familyVectorIt != familyVector.end();
+ familyVectorIt++)
+ {
+ supportEntryPath = SUPPORT_i::getEntryPath( meshName, *familyVectorIt );
+ SALOMEDS::SObject_var familyEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
+ if ( !familyEntry->_is_nil() || CORBA::is_nil( familyEntry->GetObject() ))
+ {
+ FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt);
+ SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this();
+ myFamilyI->addInStudy(myStudy,myFamilyIOR);
+ }
+ }
+
+ // group :
+ groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first);
+ nb = groupVector.size();
+ for (groupVectorIt = groupVector.begin();
+ groupVectorIt != groupVector.end();
+ groupVectorIt++)
+ {
+ supportEntryPath = SUPPORT_i::getEntryPath( meshName, *groupVectorIt );
+ SALOMEDS::SObject_var groupEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
+ if ( !groupEntry->_is_nil() || CORBA::is_nil( groupEntry->GetObject() ))
+ {
+ GROUP_i * myGroupI = new GROUP_i(*groupVectorIt);
+ SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this();
+ myGroupI->addInStudy(myStudy,myGroupIOR);
+ }
+ }
+ }
+
+ _med->updateSupport();
+
+ // supports
+ map<MED_EN::medEntityMesh,::SUPPORT*> mySupports = _med->getSupports(meshName);
+ map<MED_EN::medEntityMesh,::SUPPORT*>::const_iterator itSupport;
+ map<MED_EN::medEntityMesh,SALOME_MED::SUPPORT_ptr> &
+ mySupportsIOR = _supports[meshName];
+ for (itSupport=mySupports.begin(); itSupport!=mySupports.end(); itSupport++ )
+ {
+ supportEntryPath = SUPPORT_i::getEntryPath( meshName, itSupport->second);
+ SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
+ if ( !supportEntry->_is_nil() || CORBA::is_nil( supportEntry->GetObject() ))
+ {
+ SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second);
+ SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this();
+ mySupportsIOR[(*itSupport).first]= mySupportIOR;
+ mySupportI->addInStudy(myStudy,mySupportIOR);
+ }
+ }
+}
+
+
//=============================================================================
/*!
* CORBA: Accessor for Number of meshes
if (_med==NULL)
THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
SALOME::INTERNAL_ERROR);
+ SALOME_MED::MESH_ptr meshIOR;
try
{
+ map<string,SALOME_MED::MESH_ptr>::const_iterator name_meshIOR =
+ _meshes.find( meshName );
+ if ( name_meshIOR == _meshes.end() ) {
MESH * mesh=_med->getMesh(meshName);
MESH_i * m1 = new MESH_i(mesh);
- return m1->POA_SALOME_MED::MESH::_this();
+ meshIOR = m1->POA_SALOME_MED::MESH::_this();
+ _meshes[ meshName ] = meshIOR;
+ }
+ else {
+ meshIOR = name_meshIOR->second;
+ }
}
catch (MEDEXCEPTION &ex)
{
MESSAGE("Unable to get the specified mesh");
THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
}
-
+ return meshIOR;
}
//=============================================================================
/*!
ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
::FIELD<double> * fdouble = (::FIELD<double> *)FIELD_i::fieldMap[ind];
- MESH * mesh=_med->getMesh(fdouble);
+ mesh=_med->getMesh(fdouble);
}
else
{
ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
::FIELD<int> * fint = (::FIELD<int> *)FIELD_i::fieldMap[ind];
- MESH * mesh=_med->getMesh(fint);
+ mesh=_med->getMesh(fint);
}
MESH_i * meshi = new MESH_i(mesh);
return meshi->POA_SALOME_MED::MESH::_this();
{
const char * LOC="MED_i::getField(const char*,CORBA::Long,CORBA::Long) ";
BEGIN_OF(LOC);
+ if (_med==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
+ SALOME::INTERNAL_ERROR);
+
+ SALOME_MED::FIELD_ptr myFieldIOR = SALOME_MED::FIELD::_nil();
DT_IT_ dtIt;
dtIt.it= (int)numOrdre;
map<string,MAP_IOR_DT_IT_>::const_iterator itFields = _fields.find(fieldName);
+ if ( itFields != _fields.end() )
+ {
+ const MAP_IOR_DT_IT_ & map_dtIt = (*itFields).second;
+ MAP_IOR_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt);
+ if ( itMap_dtIt != map_dtIt.end() )
+ myFieldIOR = (*itMap_dtIt).second;
+ }
- if ( itFields == _fields.end() )
- THROW_SALOME_CORBA_EXCEPTION("Field not found !", SALOME::INTERNAL_ERROR);
-
- const MAP_IOR_DT_IT_ & map_dtIt = (*itFields).second;
- MAP_IOR_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt);
-
- if ( itMap_dtIt == map_dtIt.end() )
- THROW_SALOME_CORBA_EXCEPTION("Iteration not found !", SALOME::INTERNAL_ERROR);
-
- END_OF(LOC);
- return (*itMap_dtIt).second;
+ if ( CORBA::is_nil( myFieldIOR ))
+ {
+ try
+ {
+ ::FIELD_* myField = _med->getField( fieldName, pasTemps, numOrdre);
+
+ switch ( myField->getValueType() ) {
+ case MED_EN::MED_INT32 : {
+ FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
+ myFieldIOR = myFieldIntI->_this();
+ break;
+ }
+
+ case MED_EN::MED_REEL64: {
+ FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
+ myFieldIOR = myFieldDoubleI->_this();
+ break;
+ }
+ default:
+ THROW_SALOME_CORBA_EXCEPTION ("Wrong field type", SALOME::INTERNAL_ERROR);
+ }
+ }
+ catch (const std::exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Field not found !", SALOME::INTERNAL_ERROR);
+ }
+ _fields[fieldName][dtIt] = myFieldIOR;
+ }
+ END_OF(LOC);
+ return myFieldIOR;
}
//=============================================================================
/*!
const char * medObjName)
throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+ void updateSupportIORs(SALOMEDS::Study_ptr myStudy, const char* meshName);
+
+
// IDL Methods
CORBA::Long getNumberOfMeshes() throw (SALOME::SALOME_Exception);
CORBA::Long getNumberOfFields() throw (SALOME::SALOME_Exception);
#include "MEDMEM_define.hxx"
#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Support_i.hxx"
#include "MEDMEM_Mesh_i.hxx"
SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
try
{
- MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
+ MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
myseq->length(nbelements);
const int * numbers=_support->getNumberIndex();
SALOME::SenderInt_ptr ret;
try
{
- MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
+ MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
const int * numbers=_support->getNumberIndex();
ret=SenderFactory::buildSender(*this,numbers,nbelements);
}
MESSAGE(LOC << " Find SObject MESH (represent mesh in support)");
- string meshName = getMesh()->getName() ;
+ string meshName = _support->getMesh()->getName() ;
string meshNameStudy = meshName;
for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
THROW_SALOME_CORBA_EXCEPTION("SObject Mesh in Support not Found",SALOME::INTERNAL_ERROR);
// perhaps add MESH automatically ?
- MESSAGE("Add a support Object under /MED/MESH/MESHNAME");
+ MESSAGE("Add a support Object under /Med/MESH/MESHNAME");
char * medsupfatherName;
int lenName = 15 + strlen(meshName.c_str()) + 1;
//myBuilder->NewCommand();
- string supportName = _support->getName();
-
- SCRUTE(supportName);
-
- SCRUTE(meshNameStudy);
-
- char * supportEntryPath;
- lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str())+1;
- supportEntryPath = new char[lenName];
- supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
- supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
- supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str());
- supportEntryPath = strcat(supportEntryPath,"/");
- supportEntryPath = strcat(supportEntryPath,supportName.c_str());
-
+ string supportEntryPath = getEntryPath( meshName, _support );
//SCRUTE(supportEntryPath);
- MESSAGE("supportEntryPath in support " << supportEntryPath << " length " << lenName);
+ MESSAGE("supportEntryPath in support " << supportEntryPath/* << " length " << lenName*/);
-// SALOMEDS::SObject_var supportEntry = myStudy->FindObject(_support->getName().c_str());
- // c'est pas bon, car il faut rechercher uniquement sous le bon MESH !!!
- SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath);
+ SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
if ( CORBA::is_nil(supportEntry) )
{
}
myBuilder->CommitCommand();
- SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath);
+ SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath.c_str());
MESSAGE("Just for checking, reuse of the corba pointer");
}
delete [] medsupfatherName;
- delete [] supportEntryPath;
// register the Corba pointer: increase the referrence count
MESSAGE("Registering of the Corba Support pointer");
END_OF(LOC);
}
+
+//=======================================================================
+//function : getEntryPath
+//purpose :
+//=======================================================================
+
+string SUPPORT_i::getEntryPath(const string& aMeshName, const ::MEDMEM::SUPPORT * aSupport)
+{
+ string meshNameStudy( aMeshName.c_str(), strlen( aMeshName.c_str() ));
+ for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
+ if (isspace(meshNameStudy[pos])) meshNameStudy[pos] = '_';
+
+ string supportName = aSupport->getName();
+ string supportNameStudy( supportName.c_str(), strlen( supportName.c_str() ));
+ string supportEntryPath =
+ "/Med/MEDMESH/MEDSUPPORTS_OF_" + meshNameStudy + "/" + supportNameStudy;
+ SCRUTE( supportEntryPath );
+
+ return supportEntryPath;
+}
SALOME_MED::SUPPORT_ptr myIor)
throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+ static std::string getEntryPath (const std::string& aMeshName,
+ const ::MEDMEM::SUPPORT * aSupport);
+
void release();
// Cuisine interne
CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
#==============================================================================
-def getMedObjectFromStudy():
- mySO = batchmode_salome.myStudy.FindObject("Objet MED")
- Builder = batchmode_salome.myStudy.NewBuilder()
- anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR")
- obj = batchmode_salome.orb.string_to_object(anAttr.Value())
- myObj = obj._narrow(SALOME_MED.MED)
+def getMedObjectFromStudy(fileName=None):
+ myObj=None; Builder = batchmode_salome.myStudy.NewBuilder()
+ if fileName is not None:
+ objNameInStudy = "MED_OBJECT_FROM_FILE_"+fileName
+ mySO = batchmode_salome.myStudy.FindObject(objNameInStudy)
+ if mySO is not None:
+ anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR")
+ obj = batchmode_salome.orb.string_to_object(anAttr.Value())
+ if obj is not None:
+ myObj = obj._narrow(SALOME_MED.MED)
+ else:
+ print "ERROR: ",myObj," has been found in the Study, but with the type different of SALOME_MED.MED!!!"
+ else:
+ print "ERROR: ",objNameInStudy," hasn't been found in the Study!!!"
+ else:
+ SObj_root = batchmode_salome.myStudy.FindObjectByPath("/Med/")
+ if SObj_root is not None:
+ iter = batchmode_salome.myStudy.NewChildIterator(SObj_root)
+ try:
+ iter.Init();
+ while iter.More():
+ Obj = iter.Value()
+ if Obj is not None:
+ Ok, anAttr = Builder.FindAttribute(Obj, "AttributeIOR")
+ if Ok:
+ if len(anAttr.Value()) > 0:
+ obj = batchmode_salome.orb.string_to_object(anAttr.Value())
+ if obj is not None:
+ myObj = obj._narrow(SALOME_MED.MED)
+ if myObj is not None:
+ break
+ iter.Next()
+ except:
+ print "Exception!!!"
+ else: print "Root object Med hasn't been found in the study!!!"
return myObj
-
+
studyCurrent = batchmode_salome.myStudyName
studyCurrentId = batchmode_salome.myStudyId