1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
22 // File : SMESH_DumpPython.cxx
23 // Created : Thu Mar 24 17:17:59 2005
24 // Author : Julia DOROVSKIKH
27 #include "SMESH_PythonDump.hxx"
29 #include "SMESH_2smeshpy.hxx"
30 #include "SMESH_Comment.hxx"
31 #include "SMESH_Filter_i.hxx"
32 #include "SMESH_Gen_i.hxx"
33 #include "SMESH_MeshEditor_i.hxx"
35 #include <SALOMEDS_wrap.hxx>
37 #include <LDOMParser.hxx>
38 #include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
39 #include <TColStd_HSequenceOfInteger.hxx>
40 #include <TCollection_AsciiString.hxx>
43 static int MYDEBUG = 0;
45 static int MYDEBUG = 0;
48 #include "SMESH_TryCatch.hxx"
53 size_t TPythonDump::myCounter = 0;
54 const char theNotPublishedObjectName[] = "__NOT__Published__Object__";
56 TVar::TVar(CORBA::Double value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
57 TVar::TVar(CORBA::Long value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
58 TVar::TVar(CORBA::Short value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
59 TVar::TVar(const SMESH::double_array& value):myVals(value.length()), myIsList(true)
61 for ( size_t i = 0; i < value.length(); i++)
62 myVals[i] = SMESH_Comment(value[i]);
66 TPythonDump():myVarsCounter(0)
74 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
75 std::string aString = myStream.str();
76 TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
77 SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
78 if(!aStudy->_is_nil() && !aCollection.IsEmpty())
80 const std::string & objEntry = SMESH_Gen_i::GetSMESHGen()->GetLastObjEntry();
81 if ( !objEntry.empty() )
82 aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
83 aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection);
84 if(MYDEBUG) MESSAGE(aString);
85 // prevent misuse of already treated variables
86 aSMESHGen->UpdateParameters(CORBA::Object_var().in(),"");
91 TPythonDump& //!< store a variable value. Write either a value or '$varID$'
93 operator<<(const TVar& theVarValue)
95 const std::vector< int >& varIDs = SMESH_Gen_i::GetSMESHGen()->GetLastParamIndices();
96 if ( theVarValue.myIsList )
99 for ( size_t i = 1; i <= theVarValue.myVals.size(); ++i )
101 if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
102 myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
104 myStream << theVarValue.myVals[i-1];
105 if ( i < theVarValue.myVals.size() )
113 if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
114 myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
116 myStream << theVarValue.myVals[0];
124 operator<<(long int theArg){
131 operator<<(int theArg){
138 operator<<(double theArg){
145 operator<<(float theArg){
152 operator<<(const void* theArg){
159 operator<<(const char* theArg){
167 operator<<(const std::string& theArg){
174 operator<<(const SMESH::ElementType& theArg)
178 case ALL: myStream<<"ALL"; break;
179 case NODE: myStream<<"NODE"; break;
180 case EDGE: myStream<<"EDGE"; break;
181 case FACE: myStream<<"FACE"; break;
182 case VOLUME: myStream<<"VOLUME"; break;
183 case ELEM0D: myStream<<"ELEM0D"; break;
184 case BALL: myStream<<"BALL"; break;
185 default: myStream<<"__UNKNOWN__ElementType: " << theArg;
192 operator<<(const SMESH::GeometryType& theArg)
196 case Geom_POINT: myStream<<"Geom_POINT"; break;
197 case Geom_EDGE: myStream<<"Geom_EDGE"; break;
198 case Geom_TRIANGLE: myStream<<"Geom_TRIANGLE"; break;
199 case Geom_QUADRANGLE: myStream<<"Geom_QUADRANGLE"; break;
200 case Geom_POLYGON: myStream<<"Geom_POLYGON"; break;
201 case Geom_TETRA: myStream<<"Geom_TETRA"; break;
202 case Geom_PYRAMID: myStream<<"Geom_PYRAMID"; break;
203 case Geom_HEXA: myStream<<"Geom_HEXA"; break;
204 case Geom_PENTA: myStream<<"Geom_PENTA"; break;
205 case Geom_POLYHEDRA: myStream<<"Geom_POLYHEDRA"; break;
206 case Geom_BALL: myStream<<"Geom_BALL"; break;
207 default: myStream<<"__UNKNOWN__GeometryType: " << theArg;
213 operator<<(const SMESH::EntityType& theArg)
217 case Entity_0D: myStream<<"Entity_0D"; break;
218 case Entity_Edge: myStream<<"Entity_Edge"; break;
219 case Entity_Quad_Edge: myStream<<"Entity_Quad_Edge"; break;
220 case Entity_Triangle: myStream<<"Entity_Triangle"; break;
221 case Entity_Quad_Triangle: myStream<<"Entity_Quad_Triangle"; break;
222 case Entity_BiQuad_Triangle: myStream<<"Entity_BiQuad_Triangle"; break;
223 case Entity_Quadrangle: myStream<<"Entity_Quadrangle"; break;
224 case Entity_Quad_Quadrangle: myStream<<"Entity_Quad_Quadrangle"; break;
225 case Entity_BiQuad_Quadrangle: myStream<<"Entity_BiQuad_Quadrangle"; break;
226 case Entity_Polygon: myStream<<"Entity_Polygon"; break;
227 case Entity_Quad_Polygon: myStream<<"Entity_Quad_Polygon"; break;
228 case Entity_Tetra: myStream<<"Entity_Tetra"; break;
229 case Entity_Quad_Tetra: myStream<<"Entity_Quad_Tetra"; break;
230 case Entity_Pyramid: myStream<<"Entity_Pyramid"; break;
231 case Entity_Quad_Pyramid: myStream<<"Entity_Quad_Pyramid"; break;
232 case Entity_Hexa: myStream<<"Entity_Hexa"; break;
233 case Entity_Quad_Hexa: myStream<<"Entity_Quad_Hexa"; break;
234 case Entity_TriQuad_Hexa: myStream<<"Entity_TriQuad_Hexa"; break;
235 case Entity_Penta: myStream<<"Entity_Penta"; break;
236 case Entity_Quad_Penta: myStream<<"Entity_Quad_Penta"; break;
237 case Entity_BiQuad_Penta: myStream<<"Entity_BiQuad_Penta"; break;
238 case Entity_Hexagonal_Prism: myStream<<"Entity_Hexagonal_Prism"; break;
239 case Entity_Polyhedra: myStream<<"Entity_Polyhedra"; break;
240 case Entity_Quad_Polyhedra: myStream<<"Entity_Quad_Polyhedra"; break;
241 case Entity_Ball: myStream<<"Entity_Ball"; break;
242 case Entity_Last: myStream<<"Entity_Last"; break;
243 default: myStream<<"__UNKNOWN__EntityType: " << theArg;
248 template<class TArray>
249 void DumpArray(const TArray& theArray, TPythonDump & theStream)
251 if ( theArray.length() == 0 )
258 for (CORBA::ULong i = 1; i <= theArray.length(); i++) {
259 theStream << theArray[i-1];
260 if ( i < theArray.length() )
268 TPythonDump::operator<<(const SMESH::long_array& theArg)
270 DumpArray( theArg, *this );
275 TPythonDump::operator<<(const SMESH::double_array& theArg)
277 DumpArray( theArg, *this );
282 TPythonDump::operator<<(const SMESH::nodes_array& theArg)
284 DumpArray( theArg, *this );
289 TPythonDump::operator<<(const SMESH::string_array& theArray)
292 for ( CORBA::ULong i = 1; i <= theArray.length(); i++ ) {
293 myStream << "'" << theArray[i-1] << "'";
294 if ( i < theArray.length() )
303 operator<<(SALOMEDS::SObject_ptr aSObject)
305 if ( !aSObject->_is_nil() ) {
306 CORBA::String_var entry = aSObject->GetID();
307 myStream << entry.in();
310 myStream << theNotPublishedObjectName;
317 operator<<(CORBA::Object_ptr theArg)
319 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
320 SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
321 SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
322 if(!aSObject->_is_nil()) {
323 CORBA::String_var id = aSObject->GetID();
325 } else if ( !CORBA::is_nil(theArg)) {
326 if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object
327 myStream << "smeshObj_" << size_t(theArg);
329 myStream << theNotPublishedObjectName;
338 operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
340 SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
341 SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
342 if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
343 myStream << "hyp_" << theArg->GetId();
351 operator<<(SMESH::SMESH_IDSource_ptr theArg)
353 if ( CORBA::is_nil( theArg ) )
354 return *this << "None";
355 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
356 SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
357 SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
358 if(!aSObject->_is_nil())
360 return *this << aSObject;
362 if ( SMESH::Filter_i* filter = SMESH::DownCast<SMESH::Filter_i*>( theArg ))
364 return *this << filter;
366 if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theArg ))
368 SMESH::SMESH_Mesh_var mesh = theArg->GetMesh();
369 SMESH::long_array_var anElementsId = theArg->GetIDs();
370 SMESH::array_of_ElementType_var types = theArg->GetTypes();
371 SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
372 SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(aStudy,mesh);
373 if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
374 return *this << mesh << ".GetIDSource([], " << type << ")";
376 return *this << mesh << ".GetIDSource(" << anElementsId << ", " << type << ")";
378 return *this << theNotPublishedObjectName;
383 operator<<(SMESH::FilterLibrary_i* theArg)
385 myStream<<"aFilterLibrary"<<theArg;
391 operator<<(SMESH::FilterManager_i* theArg)
393 myStream<<"aFilterManager";
399 operator<<(SMESH::Filter_i* theArg)
401 myStream<<"aFilter"<<theArg;
407 operator<<(SMESH::Functor_i* theArg)
410 FunctorType aFunctorType = theArg->GetFunctorType();
411 switch(aFunctorType) {
412 case FT_AspectRatio: myStream<< "aAspectRatio"; break;
413 case FT_AspectRatio3D: myStream<< "aAspectRatio3D"; break;
414 case FT_Warping: myStream<< "aWarping"; break;
415 case FT_MinimumAngle: myStream<< "aMinimumAngle"; break;
416 case FT_Taper: myStream<< "aTaper"; break;
417 case FT_Skew: myStream<< "aSkew"; break;
418 case FT_Area: myStream<< "aArea"; break;
419 case FT_Volume3D: myStream<< "aVolume3D"; break;
420 case FT_MaxElementLength2D: myStream<< "aMaxElementLength2D"; break;
421 case FT_MaxElementLength3D: myStream<< "aMaxElementLength3D"; break;
422 case FT_FreeBorders: myStream<< "aFreeBorders"; break;
423 case FT_FreeEdges: myStream<< "aFreeEdges"; break;
424 case FT_FreeNodes: myStream<< "aFreeNodes"; break;
425 case FT_FreeFaces: myStream<< "aFreeFaces"; break;
426 case FT_EqualNodes: myStream<< "aEqualNodes"; break;
427 case FT_EqualEdges: myStream<< "aEqualEdges"; break;
428 case FT_EqualFaces: myStream<< "aEqualFaces"; break;
429 case FT_EqualVolumes: myStream<< "aEqualVolumes"; break;
430 case FT_MultiConnection: myStream<< "aMultiConnection"; break;
431 case FT_MultiConnection2D: myStream<< "aMultiConnection2D"; break;
432 case FT_Length: myStream<< "aLength"; break;
433 case FT_Length2D: myStream<< "aLength2D"; break;
434 case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break;
435 case FT_BelongToMeshGroup: myStream<< "aBelongToMeshGroup"; break;
436 case FT_BelongToGeom: myStream<< "aBelongToGeom"; break;
437 case FT_BelongToPlane: myStream<< "aBelongToPlane"; break;
438 case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break;
439 case FT_BelongToGenSurface: myStream<< "aBelongToGenSurface"; break;
440 case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break;
441 case FT_RangeOfIds: myStream<< "aRangeOfIds"; break;
442 case FT_BadOrientedVolume: myStream<< "aBadOrientedVolume"; break;
443 case FT_BareBorderVolume: myStream<< "aBareBorderVolume"; break;
444 case FT_BareBorderFace: myStream<< "aBareBorderFace"; break;
445 case FT_OverConstrainedVolume: myStream<< "aOverConstrainedVolume"; break;
446 case FT_OverConstrainedFace: myStream<< "aOverConstrainedFace"; break;
447 case FT_LinearOrQuadratic: myStream<< "aLinearOrQuadratic"; break;
448 case FT_GroupColor: myStream<< "aGroupColor"; break;
449 case FT_ElemGeomType: myStream<< "aElemGeomType"; break;
450 case FT_EntityType: myStream<< "aEntityType"; break;
451 case FT_CoplanarFaces: myStream<< "aCoplanarFaces"; break;
452 case FT_BallDiameter: myStream<< "aBallDiameter"; break;
453 case FT_ConnectedElements: myStream<< "aConnectedElements"; break;
454 case FT_LessThan: myStream<< "aLessThan"; break;
455 case FT_MoreThan: myStream<< "aMoreThan"; break;
456 case FT_EqualTo: myStream<< "aEqualTo"; break;
457 case FT_LogicalNOT: myStream<< "aLogicalNOT"; break;
458 case FT_LogicalAND: myStream<< "aLogicalAND"; break;
459 case FT_LogicalOR: myStream<< "aLogicalOR"; break;
460 case FT_Undefined: myStream<< "anUndefined"; break;
461 //default: -- commented to have a compilation warning
470 operator<<(SMESH::Measurements_i* theArg)
472 myStream<<"aMeasurements";
477 TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
479 myStream << SMESHGenName(); return *this;
482 TPythonDump& TPythonDump::operator<<(SMESH_MeshEditor_i* theArg)
484 myStream << MeshEditorName() << "_" << ( theArg ? theArg->GetMeshId() : -1 ); return *this;
487 TPythonDump& TPythonDump::operator<<(const TCollection_AsciiString & theStr)
489 myStream << theStr; return *this;
493 TPythonDump& TPythonDump::operator<<(SMESH::MED_VERSION theVersion)
495 switch (theVersion) {
496 case SMESH::MED_V2_1: myStream << "SMESH.MED_V2_1"; break;
497 case SMESH::MED_V2_2: myStream << "SMESH.MED_V2_2"; break;
498 default: myStream << theVersion;
503 TPythonDump& TPythonDump::operator<<(const SMESH::AxisStruct & theAxis)
505 *this << "SMESH.AxisStruct( "
506 << TVar( theAxis.x ) << ", "
507 << TVar( theAxis.y ) << ", "
508 << TVar( theAxis.z ) << ", "
509 << TVar( theAxis.vx ) << ", "
510 << TVar( theAxis.vy ) << ", "
511 << TVar( theAxis.vz ) << " )";
515 TPythonDump& TPythonDump::operator<<(const SMESH::DirStruct & theDir)
517 const SMESH::PointStruct & P = theDir.PS;
518 *this << "SMESH.DirStruct( SMESH.PointStruct ( "
519 << TVar( P.x ) << ", "
520 << TVar( P.y ) << ", "
521 << TVar( P.z ) << " ))";
525 TPythonDump& TPythonDump::operator<<(const SMESH::PointStruct & P)
527 *this << "SMESH.PointStruct ( "
528 << TVar( P.x ) << ", "
529 << TVar( P.y ) << ", "
530 << TVar( P.z ) << " )";
534 TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups& theList)
536 DumpArray( theList, *this );
539 TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups * theList)
541 DumpArray( *theList, *this );
544 TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGO& theList)
546 DumpArray( theList, *this );
549 TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGBO& theList)
551 DumpArray( theList, *this );
554 TPythonDump& TPythonDump::operator<<(const SMESH::ListOfIDSources& theList)
556 DumpArray( theList, *this );
559 TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
561 // dump CoincidentFreeBorders as a list of lists, each enclosed list
562 // contains node IDs of a group of coincident free borders where
563 // each consequent triple of IDs describe a free border: (n1, n2, nLast)
564 // For example [[1, 2, 10, 20, 21, 40], [11, 12, 15, 55, 54, 41]] describes
565 // two groups of coincident free borders, each group including two borders
568 for ( CORBA::ULong i = 0; i < theCFB.coincidentGroups.length(); ++i )
570 const SMESH::FreeBordersGroup& aGRP = theCFB.coincidentGroups[ i ];
571 if ( i ) myStream << ",";
573 for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
575 const SMESH::FreeBorderPart& aPART = aGRP[ iP ];
576 if ( 0 <= aPART.border && aPART.border < (CORBA::Long)theCFB.borders.length() )
578 if ( iP ) myStream << ", ";
579 const SMESH::FreeBorder& aBRD = theCFB.borders[ aPART.border ];
580 myStream << aBRD.nodeIDs[ aPART.node1 ] << ",";
581 myStream << aBRD.nodeIDs[ aPART.node2 ] << ",";
582 myStream << aBRD.nodeIDs[ aPART.nodeLast ];
592 const char* TPythonDump::NotPublishedObjectName()
594 return theNotPublishedObjectName;
597 TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
598 TCollection_AsciiString myLongStringEnd ( "TPythonDump::LongStringEnd" );
600 //================================================================================
602 * \brief Return marker of long string literal beginning
603 * \param type - a name of functionality producing the string literal
604 * \retval TCollection_AsciiString - the marker string to be written into
605 * a raw python script
607 //================================================================================
609 TCollection_AsciiString TPythonDump::LongStringStart(const char* type)
613 (Standard_Integer) strlen(type) +
618 //================================================================================
620 * \brief Return marker of long string literal end
621 * \retval TCollection_AsciiString - the marker string to be written into
622 * a raw python script
624 //================================================================================
626 TCollection_AsciiString TPythonDump::LongStringEnd()
628 return myLongStringEnd;
631 //================================================================================
633 * \brief Cut out a long string literal from a string
634 * \param theText - text possibly containing string literals
635 * \param theFrom - position in the text to search from
636 * \param theLongString - the retrieved literal
637 * \param theStringType - a name of functionality produced the literal
638 * \retval bool - true if a string literal found
640 * The literal is removed from theText; theFrom points position right after
641 * the removed literal
643 //================================================================================
645 bool TPythonDump::CutoutLongString( TCollection_AsciiString & theText,
647 TCollection_AsciiString & theLongString,
648 TCollection_AsciiString & theStringType)
650 if ( theFrom < 1 || theFrom > theText.Length() )
653 // ...script \ beg marker \ \ type \ literal \ end marker \ script...
654 // "theText myLongStringStart7 Pattern!!! SALOME Mesh Pattern file myLongStringEndtextEnd"
655 // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
658 theFrom = theText.Location( myLongStringStart, theFrom, theText.Length() ); // = 09
662 // find where literal begins
663 int literalBeg = theFrom + myLongStringStart.Length(); // = 26
664 char* typeLenStr = (char*) theText.ToCString() + literalBeg - 1; // = "7 Pattern!!! SALO...."
665 int typeLen = atoi ( typeLenStr ); // = 7
666 while ( *typeLenStr != ' ' ) { // look for ' ' after typeLen
667 literalBeg++; // 26 -> 27
670 literalBeg += typeLen + 1; // = 35
671 if ( literalBeg > theText.Length() )
674 // where literal ends (i.e. end marker begins)
675 int literalEnd = theText.Location( myLongStringEnd, literalBeg, theText.Length() ); // = 64
677 literalEnd = theText.Length();
680 theLongString = theText.SubString( literalBeg, literalEnd - 1); // "!!! SALOME Mesh Pattern file "
682 theStringType = theText.SubString( literalBeg - typeLen, literalBeg - 1 ); // "Pattern"
684 literalEnd += myLongStringEnd.Length(); // = 79
685 TCollection_AsciiString textEnd = theText.SubString( literalEnd, theText.Length() ); // "textE..."
686 theText = theText.SubString( 1, theFrom - 1 ) + textEnd;
691 void printException( const char* text )
694 cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << endl;
699 //=======================================================================
700 //function : RemoveTabulation
702 //=======================================================================
703 void RemoveTabulation( TCollection_AsciiString& theScript )
705 std::string aString( theScript.ToCString() );
706 std::string::size_type aPos = 0;
707 while( aPos < aString.length() )
709 aPos = aString.find( "\n\t", aPos );
710 if( aPos == std::string::npos )
712 aString.replace( aPos, 2, "\n" );
715 theScript = aString.c_str();
718 //=======================================================================
719 //function : DumpPython
721 //=======================================================================
722 Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
723 CORBA::Boolean isPublished,
724 CORBA::Boolean isMultiFile,
725 CORBA::Boolean& isValidScript)
727 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
728 if (CORBA::is_nil(aStudy))
729 return new Engines::TMPFile(0);
731 CORBA::String_var compDataType = ComponentDataType();
732 SALOMEDS::SObject_wrap aSO = aStudy->FindComponent( compDataType.in() );
733 if (CORBA::is_nil(aSO))
734 return new Engines::TMPFile(0);
736 // Map study entries to object names
737 Resource_DataMapOfAsciiStringAsciiString aMap;
738 Resource_DataMapOfAsciiStringAsciiString aMapNames;
740 SALOMEDS::ChildIterator_wrap Itr = aStudy->NewChildIterator(aSO);
741 for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
742 SALOMEDS::SObject_wrap aValue = Itr->Value();
743 CORBA::String_var anID = aValue->GetID();
744 CORBA::String_var aName = aValue->GetName();
745 TCollection_AsciiString aGUIName ( (char*) aName.in() );
746 TCollection_AsciiString anEntry ( (char*) anID.in() );
747 if (aGUIName.Length() > 0) {
748 aMapNames.Bind( anEntry, aGUIName );
749 aMap.Bind( anEntry, aGUIName );
753 // Get trace of restored study
754 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
755 SALOMEDS::GenericAttribute_wrap anAttr =
756 aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
758 SALOMEDS::AttributePythonObject_var pyAttr =
759 SALOMEDS::AttributePythonObject::_narrow(anAttr);
760 CORBA::String_var oldValue = pyAttr->GetObject();
761 TCollection_AsciiString aSavedTrace (oldValue.in());
763 // Add trace of API methods calls and replace study entries by names
764 TCollection_AsciiString aScript;
765 aScript += DumpPython_impl(aStudy, aMap, aMapNames, isPublished, isMultiFile,
766 myIsHistoricalPythonDump, isValidScript, aSavedTrace);
768 int aLen = aScript.Length();
769 unsigned char* aBuffer = new unsigned char[aLen+1];
770 strcpy((char*)aBuffer, aScript.ToCString());
772 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
773 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
775 bool hasNotPublishedObjects = aScript.Location( SMESH::theNotPublishedObjectName, 1, aLen);
776 isValidScript = isValidScript && !hasNotPublishedObjects;
778 return aStreamFile._retn();
781 //=============================================================================
785 //=============================================================================
786 void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString)
788 if (myPythonScripts.find(theStudyID) == myPythonScripts.end()) {
789 myPythonScripts[theStudyID] = new TColStd_HSequenceOfAsciiString;
791 myPythonScripts[theStudyID]->Append(theString);
794 //=============================================================================
796 * RemoveLastFromPythonScript
798 //=============================================================================
799 void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID)
801 if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
802 int aLen = myPythonScripts[theStudyID]->Length();
803 myPythonScripts[theStudyID]->Remove(aLen);
807 //=======================================================================
808 //function : SavePython
810 //=======================================================================
811 void SMESH_Gen_i::SavePython (SALOMEDS::Study_ptr theStudy)
813 // Dump trace of API methods calls
814 TCollection_AsciiString aScript = GetNewPythonLines(theStudy->StudyId());
816 // Check contents of PythonObject attribute
817 CORBA::String_var compDataType = ComponentDataType();
818 SALOMEDS::SObject_wrap aSO = theStudy->FindComponent( compDataType.in() );
819 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
820 SALOMEDS::GenericAttribute_wrap anAttr =
821 aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
823 SALOMEDS::AttributePythonObject_var pyAttr =
824 SALOMEDS::AttributePythonObject::_narrow(anAttr);
825 CORBA::String_var oldValue = pyAttr->GetObject();
826 TCollection_AsciiString oldScript (oldValue.in());
828 if (oldScript.Length() > 0) {
830 oldScript += aScript;
835 // Store in PythonObject attribute
836 pyAttr->SetObject(oldScript.ToCString(), 1);
838 // Clean trace of API methods calls
839 CleanPythonTrace(theStudy->StudyId());
846 //=============================================================================
848 * FindEntries: Returns a sequence of start/end positions of entries in the string
850 //=============================================================================
851 Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
853 Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
854 Standard_Integer aLen = theString.Length();
855 Standard_Boolean isFound = Standard_False;
857 char* arr = (char*) theString.ToCString();
858 Standard_Integer i = 0, j;
863 if ( isdigit( c )) { //Is digit?
865 isFound = Standard_False;
866 while((j < aLen) && ( isdigit(c) || c == ':' )) { //Check if it is an entry
868 if(c == ':') isFound = Standard_True;
872 int prev = (i < 1) ? 0 : (int)arr[i - 1];
873 // to distinguish from a sketcher command:
874 // last char should be a digit, not ":",
875 // previous char should not be '"'.
876 if (arr[j-2] != ':' && prev != '"') {
877 aSeq->Append(i+1); // +1 because AsciiString starts from 1
891 //================================================================================
893 * \brief Make a string be a valid python name
894 * \param aName - a string to fix
895 * \retval bool - true if aName was not modified
897 //================================================================================
899 bool fixPythonName(TCollection_AsciiString & aName)
901 bool isValidName = true;
902 int nbUnderscore = 0;
904 // replace not allowed chars by underscore
905 const char* name = aName.ToCString();
906 for ( p = 0; name[p]; ++p ) {
907 if ( !isalnum( name[p] ) && name[p] != '_' )
909 if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_')
911 aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end
913 name = aName.ToCString();
917 aName.SetValue( p+1, '_');
923 // aName must not start with a digit
924 if ( aName.IsIntegerValue() ) {
925 aName.Insert( 1, 'a' );
928 // shorten names like CartesianParameters3D_400_400_400_1000000_1
929 const int nbAllowedUnderscore = 3; /* changed from 2 to 3 by an user request
930 posted to SALOME Forum */
931 if ( aName.Length() > 20 && nbUnderscore > nbAllowedUnderscore )
933 p = aName.Location( "_", 20, aName.Length());
940 //================================================================================
942 * \brief Return Python module names of available plug-ins.
944 //================================================================================
946 std::vector<std::string> getPluginNames()
948 std::vector<std::string> pluginNames;
949 std::vector< std::string > xmlPaths = SMESH_Gen::GetPluginXMLPaths();
950 LDOMParser xmlParser;
951 for ( size_t i = 0; i < xmlPaths.size(); ++i )
953 bool error = xmlParser.parse( xmlPaths[i].c_str() );
956 TCollection_AsciiString data;
957 INFOS( xmlParser.GetError(data) );
960 // <meshers-group name="Standard Meshers"
961 // resources="StdMeshers"
962 // idl-module="StdMeshers"
963 // server-lib="StdMeshersEngine"
964 // gui-lib="StdMeshersGUI">
965 LDOM_Document xmlDoc = xmlParser.getDocument();
966 LDOM_NodeList nodeList = xmlDoc.getElementsByTagName( "meshers-group" );
967 for ( int i = 0; i < nodeList.getLength(); ++i )
969 LDOM_Node node = nodeList.item( i );
970 LDOM_Element& elem = (LDOM_Element&) node;
971 LDOMString idlModule = elem.getAttribute( "idl-module" );
972 if ( strlen( idlModule.GetString() ) > 0 )
973 pluginNames.push_back( idlModule.GetString() );
980 //================================================================================
982 * \brief Createa a Dump Python script
983 * \param [in] theStudy - the study to dump
984 * \param [in,out] theObjectNames - map of an entry to a study and python name
985 * \param [in] theNames - - map of an entry to a study name
986 * \param [in] isPublished - \c true if dump of object publication in study is needed
987 * \param [in] isMultiFile - \c true if dump of each module goes to a separate file
988 * \param [in] isHistoricalDump - \c true if removed object should be dumped
989 * \param [out] aValidScript - returns \c true if the returned script seems valid
990 * \param [in,out] theSavedTrace - the dump stored in the study. It's cleared to
991 * decrease memory usage.
992 * \return TCollection_AsciiString - the result dump script.
994 //================================================================================
996 TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
997 (SALOMEDS::Study_ptr theStudy,
998 Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
999 Resource_DataMapOfAsciiStringAsciiString& theNames,
1002 bool isHistoricalDump,
1004 TCollection_AsciiString& theSavedTrace)
1007 const int aStudyID = theStudy->StudyId();
1009 const TCollection_AsciiString aSmeshpy ( SMESH_2smeshpy::SmeshpyName() );
1010 const TCollection_AsciiString aSMESHGen( SMESH_2smeshpy::GenName() );
1011 const TCollection_AsciiString anOldGen ( SMESH::TPythonDump::SMESHGenName() );
1012 const TCollection_AsciiString helper; // to comfortably append C strings to TCollection_AsciiString
1013 const TCollection_AsciiString tab( isMultiFile ? "\t" : "" ), nt = helper + "\n" + tab;
1015 std::list< TCollection_AsciiString > lines; // lines of a script
1016 std::list< TCollection_AsciiString >::iterator linesIt;
1019 lines.push_back( aSMESHGen + " = smeshBuilder.New(theStudy)" );
1021 lines.push_back( aSMESHGen + " = smeshBuilder.New(None)" );
1022 lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" );
1023 lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );
1025 // Treat dump trace of restored study
1026 if (theSavedTrace.Length() > 0)
1028 linesIt = --lines.end();
1029 // Split theSavedTrace into lines
1030 int from = 1, end = theSavedTrace.Length(), to;
1031 while ( from < end && ( to = theSavedTrace.Location( "\n", from, end )))
1033 if ( theSavedTrace.ToCString()[from-1] == '\t' )
1036 lines.push_back( theSavedTrace.SubString( from, to - 1 ));
1039 // For the conversion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen
1040 // was replaces with "smeshgen" (==TPythonDump::SMESHGenName()).
1041 // Change "smesh" -> "smeshgen" in the trace saved before passage to smeshBuilder.py API
1043 theSavedTrace.Location( anOldGen + ".", 1, theSavedTrace.Length() );
1044 theSavedTrace.Clear();
1045 if ( !isNewVersion )
1047 const TCollection_AsciiString aSmeshCall ( "smesh." ), gen( "gen" );
1049 for ( ++linesIt; linesIt != lines.end(); ++linesIt )
1051 TCollection_AsciiString& aSavedLine = *linesIt;
1052 end = aSavedLine.Length(), from = 1;
1053 while ( from < end && ( beg = aSavedLine.Location( aSmeshCall, from, end )))
1055 char charBefore = ( beg == 1 ) ? ' ' : aSavedLine.Value( beg - 1 );
1056 if ( isspace( charBefore ) || charBefore == '=' ) { // "smesh." is not a part of a long word
1057 aSavedLine.Insert( beg + aSmeshCall.Length() - 1, gen );// "smesh" -> "smeshgen"
1058 end += gen.Length();
1060 from = beg + aSmeshCall.Length();
1066 // Add new dump trace of API methods calls to script lines
1067 if (myPythonScripts.find( aStudyID ) != myPythonScripts.end())
1069 Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[ aStudyID ];
1070 Standard_Integer istr, aLen = aPythonScript->Length();
1071 for (istr = 1; istr <= aLen; istr++)
1072 lines.push_back( aPythonScript->Value( istr ));
1075 // Convert IDL API calls into smeshBuilder.py API.
1076 // Some objects are wrapped with python classes and
1077 // Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects
1078 Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
1079 std::set< TCollection_AsciiString > aRemovedObjIDs;
1080 if ( !getenv("NO_2smeshpy_conversion"))
1081 SMESH_2smeshpy::ConvertScript( lines, anEntry2AccessorMethod,
1082 theObjectNames, aRemovedObjIDs,
1083 theStudy, isHistoricalDump );
1085 bool importGeom = false;
1086 GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
1088 // Add names of GEOM objects to theObjectNames to exclude same names of SMESH objects
1089 GEOM::string_array_var aGeomNames = geom->GetAllDumpNames();
1090 int ign = 0, nbgn = aGeomNames->length();
1091 for (; ign < nbgn; ign++) {
1092 TCollection_AsciiString aName = aGeomNames[ign].in();
1093 theObjectNames.Bind(aName, "1");
1097 TCollection_AsciiString anUpdatedScript;
1099 Resource_DataMapOfAsciiStringAsciiString mapRemoved;
1100 Resource_DataMapOfAsciiStringAsciiString mapEntries; // names and entries present in anUpdatedScript
1101 Standard_Integer objectCounter = 0;
1102 TCollection_AsciiString anEntry, aName, aGUIName, aBaseName("smeshObj_");
1104 // Treat every script line and add it to anUpdatedScript
1105 for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
1107 TCollection_AsciiString& aLine = *linesIt;
1108 anUpdatedScript += tab;
1110 //Replace characters used instead of quote marks to quote notebook variables
1112 while (( pos = aLine.Location( 1, SMESH::TVar::Quote(), pos, aLine.Length() )))
1113 aLine.SetValue( pos, '"' );
1115 // Find entries to be replaced by names
1116 Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aLine);
1117 const Standard_Integer aSeqLen = aSeq->Length();
1118 Standard_Integer aStart = 1;
1119 for (Standard_Integer i = 1; i <= aSeqLen; i += 2)
1121 if ( aStart < aSeq->Value(i) )
1122 anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry
1123 anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) );
1124 // is a GEOM object?
1125 CORBA::String_var geomName = geom->GetDumpName( anEntry.ToCString() );
1126 if ( !geomName.in() || !geomName.in()[0] ) {
1127 // is a SMESH object
1128 if ( theObjectNames.IsBound( anEntry )) {
1129 // The Object is in Study
1130 aName = theObjectNames.Find( anEntry );
1131 // check validity of aName
1132 bool isValidName = fixPythonName( aName );
1133 if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
1134 // diff objects have same name - make a new name by appending a digit
1135 TCollection_AsciiString aName2;
1136 Standard_Integer i = 0;
1138 aName2 = aName + "_" + ++i;
1139 } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
1141 isValidName = false;
1144 theObjectNames(anEntry) = aName;
1146 if ( aLine.Value(1) != '#' )
1147 mapEntries.Bind(anEntry, aName);
1153 aName = aBaseName + (++objectCounter);
1154 } while (theObjectNames.IsBound(aName));
1156 if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
1157 mapRemoved.Bind(anEntry, aName);
1159 theObjectNames.Bind(anEntry, aName);
1161 theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
1165 aName = geomName.in();
1168 anUpdatedScript += aName;
1169 aStart = aSeq->Value(i + 1) + 1;
1171 } // loop on entries within aLine
1174 anUpdatedScript += aLine;
1175 else if ( aSeq->Value( aSeqLen ) < aLine.Length() )
1176 anUpdatedScript += aLine.SubString( aSeq->Value(aSeqLen) + 1, aLine.Length() );
1178 anUpdatedScript += '\n';
1181 // Make an initial part of aSript
1183 TCollection_AsciiString initPart = "import ";
1185 initPart += "salome, ";
1186 initPart += " SMESH, SALOMEDS\n";
1187 initPart += "from salome.smesh import smeshBuilder\n";
1188 if ( importGeom && isMultiFile )
1190 initPart += ("\n## import GEOM dump file ## \n"
1191 "import string, os, sys, re, inspect\n"
1192 "thisFile = inspect.getfile( inspect.currentframe() )\n"
1193 "thisModule = os.path.splitext( os.path.basename( thisFile ))[0]\n"
1194 "sys.path.insert( 0, os.path.dirname( thisFile ))\n"
1195 "exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",thisModule)+\" import *\")\n\n");
1197 // import python files corresponding to plugins if they are used in anUpdatedScript
1199 TCollection_AsciiString importStr;
1200 std::vector<std::string> pluginNames = getPluginNames();
1201 for ( size_t i = 0; i < pluginNames.size(); ++i )
1203 // Convert access to plugin members:
1204 // e.g. StdMeshers.QUAD_REDUCED -> StdMeshersBuilder.QUAD_REDUCED
1205 TCollection_AsciiString pluginAccess = (pluginNames[i] + ".").c_str() ;
1206 int iFrom = 1, iPos;
1207 while (( iPos = anUpdatedScript.Location( pluginAccess, iFrom, anUpdatedScript.Length() )))
1209 anUpdatedScript.Insert( iPos + pluginNames[i].size(), "Builder" );
1210 iFrom = iPos + pluginNames[i].size() + 8;
1212 // if any plugin member is used, import the plugin
1214 importStr += ( helper + "\n" "from salome." + pluginNames[i].c_str() +
1215 " import " + pluginNames[i].c_str() +"Builder" );
1217 if ( !importStr.IsEmpty() )
1218 initPart += importStr + "\n";
1222 initPart += "def RebuildData(theStudy):";
1225 anUpdatedScript.Prepend( initPart );
1227 // Make a final part of aScript
1229 // Dump object removal
1230 TCollection_AsciiString removeObjPart;
1231 if ( !mapRemoved.IsEmpty() ) {
1232 removeObjPart += nt + "## some objects were removed";
1233 removeObjPart += nt + "aStudyBuilder = theStudy.NewBuilder()";
1234 Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapRemovedIt;
1235 for ( mapRemovedIt.Initialize( mapRemoved ); mapRemovedIt.More(); mapRemovedIt.Next() ) {
1236 aName = mapRemovedIt.Value(); // python name
1237 anEntry = mapRemovedIt.Key();
1238 removeObjPart += nt + "SO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(";
1239 removeObjPart += aName;
1240 // for object wrapped by class of smeshBuilder.py
1241 if ( anEntry2AccessorMethod.IsBound( anEntry ) )
1242 removeObjPart += helper + "." + anEntry2AccessorMethod( anEntry );
1243 removeObjPart += helper + "))" + nt + "if SO: aStudyBuilder.RemoveObjectWithChildren(SO)";
1248 TCollection_AsciiString setNamePart;
1249 Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapEntriesIt;
1250 for ( mapEntriesIt.Initialize( mapEntries ); mapEntriesIt.More(); mapEntriesIt.Next() )
1252 anEntry = mapEntriesIt.Key();
1253 aName = mapEntriesIt.Value(); // python name
1254 if ( theNames.IsBound( anEntry ))
1256 aGUIName = theNames.Find(anEntry);
1257 aGUIName.RemoveAll('\''); // remove a quote from a name (issue 22360)
1258 setNamePart += nt + aSMESHGen + ".SetName(" + aName;
1259 if ( anEntry2AccessorMethod.IsBound( anEntry ) )
1260 setNamePart += helper + "." + anEntry2AccessorMethod( anEntry );
1261 setNamePart += helper + ", '" + aGUIName + "')";
1264 if ( !setNamePart.IsEmpty() )
1266 setNamePart.Insert( 1, nt + "## Set names of Mesh objects" );
1269 // Store visual properties of displayed objects
1271 TCollection_AsciiString visualPropertiesPart;
1274 //Output the script that sets up the visual parameters.
1275 CORBA::String_var compDataType = ComponentDataType();
1276 CORBA::String_var script = theStudy->GetDefaultScript( compDataType.in(), tab.ToCString() );
1277 if ( script.in() && script.in()[0] ) {
1278 visualPropertiesPart += nt + "### Store presentation parameters of displayed objects\n";
1279 visualPropertiesPart += script.in();
1283 anUpdatedScript += removeObjPart + '\n' + setNamePart + '\n' + visualPropertiesPart;
1290 "\nif __name__ == '__main__':"
1291 "\n\tSMESH_RebuildData = RebuildData"
1292 "\n\texec('import '+re.sub('SMESH$','GEOM',thisModule)+' as GEOM_dump')"
1293 "\n\tGEOM_dump.RebuildData( salome.myStudy )"
1294 "\n\texec('from '+re.sub('SMESH$','GEOM',thisModule)+' import * ')"
1295 "\n\tSMESH_RebuildData( salome.myStudy )";
1297 anUpdatedScript += "\n";
1299 // no need now as we use 'tab' and 'nt' variables depending on isMultiFile
1300 // if( !isMultiFile ) // remove unnecessary tabulation
1301 // RemoveTabulation( anUpdatedScript );
1303 // -----------------------------------------------------------------
1304 // put string literals describing patterns into separate functions
1305 // -----------------------------------------------------------------
1307 TCollection_AsciiString aLongString, aFunctionType;
1309 std::set< std::string > functionNameSet;
1310 while ( SMESH::TPythonDump::CutoutLongString( anUpdatedScript, where, aLongString, aFunctionType ))
1312 // make a python string literal
1313 aLongString.Prepend(":\n\treturn '''\n");
1314 aLongString += "\n\t'''\n\tpass\n";
1316 TCollection_AsciiString functionName;
1318 // check if the function returning this literal is already defined
1319 int posAlready = anUpdatedScript.Location( aLongString, where, anUpdatedScript.Length() );
1320 if ( posAlready ) // already defined
1322 // find the function name
1323 int functBeg = posAlready;
1324 char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def fuction()"
1325 while ( *script != ' ' ) {
1329 functBeg++; // do not take ' '
1330 posAlready--; // do not take ':'
1331 functionName = anUpdatedScript.SubString( functBeg, posAlready );
1333 else // not defined yet
1335 // find a unique function name
1336 fixPythonName( aFunctionType );
1337 Standard_Integer nb = 0;
1338 do functionName = aFunctionType + "_" + ( nb++ ) + "()";
1339 while ( !functionNameSet.insert( functionName.ToCString() ).second );
1342 TCollection_AsciiString funDef = helper + "def " + functionName + aLongString;
1345 anUpdatedScript += helper + "\n\n" + funDef;
1350 anUpdatedScript.Insert( 1, funDef);
1351 where += funDef.Length();
1354 anUpdatedScript.InsertBefore( where, functionName ); // call function
1357 aValidScript = true;
1359 return anUpdatedScript;
1361 SMESH_CATCH( SMESH::printException );
1363 aValidScript = false;
1367 //=============================================================================
1371 //=============================================================================
1372 TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines (int theStudyID)
1374 TCollection_AsciiString aScript;
1376 // Dump trace of API methods calls
1377 if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
1378 Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[theStudyID];
1379 Standard_Integer istr, aLen = aPythonScript->Length();
1380 for (istr = 1; istr <= aLen; istr++) {
1382 aScript += aPythonScript->Value(istr);
1390 //=============================================================================
1394 //=============================================================================
1395 void SMESH_Gen_i::CleanPythonTrace (int theStudyID)
1397 TCollection_AsciiString aScript;
1399 // Clean trace of API methods calls
1400 if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
1401 myPythonScripts[theStudyID]->Clear();