2 #pragma warning( disable:4786 )
5 #include <Standard_Stream.hxx>
7 #include "GEOM_Gen_i.hh"
8 #include <TCollection_AsciiString.hxx>
9 #include <TCollection_ExtendedString.hxx>
10 #include <TColStd_HSequenceOfAsciiString.hxx>
11 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
13 //=======================================================================
14 //function : DumpPython
16 //=======================================================================
18 Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
19 CORBA::Boolean isPublished,
20 CORBA::Boolean& isValidScript)
22 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
23 if(CORBA::is_nil(aStudy))
24 return new Engines::TMPFile(0);
26 SALOMEDS::SObject_var aSO = aStudy->FindComponent(ComponentDataType());
27 if(CORBA::is_nil(aSO))
28 return new Engines::TMPFile(0);
30 Resource_DataMapOfAsciiStringAsciiString aMap;
32 SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
33 for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
34 SALOMEDS::SObject_var aValue = Itr->Value();
35 CORBA::String_var IOR = aValue->GetIOR();
36 if(strlen(IOR.in()) > 0) {
37 CORBA::Object_var obj = _orb->string_to_object(IOR);
38 GEOM::GEOM_Object_var GO = GEOM::GEOM_Object::_narrow(obj);
39 if(!CORBA::is_nil(GO)) {
40 CORBA::String_var aName = aValue->GetName();
41 CORBA::String_var anEntry = GO->GetEntry();
42 aMap.Bind( (char*)anEntry.in(), (char*)aName.in() );
47 TCollection_AsciiString aScript =
48 "### This file is generated by SALOME automatically by dump python funcitonality\n"
49 "### of GEOM component\n\n";
50 aScript += _impl->DumpPython(aStudy->StudyId(), aMap, isPublished, isValidScript);
52 int aLen = aScript.Length();
53 unsigned char* aBuffer = new unsigned char[aLen+1];
54 strcpy((char*)aBuffer, aScript.ToCString());
56 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
57 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
59 return aStreamFile._retn();
62 //=======================================================================
63 //function : GetDumpName
65 //=======================================================================
67 char* GEOM_Gen_i::GetDumpName (const char* theStudyEntry)
69 const char* name = _impl->GetDumpName( theStudyEntry );
70 if ( name && strlen( name ) > 0 )
71 return strdup( name );
76 //=======================================================================
77 //function : GetAllDumpNames
79 //=======================================================================
81 GEOM::string_array* GEOM_Gen_i::GetAllDumpNames()
83 Handle(TColStd_HSequenceOfAsciiString) aHSeq = _impl->GetAllDumpNames();
84 int i = 0, aLen = aHSeq->Length();
86 GEOM::string_array_var seq = new GEOM::string_array();
89 for (; i < aLen; i++) {
90 seq[i] = CORBA::string_dup(aHSeq->Value(i + 1).ToCString());