1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #pragma warning( disable:4786 )
26 #include <Standard_Stream.hxx>
28 #include "GEOM_Gen_i.hh"
29 #include "GEOM_Object_i.hh"
34 #include "Utils_CorbaException.hxx"
36 #include "Utils_ExceptHandlers.hxx"
37 #include "utilities.h"
39 #include "GEOM_Object_i.hh"
40 #include "GEOM_Object.hxx"
41 #include "GEOM_Function.hxx"
42 #include "GEOM_ISubShape.hxx"
43 #include <GEOM_PythonDump.hxx>
44 #include "GEOMImpl_Types.hxx"
45 #include "GEOMImpl_CopyDriver.hxx"
48 #include <BRep_Builder.hxx>
49 #include <BRepTools.hxx>
50 #include <TDF_Label.hxx>
51 #include <TDF_Tool.hxx>
52 #include <TDF_ChildIDIterator.hxx>
53 #include <TNaming_NamedShape.hxx>
54 #include <TDataStd_Name.hxx>
55 #include <TCollection_AsciiString.hxx>
56 #include <TColStd_HArray1OfInteger.hxx>
57 #include <TopAbs_ShapeEnum.hxx>
58 //#include <TopTools_IndexedMapOfShape.hxx>
62 #include "SALOMEDS_Tool.hxx"
64 //============================================================================
65 // function : GEOM_Gen_i()
66 // purpose : constructor to be called for servant creation.
67 //============================================================================
68 GEOM_Gen_i::GEOM_Gen_i(CORBA::ORB_ptr orb,
69 PortableServer::POA_ptr poa,
70 PortableServer::ObjectId* contId,
71 const char* instanceName,
72 const char* interfaceName) :
73 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
76 _id = _poa->activate_object(_thisObj);
77 name_service = new SALOME_NamingService(_orb);
79 _impl = new ::GEOMImpl_Gen;
81 //PAL10867: disable signals catching with "noexcepthandler" option
82 char* envNoCatchSignals = getenv("NOT_INTERCEPT_SIGNALS");
83 if (!envNoCatchSignals || !atoi(envNoCatchSignals))
85 //work around PAL12004, PAL12628
86 //OSD::SetSignal( true );
90 char* envDisableFPE = getenv("DISABLE_FPE");
91 if (envDisableFPE && atoi(envDisableFPE))
96 OSD::SetSignal( raiseFPE );
100 //============================================================================
101 // function : ~GEOM_Gen_i()
102 // purpose : destructor
103 //============================================================================
104 GEOM_Gen_i::~GEOM_Gen_i() {
110 //============================================================================
111 // function : IORToLocalPersistentID()
113 //============================================================================
114 char* GEOM_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
115 const char* IORString,
116 CORBA::Boolean isMultiFile,
117 CORBA::Boolean isASCII)
119 GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(_orb->string_to_object(IORString));
120 if (!CORBA::is_nil(anObject)) {
121 return CORBA::string_dup(anObject->GetEntry());
127 //============================================================================
128 // function : LocalPersistentIDToIOR()
129 // purpose : Create/Load CORBA object from a persistent ref (an entry)
130 // : Used when a study is loaded
131 // : The IOR (IORName) of object created is returned
132 //============================================================================
133 char* GEOM_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
134 const char* aLocalPersistentID,
135 CORBA::Boolean isMultiFile,
136 CORBA::Boolean isASCII)
138 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
140 Handle(GEOM_Object) anObject = _impl->GetObject(aStudy->StudyId(), const_cast<char*>(aLocalPersistentID));
141 TCollection_AsciiString anEntry;
142 TDF_Tool::Entry(anObject->GetEntry(), anEntry);
143 GEOM::GEOM_Object_var obj = GetObject(anObject->GetDocID(), anEntry.ToCString());
145 CORBA::String_var aPersRefString = _orb->object_to_string(obj);
146 return CORBA::string_dup(aPersRefString);
149 //============================================================================
150 // function : CanPublishInStudy
152 //============================================================================
153 bool GEOM_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
155 GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(theIOR);
156 return !(anObject->_is_nil());
160 //============================================================================
161 // function : PublishInStudy
163 //============================================================================
164 SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
165 SALOMEDS::SObject_ptr theSObject,
166 CORBA::Object_ptr theObject,
167 const char* theName) throw (SALOME::SALOME_Exception)
169 Unexpect aCatch(SALOME_SalomeException);
170 SALOMEDS::SObject_var aResultSO;
171 if(CORBA::is_nil(theObject) || theStudy->_is_nil()) return aResultSO;
172 GEOM::GEOM_Object_var aShape = GEOM::GEOM_Object::_narrow(theObject);
173 if(aShape->_is_nil()) return aResultSO;
175 SALOMEDS::GenericAttribute_var anAttr;
176 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
178 SALOMEDS::SComponent_var aFather = theStudy->FindComponent("GEOM");
179 if (aFather->_is_nil()) {
180 aFather = aStudyBuilder->NewComponent("GEOM");
181 anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributeName");
182 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
183 aName->SetValue("Geometry");
185 anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributePixMap");
186 SALOMEDS::AttributePixMap_var aPixMap=SALOMEDS::AttributePixMap::_narrow(anAttr);
187 aPixMap->SetPixMap("ICON_OBJBROWSER_Geometry");
189 aStudyBuilder->DefineComponentInstance(aFather, (GEOM::GEOM_Gen_var)GEOM_Gen::_this());
191 if (aFather->_is_nil()) return aResultSO;
193 if (CORBA::is_nil(theSObject)) {
194 aResultSO = aStudyBuilder->NewObject(aFather);
196 if (!theSObject->ReferencedObject(aResultSO))
197 aResultSO = SALOMEDS::SObject::_duplicate(theSObject); //SRN: Added Aug 24,2004 : for the method AddInStudy with theFather argumenet != NULL
198 //THROW_SALOME_CORBA_EXCEPTION("Publish in study supervision graph error",SALOME::BAD_PARAM);
200 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
201 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
202 CORBA::String_var aGeomObjIOR = _orb->object_to_string(theObject);
203 anIOR->SetValue(aGeomObjIOR);
206 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
207 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
208 TCollection_AsciiString aShapeName("Shape_");
210 if ( aShape->GetType() == GEOM_GROUP ) {
211 GEOM::GEOM_IGroupOperations_var anOp = GetIGroupOperations( theStudy->StudyId() );
212 switch ( (TopAbs_ShapeEnum)anOp->GetType( aShape ) ) {
214 aPixmap->SetPixMap( "ICON_OBJBROWSER_GROUP_PNT" );
215 aShapeName = "Group_Of_Vertices_";
218 aPixmap->SetPixMap( "ICON_OBJBROWSER_GROUP_EDGE" );
219 aShapeName = "Group_Of_Edges_";
222 aPixmap->SetPixMap( "ICON_OBJBROWSER_GROUP_FACE" );
223 aShapeName = "Group_Of_Faces_";
226 aPixmap->SetPixMap( "ICON_OBJBROWSER_GROUP_SOLID" );
227 aShapeName = "Group_Of_Solids_";
230 } else if ( aShape->GetType() == GEOM_MARKER ) {
231 aPixmap->SetPixMap( "ICON_OBJBROWSER_LCS" );
232 aShapeName = "LocalCS_";
233 } else if ( aShape->GetType() > ADVANCED_BASE ) {
235 sprintf( buf, "%d", aShape->GetType() );
236 std::string advId = "ICON_OBJBROWSER_ADVANCED_"; advId += buf;
237 aPixmap->SetPixMap( advId.c_str() );
238 aShapeName = "Advanced_";
239 } else if ( aShape->GetShapeType() == GEOM::COMPOUND ) {
240 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
241 aShapeName = "Compound_";
242 } else if ( aShape->GetShapeType() == GEOM::COMPSOLID ) {
243 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
244 aShapeName = "Compsolid_";
245 } else if ( aShape->GetShapeType() == GEOM::SOLID ) {
246 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
247 aShapeName = "Solid_";
248 } else if ( aShape->GetShapeType() == GEOM::SHELL ) {
249 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
250 aShapeName = "Shell_";
251 } else if ( aShape->GetShapeType() == GEOM::FACE ) {
252 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
253 aShapeName = "Face_";
254 } else if ( aShape->GetShapeType() == GEOM::WIRE ) {
255 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
256 aShapeName = "Wire_";
257 } else if ( aShape->GetShapeType() == GEOM::EDGE ) {
258 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
259 aShapeName = "Edge_";
260 } else if ( aShape->GetShapeType() == GEOM::VERTEX ) {
261 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
262 aShapeName = "Vertex_";
265 //if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag());
266 //else aShapeName = TCollection_AsciiString(CORBA::string_dup(theName));
268 // try to find existed name for current shape
269 bool HasName = false;
270 // recieve current TopoDS shape
271 CORBA::String_var entry = aShape->GetEntry();
272 Handle(GEOM_Object) aGShape = _impl->GetObject(aShape->GetStudyID(), entry);
273 TopoDS_Shape TopoSh = aGShape->GetValue();
274 // find label of main shape
275 GEOM::GEOM_Object_var aMainSh = aShape;
276 while( !aMainSh->IsMainShape() ) {
277 aMainSh = aMainSh->GetMainShape();
279 entry = aMainSh->GetEntry();
280 Handle(GEOM_Object) anObj = _impl->GetObject(aMainSh->GetStudyID(), entry);
281 TDF_Label aMainLbl = anObj->GetEntry();
282 // check all named shapes using iterator
283 TDF_ChildIDIterator anIt(aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
284 for(; anIt.More(); anIt.Next()) {
285 Handle(TNaming_NamedShape) anAttr =
286 Handle(TNaming_NamedShape)::DownCast(anIt.Value());
287 if(anAttr.IsNull()) continue;
288 TopoDS_Shape S = anAttr->Get();
289 if( !S.IsEqual(TopoSh) ) continue;
290 TDF_Label L = anAttr->Label();
291 Handle(TDataStd_Name) aName;
292 if(L.FindAttribute(TDataStd_Name::GetID(),aName)) {
293 aShapeName = aName->Get();
299 // asv : 11.11.04 Introducing a more sofisticated method of name creation, just as
300 // it is done in GUI in GEOMBase::GetDefaultName() - not just add a Tag() == number
301 // of objects in the study, but compute a number of objects with the same prefix
302 // and build a new name as Prefix_N+1
303 if ( strlen( theName ) == 0 ) { // MOST PROBABLY CALLED FROM BATCHMODE OR SUPERVISOR
304 int i = 0; // (WITH EMPTY NEW NAME)
305 SALOMEDS::SObject_var obj;
306 TCollection_AsciiString aNewShapeName;
308 aNewShapeName = aShapeName + TCollection_AsciiString(++i);
309 obj = theStudy->FindObject( aNewShapeName.ToCString() );
311 while ( !obj->_is_nil() );
312 aShapeName = aNewShapeName;
314 else // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME)
315 aShapeName = TCollection_AsciiString((char*)theName);
318 //Set the study entry as a name of the published GEOM_Object
319 CORBA::String_var anID =aResultSO->GetID();
320 aShape->SetStudyEntry(anID.in());
322 //Set a name of the added shape
323 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
324 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
325 aNameAttrib->SetValue(aShapeName.ToCString());
326 aNameAttrib->Destroy();
328 //Set NoteBook variables used in the object creation
329 TCollection_AsciiString aVars;
330 CORBA::String_var aString=aShape->GetParameters();
331 SALOMEDS::ListOfListOfStrings_var aSections = theStudy->ParseVariables(aString);
332 for(int i = 0, n = aSections->length(); i < n; i++) {
333 SALOMEDS::ListOfStrings aListOfVars = aSections[i];
334 for(int j = 0, m = aListOfVars.length(); j < m; j++) {
335 if(theStudy->IsVariable(aListOfVars[j].in()))
336 aVars += TCollection_AsciiString(aListOfVars[j].in());
343 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeString");
344 SALOMEDS::AttributeString_var aStringAttrib = SALOMEDS::AttributeString::_narrow(anAttr);
345 aStringAttrib->SetValue(aVars.ToCString());
346 aStringAttrib->Destroy();
350 //Set a name of the GEOM object
351 aShape->SetName(theName);
353 return aResultSO._retn();
357 //============================================================================
358 // function : CreateAndPublishGroup
359 // purpose : auxilary for PublishNamedShapesInStudy
360 //============================================================================
361 void GEOM_Gen_i::CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
362 GEOM::GEOM_Object_var theMainShape,
363 const TopTools_IndexedMapOfShape& anIndices,
364 const TopTools_SequenceOfShape& SeqS,
365 const TColStd_SequenceOfAsciiString& SeqN,
366 const Standard_CString& GrName,
367 GEOM::ListOfGO_var aResList)
369 CORBA::String_var entry = theMainShape->GetEntry();
370 Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
371 Handle(TColStd_HArray1OfInteger) anArray;
372 if(SeqS.Length()>0) {
374 GEOM::GEOM_IGroupOperations_var GOp = GetIGroupOperations(theStudy->StudyId());
375 GEOM::GEOM_Object_ptr GrObj =
376 GOp->CreateGroup( theMainShape, SeqS.Value(1).ShapeType() );
377 AddInStudy(theStudy, GrObj, GrName, theMainShape._retn());
378 CORBA::String_var GrEntry = GrObj->GetEntry();
379 Handle(GEOM_Object) HGrObj = _impl->GetObject(GrObj->GetStudyID(), GrEntry);
381 //Handle(GEOM_Object) anObj;
382 for(int i=1; i<=SeqS.Length(); i++) {
383 TopoDS_Shape aValue = SeqS.Value(i);
384 //anArray = new TColStd_HArray1OfInteger(1,1);
385 Standard_Integer anIndex = anIndices.FindIndex(aValue);
386 //anArray->SetValue(1, anIndex);
387 GOp->AddObject(GrObj,anIndex);
388 //anObj = GEOM_Engine::GetEngine()->AddObject(aMainShape->GetDocID(), GEOM_SUBSHAPE);
389 //if (anObj.IsNull()) continue;
390 //Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
391 //if (aFunction.IsNull()) continue;
392 //GEOM_ISubShape aSSI(aFunction);
393 //aSSI.SetMainShape(aMainShape->GetLastFunction());
394 //aSSI.SetIndices(anArray);
395 //aFunction->SetValue(aValue);
396 //GOp->UnionIDs(GrObj, anIndex);
397 //SALOMEDS::SObject_var aResultSO;
398 //TCollection_AsciiString anEntry;
399 //TDF_Tool::Entry(anObj->GetEntry(),anEntry);
400 //GEOM::GEOM_Object_var aGObj = GetObject(anObj->GetDocID(), anEntry.ToCString());
401 //AddInStudy(theStudy, aGObj._retn(), SeqN.Value(i).ToCString(), GrObj);
407 //============================================================================
408 // function : PublishNamedShapesInStudy
410 //============================================================================
411 GEOM::ListOfGO* GEOM_Gen_i::
412 PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
413 //SALOMEDS::SObject_ptr theSObject,
414 CORBA::Object_ptr theObject)
416 //Unexpect aCatch(SALOME_SalomeException);
417 GEOM::ListOfGO_var aResList = new GEOM::ListOfGO;
419 //CORBA::Object_var theObject = theSObject->GetObject();
420 GEOM::GEOM_Object_var theMainShape = GEOM::GEOM_Object::_narrow(theObject);
421 if(theMainShape->_is_nil()) return aResList._retn();
423 CORBA::String_var entry = theMainShape->GetEntry();
424 Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
425 if (aMainShape.IsNull()) return aResList._retn();
426 TopoDS_Shape MainSh = aMainShape->GetValue();
428 TDF_Label aMainLbl = aMainShape->GetEntry();
429 TopTools_SequenceOfShape SolidSeqS, FaceSeqS, EdgeSeqS, VertSeqS;
430 TColStd_SequenceOfAsciiString SolidSeqN, FaceSeqN, EdgeSeqN, VertSeqN;
431 TDF_ChildIDIterator anIt(aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
432 for(; anIt.More(); anIt.Next()) {
433 Handle(TNaming_NamedShape) anAttr =
434 Handle(TNaming_NamedShape)::DownCast(anIt.Value());
435 if(anAttr.IsNull()) continue;
436 TopoDS_Shape S = anAttr->Get();
437 TDF_Label L = anAttr->Label();
438 //if(S.IsEqual(MainSh)) continue;
439 Handle(TDataStd_Name) aName;
440 if(L.FindAttribute(TDataStd_Name::GetID(),aName)) {
441 TCollection_ExtendedString EName = aName->Get();
442 if(S.ShapeType()==TopAbs_SOLID) {
444 SolidSeqN.Append(aName->Get());
446 else if(S.ShapeType()==TopAbs_FACE) {
448 FaceSeqN.Append(aName->Get());
450 else if(S.ShapeType()==TopAbs_EDGE) {
452 EdgeSeqN.Append(aName->Get());
454 else if(S.ShapeType()==TopAbs_VERTEX) {
456 VertSeqN.Append(aName->Get());
461 TopTools_IndexedMapOfShape anIndices;
462 TopExp::MapShapes(MainSh, anIndices);
464 CreateAndPublishGroup(theStudy, theMainShape, anIndices, SolidSeqS, SolidSeqN,
465 "Group_Of_Named_Solids", aResList);
467 CreateAndPublishGroup(theStudy, theMainShape, anIndices, FaceSeqS, FaceSeqN,
468 "Group_Of_Named_Faces", aResList);
470 CreateAndPublishGroup(theStudy, theMainShape, anIndices, EdgeSeqS, EdgeSeqN,
471 "Group_Of_Named_Edges", aResList);
473 CreateAndPublishGroup(theStudy, theMainShape, anIndices, VertSeqS, VertSeqN,
474 "Group_Of_Named_Vertices", aResList);
476 return aResList._retn();
480 //============================================================================
482 // purpose : save OCAF/Geom document
483 //============================================================================
484 SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
487 SALOMEDS::TMPFile_var aStreamFile;
488 // Get a temporary directory to store a file
489 std::string aTmpDir = (isMultiFile)?theURL:SALOMEDS_Tool::GetTmpDir();
491 // OCCT BUG: cannot save a document (in current folder)
492 // if directory name is empty
493 if (aTmpDir.size() == 0) {
501 // Create a list to store names of created files
502 SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
504 // Prepare a file name to open
505 TCollection_AsciiString aNameWithExt("");
507 aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath
508 (theComponent->GetStudy()->URL())).c_str());
509 aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
510 aSeq[0] = CORBA::string_dup(aNameWithExt.ToCString());
511 // Build a full file name of temporary file
512 TCollection_AsciiString aFullName = TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt;
513 // Save GEOM component in this file
514 _impl->Save(theComponent->GetStudy()->StudyId(),(char*) aFullName.ToCString());
515 // Conver a file to the byte stream
516 aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile);
517 // Remove the created file and tmp directory
518 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
520 // Return the created byte stream
521 return aStreamFile._retn();
525 //============================================================================
526 // function : SaveASCII()
528 //============================================================================
529 SALOMEDS::TMPFile* GEOM_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
532 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
533 return aStreamFile._retn();
537 //============================================================================
540 //============================================================================
541 CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
542 const SALOMEDS::TMPFile& theStream,
546 if (theStream.length() <= 9) {
547 MESSAGE("The TMPFile is too short : " << theStream.length() << " bytes ");
551 // Get a temporary directory for a file
552 std::string aTmpDir = isMultiFile?theURL:SALOMEDS_Tool::GetTmpDir();
554 // OCCT BUG: cannot load a document (from current folder)
555 // if directory name is empty
556 if (aTmpDir.size() == 0) {
564 // Conver the byte stream theStream to a file and place it in tmp directory
565 SALOMEDS::ListOfFileNames_var aSeq =
566 SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.c_str(), isMultiFile);
568 // Prepare a file name to open
569 TCollection_AsciiString aNameWithExt("");
571 aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath
572 (theComponent->GetStudy()->URL())).c_str());
573 aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
574 TCollection_AsciiString aFullName = (TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt);
577 if (!_impl->Load(theComponent->GetStudy()->StudyId(),(char*) aFullName.ToCString())) return false;
579 // Remove the created file and tmp directory
580 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
582 SALOMEDS::Study_var Study = theComponent->GetStudy();
583 TCollection_AsciiString name (Study->Name());
589 //============================================================================
590 // function : LoadASCII()
592 //============================================================================
593 CORBA::Boolean GEOM_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
594 const SALOMEDS::TMPFile& theStream,
597 return Load(theComponent, theStream, theURL, isMultiFile);
601 //============================================================================
602 // function : Close()
604 //============================================================================
605 void GEOM_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
607 SALOMEDS::Study_var aStudy= theComponent->GetStudy();
608 _impl->Close(aStudy->StudyId());
611 //============================================================================
612 // function : CanCopy()
614 //============================================================================
615 CORBA::Boolean GEOM_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
616 // Try to retrieve known by Geometry component GEOM_Object by given IOR
617 SALOMEDS::GenericAttribute_var anAttr;
618 if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false;
620 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
622 CORBA::String_var aString=anIOR->Value();
624 CORBA::Object_var anObj = _orb->string_to_object(aString);
625 GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(anObj);
626 // If the object is null one it can't be copied: return false
627 if (anObject->_is_nil()) return false;
631 //============================================================================
632 // function : CopyFrom()
634 //============================================================================
635 SALOMEDS::TMPFile* GEOM_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID)
637 // Declare a sequence of the byte to store the copied object
638 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
640 // Try to get GEOM_Object object by given SObject
641 SALOMEDS::GenericAttribute_var anAttr;
642 if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return aStreamFile._retn();
643 GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow
644 (_orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()));
645 if (anObject->_is_nil()) return aStreamFile._retn();
647 aStreamFile = anObject->GetShapeStream();
649 // Assign an ID the type of GEOM_Object
650 theObjectID = anObject->GetType();
652 // Return created TMPFile
653 return aStreamFile._retn();
656 //============================================================================
657 // function : CanPaste()
659 //============================================================================
660 CORBA::Boolean GEOM_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
661 // The Geometry component can paste only objects copied by Geometry component
662 // and with the object type = 1
663 if (strcmp(theComponentName, ComponentDataType()) != 0) return false;
667 //============================================================================
668 // function : PasteInto()
670 //============================================================================
671 SALOMEDS::SObject_ptr GEOM_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
672 CORBA::Long theObjectID,
673 SALOMEDS::SObject_ptr theObject) {
674 // Find the current Study and StudyBuilder
675 SALOMEDS::Study_var aStudy = theObject->GetStudy();
676 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
678 // Retrieve a TopoDS_Shape from byte stream
679 TopoDS_Shape aTopology;
680 std::istringstream aStreamedBrep((char*) &theStream[0]);
681 BRep_Builder aBuilder;
683 BRepTools::Read(aTopology, aStreamedBrep, aBuilder);
684 } catch (Standard_Failure) {
688 // SObject of the created shape is theObject or new Child of Component if theObject == geom component
689 SALOMEDS::SObject_var aNewSO;
690 if (strcmp(theObject->GetFatherComponent()->GetID(),theObject->GetID()) == 0) {
691 aNewSO = aStudyBuilder->NewObject(theObject);
692 } else aNewSO = SALOMEDS::SObject::_duplicate(theObject);
695 //Create a new GEOM_Object
696 Handle(GEOM_Object) anObj = _impl->AddObject(aNewSO->GetStudy()->StudyId(), theObjectID);
697 Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF);
698 aFunction->SetValue(aTopology);
700 TCollection_AsciiString anEntry;
701 TDF_Tool::Entry(anObj->GetEntry(), anEntry);
702 GEOM::GEOM_Object_var obj = GetObject(anObj->GetDocID(), anEntry.ToCString());
704 //Set the study entry of the published GEOM_Object
705 obj->SetStudyEntry(aNewSO->GetID());
707 // Add IORAttribute to the Study and set IOR of the created GEOM_Object to it
708 SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSO, "AttributeIOR");
709 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
710 CORBA::String_var objStr = _orb->object_to_string(obj);
711 anIOR->SetValue(objStr.in());
714 // Return the created in the Study SObject
715 return aNewSO._retn();
718 //============================================================================
719 // function : ComponentDataType()
721 //============================================================================
722 char* GEOM_Gen_i::ComponentDataType()
724 return CORBA::string_dup("GEOM");
727 //============================================================================
728 // function : AddInStudy
730 //============================================================================
731 SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
732 GEOM::GEOM_Object_ptr theObject,
734 GEOM::GEOM_Object_ptr theFather)
736 SALOMEDS::SObject_var aResultSO;
737 if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO;
739 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
740 CORBA::String_var IOR;
742 if(!theFather->_is_nil()) {
743 IOR = _orb->object_to_string(theFather);
744 SALOMEDS::SObject_var aFatherSO = theStudy->FindObjectIOR(IOR.in());
745 if(aFatherSO->_is_nil()) return aResultSO._retn();
746 aResultSO = aStudyBuilder->NewObject(aFatherSO);
747 aFatherSO->Destroy();
748 //aStudyBuilder->Addreference(aResultSO, aResultSO);
751 aResultSO = PublishInStudy(theStudy, aResultSO, theObject, theName);
752 if(aResultSO->_is_nil()) return aResultSO._retn();
754 GEOM::ListOfGO_var aList = theObject->GetDependency();
755 Standard_Integer aLength = aList->length();
756 if(aLength < 1) return aResultSO._retn();
758 //Publish the arguments
759 for(Standard_Integer i = 0; i< aLength; i++) {
760 GEOM::GEOM_Object_var anObject = aList[i];
761 if(anObject->_is_nil()) continue;
762 IOR = _orb->object_to_string(anObject);
763 SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(IOR.in());
764 if(aSO->_is_nil()) continue;
765 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO);
766 aStudyBuilder->Addreference(aSubSO, aSO);
771 return aResultSO._retn();
774 //============================================================================
775 // function : RestoreSubShapesO
776 // purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
777 // To be used from python scripts out of geompy.addToStudy (non-default usage)
778 //============================================================================
779 GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
780 GEOM::GEOM_Object_ptr theObject,
781 const GEOM::ListOfGO& theArgs,
782 GEOM::find_shape_method theFindMethod,
783 CORBA::Boolean theInheritFirstArg,
784 CORBA::Boolean theAddPrefix)
786 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
787 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject))
788 return aParts._retn();
790 // find SObject in the study if it is already published
791 CORBA::String_var anIORo = _orb->object_to_string(theObject);
792 SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(anIORo.in());
793 //PTv, IMP 0020001, The salome object <aSO>
794 // is not obligatory in case of invokation from script
795 // if (CORBA::is_nil(aSO))
796 // return aParts._retn();
798 aParts = RestoreSubShapes(theStudy, theObject, aSO, theArgs,
799 theFindMethod, theInheritFirstArg, theAddPrefix);
800 if (!CORBA::is_nil(aSO)) aSO->Destroy();
801 return aParts._retn();
804 //============================================================================
805 // function : RestoreGivenSubShapesO
806 // purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
807 // To be used from python scripts, generated by Dump Python.
808 //============================================================================
809 GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesO (SALOMEDS::Study_ptr theStudy,
810 GEOM::GEOM_Object_ptr theObject,
811 const GEOM::ListOfGO& theArgs,
812 GEOM::find_shape_method theFindMethod,
813 CORBA::Boolean theInheritFirstArg,
814 CORBA::Boolean theAddPrefix)
816 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
817 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject))
818 return aParts._retn();
820 // find SObject in the study if it is already published
821 CORBA::String_var anIORo = _orb->object_to_string(theObject);
822 SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(anIORo.in());
823 //PTv, IMP 0020001, The salome object <aSO>
824 // is not obligatory in case of invokation from script
825 // if (CORBA::is_nil(aSO))
826 // return aParts._retn();
828 aParts = RestoreGivenSubShapes(theStudy, theObject, aSO, theArgs,
829 theFindMethod, theInheritFirstArg, theAddPrefix);
830 if (!CORBA::is_nil(aSO)) aSO->Destroy();
831 return aParts._retn();
834 //============================================================================
835 // function : RestoreSubShapesSO
836 // purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
837 // To be used from GUI and from geompy.addToStudy
838 //============================================================================
839 GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
840 SALOMEDS::SObject_ptr theSObject,
841 const GEOM::ListOfGO& theArgs,
842 GEOM::find_shape_method theFindMethod,
843 CORBA::Boolean theInheritFirstArg,
844 CORBA::Boolean theAddPrefix)
846 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
847 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theSObject))
848 return aParts._retn();
850 SALOMEDS::GenericAttribute_var anAttr;
851 if (!theSObject->FindAttribute(anAttr, "AttributeIOR"))
852 return aParts._retn();
854 SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
855 CORBA::String_var anIORso = anAttrIOR->Value();
857 // get Object from SObject
858 GEOM::GEOM_Object_var anO = GEOM::GEOM_Object::_narrow(_orb->string_to_object(anIORso));
859 if (CORBA::is_nil(anO))
860 return aParts._retn();
862 aParts = RestoreSubShapes(theStudy, anO, theSObject, theArgs,
863 theFindMethod, theInheritFirstArg, theAddPrefix);
864 return aParts._retn();
867 //============================================================================
868 // function : addToListOfGO
869 // purpose : static local function
870 //============================================================================
871 static void addToListOfGO( GEOM::GEOM_Object_ptr theObject,
872 GEOM::ListOfGO& theList )
874 const int oldLen = theList.length();
875 theList.length(oldLen + 1);
876 theList[ oldLen ] = GEOM::GEOM_Object::_duplicate( theObject );
879 //============================================================================
880 // function : addToListOfGO
881 // purpose : static local function
882 //============================================================================
883 static void addToListOfGO( const GEOM::ListOfGO& theSrcList,
884 GEOM::ListOfGO& theTrgList )
886 const int oldLen = theTrgList.length();
887 const int srcLen = theSrcList.length();
888 theTrgList.length(oldLen + srcLen);
889 for( int i = 0; i < srcLen; i++ )
890 theTrgList[ oldLen + i ] = GEOM::GEOM_Object::_duplicate( theSrcList[ i ] );
893 //============================================================================
894 // function : RestoreSubShapes
895 // purpose : Private method. Works only if both theObject and theSObject
896 // are defined, and does not check, if they correspond to each other.
897 //============================================================================
898 GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy,
899 GEOM::GEOM_Object_ptr theObject,
900 SALOMEDS::SObject_ptr theSObject,
901 const GEOM::ListOfGO& theArgs,
902 GEOM::find_shape_method theFindMethod,
903 CORBA::Boolean theInheritFirstArg,
904 CORBA::Boolean theAddPrefix)
906 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
907 //PTv, IMP 0020001, The salome object <theSObject>
908 // is not obligatory in case of invokation from script
909 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject) /*|| CORBA::is_nil(theSObject)*/)
910 return aParts._retn();
912 // For Dump Python (mantis issue 0020768)
913 GEOM::ListOfGO_var anOutArgs = new GEOM::ListOfGO;
915 // Arguments to be published
916 GEOM::ListOfGO_var aList;
918 // If theArgs list is empty, we try to publish all arguments,
919 // otherwise publish only passed args
920 Standard_Integer nbArgsActual = -1; // -1 means unknown
921 Standard_Integer aLength = theArgs.length();
923 aList = new GEOM::ListOfGO;
924 aList->length(aLength);
925 for (int i = 0; i < aLength; i++) {
926 aList[i] = GEOM::GEOM_Object::_duplicate( theArgs[i] );
931 aList = theObject->GetDependency();
932 aLength = aList->length();
933 nbArgsActual = aLength;
937 return aParts._retn();
939 if (theInheritFirstArg || (nbArgsActual == 1)) {
940 // Do not publish argument's reflection,
941 // but only reconstruct its published sub-shapes
943 CORBA::String_var anIOR = _orb->object_to_string(aList[0]);
944 SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
946 // remember restored objects for Python Dump
947 addToListOfGO(aList[0], anOutArgs);
949 aParts = RestoreSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject,
950 anOutArgs, theFindMethod, theAddPrefix);
952 // set the color of the transformed shape to the color of initial shape
953 theObject->SetColor(aList[0]->GetColor());
955 if (theObject->GetShapeType() == GEOM::VERTEX) {
956 theObject->SetMarkerStd(aList[0]->GetMarkerType(), aList[0]->GetMarkerSize());
957 if (aList[0]->GetMarkerType() == GEOM::MT_USER)
958 theObject->SetMarkerTexture(aList[0]->GetMarkerTexture());
964 // Get interface, containing method, which we will use to reconstruct sub-shapes
965 GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
966 GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
968 // Reconstruct arguments and tree of sub-shapes of the arguments
969 CORBA::String_var anIOR;
970 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
971 for (Standard_Integer i = 0; i < aLength; i++)
973 GEOM::GEOM_Object_var anArgO = aList[i];
974 if (!CORBA::is_nil(anArgO)) {
975 anIOR = _orb->object_to_string(anArgO);
976 SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
977 TCollection_AsciiString anArgName;
978 if (CORBA::is_nil(anArgSO)) {
980 anArgName += TCollection_AsciiString(i);
983 anArgName = anArgSO->GetName();
986 // Find a sub-shape of theObject in place of the argument
987 GEOM::GEOM_Object_var aSubO;
988 switch (theFindMethod) {
989 case GEOM::FSM_GetInPlace:
992 aSubO = aShapesOp->GetInPlace(theObject, anArgO);
995 case GEOM::FSM_Transformed:
997 // transformation, cannot use GetInPlace, operate with indices
998 GEOM::ListOfLong_var anIDs = anArgO->GetSubShapeIndices();
999 if (anIDs->length() > 1) {
1001 aSubO = aGroupOp->CreateGroup(theObject, aGroupOp->GetType(anArgO));
1002 if (!CORBA::is_nil(aSubO))
1003 aGroupOp->UnionIDs(aSubO, anIDs);
1005 else if (anIDs->length() > 0) {
1007 aSubO = aShapesOp->GetSubShape(theObject, anIDs[0]);
1011 case GEOM::FSM_GetSame:
1014 aSubO = aShapesOp->GetSame(theObject, anArgO);
1017 case GEOM::FSM_GetShapesOnShape:
1019 // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
1020 aSubO = aShapesOp->GetShapesOnShapeAsCompound(anArgO, theObject,
1021 (short)GEOM::SOLID, GEOM::ST_ONIN);
1024 case GEOM::FSM_GetInPlaceByHistory:
1026 // Use GetInPlaceByHistory
1027 aSubO = aShapesOp->GetInPlaceByHistory(theObject, anArgO);
1034 if (!CORBA::is_nil(aSubO)) {
1035 // remember restored objects for Python Dump
1036 addToListOfGO(anArgO, anOutArgs);
1038 // add to parts list
1039 addToListOfGO( aSubO, aParts );
1041 // Publish the sub-shape
1042 SALOMEDS::SObject_var aSubSO;
1043 if (!CORBA::is_nil(theSObject)) {
1044 TCollection_AsciiString aSubName;
1048 aSubName += anArgName;
1049 aSubSO = aStudyBuilder->NewObject(theSObject);
1050 aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
1052 aSubO->SetColor(anArgO->GetColor());
1054 if (aSubO->GetShapeType() == GEOM::VERTEX) {
1055 aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
1056 if (anArgO->GetMarkerType() == GEOM::MT_USER)
1057 aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
1061 if (!CORBA::is_nil(anArgSO)) {
1062 // Restore published sub-shapes of the argument
1063 GEOM::ListOfGO_var aSubParts;
1064 if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
1065 // pass theObject, because only it has the history
1066 aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1067 theObject, anOutArgs, theFindMethod, theAddPrefix);
1069 aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1070 aSubO, anOutArgs, theFindMethod, theAddPrefix);
1071 // add to parts list
1072 addToListOfGO( aSubParts, aParts );
1075 else { // GetInPlace failed, try to build from published parts
1076 if (!CORBA::is_nil(anArgSO)) {
1077 SALOMEDS::SObject_var aSubSO;
1078 if (!CORBA::is_nil(theSObject))
1079 aSubSO = aStudyBuilder->NewObject(theSObject);
1081 // Restore published sub-shapes of the argument
1082 GEOM::ListOfGO_var aSubParts =
1083 RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1084 theObject, anOutArgs, theFindMethod, theAddPrefix);
1086 // add to parts list
1087 addToListOfGO( aSubParts, aParts );
1089 if (aSubParts->length() > 0) {
1090 // remember restored objects for Python Dump
1091 addToListOfGO(anArgO, anOutArgs);
1093 // try to build an argument from a set of its sub-shapes,
1094 // that published and will be reconstructed
1095 if (aSubParts->length() > 1) {
1096 aSubO = aShapesOp->MakeCompound(aSubParts);
1097 // add to parts list
1098 addToListOfGO( aSubO, aParts );
1101 aSubO = aSubParts[0];
1103 if (!CORBA::is_nil(aSubO) && !CORBA::is_nil(aSubSO)) {
1104 // Publish the sub-shape
1105 TCollection_AsciiString aSubName;
1107 aSubName = "from_parts_of_";
1109 aSubName += anArgName;
1110 aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
1112 aSubO->SetColor(anArgO->GetColor());
1114 if (aSubO->GetShapeType() == GEOM::VERTEX) {
1115 aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
1116 if (anArgO->GetMarkerType() == GEOM::MT_USER)
1117 aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
1121 else if (!CORBA::is_nil(aSubSO)) {
1122 // remove created aSubSO, because no parts have been found
1123 aStudyBuilder->RemoveObject(aSubSO);
1126 } // try to build from published parts
1129 } // process arguments
1131 std::set<std::string> anObjEntryMap;
1132 GEOM::ListOfGO_var aResParts = new GEOM::ListOfGO;
1134 int nb = aParts->length();
1135 aResParts->length(nb);
1138 Handle(GEOM_Object) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
1139 Handle(GEOM_Function) aFunction = aMainObj->GetLastFunction();
1140 GEOM::TPythonDump pd (aFunction, true);
1143 for ( ; i < nb; i++ )
1145 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_duplicate( aParts[ i ] );
1146 if (CORBA::is_nil(anObj))
1148 char* anEntry = anObj->GetEntry();
1149 if (anObjEntryMap.count(anEntry))
1150 continue; // already treated
1151 anObjEntryMap.insert(anEntry);
1152 aResParts[nbRes++] = anObj;
1153 // clear python dump of object
1154 Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
1155 Handle(GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
1156 if ( !anObjFun.IsNull() )
1157 anObjFun->SetDescription( "" );
1163 pd <<"]" << " = geompy.RestoreGivenSubShapes(" << aMainObj << ", " << "[";
1164 //i = 0; nb = theArgs.length(); j = 0;
1165 i = 0; nb = anOutArgs->length(); j = 0;
1166 for ( ; i < nb; i++ )
1168 //GEOM::GEOM_Object_var anObj = theArgs[ i ];
1169 GEOM::GEOM_Object_var anObj = anOutArgs[ i ];
1170 if (CORBA::is_nil(anObj))
1172 Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
1178 pd <<"]" << ", " <<"geompy.GEOM.";
1179 switch (theFindMethod) {
1180 case GEOM::FSM_GetInPlace:
1181 pd << "FSM_GetInPlace"; break;
1182 case GEOM::FSM_Transformed:
1183 pd << "FSM_Transformed"; break;
1184 case GEOM::FSM_GetSame:
1185 pd << "FSM_GetSame"; break;
1186 case GEOM::FSM_GetShapesOnShape:
1187 pd << "FSM_GetShapesOnShape"; break;
1188 case GEOM::FSM_GetInPlaceByHistory:
1190 pd << "FSM_GetInPlaceByHistory"; break;
1192 pd << ", " << theInheritFirstArg << ", " << theAddPrefix << ")";
1194 aResParts->length(nbRes);
1195 return aResParts._retn();
1198 //============================================================================
1199 // function : RestoreSubShapesOneLevel
1200 // purpose : Private method
1201 //============================================================================
1202 GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
1203 SALOMEDS::SObject_ptr theOldSO,
1204 SALOMEDS::SObject_ptr theNewSO,
1205 GEOM::GEOM_Object_ptr theNewO,
1206 GEOM::ListOfGO& theOutArgs,
1207 GEOM::find_shape_method theFindMethod,
1208 CORBA::Boolean theAddPrefix)
1211 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
1212 GEOM::ListOfGO_var aNewParts = new GEOM::ListOfGO;
1213 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theOldSO) ||
1214 CORBA::is_nil(theNewO) /*|| CORBA::is_nil(theNewSO)*/)
1215 return aParts._retn();
1217 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
1219 // Get interface, containing method, which we will use to reconstruct sub-shapes
1220 GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
1221 GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
1223 // Reconstruct published sub-shapes
1224 SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO);
1227 for (it->Init(); it->More(); it->Next()) {
1230 aParts->length(aLen);
1232 for (it->Init(); it->More(); it->Next()) {
1233 SALOMEDS::SObject_var anOldSubSO = it->Value();
1235 TCollection_AsciiString anArgName = anOldSubSO->GetName();
1237 SALOMEDS::GenericAttribute_var anAttr;
1238 if (anOldSubSO->FindAttribute(anAttr, "AttributeIOR")) {
1239 SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1240 GEOM::GEOM_Object_var anOldSubO =
1241 GEOM::GEOM_Object::_narrow(_orb->string_to_object(anAttrIOR->Value()));
1242 if (!CORBA::is_nil(anOldSubO)) {
1243 // Find a sub-shape of theNewO in place of anOldSubO
1244 GEOM::GEOM_Object_var aNewSubO;
1245 switch (theFindMethod) {
1246 case GEOM::FSM_GetInPlace:
1249 aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO);
1252 case GEOM::FSM_Transformed:
1254 // transformation, cannot use GetInPlace, operate with indices
1255 GEOM::ListOfLong_var anIDs = anOldSubO->GetSubShapeIndices();
1256 if (anIDs->length() > 1) {
1258 aNewSubO = aGroupOp->CreateGroup(theNewO, aGroupOp->GetType(anOldSubO));
1259 if (!CORBA::is_nil(aNewSubO))
1260 aGroupOp->UnionIDs(aNewSubO, anIDs);
1264 aNewSubO = aShapesOp->GetSubShape(theNewO, anIDs[0]);
1268 case GEOM::FSM_GetSame:
1271 aNewSubO = aShapesOp->GetSame(theNewO, anOldSubO);
1274 case GEOM::FSM_GetShapesOnShape:
1276 // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
1277 aNewSubO = aShapesOp->GetShapesOnShapeAsCompound(anOldSubO, theNewO,
1278 (short)GEOM::SOLID, GEOM::ST_ONIN);
1281 case GEOM::FSM_GetInPlaceByHistory:
1283 // Use GetInPlaceByHistory
1284 aNewSubO = aShapesOp->GetInPlaceByHistory(theNewO, anOldSubO);
1291 if (!CORBA::is_nil(aNewSubO)) {
1292 // remember restored objects for Python Dump
1293 addToListOfGO(anOldSubO, theOutArgs);
1295 // add the part to the list
1296 aParts[i] = aNewSubO;
1298 // add to parts list
1299 addToListOfGO( aNewSubO, aNewParts );
1301 SALOMEDS::SObject_var aNewSubSO;
1302 if (!CORBA::is_nil(theNewSO)) {
1303 // Publish the sub-shape
1304 TCollection_AsciiString aSubName;
1308 aSubName += anArgName;
1309 aNewSubSO = aStudyBuilder->NewObject(theNewSO);
1310 aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
1312 aNewSubO->SetColor(anOldSubO->GetColor());
1314 if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
1315 aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
1316 if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
1317 aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
1320 // Restore published sub-shapes of the argument
1321 GEOM::ListOfGO_var aSubParts;
1322 if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
1323 // pass the main shape as Object, because only it has the history
1324 aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1325 theNewO, theOutArgs, theFindMethod, theAddPrefix);
1327 aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1328 aNewSubO, theOutArgs, theFindMethod, theAddPrefix);
1329 // add to parts list
1330 addToListOfGO( aSubParts, aNewParts );
1332 else { // GetInPlace failed, try to build from published parts
1333 SALOMEDS::SObject_var aNewSubSO;
1334 if (!CORBA::is_nil(theNewSO))
1335 aNewSubSO = aStudyBuilder->NewObject(theNewSO);
1337 // Restore published sub-shapes of the argument
1338 GEOM::ListOfGO_var aSubParts =
1339 RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1340 theNewO, theOutArgs, theFindMethod, theAddPrefix);
1341 // add to parts list
1342 addToListOfGO( aSubParts, aNewParts );
1344 if (aSubParts->length() > 0) {
1345 // remember restored objects for Python Dump
1346 addToListOfGO(anOldSubO, theOutArgs);
1348 // try to build an object from a set of its sub-shapes,
1349 // that published and will be reconstructed
1350 if (aSubParts->length() > 1) {
1351 aNewSubO = aShapesOp->MakeCompound(aSubParts);
1352 // add to parts list
1353 addToListOfGO( aNewSubO, aNewParts );
1356 aNewSubO = aSubParts[0];
1359 if (!CORBA::is_nil(aNewSubO)) {
1360 // add the part to the list
1361 aSubParts[i] = aNewSubO;
1364 // Publish the sub-shape
1365 if (!CORBA::is_nil(aNewSubSO)) {
1366 TCollection_AsciiString aSubName;
1368 aSubName = "from_parts_of_";
1370 aSubName += anArgName;
1371 aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
1373 aNewSubO->SetColor(anOldSubO->GetColor());
1375 if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
1376 aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
1377 if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
1378 aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
1383 else if (!CORBA::is_nil(aNewSubSO)) {
1384 // remove created aSubSO, because no parts have been found
1385 aStudyBuilder->RemoveObject(aNewSubSO);
1387 } // try to build from published parts
1390 } // iterate on published sub-shapes
1393 // add to parts list
1394 addToListOfGO( aNewParts, aParts );
1395 return aParts._retn();
1398 //============================================================================
1399 // function : RestoreGivenSubShapes
1400 // purpose : Private method. Works only if both theObject and theSObject
1401 // are defined, and does not check, if they correspond to each other.
1402 // List theArgs in this case contains not only operation arguments,
1403 // but also all subshapes, which must be published.
1404 //============================================================================
1405 GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr theStudy,
1406 GEOM::GEOM_Object_ptr theObject,
1407 SALOMEDS::SObject_ptr theSObject,
1408 const GEOM::ListOfGO& theArgs,
1409 GEOM::find_shape_method theFindMethod,
1410 CORBA::Boolean theInheritFirstArg,
1411 CORBA::Boolean theAddPrefix)
1413 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
1414 //PTv, IMP 0020001, The salome object <theSObject>
1415 // is not obligatory in case of invokation from script
1416 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject) /*|| CORBA::is_nil(theSObject)*/)
1417 return aParts._retn();
1419 // If theArgs list is empty, nothing to do
1420 Standard_Integer aLength = theArgs.length();
1422 return aParts._retn();
1424 // Get all arguments
1425 GEOM::ListOfGO_var anOpArgsList = theObject->GetDependency();
1426 Standard_Integer nbArgsActual = anOpArgsList->length();
1428 // If anOpArgsList list is empty, nothing to do
1429 if (nbArgsActual == 0)
1430 return aParts._retn();
1432 // Entries of arguments and subshapes
1433 std::set<std::string> anArgs;
1434 for (int i = 0; i < aLength; i++) {
1435 CORBA::String_var anEntry = theArgs[i]->GetEntry();
1436 anArgs.insert(anEntry.in());
1439 // Arguments to be published
1440 // We try to publish all arguments, that are in theArgs list
1441 GEOM::ListOfGO_var aList = new GEOM::ListOfGO;
1442 aList->length(nbArgsActual);
1445 for (int j = 0; j < nbArgsActual; j++) {
1446 CORBA::String_var anEntry = anOpArgsList[j]->GetEntry();
1447 if (anArgs.count(anEntry.in())) {
1448 aList[k] = GEOM::GEOM_Object::_duplicate(anOpArgsList[j]);
1453 //aList->length(nbArgsActual);
1455 if (nbArgsActual < 1)
1456 return aParts._retn();
1458 if (theInheritFirstArg || (nbArgsActual == 1)) {
1459 // Do not publish argument's reflection,
1460 // but only reconstruct its published sub-shapes
1462 CORBA::String_var anIOR = _orb->object_to_string(aList[0]);
1463 SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
1465 aParts = RestoreGivenSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject,
1466 anArgs, theFindMethod, theAddPrefix);
1468 // set the color of the transformed shape to the color of initial shape
1469 theObject->SetColor(aList[0]->GetColor());
1471 if (theObject->GetShapeType() == GEOM::VERTEX) {
1472 theObject->SetMarkerStd(aList[0]->GetMarkerType(), aList[0]->GetMarkerSize());
1473 if (aList[0]->GetMarkerType() == GEOM::MT_USER)
1474 theObject->SetMarkerTexture(aList[0]->GetMarkerTexture());
1480 // Get interface, containing method, which we will use to reconstruct sub-shapes
1481 GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
1482 GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
1484 // Reconstruct arguments and tree of sub-shapes of the arguments
1485 CORBA::String_var anIOR;
1486 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
1487 for (Standard_Integer i = 0; i < nbArgsActual; i++)
1489 GEOM::GEOM_Object_var anArgO = aList[i];
1490 if (!CORBA::is_nil(anArgO)) {
1491 anIOR = _orb->object_to_string(anArgO);
1492 SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
1493 TCollection_AsciiString anArgName;
1494 if (CORBA::is_nil(anArgSO)) {
1496 anArgName += TCollection_AsciiString(i);
1499 anArgName = anArgSO->GetName();
1502 // Find a sub-shape of theObject in place of the argument
1503 GEOM::GEOM_Object_var aSubO;
1504 switch (theFindMethod) {
1505 case GEOM::FSM_GetInPlace:
1508 aSubO = aShapesOp->GetInPlace(theObject, anArgO);
1511 case GEOM::FSM_Transformed:
1513 // transformation, cannot use GetInPlace, operate with indices
1514 GEOM::ListOfLong_var anIDs = anArgO->GetSubShapeIndices();
1515 if (anIDs->length() > 1) {
1517 aSubO = aGroupOp->CreateGroup(theObject, aGroupOp->GetType(anArgO));
1518 if (!CORBA::is_nil(aSubO))
1519 aGroupOp->UnionIDs(aSubO, anIDs);
1521 else if (anIDs->length() > 0) {
1523 aSubO = aShapesOp->GetSubShape(theObject, anIDs[0]);
1527 case GEOM::FSM_GetSame:
1530 aSubO = aShapesOp->GetSame(theObject, anArgO);
1533 case GEOM::FSM_GetShapesOnShape:
1535 // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
1536 aSubO = aShapesOp->GetShapesOnShapeAsCompound(anArgO, theObject,
1537 (short)GEOM::SOLID, GEOM::ST_ONIN);
1540 case GEOM::FSM_GetInPlaceByHistory:
1542 // Use GetInPlaceByHistory
1543 aSubO = aShapesOp->GetInPlaceByHistory(theObject, anArgO);
1550 if (!CORBA::is_nil(aSubO)) {
1551 // add to parts list
1552 addToListOfGO( aSubO, aParts );
1554 // Publish the sub-shape
1555 SALOMEDS::SObject_var aSubSO;
1556 if (!CORBA::is_nil(theSObject)) {
1557 TCollection_AsciiString aSubName;
1561 aSubName += anArgName;
1562 aSubSO = aStudyBuilder->NewObject(theSObject);
1563 aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
1565 aSubO->SetColor(anArgO->GetColor());
1567 if (aSubO->GetShapeType() == GEOM::VERTEX) {
1568 aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
1569 if (anArgO->GetMarkerType() == GEOM::MT_USER)
1570 aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
1574 if (!CORBA::is_nil(anArgSO)) {
1575 // Restore published sub-shapes of the argument
1576 GEOM::ListOfGO_var aSubParts;
1577 if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
1578 // pass theObject, because only it has the history
1579 aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1580 theObject, anArgs, theFindMethod, theAddPrefix);
1582 aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1583 aSubO, anArgs, theFindMethod, theAddPrefix);
1584 // add to parts list
1585 addToListOfGO( aSubParts, aParts );
1588 else { // GetInPlace failed, try to build from published parts
1589 if (!CORBA::is_nil(anArgSO)) {
1590 SALOMEDS::SObject_var aSubSO;
1591 if (!CORBA::is_nil(theSObject))
1592 aSubSO = aStudyBuilder->NewObject(theSObject);
1594 // Restore published sub-shapes of the argument
1595 GEOM::ListOfGO_var aSubParts =
1596 RestoreGivenSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1597 theObject, anArgs, theFindMethod, theAddPrefix);
1599 // add to parts list
1600 addToListOfGO( aSubParts, aParts );
1602 if (aSubParts->length() > 0) {
1603 // try to build an argument from a set of its sub-shapes,
1604 // that published and will be reconstructed
1605 if (aSubParts->length() > 1) {
1606 aSubO = aShapesOp->MakeCompound(aSubParts);
1607 // add to parts list
1608 addToListOfGO( aSubO, aParts );
1611 aSubO = aSubParts[0];
1613 if (!CORBA::is_nil(aSubO) && !CORBA::is_nil(aSubSO)) {
1614 // Publish the sub-shape
1615 TCollection_AsciiString aSubName;
1617 aSubName = "from_parts_of_";
1619 aSubName += anArgName;
1620 aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
1622 aSubO->SetColor(anArgO->GetColor());
1624 if (aSubO->GetShapeType() == GEOM::VERTEX) {
1625 aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
1626 if (anArgO->GetMarkerType() == GEOM::MT_USER)
1627 aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
1631 else if (!CORBA::is_nil(aSubSO)) {
1632 // remove created aSubSO, because no parts have been found
1633 aStudyBuilder->RemoveObject(aSubSO);
1636 } // try to build from published parts
1639 } // process arguments
1641 std::set<std::string> anObjEntryMap;
1642 GEOM::ListOfGO_var aResParts = new GEOM::ListOfGO;
1644 int nb = aParts->length();
1645 aResParts->length(nb);
1648 Handle(GEOM_Object) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
1649 Handle(GEOM_Function) aFunction = aMainObj->GetLastFunction();
1650 GEOM::TPythonDump pd (aFunction, true);
1653 for ( ; i < nb; i++ )
1655 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_duplicate( aParts[ i ] );
1656 if (CORBA::is_nil(anObj))
1658 char* anEntry = anObj->GetEntry();
1659 if (anObjEntryMap.count(anEntry))
1660 continue; // already treated
1661 anObjEntryMap.insert(anEntry);
1662 aResParts[nbRes++] = anObj;
1663 // clear python dump of object
1664 Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
1665 Handle(GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
1666 if ( !anObjFun.IsNull() )
1667 anObjFun->SetDescription( "" );
1673 pd <<"]" << " = geompy.RestoreGivenSubShapes(" << aMainObj << ", " << "[";
1674 i = 0; nb = theArgs.length(); j = 0;
1675 for ( ; i < nb; i++ )
1677 GEOM::GEOM_Object_var anObj = theArgs[ i ];
1678 if (CORBA::is_nil(anObj))
1680 Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
1686 pd <<"]" << ", " <<"geompy.GEOM.";
1687 switch (theFindMethod) {
1688 case GEOM::FSM_GetInPlace:
1689 pd << "FSM_GetInPlace"; break;
1690 case GEOM::FSM_Transformed:
1691 pd << "FSM_Transformed"; break;
1692 case GEOM::FSM_GetSame:
1693 pd << "FSM_GetSame"; break;
1694 case GEOM::FSM_GetShapesOnShape:
1695 pd << "FSM_GetShapesOnShape"; break;
1696 case GEOM::FSM_GetInPlaceByHistory:
1698 pd << "FSM_GetInPlaceByHistory"; break;
1700 pd << ", " << theInheritFirstArg << ", " << theAddPrefix << ")";
1702 aResParts->length(nbRes);
1703 return aResParts._retn();
1706 //============================================================================
1707 // function : RestoreGivenSubShapesOneLevel
1708 // purpose : Private method
1709 //============================================================================
1710 GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
1711 SALOMEDS::SObject_ptr theOldSO,
1712 SALOMEDS::SObject_ptr theNewSO,
1713 GEOM::GEOM_Object_ptr theNewO,
1714 std::set<std::string> theArgs,
1715 GEOM::find_shape_method theFindMethod,
1716 CORBA::Boolean theAddPrefix)
1719 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
1720 GEOM::ListOfGO_var aNewParts = new GEOM::ListOfGO;
1721 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theOldSO) ||
1722 CORBA::is_nil(theNewO) /*|| CORBA::is_nil(theNewSO)*/)
1723 return aParts._retn();
1725 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
1727 // Get interface, containing method, which we will use to reconstruct sub-shapes
1728 GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
1729 GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
1731 // Reconstruct published sub-shapes
1732 SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO);
1735 for (it->Init(); it->More(); it->Next()) {
1738 aParts->length(aLen);
1740 for (it->Init(); it->More(); it->Next()) {
1741 SALOMEDS::SObject_var anOldSubSO = it->Value();
1743 TCollection_AsciiString anArgName = anOldSubSO->GetName();
1745 SALOMEDS::GenericAttribute_var anAttr;
1746 if (anOldSubSO->FindAttribute(anAttr, "AttributeIOR")) {
1747 SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1748 GEOM::GEOM_Object_var anOldSubO =
1749 GEOM::GEOM_Object::_narrow(_orb->string_to_object(anAttrIOR->Value()));
1751 bool okToContinue = false;
1753 if (!CORBA::is_nil(anOldSubO)) {
1754 CORBA::String_var anEntry = anOldSubO->GetEntry();
1755 okToContinue = theArgs.count(anEntry.in());
1759 // Find a sub-shape of theNewO in place of anOldSubO
1760 GEOM::GEOM_Object_var aNewSubO;
1761 switch (theFindMethod) {
1762 case GEOM::FSM_GetInPlace:
1765 aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO);
1768 case GEOM::FSM_Transformed:
1770 // transformation, cannot use GetInPlace, operate with indices
1771 GEOM::ListOfLong_var anIDs = anOldSubO->GetSubShapeIndices();
1772 if (anIDs->length() > 1) {
1774 aNewSubO = aGroupOp->CreateGroup(theNewO, aGroupOp->GetType(anOldSubO));
1775 if (!CORBA::is_nil(aNewSubO))
1776 aGroupOp->UnionIDs(aNewSubO, anIDs);
1780 aNewSubO = aShapesOp->GetSubShape(theNewO, anIDs[0]);
1784 case GEOM::FSM_GetSame:
1787 aNewSubO = aShapesOp->GetSame(theNewO, anOldSubO);
1790 case GEOM::FSM_GetShapesOnShape:
1792 // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
1793 aNewSubO = aShapesOp->GetShapesOnShapeAsCompound(anOldSubO, theNewO,
1794 (short)GEOM::SOLID, GEOM::ST_ONIN);
1797 case GEOM::FSM_GetInPlaceByHistory:
1799 // Use GetInPlaceByHistory
1800 aNewSubO = aShapesOp->GetInPlaceByHistory(theNewO, anOldSubO);
1807 if (!CORBA::is_nil(aNewSubO)) {
1808 // add the part to the list
1809 aParts[i] = aNewSubO;
1811 // add to parts list
1812 addToListOfGO( aNewSubO, aNewParts );
1814 SALOMEDS::SObject_var aNewSubSO;
1815 if (!CORBA::is_nil(theNewSO)) {
1816 // Publish the sub-shape
1817 TCollection_AsciiString aSubName;
1821 aSubName += anArgName;
1822 aNewSubSO = aStudyBuilder->NewObject(theNewSO);
1823 aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
1825 aNewSubO->SetColor(anOldSubO->GetColor());
1827 if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
1828 aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
1829 if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
1830 aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
1833 // Restore published sub-shapes of the argument
1834 GEOM::ListOfGO_var aSubParts;
1835 if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
1836 // pass the main shape as Object, because only it has the history
1837 aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1838 theNewO, theArgs, theFindMethod, theAddPrefix);
1840 aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1841 aNewSubO, theArgs, theFindMethod, theAddPrefix);
1842 // add to parts list
1843 addToListOfGO( aSubParts, aNewParts );
1845 else { // GetInPlace failed, try to build from published parts
1846 SALOMEDS::SObject_var aNewSubSO;
1847 if (!CORBA::is_nil(theNewSO))
1848 aNewSubSO = aStudyBuilder->NewObject(theNewSO);
1850 // Restore published sub-shapes of the argument
1851 GEOM::ListOfGO_var aSubParts =
1852 RestoreGivenSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1853 theNewO, theArgs, theFindMethod, theAddPrefix);
1854 // add to parts list
1855 addToListOfGO( aSubParts, aNewParts );
1857 if (aSubParts->length() > 0) {
1858 // try to build an object from a set of its sub-shapes,
1859 // that published and will be reconstructed
1860 if (aSubParts->length() > 1) {
1861 aNewSubO = aShapesOp->MakeCompound(aSubParts);
1862 // add to parts list
1863 addToListOfGO( aNewSubO, aNewParts );
1866 aNewSubO = aSubParts[0];
1869 if (!CORBA::is_nil(aNewSubO)) {
1870 // add the part to the list
1871 aSubParts[i] = aNewSubO;
1874 // Publish the sub-shape
1875 if (!CORBA::is_nil(aNewSubSO)) {
1876 TCollection_AsciiString aSubName;
1878 aSubName = "from_parts_of_";
1880 aSubName += anArgName;
1881 aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
1883 aNewSubO->SetColor(anOldSubO->GetColor());
1885 if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
1886 aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
1887 if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
1888 aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
1893 else if (!CORBA::is_nil(aNewSubSO)) {
1894 // remove created aSubSO, because no parts have been found
1895 aStudyBuilder->RemoveObject(aNewSubSO);
1897 } // try to build from published parts
1900 } // iterate on published sub-shapes
1903 // add to parts list
1904 addToListOfGO( aNewParts, aParts );
1905 return aParts._retn();
1908 //============================================================================
1909 // function : register()
1910 // purpose : register 'name' in 'name_service'
1911 //============================================================================
1912 void GEOM_Gen_i::register_name(char * name)
1914 GEOM::GEOM_Gen_var g = _this();
1915 name_service->Register(g, name);
1918 //============================================================================
1921 //============================================================================
1922 void GEOM_Gen_i::Undo(CORBA::Long theStudyID)
1924 _impl->Undo(theStudyID);
1927 //============================================================================
1930 //============================================================================
1931 void GEOM_Gen_i::Redo(CORBA::Long theStudyID)
1933 _impl->Redo(theStudyID);
1936 //============================================================================
1937 // function : GetIBasicOperations
1939 //============================================================================
1940 GEOM::GEOM_IBasicOperations_ptr GEOM_Gen_i::GetIBasicOperations(CORBA::Long theStudyID)
1941 throw ( SALOME::SALOME_Exception )
1943 Unexpect aCatch(SALOME_SalomeException);
1944 MESSAGE( "GEOM_Gen_i::GetIBasicOperations" );
1946 GEOM::GEOM_Gen_ptr engine = _this();
1948 //transfer reference on engine
1949 GEOM_IBasicOperations_i* aServant =
1950 new GEOM_IBasicOperations_i(_poa, engine, _impl->GetIBasicOperations(theStudyID));
1952 PortableServer::ObjectId_var id = _poa->activate_object(aServant);
1953 // activate the CORBA servant
1954 GEOM::GEOM_IBasicOperations_var operations = aServant->_this();
1955 return operations._retn();
1958 //============================================================================
1959 // function : GetITransformOperations
1961 //============================================================================
1962 GEOM::GEOM_ITransformOperations_ptr GEOM_Gen_i::GetITransformOperations(CORBA::Long theStudyID)
1963 throw ( SALOME::SALOME_Exception )
1965 Unexpect aCatch(SALOME_SalomeException);
1966 MESSAGE( "GEOM_Gen_i::GetITransformOperations" );
1968 GEOM::GEOM_Gen_ptr engine = _this();
1970 GEOM_ITransformOperations_i* aServant =
1971 new GEOM_ITransformOperations_i(_poa, engine, _impl->GetITransformOperations(theStudyID));
1973 // activate the CORBA servant
1974 GEOM::GEOM_ITransformOperations_var operations = aServant->_this();
1975 return operations._retn();
1978 //============================================================================
1979 // function : GetI3DPrimOperations
1981 //============================================================================
1982 GEOM::GEOM_I3DPrimOperations_ptr GEOM_Gen_i::GetI3DPrimOperations(CORBA::Long theStudyID)
1983 throw ( SALOME::SALOME_Exception )
1985 Unexpect aCatch(SALOME_SalomeException);
1986 MESSAGE( "GEOM_Gen_i::GetI3DPrimOperations" );
1988 GEOM::GEOM_Gen_ptr engine = _this();
1990 GEOM_I3DPrimOperations_i* aServant =
1991 new GEOM_I3DPrimOperations_i(_poa, engine, _impl->GetI3DPrimOperations(theStudyID));
1992 PortableServer::ObjectId_var id = _poa->activate_object(aServant);
1994 // activate the CORBA servant
1995 GEOM::GEOM_I3DPrimOperations_var operations = aServant->_this();
1996 return operations._retn();
1999 //============================================================================
2000 // function : GetIShapesOperations
2002 //============================================================================
2003 GEOM::GEOM_IShapesOperations_ptr GEOM_Gen_i::GetIShapesOperations(CORBA::Long theStudyID)
2004 throw ( SALOME::SALOME_Exception )
2006 Unexpect aCatch(SALOME_SalomeException);
2007 MESSAGE( "GEOM_Gen_i::GetIShapesOperations" );
2009 GEOM::GEOM_Gen_ptr engine = _this();
2011 GEOM_IShapesOperations_i* aServant =
2012 new GEOM_IShapesOperations_i(_poa, engine, _impl->GetIShapesOperations(theStudyID));
2014 // activate the CORBA servant
2015 GEOM::GEOM_IShapesOperations_var operations = aServant->_this();
2016 return operations._retn();
2019 //============================================================================
2020 // function : GetIBlocksOperations
2022 //============================================================================
2023 GEOM::GEOM_IBlocksOperations_ptr GEOM_Gen_i::GetIBlocksOperations(CORBA::Long theStudyID)
2024 throw ( SALOME::SALOME_Exception )
2026 Unexpect aCatch(SALOME_SalomeException);
2027 MESSAGE( "GEOM_Gen_i::GetIBlocksOperations" );
2029 GEOM::GEOM_Gen_ptr engine = _this();
2031 GEOM_IBlocksOperations_i* aServant =
2032 new GEOM_IBlocksOperations_i(_poa, engine, _impl->GetIBlocksOperations(theStudyID));
2034 // activate the CORBA servant
2035 GEOM::GEOM_IBlocksOperations_var operations = aServant->_this();
2036 return operations._retn();
2039 //============================================================================
2040 // function : GetIBooleanOperations
2042 //============================================================================
2043 GEOM::GEOM_IBooleanOperations_ptr GEOM_Gen_i::GetIBooleanOperations(CORBA::Long theStudyID)
2044 throw ( SALOME::SALOME_Exception )
2046 Unexpect aCatch(SALOME_SalomeException);
2047 MESSAGE( "GEOM_Gen_i::GetIBooleanOperations" );
2049 GEOM::GEOM_Gen_ptr engine = _this();
2051 GEOM_IBooleanOperations_i* aServant =
2052 new GEOM_IBooleanOperations_i(_poa, engine, _impl->GetIBooleanOperations(theStudyID));
2054 // activate the CORBA servant
2055 GEOM::GEOM_IBooleanOperations_var operations = aServant->_this();
2056 return operations._retn();
2059 //============================================================================
2060 // function : GetICurvesOperations
2062 //============================================================================
2063 GEOM::GEOM_ICurvesOperations_ptr GEOM_Gen_i::GetICurvesOperations(CORBA::Long theStudyID)
2064 throw ( SALOME::SALOME_Exception )
2066 Unexpect aCatch(SALOME_SalomeException);
2067 MESSAGE( "GEOM_Gen_i::GetICurvesOperations" );
2069 GEOM::GEOM_Gen_ptr engine = _this();
2071 GEOM_ICurvesOperations_i* aServant =
2072 new GEOM_ICurvesOperations_i(_poa, engine, _impl->GetICurvesOperations(theStudyID));
2074 // activate the CORBA servant
2075 GEOM::GEOM_ICurvesOperations_var operations = aServant->_this();
2076 return operations._retn();
2079 //============================================================================
2080 // function : GetILocalOperations
2082 //============================================================================
2083 GEOM::GEOM_ILocalOperations_ptr GEOM_Gen_i::GetILocalOperations(CORBA::Long theStudyID)
2084 throw ( SALOME::SALOME_Exception )
2086 Unexpect aCatch(SALOME_SalomeException);
2087 MESSAGE( "GEOM_Gen_i::GetILocalOperations" );
2089 GEOM::GEOM_Gen_ptr engine = _this();
2091 GEOM_ILocalOperations_i* aServant =
2092 new GEOM_ILocalOperations_i(_poa, engine, _impl->GetILocalOperations(theStudyID));
2094 // activate the CORBA servant
2095 GEOM::GEOM_ILocalOperations_var operations = aServant->_this();
2096 return operations._retn();
2099 //============================================================================
2100 // function : GetIHealingOperations
2102 //============================================================================
2103 GEOM::GEOM_IHealingOperations_ptr GEOM_Gen_i::GetIHealingOperations(CORBA::Long theStudyID)
2104 throw ( SALOME::SALOME_Exception )
2106 Unexpect aCatch(SALOME_SalomeException);
2107 MESSAGE( "GEOM_Gen_i::IHealingOperations" );
2109 GEOM::GEOM_Gen_ptr engine = _this();
2111 GEOM_IHealingOperations_i* aServant =
2112 new GEOM_IHealingOperations_i(_poa, engine, _impl->GetIHealingOperations(theStudyID));
2114 // activate the CORBA servant
2115 GEOM::GEOM_IHealingOperations_var operations = aServant->_this();
2116 return operations._retn();
2119 //============================================================================
2120 // function : GetIInsertOperations
2122 //============================================================================
2123 GEOM::GEOM_IInsertOperations_ptr GEOM_Gen_i::GetIInsertOperations(CORBA::Long theStudyID)
2124 throw ( SALOME::SALOME_Exception )
2126 Unexpect aCatch(SALOME_SalomeException);
2127 MESSAGE( "GEOM_Gen_i::GetIInsertOperations" );
2129 GEOM::GEOM_Gen_ptr engine = _this();
2131 GEOM_IInsertOperations_i* aServant =
2132 new GEOM_IInsertOperations_i(_poa, engine, _impl->GetIInsertOperations(theStudyID));
2134 // activate the CORBA servant
2135 GEOM::GEOM_IInsertOperations_var operations = aServant->_this();
2136 return operations._retn();
2139 //============================================================================
2140 // function : GetIMeasureOperations
2142 //============================================================================
2143 GEOM::GEOM_IMeasureOperations_ptr GEOM_Gen_i::GetIMeasureOperations(CORBA::Long theStudyID)
2144 throw ( SALOME::SALOME_Exception )
2146 Unexpect aCatch(SALOME_SalomeException);
2147 MESSAGE( "GEOM_Gen_i::GetIMeasureOperations" );
2149 GEOM::GEOM_Gen_ptr engine = _this();
2151 GEOM_IMeasureOperations_i* aServant =
2152 new GEOM_IMeasureOperations_i(_poa, engine, _impl->GetIMeasureOperations(theStudyID));
2154 // activate the CORBA servant
2155 GEOM::GEOM_IMeasureOperations_var operations = aServant->_this();
2156 return operations._retn();
2159 //============================================================================
2160 // function : GetIGroupOperations
2162 //============================================================================
2163 GEOM::GEOM_IGroupOperations_ptr GEOM_Gen_i::GetIGroupOperations(CORBA::Long theStudyID)
2164 throw ( SALOME::SALOME_Exception )
2166 Unexpect aCatch(SALOME_SalomeException);
2167 MESSAGE( "GEOM_Gen_i::GetIGroupOperations" );
2169 GEOM::GEOM_Gen_ptr engine = _this();
2171 GEOM_IGroupOperations_i* aServant =
2172 new GEOM_IGroupOperations_i(_poa, engine, _impl->GetIGroupOperations(theStudyID));
2174 // activate the CORBA servant
2175 GEOM::GEOM_IGroupOperations_var operations = aServant->_this();
2176 return operations._retn();
2179 //============================================================================
2180 // function : GetIAdvancedOperations
2182 //============================================================================
2183 GEOM::GEOM_IAdvancedOperations_ptr GEOM_Gen_i::GetIAdvancedOperations(CORBA::Long theStudyID)
2184 throw ( SALOME::SALOME_Exception )
2186 Unexpect aCatch(SALOME_SalomeException);
2187 MESSAGE( "GEOM_Gen_i::GetIAdvancedOperations" );
2189 GEOM::GEOM_Gen_ptr engine = _this();
2191 GEOM_IAdvancedOperations_i* aServant =
2192 new GEOM_IAdvancedOperations_i(_poa, engine, _impl->GetIAdvancedOperations(theStudyID));
2194 // activate the CORBA servant
2195 GEOM::GEOM_IAdvancedOperations_var operations = aServant->_this();
2196 return operations._retn();
2199 //=============================================================================
2203 //=============================================================================
2204 GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
2205 const GEOM::ListOfLong& theIndices)
2207 if (CORBA::is_nil(theMainShape) || theIndices.length() < 1)
2208 return GEOM::GEOM_Object::_nil();
2209 CORBA::String_var entry = theMainShape->GetEntry();
2210 Handle(GEOM_Object) aMainsShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
2211 if (aMainsShape.IsNull()) return GEOM::GEOM_Object::_nil();
2213 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theIndices.length());
2214 for(Standard_Integer i = 0; i<theIndices.length(); i++) anArray->SetValue(i+1, theIndices[i]);
2216 Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainsShape, anArray, true);
2217 if(anObject.IsNull()) return GEOM::GEOM_Object::_nil();
2219 TCollection_AsciiString anEntry;
2220 TDF_Tool::Entry(anObject->GetEntry(), anEntry);
2221 return GetObject(anObject->GetDocID(), anEntry.ToCString());
2224 //=============================================================================
2228 //=============================================================================
2229 void GEOM_Gen_i::RemoveObject(GEOM::GEOM_Object_ptr theObject)
2231 CORBA::String_var anEntry = theObject->GetEntry();
2232 Handle(GEOM_Object) anObject = _impl->GetObject(theObject->GetStudyID(), anEntry, false);
2233 if (anObject.IsNull()) return;
2234 _impl->RemoveObject(anObject);
2239 //=================================================================================
2240 // function : GetStringFromIOR()
2241 // purpose : returns a string that represents a 'GEOM::GEOM_Object_var'
2242 //=================================================================================
2243 char* GEOM_Gen_i::GetStringFromIOR(GEOM::GEOM_Object_ptr theObject) {
2244 return _orb->object_to_string(theObject);
2248 //=================================================================================
2249 // function : GetIORFromString()
2250 // purpose : returns a 'GEOM::GEOM_Object_var' from a string representing it
2251 //=================================================================================
2252 GEOM::GEOM_Object_ptr GEOM_Gen_i::GetIORFromString(const char* stringIOR) {
2253 GEOM::GEOM_Object_var aGeomObject;
2254 if(strcmp(stringIOR,"") != 0){
2255 CORBA::Object_var anObject = _orb->string_to_object(stringIOR);
2256 if(!CORBA::is_nil(anObject))
2257 aGeomObject = GEOM::GEOM_Object::_narrow(anObject.in());
2259 return aGeomObject._retn();
2262 //=================================================================================
2263 // function : GetObject()
2265 //=================================================================================
2266 GEOM::GEOM_Object_ptr GEOM_Gen_i::GetObject (CORBA::Long theStudyID, const char* theEntry)
2268 GEOM::GEOM_Object_var obj;
2269 Handle(GEOM_Object) handle_object = _impl->GetObject(theStudyID, (char*)theEntry);
2270 if (handle_object.IsNull()) return obj._retn();
2272 TCollection_AsciiString stringIOR = handle_object->GetIOR();
2273 if (stringIOR.Length() > 1) {
2274 CORBA::Object_var corba_object = _orb->string_to_object(stringIOR.ToCString());
2275 if (!CORBA::is_nil(corba_object)) obj = GEOM::GEOM_Object::_narrow(corba_object);
2279 GEOM::GEOM_Gen_ptr engine = _this();
2280 //transfer the reference to GEOM_Object_i
2281 GEOM_Object_i* servant = new GEOM_Object_i (_poa, engine, handle_object);
2282 PortableServer::ObjectId_var id = _poa->activate_object(servant);
2284 obj = servant->_this();
2285 CORBA::String_var objStr = _orb->object_to_string(obj);
2286 TCollection_AsciiString anAscii( (char *)objStr.in() );
2287 handle_object->SetIOR( anAscii );
2291 //=================================================================================
2292 // function : hasObjectInfo()
2293 // purpose : shows if module provides information for its objects
2294 //=================================================================================
2295 bool GEOM_Gen_i::hasObjectInfo()
2300 //=================================================================================
2301 // function : getObjectInfo()
2302 // purpose : returns an information for a given object by its entry
2303 //=================================================================================
2304 char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry)
2306 GEOM::GEOM_Object_var aGeomObject;
2308 CORBA::Object_var aSMObject = name_service->Resolve( "/myStudyManager" );
2309 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
2310 SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId );
2311 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( entry );
2312 SALOMEDS::SObject_var aResultSObj;
2313 if (aSObj->ReferencedObject(aResultSObj))
2314 aSObj = aResultSObj;
2316 SALOMEDS::GenericAttribute_var anAttr;
2317 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
2318 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2319 CORBA::String_var aVal = anIOR->Value();
2321 CORBA::Object_var anObject = aStudy->ConvertIORToObject(aVal);
2322 aGeomObject = GEOM::GEOM_Object::_narrow(anObject);
2324 if (!aSObj->_is_nil() )
2327 const char* aTypeInfo = "Object";
2328 if ( !aGeomObject->_is_nil() ) {
2329 GEOM::GEOM_IKindOfShape::shape_kind aKind;
2330 GEOM::ListOfLong_var anInts;
2331 GEOM::ListOfDouble_var aDbls;
2333 GEOM::GEOM_IMeasureOperations_var anOp = GetIMeasureOperations( studyId );
2334 aKind = anOp->KindOfShape( aGeomObject, anInts, aDbls );
2336 if ( anOp->IsDone() ) {
2338 case GEOM::GEOM_IKindOfShape::COMPOUND:
2339 aTypeInfo = "Compound";
2341 case GEOM::GEOM_IKindOfShape::COMPSOLID:
2342 aTypeInfo = "CompSolid";
2344 case GEOM::GEOM_IKindOfShape::SHELL:
2345 aTypeInfo = "Shell";
2347 case GEOM::GEOM_IKindOfShape::WIRE:
2348 if ( anInts[0] == 1 )
2349 aTypeInfo = "Closed Wire";
2350 else if ( anInts[0] == 2 )
2351 aTypeInfo = "Opened Wire";
2356 case GEOM::GEOM_IKindOfShape::SPHERE:
2357 aTypeInfo = "Sphere";
2359 case GEOM::GEOM_IKindOfShape::CYLINDER:
2360 aTypeInfo = "Cylinder";
2362 case GEOM::GEOM_IKindOfShape::BOX:
2363 case GEOM::GEOM_IKindOfShape::ROTATED_BOX:
2366 case GEOM::GEOM_IKindOfShape::TORUS:
2367 aTypeInfo = "Torus";
2369 case GEOM::GEOM_IKindOfShape::CONE:
2372 case GEOM::GEOM_IKindOfShape::POLYHEDRON:
2373 aTypeInfo = "Polyhedron";
2375 case GEOM::GEOM_IKindOfShape::SOLID:
2376 aTypeInfo = "Solid";
2379 case GEOM::GEOM_IKindOfShape::SPHERE2D:
2380 aTypeInfo = "Spherical Face";
2382 case GEOM::GEOM_IKindOfShape::CYLINDER2D:
2383 aTypeInfo = "Cylindrical Face";
2385 case GEOM::GEOM_IKindOfShape::TORUS2D:
2386 aTypeInfo = "Toroidal Face";
2388 case GEOM::GEOM_IKindOfShape::CONE2D:
2389 aTypeInfo = "Conical Face";
2391 case GEOM::GEOM_IKindOfShape::DISK_CIRCLE:
2394 case GEOM::GEOM_IKindOfShape::DISK_ELLIPSE:
2395 aTypeInfo = "Elliptical Face";
2397 case GEOM::GEOM_IKindOfShape::POLYGON:
2398 aTypeInfo = "Polygon";
2400 case GEOM::GEOM_IKindOfShape::PLANE:
2401 aTypeInfo = "Plane";
2403 case GEOM::GEOM_IKindOfShape::PLANAR:
2404 aTypeInfo = "Planar Face";
2406 case GEOM::GEOM_IKindOfShape::FACE:
2410 case GEOM::GEOM_IKindOfShape::CIRCLE:
2411 aTypeInfo = "Circle";
2413 case GEOM::GEOM_IKindOfShape::ARC_CIRCLE:
2414 aTypeInfo = "Arc Circle";
2416 case GEOM::GEOM_IKindOfShape::ELLIPSE:
2417 aTypeInfo = "Ellipse";
2419 case GEOM::GEOM_IKindOfShape::ARC_ELLIPSE:
2420 aTypeInfo = "Arc Ellipse";
2422 case GEOM::GEOM_IKindOfShape::LINE:
2425 case GEOM::GEOM_IKindOfShape::SEGMENT:
2426 aTypeInfo = "Segment";
2428 case GEOM::GEOM_IKindOfShape::EDGE:
2431 case GEOM::GEOM_IKindOfShape::VERTEX:
2432 aTypeInfo = "Vertex";
2440 char* anInfo = new char[strlen("Module ") + strlen(ComponentDataType()) + strlen(", ") + strlen(aTypeInfo) + 3];
2441 sprintf(anInfo, "Module %s, %s", ComponentDataType(), aTypeInfo);
2443 char* ret = CORBA::string_dup(anInfo);
2448 //=====================================================================================
2450 //=====================================================================================
2455 PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB*, PortableServer::POA*, PortableServer::ObjectId*, const char*, const char*);
2459 PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB_ptr orb,
2460 PortableServer::POA_ptr poa,
2461 PortableServer::ObjectId* contId,
2462 const char* instanceName,
2463 const char* interfaceName)
2465 GEOM_Gen_i* myGEOM_Gen_i = new GEOM_Gen_i(orb, poa, contId, instanceName, interfaceName);
2466 return myGEOM_Gen_i->getId();