3 #include "GEOM_Gen_i.hh"
4 #include <TCollection_AsciiString.hxx>
5 #include <TCollection_ExtendedString.hxx>
6 #include <TColStd_HSequenceOfAsciiString.hxx>
7 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
9 //=======================================================================
10 //function : DumpPython
12 //=======================================================================
14 Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
15 CORBA::Boolean isPublished,
16 CORBA::Boolean& isValidScript)
18 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
19 if(CORBA::is_nil(aStudy))
20 return new Engines::TMPFile(0);
22 SALOMEDS::SObject_var aSO = aStudy->FindComponent(ComponentDataType());
23 if(CORBA::is_nil(aSO))
24 return new Engines::TMPFile(0);
26 Resource_DataMapOfAsciiStringAsciiString aMap;
28 SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
29 for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
30 SALOMEDS::SObject_var aValue = Itr->Value();
31 CORBA::String_var IOR = aValue->GetIOR();
32 if(strlen(IOR.in()) > 0) {
33 CORBA::Object_var obj = _orb->string_to_object(IOR);
34 GEOM::GEOM_Object_var GO = GEOM::GEOM_Object::_narrow(obj);
35 if(!CORBA::is_nil(GO)) {
36 CORBA::String_var aName = aValue->GetName();
37 CORBA::String_var anEntry = GO->GetEntry();
38 aMap.Bind( (char*)anEntry.in(), (char*)aName.in() );
43 TCollection_AsciiString aScript =
44 "### This file is generated by SALOME automatically by dump python funcitonality\n"
45 "### of GEOM component\n\n";
46 aScript += _impl->DumpPython(aStudy->StudyId(), aMap, isPublished, isValidScript);
48 int aLen = aScript.Length();
49 unsigned char* aBuffer = new unsigned char[aLen+1];
50 strcpy((char*)aBuffer, aScript.ToCString());
52 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
53 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
55 return aStreamFile._retn();
58 //=======================================================================
59 //function : GetDumpName
61 //=======================================================================
63 char* GEOM_Gen_i::GetDumpName (const char* theStudyEntry)
65 const char* name = _impl->GetDumpName( theStudyEntry );
66 if ( name && strlen( name ) > 0 )
67 return strdup( name );
72 //=======================================================================
73 //function : GetAllDumpNames
75 //=======================================================================
77 GEOM::string_array* GEOM_Gen_i::GetAllDumpNames()
79 Handle(TColStd_HSequenceOfAsciiString) aHSeq = _impl->GetAllDumpNames();
80 int i = 0, aLen = aHSeq->Length();
82 GEOM::string_array_var seq = new GEOM::string_array();
85 for (; i < aLen; i++) {
86 seq[i] = CORBA::string_dup(aHSeq->Value(i + 1).ToCString());