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 // BEGIN: 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->GetFunction(1)->GetNamingEntry();
283 // check all named shapes using iterator
284 TDF_ChildIDIterator anIt (aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
286 for (; anIt.More() && !HasName; anIt.Next()) {
287 Handle(TNaming_NamedShape) anAttr =
288 Handle(TNaming_NamedShape)::DownCast(anIt.Value());
289 if (anAttr.IsNull()) continue;
290 TopoDS_Shape S = anAttr->Get();
291 if (S.IsEqual(TopoSh)) {
292 TDF_Label L = anAttr->Label();
293 Handle(TDataStd_Name) aName;
294 if (L.FindAttribute(TDataStd_Name::GetID(), aName)) {
295 aShapeName = aName->Get();
300 // END: try to find existed name for current shape
303 // asv : 11.11.04 Introducing a more sofisticated method of name creation, just as
304 // it is done in GUI in GEOMBase::GetDefaultName() - not just add a Tag() == number
305 // of objects in the study, but compute a number of objects with the same prefix
306 // and build a new name as Prefix_N+1
307 if ( strlen( theName ) == 0 ) { // MOST PROBABLY CALLED FROM BATCHMODE OR SUPERVISOR
308 int i = 0; // (WITH EMPTY NEW NAME)
309 SALOMEDS::SObject_var obj;
310 TCollection_AsciiString aNewShapeName;
312 aNewShapeName = aShapeName + TCollection_AsciiString(++i);
313 obj = theStudy->FindObject( aNewShapeName.ToCString() );
315 while ( !obj->_is_nil() );
316 aShapeName = aNewShapeName;
318 else // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME)
319 aShapeName = TCollection_AsciiString((char*)theName);
322 //Set the study entry as a name of the published GEOM_Object
323 CORBA::String_var anID =aResultSO->GetID();
324 aShape->SetStudyEntry(anID.in());
326 //Set a name of the added shape
327 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
328 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
329 aNameAttrib->SetValue(aShapeName.ToCString());
330 aNameAttrib->Destroy();
332 //Set NoteBook variables used in the object creation
333 TCollection_AsciiString aVars;
334 CORBA::String_var aString=aShape->GetParameters();
335 SALOMEDS::ListOfListOfStrings_var aSections = theStudy->ParseVariables(aString);
336 for(int i = 0, n = aSections->length(); i < n; i++) {
337 SALOMEDS::ListOfStrings aListOfVars = aSections[i];
338 for(int j = 0, m = aListOfVars.length(); j < m; j++) {
339 if(theStudy->IsVariable(aListOfVars[j].in()))
340 aVars += TCollection_AsciiString(aListOfVars[j].in());
347 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeString");
348 SALOMEDS::AttributeString_var aStringAttrib = SALOMEDS::AttributeString::_narrow(anAttr);
349 aStringAttrib->SetValue(aVars.ToCString());
350 aStringAttrib->Destroy();
354 //Set a name of the GEOM object
355 aShape->SetName(theName);
357 return aResultSO._retn();
361 //============================================================================
362 // function : CreateAndPublishGroup
363 // purpose : auxilary for PublishNamedShapesInStudy
364 //============================================================================
365 void GEOM_Gen_i::CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
366 GEOM::GEOM_Object_var theMainShape,
367 const TopTools_IndexedMapOfShape& anIndices,
368 const TopTools_SequenceOfShape& SeqS,
369 const TColStd_SequenceOfAsciiString& SeqN,
370 const Standard_CString& GrName,
371 GEOM::ListOfGO_var aResList)
373 CORBA::String_var entry = theMainShape->GetEntry();
374 Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
375 Handle(TColStd_HArray1OfInteger) anArray;
376 if(SeqS.Length()>0) {
378 GEOM::GEOM_IGroupOperations_var GOp = GetIGroupOperations(theStudy->StudyId());
379 GEOM::GEOM_Object_ptr GrObj =
380 GOp->CreateGroup( theMainShape, SeqS.Value(1).ShapeType() );
381 AddInStudy(theStudy, GrObj, GrName, theMainShape._retn());
382 CORBA::String_var GrEntry = GrObj->GetEntry();
383 Handle(GEOM_Object) HGrObj = _impl->GetObject(GrObj->GetStudyID(), GrEntry);
385 //Handle(GEOM_Object) anObj;
386 for(int i=1; i<=SeqS.Length(); i++) {
387 TopoDS_Shape aValue = SeqS.Value(i);
388 //anArray = new TColStd_HArray1OfInteger(1,1);
389 Standard_Integer anIndex = anIndices.FindIndex(aValue);
390 //anArray->SetValue(1, anIndex);
391 GOp->AddObject(GrObj,anIndex);
392 //anObj = GEOM_Engine::GetEngine()->AddObject(aMainShape->GetDocID(), GEOM_SUBSHAPE);
393 //if (anObj.IsNull()) continue;
394 //Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
395 //if (aFunction.IsNull()) continue;
396 //GEOM_ISubShape aSSI(aFunction);
397 //aSSI.SetMainShape(aMainShape->GetLastFunction());
398 //aSSI.SetIndices(anArray);
399 //aFunction->SetValue(aValue);
400 //GOp->UnionIDs(GrObj, anIndex);
401 //SALOMEDS::SObject_var aResultSO;
402 //TCollection_AsciiString anEntry;
403 //TDF_Tool::Entry(anObj->GetEntry(),anEntry);
404 //GEOM::GEOM_Object_var aGObj = GetObject(anObj->GetDocID(), anEntry.ToCString());
405 //AddInStudy(theStudy, aGObj._retn(), SeqN.Value(i).ToCString(), GrObj);
411 //============================================================================
412 // function : PublishNamedShapesInStudy
414 //============================================================================
415 GEOM::ListOfGO* GEOM_Gen_i::
416 PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
417 //SALOMEDS::SObject_ptr theSObject,
418 CORBA::Object_ptr theObject)
420 //Unexpect aCatch(SALOME_SalomeException);
421 GEOM::ListOfGO_var aResList = new GEOM::ListOfGO;
423 //CORBA::Object_var theObject = theSObject->GetObject();
424 GEOM::GEOM_Object_var theMainShape = GEOM::GEOM_Object::_narrow(theObject);
425 if(theMainShape->_is_nil()) return aResList._retn();
427 CORBA::String_var entry = theMainShape->GetEntry();
428 Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
429 if (aMainShape.IsNull()) return aResList._retn();
430 TopoDS_Shape MainSh = aMainShape->GetValue();
432 TDF_Label aMainLbl = aMainShape->GetEntry();
433 TopTools_SequenceOfShape SolidSeqS, FaceSeqS, EdgeSeqS, VertSeqS;
434 TColStd_SequenceOfAsciiString SolidSeqN, FaceSeqN, EdgeSeqN, VertSeqN;
435 TDF_ChildIDIterator anIt(aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
436 for(; anIt.More(); anIt.Next()) {
437 Handle(TNaming_NamedShape) anAttr =
438 Handle(TNaming_NamedShape)::DownCast(anIt.Value());
439 if(anAttr.IsNull()) continue;
440 TopoDS_Shape S = anAttr->Get();
441 TDF_Label L = anAttr->Label();
442 //if(S.IsEqual(MainSh)) continue;
443 Handle(TDataStd_Name) aName;
444 if(L.FindAttribute(TDataStd_Name::GetID(),aName)) {
445 TCollection_ExtendedString EName = aName->Get();
446 if(S.ShapeType()==TopAbs_SOLID) {
448 SolidSeqN.Append(aName->Get());
450 else if(S.ShapeType()==TopAbs_FACE) {
452 FaceSeqN.Append(aName->Get());
454 else if(S.ShapeType()==TopAbs_EDGE) {
456 EdgeSeqN.Append(aName->Get());
458 else if(S.ShapeType()==TopAbs_VERTEX) {
460 VertSeqN.Append(aName->Get());
465 TopTools_IndexedMapOfShape anIndices;
466 TopExp::MapShapes(MainSh, anIndices);
468 CreateAndPublishGroup(theStudy, theMainShape, anIndices, SolidSeqS, SolidSeqN,
469 "Group_Of_Named_Solids", aResList);
471 CreateAndPublishGroup(theStudy, theMainShape, anIndices, FaceSeqS, FaceSeqN,
472 "Group_Of_Named_Faces", aResList);
474 CreateAndPublishGroup(theStudy, theMainShape, anIndices, EdgeSeqS, EdgeSeqN,
475 "Group_Of_Named_Edges", aResList);
477 CreateAndPublishGroup(theStudy, theMainShape, anIndices, VertSeqS, VertSeqN,
478 "Group_Of_Named_Vertices", aResList);
480 return aResList._retn();
484 //============================================================================
486 // purpose : save OCAF/Geom document
487 //============================================================================
488 SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
491 SALOMEDS::TMPFile_var aStreamFile;
492 // Get a temporary directory to store a file
493 std::string aTmpDir = (isMultiFile)?theURL:SALOMEDS_Tool::GetTmpDir();
495 // OCCT BUG: cannot save a document (in current folder)
496 // if directory name is empty
497 if (aTmpDir.size() == 0) {
505 // Create a list to store names of created files
506 SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
508 // Prepare a file name to open
509 TCollection_AsciiString aNameWithExt("");
511 aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath
512 (theComponent->GetStudy()->URL())).c_str());
513 aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
514 aSeq[0] = CORBA::string_dup(aNameWithExt.ToCString());
515 // Build a full file name of temporary file
516 TCollection_AsciiString aFullName = TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt;
517 // Save GEOM component in this file
518 _impl->Save(theComponent->GetStudy()->StudyId(),(char*) aFullName.ToCString());
519 // Conver a file to the byte stream
520 aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile);
521 // Remove the created file and tmp directory
522 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
524 // Return the created byte stream
525 return aStreamFile._retn();
529 //============================================================================
530 // function : SaveASCII()
532 //============================================================================
533 SALOMEDS::TMPFile* GEOM_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
536 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
537 return aStreamFile._retn();
541 //============================================================================
544 //============================================================================
545 CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
546 const SALOMEDS::TMPFile& theStream,
550 if (theStream.length() <= 9) {
551 MESSAGE("The TMPFile is too short : " << theStream.length() << " bytes ");
555 // Get a temporary directory for a file
556 std::string aTmpDir = isMultiFile?theURL:SALOMEDS_Tool::GetTmpDir();
558 // OCCT BUG: cannot load a document (from current folder)
559 // if directory name is empty
560 if (aTmpDir.size() == 0) {
568 // Conver the byte stream theStream to a file and place it in tmp directory
569 SALOMEDS::ListOfFileNames_var aSeq =
570 SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.c_str(), isMultiFile);
572 // Prepare a file name to open
573 TCollection_AsciiString aNameWithExt("");
575 aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath
576 (theComponent->GetStudy()->URL())).c_str());
577 aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
578 TCollection_AsciiString aFullName = (TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt);
581 if (!_impl->Load(theComponent->GetStudy()->StudyId(),(char*) aFullName.ToCString())) return false;
583 // Remove the created file and tmp directory
584 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
586 SALOMEDS::Study_var Study = theComponent->GetStudy();
587 TCollection_AsciiString name (Study->Name());
593 //============================================================================
594 // function : LoadASCII()
596 //============================================================================
597 CORBA::Boolean GEOM_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
598 const SALOMEDS::TMPFile& theStream,
601 return Load(theComponent, theStream, theURL, isMultiFile);
605 //============================================================================
606 // function : Close()
608 //============================================================================
609 void GEOM_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
611 SALOMEDS::Study_var aStudy= theComponent->GetStudy();
612 _impl->Close(aStudy->StudyId());
615 //============================================================================
616 // function : CanCopy()
618 //============================================================================
619 CORBA::Boolean GEOM_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
620 // Try to retrieve known by Geometry component GEOM_Object by given IOR
621 SALOMEDS::GenericAttribute_var anAttr;
622 if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false;
624 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
626 CORBA::String_var aString=anIOR->Value();
628 CORBA::Object_var anObj = _orb->string_to_object(aString);
629 GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(anObj);
630 // If the object is null one it can't be copied: return false
631 if (anObject->_is_nil()) return false;
635 //============================================================================
636 // function : CopyFrom()
638 //============================================================================
639 SALOMEDS::TMPFile* GEOM_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID)
641 // Declare a sequence of the byte to store the copied object
642 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
644 // Try to get GEOM_Object object by given SObject
645 SALOMEDS::GenericAttribute_var anAttr;
646 if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return aStreamFile._retn();
647 GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow
648 (_orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()));
649 if (anObject->_is_nil()) return aStreamFile._retn();
651 aStreamFile = anObject->GetShapeStream();
653 // Assign an ID the type of GEOM_Object
654 theObjectID = anObject->GetType();
656 // Return created TMPFile
657 return aStreamFile._retn();
660 //============================================================================
661 // function : CanPaste()
663 //============================================================================
664 CORBA::Boolean GEOM_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
665 // The Geometry component can paste only objects copied by Geometry component
666 // and with the object type = 1
667 if (strcmp(theComponentName, ComponentDataType()) != 0) return false;
671 //============================================================================
672 // function : PasteInto()
674 //============================================================================
675 SALOMEDS::SObject_ptr GEOM_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
676 CORBA::Long theObjectID,
677 SALOMEDS::SObject_ptr theObject) {
678 // Find the current Study and StudyBuilder
679 SALOMEDS::Study_var aStudy = theObject->GetStudy();
680 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
682 // Retrieve a TopoDS_Shape from byte stream
683 TopoDS_Shape aTopology;
684 std::istringstream aStreamedBrep((char*) &theStream[0]);
685 BRep_Builder aBuilder;
687 BRepTools::Read(aTopology, aStreamedBrep, aBuilder);
688 } catch (Standard_Failure) {
692 // SObject of the created shape is theObject or new Child of Component if theObject == geom component
693 SALOMEDS::SObject_var aNewSO;
694 if (strcmp(theObject->GetFatherComponent()->GetID(),theObject->GetID()) == 0) {
695 aNewSO = aStudyBuilder->NewObject(theObject);
696 } else aNewSO = SALOMEDS::SObject::_duplicate(theObject);
699 //Create a new GEOM_Object
700 Handle(GEOM_Object) anObj = _impl->AddObject(aNewSO->GetStudy()->StudyId(), theObjectID);
701 Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF);
702 aFunction->SetValue(aTopology);
704 TCollection_AsciiString anEntry;
705 TDF_Tool::Entry(anObj->GetEntry(), anEntry);
706 GEOM::GEOM_Object_var obj = GetObject(anObj->GetDocID(), anEntry.ToCString());
708 //Set the study entry of the published GEOM_Object
709 obj->SetStudyEntry(aNewSO->GetID());
711 // Add IORAttribute to the Study and set IOR of the created GEOM_Object to it
712 SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSO, "AttributeIOR");
713 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
714 CORBA::String_var objStr = _orb->object_to_string(obj);
715 anIOR->SetValue(objStr.in());
718 // Return the created in the Study SObject
719 return aNewSO._retn();
722 //============================================================================
723 // function : ComponentDataType()
725 //============================================================================
726 char* GEOM_Gen_i::ComponentDataType()
728 return CORBA::string_dup("GEOM");
731 //============================================================================
732 // function : AddInStudy
734 //============================================================================
735 SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
736 GEOM::GEOM_Object_ptr theObject,
738 GEOM::GEOM_Object_ptr theFather)
740 SALOMEDS::SObject_var aResultSO;
741 if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO;
743 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
744 CORBA::String_var IOR;
746 if(!theFather->_is_nil()) {
747 IOR = _orb->object_to_string(theFather);
748 SALOMEDS::SObject_var aFatherSO = theStudy->FindObjectIOR(IOR.in());
749 if(aFatherSO->_is_nil()) return aResultSO._retn();
750 aResultSO = aStudyBuilder->NewObject(aFatherSO);
751 aFatherSO->Destroy();
752 //aStudyBuilder->Addreference(aResultSO, aResultSO);
755 aResultSO = PublishInStudy(theStudy, aResultSO, theObject, theName);
756 if(aResultSO->_is_nil()) return aResultSO._retn();
758 GEOM::ListOfGO_var aList = theObject->GetDependency();
759 Standard_Integer aLength = aList->length();
760 if(aLength < 1) return aResultSO._retn();
762 //Publish the arguments
763 for(Standard_Integer i = 0; i< aLength; i++) {
764 GEOM::GEOM_Object_var anObject = aList[i];
765 if(anObject->_is_nil()) continue;
766 IOR = _orb->object_to_string(anObject);
767 SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(IOR.in());
768 if(aSO->_is_nil()) continue;
769 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO);
770 aStudyBuilder->Addreference(aSubSO, aSO);
775 return aResultSO._retn();
778 //============================================================================
779 // function : RestoreSubShapesO
780 // purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
781 // To be used from python scripts out of geompy.addToStudy (non-default usage)
782 //============================================================================
783 GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
784 GEOM::GEOM_Object_ptr theObject,
785 const GEOM::ListOfGO& theArgs,
786 GEOM::find_shape_method theFindMethod,
787 CORBA::Boolean theInheritFirstArg,
788 CORBA::Boolean theAddPrefix)
790 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
791 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject))
792 return aParts._retn();
794 // find SObject in the study if it is already published
795 CORBA::String_var anIORo = _orb->object_to_string(theObject);
796 SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(anIORo.in());
797 //PTv, IMP 0020001, The salome object <aSO>
798 // is not obligatory in case of invokation from script
799 // if (CORBA::is_nil(aSO))
800 // return aParts._retn();
802 aParts = RestoreSubShapes(theStudy, theObject, aSO, theArgs,
803 theFindMethod, theInheritFirstArg, theAddPrefix);
804 if (!CORBA::is_nil(aSO)) aSO->Destroy();
805 return aParts._retn();
808 //============================================================================
809 // function : RestoreGivenSubShapesO
810 // purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
811 // To be used from python scripts, generated by Dump Python.
812 //============================================================================
813 GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesO (SALOMEDS::Study_ptr theStudy,
814 GEOM::GEOM_Object_ptr theObject,
815 const GEOM::ListOfGO& theArgs,
816 GEOM::find_shape_method theFindMethod,
817 CORBA::Boolean theInheritFirstArg,
818 CORBA::Boolean theAddPrefix)
820 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
821 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject))
822 return aParts._retn();
824 // find SObject in the study if it is already published
825 CORBA::String_var anIORo = _orb->object_to_string(theObject);
826 SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(anIORo.in());
827 //PTv, IMP 0020001, The salome object <aSO>
828 // is not obligatory in case of invokation from script
829 // if (CORBA::is_nil(aSO))
830 // return aParts._retn();
832 aParts = RestoreGivenSubShapes(theStudy, theObject, aSO, theArgs,
833 theFindMethod, theInheritFirstArg, theAddPrefix);
834 if (!CORBA::is_nil(aSO)) aSO->Destroy();
835 return aParts._retn();
838 //============================================================================
839 // function : RestoreSubShapesSO
840 // purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
841 // To be used from GUI and from geompy.addToStudy
842 //============================================================================
843 GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
844 SALOMEDS::SObject_ptr theSObject,
845 const GEOM::ListOfGO& theArgs,
846 GEOM::find_shape_method theFindMethod,
847 CORBA::Boolean theInheritFirstArg,
848 CORBA::Boolean theAddPrefix)
850 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
851 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theSObject))
852 return aParts._retn();
854 SALOMEDS::GenericAttribute_var anAttr;
855 if (!theSObject->FindAttribute(anAttr, "AttributeIOR"))
856 return aParts._retn();
858 SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
859 CORBA::String_var anIORso = anAttrIOR->Value();
861 // get Object from SObject
862 GEOM::GEOM_Object_var anO = GEOM::GEOM_Object::_narrow(_orb->string_to_object(anIORso));
863 if (CORBA::is_nil(anO))
864 return aParts._retn();
866 aParts = RestoreSubShapes(theStudy, anO, theSObject, theArgs,
867 theFindMethod, theInheritFirstArg, theAddPrefix);
868 return aParts._retn();
871 //============================================================================
872 // function : addToListOfGO
873 // purpose : static local function
874 //============================================================================
875 static void addToListOfGO( GEOM::GEOM_Object_ptr theObject,
876 GEOM::ListOfGO& theList )
878 const int oldLen = theList.length();
879 theList.length(oldLen + 1);
880 theList[ oldLen ] = GEOM::GEOM_Object::_duplicate( theObject );
883 //============================================================================
884 // function : addToListOfGO
885 // purpose : static local function
886 //============================================================================
887 static void addToListOfGO( const GEOM::ListOfGO& theSrcList,
888 GEOM::ListOfGO& theTrgList )
890 const int oldLen = theTrgList.length();
891 const int srcLen = theSrcList.length();
892 theTrgList.length(oldLen + srcLen);
893 for( int i = 0; i < srcLen; i++ )
894 theTrgList[ oldLen + i ] = GEOM::GEOM_Object::_duplicate( theSrcList[ i ] );
897 //============================================================================
898 // function : RestoreSubShapes
899 // purpose : Private method. Works only if both theObject and theSObject
900 // are defined, and does not check, if they correspond to each other.
901 //============================================================================
902 GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy,
903 GEOM::GEOM_Object_ptr theObject,
904 SALOMEDS::SObject_ptr theSObject,
905 const GEOM::ListOfGO& theArgs,
906 GEOM::find_shape_method theFindMethod,
907 CORBA::Boolean theInheritFirstArg,
908 CORBA::Boolean theAddPrefix)
910 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
911 //PTv, IMP 0020001, The salome object <theSObject>
912 // is not obligatory in case of invokation from script
913 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject) /*|| CORBA::is_nil(theSObject)*/)
914 return aParts._retn();
916 // For Dump Python (mantis issue 0020768)
917 GEOM::ListOfGO_var anOutArgs = new GEOM::ListOfGO;
919 // Arguments to be published
920 GEOM::ListOfGO_var aList;
922 // If theArgs list is empty, we try to publish all arguments,
923 // otherwise publish only passed args
924 Standard_Integer nbArgsActual = -1; // -1 means unknown
925 Standard_Integer aLength = theArgs.length();
927 aList = new GEOM::ListOfGO;
928 aList->length(aLength);
929 for (int i = 0; i < aLength; i++) {
930 aList[i] = GEOM::GEOM_Object::_duplicate( theArgs[i] );
935 aList = theObject->GetDependency();
936 aLength = aList->length();
937 nbArgsActual = aLength;
941 return aParts._retn();
943 if (theInheritFirstArg || (nbArgsActual == 1)) {
944 // Do not publish argument's reflection,
945 // but only reconstruct its published sub-shapes
947 CORBA::String_var anIOR = _orb->object_to_string(aList[0]);
948 SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
950 // remember restored objects for Python Dump
951 addToListOfGO(aList[0], anOutArgs);
953 aParts = RestoreSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject,
954 anOutArgs, theFindMethod, theAddPrefix);
956 // set the color of the transformed shape to the color of initial shape
957 theObject->SetColor(aList[0]->GetColor());
959 if (theObject->GetShapeType() == GEOM::VERTEX) {
960 theObject->SetMarkerStd(aList[0]->GetMarkerType(), aList[0]->GetMarkerSize());
961 if (aList[0]->GetMarkerType() == GEOM::MT_USER)
962 theObject->SetMarkerTexture(aList[0]->GetMarkerTexture());
968 // Get interface, containing method, which we will use to reconstruct sub-shapes
969 GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
970 GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
972 // Reconstruct arguments and tree of sub-shapes of the arguments
973 CORBA::String_var anIOR;
974 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
975 for (Standard_Integer i = 0; i < aLength; i++)
977 GEOM::GEOM_Object_var anArgO = aList[i];
978 if (!CORBA::is_nil(anArgO)) {
979 anIOR = _orb->object_to_string(anArgO);
980 SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
981 TCollection_AsciiString anArgName;
982 if (CORBA::is_nil(anArgSO)) {
984 anArgName += TCollection_AsciiString(i);
987 anArgName = anArgSO->GetName();
990 // Find a sub-shape of theObject in place of the argument
991 GEOM::GEOM_Object_var aSubO;
992 switch (theFindMethod) {
993 case GEOM::FSM_GetInPlace:
996 aSubO = aShapesOp->GetInPlace(theObject, anArgO);
999 case GEOM::FSM_Transformed:
1001 // transformation, cannot use GetInPlace, operate with indices
1002 GEOM::ListOfLong_var anIDs = anArgO->GetSubShapeIndices();
1003 if (anIDs->length() > 1) {
1005 aSubO = aGroupOp->CreateGroup(theObject, aGroupOp->GetType(anArgO));
1006 if (!CORBA::is_nil(aSubO))
1007 aGroupOp->UnionIDs(aSubO, anIDs);
1009 else if (anIDs->length() > 0) {
1011 aSubO = aShapesOp->GetSubShape(theObject, anIDs[0]);
1015 case GEOM::FSM_GetSame:
1018 aSubO = aShapesOp->GetSame(theObject, anArgO);
1021 case GEOM::FSM_GetShapesOnShape:
1023 // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
1024 aSubO = aShapesOp->GetShapesOnShapeAsCompound(anArgO, theObject,
1025 (short)GEOM::SOLID, GEOM::ST_ONIN);
1028 case GEOM::FSM_GetInPlaceByHistory:
1030 // Use GetInPlaceByHistory
1031 aSubO = aShapesOp->GetInPlaceByHistory(theObject, anArgO);
1038 if (!CORBA::is_nil(aSubO)) {
1039 // remember restored objects for Python Dump
1040 addToListOfGO(anArgO, anOutArgs);
1042 // add to parts list
1043 addToListOfGO( aSubO, aParts );
1045 // Publish the sub-shape
1046 SALOMEDS::SObject_var aSubSO;
1047 if (!CORBA::is_nil(theSObject)) {
1048 TCollection_AsciiString aSubName;
1052 aSubName += anArgName;
1053 aSubSO = aStudyBuilder->NewObject(theSObject);
1054 aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
1056 aSubO->SetColor(anArgO->GetColor());
1058 if (aSubO->GetShapeType() == GEOM::VERTEX) {
1059 aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
1060 if (anArgO->GetMarkerType() == GEOM::MT_USER)
1061 aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
1065 if (!CORBA::is_nil(anArgSO)) {
1066 // Restore published sub-shapes of the argument
1067 GEOM::ListOfGO_var aSubParts;
1068 if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
1069 // pass theObject, because only it has the history
1070 aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1071 theObject, anOutArgs, theFindMethod, theAddPrefix);
1073 aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1074 aSubO, anOutArgs, theFindMethod, theAddPrefix);
1075 // add to parts list
1076 addToListOfGO( aSubParts, aParts );
1079 else { // GetInPlace failed, try to build from published parts
1080 if (!CORBA::is_nil(anArgSO)) {
1081 SALOMEDS::SObject_var aSubSO;
1082 if (!CORBA::is_nil(theSObject))
1083 aSubSO = aStudyBuilder->NewObject(theSObject);
1085 // Restore published sub-shapes of the argument
1086 GEOM::ListOfGO_var aSubParts =
1087 RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1088 theObject, anOutArgs, theFindMethod, theAddPrefix);
1090 // add to parts list
1091 addToListOfGO( aSubParts, aParts );
1093 if (aSubParts->length() > 0) {
1094 // remember restored objects for Python Dump
1095 addToListOfGO(anArgO, anOutArgs);
1097 // try to build an argument from a set of its sub-shapes,
1098 // that published and will be reconstructed
1099 if (aSubParts->length() > 1) {
1100 aSubO = aShapesOp->MakeCompound(aSubParts);
1101 // add to parts list
1102 addToListOfGO( aSubO, aParts );
1105 aSubO = aSubParts[0];
1107 if (!CORBA::is_nil(aSubO) && !CORBA::is_nil(aSubSO)) {
1108 // Publish the sub-shape
1109 TCollection_AsciiString aSubName;
1111 aSubName = "from_parts_of_";
1113 aSubName += anArgName;
1114 aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
1116 aSubO->SetColor(anArgO->GetColor());
1118 if (aSubO->GetShapeType() == GEOM::VERTEX) {
1119 aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
1120 if (anArgO->GetMarkerType() == GEOM::MT_USER)
1121 aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
1125 else if (!CORBA::is_nil(aSubSO)) {
1126 // remove created aSubSO, because no parts have been found
1127 aStudyBuilder->RemoveObject(aSubSO);
1130 } // try to build from published parts
1133 } // process arguments
1135 std::set<std::string> anObjEntryMap;
1136 GEOM::ListOfGO_var aResParts = new GEOM::ListOfGO;
1138 int nb = aParts->length();
1139 aResParts->length(nb);
1142 Handle(GEOM_Object) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
1143 Handle(GEOM_Function) aFunction = aMainObj->GetLastFunction();
1144 GEOM::TPythonDump pd (aFunction, true);
1147 for ( ; i < nb; i++ )
1149 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_duplicate( aParts[ i ] );
1150 if (CORBA::is_nil(anObj))
1152 char* anEntry = anObj->GetEntry();
1153 if (anObjEntryMap.count(anEntry))
1154 continue; // already treated
1155 anObjEntryMap.insert(anEntry);
1156 aResParts[nbRes++] = anObj;
1157 // clear python dump of object
1158 Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
1159 Handle(GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
1160 if ( !anObjFun.IsNull() )
1161 anObjFun->SetDescription( "" );
1167 pd <<"]" << " = geompy.RestoreGivenSubShapes(" << aMainObj << ", " << "[";
1168 //i = 0; nb = theArgs.length(); j = 0;
1169 i = 0; nb = anOutArgs->length(); j = 0;
1170 for ( ; i < nb; i++ )
1172 //GEOM::GEOM_Object_var anObj = theArgs[ i ];
1173 GEOM::GEOM_Object_var anObj = anOutArgs[ i ];
1174 if (CORBA::is_nil(anObj))
1176 Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
1182 pd <<"]" << ", " <<"geompy.GEOM.";
1183 switch (theFindMethod) {
1184 case GEOM::FSM_GetInPlace:
1185 pd << "FSM_GetInPlace"; break;
1186 case GEOM::FSM_Transformed:
1187 pd << "FSM_Transformed"; break;
1188 case GEOM::FSM_GetSame:
1189 pd << "FSM_GetSame"; break;
1190 case GEOM::FSM_GetShapesOnShape:
1191 pd << "FSM_GetShapesOnShape"; break;
1192 case GEOM::FSM_GetInPlaceByHistory:
1194 pd << "FSM_GetInPlaceByHistory"; break;
1196 pd << ", " << theInheritFirstArg << ", " << theAddPrefix << ")";
1198 aResParts->length(nbRes);
1199 return aResParts._retn();
1202 //============================================================================
1203 // function : RestoreSubShapesOneLevel
1204 // purpose : Private method
1205 //============================================================================
1206 GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
1207 SALOMEDS::SObject_ptr theOldSO,
1208 SALOMEDS::SObject_ptr theNewSO,
1209 GEOM::GEOM_Object_ptr theNewO,
1210 GEOM::ListOfGO& theOutArgs,
1211 GEOM::find_shape_method theFindMethod,
1212 CORBA::Boolean theAddPrefix)
1215 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
1216 GEOM::ListOfGO_var aNewParts = new GEOM::ListOfGO;
1217 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theOldSO) ||
1218 CORBA::is_nil(theNewO) /*|| CORBA::is_nil(theNewSO)*/)
1219 return aParts._retn();
1221 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
1223 // Get interface, containing method, which we will use to reconstruct sub-shapes
1224 GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
1225 GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
1227 // Reconstruct published sub-shapes
1228 SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO);
1231 for (it->Init(); it->More(); it->Next()) {
1234 aParts->length(aLen);
1236 for (it->Init(); it->More(); it->Next()) {
1237 SALOMEDS::SObject_var anOldSubSO = it->Value();
1239 TCollection_AsciiString anArgName = anOldSubSO->GetName();
1241 SALOMEDS::GenericAttribute_var anAttr;
1242 if (anOldSubSO->FindAttribute(anAttr, "AttributeIOR")) {
1243 SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1244 GEOM::GEOM_Object_var anOldSubO =
1245 GEOM::GEOM_Object::_narrow(_orb->string_to_object(anAttrIOR->Value()));
1246 if (!CORBA::is_nil(anOldSubO)) {
1247 // Find a sub-shape of theNewO in place of anOldSubO
1248 GEOM::GEOM_Object_var aNewSubO;
1249 switch (theFindMethod) {
1250 case GEOM::FSM_GetInPlace:
1253 aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO);
1256 case GEOM::FSM_Transformed:
1258 // transformation, cannot use GetInPlace, operate with indices
1259 GEOM::ListOfLong_var anIDs = anOldSubO->GetSubShapeIndices();
1260 if (anIDs->length() > 1) {
1262 aNewSubO = aGroupOp->CreateGroup(theNewO, aGroupOp->GetType(anOldSubO));
1263 if (!CORBA::is_nil(aNewSubO))
1264 aGroupOp->UnionIDs(aNewSubO, anIDs);
1268 aNewSubO = aShapesOp->GetSubShape(theNewO, anIDs[0]);
1272 case GEOM::FSM_GetSame:
1275 aNewSubO = aShapesOp->GetSame(theNewO, anOldSubO);
1278 case GEOM::FSM_GetShapesOnShape:
1280 // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
1281 aNewSubO = aShapesOp->GetShapesOnShapeAsCompound(anOldSubO, theNewO,
1282 (short)GEOM::SOLID, GEOM::ST_ONIN);
1285 case GEOM::FSM_GetInPlaceByHistory:
1287 // Use GetInPlaceByHistory
1288 aNewSubO = aShapesOp->GetInPlaceByHistory(theNewO, anOldSubO);
1295 if (!CORBA::is_nil(aNewSubO)) {
1296 // remember restored objects for Python Dump
1297 addToListOfGO(anOldSubO, theOutArgs);
1299 // add the part to the list
1300 aParts[i] = aNewSubO;
1302 // add to parts list
1303 addToListOfGO( aNewSubO, aNewParts );
1305 SALOMEDS::SObject_var aNewSubSO;
1306 if (!CORBA::is_nil(theNewSO)) {
1307 // Publish the sub-shape
1308 TCollection_AsciiString aSubName;
1312 aSubName += anArgName;
1313 aNewSubSO = aStudyBuilder->NewObject(theNewSO);
1314 aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
1316 aNewSubO->SetColor(anOldSubO->GetColor());
1318 if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
1319 aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
1320 if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
1321 aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
1324 // Restore published sub-shapes of the argument
1325 GEOM::ListOfGO_var aSubParts;
1326 if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
1327 // pass the main shape as Object, because only it has the history
1328 aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1329 theNewO, theOutArgs, theFindMethod, theAddPrefix);
1331 aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1332 aNewSubO, theOutArgs, theFindMethod, theAddPrefix);
1333 // add to parts list
1334 addToListOfGO( aSubParts, aNewParts );
1336 else { // GetInPlace failed, try to build from published parts
1337 SALOMEDS::SObject_var aNewSubSO;
1338 if (!CORBA::is_nil(theNewSO))
1339 aNewSubSO = aStudyBuilder->NewObject(theNewSO);
1341 // Restore published sub-shapes of the argument
1342 GEOM::ListOfGO_var aSubParts =
1343 RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1344 theNewO, theOutArgs, theFindMethod, theAddPrefix);
1345 // add to parts list
1346 addToListOfGO( aSubParts, aNewParts );
1348 if (aSubParts->length() > 0) {
1349 // remember restored objects for Python Dump
1350 addToListOfGO(anOldSubO, theOutArgs);
1352 // try to build an object from a set of its sub-shapes,
1353 // that published and will be reconstructed
1354 if (aSubParts->length() > 1) {
1355 aNewSubO = aShapesOp->MakeCompound(aSubParts);
1356 // add to parts list
1357 addToListOfGO( aNewSubO, aNewParts );
1360 aNewSubO = aSubParts[0];
1363 if (!CORBA::is_nil(aNewSubO)) {
1364 // add the part to the list
1365 aSubParts[i] = aNewSubO;
1368 // Publish the sub-shape
1369 if (!CORBA::is_nil(aNewSubSO)) {
1370 TCollection_AsciiString aSubName;
1372 aSubName = "from_parts_of_";
1374 aSubName += anArgName;
1375 aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
1377 aNewSubO->SetColor(anOldSubO->GetColor());
1379 if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
1380 aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
1381 if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
1382 aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
1387 else if (!CORBA::is_nil(aNewSubSO)) {
1388 // remove created aSubSO, because no parts have been found
1389 aStudyBuilder->RemoveObject(aNewSubSO);
1391 } // try to build from published parts
1394 } // iterate on published sub-shapes
1397 // add to parts list
1398 addToListOfGO( aNewParts, aParts );
1399 return aParts._retn();
1402 //============================================================================
1403 // function : RestoreGivenSubShapes
1404 // purpose : Private method. Works only if both theObject and theSObject
1405 // are defined, and does not check, if they correspond to each other.
1406 // List theArgs in this case contains not only operation arguments,
1407 // but also all subshapes, which must be published.
1408 //============================================================================
1409 GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr theStudy,
1410 GEOM::GEOM_Object_ptr theObject,
1411 SALOMEDS::SObject_ptr theSObject,
1412 const GEOM::ListOfGO& theArgs,
1413 GEOM::find_shape_method theFindMethod,
1414 CORBA::Boolean theInheritFirstArg,
1415 CORBA::Boolean theAddPrefix)
1417 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
1418 //PTv, IMP 0020001, The salome object <theSObject>
1419 // is not obligatory in case of invokation from script
1420 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject) /*|| CORBA::is_nil(theSObject)*/)
1421 return aParts._retn();
1423 // If theArgs list is empty, nothing to do
1424 Standard_Integer aLength = theArgs.length();
1426 return aParts._retn();
1428 // Get all arguments
1429 GEOM::ListOfGO_var anOpArgsList = theObject->GetDependency();
1430 Standard_Integer nbArgsActual = anOpArgsList->length();
1432 // If anOpArgsList list is empty, nothing to do
1433 if (nbArgsActual == 0)
1434 return aParts._retn();
1436 // Entries of arguments and subshapes
1437 std::set<std::string> anArgs;
1438 for (int i = 0; i < aLength; i++) {
1439 CORBA::String_var anEntry = theArgs[i]->GetEntry();
1440 anArgs.insert(anEntry.in());
1443 // Arguments to be published
1444 // We try to publish all arguments, that are in theArgs list
1445 GEOM::ListOfGO_var aList = new GEOM::ListOfGO;
1446 aList->length(nbArgsActual);
1449 for (int j = 0; j < nbArgsActual; j++) {
1450 CORBA::String_var anEntry = anOpArgsList[j]->GetEntry();
1451 if (anArgs.count(anEntry.in())) {
1452 aList[k] = GEOM::GEOM_Object::_duplicate(anOpArgsList[j]);
1457 //aList->length(nbArgsActual);
1459 if (nbArgsActual < 1)
1460 return aParts._retn();
1462 if (theInheritFirstArg || (nbArgsActual == 1)) {
1463 // Do not publish argument's reflection,
1464 // but only reconstruct its published sub-shapes
1466 CORBA::String_var anIOR = _orb->object_to_string(aList[0]);
1467 SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
1469 aParts = RestoreGivenSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject,
1470 anArgs, theFindMethod, theAddPrefix);
1472 // set the color of the transformed shape to the color of initial shape
1473 theObject->SetColor(aList[0]->GetColor());
1475 if (theObject->GetShapeType() == GEOM::VERTEX) {
1476 theObject->SetMarkerStd(aList[0]->GetMarkerType(), aList[0]->GetMarkerSize());
1477 if (aList[0]->GetMarkerType() == GEOM::MT_USER)
1478 theObject->SetMarkerTexture(aList[0]->GetMarkerTexture());
1484 // Get interface, containing method, which we will use to reconstruct sub-shapes
1485 GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
1486 GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
1488 // Reconstruct arguments and tree of sub-shapes of the arguments
1489 CORBA::String_var anIOR;
1490 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
1491 for (Standard_Integer i = 0; i < nbArgsActual; i++)
1493 GEOM::GEOM_Object_var anArgO = aList[i];
1494 if (!CORBA::is_nil(anArgO)) {
1495 anIOR = _orb->object_to_string(anArgO);
1496 SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
1497 TCollection_AsciiString anArgName;
1498 if (CORBA::is_nil(anArgSO)) {
1500 anArgName += TCollection_AsciiString(i);
1503 anArgName = anArgSO->GetName();
1506 // Find a sub-shape of theObject in place of the argument
1507 GEOM::GEOM_Object_var aSubO;
1508 switch (theFindMethod) {
1509 case GEOM::FSM_GetInPlace:
1512 aSubO = aShapesOp->GetInPlace(theObject, anArgO);
1515 case GEOM::FSM_Transformed:
1517 // transformation, cannot use GetInPlace, operate with indices
1518 GEOM::ListOfLong_var anIDs = anArgO->GetSubShapeIndices();
1519 if (anIDs->length() > 1) {
1521 aSubO = aGroupOp->CreateGroup(theObject, aGroupOp->GetType(anArgO));
1522 if (!CORBA::is_nil(aSubO))
1523 aGroupOp->UnionIDs(aSubO, anIDs);
1525 else if (anIDs->length() > 0) {
1527 aSubO = aShapesOp->GetSubShape(theObject, anIDs[0]);
1531 case GEOM::FSM_GetSame:
1534 aSubO = aShapesOp->GetSame(theObject, anArgO);
1537 case GEOM::FSM_GetShapesOnShape:
1539 // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
1540 aSubO = aShapesOp->GetShapesOnShapeAsCompound(anArgO, theObject,
1541 (short)GEOM::SOLID, GEOM::ST_ONIN);
1544 case GEOM::FSM_GetInPlaceByHistory:
1546 // Use GetInPlaceByHistory
1547 aSubO = aShapesOp->GetInPlaceByHistory(theObject, anArgO);
1554 if (!CORBA::is_nil(aSubO)) {
1555 // add to parts list
1556 addToListOfGO( aSubO, aParts );
1558 // Publish the sub-shape
1559 SALOMEDS::SObject_var aSubSO;
1560 if (!CORBA::is_nil(theSObject)) {
1561 TCollection_AsciiString aSubName;
1565 aSubName += anArgName;
1566 aSubSO = aStudyBuilder->NewObject(theSObject);
1567 aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
1569 aSubO->SetColor(anArgO->GetColor());
1571 if (aSubO->GetShapeType() == GEOM::VERTEX) {
1572 aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
1573 if (anArgO->GetMarkerType() == GEOM::MT_USER)
1574 aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
1578 if (!CORBA::is_nil(anArgSO)) {
1579 // Restore published sub-shapes of the argument
1580 GEOM::ListOfGO_var aSubParts;
1581 if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
1582 // pass theObject, because only it has the history
1583 aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1584 theObject, anArgs, theFindMethod, theAddPrefix);
1586 aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1587 aSubO, anArgs, theFindMethod, theAddPrefix);
1588 // add to parts list
1589 addToListOfGO( aSubParts, aParts );
1592 else { // GetInPlace failed, try to build from published parts
1593 if (!CORBA::is_nil(anArgSO)) {
1594 SALOMEDS::SObject_var aSubSO;
1595 if (!CORBA::is_nil(theSObject))
1596 aSubSO = aStudyBuilder->NewObject(theSObject);
1598 // Restore published sub-shapes of the argument
1599 GEOM::ListOfGO_var aSubParts =
1600 RestoreGivenSubShapesOneLevel(theStudy, anArgSO, aSubSO,
1601 theObject, anArgs, theFindMethod, theAddPrefix);
1603 // add to parts list
1604 addToListOfGO( aSubParts, aParts );
1606 if (aSubParts->length() > 0) {
1607 // try to build an argument from a set of its sub-shapes,
1608 // that published and will be reconstructed
1609 if (aSubParts->length() > 1) {
1610 aSubO = aShapesOp->MakeCompound(aSubParts);
1611 // add to parts list
1612 addToListOfGO( aSubO, aParts );
1615 aSubO = aSubParts[0];
1617 if (!CORBA::is_nil(aSubO) && !CORBA::is_nil(aSubSO)) {
1618 // Publish the sub-shape
1619 TCollection_AsciiString aSubName;
1621 aSubName = "from_parts_of_";
1623 aSubName += anArgName;
1624 aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
1626 aSubO->SetColor(anArgO->GetColor());
1628 if (aSubO->GetShapeType() == GEOM::VERTEX) {
1629 aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
1630 if (anArgO->GetMarkerType() == GEOM::MT_USER)
1631 aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
1635 else if (!CORBA::is_nil(aSubSO)) {
1636 // remove created aSubSO, because no parts have been found
1637 aStudyBuilder->RemoveObject(aSubSO);
1640 } // try to build from published parts
1643 } // process arguments
1645 std::set<std::string> anObjEntryMap;
1646 GEOM::ListOfGO_var aResParts = new GEOM::ListOfGO;
1648 int nb = aParts->length();
1649 aResParts->length(nb);
1652 Handle(GEOM_Object) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry());
1653 Handle(GEOM_Function) aFunction = aMainObj->GetLastFunction();
1654 GEOM::TPythonDump pd (aFunction, true);
1657 for ( ; i < nb; i++ )
1659 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_duplicate( aParts[ i ] );
1660 if (CORBA::is_nil(anObj))
1662 char* anEntry = anObj->GetEntry();
1663 if (anObjEntryMap.count(anEntry))
1664 continue; // already treated
1665 anObjEntryMap.insert(anEntry);
1666 aResParts[nbRes++] = anObj;
1667 // clear python dump of object
1668 Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry);
1669 Handle(GEOM_Function) anObjFun = aGeomObj->GetLastFunction();
1670 if ( !anObjFun.IsNull() )
1671 anObjFun->SetDescription( "" );
1677 pd <<"]" << " = geompy.RestoreGivenSubShapes(" << aMainObj << ", " << "[";
1678 i = 0; nb = theArgs.length(); j = 0;
1679 for ( ; i < nb; i++ )
1681 GEOM::GEOM_Object_var anObj = theArgs[ i ];
1682 if (CORBA::is_nil(anObj))
1684 Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
1690 pd <<"]" << ", " <<"geompy.GEOM.";
1691 switch (theFindMethod) {
1692 case GEOM::FSM_GetInPlace:
1693 pd << "FSM_GetInPlace"; break;
1694 case GEOM::FSM_Transformed:
1695 pd << "FSM_Transformed"; break;
1696 case GEOM::FSM_GetSame:
1697 pd << "FSM_GetSame"; break;
1698 case GEOM::FSM_GetShapesOnShape:
1699 pd << "FSM_GetShapesOnShape"; break;
1700 case GEOM::FSM_GetInPlaceByHistory:
1702 pd << "FSM_GetInPlaceByHistory"; break;
1704 pd << ", " << theInheritFirstArg << ", " << theAddPrefix << ")";
1706 aResParts->length(nbRes);
1707 return aResParts._retn();
1710 //============================================================================
1711 // function : RestoreGivenSubShapesOneLevel
1712 // purpose : Private method
1713 //============================================================================
1714 GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
1715 SALOMEDS::SObject_ptr theOldSO,
1716 SALOMEDS::SObject_ptr theNewSO,
1717 GEOM::GEOM_Object_ptr theNewO,
1718 std::set<std::string> theArgs,
1719 GEOM::find_shape_method theFindMethod,
1720 CORBA::Boolean theAddPrefix)
1723 GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
1724 GEOM::ListOfGO_var aNewParts = new GEOM::ListOfGO;
1725 if (CORBA::is_nil(theStudy) || CORBA::is_nil(theOldSO) ||
1726 CORBA::is_nil(theNewO) /*|| CORBA::is_nil(theNewSO)*/)
1727 return aParts._retn();
1729 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
1731 // Get interface, containing method, which we will use to reconstruct sub-shapes
1732 GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
1733 GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
1735 // Reconstruct published sub-shapes
1736 SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO);
1739 for (it->Init(); it->More(); it->Next()) {
1742 aParts->length(aLen);
1744 for (it->Init(); it->More(); it->Next()) {
1745 SALOMEDS::SObject_var anOldSubSO = it->Value();
1747 TCollection_AsciiString anArgName = anOldSubSO->GetName();
1749 SALOMEDS::GenericAttribute_var anAttr;
1750 if (anOldSubSO->FindAttribute(anAttr, "AttributeIOR")) {
1751 SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1752 GEOM::GEOM_Object_var anOldSubO =
1753 GEOM::GEOM_Object::_narrow(_orb->string_to_object(anAttrIOR->Value()));
1755 bool okToContinue = false;
1757 if (!CORBA::is_nil(anOldSubO)) {
1758 CORBA::String_var anEntry = anOldSubO->GetEntry();
1759 okToContinue = theArgs.count(anEntry.in());
1763 // Find a sub-shape of theNewO in place of anOldSubO
1764 GEOM::GEOM_Object_var aNewSubO;
1765 switch (theFindMethod) {
1766 case GEOM::FSM_GetInPlace:
1769 aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO);
1772 case GEOM::FSM_Transformed:
1774 // transformation, cannot use GetInPlace, operate with indices
1775 GEOM::ListOfLong_var anIDs = anOldSubO->GetSubShapeIndices();
1776 if (anIDs->length() > 1) {
1778 aNewSubO = aGroupOp->CreateGroup(theNewO, aGroupOp->GetType(anOldSubO));
1779 if (!CORBA::is_nil(aNewSubO))
1780 aGroupOp->UnionIDs(aNewSubO, anIDs);
1784 aNewSubO = aShapesOp->GetSubShape(theNewO, anIDs[0]);
1788 case GEOM::FSM_GetSame:
1791 aNewSubO = aShapesOp->GetSame(theNewO, anOldSubO);
1794 case GEOM::FSM_GetShapesOnShape:
1796 // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
1797 aNewSubO = aShapesOp->GetShapesOnShapeAsCompound(anOldSubO, theNewO,
1798 (short)GEOM::SOLID, GEOM::ST_ONIN);
1801 case GEOM::FSM_GetInPlaceByHistory:
1803 // Use GetInPlaceByHistory
1804 aNewSubO = aShapesOp->GetInPlaceByHistory(theNewO, anOldSubO);
1811 if (!CORBA::is_nil(aNewSubO)) {
1812 // add the part to the list
1813 aParts[i] = aNewSubO;
1815 // add to parts list
1816 addToListOfGO( aNewSubO, aNewParts );
1818 SALOMEDS::SObject_var aNewSubSO;
1819 if (!CORBA::is_nil(theNewSO)) {
1820 // Publish the sub-shape
1821 TCollection_AsciiString aSubName;
1825 aSubName += anArgName;
1826 aNewSubSO = aStudyBuilder->NewObject(theNewSO);
1827 aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
1829 aNewSubO->SetColor(anOldSubO->GetColor());
1831 if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
1832 aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
1833 if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
1834 aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
1837 // Restore published sub-shapes of the argument
1838 GEOM::ListOfGO_var aSubParts;
1839 if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
1840 // pass the main shape as Object, because only it has the history
1841 aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1842 theNewO, theArgs, theFindMethod, theAddPrefix);
1844 aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1845 aNewSubO, theArgs, theFindMethod, theAddPrefix);
1846 // add to parts list
1847 addToListOfGO( aSubParts, aNewParts );
1849 else { // GetInPlace failed, try to build from published parts
1850 SALOMEDS::SObject_var aNewSubSO;
1851 if (!CORBA::is_nil(theNewSO))
1852 aNewSubSO = aStudyBuilder->NewObject(theNewSO);
1854 // Restore published sub-shapes of the argument
1855 GEOM::ListOfGO_var aSubParts =
1856 RestoreGivenSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
1857 theNewO, theArgs, theFindMethod, theAddPrefix);
1858 // add to parts list
1859 addToListOfGO( aSubParts, aNewParts );
1861 if (aSubParts->length() > 0) {
1862 // try to build an object from a set of its sub-shapes,
1863 // that published and will be reconstructed
1864 if (aSubParts->length() > 1) {
1865 aNewSubO = aShapesOp->MakeCompound(aSubParts);
1866 // add to parts list
1867 addToListOfGO( aNewSubO, aNewParts );
1870 aNewSubO = aSubParts[0];
1873 if (!CORBA::is_nil(aNewSubO)) {
1874 // add the part to the list
1875 aSubParts[i] = aNewSubO;
1878 // Publish the sub-shape
1879 if (!CORBA::is_nil(aNewSubSO)) {
1880 TCollection_AsciiString aSubName;
1882 aSubName = "from_parts_of_";
1884 aSubName += anArgName;
1885 aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
1887 aNewSubO->SetColor(anOldSubO->GetColor());
1889 if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
1890 aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
1891 if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
1892 aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
1897 else if (!CORBA::is_nil(aNewSubSO)) {
1898 // remove created aSubSO, because no parts have been found
1899 aStudyBuilder->RemoveObject(aNewSubSO);
1901 } // try to build from published parts
1904 } // iterate on published sub-shapes
1907 // add to parts list
1908 addToListOfGO( aNewParts, aParts );
1909 return aParts._retn();
1912 //============================================================================
1913 // function : register()
1914 // purpose : register 'name' in 'name_service'
1915 //============================================================================
1916 void GEOM_Gen_i::register_name(char * name)
1918 GEOM::GEOM_Gen_var g = _this();
1919 name_service->Register(g, name);
1922 //============================================================================
1925 //============================================================================
1926 void GEOM_Gen_i::Undo(CORBA::Long theStudyID)
1928 _impl->Undo(theStudyID);
1931 //============================================================================
1934 //============================================================================
1935 void GEOM_Gen_i::Redo(CORBA::Long theStudyID)
1937 _impl->Redo(theStudyID);
1940 //============================================================================
1941 // function : GetIBasicOperations
1943 //============================================================================
1944 GEOM::GEOM_IBasicOperations_ptr GEOM_Gen_i::GetIBasicOperations(CORBA::Long theStudyID)
1945 throw ( SALOME::SALOME_Exception )
1947 Unexpect aCatch(SALOME_SalomeException);
1948 MESSAGE( "GEOM_Gen_i::GetIBasicOperations" );
1950 GEOM::GEOM_Gen_ptr engine = _this();
1952 //transfer reference on engine
1953 GEOM_IBasicOperations_i* aServant =
1954 new GEOM_IBasicOperations_i(_poa, engine, _impl->GetIBasicOperations(theStudyID));
1956 PortableServer::ObjectId_var id = _poa->activate_object(aServant);
1957 // activate the CORBA servant
1958 GEOM::GEOM_IBasicOperations_var operations = aServant->_this();
1959 return operations._retn();
1962 //============================================================================
1963 // function : GetITransformOperations
1965 //============================================================================
1966 GEOM::GEOM_ITransformOperations_ptr GEOM_Gen_i::GetITransformOperations(CORBA::Long theStudyID)
1967 throw ( SALOME::SALOME_Exception )
1969 Unexpect aCatch(SALOME_SalomeException);
1970 MESSAGE( "GEOM_Gen_i::GetITransformOperations" );
1972 GEOM::GEOM_Gen_ptr engine = _this();
1974 GEOM_ITransformOperations_i* aServant =
1975 new GEOM_ITransformOperations_i(_poa, engine, _impl->GetITransformOperations(theStudyID));
1977 // activate the CORBA servant
1978 GEOM::GEOM_ITransformOperations_var operations = aServant->_this();
1979 return operations._retn();
1982 //============================================================================
1983 // function : GetI3DPrimOperations
1985 //============================================================================
1986 GEOM::GEOM_I3DPrimOperations_ptr GEOM_Gen_i::GetI3DPrimOperations(CORBA::Long theStudyID)
1987 throw ( SALOME::SALOME_Exception )
1989 Unexpect aCatch(SALOME_SalomeException);
1990 MESSAGE( "GEOM_Gen_i::GetI3DPrimOperations" );
1992 GEOM::GEOM_Gen_ptr engine = _this();
1994 GEOM_I3DPrimOperations_i* aServant =
1995 new GEOM_I3DPrimOperations_i(_poa, engine, _impl->GetI3DPrimOperations(theStudyID));
1996 PortableServer::ObjectId_var id = _poa->activate_object(aServant);
1998 // activate the CORBA servant
1999 GEOM::GEOM_I3DPrimOperations_var operations = aServant->_this();
2000 return operations._retn();
2003 //============================================================================
2004 // function : GetIShapesOperations
2006 //============================================================================
2007 GEOM::GEOM_IShapesOperations_ptr GEOM_Gen_i::GetIShapesOperations(CORBA::Long theStudyID)
2008 throw ( SALOME::SALOME_Exception )
2010 Unexpect aCatch(SALOME_SalomeException);
2011 MESSAGE( "GEOM_Gen_i::GetIShapesOperations" );
2013 GEOM::GEOM_Gen_ptr engine = _this();
2015 GEOM_IShapesOperations_i* aServant =
2016 new GEOM_IShapesOperations_i(_poa, engine, _impl->GetIShapesOperations(theStudyID));
2018 // activate the CORBA servant
2019 GEOM::GEOM_IShapesOperations_var operations = aServant->_this();
2020 return operations._retn();
2023 //============================================================================
2024 // function : GetIBlocksOperations
2026 //============================================================================
2027 GEOM::GEOM_IBlocksOperations_ptr GEOM_Gen_i::GetIBlocksOperations(CORBA::Long theStudyID)
2028 throw ( SALOME::SALOME_Exception )
2030 Unexpect aCatch(SALOME_SalomeException);
2031 MESSAGE( "GEOM_Gen_i::GetIBlocksOperations" );
2033 GEOM::GEOM_Gen_ptr engine = _this();
2035 GEOM_IBlocksOperations_i* aServant =
2036 new GEOM_IBlocksOperations_i(_poa, engine, _impl->GetIBlocksOperations(theStudyID));
2038 // activate the CORBA servant
2039 GEOM::GEOM_IBlocksOperations_var operations = aServant->_this();
2040 return operations._retn();
2043 //============================================================================
2044 // function : GetIBooleanOperations
2046 //============================================================================
2047 GEOM::GEOM_IBooleanOperations_ptr GEOM_Gen_i::GetIBooleanOperations(CORBA::Long theStudyID)
2048 throw ( SALOME::SALOME_Exception )
2050 Unexpect aCatch(SALOME_SalomeException);
2051 MESSAGE( "GEOM_Gen_i::GetIBooleanOperations" );
2053 GEOM::GEOM_Gen_ptr engine = _this();
2055 GEOM_IBooleanOperations_i* aServant =
2056 new GEOM_IBooleanOperations_i(_poa, engine, _impl->GetIBooleanOperations(theStudyID));
2058 // activate the CORBA servant
2059 GEOM::GEOM_IBooleanOperations_var operations = aServant->_this();
2060 return operations._retn();
2063 //============================================================================
2064 // function : GetICurvesOperations
2066 //============================================================================
2067 GEOM::GEOM_ICurvesOperations_ptr GEOM_Gen_i::GetICurvesOperations(CORBA::Long theStudyID)
2068 throw ( SALOME::SALOME_Exception )
2070 Unexpect aCatch(SALOME_SalomeException);
2071 MESSAGE( "GEOM_Gen_i::GetICurvesOperations" );
2073 GEOM::GEOM_Gen_ptr engine = _this();
2075 GEOM_ICurvesOperations_i* aServant =
2076 new GEOM_ICurvesOperations_i(_poa, engine, _impl->GetICurvesOperations(theStudyID));
2078 // activate the CORBA servant
2079 GEOM::GEOM_ICurvesOperations_var operations = aServant->_this();
2080 return operations._retn();
2083 //============================================================================
2084 // function : GetILocalOperations
2086 //============================================================================
2087 GEOM::GEOM_ILocalOperations_ptr GEOM_Gen_i::GetILocalOperations(CORBA::Long theStudyID)
2088 throw ( SALOME::SALOME_Exception )
2090 Unexpect aCatch(SALOME_SalomeException);
2091 MESSAGE( "GEOM_Gen_i::GetILocalOperations" );
2093 GEOM::GEOM_Gen_ptr engine = _this();
2095 GEOM_ILocalOperations_i* aServant =
2096 new GEOM_ILocalOperations_i(_poa, engine, _impl->GetILocalOperations(theStudyID));
2098 // activate the CORBA servant
2099 GEOM::GEOM_ILocalOperations_var operations = aServant->_this();
2100 return operations._retn();
2103 //============================================================================
2104 // function : GetIHealingOperations
2106 //============================================================================
2107 GEOM::GEOM_IHealingOperations_ptr GEOM_Gen_i::GetIHealingOperations(CORBA::Long theStudyID)
2108 throw ( SALOME::SALOME_Exception )
2110 Unexpect aCatch(SALOME_SalomeException);
2111 MESSAGE( "GEOM_Gen_i::IHealingOperations" );
2113 GEOM::GEOM_Gen_ptr engine = _this();
2115 GEOM_IHealingOperations_i* aServant =
2116 new GEOM_IHealingOperations_i(_poa, engine, _impl->GetIHealingOperations(theStudyID));
2118 // activate the CORBA servant
2119 GEOM::GEOM_IHealingOperations_var operations = aServant->_this();
2120 return operations._retn();
2123 //============================================================================
2124 // function : GetIInsertOperations
2126 //============================================================================
2127 GEOM::GEOM_IInsertOperations_ptr GEOM_Gen_i::GetIInsertOperations(CORBA::Long theStudyID)
2128 throw ( SALOME::SALOME_Exception )
2130 Unexpect aCatch(SALOME_SalomeException);
2131 MESSAGE( "GEOM_Gen_i::GetIInsertOperations" );
2133 GEOM::GEOM_Gen_ptr engine = _this();
2135 GEOM_IInsertOperations_i* aServant =
2136 new GEOM_IInsertOperations_i(_poa, engine, _impl->GetIInsertOperations(theStudyID));
2138 // activate the CORBA servant
2139 GEOM::GEOM_IInsertOperations_var operations = aServant->_this();
2140 return operations._retn();
2143 //============================================================================
2144 // function : GetIMeasureOperations
2146 //============================================================================
2147 GEOM::GEOM_IMeasureOperations_ptr GEOM_Gen_i::GetIMeasureOperations(CORBA::Long theStudyID)
2148 throw ( SALOME::SALOME_Exception )
2150 Unexpect aCatch(SALOME_SalomeException);
2151 MESSAGE( "GEOM_Gen_i::GetIMeasureOperations" );
2153 GEOM::GEOM_Gen_ptr engine = _this();
2155 GEOM_IMeasureOperations_i* aServant =
2156 new GEOM_IMeasureOperations_i(_poa, engine, _impl->GetIMeasureOperations(theStudyID));
2158 // activate the CORBA servant
2159 GEOM::GEOM_IMeasureOperations_var operations = aServant->_this();
2160 return operations._retn();
2163 //============================================================================
2164 // function : GetIGroupOperations
2166 //============================================================================
2167 GEOM::GEOM_IGroupOperations_ptr GEOM_Gen_i::GetIGroupOperations(CORBA::Long theStudyID)
2168 throw ( SALOME::SALOME_Exception )
2170 Unexpect aCatch(SALOME_SalomeException);
2171 MESSAGE( "GEOM_Gen_i::GetIGroupOperations" );
2173 GEOM::GEOM_Gen_ptr engine = _this();
2175 GEOM_IGroupOperations_i* aServant =
2176 new GEOM_IGroupOperations_i(_poa, engine, _impl->GetIGroupOperations(theStudyID));
2178 // activate the CORBA servant
2179 GEOM::GEOM_IGroupOperations_var operations = aServant->_this();
2180 return operations._retn();
2183 //============================================================================
2184 // function : GetIAdvancedOperations
2186 //============================================================================
2187 GEOM::GEOM_IAdvancedOperations_ptr GEOM_Gen_i::GetIAdvancedOperations(CORBA::Long theStudyID)
2188 throw ( SALOME::SALOME_Exception )
2190 Unexpect aCatch(SALOME_SalomeException);
2191 MESSAGE( "GEOM_Gen_i::GetIAdvancedOperations" );
2193 GEOM::GEOM_Gen_ptr engine = _this();
2195 GEOM_IAdvancedOperations_i* aServant =
2196 new GEOM_IAdvancedOperations_i(_poa, engine, _impl->GetIAdvancedOperations(theStudyID));
2198 // activate the CORBA servant
2199 GEOM::GEOM_IAdvancedOperations_var operations = aServant->_this();
2200 return operations._retn();
2203 //=============================================================================
2207 //=============================================================================
2208 GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
2209 const GEOM::ListOfLong& theIndices)
2211 if (CORBA::is_nil(theMainShape) || theIndices.length() < 1)
2212 return GEOM::GEOM_Object::_nil();
2213 CORBA::String_var entry = theMainShape->GetEntry();
2214 Handle(GEOM_Object) aMainsShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
2215 if (aMainsShape.IsNull()) return GEOM::GEOM_Object::_nil();
2217 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theIndices.length());
2218 for(Standard_Integer i = 0; i<theIndices.length(); i++) anArray->SetValue(i+1, theIndices[i]);
2220 Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainsShape, anArray, true);
2221 if(anObject.IsNull()) return GEOM::GEOM_Object::_nil();
2223 TCollection_AsciiString anEntry;
2224 TDF_Tool::Entry(anObject->GetEntry(), anEntry);
2225 return GetObject(anObject->GetDocID(), anEntry.ToCString());
2228 //=============================================================================
2232 //=============================================================================
2233 void GEOM_Gen_i::RemoveObject(GEOM::GEOM_Object_ptr theObject)
2235 CORBA::String_var anEntry = theObject->GetEntry();
2236 Handle(GEOM_Object) anObject = _impl->GetObject(theObject->GetStudyID(), anEntry, false);
2237 if (anObject.IsNull()) return;
2238 _impl->RemoveObject(anObject);
2243 //=================================================================================
2244 // function : GetStringFromIOR()
2245 // purpose : returns a string that represents a 'GEOM::GEOM_Object_var'
2246 //=================================================================================
2247 char* GEOM_Gen_i::GetStringFromIOR(GEOM::GEOM_Object_ptr theObject) {
2248 return _orb->object_to_string(theObject);
2252 //=================================================================================
2253 // function : GetIORFromString()
2254 // purpose : returns a 'GEOM::GEOM_Object_var' from a string representing it
2255 //=================================================================================
2256 GEOM::GEOM_Object_ptr GEOM_Gen_i::GetIORFromString(const char* stringIOR) {
2257 GEOM::GEOM_Object_var aGeomObject;
2258 if(strcmp(stringIOR,"") != 0){
2259 CORBA::Object_var anObject = _orb->string_to_object(stringIOR);
2260 if(!CORBA::is_nil(anObject))
2261 aGeomObject = GEOM::GEOM_Object::_narrow(anObject.in());
2263 return aGeomObject._retn();
2266 //=================================================================================
2267 // function : GetObject()
2269 //=================================================================================
2270 GEOM::GEOM_Object_ptr GEOM_Gen_i::GetObject (CORBA::Long theStudyID, const char* theEntry)
2272 GEOM::GEOM_Object_var obj;
2273 Handle(GEOM_Object) handle_object = _impl->GetObject(theStudyID, (char*)theEntry);
2274 if (handle_object.IsNull()) return obj._retn();
2276 TCollection_AsciiString stringIOR = handle_object->GetIOR();
2277 if (stringIOR.Length() > 1) {
2278 CORBA::Object_var corba_object = _orb->string_to_object(stringIOR.ToCString());
2279 if (!CORBA::is_nil(corba_object)) obj = GEOM::GEOM_Object::_narrow(corba_object);
2283 GEOM::GEOM_Gen_ptr engine = _this();
2284 //transfer the reference to GEOM_Object_i
2285 GEOM_Object_i* servant = new GEOM_Object_i (_poa, engine, handle_object);
2286 PortableServer::ObjectId_var id = _poa->activate_object(servant);
2288 obj = servant->_this();
2289 CORBA::String_var objStr = _orb->object_to_string(obj);
2290 TCollection_AsciiString anAscii( (char *)objStr.in() );
2291 handle_object->SetIOR( anAscii );
2295 //=================================================================================
2296 // function : hasObjectInfo()
2297 // purpose : shows if module provides information for its objects
2298 //=================================================================================
2299 bool GEOM_Gen_i::hasObjectInfo()
2304 //=================================================================================
2305 // function : getObjectInfo()
2306 // purpose : returns an information for a given object by its entry
2307 //=================================================================================
2308 char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry)
2310 GEOM::GEOM_Object_var aGeomObject;
2312 CORBA::Object_var aSMObject = name_service->Resolve( "/myStudyManager" );
2313 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
2314 SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId );
2315 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( entry );
2316 SALOMEDS::SObject_var aResultSObj;
2317 if (aSObj->ReferencedObject(aResultSObj))
2318 aSObj = aResultSObj;
2320 SALOMEDS::GenericAttribute_var anAttr;
2321 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
2322 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2323 CORBA::String_var aVal = anIOR->Value();
2325 CORBA::Object_var anObject = aStudy->ConvertIORToObject(aVal);
2326 aGeomObject = GEOM::GEOM_Object::_narrow(anObject);
2328 if (!aSObj->_is_nil() )
2331 const char* aTypeInfo = "Object";
2332 if ( !aGeomObject->_is_nil() ) {
2333 GEOM::GEOM_IKindOfShape::shape_kind aKind;
2334 GEOM::ListOfLong_var anInts;
2335 GEOM::ListOfDouble_var aDbls;
2337 GEOM::GEOM_IMeasureOperations_var anOp = GetIMeasureOperations( studyId );
2338 aKind = anOp->KindOfShape( aGeomObject, anInts, aDbls );
2340 if ( anOp->IsDone() ) {
2342 case GEOM::GEOM_IKindOfShape::COMPOUND:
2343 aTypeInfo = "Compound";
2345 case GEOM::GEOM_IKindOfShape::COMPSOLID:
2346 aTypeInfo = "CompSolid";
2348 case GEOM::GEOM_IKindOfShape::SHELL:
2349 aTypeInfo = "Shell";
2351 case GEOM::GEOM_IKindOfShape::WIRE:
2352 if ( anInts[0] == 1 )
2353 aTypeInfo = "Closed Wire";
2354 else if ( anInts[0] == 2 )
2355 aTypeInfo = "Opened Wire";
2360 case GEOM::GEOM_IKindOfShape::SPHERE:
2361 aTypeInfo = "Sphere";
2363 case GEOM::GEOM_IKindOfShape::CYLINDER:
2364 aTypeInfo = "Cylinder";
2366 case GEOM::GEOM_IKindOfShape::BOX:
2367 case GEOM::GEOM_IKindOfShape::ROTATED_BOX:
2370 case GEOM::GEOM_IKindOfShape::TORUS:
2371 aTypeInfo = "Torus";
2373 case GEOM::GEOM_IKindOfShape::CONE:
2376 case GEOM::GEOM_IKindOfShape::POLYHEDRON:
2377 aTypeInfo = "Polyhedron";
2379 case GEOM::GEOM_IKindOfShape::SOLID:
2380 aTypeInfo = "Solid";
2383 case GEOM::GEOM_IKindOfShape::SPHERE2D:
2384 aTypeInfo = "Spherical Face";
2386 case GEOM::GEOM_IKindOfShape::CYLINDER2D:
2387 aTypeInfo = "Cylindrical Face";
2389 case GEOM::GEOM_IKindOfShape::TORUS2D:
2390 aTypeInfo = "Toroidal Face";
2392 case GEOM::GEOM_IKindOfShape::CONE2D:
2393 aTypeInfo = "Conical Face";
2395 case GEOM::GEOM_IKindOfShape::DISK_CIRCLE:
2398 case GEOM::GEOM_IKindOfShape::DISK_ELLIPSE:
2399 aTypeInfo = "Elliptical Face";
2401 case GEOM::GEOM_IKindOfShape::POLYGON:
2402 aTypeInfo = "Polygon";
2404 case GEOM::GEOM_IKindOfShape::PLANE:
2405 aTypeInfo = "Plane";
2407 case GEOM::GEOM_IKindOfShape::PLANAR:
2408 aTypeInfo = "Planar Face";
2410 case GEOM::GEOM_IKindOfShape::FACE:
2414 case GEOM::GEOM_IKindOfShape::CIRCLE:
2415 aTypeInfo = "Circle";
2417 case GEOM::GEOM_IKindOfShape::ARC_CIRCLE:
2418 aTypeInfo = "Arc Circle";
2420 case GEOM::GEOM_IKindOfShape::ELLIPSE:
2421 aTypeInfo = "Ellipse";
2423 case GEOM::GEOM_IKindOfShape::ARC_ELLIPSE:
2424 aTypeInfo = "Arc Ellipse";
2426 case GEOM::GEOM_IKindOfShape::LINE:
2429 case GEOM::GEOM_IKindOfShape::SEGMENT:
2430 aTypeInfo = "Segment";
2432 case GEOM::GEOM_IKindOfShape::EDGE:
2435 case GEOM::GEOM_IKindOfShape::VERTEX:
2436 aTypeInfo = "Vertex";
2444 char* anInfo = new char[strlen("Module ") + strlen(ComponentDataType()) + strlen(", ") + strlen(aTypeInfo) + 3];
2445 sprintf(anInfo, "Module %s, %s", ComponentDataType(), aTypeInfo);
2447 char* ret = CORBA::string_dup(anInfo);
2452 //=====================================================================================
2454 //=====================================================================================
2459 PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB*, PortableServer::POA*, PortableServer::ObjectId*, const char*, const char*);
2463 PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB_ptr orb,
2464 PortableServer::POA_ptr poa,
2465 PortableServer::ObjectId* contId,
2466 const char* instanceName,
2467 const char* interfaceName)
2469 GEOM_Gen_i* myGEOM_Gen_i = new GEOM_Gen_i(orb, poa, contId, instanceName, interfaceName);
2470 return myGEOM_Gen_i->getId();