SIMAN removal

This commit is contained in:
Cédric Aguerre 2015-07-28 16:40:24 +02:00 committed by vsr
parent f8174cfe42
commit ab0d7e24cd
2 changed files with 85 additions and 236 deletions

View File

@ -66,7 +66,6 @@
#include <SALOMEDS_Tool.hxx>
#include <SALOMEDS_wrap.hxx>
#include <SALOME_DataContainer_i.hxx>
#include <Basics_DirUtils.hxx>
#include <set>
@ -326,8 +325,8 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
std::string plgId;
for ( size_t j = 0; j < infoSeq->length(); ++j )
for ( size_t i = 0; i < infoSeq[j].params.length(); ++i ) {
std::string param_name = infoSeq[j].params[i].name.in();
std::string param_value = infoSeq[j].params[i].value.in();
std::string param_name = infoSeq[j].params[i].name.in();
std::string param_value = infoSeq[j].params[i].value.in();
if( param_name == PLUGIN_NAME) {
plgId = param_value;
break;
@ -2459,7 +2458,7 @@ GEOM::GEOM_IOperations_ptr GEOM_Gen_i::GetPluginOperations(CORBA::Long theStudyI
aServant = myOpCreatorMap[aLibName]->Create(_poa, theStudyID, engine, _impl);
// activate the CORBA servant
if (aServant)
operations = aServant->_this();
operations = aServant->_this();
}
}
catch (SALOME_Exception& S_ex) {
@ -2809,7 +2808,7 @@ char* GEOM_Gen_i::getVersion()
// purpose : Creates and returns a new folder object
//=================================================================================
SALOMEDS::SObject_ptr GEOM_Gen_i::CreateFolder(const char* theName,
SALOMEDS::SObject_ptr theFather)
SALOMEDS::SObject_ptr theFather)
{
SALOMEDS::SObject_var aFolderSO;
@ -2862,7 +2861,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::CreateFolder(const char* theName,
// purpose : Moves GEOM object to the specified folder
//=================================================================================
void GEOM_Gen_i::MoveToFolder(GEOM::GEOM_Object_ptr theObject,
SALOMEDS::SObject_ptr theFolder) {
SALOMEDS::SObject_ptr theFolder) {
GEOM::object_list_var objects = new GEOM::object_list();
objects->length( 1 );
SALOMEDS::SObject_var aSO = theFolder->GetStudy()->FindObjectID( theObject->GetStudyEntry() );
@ -2875,7 +2874,7 @@ void GEOM_Gen_i::MoveToFolder(GEOM::GEOM_Object_ptr theObject,
// purpose : Moves list of GEOM objects to the specified folder
//=================================================================================
void GEOM_Gen_i::MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
SALOMEDS::SObject_ptr theFolder) {
SALOMEDS::SObject_ptr theFolder) {
int aLen = theListOfGO.length();
GEOM::object_list_var objects = new GEOM::object_list();
objects->length( aLen );
@ -2896,8 +2895,8 @@ void GEOM_Gen_i::MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
// Is used in the drag-n-drop functionality.
//=================================================================================
void GEOM_Gen_i::Move( const GEOM::object_list& what,
SALOMEDS::SObject_ptr where,
CORBA::Long row )
SALOMEDS::SObject_ptr where,
CORBA::Long row )
{
if ( CORBA::is_nil( where ) ) return;
@ -2930,155 +2929,12 @@ void GEOM_Gen_i::Move( const GEOM::object_list& what,
}
}
//=================================================================================
// function : importData
// purpose : imports geometrical data file into the GEOM internal data structure
//=================================================================================
Engines::ListOfIdentifiers* GEOM_Gen_i::importData(
CORBA::Long studyId, Engines::DataContainer_ptr data, const Engines::ListOfOptions& options)
{
CORBA::Object_var aSMObject = name_service->Resolve( "/myStudyManager" );
SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId );
Engines::ListOfIdentifiers_var aResult = new Engines::ListOfIdentifiers;
GEOM::GEOM_IInsertOperations_var aInsOp = GetIInsertOperations(aStudy->StudyId());
if (aInsOp->_is_nil()) {
MESSAGE("No insert operations!");
return aResult._retn();
}
// Get a temporary directory to store a file
std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
std::string aFileName("file");
if (aFileName.rfind("/") != std::string::npos) { // remove folders from the name
aFileName = aFileName.substr(aFileName.rfind("/") + 1);
}
std::string anExtension(data->extension());
aFileName += "." + anExtension;
// convert extension to upper case
std::transform(anExtension.begin(), anExtension.end(), anExtension.begin(), ::toupper);
std::string aFullPath = aTmpDir + aFileName;
Engines::TMPFile* aFileStream = data->get();
const char *aBuffer = (const char*)aFileStream->NP_data();
#ifdef WIN32
std::ofstream aFile(aFullPath.c_str(), std::ios::binary);
#else
std::ofstream aFile(aFullPath.c_str());
#endif
aFile.write(aBuffer, aFileStream->length());
aFile.close();
GEOM::ListOfGBO_var aObjects = aInsOp->ImportFile(aFullPath.c_str(), "XAO");
if ( aObjects->length() > 0 && aInsOp->IsDone() ) {
aResult->length(aObjects->length());
// publish main object (first in the list of returned geom objects)
CORBA::String_var aName = aObjects[0]->GetName();
SALOMEDS::SObject_var aSO = PublishInStudy(aStudy.in(), SALOMEDS::SObject::_nil(), aObjects[0].in(), aName.in());
aResult[0] = aSO->GetID();
// publish groups && fields
for (int i = 1; i < aObjects->length(); i++ ) {
aName = aObjects[i]->GetName();
aSO = AddInStudy(aStudy.in(), aObjects[0].in(), aName.in(), aObjects[0].in());
aResult[i] = aSO->GetID();
}
}
else {
if (aObjects->length() == 0)
MESSAGE("ImportXAO operation is failed for file "<<aFullPath.c_str());
if (!aInsOp->IsDone())
MESSAGE("Import operation is not done for file "<<aFullPath.c_str());
return aResult._retn();
}
// remove temporary file and directory
SALOMEDS::ListOfFileNames aTmpFiles;
aTmpFiles.length(1);
aTmpFiles[0] = aFileName.c_str();
SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aTmpFiles, true);
_impl->DocumentModified(studyId, false);
return aResult._retn();
}
//=================================================================================
// function : getModifiedData
// purpose : exports all geometry of this GEOM module into one BRep file
//=================================================================================
Engines::ListOfData* GEOM_Gen_i::getModifiedData(CORBA::Long studyId)
{
Engines::ListOfData_var aResult = new Engines::ListOfData;
if (!_impl->DocumentModified(studyId)) {
MESSAGE("Document is not modified")
return aResult._retn();
}
CORBA::Object_var aSMObject = name_service->Resolve("/myStudyManager");
SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
if (CORBA::is_nil(aStudyManager))
return aResult._retn();
SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId );
if (CORBA::is_nil(aStudy))
return aResult._retn();
SALOMEDS::SComponent_var aComponent = aStudy->FindComponent("GEOM");
if (CORBA::is_nil(aComponent))
return aResult._retn();
SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(aComponent); // check only published shapes
GEOM::GEOM_IInsertOperations_var aInsOp = GetIInsertOperations(aStudy->StudyId());
if (aInsOp->_is_nil()) {
MESSAGE("No insert operations!");
return aResult._retn();
}
GEOM::GEOM_Object_var shapeObj;
for(; anIter->More(); anIter->Next()) {
SALOMEDS::SObject_var aSO = anIter->Value();
SALOMEDS::SObject_var aRefSO;
// export only not referenced objects, or referenced outside of GEOM
if (!aSO->ReferencedObject(aRefSO) || aRefSO->GetFatherComponent()->GetID() != aComponent->GetID()) {
CORBA::Object_var anObj = aSO->GetObject();
if (!CORBA::is_nil(anObj)) {
GEOM::GEOM_Object_var aCORBAMainShape = GEOM::GEOM_Object::_narrow(anObj);
if(!aCORBAMainShape->_is_nil()) {
CORBA::String_var entry = aCORBAMainShape->GetEntry();
Handle(GEOM_Object) aMainShape = Handle(GEOM_Object)::DownCast(_impl->GetObject(studyId, entry));
GEOM::shape_type aCORBAShapeType = aCORBAMainShape->GetShapeType();
if (!aMainShape.IsNull() && !(aCORBAShapeType == GEOM::VERTEX) && !(aCORBAShapeType == GEOM::EDGE)) {
shapeObj = aCORBAMainShape;
break;
}
}
}
}
}
if (!CORBA::is_nil(shapeObj)) { // Shape is correct, write it to the temporary file
std::string aPath = Kernel_Utils::GetTmpFileName() + ".xao";
aInsOp->Export(shapeObj.in(), aPath.c_str(), "XAO");
aResult->length(1);
Engines::DataContainer_var aData = (new Engines_DataContainer_i(
aPath.c_str(), "", "", true))->_this();
aResult[0] = aData;
} else {
MESSAGE("No shapes to export");
}
return aResult._retn();
}
//=======================================================================
// function : GetDependencyTree
// purpose : Collects dependencies of the given objects from other ones
//=======================================================================
SALOMEDS::TMPFile* GEOM_Gen_i::GetDependencyTree( SALOMEDS::Study_ptr theStudy,
const GEOM::string_array& theObjectEntries ) {
const GEOM::string_array& theObjectEntries ) {
// fill in the tree structure
GEOMUtils::TreeModel tree;
@ -3119,9 +2975,9 @@ SALOMEDS::TMPFile* GEOM_Gen_i::GetDependencyTree( SALOMEDS::Study_ptr theStudy,
// purpose : Collects the entries of objects on that the given one depends
//=======================================================================
void GEOM_Gen_i::getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
GEOMUtils::LevelsList &upLevelList,
std::map< std::string, std::set<std::string> > &passedEntries,
int level ) {
GEOMUtils::LevelsList &upLevelList,
std::map< std::string, std::set<std::string> > &passedEntries,
int level ) {
std::string aGboEntry = gbo->GetEntry();
GEOMUtils::NodeLinks anEntries;
GEOMUtils::LevelInfo aLevelMap;
@ -3133,7 +2989,7 @@ void GEOM_Gen_i::getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
// get the existent map
aLevelMap = upLevelList.at(level-1);
if ( aLevelMap.count( aGboEntry ) > 0 ) {
anEntries = aLevelMap[ aGboEntry ];
anEntries = aLevelMap[ aGboEntry ];
}
}
}
@ -3167,9 +3023,9 @@ void GEOM_Gen_i::getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
// purpose : Collects the entries of objects that depends on the given one
//=======================================================================
void GEOM_Gen_i::getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
GEOMUtils::LevelsList &downLevelList,
std::map< std::string, std::set<std::string> > &passedEntries,
int level ) {
GEOMUtils::LevelsList &downLevelList,
std::map< std::string, std::set<std::string> > &passedEntries,
int level ) {
std::string aGboEntry = gbo->GetEntry();
Handle(TDocStd_Document) aDoc = GEOM_Engine::GetEngine()->GetDocument(gbo->GetStudyID());
Handle(TDataStd_TreeNode) aNode, aRoot;
@ -3234,10 +3090,10 @@ void GEOM_Gen_i::getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
// purpose : Fills 3 lists that is used to clean study of redundant objects
//==============================================================================
void GEOM_Gen_i::GetEntriesToReduceStudy(SALOMEDS::Study_ptr theStudy,
GEOM::string_array& theSelectedEntries,
GEOM::string_array& theParentEntries,
GEOM::string_array& theSubEntries,
GEOM::string_array& theOtherEntries)
GEOM::string_array& theSelectedEntries,
GEOM::string_array& theParentEntries,
GEOM::string_array& theSubEntries,
GEOM::string_array& theOtherEntries)
{
std::set<std::string> aSelected, aParents, aChildren, anOthers;
for ( int i = 0; i < theSelectedEntries.length(); i++ ) {
@ -3344,10 +3200,10 @@ void GEOM_Gen_i::GetEntriesToReduceStudy(SALOMEDS::Study_ptr theStudy,
// purpose :
//==============================================================================
void GEOM_Gen_i::includeParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj,
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers)
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers)
{
std::string anEntry = geomObj->GetEntry();
if ( aSelected.count( anEntry ) == 0 ) {
@ -3369,10 +3225,10 @@ void GEOM_Gen_i::includeParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj,
for( int i = 0; i < depList->length(); i++ ) {
aDepEntry = depList[i]->GetEntry();
if ( depList[i]->_is_nil() ||
aDepEntry == anEntry || // skip self-depending
aSelected.count( aDepEntry ) > 0 || // skip selected objects
aParents.count( aDepEntry ) > 0 // skip already processed objects
)
aDepEntry == anEntry || // skip self-depending
aSelected.count( aDepEntry ) > 0 || // skip selected objects
aParents.count( aDepEntry ) > 0 // skip already processed objects
)
continue;
includeParentDependencies( depList[i], aSelected, aParents, aChildren, anOthers );
}
@ -3383,11 +3239,11 @@ void GEOM_Gen_i::includeParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj,
// purpose :
//==============================================================================
void GEOM_Gen_i::includeSubObjects(SALOMEDS::Study_ptr theStudy,
const std::string& aSelectedEntry,
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers)
const std::string& aSelectedEntry,
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers)
{
std::set<std::string>::iterator foundIt;
Handle(GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), aSelectedEntry.c_str(), false);
@ -3412,10 +3268,10 @@ void GEOM_Gen_i::includeSubObjects(SALOMEDS::Study_ptr theStudy,
if ( foundIt == aParents.end() ) { // add to sub-objects if it is not in parents list
foundIt = aSelected.find( aSubEntryStr );
if ( foundIt == aSelected.end() ) { // add to sub-objects if it is not in selected list
aChildren.insert( aSubEntryStr );
foundIt = anOthers.find( aSubEntryStr );
if ( foundIt != anOthers.end() )
anOthers.erase( foundIt );
aChildren.insert( aSubEntryStr );
foundIt = anOthers.find( aSubEntryStr );
if ( foundIt != anOthers.end() )
anOthers.erase( foundIt );
}
}
includeSubObjects( theStudy, aSubEntryStr, aSelected, aParents, aChildren, anOthers );

View File

@ -201,7 +201,7 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
//Collects dependencies of the given objects from other ones
SALOMEDS::TMPFile* GetDependencyTree(SALOMEDS::Study_ptr theStudy,
const GEOM::string_array& theObjectEntries);
const GEOM::string_array& theObjectEntries);
//-----------------------------------------------------------------------//
// Transaction methods //
@ -302,36 +302,29 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
// Create a new folder object
SALOMEDS::SObject_ptr CreateFolder(const char* theName,
SALOMEDS::SObject_ptr theFather);
SALOMEDS::SObject_ptr theFather);
// Move GEOM object to the specified folder
void MoveToFolder(GEOM::GEOM_Object_ptr theObject,
SALOMEDS::SObject_ptr theFolder);
SALOMEDS::SObject_ptr theFolder);
// Move list of GEOM objects to the specified folder
void MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
SALOMEDS::SObject_ptr theFolder);
SALOMEDS::SObject_ptr theFolder);
// Move objects to the specified position
void Move( const GEOM::object_list& what,
SALOMEDS::SObject_ptr where,
CORBA::Long row );
// 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);
SALOMEDS::SObject_ptr where,
CORBA::Long row );
/*! \brief Fills 3 lists that is used to clean study of redundant objects.
* To be used from GUI.
*/
void GetEntriesToReduceStudy(SALOMEDS::Study_ptr theStudy,
GEOM::string_array& theSelectedEntries,
GEOM::string_array& theParentEntries,
GEOM::string_array& theSubEntries,
GEOM::string_array& theOtherEntries);
GEOM::string_array& theSelectedEntries,
GEOM::string_array& theParentEntries,
GEOM::string_array& theSubEntries,
GEOM::string_array& theOtherEntries);
//-----------------------------------------------------------------------//
// Internal methods //
@ -383,26 +376,26 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
void getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
GEOMUtils::LevelsList &upLevelList,
std::map< std::string, std::set<std::string> > &passedEntries,
std::map< std::string, std::set<std::string> > &passedEntries,
int level = 0 );
void getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
GEOMUtils::LevelsList &downLevelList,
std::map< std::string, std::set<std::string> > &passedEntries,
std::map< std::string, std::set<std::string> > &passedEntries,
int level = 0 );
void includeParentDependencies(GEOM::GEOM_BaseObject_ptr gbo,
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers);
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers);
void includeSubObjects(SALOMEDS::Study_ptr theStudy,
const std::string& aSelectedEntry,
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers);
const std::string& aSelectedEntry,
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers);
void LoadPlugin(const std::string& theLibName);