- long anId = elem->GetID();
- if ( anElementsOnShape->IsSatisfy( anId ) )
- res.push_back( anId );
- }
- }
- }
- return res;
-}
-
-
-//=================================================================================
-// function : importData
-// purpose : imports mesh data file (the med one) into the SMESH internal data structure
-//=================================================================================
-Engines::ListOfIdentifiers* SMESH_Gen_i::importData(CORBA::Long studyId,
- Engines::DataContainer_ptr data,
- const Engines::ListOfOptions& options)
-{
- Engines::ListOfIdentifiers_var aResultIds = new Engines::ListOfIdentifiers;
- list<string> aResultList;
-
- CORBA::Object_var aSMObject = myNS->Resolve( "/myStudyManager" );
- SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
- SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId );
- SetCurrentStudy(aStudy);
-
- // load and store temporary imported file
- string aFileName = Kernel_Utils::GetTmpFileName();
- aFileName += string(".") + data->extension();
- Engines::TMPFile* aFileStream = data->get();
- const char *aBuffer = (const char*)aFileStream->NP_data();
-#ifdef WIN32
- std::ofstream aFile(aFileName.c_str(), std::ios::binary);
-#else
- std::ofstream aFile(aFileName.c_str());
-#endif
- aFile.write(aBuffer, aFileStream->length());
- aFile.close();
-
- // Retrieve mesh names from the file
- DriverMED_R_SMESHDS_Mesh aReader;
- aReader.SetFile( aFileName );
- aReader.SetMeshId(-1);
- Driver_Mesh::Status aStatus;
- list<string> aNames = aReader.GetMeshNames(aStatus);
- SMESH::mesh_array_var aResult = new SMESH::mesh_array();
- SMESH::DriverMED_ReadStatus aStatus2 = (SMESH::DriverMED_ReadStatus)aStatus;
- if (aStatus2 == SMESH::DRS_OK) {
- // Iterate through all meshes and create mesh objects
- for ( list<string>::iterator it = aNames.begin(); it != aNames.end(); it++ ) {
- // create mesh
- SMESH::SMESH_Mesh_var mesh = createMesh();
-
- // publish mesh in the study
- SALOMEDS::SObject_var aSO;
- if (CanPublishInStudy(mesh)) {
- aSO = PublishMesh(aStudy, mesh.in(), (*it).c_str());
- aResultList.push_back(aSO->GetID());