#include <SALOMEDS_Tool.hxx>
#include <SALOMEDS_wrap.hxx>
-#include <SALOME_DataContainer_i.hxx>
#include <Basics_DirUtils.hxx>
#include <set>
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;
useCaseBuilder->SetRootCurrent();
useCaseBuilder->Append( theComponent ); // component object is added as the top level item
}
-
- SALOMEDS::ChildIterator_wrap it = study->NewChildIterator( theComponent );
+
+ SALOMEDS::ChildIterator_wrap it = study->NewChildIterator( theComponent );
for ( it->InitEx(true); it->More(); it->Next() ) {
if ( !useCaseBuilder->IsUseCaseNode( it->Value() ) ) {
useCaseBuilder->AppendTo( it->Value()->GetFather(), it->Value() );
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) {
aPlatformLibName += theLibName;
aPlatformLibName += ".so";
#endif
-
+
// check, if corresponding operations are already created
if (myOpCreatorMap.find(theLibName) == myOpCreatorMap.end()) {
// load plugin library
throw(SALOME_Exception(LOCALIZED( "Can't load server geometry plugin library" )));
#endif
}
-
+
// get method, returning operations creator
typedef GEOM_GenericOperationsCreator* (*GetOperationsCreator)();
GetOperationsCreator procHandle =
UnLoadLib(libHandle);
throw(SALOME_Exception(LOCALIZED("bad geometry plugin library")));
}
-
+
// get operations creator
GEOM_GenericOperationsCreator* aCreator = procHandle();
if (aCreator) {
// function : CreateFolder()
// 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 GEOM_Gen_i::CreateFolder(const char* theName,
+ SALOMEDS::SObject_ptr theFather)
{
SALOMEDS::SObject_var aFolderSO;
// function : MoveToFolder()
// purpose : Moves GEOM object to the specified folder
//=================================================================================
-void GEOM_Gen_i::MoveToFolder(GEOM::GEOM_Object_ptr theObject,
- SALOMEDS::SObject_ptr theFolder) {
+void GEOM_Gen_i::MoveToFolder(GEOM::GEOM_Object_ptr theObject,
+ 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() );
// function : MoveListToFolder()
// purpose : Moves list of GEOM objects to the specified folder
//=================================================================================
-void GEOM_Gen_i::MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
- SALOMEDS::SObject_ptr theFolder) {
+void GEOM_Gen_i::MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
+ SALOMEDS::SObject_ptr theFolder) {
int aLen = theListOfGO.length();
GEOM::object_list_var objects = new GEOM::object_list();
objects->length( aLen );
//=================================================================================
// function : Move()
-// purpose : Moves objects to the specified position.
+// purpose : Moves objects to the specified position.
// 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;
SALOMEDS::SComponent_var father = where->GetFatherComponent();
std::string dataType = father->ComponentDataType();
if ( dataType != "GEOM" ) return; // not a GEOM component
-
+
SALOMEDS::SObject_var objAfter;
if ( row >= 0 && useCaseBuilder->HasChildren( where ) ) {
// insert at given row -> find insertion position
objAfter = useCaseIt->Value();
}
}
-
+
for ( int i = 0; i < what.length(); i++ ) {
SALOMEDS::SObject_var sobj = what[i];
if ( CORBA::is_nil( sobj ) ) continue; // skip bad object
}
}
-//=================================================================================
-// 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;
// translation the tree into string
std::string treeStr;
GEOMUtils::ConvertTreeToString( tree, treeStr );
-
+
// put string into stream
char* aBuffer = (char*)CORBA::string_dup(treeStr.c_str());
int aBufferSize = strlen((char*)aBuffer);
// function : getUpwardDependency
// 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 ) {
+void GEOM_Gen_i::getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
+ 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;
// get the existent map
aLevelMap = upLevelList.at(level-1);
if ( aLevelMap.count( aGboEntry ) > 0 ) {
- anEntries = aLevelMap[ aGboEntry ];
+ anEntries = aLevelMap[ aGboEntry ];
}
}
}
if ( depList[j]->_is_nil() )
continue;
aDepEntry = depList[j]->GetEntry();
- if ( passedEntries.count( aGboEntry ) > 0 &&
+ if ( passedEntries.count( aGboEntry ) > 0 &&
passedEntries[aGboEntry].count( aDepEntry ) > 0 ) {
//avoid checking the passed objects
continue;
// function : getDownwardDependency
// 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 ) {
+void GEOM_Gen_i::getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
+ 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;
continue;
if ( depList[i]->_is_equivalent( gbo ) ) {
// yes, the current object depends on the given object
- if ( passedEntries.count( aGoEntry ) > 0 &&
+ if ( passedEntries.count( aGoEntry ) > 0 &&
passedEntries[aGoEntry].count( aGboEntry ) > 0 ) {
//avoid checking the passed objects
continue;
// 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++ ) {
if ( aSelected.count( anEntry ) > 0 &&
aParents.count( anEntry ) == 0 ) {
includeParentDependencies( geomObj, aSelected, aParents, aChildren, anOthers );
- } else if ( aParents.count( anEntry ) == 0 &&
+ } else if ( aParents.count( anEntry ) == 0 &&
aChildren.count( anEntry ) == 0 ) {
anOthers.insert( geomObj->GetEntry() );
}
}
// if some selected object is not a main shape,
- // we move it's main shapes into 'selected' list,
+ // we move it's main shapes into 'selected' list,
// because they could not be modified anyhow.
std::set<std::string> aToBeInSelected;
for ( it = aSelected.begin(); it != aSelected.end(); ++it ) {
//==============================================================================
// function : includeParentDependencies
-// purpose :
+// 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 ) {
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 );
}
//==============================================================================
// function : includeSubObjects
-// purpose :
+// 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);
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 );
//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 //
virtual char* getVersion();
// Create a new folder object
- SALOMEDS::SObject_ptr CreateFolder(const char* theName,
- SALOMEDS::SObject_ptr theFather);
+ SALOMEDS::SObject_ptr CreateFolder(const char* theName,
+ SALOMEDS::SObject_ptr theFather);
// Move GEOM object to the specified folder
- void MoveToFolder(GEOM::GEOM_Object_ptr theObject,
- SALOMEDS::SObject_ptr theFolder);
+ void MoveToFolder(GEOM::GEOM_Object_ptr theObject,
+ SALOMEDS::SObject_ptr theFolder);
// Move list of GEOM objects to the specified folder
- void MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
- SALOMEDS::SObject_ptr theFolder);
+ void MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
+ 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 //
const Standard_CString& GrName,
GEOM::ListOfGO_var aResList);
- void getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
- GEOMUtils::LevelsList &upLevelList,
- std::map< std::string, std::set<std::string> > &passedEntries,
+ void getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
+ GEOMUtils::LevelsList &upLevelList,
+ 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,
+ void getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
+ GEOMUtils::LevelsList &downLevelList,
+ 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);