SIMAN removal

This commit is contained in:
Cédric Aguerre 2015-07-28 17:06:26 +02:00
parent 938ed6ac35
commit 8ab62ff6f4
2 changed files with 85 additions and 235 deletions

View File

@ -113,7 +113,6 @@
#include <OpUtil.hxx> #include <OpUtil.hxx>
#include <SALOMEDS_Tool.hxx> #include <SALOMEDS_Tool.hxx>
#include <SALOME_Container_i.hxx> #include <SALOME_Container_i.hxx>
#include <SALOME_DataContainer_i.hxx>
#include <SALOME_LifeCycleCORBA.hxx> #include <SALOME_LifeCycleCORBA.hxx>
#include <SALOME_NamingService.hxx> #include <SALOME_NamingService.hxx>
#include <Utils_CorbaException.hxx> #include <Utils_CorbaException.hxx>
@ -301,9 +300,6 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb,
myIsHistoricalPythonDump = true; myIsHistoricalPythonDump = true;
myToForgetMeshDataOnHypModif = false; myToForgetMeshDataOnHypModif = false;
myImportedStudyChanged = true;
myImportedStudyId = 0;
// set it in standalone mode only // set it in standalone mode only
//OSD::SetSignal( true ); //OSD::SetSignal( true );
@ -4990,8 +4986,6 @@ int SMESH_Gen_i::RegisterObject(CORBA::Object_ptr theObject)
{ {
StudyContext* myStudyContext = GetCurrentStudyContext(); StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && !CORBA::is_nil( theObject )) { if ( myStudyContext && !CORBA::is_nil( theObject )) {
if (GetCurrentStudyID() == myImportedStudyId)
myImportedStudyChanged = true;
CORBA::String_var iorString = GetORB()->object_to_string( theObject ); CORBA::String_var iorString = GetORB()->object_to_string( theObject );
return myStudyContext->addObject( string( iorString.in() ) ); return myStudyContext->addObject( string( iorString.in() ) );
} }
@ -5135,11 +5129,11 @@ CORBA::Boolean SMESH_Gen_i::IsApplicable ( const char* theAlgoType,
// purpose : Collect indices of elements, which are located inside the sphere // purpose : Collect indices of elements, which are located inside the sphere
//================================================================================= //=================================================================================
SMESH::long_array* SMESH_Gen_i::GetInsideSphere( SMESH::SMESH_IDSource_ptr meshPart, SMESH::long_array* SMESH_Gen_i::GetInsideSphere( SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
CORBA::Double theX, CORBA::Double theX,
CORBA::Double theY, CORBA::Double theY,
CORBA::Double theZ, CORBA::Double theZ,
CORBA::Double theR) { CORBA::Double theR) {
SMESH::long_array_var aResult = new SMESH::long_array(); SMESH::long_array_var aResult = new SMESH::long_array();
if(meshPart->_is_nil()) if(meshPart->_is_nil())
return aResult._retn(); return aResult._retn();
@ -5160,13 +5154,13 @@ SMESH::long_array* SMESH_Gen_i::GetInsideSphere( SMESH::SMESH_IDSource_ptr meshP
} }
SMESH::long_array* SMESH_Gen_i::GetInsideBox( SMESH::SMESH_IDSource_ptr meshPart, SMESH::long_array* SMESH_Gen_i::GetInsideBox( SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
CORBA::Double theX1, CORBA::Double theX1,
CORBA::Double theY1, CORBA::Double theY1,
CORBA::Double theZ1, CORBA::Double theZ1,
CORBA::Double theX2, CORBA::Double theX2,
CORBA::Double theY2, CORBA::Double theY2,
CORBA::Double theZ2) { CORBA::Double theZ2) {
SMESH::long_array_var aResult = new SMESH::long_array(); SMESH::long_array_var aResult = new SMESH::long_array();
if( meshPart->_is_nil() ) if( meshPart->_is_nil() )
return aResult._retn(); return aResult._retn();
@ -5185,15 +5179,15 @@ SMESH::long_array* SMESH_Gen_i::GetInsideBox( SMESH::SMESH_IDSource_ptr meshPart
} }
SMESH::long_array* SMESH_Gen_i::GetInsideCylinder( SMESH::SMESH_IDSource_ptr meshPart, SMESH::long_array* SMESH_Gen_i::GetInsideCylinder( SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
CORBA::Double theX, CORBA::Double theX,
CORBA::Double theY, CORBA::Double theY,
CORBA::Double theZ, CORBA::Double theZ,
CORBA::Double theDX, CORBA::Double theDX,
CORBA::Double theDY, CORBA::Double theDY,
CORBA::Double theDZ, CORBA::Double theDZ,
CORBA::Double theH, CORBA::Double theH,
CORBA::Double theR ){ CORBA::Double theR ){
SMESH::long_array_var aResult = new SMESH::long_array(); SMESH::long_array_var aResult = new SMESH::long_array();
if( meshPart->_is_nil() ) if( meshPart->_is_nil() )
return aResult._retn(); return aResult._retn();
@ -5216,9 +5210,9 @@ SMESH::long_array* SMESH_Gen_i::GetInsideCylinder( SMESH::SMESH_IDSource_ptr mes
} }
SMESH::long_array* SMESH_Gen_i::GetInside( SMESH::SMESH_IDSource_ptr meshPart, SMESH::long_array* SMESH_Gen_i::GetInside( SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
GEOM::GEOM_Object_ptr theGeom, GEOM::GEOM_Object_ptr theGeom,
CORBA::Double theTolerance ) { CORBA::Double theTolerance ) {
SMESH::long_array_var aResult = new SMESH::long_array(); SMESH::long_array_var aResult = new SMESH::long_array();
if( meshPart->_is_nil() || theGeom->_is_nil() ) if( meshPart->_is_nil() || theGeom->_is_nil() )
return aResult._retn(); return aResult._retn();
@ -5239,9 +5233,9 @@ SMESH::long_array* SMESH_Gen_i::GetInside( SMESH::SMESH_IDSource_ptr meshPart,
std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart, std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
TopoDS_Shape& aShape, TopoDS_Shape& aShape,
double* theTolerance) { double* theTolerance) {
std::vector<long> res; std::vector<long> res;
SMESH::SMESH_Mesh_var mesh = meshPart->GetMesh(); SMESH::SMESH_Mesh_var mesh = meshPart->GetMesh();
@ -5272,10 +5266,10 @@ std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart,
SMDS_ElemIteratorPtr elemIt = meshDS->elementsIterator( aType ); SMDS_ElemIteratorPtr elemIt = meshDS->elementsIterator( aType );
if ( elemIt ) { if ( elemIt ) {
while ( elemIt->more() ) { while ( elemIt->more() ) {
const SMDS_MeshElement* anElem = elemIt->next(); const SMDS_MeshElement* anElem = elemIt->next();
long anId = anElem->GetID(); long anId = anElem->GetID();
if ( anElementsOnShape->IsSatisfy( anId ) ) if ( anElementsOnShape->IsSatisfy( anId ) )
res.push_back( anId ); res.push_back( anId );
} }
} }
} }
@ -5284,20 +5278,20 @@ std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart,
if(theElemType == SMESH::NODE) { if(theElemType == SMESH::NODE) {
SMESH::long_array_var nodes = gsource->GetNodeIDs(); SMESH::long_array_var nodes = gsource->GetNodeIDs();
for ( int i = 0; i < nodes->length(); ++i ) { for ( int i = 0; i < nodes->length(); ++i ) {
if ( const SMDS_MeshNode* node = meshDS->FindNode( nodes[i] ) ) { if ( const SMDS_MeshNode* node = meshDS->FindNode( nodes[i] ) ) {
long anId = node->GetID(); long anId = node->GetID();
if ( anElementsOnShape->IsSatisfy( anId ) ) if ( anElementsOnShape->IsSatisfy( anId ) )
res.push_back( anId ); res.push_back( anId );
} }
} }
} else if (gsource->GetType() == theElemType || theElemType == SMESH::ALL ) { } else if (gsource->GetType() == theElemType || theElemType == SMESH::ALL ) {
SMESH::long_array_var elems = gsource->GetListOfID(); SMESH::long_array_var elems = gsource->GetListOfID();
for ( int i = 0; i < elems->length(); ++i ) { for ( int i = 0; i < elems->length(); ++i ) {
if ( const SMDS_MeshElement* elem = meshDS->FindElement( elems[i] ) ) { if ( const SMDS_MeshElement* elem = meshDS->FindElement( elems[i] ) ) {
long anId = elem->GetID(); long anId = elem->GetID();
if ( anElementsOnShape->IsSatisfy( anId ) ) if ( anElementsOnShape->IsSatisfy( anId ) )
res.push_back( anId ); res.push_back( anId );
} }
} }
} }
} }
@ -5307,9 +5301,9 @@ std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart,
for ( int i = 0; i < elems->length(); ++i ) { for ( int i = 0; i < elems->length(); ++i ) {
const SMDS_MeshElement* elem = ( theElemType == SMESH::NODE ) ? meshDS->FindNode( elems[i] ) : meshDS->FindElement( elems[i] ); const SMDS_MeshElement* elem = ( theElemType == SMESH::NODE ) ? meshDS->FindNode( elems[i] ) : meshDS->FindElement( elems[i] );
if (elem) { if (elem) {
long anId = elem->GetID(); long anId = elem->GetID();
if ( anElementsOnShape->IsSatisfy( anId ) ) if ( anElementsOnShape->IsSatisfy( anId ) )
res.push_back( anId ); res.push_back( anId );
} }
} }
} }
@ -5317,141 +5311,6 @@ std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart,
} }
//=================================================================================
// 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());
}
// Read mesh data (groups are published automatically by ImportMEDFile())
SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( mesh ).in() );
ASSERT( meshServant );
meshServant->ImportMEDFile( aFileName.c_str(), (*it).c_str() );
//meshServant->GetImpl().GetMeshDS()->Modified();
}
} else {
MESSAGE("Opening MED file problems "<<aFileName.c_str())
return aResultIds._retn();
}
// remove temporary file
#ifdef WIN32
DeleteFileA(aFileName.c_str());
#else
unlink(aFileName.c_str());
#endif
if (!aResultList.empty()) {
aResultIds->length(aResultList.size());
list<string>::iterator aListIter = aResultList.begin();
for(int a = 0; aListIter != aResultList.end(); aListIter++, a++)
aResultIds[a] = aListIter->c_str();
}
myImportedStudyId = studyId;
myImportedStudyChanged = false;
return aResultIds._retn();
}
//=================================================================================
// function : getModifiedData
// purpose : exports all geometry of this GEOM module into one BRep file
//=================================================================================
Engines::ListOfData* SMESH_Gen_i::getModifiedData(CORBA::Long studyId)
{
Engines::ListOfData_var aResult = new Engines::ListOfData;
if (!myImportedStudyChanged) {
INFOS("SMESH module data was not changed")
return aResult._retn();
}
CORBA::Object_var aSMObject = myNS->Resolve("/myStudyManager");
SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID(studyId);
SetCurrentStudy(aStudy);
SALOMEDS::SComponent_var aComponent = aStudy->FindComponent("SMESH");
if (CORBA::is_nil(aComponent))
return aResult._retn();
std::string aFullPath(Kernel_Utils::GetTmpFileName());
aFullPath += ".med";
StudyContext* myStudyContext = GetCurrentStudyContext();
SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(aComponent); // check only published meshes
int aNumMeshes = 0; // number of meshes in result
for(; anIter->More(); anIter->Next()) {
SALOMEDS::SObject_var aSO = anIter->Value();
CORBA::Object_var anObj = aSO->GetObject();
if (!CORBA::is_nil(anObj)) {
SMESH::SMESH_Mesh_var aCORBAMesh = SMESH::SMESH_Mesh::_narrow(anObj);
if(!aCORBAMesh->_is_nil()) {
SMESH_Mesh_i* myImpl = dynamic_cast<SMESH_Mesh_i*>(GetServant(aCORBAMesh).in());
if (myImpl) {
myImpl->Load();
SMESH_Mesh& aMesh = myImpl->GetImpl();
CORBA::String_var objName = aSO->GetName();
aMesh.ExportMED(aFullPath.c_str(), objName.in(), false, MED::eV2_2, 0);
aNumMeshes++;
}
}
}
}
if (aNumMeshes > 0) { // prepare a container to store files
INFOS("Write "<<aNumMeshes<<" meshes to "<<aFullPath.c_str());
aResult->length(1);
Engines::DataContainer_var aData = (new Engines_DataContainer_i(
aFullPath.c_str(), "", "", true))->_this();
aResult[0] = aData;
}
return aResult._retn();
}
//============================================================================= //=============================================================================
/*! /*!
* SMESHEngine_factory * SMESHEngine_factory

View File

@ -491,13 +491,6 @@ public:
void CleanPythonTrace (int theStudyID); void CleanPythonTrace (int theStudyID);
// SIMAN-related functions (check out/check in) : import data to study
virtual Engines::ListOfIdentifiers* importData(CORBA::Long studyId,
Engines::DataContainer_ptr data,
const Engines::ListOfOptions& options);
// SIMAN-related functions (check out/check in) : get modified data
virtual Engines::ListOfData* getModifiedData(CORBA::Long studyId);
// ***************************************** // *****************************************
// Internal methods // Internal methods
// ***************************************** // *****************************************
@ -609,36 +602,36 @@ public:
CORBA::Boolean toCheckAll); CORBA::Boolean toCheckAll);
SMESH::long_array* GetInsideSphere( SMESH::SMESH_IDSource_ptr meshPart, SMESH::long_array* GetInsideSphere( SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
CORBA::Double theX, CORBA::Double theX,
CORBA::Double theY, CORBA::Double theY,
CORBA::Double theZ, CORBA::Double theZ,
CORBA::Double theR); CORBA::Double theR);
SMESH::long_array* GetInsideBox( SMESH::SMESH_IDSource_ptr meshPart, SMESH::long_array* GetInsideBox( SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
CORBA::Double theX1, CORBA::Double theX1,
CORBA::Double theY1, CORBA::Double theY1,
CORBA::Double theZ1, CORBA::Double theZ1,
CORBA::Double theX2, CORBA::Double theX2,
CORBA::Double theY2, CORBA::Double theY2,
CORBA::Double theZ2); CORBA::Double theZ2);
SMESH::long_array* GetInsideCylinder( SMESH::SMESH_IDSource_ptr meshPart, SMESH::long_array* GetInsideCylinder( SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
CORBA::Double theX, CORBA::Double theX,
CORBA::Double theY, CORBA::Double theY,
CORBA::Double theZ, CORBA::Double theZ,
CORBA::Double theDX, CORBA::Double theDX,
CORBA::Double theDY, CORBA::Double theDY,
CORBA::Double theDZ, CORBA::Double theDZ,
CORBA::Double theH, CORBA::Double theH,
CORBA::Double theR ); CORBA::Double theR );
SMESH::long_array* GetInside( SMESH::SMESH_IDSource_ptr meshPart, SMESH::long_array* GetInside( SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
GEOM::GEOM_Object_ptr theGeom, GEOM::GEOM_Object_ptr theGeom,
CORBA::Double theTolerance ); CORBA::Double theTolerance );
private: private:
// Get hypothesis creator // Get hypothesis creator
@ -664,9 +657,9 @@ private:
bool theStudyIsBeingClosed=false); bool theStudyIsBeingClosed=false);
std::vector<long> _GetInside(SMESH::SMESH_IDSource_ptr meshPart, std::vector<long> _GetInside(SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
TopoDS_Shape& aShape, TopoDS_Shape& aShape,
double* theTolerance = NULL); double* theTolerance = NULL);
private: private:
static GEOM::GEOM_Gen_var myGeomGen; static GEOM::GEOM_Gen_var myGeomGen;
@ -695,8 +688,6 @@ private:
std::vector< int > myLastParamIndex; std::vector< int > myLastParamIndex;
std::vector< std::string > myLastParameters; std::vector< std::string > myLastParameters;
std::string myLastObj; std::string myLastObj;
int myImportedStudyId; // SIMAN: identifier of the imported in importData study to keep no-modifiection flag for getModifiedData method
int myImportedStudyChanged; // SIMAN: flag that indicates that the imported study has been changed (by creation of the additional mesh)
}; };