-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
-#ifdef WNT
+#ifdef WIN32
#pragma warning( disable:4786 )
#endif
#include "Utils_ExceptHandlers.hxx"
#include "utilities.h"
-#include "GEOM_Object_i.hh"
#include "GEOM_Object.hxx"
#include "GEOM_Function.hxx"
#include "GEOM_ISubShape.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMImpl_Types.hxx"
#include "GEOMImpl_CopyDriver.hxx"
+#include "GEOMImpl_IInsertOperations.hxx"
#include "GEOM_wrap.hxx"
+#include "GEOMUtils_XmlHandler.hxx"
// Cascade headers
#include <BRep_Builder.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopExp.hxx>
#include <OSD.hxx>
+#include <TDataStd_ChildNodeIterator.hxx>
+#include <TDocStd_Owner.hxx>
+#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
#include <SALOMEDS_Tool.hxx>
#include <SALOMEDS_wrap.hxx>
+#include <Basics_DirUtils.hxx>
#include <set>
#include <sstream>
-#ifdef WNT
+#ifdef WIN32
#include <windows.h>
#include <process.h>
#else
#include <dlfcn.h>
#endif
-#ifdef WNT
+#ifdef WIN32
#define LibHandle HMODULE
#define LoadLib( name ) LoadLibrary( name )
#define GetProc GetProcAddress
#define UnLoadLib( handle ) FreeLibrary( handle );
#else
#define LibHandle void*
- #define LoadLib( name ) dlopen( name, RTLD_LAZY )
+ #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL )
#define GetProc dlsym
#define UnLoadLib( handle ) dlclose( handle );
#endif
{
//work around PAL12004, PAL12628
//OSD::SetSignal( true );
- bool raiseFPE;
-#ifdef _DEBUG_
- raiseFPE = true;
- char* envDisableFPE = getenv("DISABLE_FPE");
- if (envDisableFPE && atoi(envDisableFPE))
- raiseFPE = false;
-#else
- raiseFPE = false;
+ bool raiseFPE = false;
+#if defined(_DEBUG_) | defined(_DEBUG) //the Last for WIN32 default settings
+ char* envEnableFPE = getenv("ENABLE_FPE");
+ if (envEnableFPE && atoi(envEnableFPE))
+ raiseFPE = true;
#endif
OSD::SetSignal( raiseFPE );
}
+
+ GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo();
+ GEOMUtils::PluginInfo::const_iterator it;
+ for (it = plugins.begin(); it != plugins.end(); ++it)
+ {
+ try {
+ LoadPlugin((*it).serverLib);
+ }
+ catch (...) {
+ MESSAGE("Warning: can't load plugin library " << (*it).serverLib);
+ }
+ }
}
//============================================================================
GEOM_Gen_i::~GEOM_Gen_i() {
delete name_service;
delete _impl;
+ std::map<std::string, GEOM_GenericOperationsCreator*>::const_iterator it;
+ for ( it = myOpCreatorMap.begin(); it != myOpCreatorMap.end(); ++it)
+ delete (*it).second;
}
{
SALOMEDS::Study_var aStudy = theSObject->GetStudy();
- Handle(GEOM_BaseObject) anObject =
+ Handle(::GEOM_BaseObject) anObject =
_impl->GetObject(aStudy->StudyId(), aLocalPersistentID);
if ( !anObject.IsNull() )
{
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
- SALOMEDS::UseCaseBuilder_var useCaseBuilder = theStudy->GetUseCaseBuilder();
+ SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder();
SALOMEDS::SComponent_var aFather = theStudy->FindComponent("GEOM");
if (aFather->_is_nil()) {
CORBA::String_var aGeomObjIOR = _orb->object_to_string(theObject);
aResultSO->SetAttrString("AttributeIOR",aGeomObjIOR);
- TCollection_AsciiString anObjectName("Shape_");
+ TCollection_AsciiString anObjectName, aNamePrefix("Shape_");
+ CORBA::Long mytype=aBaseObj->GetType();
// BEGIN: try to find existed name for current shape
- bool HasName = false;
- if ( !aShape->_is_nil() )
+ if ( !aShape->_is_nil() && mytype != GEOM_GROUP)
{
- // recieve current TopoDS shape
+ // receive current TopoDS shape
CORBA::String_var entry = aShape->GetEntry();
- Handle(GEOM_Object) aGShape = Handle(GEOM_Object)::DownCast
+ Handle(::GEOM_Object) aGShape = Handle(::GEOM_Object)::DownCast
( _impl->GetObject( aShape->GetStudyID(), entry ));
TopoDS_Shape TopoSh = aGShape->GetValue();
// find label of main shape
aMainSh = aMainSh->GetMainShape();
}
entry = aMainSh->GetEntry();
- Handle(GEOM_BaseObject) anObj = _impl->GetObject( aMainSh->GetStudyID(), entry );
+ Handle(::GEOM_BaseObject) anObj = _impl->GetObject( aMainSh->GetStudyID(), entry );
TDF_Label aMainLbl = anObj->GetFunction(1)->GetNamingEntry();
// check all named shapes using iterator
TDF_ChildIDIterator anIt (aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
- for (; anIt.More() && !HasName; anIt.Next()) {
+ for (; anIt.More() && anObjectName.IsEmpty(); anIt.Next()) {
Handle(TNaming_NamedShape) anAttr =
Handle(TNaming_NamedShape)::DownCast(anIt.Value());
if (anAttr.IsNull()) continue;
if (S.IsEqual(TopoSh)) {
TDF_Label L = anAttr->Label();
Handle(TDataStd_Name) aName;
- if (L.FindAttribute(TDataStd_Name::GetID(), aName)) {
+ if (L.FindAttribute(TDataStd_Name::GetID(), aName))
anObjectName = aName->Get();
- HasName = true;
- }
}
}
}
// END: try to find existed name for current shape
- CORBA::Long mytype=aBaseObj->GetType();
if ( mytype == GEOM_GROUP ) {
GEOM::GEOM_IGroupOperations_var anOp = GetIGroupOperations( theStudy->StudyId() );
switch ( (TopAbs_ShapeEnum)anOp->GetType( aShape )) {
case TopAbs_VERTEX:
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_PNT" );
- anObjectName = "Group_Of_Vertices_";
+ aNamePrefix = "Group_Of_Vertices_";
break;
case TopAbs_EDGE:
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_EDGE");
- anObjectName = "Group_Of_Edges_";
+ aNamePrefix = "Group_Of_Edges_";
break;
case TopAbs_FACE:
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_FACE");
- anObjectName = "Group_Of_Faces_";
+ aNamePrefix = "Group_Of_Faces_";
break;
case TopAbs_SOLID:
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_SOLID");
- anObjectName = "Group_Of_Solids_";
+ aNamePrefix = "Group_Of_Solids_";
break;
}
} else if ( mytype == GEOM_MARKER ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_LCS");
- anObjectName = "LocalCS_";
- } else if ( mytype > ADVANCED_BASE ) {
+ aNamePrefix = "LocalCS_";
+ } else if ( mytype >= USER_TYPE_EX ) {
+ char buf[20];
+ sprintf( buf, "%d", aBaseObj->GetType() );
+ GEOM::CreationInformationSeq_var infoSeq = aBaseObj->GetCreationInformation();
+ 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();
+ if( param_name == PLUGIN_NAME) {
+ plgId = param_value;
+ break;
+ }
+ }
+ if(plgId.length() > 0 ) {
+ plgId += "::";
+ }
+ plgId +="ICON_OBJBROWSER_";
+ plgId += buf;
+ aResultSO->SetAttrString("AttributePixMap",plgId.c_str());
+ } else if ( mytype > USER_TYPE ) {
char buf[20];
sprintf( buf, "%d", aBaseObj->GetType() );
std::string advId = "ICON_OBJBROWSER_ADVANCED_"; advId += buf;
aResultSO->SetAttrString("AttributePixMap",advId.c_str());
- anObjectName = "Advanced_";
+ aNamePrefix = "Advanced_";
} else if ( mytype == GEOM_FIELD ) {
- anObjectName = "Field_";
+ aNamePrefix = "Field_";
GEOM::GEOM_Field_var aField = GEOM::GEOM_Field::_narrow(theObject);
if ( !aField->_is_nil() )
switch( aField->GetDimension() ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FIELD_SOLID");
}
} else if ( mytype == GEOM_FIELD_STEP ) {
- anObjectName = "Step_";
+ aNamePrefix = "Step_";
} else if ( !aShape->_is_nil() ) {
GEOM::shape_type myshapetype=aShape->GetShapeType();
if ( myshapetype == GEOM::COMPOUND ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPOUND" );
- anObjectName = "Compound_";
+ aNamePrefix = "Compound_";
} else if ( myshapetype == GEOM::COMPSOLID ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPSOLID");
- anObjectName = "Compsolid_";
+ aNamePrefix = "Compsolid_";
} else if ( myshapetype == GEOM::SOLID ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SOLID");
- anObjectName = "Solid_";
+ aNamePrefix = "Solid_";
} else if ( myshapetype == GEOM::SHELL ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SHELL");
- anObjectName = "Shell_";
+ aNamePrefix = "Shell_";
} else if ( myshapetype == GEOM::FACE ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FACE");
- anObjectName = "Face_";
+ aNamePrefix = "Face_";
} else if ( myshapetype == GEOM::WIRE ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_WIRE");
- anObjectName = "Wire_";
+ aNamePrefix = "Wire_";
} else if ( myshapetype == GEOM::EDGE ) {
aResultSO->SetAttrString("AttributePixMap", "ICON_OBJBROWSER_EDGE");
- anObjectName = "Edge_";
+ aNamePrefix = "Edge_";
} else if ( myshapetype == GEOM::VERTEX ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_VERTEX" );
- anObjectName = "Vertex_";
+ aNamePrefix = "Vertex_";
}
}
- if (!HasName)
+ if ( anObjectName.IsEmpty() )
{
- //if (strlen(theName) == 0) anObjectName += TCollection_AsciiString(aResultSO->Tag());
+ //if (strlen(theName) == 0) aNamePrefix += TCollection_AsciiString(aResultSO->Tag());
//else anObjectName = TCollection_AsciiString(CORBA::string_dup(theName));
// asv : 11.11.04 Introducing a more sofisticated method of name creation, just as
if ( strlen( theName ) == 0 ) { // MOST PROBABLY CALLED FROM BATCHMODE OR SUPERVISOR
int i = 0; // (WITH EMPTY NEW NAME)
SALOMEDS::SObject_var obj;
- TCollection_AsciiString aNewObjectName;
do {
- aNewObjectName = anObjectName + TCollection_AsciiString(++i);
- obj = theStudy->FindObject( aNewObjectName.ToCString() );
+ anObjectName = aNamePrefix + TCollection_AsciiString(++i);
+ obj = theStudy->FindObject( anObjectName.ToCString() );
}
while ( !obj->_is_nil() );
- anObjectName = aNewObjectName;
}
- else // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME)
+ else { // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME)
anObjectName = theName;
+ }
}
//Set the study entry as a name of the published GEOM_Object
//============================================================================
// function : CreateAndPublishGroup
-// purpose : auxilary for PublishNamedShapesInStudy
+// purpose : auxiliary for PublishNamedShapesInStudy
//============================================================================
void GEOM_Gen_i::CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_var theMainShape,
GEOM::ListOfGO_var aResList)
{
CORBA::String_var entry = theMainShape->GetEntry();
- //Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
+ //Handle(::GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
Handle(TColStd_HArray1OfInteger) anArray;
if(SeqS.Length()>0) {
// create a group
GEOM::GEOM_Object_wrap GrObj = GOp->CreateGroup( theMainShape, SeqS(1).ShapeType() );
AddInStudy(theStudy, GrObj, GrName, theMainShape._retn());
//CORBA::String_var GrEntry = GrObj->GetEntry();
- //Handle(GEOM_Object) HGrObj = _impl->GetObject(GrObj->GetStudyID(), GrEntry);
+ //Handle(::GEOM_Object) HGrObj = _impl->GetObject(GrObj->GetStudyID(), GrEntry);
// add named objects
- //Handle(GEOM_Object) anObj;
+ //Handle(::GEOM_Object) anObj;
for(int i=1; i<=SeqS.Length(); i++) {
TopoDS_Shape aValue = SeqS.Value(i);
//anArray = new TColStd_HArray1OfInteger(1,1);
GOp->AddObject(GrObj,anIndex);
//anObj = GEOM_Engine::GetEngine()->AddObject(aMainShape->GetDocID(), GEOM_SUBSHAPE);
//if (anObj.IsNull()) continue;
- //Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
+ //Handle(::GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
//if (aFunction.IsNull()) continue;
//GEOM_ISubShape aSSI(aFunction);
//aSSI.SetMainShape(aMainShape->GetLastFunction());
if(theMainShape->_is_nil()) return aResList._retn();
CORBA::String_var entry = theMainShape->GetEntry();
- Handle(GEOM_Object) aMainShape = Handle(GEOM_Object)::DownCast
+ Handle(::GEOM_Object) aMainShape = Handle(::GEOM_Object)::DownCast
( _impl->GetObject( theMainShape->GetStudyID(), entry ));
if (aMainShape.IsNull()) return aResList._retn();
TopoDS_Shape MainSh = aMainShape->GetValue();
// OCCT BUG: cannot save a document (in current folder)
// if directory name is empty
if (aTmpDir.size() == 0) {
-#ifdef WNT
+#ifdef WIN32
aTmpDir = ".\\";
#else
aTmpDir = "./";
if (isMultiFile)
aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath
(theComponent->GetStudy()->URL())).c_str());
- aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
+ aNameWithExt += TCollection_AsciiString("_GEOM.cbf");
aSeq[0] = CORBA::string_dup(aNameWithExt.ToCString());
// Build a full file name of temporary file
TCollection_AsciiString aFullName = TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt;
// OCCT BUG: cannot load a document (from current folder)
// if directory name is empty
if (aTmpDir.size() == 0) {
-#ifdef WNT
+#ifdef WIN32
aTmpDir = ".\\";
#else
aTmpDir = "./";
// Prepare a file name to open
TCollection_AsciiString aNameWithExt("");
SALOMEDS::Study_var study = theComponent->GetStudy();
- if (isMultiFile) {
- CORBA::String_var url = study->URL();
- aNameWithExt = (char*)SALOMEDS_Tool::GetNameFromPath(url.in()).c_str();
+
+ // Get the file name.
+ int i;
+ int aLength = aSeq->length();
+ const char *aGeomSgd = "_GEOM.sgd";
+ const char *aGeomcbf = "_GEOM.cbf";
+
+ for(i = 0; i < aLength; i++) {
+ std::string aName(aSeq[i]);
+
+ if (aName.rfind(aGeomSgd) != std::string::npos ||
+ aName.rfind(aGeomcbf) != std::string::npos) {
+ aNameWithExt = aName.c_str();
+ break;
+ }
}
- aNameWithExt += "_GEOM.sgd";
+
TCollection_AsciiString aFullName = (TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt);
// Open document
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() );
// Find the current Study and StudyBuilder
SALOMEDS::Study_var aStudy = theObject->GetStudy();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::UseCaseBuilder_var anUseCaseBuilder = aStudy->GetUseCaseBuilder();
SALOMEDS::SObject_var aNewSO;
// Retrieve a TopoDS_Shape from byte stream
TopoDS_Shape aTopology;
//Create a new GEOM_Object
- Handle(GEOM_Object) anObj = _impl->AddObject(aNewSO->GetStudy()->StudyId(), theObjectID);
- Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF);
+ Handle(::GEOM_Object) anObj = _impl->AddObject(aNewSO->GetStudy()->StudyId(), theObjectID);
+ Handle(::GEOM_Function) aFunction = anObj->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF);
aFunction->SetValue(aTopology);
TCollection_AsciiString anEntry;
anIOR->SetValue(objStr.in());
anIOR->UnRegister();
+ // add object to the use case tree
+ // (to support tree representation customization and drag-n-drop)
+ anUseCaseBuilder->AppendTo( aNewSO->GetFather(), aNewSO );
+
// Return the created in the Study SObject
return aNewSO._retn();
}
GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anArgO, theObject);
if (!CORBA::is_nil(anArgOTrsf)) {
CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
- Handle(GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
- Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
+ Handle(::GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+ Handle(::GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
anArgOTrsfFun->SetDescription("");
aSubO = aShapesOp->GetInPlace(theObject, anArgOTrsf);
}
/*
- Handle(GEOM_Function) anOFun = theObject->GetLastFunction();
+ Handle(::GEOM_Function) anOFun = theObject->GetLastFunction();
if (!anOFun.IsNull()) {
CORBA::String_var entryArg = anArgO->GetEntry();
- Handle(GEOM_Object) anArgOImpl = _impl->GetObject(anArgO->GetStudyID(), entryArg);
+ Handle(::GEOM_Object) anArgOImpl = _impl->GetObject(anArgO->GetStudyID(), entryArg);
if (!anArgOImpl.IsNull()) {
TopoDS_Shape anArgOShape = anArgOImpl->GetValue();
TopoDS_Shape aMultiArgShape;
{}
}
GEOM::GEOM_Object_var anArgOMulti = (aMultiArgShape); // TODO
- Handle(GEOM_Function) anArgOMultiFun = anArgOMulti->GetLastFunction();
+ Handle(::GEOM_Function) anArgOMultiFun = anArgOMulti->GetLastFunction();
anArgOMultiFun->SetDescription("");
aSubO = aShapesOp->GetInPlace(theObject, anArgOMulti);
}
aResParts->length(nb);
if (nb > 0)
{
- Handle(GEOM_BaseObject) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
- Handle(GEOM_Function) aFunction = aMainObj->GetLastFunction();
+ Handle(::GEOM_BaseObject) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
+ Handle(::GEOM_Function) aFunction = aMainObj->GetLastFunction();
GEOM::TPythonDump pd (aFunction, true);
pd <<"[";
int i = 0, j = 0;
anObjEntryMap.insert(anEntry);
aResParts[nbRes++] = anObj;
// clear python dump of object
- Handle(GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
- Handle(GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
+ Handle(::GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
+ Handle(::GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
if ( !anObjFun.IsNull() )
anObjFun->SetDescription( "" );
if ( j > 0 )
GEOM::GEOM_Object_var anObj = anOutArgs[ i ];
if (CORBA::is_nil(anObj))
continue;
- Handle(GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
+ Handle(::GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
if ( j > 0 )
pd << ", ";
pd << aGeomObj;
GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anOldSubO, theNewO);
if (!CORBA::is_nil(anArgOTrsf)) {
CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
- Handle(GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
- Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
+ Handle(::GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+ Handle(::GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
anArgOTrsfFun->SetDescription("");
aNewSubO = aShapesOp->GetInPlace(theNewO, anArgOTrsf);
}
GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anArgO, theObject);
if (!CORBA::is_nil(anArgOTrsf)) {
CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
- Handle(GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
- Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
+ Handle(::GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+ Handle(::GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
anArgOTrsfFun->SetDescription("");
aSubO = aShapesOp->GetInPlace(theObject, anArgOTrsf);
}
aResParts->length(nb);
if (nb > 0)
{
- Handle(GEOM_BaseObject) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
- Handle(GEOM_Function) aFunction = aMainObj->GetLastFunction();
+ Handle(::GEOM_BaseObject) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
+ Handle(::GEOM_Function) aFunction = aMainObj->GetLastFunction();
GEOM::TPythonDump pd (aFunction, true);
pd <<"[";
int i = 0, j = 0;
anObjEntryMap.insert(anEntry);
aResParts[nbRes++] = anObj;
// clear python dump of object
- Handle(GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
- Handle(GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
+ Handle(::GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
+ Handle(::GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
if ( !anObjFun.IsNull() )
anObjFun->SetDescription( "" );
if ( j > 0 )
GEOM::GEOM_Object_var anObj = theArgs[ i ];
if (CORBA::is_nil(anObj))
continue;
- Handle(GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
+ Handle(::GEOM_BaseObject) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
if ( j > 0 )
pd << ", ";
pd << aGeomObj;
GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anOldSubO, theNewO);
if (!CORBA::is_nil(anArgOTrsf)) {
CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
- Handle(GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
- Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
+ Handle(::GEOM_BaseObject) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+ Handle(::GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
anArgOTrsfFun->SetDescription("");
aNewSubO = aShapesOp->GetInPlace(theNewO, anArgOTrsf);
}
const char* theLibName)
throw ( SALOME::SALOME_Exception )
{
- std::string aPlatformLibName;
-#ifdef WNT
- aPlatformLibName = theLibName;
- aPlatformLibName += ".dll" ;
-#else
- aPlatformLibName = "lib";
- aPlatformLibName += theLibName;
- aPlatformLibName += ".so";
-#endif
-
Unexpect aCatch(SALOME_SalomeException);
MESSAGE( "GEOM_Gen_i::GetPluginOperations" );
GEOM::GEOM_Gen_ptr engine = _this();
- GEOM_IOperations_i* aServant = 0;
GEOM::GEOM_IOperations_var operations;
+ std::string aLibName = theLibName;
+
try {
- // check, if corresponding operations are already created
- if (myOpCreatorMap.find(std::string(theLibName)) == myOpCreatorMap.end()) {
- // load plugin library
- LibHandle libHandle = LoadLib( aPlatformLibName.c_str()/*theLibName*/ );
- if (!libHandle) {
- // report any error, if occured
-#ifndef WNT
- const char* anError = dlerror();
- throw(SALOME_Exception(anError));
+ // load plugin library
+ LoadPlugin(aLibName);
+ // create a new operations object, store its ref. in engine
+ if ( myOpCreatorMap.find(aLibName) != myOpCreatorMap.end() ) {
+ GEOM_IOperations_i* aServant = 0;
+ aServant = myOpCreatorMap[aLibName]->Create(_poa, theStudyID, engine, _impl);
+ // activate the CORBA servant
+ if (aServant)
+ operations = aServant->_this();
+ }
+ }
+ catch (SALOME_Exception& S_ex) {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+ }
+
+ return operations._retn();
+}
+
+//============================================================================
+// function : LoadPlugin
+// purpose : load plugin library and retrieve an instance of operations creator
+//============================================================================
+void GEOM_Gen_i::LoadPlugin(const std::string& theLibName)
+{
+ std::string aPlatformLibName;
+#if !defined(WIN32)
+ aPlatformLibName = "lib";
+#endif
+ aPlatformLibName += theLibName;
+#if defined(WIN32)
+ aPlatformLibName += ".dll" ;
+#elif defined(__APPLE__)
+ aPlatformLibName += ".dylib";
#else
- throw(SALOME_Exception(LOCALIZED( "Can't load server geometry plugin library" )));
+ aPlatformLibName += ".so";
#endif
- }
- // get method, returning operations creator
- typedef GEOM_GenericOperationsCreator* (*GetOperationsCreator)();
- GetOperationsCreator procHandle =
- (GetOperationsCreator)GetProc( libHandle, "GetOperationsCreator" );
- if (!procHandle) {
- throw(SALOME_Exception(LOCALIZED("bad geometry plugin library")));
- UnLoadLib(libHandle);
- }
+ // check, if corresponding operations are already created
+ if (myOpCreatorMap.find(theLibName) == myOpCreatorMap.end()) {
+ // load plugin library
+ LibHandle libHandle = LoadLib( aPlatformLibName.c_str() );
+ if (!libHandle) {
+ // report any error, if occurred
+#ifndef WIN32
+ throw(SALOME_Exception(dlerror()));
+#else
+ throw(SALOME_Exception(LOCALIZED( "Can't load server geometry plugin library" )));
+#endif
+ }
- // get operations creator
- GEOM_GenericOperationsCreator* aCreator = procHandle();
- if (!aCreator) {
- throw(SALOME_Exception(LOCALIZED("bad geometry plugin library implementation")));
- }
+ // get method, returning operations creator
+ typedef GEOM_GenericOperationsCreator* (*GetOperationsCreator)();
+ GetOperationsCreator procHandle =
+ (GetOperationsCreator)GetProc( libHandle, "GetOperationsCreator" );
+ if (!procHandle) {
+ UnLoadLib(libHandle);
+ throw(SALOME_Exception(LOCALIZED("bad geometry plugin library")));
+ }
+ // get operations creator
+ GEOM_GenericOperationsCreator* aCreator = procHandle();
+ if (aCreator) {
// map operations creator to a plugin name
- myOpCreatorMap[std::string(theLibName)] = aCreator;
+ myOpCreatorMap[theLibName] = aCreator;
+ }
+ else {
+ throw(SALOME_Exception(LOCALIZED("bad geometry plugin library implementation")));
}
-
- // create a new operations object, store its ref. in engine
- aServant = myOpCreatorMap[std::string(theLibName)]->Create(_poa, theStudyID, engine, _impl);
- //??? aServant->SetLibName(aPlatformLibName/*theLibName*/); // for persistency assurance
- }
- catch (SALOME_Exception& S_ex) {
- THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
}
-
- if (!aServant)
- return operations._retn();
-
- // activate the CORBA servant
- operations = GEOM::GEOM_IOperations::_narrow( aServant->_this() );
- return operations._retn();
}
//=============================================================================
if (CORBA::is_nil(theMainShape) || theIndices.length() < 1)
return GEOM::GEOM_Object::_nil();
CORBA::String_var entry = theMainShape->GetEntry();
- Handle(GEOM_Object) aMainShape = Handle(GEOM_Object)::DownCast
+ Handle(::GEOM_Object) aMainShape = Handle(::GEOM_Object)::DownCast
( _impl->GetObject( theMainShape->GetStudyID(), entry ));
if (aMainShape.IsNull()) return GEOM::GEOM_Object::_nil();
Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theIndices.length());
for(Standard_Integer i = 0; i<theIndices.length(); i++) anArray->SetValue(i+1, theIndices[i]);
- Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainShape, anArray, true);
+ Handle(::GEOM_Object) anObject = _impl->AddSubShape(aMainShape, anArray, true);
if(anObject.IsNull()) return GEOM::GEOM_Object::_nil();
TCollection_AsciiString anEntry;
void GEOM_Gen_i::RemoveObject(GEOM::GEOM_BaseObject_ptr theObject)
{
CORBA::String_var anEntry = theObject->GetEntry();
- Handle(GEOM_BaseObject) anObject = _impl->GetObject(theObject->GetStudyID(), anEntry, false);
+ Handle(::GEOM_BaseObject) anObject = _impl->GetObject(theObject->GetStudyID(), anEntry, false);
if (!anObject.IsNull())
_impl->RemoveObject(anObject);
}
GEOM::GEOM_BaseObject_ptr GEOM_Gen_i::GetObject (CORBA::Long theStudyID, const char* theEntry)
{
GEOM::GEOM_BaseObject_var obj;
- Handle(GEOM_BaseObject) handle_object = _impl->GetObject(theStudyID, (char*)theEntry);
+ Handle(::GEOM_BaseObject) handle_object = _impl->GetObject(theStudyID, (char*)theEntry);
if (handle_object.IsNull()) return obj._retn();
TCollection_AsciiString stringIOR = handle_object->GetIOR();
GEOM_BaseObject_i* servant = 0;
switch( handle_object->GetType() ) {
case GEOM_FIELD: {
- servant = new GEOM_Field_i (_poa, engine, Handle(GEOM_Field)::DownCast( handle_object ));
+ servant = new GEOM_Field_i (_poa, engine, Handle(::GEOM_Field)::DownCast( handle_object ));
break;
}
case GEOM_FIELD_STEP: {
- Handle(GEOM_FieldStep) step = Handle(GEOM_FieldStep)::DownCast( handle_object );
- Handle(GEOM_Field) field = step->GetField();
+ Handle(::GEOM_FieldStep) step = Handle(::GEOM_FieldStep)::DownCast( handle_object );
+ Handle(::GEOM_Field) field = step->GetField();
int type = ( !field.IsNull() ? field->GetDataType() : 0 );
switch( type ) {
case GEOM::FDT_Bool:
break;
}
default:
- servant = new GEOM_Object_i (_poa, engine, Handle(GEOM_Object)::DownCast( handle_object ));
+ servant = new GEOM_Object_i (_poa, engine, Handle(::GEOM_Object)::DownCast( handle_object ));
}
PortableServer::ObjectId_var id = _poa->activate_object(servant);
}
}
- char* anInfo = new char[strlen("Module ") + strlen(ComponentDataType()) + strlen(", ") + strlen(aTypeInfo) + 3];
- sprintf(anInfo, "Module %s, %s", ComponentDataType(), aTypeInfo);
+ CORBA::String_var compType = ComponentDataType();
+ char* anInfo = new char[strlen("Module ") + strlen(compType.in()) + strlen(", ") + strlen(aTypeInfo) + 3];
+ sprintf(anInfo, "Module %s, %s", compType.in(), aTypeInfo);
char* ret = CORBA::string_dup(anInfo);
delete [] anInfo;
// 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 : 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 ) {
+ // fill in the tree structure
+ GEOMUtils::TreeModel tree;
+
+ std::string entry;
+ for ( int i = 0; i < theObjectEntries.length(); i++ ) {
+ // process objects one-by-one
+ entry = theObjectEntries[i].in();
+ GEOM::GEOM_BaseObject_var anObj = GetObject( theStudy->StudyId(), entry.c_str() );
+ if ( anObj->_is_nil() )
+ continue;
+ std::map< std::string, std::set<std::string> > passedEntries;
+ GEOMUtils::LevelsList upLevelList;
+ // get objects from which current one depends on recursively
+ getUpwardDependency( anObj, upLevelList, passedEntries );
+ GEOMUtils::LevelsList downLevelList;
+ // get objects that depends on current one recursively
+ getDownwardDependency( anObj, downLevelList, passedEntries );
+ tree.insert( std::pair<std::string, std::pair<GEOMUtils::LevelsList,GEOMUtils::LevelsList> >(entry, std::pair<GEOMUtils::LevelsList,GEOMUtils::LevelsList>( upLevelList, downLevelList ) ) );
+ }
+
+ // 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);
+
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
+
+ SALOMEDS::TMPFile_var aStream = new SALOMEDS::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
+
+ return aStream._retn();
+}
+
+//=======================================================================
+// 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 ) {
+ std::string aGboEntry = gbo->GetEntry();
+ GEOMUtils::NodeLinks anEntries;
+ GEOMUtils::LevelInfo aLevelMap;
+ if ( level > 0 ) {
+ if ( level-1 >= upLevelList.size() ) {
+ // create a new map
+ upLevelList.push_back( aLevelMap );
+ } else {
+ // get the existent map
+ aLevelMap = upLevelList.at(level-1);
+ if ( aLevelMap.count( aGboEntry ) > 0 ) {
+ anEntries = aLevelMap[ aGboEntry ];
+ }
+ }
+ }
+ // get objects on that the current one depends
+ GEOM::ListOfGBO_var depList = gbo->GetDependency();
+ std::string aDepEntry;
+ for( int j = 0; j < depList->length(); j++ ) {
+ if ( depList[j]->_is_nil() )
+ continue;
+ aDepEntry = depList[j]->GetEntry();
+ if ( passedEntries.count( aGboEntry ) > 0 &&
+ passedEntries[aGboEntry].count( aDepEntry ) > 0 ) {
+ //avoid checking the passed objects
+ continue;
+ }
+ passedEntries[aGboEntry].insert( aDepEntry );
+ if ( level > 0 ) {
+ anEntries.push_back( aDepEntry );
+ }
+ // get dependencies recursively
+ getUpwardDependency(depList[j], upLevelList, passedEntries, level+1);
+ }
+ if ( level > 0 ) {
+ aLevelMap.insert( std::pair<std::string, GEOMUtils::NodeLinks>(aGboEntry, anEntries) );
+ upLevelList[level-1] = aLevelMap;
+ }
+}
+
+//=======================================================================
+// 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 ) {
+ std::string aGboEntry = gbo->GetEntry();
+ Handle(TDocStd_Document) aDoc = GEOM_Engine::GetEngine()->GetDocument(gbo->GetStudyID());
+ Handle(TDataStd_TreeNode) aNode, aRoot;
+ Handle(::GEOM_Function) aFunction;
+ if (aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) {
+ // go through the whole OCAF tree
+ TDataStd_ChildNodeIterator Itr( aRoot );
+ for (; Itr.More(); Itr.Next()) {
+ aNode = Itr.Value();
+ aFunction = GEOM_Function::GetFunction(aNode->Label());
+ if (aFunction.IsNull()) {
+ continue;
+ }
+ TDF_Label aLabel = aFunction->GetOwnerEntry();
+ if(aLabel.IsNull()) continue;
+ TCollection_AsciiString anEntry;
+ TDF_Tool::Entry(aLabel, anEntry);
+ GEOM::GEOM_BaseObject_var geomObj = GetObject( gbo->GetStudyID(), anEntry.ToCString() );
+ if( CORBA::is_nil( geomObj ) )
+ continue;
+ // get dependencies for current object in the tree
+ GEOM::ListOfGBO_var depList = geomObj->GetDependency();
+ if( depList->length() == 0 )
+ continue;
+ std::string aGoEntry = geomObj->GetEntry();
+ // go through dependencies of current object to check whether it depends on the given object
+ for( int i = 0; i < depList->length(); i++ ) {
+ if ( depList[i]->_is_nil() )
+ continue;
+ if ( depList[i]->_is_equivalent( gbo ) ) {
+ // yes, the current object depends on the given object
+ if ( passedEntries.count( aGoEntry ) > 0 &&
+ passedEntries[aGoEntry].count( aGboEntry ) > 0 ) {
+ //avoid checking the passed objects
+ continue;
+ }
+ passedEntries[aGoEntry].insert( aGboEntry );
+ GEOMUtils::NodeLinks anEntries;
+ GEOMUtils::LevelInfo aLevelMap;
+ anEntries.push_back( aGboEntry );
+ if ( level >= downLevelList.size() ) {
+ downLevelList.push_back( aLevelMap );
+ } else {
+ aLevelMap = downLevelList.at(level);
+ if ( aLevelMap.count( aGoEntry ) > 0 ) {
+ anEntries = aLevelMap[ aGoEntry ];
+ }
+ }
+ aLevelMap.insert( std::pair<std::string, GEOMUtils::NodeLinks>(aGoEntry, anEntries) );
+ downLevelList[level] = aLevelMap;
+ // get dependencies of the current object recursively
+ getDownwardDependency(geomObj, downLevelList, passedEntries, level+1);
+ break;
+ }
+ }
+ }
+ }
+}
+
+//==============================================================================
+// function : GetEntriesToReduceStudy
+// 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)
+{
+ std::set<std::string> aSelected, aParents, aChildren, anOthers;
+ for ( int i = 0; i < theSelectedEntries.length(); i++ ) {
+ aSelected.insert( CORBA::string_dup( theSelectedEntries[i] ) );
+ }
+
+ Handle(TDocStd_Document) aDoc = GEOM_Engine::GetEngine()->GetDocument(theStudy->StudyId());
+ Handle(TDataStd_TreeNode) aNode, aRoot;
+ Handle(::GEOM_Function) aFunction;
+ if (aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) {
+ // go through the whole OCAF tree
+ TDF_Label aLabel;
+ std::string anEntry;
+ TCollection_AsciiString anAsciiEntry;
+ TDataStd_ChildNodeIterator Itr( aRoot );
+ for (; Itr.More(); Itr.Next()) {
+ aNode = Itr.Value();
+ aFunction = GEOM_Function::GetFunction(aNode->Label());
+ if (aFunction.IsNull()) {
+ continue;
+ }
+ aLabel = aFunction->GetOwnerEntry();
+ if(aLabel.IsNull())
+ continue;
+ TDF_Tool::Entry(aLabel, anAsciiEntry);
+ anEntry = anAsciiEntry.ToCString();
+ GEOM::GEOM_BaseObject_var geomObj = GetObject( theStudy->StudyId(), anEntry.c_str() );
+ if( CORBA::is_nil( geomObj ) )
+ continue;
+
+ if ( aSelected.count( anEntry ) > 0 &&
+ aParents.count( anEntry ) == 0 ) {
+ includeParentDependencies( geomObj, aSelected, aParents, aChildren, anOthers );
+ } else if ( aParents.count( anEntry ) == 0 &&
+ aChildren.count( anEntry ) == 0 ) {
+ anOthers.insert( geomObj->GetEntry() );
+ }
+ }
+
+ std::set<std::string>::iterator it;
+ std::set<std::string>::iterator foundIt;
+ TCollection_AsciiString stringIOR;
+ GEOM::GEOM_Object_var geomObj;
+
+ // filling list of sub-objects
+ for ( it = aSelected.begin(); it != aSelected.end(); ++it ) {
+ includeSubObjects( theStudy, *it, aSelected, aParents, aChildren, anOthers );
+ }
+
+ // if some selected object is not a main shape,
+ // 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 ) {
+ Handle(::GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), (*it).c_str(), false);
+ if ( handle_object.IsNull() )
+ continue;
+
+ stringIOR = handle_object->GetIOR();
+ if ( !stringIOR.Length() > 1 )
+ continue;
+
+ geomObj = GetIORFromString( stringIOR.ToCString() );
+ while ( !geomObj->IsMainShape() ) {
+ geomObj = geomObj->GetMainShape();
+ anEntry = geomObj->GetEntry();
+
+ foundIt = aParents.find( anEntry );
+ if ( foundIt != aParents.end() )
+ aParents.erase( foundIt );
+
+ foundIt = aChildren.find( anEntry );
+ if ( foundIt != aChildren.end() )
+ aChildren.erase( foundIt );
+
+ foundIt = anOthers.find( anEntry );
+ if ( foundIt != anOthers.end() )
+ anOthers.erase( foundIt );
+
+ aToBeInSelected.insert( anEntry );
+ }
+ }
+ aSelected.insert( aToBeInSelected.begin(), aToBeInSelected.end() );
+
+ // fill the CORBA arrays with values from sets
+ int i;
+ theSelectedEntries.length( aSelected.size() );
+ for ( i = 0, it = aSelected.begin(); it != aSelected.end(); ++it, i++ )
+ theSelectedEntries[i] = CORBA::string_dup( (*it).c_str() );
+ theParentEntries.length( aParents.size() );
+ for ( i = 0, it = aParents.begin(); it != aParents.end(); ++it, i++ )
+ theParentEntries[i] = CORBA::string_dup( (*it).c_str() );
+ theSubEntries.length( aChildren.size() );
+ for ( i = 0, it = aChildren.begin(); it != aChildren.end(); ++it, i++ )
+ theSubEntries[i] = CORBA::string_dup( (*it).c_str() );
+ theOtherEntries.length( anOthers.size() );
+ for ( i = 0, it = anOthers.begin(); it != anOthers.end(); ++it, i++ )
+ theOtherEntries[i] = CORBA::string_dup( (*it).c_str() );
+ }
+}
+
+//==============================================================================
+// function : includeParentDependencies
+// 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::string anEntry = geomObj->GetEntry();
+ if ( aSelected.count( anEntry ) == 0 ) {
+ aParents.insert( anEntry );
+ std::set<std::string>::iterator it;
+ it = aChildren.find( anEntry );
+ if ( it != aChildren.end() )
+ aChildren.erase( it );
+ it = anOthers.find( anEntry );
+ if ( it != anOthers.end() )
+ anOthers.erase( it );
+ }
+ // get dependencies for current object in the tree
+ GEOM::ListOfGBO_var depList = geomObj->GetDependency();
+ if( depList->length() == 0 )
+ return;
+ // go through dependencies of current object to check whether it depends on the given object
+ std::string aDepEntry;
+ 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
+ )
+ continue;
+ includeParentDependencies( depList[i], aSelected, aParents, aChildren, anOthers );
+ }
+}
+
+//==============================================================================
+// function : includeSubObjects
+// 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)
+{
+ std::set<std::string>::iterator foundIt;
+ Handle(::GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), aSelectedEntry.c_str(), false);
+ if ( handle_object.IsNull() )
+ return;
+
+ Handle(::GEOM_Function) aShapeFun = handle_object->GetFunction(1);
+ if ( aShapeFun.IsNull() || !aShapeFun->HasSubShapeReferences() )
+ return;
+
+ const TDataStd_ListOfExtendedString& aListEntries = aShapeFun->GetSubShapeReferences();
+ if ( aListEntries.IsEmpty() )
+ return;
+
+ TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries);
+ for ( ; anIt.More(); anIt.Next() ) {
+ TCollection_ExtendedString aSubEntry = anIt.Value();
+ Standard_Integer aStrLen = aSubEntry.LengthOfCString();
+ char* aSubEntryStr = new char[aStrLen+1];
+ aSubEntry.ToUTF8CString( aSubEntryStr );
+ foundIt = aParents.find( aSubEntryStr );
+ 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 );
+ }
+ }
+ includeSubObjects( theStudy, aSubEntryStr, aSelected, aParents, aChildren, anOthers );
+ }
+}
//=====================================================================================
// EXPORTED METHODS
//=====================================================================================