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_Hexagonal_Prism: myStream<<"Entity_Hexagonal_Prism"; break;
238 case Entity_Polyhedra: myStream<<"Entity_Polyhedra"; break;
239 case Entity_Quad_Polyhedra: myStream<<"Entity_Quad_Polyhedra"; break;
240 case Entity_Ball: myStream<<"Entity_Ball"; break;
241 case Entity_Last: myStream<<"Entity_Last"; break;
242 default: myStream<<"__UNKNOWN__EntityType: " << theArg;
247 template<class TArray>
248 void DumpArray(const TArray& theArray, TPythonDump & theStream)
250 if ( theArray.length() == 0 )
257 for (CORBA::ULong i = 1; i <= theArray.length(); i++) {
258 theStream << theArray[i-1];
259 if ( i < theArray.length() )
267 TPythonDump::operator<<(const SMESH::long_array& theArg)
269 DumpArray( theArg, *this );
274 TPythonDump::operator<<(const SMESH::double_array& theArg)
276 DumpArray( theArg, *this );
281 TPythonDump::operator<<(const SMESH::nodes_array& theArg)
283 DumpArray( theArg, *this );
288 TPythonDump::operator<<(const SMESH::string_array& theArray)
291 for ( CORBA::ULong i = 1; i <= theArray.length(); i++ ) {
292 myStream << "'" << theArray[i-1] << "'";
293 if ( i < theArray.length() )
302 operator<<(SALOMEDS::SObject_ptr aSObject)
304 if ( !aSObject->_is_nil() ) {
305 CORBA::String_var entry = aSObject->GetID();
306 myStream << entry.in();
309 myStream << theNotPublishedObjectName;
316 operator<<(CORBA::Object_ptr theArg)
318 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
319 SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
320 SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
321 if(!aSObject->_is_nil()) {
322 CORBA::String_var id = aSObject->GetID();
324 } else if ( !CORBA::is_nil(theArg)) {
325 if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object
326 myStream << "smeshObj_" << size_t(theArg);
328 myStream << theNotPublishedObjectName;
337 operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
339 SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
340 SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
341 if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
342 myStream << "hyp_" << theArg->GetId();
350 operator<<(SMESH::SMESH_IDSource_ptr theArg)
352 if ( CORBA::is_nil( theArg ) )
353 return *this << "None";
354 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
355 SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
356 SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
357 if(!aSObject->_is_nil())
359 return *this << aSObject;
361 if ( SMESH::Filter_i* filter = SMESH::DownCast<SMESH::Filter_i*>( theArg ))
363 return *this << filter;
365 if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theArg ))
367 SMESH::SMESH_Mesh_var mesh = theArg->GetMesh();
368 SMESH::long_array_var anElementsId = theArg->GetIDs();
369 SMESH::array_of_ElementType_var types = theArg->GetTypes();
370 SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
371 SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(aStudy,mesh);
372 if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
373 return *this << mesh << ".GetIDSource([], " << type << ")";
375 return *this << mesh << ".GetIDSource(" << anElementsId << ", " << type << ")";
377 return *this << theNotPublishedObjectName;
382 operator<<(SMESH::FilterLibrary_i* theArg)
384 myStream<<"aFilterLibrary"<<theArg;
390 operator<<(SMESH::FilterManager_i* theArg)
392 myStream<<"aFilterManager";
398 operator<<(SMESH::Filter_i* theArg)
400 myStream<<"aFilter"<<theArg;
406 operator<<(SMESH::Functor_i* theArg)
409 FunctorType aFunctorType = theArg->GetFunctorType();
410 switch(aFunctorType) {
411 case FT_AspectRatio: myStream<< "aAspectRatio"; break;
412 case FT_AspectRatio3D: myStream<< "aAspectRatio3D"; break;
413 case FT_Warping: myStream<< "aWarping"; break;
414 case FT_MinimumAngle: myStream<< "aMinimumAngle"; break;
415 case FT_Taper: myStream<< "aTaper"; break;
416 case FT_Skew: myStream<< "aSkew"; break;
417 case FT_Area: myStream<< "aArea"; break;
418 case FT_Volume3D: myStream<< "aVolume3D"; break;
419 case FT_MaxElementLength2D: myStream<< "aMaxElementLength2D"; break;
420 case FT_MaxElementLength3D: myStream<< "aMaxElementLength3D"; break;
421 case FT_FreeBorders: myStream<< "aFreeBorders"; break;
422 case FT_FreeEdges: myStream<< "aFreeEdges"; break;
423 case FT_FreeNodes: myStream<< "aFreeNodes"; break;
424 case FT_FreeFaces: myStream<< "aFreeFaces"; break;
425 case FT_EqualNodes: myStream<< "aEqualNodes"; break;
426 case FT_EqualEdges: myStream<< "aEqualEdges"; break;
427 case FT_EqualFaces: myStream<< "aEqualFaces"; break;
428 case FT_EqualVolumes: myStream<< "aEqualVolumes"; break;
429 case FT_MultiConnection: myStream<< "aMultiConnection"; break;
430 case FT_MultiConnection2D: myStream<< "aMultiConnection2D"; break;
431 case FT_Length: myStream<< "aLength"; break;
432 case FT_Length2D: myStream<< "aLength2D"; break;
433 case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break;
434 case FT_BelongToMeshGroup: myStream<< "aBelongToMeshGroup"; break;
435 case FT_BelongToGeom: myStream<< "aBelongToGeom"; break;
436 case FT_BelongToPlane: myStream<< "aBelongToPlane"; break;
437 case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break;
438 case FT_BelongToGenSurface: myStream<< "aBelongToGenSurface"; break;
439 case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break;
440 case FT_RangeOfIds: myStream<< "aRangeOfIds"; break;
441 case FT_BadOrientedVolume: myStream<< "aBadOrientedVolume"; break;
442 case FT_BareBorderVolume: myStream<< "aBareBorderVolume"; break;
443 case FT_BareBorderFace: myStream<< "aBareBorderFace"; break;
444 case FT_OverConstrainedVolume: myStream<< "aOverConstrainedVolume"; break;
445 case FT_OverConstrainedFace: myStream<< "aOverConstrainedFace"; break;
446 case FT_LinearOrQuadratic: myStream<< "aLinearOrQuadratic"; break;
447 case FT_GroupColor: myStream<< "aGroupColor"; break;
448 case FT_ElemGeomType: myStream<< "aElemGeomType"; break;
449 case FT_EntityType: myStream<< "aEntityType"; break;
450 case FT_CoplanarFaces: myStream<< "aCoplanarFaces"; break;
451 case FT_BallDiameter: myStream<< "aBallDiameter"; break;
452 case FT_ConnectedElements: myStream<< "aConnectedElements"; break;
453 case FT_LessThan: myStream<< "aLessThan"; break;
454 case FT_MoreThan: myStream<< "aMoreThan"; break;
455 case FT_EqualTo: myStream<< "aEqualTo"; break;
456 case FT_LogicalNOT: myStream<< "aLogicalNOT"; break;
457 case FT_LogicalAND: myStream<< "aLogicalAND"; break;
458 case FT_LogicalOR: myStream<< "aLogicalOR"; break;
459 case FT_Undefined: myStream<< "anUndefined"; break;
460 //default: -- commented to have a compilation warning
469 operator<<(SMESH::Measurements_i* theArg)
471 myStream<<"aMeasurements";
476 TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
478 myStream << SMESHGenName(); return *this;
481 TPythonDump& TPythonDump::operator<<(SMESH_MeshEditor_i* theArg)
483 myStream << MeshEditorName() << "_" << ( theArg ? theArg->GetMeshId() : -1 ); return *this;
486 TPythonDump& TPythonDump::operator<<(const TCollection_AsciiString & theStr)
488 myStream << theStr; return *this;
492 TPythonDump& TPythonDump::operator<<(SMESH::MED_VERSION theVersion)
494 switch (theVersion) {
495 case SMESH::MED_V2_1: myStream << "SMESH.MED_V2_1"; break;
496 case SMESH::MED_V2_2: myStream << "SMESH.MED_V2_2"; break;
497 default: myStream << theVersion;
502 TPythonDump& TPythonDump::operator<<(const SMESH::AxisStruct & theAxis)
504 *this << "SMESH.AxisStruct( "
505 << TVar( theAxis.x ) << ", "
506 << TVar( theAxis.y ) << ", "
507 << TVar( theAxis.z ) << ", "
508 << TVar( theAxis.vx ) << ", "
509 << TVar( theAxis.vy ) << ", "
510 << TVar( theAxis.vz ) << " )";
514 TPythonDump& TPythonDump::operator<<(const SMESH::DirStruct & theDir)
516 const SMESH::PointStruct & P = theDir.PS;
517 *this << "SMESH.DirStruct( SMESH.PointStruct ( "
518 << TVar( P.x ) << ", "
519 << TVar( P.y ) << ", "
520 << TVar( P.z ) << " ))";
524 TPythonDump& TPythonDump::operator<<(const SMESH::PointStruct & P)
526 *this << "SMESH.PointStruct ( "
527 << TVar( P.x ) << ", "
528 << TVar( P.y ) << ", "
529 << TVar( P.z ) << " )";
533 TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups& theList)
535 DumpArray( theList, *this );
538 TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups * theList)
540 DumpArray( *theList, *this );
543 TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGO& theList)
545 DumpArray( theList, *this );
548 TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGBO& theList)
550 DumpArray( theList, *this );
553 TPythonDump& TPythonDump::operator<<(const SMESH::ListOfIDSources& theList)
555 DumpArray( theList, *this );
558 TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
560 // dump CoincidentFreeBorders as a list of lists, each enclosed list
561 // contains node IDs of a group of coincident free borders where
562 // each consequent triple of IDs describe a free border: (n1, n2, nLast)
563 // For example [[1, 2, 10, 20, 21, 40], [11, 12, 15, 55, 54, 41]] describes
564 // two groups of coincident free borders, each group including two borders
567 for ( CORBA::ULong i = 0; i < theCFB.coincidentGroups.length(); ++i )
569 const SMESH::FreeBordersGroup& aGRP = theCFB.coincidentGroups[ i ];
570 if ( i ) myStream << ",";
572 for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
574 const SMESH::FreeBorderPart& aPART = aGRP[ iP ];
575 if ( 0 <= aPART.border && aPART.border < (CORBA::Long)theCFB.borders.length() )
577 if ( iP ) myStream << ", ";
578 const SMESH::FreeBorder& aBRD = theCFB.borders[ aPART.border ];
579 myStream << aBRD.nodeIDs[ aPART.node1 ] << ",";
580 myStream << aBRD.nodeIDs[ aPART.node2 ] << ",";
581 myStream << aBRD.nodeIDs[ aPART.nodeLast ];
591 const char* TPythonDump::NotPublishedObjectName()
593 return theNotPublishedObjectName;
596 TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
597 TCollection_AsciiString myLongStringEnd ( "TPythonDump::LongStringEnd" );
599 //================================================================================
601 * \brief Return marker of long string literal beginning
602 * \param type - a name of functionality producing the string literal
603 * \retval TCollection_AsciiString - the marker string to be written into
604 * a raw python script
606 //================================================================================
608 TCollection_AsciiString TPythonDump::LongStringStart(const char* type)
612 (Standard_Integer) strlen(type) +
617 //================================================================================
619 * \brief Return marker of long string literal end
620 * \retval TCollection_AsciiString - the marker string to be written into
621 * a raw python script
623 //================================================================================
625 TCollection_AsciiString TPythonDump::LongStringEnd()
627 return myLongStringEnd;
630 //================================================================================
632 * \brief Cut out a long string literal from a string
633 * \param theText - text possibly containing string literals
634 * \param theFrom - position in the text to search from
635 * \param theLongString - the retrieved literal
636 * \param theStringType - a name of functionality produced the literal
637 * \retval bool - true if a string literal found
639 * The literal is removed from theText; theFrom points position right after
640 * the removed literal
642 //================================================================================
644 bool TPythonDump::CutoutLongString( TCollection_AsciiString & theText,
646 TCollection_AsciiString & theLongString,
647 TCollection_AsciiString & theStringType)
649 if ( theFrom < 1 || theFrom > theText.Length() )
652 // ...script \ beg marker \ \ type \ literal \ end marker \ script...
653 // "theText myLongStringStart7 Pattern!!! SALOME Mesh Pattern file myLongStringEndtextEnd"
654 // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
657 theFrom = theText.Location( myLongStringStart, theFrom, theText.Length() ); // = 09
661 // find where literal begins
662 int literalBeg = theFrom + myLongStringStart.Length(); // = 26
663 char* typeLenStr = (char*) theText.ToCString() + literalBeg - 1; // = "7 Pattern!!! SALO...."
664 int typeLen = atoi ( typeLenStr ); // = 7
665 while ( *typeLenStr != ' ' ) { // look for ' ' after typeLen
666 literalBeg++; // 26 -> 27
669 literalBeg += typeLen + 1; // = 35
670 if ( literalBeg > theText.Length() )
673 // where literal ends (i.e. end marker begins)
674 int literalEnd = theText.Location( myLongStringEnd, literalBeg, theText.Length() ); // = 64
676 literalEnd = theText.Length();
679 theLongString = theText.SubString( literalBeg, literalEnd - 1); // "!!! SALOME Mesh Pattern file "
681 theStringType = theText.SubString( literalBeg - typeLen, literalBeg - 1 ); // "Pattern"
683 literalEnd += myLongStringEnd.Length(); // = 79
684 TCollection_AsciiString textEnd = theText.SubString( literalEnd, theText.Length() ); // "textE..."
685 theText = theText.SubString( 1, theFrom - 1 ) + textEnd;
690 void printException( const char* text )
693 cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << endl;
698 //=======================================================================
699 //function : RemoveTabulation
701 //=======================================================================
702 void RemoveTabulation( TCollection_AsciiString& theScript )
704 std::string aString( theScript.ToCString() );
705 std::string::size_type aPos = 0;
706 while( aPos < aString.length() )
708 aPos = aString.find( "\n\t", aPos );
709 if( aPos == std::string::npos )
711 aString.replace( aPos, 2, "\n" );
714 theScript = aString.c_str();
717 //=======================================================================
718 //function : DumpPython
720 //=======================================================================
721 Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
722 CORBA::Boolean isPublished,
723 CORBA::Boolean isMultiFile,
724 CORBA::Boolean& isValidScript)
726 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
727 if (CORBA::is_nil(aStudy))
728 return new Engines::TMPFile(0);
730 CORBA::String_var compDataType = ComponentDataType();
731 SALOMEDS::SObject_wrap aSO = aStudy->FindComponent( compDataType.in() );
732 if (CORBA::is_nil(aSO))
733 return new Engines::TMPFile(0);
735 // Map study entries to object names
736 Resource_DataMapOfAsciiStringAsciiString aMap;
737 Resource_DataMapOfAsciiStringAsciiString aMapNames;
739 SALOMEDS::ChildIterator_wrap Itr = aStudy->NewChildIterator(aSO);
740 for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
741 SALOMEDS::SObject_wrap aValue = Itr->Value();
742 CORBA::String_var anID = aValue->GetID();
743 CORBA::String_var aName = aValue->GetName();
744 TCollection_AsciiString aGUIName ( (char*) aName.in() );
745 TCollection_AsciiString anEntry ( (char*) anID.in() );
746 if (aGUIName.Length() > 0) {
747 aMapNames.Bind( anEntry, aGUIName );
748 aMap.Bind( anEntry, aGUIName );
752 // Get trace of restored study
753 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
754 SALOMEDS::GenericAttribute_wrap anAttr =
755 aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
757 SALOMEDS::AttributePythonObject_var pyAttr =
758 SALOMEDS::AttributePythonObject::_narrow(anAttr);
759 CORBA::String_var oldValue = pyAttr->GetObject();
760 TCollection_AsciiString aSavedTrace (oldValue.in());
762 // Add trace of API methods calls and replace study entries by names
763 TCollection_AsciiString aScript;
764 aScript += DumpPython_impl(aStudy, aMap, aMapNames, isPublished, isMultiFile,
765 myIsHistoricalPythonDump, isValidScript, aSavedTrace);
767 int aLen = aScript.Length();
768 unsigned char* aBuffer = new unsigned char[aLen+1];
769 strcpy((char*)aBuffer, aScript.ToCString());
771 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
772 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
774 bool hasNotPublishedObjects = aScript.Location( SMESH::theNotPublishedObjectName, 1, aLen);
775 isValidScript = isValidScript && !hasNotPublishedObjects;
777 return aStreamFile._retn();
780 //=============================================================================
784 //=============================================================================
785 void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString)
787 if (myPythonScripts.find(theStudyID) == myPythonScripts.end()) {
788 myPythonScripts[theStudyID] = new TColStd_HSequenceOfAsciiString;
790 myPythonScripts[theStudyID]->Append(theString);
793 //=============================================================================
795 * RemoveLastFromPythonScript
797 //=============================================================================
798 void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID)
800 if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
801 int aLen = myPythonScripts[theStudyID]->Length();
802 myPythonScripts[theStudyID]->Remove(aLen);
806 //=======================================================================
807 //function : SavePython
809 //=======================================================================
810 void SMESH_Gen_i::SavePython (SALOMEDS::Study_ptr theStudy)
812 // Dump trace of API methods calls
813 TCollection_AsciiString aScript = GetNewPythonLines(theStudy->StudyId());
815 // Check contents of PythonObject attribute
816 CORBA::String_var compDataType = ComponentDataType();
817 SALOMEDS::SObject_wrap aSO = theStudy->FindComponent( compDataType.in() );
818 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
819 SALOMEDS::GenericAttribute_wrap anAttr =
820 aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
822 SALOMEDS::AttributePythonObject_var pyAttr =
823 SALOMEDS::AttributePythonObject::_narrow(anAttr);
824 CORBA::String_var oldValue = pyAttr->GetObject();
825 TCollection_AsciiString oldScript (oldValue.in());
827 if (oldScript.Length() > 0) {
829 oldScript += aScript;
834 // Store in PythonObject attribute
835 pyAttr->SetObject(oldScript.ToCString(), 1);
837 // Clean trace of API methods calls
838 CleanPythonTrace(theStudy->StudyId());
845 //=============================================================================
847 * FindEntries: Returns a sequence of start/end positions of entries in the string
849 //=============================================================================
850 Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
852 Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
853 Standard_Integer aLen = theString.Length();
854 Standard_Boolean isFound = Standard_False;
856 char* arr = (char*) theString.ToCString();
857 Standard_Integer i = 0, j;
862 if ( isdigit( c )) { //Is digit?
864 isFound = Standard_False;
865 while((j < aLen) && ( isdigit(c) || c == ':' )) { //Check if it is an entry
867 if(c == ':') isFound = Standard_True;
871 int prev = (i < 1) ? 0 : (int)arr[i - 1];
872 // to distinguish from a sketcher command:
873 // last char should be a digit, not ":",
874 // previous char should not be '"'.
875 if (arr[j-2] != ':' && prev != '"') {
876 aSeq->Append(i+1); // +1 because AsciiString starts from 1
890 //================================================================================
892 * \brief Make a string be a valid python name
893 * \param aName - a string to fix
894 * \retval bool - true if aName was not modified
896 //================================================================================
898 bool fixPythonName(TCollection_AsciiString & aName)
900 bool isValidName = true;
901 int nbUnderscore = 0;
903 // replace not allowed chars by underscore
904 const char* name = aName.ToCString();
905 for ( p = 0; name[p]; ++p ) {
906 if ( !isalnum( name[p] ) && name[p] != '_' )
908 if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_')
910 aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end
912 name = aName.ToCString();
916 aName.SetValue( p+1, '_');
922 // aName must not start with a digit
923 if ( aName.IsIntegerValue() ) {
924 aName.Insert( 1, 'a' );
927 // shorten names like CartesianParameters3D_400_400_400_1000000_1
928 const int nbAllowedUnderscore = 3; /* changed from 2 to 3 by an user request
929 posted to SALOME Forum */
930 if ( aName.Length() > 20 && nbUnderscore > nbAllowedUnderscore )
932 p = aName.Location( "_", 20, aName.Length());
939 //================================================================================
941 * \brief Return Python module names of available plug-ins.
943 //================================================================================
945 std::vector<std::string> getPluginNames()
947 std::vector<std::string> pluginNames;
948 std::vector< std::string > xmlPaths = SMESH_Gen::GetPluginXMLPaths();
949 LDOMParser xmlParser;
950 for ( size_t i = 0; i < xmlPaths.size(); ++i )
952 bool error = xmlParser.parse( xmlPaths[i].c_str() );
955 TCollection_AsciiString data;
956 INFOS( xmlParser.GetError(data) );
959 // <meshers-group name="Standard Meshers"
960 // resources="StdMeshers"
961 // idl-module="StdMeshers"
962 // server-lib="StdMeshersEngine"
963 // gui-lib="StdMeshersGUI">
964 LDOM_Document xmlDoc = xmlParser.getDocument();
965 LDOM_NodeList nodeList = xmlDoc.getElementsByTagName( "meshers-group" );
966 for ( int i = 0; i < nodeList.getLength(); ++i )
968 LDOM_Node node = nodeList.item( i );
969 LDOM_Element& elem = (LDOM_Element&) node;
970 LDOMString idlModule = elem.getAttribute( "idl-module" );
971 if ( strlen( idlModule.GetString() ) > 0 )
972 pluginNames.push_back( idlModule.GetString() );
979 //================================================================================
981 * \brief Createa a Dump Python script
982 * \param [in] theStudy - the study to dump
983 * \param [in,out] theObjectNames - map of an entry to a study and python name
984 * \param [in] theNames - - map of an entry to a study name
985 * \param [in] isPublished - \c true if dump of object publication in study is needed
986 * \param [in] isMultiFile - \c true if dump of each module goes to a separate file
987 * \param [in] isHistoricalDump - \c true if removed object should be dumped
988 * \param [out] aValidScript - returns \c true if the returned script seems valid
989 * \param [in,out] theSavedTrace - the dump stored in the study. It's cleared to
990 * decrease memory usage.
991 * \return TCollection_AsciiString - the result dump script.
993 //================================================================================
995 TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
996 (SALOMEDS::Study_ptr theStudy,
997 Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
998 Resource_DataMapOfAsciiStringAsciiString& theNames,
1001 bool isHistoricalDump,
1003 TCollection_AsciiString& theSavedTrace)
1006 const int aStudyID = theStudy->StudyId();
1008 const TCollection_AsciiString aSmeshpy ( SMESH_2smeshpy::SmeshpyName() );
1009 const TCollection_AsciiString aSMESHGen( SMESH_2smeshpy::GenName() );
1010 const TCollection_AsciiString anOldGen ( SMESH::TPythonDump::SMESHGenName() );
1011 const TCollection_AsciiString helper; // to comfortably append C strings to TCollection_AsciiString
1012 const TCollection_AsciiString tab( isMultiFile ? "\t" : "" ), nt = helper + "\n" + tab;
1014 std::list< TCollection_AsciiString > lines; // lines of a script
1015 std::list< TCollection_AsciiString >::iterator linesIt;
1018 lines.push_back( aSMESHGen + " = smeshBuilder.New(theStudy)" );
1020 lines.push_back( aSMESHGen + " = smeshBuilder.New(None)" );
1021 lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" );
1022 lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );
1024 // Treat dump trace of restored study
1025 if (theSavedTrace.Length() > 0)
1027 linesIt = --lines.end();
1028 // Split theSavedTrace into lines
1029 int from = 1, end = theSavedTrace.Length(), to;
1030 while ( from < end && ( to = theSavedTrace.Location( "\n", from, end )))
1032 if ( theSavedTrace.ToCString()[from-1] == '\t' )
1035 lines.push_back( theSavedTrace.SubString( from, to - 1 ));
1038 // For the convertion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen
1039 // was replaces with "smeshgen" (==TPythonDump::SMESHGenName()).
1040 // Change "smesh" -> "smeshgen" in the trace saved before passage to smeshBuilder.py API
1042 theSavedTrace.Location( anOldGen + ".", 1, theSavedTrace.Length() );
1043 theSavedTrace.Clear();
1044 if ( !isNewVersion )
1046 const TCollection_AsciiString aSmeshCall ( "smesh." ), gen( "gen" );
1048 for ( ++linesIt; linesIt != lines.end(); ++linesIt )
1050 TCollection_AsciiString& aSavedLine = *linesIt;
1051 end = aSavedLine.Length(), from = 1;
1052 while ( from < end && ( beg = aSavedLine.Location( aSmeshCall, from, end )))
1054 char charBefore = ( beg == 1 ) ? ' ' : aSavedLine.Value( beg - 1 );
1055 if ( isspace( charBefore ) || charBefore == '=' ) { // "smesh." is not a part of a long word
1056 aSavedLine.Insert( beg + aSmeshCall.Length() - 1, gen );// "smesh" -> "smeshgen"
1057 end += gen.Length();
1059 from = beg + aSmeshCall.Length();
1065 // Add new dump trace of API methods calls to script lines
1066 if (myPythonScripts.find( aStudyID ) != myPythonScripts.end())
1068 Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[ aStudyID ];
1069 Standard_Integer istr, aLen = aPythonScript->Length();
1070 for (istr = 1; istr <= aLen; istr++)
1071 lines.push_back( aPythonScript->Value( istr ));
1074 // Convert IDL API calls into smeshBuilder.py API.
1075 // Some objects are wrapped with python classes and
1076 // Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects
1077 Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
1078 std::set< TCollection_AsciiString > aRemovedObjIDs;
1079 if ( !getenv("NO_2smeshpy_conversion"))
1080 SMESH_2smeshpy::ConvertScript( lines, anEntry2AccessorMethod,
1081 theObjectNames, aRemovedObjIDs,
1082 theStudy, isHistoricalDump );
1084 bool importGeom = false;
1085 GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
1087 // Add names of GEOM objects to theObjectNames to exclude same names of SMESH objects
1088 GEOM::string_array_var aGeomNames = geom->GetAllDumpNames();
1089 int ign = 0, nbgn = aGeomNames->length();
1090 for (; ign < nbgn; ign++) {
1091 TCollection_AsciiString aName = aGeomNames[ign].in();
1092 theObjectNames.Bind(aName, "1");
1096 TCollection_AsciiString anUpdatedScript;
1098 Resource_DataMapOfAsciiStringAsciiString mapRemoved;
1099 Resource_DataMapOfAsciiStringAsciiString mapEntries; // names and entries present in anUpdatedScript
1100 Standard_Integer objectCounter = 0;
1101 TCollection_AsciiString anEntry, aName, aGUIName, aBaseName("smeshObj_");
1103 // Treat every script line and add it to anUpdatedScript
1104 for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
1106 TCollection_AsciiString& aLine = *linesIt;
1107 anUpdatedScript += tab;
1109 //Replace characters used instead of quote marks to quote notebook variables
1111 while (( pos = aLine.Location( 1, SMESH::TVar::Quote(), pos, aLine.Length() )))
1112 aLine.SetValue( pos, '"' );
1114 // Find entries to be replaced by names
1115 Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aLine);
1116 const Standard_Integer aSeqLen = aSeq->Length();
1117 Standard_Integer aStart = 1;
1118 for (Standard_Integer i = 1; i <= aSeqLen; i += 2)
1120 if ( aStart < aSeq->Value(i) )
1121 anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry
1122 anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) );
1123 // is a GEOM object?
1124 CORBA::String_var geomName = geom->GetDumpName( anEntry.ToCString() );
1125 if ( !geomName.in() || !geomName.in()[0] ) {
1126 // is a SMESH object
1127 if ( theObjectNames.IsBound( anEntry )) {
1128 // The Object is in Study
1129 aName = theObjectNames.Find( anEntry );
1130 // check validity of aName
1131 bool isValidName = fixPythonName( aName );
1132 if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
1133 // diff objects have same name - make a new name by appending a digit
1134 TCollection_AsciiString aName2;
1135 Standard_Integer i = 0;
1137 aName2 = aName + "_" + ++i;
1138 } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
1140 isValidName = false;
1143 theObjectNames(anEntry) = aName;
1145 if ( aLine.Value(1) != '#' )
1146 mapEntries.Bind(anEntry, aName);
1152 aName = aBaseName + (++objectCounter);
1153 } while (theObjectNames.IsBound(aName));
1155 if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
1156 mapRemoved.Bind(anEntry, aName);
1158 theObjectNames.Bind(anEntry, aName);
1160 theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
1164 aName = geomName.in();
1167 anUpdatedScript += aName;
1168 aStart = aSeq->Value(i + 1) + 1;
1170 } // loop on entries within aLine
1173 anUpdatedScript += aLine;
1174 else if ( aSeq->Value( aSeqLen ) < aLine.Length() )
1175 anUpdatedScript += aLine.SubString( aSeq->Value(aSeqLen) + 1, aLine.Length() );
1177 anUpdatedScript += '\n';
1180 // Make an initial part of aSript
1182 TCollection_AsciiString initPart = "import ";
1184 initPart += "salome, ";
1185 initPart += " SMESH, SALOMEDS\n";
1186 initPart += "from salome.smesh import smeshBuilder\n";
1187 if ( importGeom && isMultiFile )
1189 initPart += ("\n## import GEOM dump file ## \n"
1190 "import string, os, sys, re, inspect\n"
1191 "thisFile = inspect.getfile( inspect.currentframe() )\n"
1192 "thisModule = os.path.splitext( os.path.basename( thisFile ))[0]\n"
1193 "sys.path.insert( 0, os.path.dirname( thisFile ))\n"
1194 "exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",thisModule)+\" import *\")\n\n");
1196 // import python files corresponding to plugins if they are used in anUpdatedScript
1198 TCollection_AsciiString importStr;
1199 std::vector<std::string> pluginNames = getPluginNames();
1200 for ( size_t i = 0; i < pluginNames.size(); ++i )
1202 // Convert access to plugin members:
1203 // e.g. StdMeshers.QUAD_REDUCED -> StdMeshersBuilder.QUAD_REDUCED
1204 TCollection_AsciiString pluginAccess = (pluginNames[i] + ".").c_str() ;
1205 int iFrom = 1, iPos;
1206 while (( iPos = anUpdatedScript.Location( pluginAccess, iFrom, anUpdatedScript.Length() )))
1208 anUpdatedScript.Insert( iPos + pluginNames[i].size(), "Builder" );
1209 iFrom = iPos + pluginNames[i].size() + 8;
1211 // if any plugin member is used, import the plugin
1213 importStr += ( helper + "\n" "from salome." + pluginNames[i].c_str() +
1214 " import " + pluginNames[i].c_str() +"Builder" );
1216 if ( !importStr.IsEmpty() )
1217 initPart += importStr + "\n";
1221 initPart += "def RebuildData(theStudy):";
1224 anUpdatedScript.Prepend( initPart );
1226 // Make a final part of aScript
1228 // Dump object removal
1229 TCollection_AsciiString removeObjPart;
1230 if ( !mapRemoved.IsEmpty() ) {
1231 removeObjPart += nt + "## some objects were removed";
1232 removeObjPart += nt + "aStudyBuilder = theStudy.NewBuilder()";
1233 Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapRemovedIt;
1234 for ( mapRemovedIt.Initialize( mapRemoved ); mapRemovedIt.More(); mapRemovedIt.Next() ) {
1235 aName = mapRemovedIt.Value(); // python name
1236 anEntry = mapRemovedIt.Key();
1237 removeObjPart += nt + "SO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(";
1238 removeObjPart += aName;
1239 // for object wrapped by class of smeshBuilder.py
1240 if ( anEntry2AccessorMethod.IsBound( anEntry ) )
1241 removeObjPart += helper + "." + anEntry2AccessorMethod( anEntry );
1242 removeObjPart += helper + "))" + nt + "if SO: aStudyBuilder.RemoveObjectWithChildren(SO)";
1247 TCollection_AsciiString setNamePart;
1248 Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapEntriesIt;
1249 for ( mapEntriesIt.Initialize( mapEntries ); mapEntriesIt.More(); mapEntriesIt.Next() )
1251 anEntry = mapEntriesIt.Key();
1252 aName = mapEntriesIt.Value(); // python name
1253 if ( theNames.IsBound( anEntry ))
1255 aGUIName = theNames.Find(anEntry);
1256 aGUIName.RemoveAll('\''); // remove a quote from a name (issue 22360)
1257 setNamePart += nt + aSMESHGen + ".SetName(" + aName;
1258 if ( anEntry2AccessorMethod.IsBound( anEntry ) )
1259 setNamePart += helper + "." + anEntry2AccessorMethod( anEntry );
1260 setNamePart += helper + ", '" + aGUIName + "')";
1263 if ( !setNamePart.IsEmpty() )
1265 setNamePart.Insert( 1, nt + "## Set names of Mesh objects" );
1268 // Store visual properties of displayed objects
1270 TCollection_AsciiString visualPropertiesPart;
1273 //Output the script that sets up the visual parameters.
1274 CORBA::String_var compDataType = ComponentDataType();
1275 CORBA::String_var script = theStudy->GetDefaultScript( compDataType.in(), tab.ToCString() );
1276 if ( script.in() && script.in()[0] ) {
1277 visualPropertiesPart += nt + "### Store presentation parameters of displayed objects\n";
1278 visualPropertiesPart += script.in();
1282 anUpdatedScript += removeObjPart + '\n' + setNamePart + '\n' + visualPropertiesPart;
1289 "\nif __name__ == '__main__':"
1290 "\n\tSMESH_RebuildData = RebuildData"
1291 "\n\texec('import '+re.sub('SMESH$','GEOM',thisModule)+' as GEOM_dump')"
1292 "\n\tGEOM_dump.RebuildData( salome.myStudy )"
1293 "\n\texec('from '+re.sub('SMESH$','GEOM',thisModule)+' import * ')"
1294 "\n\tSMESH_RebuildData( salome.myStudy )";
1296 anUpdatedScript += "\n";
1298 // no need now as we use 'tab' and 'nt' variables depending on isMultiFile
1299 // if( !isMultiFile ) // remove unnecessary tabulation
1300 // RemoveTabulation( anUpdatedScript );
1302 // -----------------------------------------------------------------
1303 // put string literals describing patterns into separate functions
1304 // -----------------------------------------------------------------
1306 TCollection_AsciiString aLongString, aFunctionType;
1308 std::set< std::string > functionNameSet;
1309 while ( SMESH::TPythonDump::CutoutLongString( anUpdatedScript, where, aLongString, aFunctionType ))
1311 // make a python string literal
1312 aLongString.Prepend(":\n\treturn '''\n");
1313 aLongString += "\n\t'''\n\tpass\n";
1315 TCollection_AsciiString functionName;
1317 // check if the function returning this literal is already defined
1318 int posAlready = anUpdatedScript.Location( aLongString, where, anUpdatedScript.Length() );
1319 if ( posAlready ) // already defined
1321 // find the function name
1322 int functBeg = posAlready;
1323 char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def fuction()"
1324 while ( *script != ' ' ) {
1328 functBeg++; // do not take ' '
1329 posAlready--; // do not take ':'
1330 functionName = anUpdatedScript.SubString( functBeg, posAlready );
1332 else // not defined yet
1334 // find a unique function name
1335 fixPythonName( aFunctionType );
1336 Standard_Integer nb = 0;
1337 do functionName = aFunctionType + "_" + ( nb++ ) + "()";
1338 while ( !functionNameSet.insert( functionName.ToCString() ).second );
1341 TCollection_AsciiString funDef = helper + "def " + functionName + aLongString;
1344 anUpdatedScript += helper + "\n\n" + funDef;
1349 anUpdatedScript.Insert( 1, funDef);
1350 where += funDef.Length();
1353 anUpdatedScript.InsertBefore( where, functionName ); // call function
1356 aValidScript = true;
1358 return anUpdatedScript;
1360 SMESH_CATCH( SMESH::printException );
1362 aValidScript = false;
1366 //=============================================================================
1370 //=============================================================================
1371 TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines (int theStudyID)
1373 TCollection_AsciiString aScript;
1375 // Dump trace of API methods calls
1376 if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
1377 Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[theStudyID];
1378 Standard_Integer istr, aLen = aPythonScript->Length();
1379 for (istr = 1; istr <= aLen; istr++) {
1381 aScript += aPythonScript->Value(istr);
1389 //=============================================================================
1393 //=============================================================================
1394 void SMESH_Gen_i::CleanPythonTrace (int theStudyID)
1396 TCollection_AsciiString aScript;
1398 // Clean trace of API methods calls
1399 if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
1400 myPythonScripts[theStudyID]->Clear();