Version: 9.16.0
SMESH_PythonDump.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
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.
10//
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.
15//
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
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23#ifndef _SMESH_PYTHONDUMP_HXX_
24#define _SMESH_PYTHONDUMP_HXX_
25
26#include "SMESH.hxx"
27
28#include <SALOMEconfig.h>
29#include CORBA_SERVER_HEADER(SMESH_Mesh)
30#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
31#include CORBA_SERVER_HEADER(GEOM_Gen)
32#include CORBA_SERVER_HEADER(SALOMEDS)
33
34#include <TCollection_AsciiString.hxx>
35#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
36
37#include <sstream>
38#include <vector>
39#include <set>
40#include <list>
41
42class SMESH_Gen_i;
44
45// ===========================================================================================
51// ===========================================================================================
52
54{
55public:
67 static void
68 ConvertScript(std::list< TCollection_AsciiString >& theScriptLines,
69 Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
70 Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
71 std::set< TCollection_AsciiString >& theRemovedObjIDs,
72 const bool theHistoricalDump);
73
78 static const char* SmeshpyName() { return "smesh"; }
79 static const char* GenName() { return "smesh"; }
80};
81
82namespace SMESH
83{
84 class FilterLibrary_i;
85 class FilterManager_i;
86 class Filter_i;
87 class Functor_i;
88 class Measurements_i;
89
90 // ===========================================================================================
96 // ===========================================================================================
97
99 {
100 std::vector< std::string > myVals;
102 TVar(CORBA::Double value);
103 TVar(CORBA::Long value);
104 TVar(CORBA::LongLong value);
105 TVar(CORBA::Short value);
106 TVar(const SMESH::double_array& value);
107 // string used to temporary quote variable names in order
108 // not to confuse variables with string arguments
109 static char Quote() { return '$'; }
110 // string preceding an entry of object storing the attribute holding var names
111 static const char* ObjPrefix() { return " # OBJ: "; }
112 };
113
114 // ===========================================================================================
118 // ===========================================================================================
119
121 {
122 std::ostringstream myStream;
123 static size_t myCounter;
124 int myVarsCounter; // counts stored TVar's
125 SMESH_Gen_i *mySmesh = nullptr;
126 public:
127 TPythonDump(SMESH_Gen_i *smesh);
128 TPythonDump();
129
137 virtual ~TPythonDump();
138
147 static void IncrementMyCounter();
148
157 static void DecrementMyCounter();
158
159
161 operator<<(const TVar& theVariableValue);
162
164 operator<<(long int theArg);
165
167 operator<<(int theArg);
168
170 operator<<(long long theArg);
171
173 operator<<(double theArg);
174
176 operator<<(float theArg);
177
179 operator<<(const void* theArg);
180
182 operator<<(const char* theArg);
183
185 operator<<(const SMESH::ElementType& theArg);
186
188 operator<<(const SMESH::GeometryType& theArg);
189
191 operator<<(const SMESH::EntityType& theArg);
192
194 operator<<(const SMESH::long_array& theArg);
195
197 operator<<(const SMESH::smIdType_array& theArg);
198
200 operator<<(const SMESH::double_array& theArg);
201
203 operator<<(const SMESH::string_array& theArg);
204
206 operator<<(const SMESH::nodes_array& theArg);
207
209 operator<<(SMESH::SMESH_Hypothesis_ptr theArg);
210
212 operator<<(SMESH::SMESH_IDSource_ptr theArg);
213
215 operator<<(SALOMEDS::SObject_ptr theArg);
216
218 operator<<(CORBA::Object_ptr theArg);
219
222
225
228
231
234
236 operator<<(SMESH_Gen_i* theArg);
237
240
242 operator<<(const SMESH::AxisStruct & theAxis);
243
245 operator<<(const SMESH::DirStruct & theDir);
246
249
251 operator<<(const TCollection_AsciiString & theArg);
252
254 operator<<(const SMESH::ListOfGroups& theList);
255
257 operator<<(const SMESH::ListOfGroups * theList);
258
260 operator<<(const GEOM::ListOfGO& theList);
261
263 operator<<(const GEOM::ListOfGBO& theList);
264
266 operator<<(const SMESH::ListOfIDSources& theList);
267
269 operator<<(const SMESH::submesh_array& theList);
270
272 operator<<(const SMESH::ListOfHypothesis& theList);
273
276
278 operator<<(const std::string& theArg);
279
280
281 template<class TArray, class TStream>
282 static TStream& DumpArray(const TArray& theArray, TStream & theStream)
283 {
284 if ( theArray.length() == 0 )
285 {
286 theStream << "[]";
287 }
288 else
289 {
290 theStream << "[ ";
291 for (CORBA::ULong i = 1; i <= theArray.length(); i++) {
292 theStream << theArray[i-1];
293 if ( i < theArray.length() )
294 theStream << ", ";
295 }
296 theStream << " ]";
297 }
298 return theStream;
299 }
300
301 static const char* SMESHGenName() { return "smeshgen"; }
302 static const char* MeshEditorName() { return "mesh_editor"; }
303 static const char* NotPublishedObjectName();
304
311 static TCollection_AsciiString LongStringStart(const char* type);
317 static TCollection_AsciiString LongStringEnd();
329 static bool CutoutLongString( TCollection_AsciiString & theText,
330 int & theFrom,
331 TCollection_AsciiString & theLongString,
332 TCollection_AsciiString & theStringType);
333 };
334}
335
336#endif
ostream & operator<<(ostream &OS, const SMDS_MeshElement *e)
Definition: SMDS_MeshElement.cxx:212
#define SMESH_I_EXPORT
Definition: SMESH.hxx:39
Definition: SMESH_Filter_i.hxx:1090
Definition: SMESH_Filter_i.hxx:1128
Definition: SMESH_Filter_i.hxx:1009
Definition: SMESH_Filter_i.hxx:80
Definition: SMESH_Measurements_i.hxx:45
Utility helping in storing SMESH engine calls as python commands.
Definition: SMESH_PythonDump.hxx:121
static const char * SMESHGenName()
Definition: SMESH_PythonDump.hxx:301
int myVarsCounter
Definition: SMESH_PythonDump.hxx:124
static const char * MeshEditorName()
Definition: SMESH_PythonDump.hxx:302
static TStream & DumpArray(const TArray &theArray, TStream &theStream)
Definition: SMESH_PythonDump.hxx:282
static size_t myCounter
Definition: SMESH_PythonDump.hxx:123
std::ostringstream myStream
Definition: SMESH_PythonDump.hxx:122
Tool converting SMESH engine calls into commands defined in smeshBuilder.py.
Definition: SMESH_PythonDump.hxx:54
static const char * GenName()
Definition: SMESH_PythonDump.hxx:79
static const char * SmeshpyName()
Return the name of the python file wrapping IDL API.
Definition: SMESH_PythonDump.hxx:78
static void ConvertScript(std::list< TCollection_AsciiString > &theScriptLines, Resource_DataMapOfAsciiStringAsciiString &theEntry2AccessorMethod, Resource_DataMapOfAsciiStringAsciiString &theObjectNames, std::set< TCollection_AsciiString > &theRemovedObjIDs, const bool theHistoricalDump)
Convert a python script using commands of smeshBuilder.py.
Definition: SMESH_2smeshpy.cxx:546
Definition: SMESH_Gen_i.hxx:99
Definition: SMESH_MeshEditor_i.hxx:50
Definition: SMESH_ControlsClassifier.cxx:39
EntityType
Enumeration of entity type used in mesh info array, it should be synchronised with enum SMDSAbs_Entit...
Definition: SMESH_Mesh.idl:174
sequence< SMESH_subMesh > submesh_array
Definition: SMESH_Mesh.idl:334
sequence< SMESH_IDSource > ListOfIDSources
Definition: SMESH_Mesh.idl:41
sequence< smIdType > smIdType_array
Definition: SMESH_Mesh.idl:45
GeometryType
Enumeration for element geometry type, like SMDSAbs_GeometryType in SMDSAbs_ElementType....
Definition: SMESH_Mesh.idl:144
ElementType
Enumeration for element type, like in SMDS.
Definition: SMESH_Mesh.idl:128
sequence< double > double_array
Definition: SMESH_Mesh.idl:43
sequence< string > string_array
Definition: SMESH_Mesh.idl:46
sequence< SMESH_Hypothesis > ListOfHypothesis
Definition: SMESH_Mesh.idl:37
sequence< SMESH_GroupBase > ListOfGroups
Definition: SMESH_Mesh.idl:39
sequence< PointStruct > nodes_array
Definition: SMESH_Mesh.idl:97
sequence< long > long_array
Definition: SMESH_Mesh.idl:44
Definition: SMESH_Mesh.idl:101
Definition: SMESH_MeshEditor.idl:55
Definition: SMESH_Mesh.idl:99
Definition: SMESH_Mesh.idl:93
Object used to make TPythonDump know that its held value can be a variable.
Definition: SMESH_PythonDump.hxx:99
static char Quote()
Definition: SMESH_PythonDump.hxx:109
bool myIsList
Definition: SMESH_PythonDump.hxx:101
static const char * ObjPrefix()
Definition: SMESH_PythonDump.hxx:111
std::vector< std::string > myVals
Definition: SMESH_PythonDump.hxx:100