Salome HOME
Merge from V5_1_2_BR branch (14 July 2009)
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, 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.
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 #  File   : smesh.py
23 #  Author : Francis KLOSS, OCC
24 #  Module : SMESH
25 #
26 """
27  \namespace smesh
28  \brief Module smesh
29 """
30
31 ## @defgroup l1_auxiliary Auxiliary methods and structures
32 ## @defgroup l1_creating  Creating meshes
33 ## @{
34 ##   @defgroup l2_impexp     Importing and exporting meshes
35 ##   @defgroup l2_construct  Constructing meshes
36 ##   @defgroup l2_algorithms Defining Algorithms
37 ##   @{
38 ##     @defgroup l3_algos_basic   Basic meshing algorithms
39 ##     @defgroup l3_algos_proj    Projection Algorithms
40 ##     @defgroup l3_algos_radialp Radial Prism
41 ##     @defgroup l3_algos_segmarv Segments around Vertex
42 ##     @defgroup l3_algos_3dextr  3D extrusion meshing algorithm
43
44 ##   @}
45 ##   @defgroup l2_hypotheses Defining hypotheses
46 ##   @{
47 ##     @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
48 ##     @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
49 ##     @defgroup l3_hypos_maxvol Max Element Volume hypothesis
50 ##     @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
51 ##     @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
52 ##     @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
53 ##     @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
54 ##     @defgroup l3_hypos_additi Additional Hypotheses
55
56 ##   @}
57 ##   @defgroup l2_submeshes Constructing submeshes
58 ##   @defgroup l2_compounds Building Compounds
59 ##   @defgroup l2_editing   Editing Meshes
60
61 ## @}
62 ## @defgroup l1_meshinfo  Mesh Information
63 ## @defgroup l1_controls  Quality controls and Filtering
64 ## @defgroup l1_grouping  Grouping elements
65 ## @{
66 ##   @defgroup l2_grps_create Creating groups
67 ##   @defgroup l2_grps_edit   Editing groups
68 ##   @defgroup l2_grps_operon Using operations on groups
69 ##   @defgroup l2_grps_delete Deleting Groups
70
71 ## @}
72 ## @defgroup l1_modifying Modifying meshes
73 ## @{
74 ##   @defgroup l2_modif_add      Adding nodes and elements
75 ##   @defgroup l2_modif_del      Removing nodes and elements
76 ##   @defgroup l2_modif_edit     Modifying nodes and elements
77 ##   @defgroup l2_modif_renumber Renumbering nodes and elements
78 ##   @defgroup l2_modif_trsf     Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ##   @defgroup l2_modif_movenode Moving nodes
80 ##   @defgroup l2_modif_throughp Mesh through point
81 ##   @defgroup l2_modif_invdiag  Diagonal inversion of elements
82 ##   @defgroup l2_modif_unitetri Uniting triangles
83 ##   @defgroup l2_modif_changori Changing orientation of elements
84 ##   @defgroup l2_modif_cutquadr Cutting quadrangles
85 ##   @defgroup l2_modif_smooth   Smoothing
86 ##   @defgroup l2_modif_extrurev Extrusion and Revolution
87 ##   @defgroup l2_modif_patterns Pattern mapping
88 ##   @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
89
90 ## @}
91
92 import salome
93 import geompyDC
94
95 import SMESH # This is necessary for back compatibility
96 from   SMESH import *
97
98 import StdMeshers
99
100 import SALOME
101
102 # import NETGENPlugin module if possible
103 noNETGENPlugin = 0
104 try:
105     import NETGENPlugin
106 except ImportError:
107     noNETGENPlugin = 1
108     pass
109
110 ## @addtogroup l1_auxiliary
111 ## @{
112
113 # Types of algorithms
114 REGULAR    = 1
115 PYTHON     = 2
116 COMPOSITE  = 3
117 SOLE       = 0
118 SIMPLE     = 1
119
120 MEFISTO       = 3
121 NETGEN        = 4
122 GHS3D         = 5
123 FULL_NETGEN   = 6
124 NETGEN_2D     = 7
125 NETGEN_1D2D   = NETGEN
126 NETGEN_1D2D3D = FULL_NETGEN
127 NETGEN_FULL   = FULL_NETGEN
128 Hexa    = 8
129 Hexotic = 9
130 BLSURF  = 10
131 GHS3DPRL = 11
132
133 # MirrorType enumeration
134 POINT = SMESH_MeshEditor.POINT
135 AXIS =  SMESH_MeshEditor.AXIS
136 PLANE = SMESH_MeshEditor.PLANE
137
138 # Smooth_Method enumeration
139 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
140 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
141
142 # Fineness enumeration (for NETGEN)
143 VeryCoarse = 0
144 Coarse     = 1
145 Moderate   = 2
146 Fine       = 3
147 VeryFine   = 4
148 Custom     = 5
149
150 # Optimization level of GHS3D
151 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
152
153 # Topology treatment way of BLSURF
154 FromCAD, PreProcess, PreProcessPlus = 0,1,2
155
156 # Element size flag of BLSURF
157 DefaultSize, DefaultGeom, Custom = 0,0,1
158
159 PrecisionConfusion = 1e-07
160
161 ## Converts an angle from degrees to radians
162 def DegreesToRadians(AngleInDegrees):
163     from math import pi
164     return AngleInDegrees * pi / 180.0
165
166 # Salome notebook variable separator
167 var_separator = ":"
168
169 # Parametrized substitute for PointStruct
170 class PointStructStr:
171
172     x = 0
173     y = 0
174     z = 0
175     xStr = ""
176     yStr = ""
177     zStr = ""
178
179     def __init__(self, xStr, yStr, zStr):
180         self.xStr = xStr
181         self.yStr = yStr
182         self.zStr = zStr
183         if isinstance(xStr, str) and notebook.isVariable(xStr):
184             self.x = notebook.get(xStr)
185         else:
186             self.x = xStr
187         if isinstance(yStr, str) and notebook.isVariable(yStr):
188             self.y = notebook.get(yStr)
189         else:
190             self.y = yStr
191         if isinstance(zStr, str) and notebook.isVariable(zStr):
192             self.z = notebook.get(zStr)
193         else:
194             self.z = zStr
195
196 # Parametrized substitute for PointStruct (with 6 parameters)
197 class PointStructStr6:
198
199     x1 = 0
200     y1 = 0
201     z1 = 0
202     x2 = 0
203     y2 = 0
204     z2 = 0
205     xStr1 = ""
206     yStr1 = ""
207     zStr1 = ""
208     xStr2 = ""
209     yStr2 = ""
210     zStr2 = ""
211
212     def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
213         self.x1Str = x1Str
214         self.x2Str = x2Str
215         self.y1Str = y1Str
216         self.y2Str = y2Str
217         self.z1Str = z1Str
218         self.z2Str = z2Str
219         if isinstance(x1Str, str) and notebook.isVariable(x1Str):
220             self.x1 = notebook.get(x1Str)
221         else:
222             self.x1 = x1Str
223         if isinstance(x2Str, str) and notebook.isVariable(x2Str):
224             self.x2 = notebook.get(x2Str)
225         else:
226             self.x2 = x2Str
227         if isinstance(y1Str, str) and notebook.isVariable(y1Str):
228             self.y1 = notebook.get(y1Str)
229         else:
230             self.y1 = y1Str
231         if isinstance(y2Str, str) and notebook.isVariable(y2Str):
232             self.y2 = notebook.get(y2Str)
233         else:
234             self.y2 = y2Str
235         if isinstance(z1Str, str) and notebook.isVariable(z1Str):
236             self.z1 = notebook.get(z1Str)
237         else:
238             self.z1 = z1Str
239         if isinstance(z2Str, str) and notebook.isVariable(z2Str):
240             self.z2 = notebook.get(z2Str)
241         else:
242             self.z2 = z2Str
243
244 # Parametrized substitute for AxisStruct
245 class AxisStructStr:
246
247     x = 0
248     y = 0
249     z = 0
250     dx = 0
251     dy = 0
252     dz = 0
253     xStr = ""
254     yStr = ""
255     zStr = ""
256     dxStr = ""
257     dyStr = ""
258     dzStr = ""
259
260     def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
261         self.xStr = xStr
262         self.yStr = yStr
263         self.zStr = zStr
264         self.dxStr = dxStr
265         self.dyStr = dyStr
266         self.dzStr = dzStr
267         if isinstance(xStr, str) and notebook.isVariable(xStr):
268             self.x = notebook.get(xStr)
269         else:
270             self.x = xStr
271         if isinstance(yStr, str) and notebook.isVariable(yStr):
272             self.y = notebook.get(yStr)
273         else:
274             self.y = yStr
275         if isinstance(zStr, str) and notebook.isVariable(zStr):
276             self.z = notebook.get(zStr)
277         else:
278             self.z = zStr
279         if isinstance(dxStr, str) and notebook.isVariable(dxStr):
280             self.dx = notebook.get(dxStr)
281         else:
282             self.dx = dxStr
283         if isinstance(dyStr, str) and notebook.isVariable(dyStr):
284             self.dy = notebook.get(dyStr)
285         else:
286             self.dy = dyStr
287         if isinstance(dzStr, str) and notebook.isVariable(dzStr):
288             self.dz = notebook.get(dzStr)
289         else:
290             self.dz = dzStr
291
292 # Parametrized substitute for DirStruct
293 class DirStructStr:
294
295     def __init__(self, pointStruct):
296         self.pointStruct = pointStruct
297
298 # Returns list of variable values from salome notebook
299 def ParsePointStruct(Point):
300     Parameters = 2*var_separator
301     if isinstance(Point, PointStructStr):
302         Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
303         Point = PointStruct(Point.x, Point.y, Point.z)
304     return Point, Parameters
305
306 # Returns list of variable values from salome notebook
307 def ParseDirStruct(Dir):
308     Parameters = 2*var_separator
309     if isinstance(Dir, DirStructStr):
310         pntStr = Dir.pointStruct
311         if isinstance(pntStr, PointStructStr6):
312             Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
313             Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator 
314             Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
315             Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
316         else:
317             Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
318             Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
319         Dir = DirStruct(Point)
320     return Dir, Parameters
321
322 # Returns list of variable values from salome notebook
323 def ParseAxisStruct(Axis):
324     Parameters = 5*var_separator
325     if isinstance(Axis, AxisStructStr):
326         Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
327         Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
328         Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
329     return Axis, Parameters
330
331 ## Return list of variable values from salome notebook
332 def ParseAngles(list):
333     Result = []
334     Parameters = ""
335     for parameter in list:
336         if isinstance(parameter,str) and notebook.isVariable(parameter):
337             Result.append(DegreesToRadians(notebook.get(parameter)))
338             pass
339         else:
340             Result.append(parameter)
341             pass
342         
343         Parameters = Parameters + str(parameter)
344         Parameters = Parameters + var_separator
345         pass
346     Parameters = Parameters[:len(Parameters)-1]
347     return Result, Parameters
348     
349 def IsEqual(val1, val2, tol=PrecisionConfusion):
350     if abs(val1 - val2) < tol:
351         return True
352     return False
353
354 NO_NAME = "NoName"
355
356 ## Gets object name
357 def GetName(obj):
358     ior  = salome.orb.object_to_string(obj)
359     sobj = salome.myStudy.FindObjectIOR(ior)
360     if sobj is None:
361         return NO_NAME
362     else:
363         attr = sobj.FindAttribute("AttributeName")[1]
364         return attr.Value()
365
366 ## Prints error message if a hypothesis was not assigned.
367 def TreatHypoStatus(status, hypName, geomName, isAlgo):
368     if isAlgo:
369         hypType = "algorithm"
370     else:
371         hypType = "hypothesis"
372         pass
373     if status == HYP_UNKNOWN_FATAL :
374         reason = "for unknown reason"
375     elif status == HYP_INCOMPATIBLE :
376         reason = "this hypothesis mismatches the algorithm"
377     elif status == HYP_NOTCONFORM :
378         reason = "a non-conform mesh would be built"
379     elif status == HYP_ALREADY_EXIST :
380         reason = hypType + " of the same dimension is already assigned to this shape"
381     elif status == HYP_BAD_DIM :
382         reason = hypType + " mismatches the shape"
383     elif status == HYP_CONCURENT :
384         reason = "there are concurrent hypotheses on sub-shapes"
385     elif status == HYP_BAD_SUBSHAPE :
386         reason = "the shape is neither the main one, nor its subshape, nor a valid group"
387     elif status == HYP_BAD_GEOMETRY:
388         reason = "geometry mismatches the expectation of the algorithm"
389     elif status == HYP_HIDDEN_ALGO:
390         reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
391     elif status == HYP_HIDING_ALGO:
392         reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
393     elif status == HYP_NEED_SHAPE:
394         reason = "Algorithm can't work without shape"
395     else:
396         return
397     hypName = '"' + hypName + '"'
398     geomName= '"' + geomName+ '"'
399     if status < HYP_UNKNOWN_FATAL:
400         print hypName, "was assigned to",    geomName,"but", reason
401     else:
402         print hypName, "was not assigned to",geomName,":", reason
403         pass
404
405 # end of l1_auxiliary
406 ## @}
407
408 # All methods of this class are accessible directly from the smesh.py package.
409 class smeshDC(SMESH._objref_SMESH_Gen):
410
411     ## Sets the current study and Geometry component
412     #  @ingroup l1_auxiliary
413     def init_smesh(self,theStudy,geompyD):
414         self.SetCurrentStudy(theStudy,geompyD)
415
416     ## Creates an empty Mesh. This mesh can have an underlying geometry.
417     #  @param obj the Geometrical object on which the mesh is built. If not defined,
418     #             the mesh will have no underlying geometry.
419     #  @param name the name for the new mesh.
420     #  @return an instance of Mesh class.
421     #  @ingroup l2_construct
422     def Mesh(self, obj=0, name=0):
423       return Mesh(self,self.geompyD,obj,name)
424
425     ## Returns a long value from enumeration
426     #  Should be used for SMESH.FunctorType enumeration
427     #  @ingroup l1_controls
428     def EnumToLong(self,theItem):
429         return theItem._v
430
431     ## Gets PointStruct from vertex
432     #  @param theVertex a GEOM object(vertex)
433     #  @return SMESH.PointStruct
434     #  @ingroup l1_auxiliary
435     def GetPointStruct(self,theVertex):
436         [x, y, z] = self.geompyD.PointCoordinates(theVertex)
437         return PointStruct(x,y,z)
438
439     ## Gets DirStruct from vector
440     #  @param theVector a GEOM object(vector)
441     #  @return SMESH.DirStruct
442     #  @ingroup l1_auxiliary
443     def GetDirStruct(self,theVector):
444         vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
445         if(len(vertices) != 2):
446             print "Error: vector object is incorrect."
447             return None
448         p1 = self.geompyD.PointCoordinates(vertices[0])
449         p2 = self.geompyD.PointCoordinates(vertices[1])
450         pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
451         dirst = DirStruct(pnt)
452         return dirst
453
454     ## Makes DirStruct from a triplet
455     #  @param x,y,z vector components
456     #  @return SMESH.DirStruct
457     #  @ingroup l1_auxiliary
458     def MakeDirStruct(self,x,y,z):
459         pnt = PointStruct(x,y,z)
460         return DirStruct(pnt)
461
462     ## Get AxisStruct from object
463     #  @param theObj a GEOM object (line or plane)
464     #  @return SMESH.AxisStruct
465     #  @ingroup l1_auxiliary
466     def GetAxisStruct(self,theObj):
467         edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
468         if len(edges) > 1:
469             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
470             vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
471             vertex1 = self.geompyD.PointCoordinates(vertex1)
472             vertex2 = self.geompyD.PointCoordinates(vertex2)
473             vertex3 = self.geompyD.PointCoordinates(vertex3)
474             vertex4 = self.geompyD.PointCoordinates(vertex4)
475             v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
476             v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
477             normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
478             axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
479             return axis
480         elif len(edges) == 1:
481             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
482             p1 = self.geompyD.PointCoordinates( vertex1 )
483             p2 = self.geompyD.PointCoordinates( vertex2 )
484             axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
485             return axis
486         return None
487
488     # From SMESH_Gen interface:
489     # ------------------------
490
491     ## Sets the given name to the object
492     #  @param obj the object to rename
493     #  @param name a new object name
494     #  @ingroup l1_auxiliary
495     def SetName(self, obj, name):
496         if isinstance( obj, Mesh ):
497             obj = obj.GetMesh()
498         elif isinstance( obj, Mesh_Algorithm ):
499             obj = obj.GetAlgorithm()
500         ior  = salome.orb.object_to_string(obj)
501         SMESH._objref_SMESH_Gen.SetName(self, ior, name)
502
503     ## Sets the current mode
504     #  @ingroup l1_auxiliary
505     def SetEmbeddedMode( self,theMode ):
506         #self.SetEmbeddedMode(theMode)
507         SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
508
509     ## Gets the current mode
510     #  @ingroup l1_auxiliary
511     def IsEmbeddedMode(self):
512         #return self.IsEmbeddedMode()
513         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
514
515     ## Sets the current study
516     #  @ingroup l1_auxiliary
517     def SetCurrentStudy( self, theStudy, geompyD = None ):
518         #self.SetCurrentStudy(theStudy)
519         if not geompyD:
520             import geompy
521             geompyD = geompy.geom
522             pass
523         self.geompyD=geompyD
524         self.SetGeomEngine(geompyD)
525         SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
526
527     ## Gets the current study
528     #  @ingroup l1_auxiliary
529     def GetCurrentStudy(self):
530         #return self.GetCurrentStudy()
531         return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
532
533     ## Creates a Mesh object importing data from the given UNV file
534     #  @return an instance of Mesh class
535     #  @ingroup l2_impexp
536     def CreateMeshesFromUNV( self,theFileName ):
537         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
538         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
539         return aMesh
540
541     ## Creates a Mesh object(s) importing data from the given MED file
542     #  @return a list of Mesh class instances
543     #  @ingroup l2_impexp
544     def CreateMeshesFromMED( self,theFileName ):
545         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
546         aMeshes = []
547         for iMesh in range(len(aSmeshMeshes)) :
548             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
549             aMeshes.append(aMesh)
550         return aMeshes, aStatus
551
552     ## Creates a Mesh object importing data from the given STL file
553     #  @return an instance of Mesh class
554     #  @ingroup l2_impexp
555     def CreateMeshesFromSTL( self, theFileName ):
556         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
557         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
558         return aMesh
559
560     ## From SMESH_Gen interface
561     #  @return the list of integer values
562     #  @ingroup l1_auxiliary
563     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
564         return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
565
566     ## From SMESH_Gen interface. Creates a pattern
567     #  @return an instance of SMESH_Pattern
568     #
569     #  <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
570     #  @ingroup l2_modif_patterns
571     def GetPattern(self):
572         return SMESH._objref_SMESH_Gen.GetPattern(self)
573
574     ## Sets number of segments per diagonal of boundary box of geometry by which
575     #  default segment length of appropriate 1D hypotheses is defined.
576     #  Default value is 10
577     #  @ingroup l1_auxiliary
578     def SetBoundaryBoxSegmentation(self, nbSegments):
579         SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
580
581     ## Concatenate the given meshes into one mesh.
582     #  @return an instance of Mesh class
583     #  @param meshes the meshes to combine into one mesh
584     #  @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
585     #  @param mergeNodesAndElements if true, equal nodes and elements aremerged
586     #  @param mergeTolerance tolerance for merging nodes
587     #  @param allGroups forces creation of groups of all elements
588     def Concatenate( self, meshes, uniteIdenticalGroups,
589                      mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
590         mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
591         if allGroups:
592             aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
593                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
594         else:
595             aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
596                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
597         aSmeshMesh.SetParameters(Parameters)
598         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
599         return aMesh
600
601     # Filtering. Auxiliary functions:
602     # ------------------------------
603
604     ## Creates an empty criterion
605     #  @return SMESH.Filter.Criterion
606     #  @ingroup l1_controls
607     def GetEmptyCriterion(self):
608         Type = self.EnumToLong(FT_Undefined)
609         Compare = self.EnumToLong(FT_Undefined)
610         Threshold = 0
611         ThresholdStr = ""
612         ThresholdID = ""
613         UnaryOp = self.EnumToLong(FT_Undefined)
614         BinaryOp = self.EnumToLong(FT_Undefined)
615         Tolerance = 1e-07
616         TypeOfElement = ALL
617         Precision = -1 ##@1e-07
618         return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
619                                 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
620
621     ## Creates a criterion by the given parameters
622     #  @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
623     #  @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
624     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
625     #  @param Treshold the threshold value (range of ids as string, shape, numeric)
626     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
627     #  @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
628     #                  FT_Undefined (must be for the last criterion of all criteria)
629     #  @return SMESH.Filter.Criterion
630     #  @ingroup l1_controls
631     def GetCriterion(self,elementType,
632                      CritType,
633                      Compare = FT_EqualTo,
634                      Treshold="",
635                      UnaryOp=FT_Undefined,
636                      BinaryOp=FT_Undefined):
637         aCriterion = self.GetEmptyCriterion()
638         aCriterion.TypeOfElement = elementType
639         aCriterion.Type = self.EnumToLong(CritType)
640
641         aTreshold = Treshold
642
643         if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
644             aCriterion.Compare = self.EnumToLong(Compare)
645         elif Compare == "=" or Compare == "==":
646             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
647         elif Compare == "<":
648             aCriterion.Compare = self.EnumToLong(FT_LessThan)
649         elif Compare == ">":
650             aCriterion.Compare = self.EnumToLong(FT_MoreThan)
651         else:
652             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
653             aTreshold = Compare
654
655         if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
656                         FT_BelongToCylinder, FT_LyingOnGeom]:
657             # Checks the treshold
658             if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
659                 aCriterion.ThresholdStr = GetName(aTreshold)
660                 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
661             else:
662                 print "Error: The treshold should be a shape."
663                 return None
664         elif CritType == FT_RangeOfIds:
665             # Checks the treshold
666             if isinstance(aTreshold, str):
667                 aCriterion.ThresholdStr = aTreshold
668             else:
669                 print "Error: The treshold should be a string."
670                 return None
671         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
672                           FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
673             # At this point the treshold is unnecessary
674             if aTreshold ==  FT_LogicalNOT:
675                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
676             elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
677                 aCriterion.BinaryOp = aTreshold
678         else:
679             # Check treshold
680             try:
681                 aTreshold = float(aTreshold)
682                 aCriterion.Threshold = aTreshold
683             except:
684                 print "Error: The treshold should be a number."
685                 return None
686
687         if Treshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
688             aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
689
690         if Treshold in [FT_LogicalAND, FT_LogicalOR]:
691             aCriterion.BinaryOp = self.EnumToLong(Treshold)
692
693         if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
694             aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
695
696         if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
697             aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
698
699         return aCriterion
700
701     ## Creates a filter with the given parameters
702     #  @param elementType the type of elements in the group
703     #  @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
704     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
705     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
706     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
707     #  @return SMESH_Filter
708     #  @ingroup l1_controls
709     def GetFilter(self,elementType,
710                   CritType=FT_Undefined,
711                   Compare=FT_EqualTo,
712                   Treshold="",
713                   UnaryOp=FT_Undefined):
714         aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
715         aFilterMgr = self.CreateFilterManager()
716         aFilter = aFilterMgr.CreateFilter()
717         aCriteria = []
718         aCriteria.append(aCriterion)
719         aFilter.SetCriteria(aCriteria)
720         return aFilter
721
722     ## Creates a numerical functor by its type
723     #  @param theCriterion FT_...; functor type
724     #  @return SMESH_NumericalFunctor
725     #  @ingroup l1_controls
726     def GetFunctor(self,theCriterion):
727         aFilterMgr = self.CreateFilterManager()
728         if theCriterion == FT_AspectRatio:
729             return aFilterMgr.CreateAspectRatio()
730         elif theCriterion == FT_AspectRatio3D:
731             return aFilterMgr.CreateAspectRatio3D()
732         elif theCriterion == FT_Warping:
733             return aFilterMgr.CreateWarping()
734         elif theCriterion == FT_MinimumAngle:
735             return aFilterMgr.CreateMinimumAngle()
736         elif theCriterion == FT_Taper:
737             return aFilterMgr.CreateTaper()
738         elif theCriterion == FT_Skew:
739             return aFilterMgr.CreateSkew()
740         elif theCriterion == FT_Area:
741             return aFilterMgr.CreateArea()
742         elif theCriterion == FT_Volume3D:
743             return aFilterMgr.CreateVolume3D()
744         elif theCriterion == FT_MultiConnection:
745             return aFilterMgr.CreateMultiConnection()
746         elif theCriterion == FT_MultiConnection2D:
747             return aFilterMgr.CreateMultiConnection2D()
748         elif theCriterion == FT_Length:
749             return aFilterMgr.CreateLength()
750         elif theCriterion == FT_Length2D:
751             return aFilterMgr.CreateLength2D()
752         else:
753             print "Error: given parameter is not numerucal functor type."
754
755     ## Creates hypothesis
756     #  @param 
757     #  @param 
758     #  @return created hypothesis instance
759     def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
760         return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
761
762 import omniORB
763 #Registering the new proxy for SMESH_Gen
764 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
765
766
767 # Public class: Mesh
768 # ==================
769
770 ## This class allows defining and managing a mesh.
771 #  It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
772 #  It also has methods to define groups of mesh elements, to modify a mesh (by addition of
773 #  new nodes and elements and by changing the existing entities), to get information
774 #  about a mesh and to export a mesh into different formats.
775 class Mesh:
776
777     geom = 0
778     mesh = 0
779     editor = 0
780
781     ## Constructor
782     #
783     #  Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
784     #  sets the GUI name of this mesh to \a name.
785     #  @param smeshpyD an instance of smeshDC class
786     #  @param geompyD an instance of geompyDC class
787     #  @param obj Shape to be meshed or SMESH_Mesh object
788     #  @param name Study name of the mesh
789     #  @ingroup l2_construct
790     def __init__(self, smeshpyD, geompyD, obj=0, name=0):
791         self.smeshpyD=smeshpyD
792         self.geompyD=geompyD
793         if obj is None:
794             obj = 0
795         if obj != 0:
796             if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
797                 self.geom = obj
798                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
799             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
800                 self.SetMesh(obj)
801         else:
802             self.mesh = self.smeshpyD.CreateEmptyMesh()
803         if name != 0:
804             self.smeshpyD.SetName(self.mesh, name)
805         elif obj != 0:
806             self.smeshpyD.SetName(self.mesh, GetName(obj))
807
808         if not self.geom:
809             self.geom = self.mesh.GetShapeToMesh()
810
811         self.editor = self.mesh.GetMeshEditor()
812
813     ## Initializes the Mesh object from an instance of SMESH_Mesh interface
814     #  @param theMesh a SMESH_Mesh object
815     #  @ingroup l2_construct
816     def SetMesh(self, theMesh):
817         self.mesh = theMesh
818         self.geom = self.mesh.GetShapeToMesh()
819
820     ## Returns the mesh, that is an instance of SMESH_Mesh interface
821     #  @return a SMESH_Mesh object
822     #  @ingroup l2_construct
823     def GetMesh(self):
824         return self.mesh
825
826     ## Gets the name of the mesh
827     #  @return the name of the mesh as a string
828     #  @ingroup l2_construct
829     def GetName(self):
830         name = GetName(self.GetMesh())
831         return name
832
833     ## Sets a name to the mesh
834     #  @param name a new name of the mesh
835     #  @ingroup l2_construct
836     def SetName(self, name):
837         self.smeshpyD.SetName(self.GetMesh(), name)
838
839     ## Gets the subMesh object associated to a \a theSubObject geometrical object.
840     #  The subMesh object gives access to the IDs of nodes and elements.
841     #  @param theSubObject a geometrical object (shape)
842     #  @param theName a name for the submesh
843     #  @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
844     #  @ingroup l2_submeshes
845     def GetSubMesh(self, theSubObject, theName):
846         submesh = self.mesh.GetSubMesh(theSubObject, theName)
847         return submesh
848
849     ## Returns the shape associated to the mesh
850     #  @return a GEOM_Object
851     #  @ingroup l2_construct
852     def GetShape(self):
853         return self.geom
854
855     ## Associates the given shape to the mesh (entails the recreation of the mesh)
856     #  @param geom the shape to be meshed (GEOM_Object)
857     #  @ingroup l2_construct
858     def SetShape(self, geom):
859         self.mesh = self.smeshpyD.CreateMesh(geom)
860
861     ## Returns true if the hypotheses are defined well
862     #  @param theSubObject a subshape of a mesh shape
863     #  @return True or False
864     #  @ingroup l2_construct
865     def IsReadyToCompute(self, theSubObject):
866         return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
867
868     ## Returns errors of hypotheses definition.
869     #  The list of errors is empty if everything is OK.
870     #  @param theSubObject a subshape of a mesh shape
871     #  @return a list of errors
872     #  @ingroup l2_construct
873     def GetAlgoState(self, theSubObject):
874         return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
875
876     ## Returns a geometrical object on which the given element was built.
877     #  The returned geometrical object, if not nil, is either found in the
878     #  study or published by this method with the given name
879     #  @param theElementID the id of the mesh element
880     #  @param theGeomName the user-defined name of the geometrical object
881     #  @return GEOM::GEOM_Object instance
882     #  @ingroup l2_construct
883     def GetGeometryByMeshElement(self, theElementID, theGeomName):
884         return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
885
886     ## Returns the mesh dimension depending on the dimension of the underlying shape
887     #  @return mesh dimension as an integer value [0,3]
888     #  @ingroup l1_auxiliary
889     def MeshDimension(self):
890         shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
891         if len( shells ) > 0 :
892             return 3
893         elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
894             return 2
895         elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
896             return 1
897         else:
898             return 0;
899         pass
900
901     ## Creates a segment discretization 1D algorithm.
902     #  If the optional \a algo parameter is not set, this algorithm is REGULAR.
903     #  \n If the optional \a geom parameter is not set, this algorithm is global.
904     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
905     #  @param algo the type of the required algorithm. Possible values are:
906     #     - smesh.REGULAR,
907     #     - smesh.PYTHON for discretization via a python function,
908     #     - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
909     #  @param geom If defined is the subshape to be meshed
910     #  @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
911     #  @ingroup l3_algos_basic
912     def Segment(self, algo=REGULAR, geom=0):
913         ## if Segment(geom) is called by mistake
914         if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
915             algo, geom = geom, algo
916             if not algo: algo = REGULAR
917             pass
918         if algo == REGULAR:
919             return Mesh_Segment(self,  geom)
920         elif algo == PYTHON:
921             return Mesh_Segment_Python(self, geom)
922         elif algo == COMPOSITE:
923             return Mesh_CompositeSegment(self, geom)
924         else:
925             return Mesh_Segment(self, geom)
926
927     ## Enables creation of nodes and segments usable by 2D algoritms.
928     #  The added nodes and segments must be bound to edges and vertices by
929     #  SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
930     #  If the optional \a geom parameter is not set, this algorithm is global.
931     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
932     #  @param geom the subshape to be manually meshed
933     #  @return StdMeshers_UseExisting_1D algorithm that generates nothing
934     #  @ingroup l3_algos_basic
935     def UseExistingSegments(self, geom=0):
936         algo = Mesh_UseExisting(1,self,geom)
937         return algo.GetAlgorithm()
938
939     ## Enables creation of nodes and faces usable by 3D algoritms.
940     #  The added nodes and faces must be bound to geom faces by SetNodeOnFace()
941     #  and SetMeshElementOnShape()
942     #  If the optional \a geom parameter is not set, this algorithm is global.
943     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
944     #  @param geom the subshape to be manually meshed
945     #  @return StdMeshers_UseExisting_2D algorithm that generates nothing
946     #  @ingroup l3_algos_basic
947     def UseExistingFaces(self, geom=0):
948         algo = Mesh_UseExisting(2,self,geom)
949         return algo.GetAlgorithm()
950
951     ## Creates a triangle 2D algorithm for faces.
952     #  If the optional \a geom parameter is not set, this algorithm is global.
953     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
954     #  @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
955     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
956     #  @return an instance of Mesh_Triangle algorithm
957     #  @ingroup l3_algos_basic
958     def Triangle(self, algo=MEFISTO, geom=0):
959         ## if Triangle(geom) is called by mistake
960         if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
961             geom = algo
962             algo = MEFISTO
963
964         return Mesh_Triangle(self, algo, geom)
965
966     ## Creates a quadrangle 2D algorithm for faces.
967     #  If the optional \a geom parameter is not set, this algorithm is global.
968     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
969     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
970     #  @return an instance of Mesh_Quadrangle algorithm
971     #  @ingroup l3_algos_basic
972     def Quadrangle(self, geom=0):
973         return Mesh_Quadrangle(self,  geom)
974
975     ## Creates a tetrahedron 3D algorithm for solids.
976     #  The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
977     #  If the optional \a geom parameter is not set, this algorithm is global.
978     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
979     #  @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
980     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
981     #  @return an instance of Mesh_Tetrahedron algorithm
982     #  @ingroup l3_algos_basic
983     def Tetrahedron(self, algo=NETGEN, geom=0):
984         ## if Tetrahedron(geom) is called by mistake
985         if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
986             algo, geom = geom, algo
987             if not algo: algo = NETGEN
988             pass
989         return Mesh_Tetrahedron(self,  algo, geom)
990
991     ## Creates a hexahedron 3D algorithm for solids.
992     #  If the optional \a geom parameter is not set, this algorithm is global.
993     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
994     #  @param algo possible values are: smesh.Hexa, smesh.Hexotic
995     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
996     #  @return an instance of Mesh_Hexahedron algorithm
997     #  @ingroup l3_algos_basic
998     def Hexahedron(self, algo=Hexa, geom=0):
999         ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1000         if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1001             if   geom in [Hexa, Hexotic]: algo, geom = geom, algo
1002             elif geom == 0:               algo, geom = Hexa, algo
1003         return Mesh_Hexahedron(self, algo, geom)
1004
1005     ## Deprecated, used only for compatibility!
1006     #  @return an instance of Mesh_Netgen algorithm
1007     #  @ingroup l3_algos_basic
1008     def Netgen(self, is3D, geom=0):
1009         return Mesh_Netgen(self,  is3D, geom)
1010
1011     ## Creates a projection 1D algorithm for edges.
1012     #  If the optional \a geom parameter is not set, this algorithm is global.
1013     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1014     #  @param geom If defined, the subshape to be meshed
1015     #  @return an instance of Mesh_Projection1D algorithm
1016     #  @ingroup l3_algos_proj
1017     def Projection1D(self, geom=0):
1018         return Mesh_Projection1D(self,  geom)
1019
1020     ## Creates a projection 2D algorithm for faces.
1021     #  If the optional \a geom parameter is not set, this algorithm is global.
1022     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1023     #  @param geom If defined, the subshape to be meshed
1024     #  @return an instance of Mesh_Projection2D algorithm
1025     #  @ingroup l3_algos_proj
1026     def Projection2D(self, geom=0):
1027         return Mesh_Projection2D(self,  geom)
1028
1029     ## Creates a projection 3D algorithm for solids.
1030     #  If the optional \a geom parameter is not set, this algorithm is global.
1031     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1032     #  @param geom If defined, the subshape to be meshed
1033     #  @return an instance of Mesh_Projection3D algorithm
1034     #  @ingroup l3_algos_proj
1035     def Projection3D(self, geom=0):
1036         return Mesh_Projection3D(self,  geom)
1037
1038     ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1039     #  If the optional \a geom parameter is not set, this algorithm is global.
1040     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
1041     #  @param geom If defined, the subshape to be meshed
1042     #  @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1043     #  @ingroup l3_algos_radialp l3_algos_3dextr
1044     def Prism(self, geom=0):
1045         shape = geom
1046         if shape==0:
1047             shape = self.geom
1048         nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1049         nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1050         if nbSolids == 0 or nbSolids == nbShells:
1051             return Mesh_Prism3D(self,  geom)
1052         return Mesh_RadialPrism3D(self,  geom)
1053
1054     ## Evaluates size of prospective mesh on a shape
1055     #  @return True or False
1056     def Evaluate(self, geom=0):
1057         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1058             if self.geom == 0:
1059                 geom = self.mesh.GetShapeToMesh()
1060             else:
1061                 geom = self.geom
1062         return self.smeshpyD.Evaluate(self.mesh, geom)
1063
1064
1065     ## Computes the mesh and returns the status of the computation
1066     #  @return True or False
1067     #  @ingroup l2_construct
1068     def Compute(self, geom=0):
1069         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1070             if self.geom == 0:
1071                 geom = self.mesh.GetShapeToMesh()
1072             else:
1073                 geom = self.geom
1074         ok = False
1075         try:
1076             ok = self.smeshpyD.Compute(self.mesh, geom)
1077         except SALOME.SALOME_Exception, ex:
1078             print "Mesh computation failed, exception caught:"
1079             print "    ", ex.details.text
1080         except:
1081             import traceback
1082             print "Mesh computation failed, exception caught:"
1083             traceback.print_exc()
1084         if True:#not ok:
1085             errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1086             allReasons = ""
1087             for err in errors:
1088                 if err.isGlobalAlgo:
1089                     glob = "global"
1090                 else:
1091                     glob = "local"
1092                     pass
1093                 dim = err.algoDim
1094                 name = err.algoName
1095                 if len(name) == 0:
1096                     reason = '%s %sD algorithm is missing' % (glob, dim)
1097                 elif err.state == HYP_MISSING:
1098                     reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1099                               % (glob, dim, name, dim))
1100                 elif err.state == HYP_NOTCONFORM:
1101                     reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1102                 elif err.state == HYP_BAD_PARAMETER:
1103                     reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1104                               % ( glob, dim, name ))
1105                 elif err.state == HYP_BAD_GEOMETRY:
1106                     reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1107                               'geometry' % ( glob, dim, name ))
1108                 else:
1109                     reason = "For unknown reason."+\
1110                              " Revise Mesh.Compute() implementation in smeshDC.py!"
1111                     pass
1112                 if allReasons != "":
1113                     allReasons += "\n"
1114                     pass
1115                 allReasons += reason
1116                 pass
1117             if allReasons != "":
1118                 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1119                 print allReasons
1120                 ok = False
1121             elif not ok:
1122                 print '"' + GetName(self.mesh) + '"',"has not been computed."
1123                 pass
1124             pass
1125         if salome.sg.hasDesktop():
1126             smeshgui = salome.ImportComponentGUI("SMESH")
1127             smeshgui.Init(self.mesh.GetStudyId())
1128             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1129             salome.sg.updateObjBrowser(1)
1130             pass
1131         return ok
1132
1133     ## Removes all nodes and elements
1134     #  @ingroup l2_construct
1135     def Clear(self):
1136         self.mesh.Clear()
1137         if salome.sg.hasDesktop():
1138             smeshgui = salome.ImportComponentGUI("SMESH")
1139             smeshgui.Init(self.mesh.GetStudyId())
1140             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1141             salome.sg.updateObjBrowser(1)
1142
1143     ## Removes all nodes and elements of indicated shape
1144     #  @ingroup l2_construct
1145     def ClearSubMesh(self, geomId):
1146         self.mesh.ClearSubMesh(geomId)
1147         if salome.sg.hasDesktop():
1148             smeshgui = salome.ImportComponentGUI("SMESH")
1149             smeshgui.Init(self.mesh.GetStudyId())
1150             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1151             salome.sg.updateObjBrowser(1)
1152
1153     ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1154     #  @param fineness [0,-1] defines mesh fineness
1155     #  @return True or False
1156     #  @ingroup l3_algos_basic
1157     def AutomaticTetrahedralization(self, fineness=0):
1158         dim = self.MeshDimension()
1159         # assign hypotheses
1160         self.RemoveGlobalHypotheses()
1161         self.Segment().AutomaticLength(fineness)
1162         if dim > 1 :
1163             self.Triangle().LengthFromEdges()
1164             pass
1165         if dim > 2 :
1166             self.Tetrahedron(NETGEN)
1167             pass
1168         return self.Compute()
1169
1170     ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1171     #  @param fineness [0,-1] defines mesh fineness
1172     #  @return True or False
1173     #  @ingroup l3_algos_basic
1174     def AutomaticHexahedralization(self, fineness=0):
1175         dim = self.MeshDimension()
1176         # assign the hypotheses
1177         self.RemoveGlobalHypotheses()
1178         self.Segment().AutomaticLength(fineness)
1179         if dim > 1 :
1180             self.Quadrangle()
1181             pass
1182         if dim > 2 :
1183             self.Hexahedron()
1184             pass
1185         return self.Compute()
1186
1187     ## Assigns a hypothesis
1188     #  @param hyp a hypothesis to assign
1189     #  @param geom a subhape of mesh geometry
1190     #  @return SMESH.Hypothesis_Status
1191     #  @ingroup l2_hypotheses
1192     def AddHypothesis(self, hyp, geom=0):
1193         if isinstance( hyp, Mesh_Algorithm ):
1194             hyp = hyp.GetAlgorithm()
1195             pass
1196         if not geom:
1197             geom = self.geom
1198             if not geom:
1199                 geom = self.mesh.GetShapeToMesh()
1200             pass
1201         status = self.mesh.AddHypothesis(geom, hyp)
1202         isAlgo = hyp._narrow( SMESH_Algo )
1203         TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1204         return status
1205
1206     ## Unassigns a hypothesis
1207     #  @param hyp a hypothesis to unassign
1208     #  @param geom a subshape of mesh geometry
1209     #  @return SMESH.Hypothesis_Status
1210     #  @ingroup l2_hypotheses
1211     def RemoveHypothesis(self, hyp, geom=0):
1212         if isinstance( hyp, Mesh_Algorithm ):
1213             hyp = hyp.GetAlgorithm()
1214             pass
1215         if not geom:
1216             geom = self.geom
1217             pass
1218         status = self.mesh.RemoveHypothesis(geom, hyp)
1219         return status
1220
1221     ## Gets the list of hypotheses added on a geometry
1222     #  @param geom a subshape of mesh geometry
1223     #  @return the sequence of SMESH_Hypothesis
1224     #  @ingroup l2_hypotheses
1225     def GetHypothesisList(self, geom):
1226         return self.mesh.GetHypothesisList( geom )
1227
1228     ## Removes all global hypotheses
1229     #  @ingroup l2_hypotheses
1230     def RemoveGlobalHypotheses(self):
1231         current_hyps = self.mesh.GetHypothesisList( self.geom )
1232         for hyp in current_hyps:
1233             self.mesh.RemoveHypothesis( self.geom, hyp )
1234             pass
1235         pass
1236
1237     ## Creates a mesh group based on the geometric object \a grp
1238     #  and gives a \a name, \n if this parameter is not defined
1239     #  the name is the same as the geometric group name \n
1240     #  Note: Works like GroupOnGeom().
1241     #  @param grp  a geometric group, a vertex, an edge, a face or a solid
1242     #  @param name the name of the mesh group
1243     #  @return SMESH_GroupOnGeom
1244     #  @ingroup l2_grps_create
1245     def Group(self, grp, name=""):
1246         return self.GroupOnGeom(grp, name)
1247
1248     ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1249     #  Exports the mesh in a file in MED format and chooses the \a version of MED format
1250     #  @param f the file name
1251     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1252     #  @ingroup l2_impexp
1253     def ExportToMED(self, f, version, opt=0):
1254         self.mesh.ExportToMED(f, opt, version)
1255
1256     ## Exports the mesh in a file in MED format
1257     #  @param f is the file name
1258     #  @param auto_groups boolean parameter for creating/not creating
1259     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1260     #  the typical use is auto_groups=false.
1261     #  @param version MED format version(MED_V2_1 or MED_V2_2)
1262     #  @ingroup l2_impexp
1263     def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1264         self.mesh.ExportToMED(f, auto_groups, version)
1265
1266     ## Exports the mesh in a file in DAT format
1267     #  @param f the file name
1268     #  @ingroup l2_impexp
1269     def ExportDAT(self, f):
1270         self.mesh.ExportDAT(f)
1271
1272     ## Exports the mesh in a file in UNV format
1273     #  @param f the file name
1274     #  @ingroup l2_impexp
1275     def ExportUNV(self, f):
1276         self.mesh.ExportUNV(f)
1277
1278     ## Export the mesh in a file in STL format
1279     #  @param f the file name
1280     #  @param ascii defines the file encoding
1281     #  @ingroup l2_impexp
1282     def ExportSTL(self, f, ascii=1):
1283         self.mesh.ExportSTL(f, ascii)
1284
1285
1286     # Operations with groups:
1287     # ----------------------
1288
1289     ## Creates an empty mesh group
1290     #  @param elementType the type of elements in the group
1291     #  @param name the name of the mesh group
1292     #  @return SMESH_Group
1293     #  @ingroup l2_grps_create
1294     def CreateEmptyGroup(self, elementType, name):
1295         return self.mesh.CreateGroup(elementType, name)
1296
1297     ## Creates a mesh group based on the geometrical object \a grp
1298     #  and gives a \a name, \n if this parameter is not defined
1299     #  the name is the same as the geometrical group name
1300     #  @param grp  a geometrical group, a vertex, an edge, a face or a solid
1301     #  @param name the name of the mesh group
1302     #  @param typ  the type of elements in the group. If not set, it is
1303     #              automatically detected by the type of the geometry
1304     #  @return SMESH_GroupOnGeom
1305     #  @ingroup l2_grps_create
1306     def GroupOnGeom(self, grp, name="", typ=None):
1307         if name == "":
1308             name = grp.GetName()
1309
1310         if typ == None:
1311             tgeo = str(grp.GetShapeType())
1312             if tgeo == "VERTEX":
1313                 typ = NODE
1314             elif tgeo == "EDGE":
1315                 typ = EDGE
1316             elif tgeo == "FACE":
1317                 typ = FACE
1318             elif tgeo == "SOLID":
1319                 typ = VOLUME
1320             elif tgeo == "SHELL":
1321                 typ = VOLUME
1322             elif tgeo == "COMPOUND":
1323                 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1324                     print "Mesh.Group: empty geometric group", GetName( grp )
1325                     return 0
1326                 tgeo = self.geompyD.GetType(grp)
1327                 if tgeo == geompyDC.ShapeType["VERTEX"]:
1328                     typ = NODE
1329                 elif tgeo == geompyDC.ShapeType["EDGE"]:
1330                     typ = EDGE
1331                 elif tgeo == geompyDC.ShapeType["FACE"]:
1332                     typ = FACE
1333                 elif tgeo == geompyDC.ShapeType["SOLID"]:
1334                     typ = VOLUME
1335
1336         if typ == None:
1337             print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1338             return 0
1339         else:
1340             return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1341
1342     ## Creates a mesh group by the given ids of elements
1343     #  @param groupName the name of the mesh group
1344     #  @param elementType the type of elements in the group
1345     #  @param elemIDs the list of ids
1346     #  @return SMESH_Group
1347     #  @ingroup l2_grps_create
1348     def MakeGroupByIds(self, groupName, elementType, elemIDs):
1349         group = self.mesh.CreateGroup(elementType, groupName)
1350         group.Add(elemIDs)
1351         return group
1352
1353     ## Creates a mesh group by the given conditions
1354     #  @param groupName the name of the mesh group
1355     #  @param elementType the type of elements in the group
1356     #  @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1357     #  @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1358     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
1359     #  @param UnaryOp FT_LogicalNOT or FT_Undefined
1360     #  @return SMESH_Group
1361     #  @ingroup l2_grps_create
1362     def MakeGroup(self,
1363                   groupName,
1364                   elementType,
1365                   CritType=FT_Undefined,
1366                   Compare=FT_EqualTo,
1367                   Treshold="",
1368                   UnaryOp=FT_Undefined):
1369         aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1370         group = self.MakeGroupByCriterion(groupName, aCriterion)
1371         return group
1372
1373     ## Creates a mesh group by the given criterion
1374     #  @param groupName the name of the mesh group
1375     #  @param Criterion the instance of Criterion class
1376     #  @return SMESH_Group
1377     #  @ingroup l2_grps_create
1378     def MakeGroupByCriterion(self, groupName, Criterion):
1379         aFilterMgr = self.smeshpyD.CreateFilterManager()
1380         aFilter = aFilterMgr.CreateFilter()
1381         aCriteria = []
1382         aCriteria.append(Criterion)
1383         aFilter.SetCriteria(aCriteria)
1384         group = self.MakeGroupByFilter(groupName, aFilter)
1385         return group
1386
1387     ## Creates a mesh group by the given criteria (list of criteria)
1388     #  @param groupName the name of the mesh group
1389     #  @param theCriteria the list of criteria
1390     #  @return SMESH_Group
1391     #  @ingroup l2_grps_create
1392     def MakeGroupByCriteria(self, groupName, theCriteria):
1393         aFilterMgr = self.smeshpyD.CreateFilterManager()
1394         aFilter = aFilterMgr.CreateFilter()
1395         aFilter.SetCriteria(theCriteria)
1396         group = self.MakeGroupByFilter(groupName, aFilter)
1397         return group
1398
1399     ## Creates a mesh group by the given filter
1400     #  @param groupName the name of the mesh group
1401     #  @param theFilter the instance of Filter class
1402     #  @return SMESH_Group
1403     #  @ingroup l2_grps_create
1404     def MakeGroupByFilter(self, groupName, theFilter):
1405         anIds = theFilter.GetElementsId(self.mesh)
1406         anElemType = theFilter.GetElementType()
1407         group = self.MakeGroupByIds(groupName, anElemType, anIds)
1408         return group
1409
1410     ## Passes mesh elements through the given filter and return IDs of fitting elements
1411     #  @param theFilter SMESH_Filter
1412     #  @return a list of ids
1413     #  @ingroup l1_controls
1414     def GetIdsFromFilter(self, theFilter):
1415         return theFilter.GetElementsId(self.mesh)
1416
1417     ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1418     #  Returns a list of special structures (borders).
1419     #  @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1420     #  @ingroup l1_controls
1421     def GetFreeBorders(self):
1422         aFilterMgr = self.smeshpyD.CreateFilterManager()
1423         aPredicate = aFilterMgr.CreateFreeEdges()
1424         aPredicate.SetMesh(self.mesh)
1425         aBorders = aPredicate.GetBorders()
1426         return aBorders
1427
1428     ## Removes a group
1429     #  @ingroup l2_grps_delete
1430     def RemoveGroup(self, group):
1431         self.mesh.RemoveGroup(group)
1432
1433     ## Removes a group with its contents
1434     #  @ingroup l2_grps_delete
1435     def RemoveGroupWithContents(self, group):
1436         self.mesh.RemoveGroupWithContents(group)
1437
1438     ## Gets the list of groups existing in the mesh
1439     #  @return a sequence of SMESH_GroupBase
1440     #  @ingroup l2_grps_create
1441     def GetGroups(self):
1442         return self.mesh.GetGroups()
1443
1444     ## Gets the number of groups existing in the mesh
1445     #  @return the quantity of groups as an integer value
1446     #  @ingroup l2_grps_create
1447     def NbGroups(self):
1448         return self.mesh.NbGroups()
1449
1450     ## Gets the list of names of groups existing in the mesh
1451     #  @return list of strings
1452     #  @ingroup l2_grps_create
1453     def GetGroupNames(self):
1454         groups = self.GetGroups()
1455         names = []
1456         for group in groups:
1457             names.append(group.GetName())
1458         return names
1459
1460     ## Produces a union of two groups
1461     #  A new group is created. All mesh elements that are
1462     #  present in the initial groups are added to the new one
1463     #  @return an instance of SMESH_Group
1464     #  @ingroup l2_grps_operon
1465     def UnionGroups(self, group1, group2, name):
1466         return self.mesh.UnionGroups(group1, group2, name)
1467         
1468     ## Produces a union list of groups
1469     #  New group is created. All mesh elements that are present in 
1470     #  initial groups are added to the new one
1471     #  @return an instance of SMESH_Group
1472     #  @ingroup l2_grps_operon
1473     def UnionListOfGroups(self, groups, name):
1474       return self.mesh.UnionListOfGroups(groups, name)
1475       
1476     ## Prodices an intersection of two groups
1477     #  A new group is created. All mesh elements that are common
1478     #  for the two initial groups are added to the new one.
1479     #  @return an instance of SMESH_Group
1480     #  @ingroup l2_grps_operon
1481     def IntersectGroups(self, group1, group2, name):
1482         return self.mesh.IntersectGroups(group1, group2, name)
1483         
1484     ## Produces an intersection of groups
1485     #  New group is created. All mesh elements that are present in all 
1486     #  initial groups simultaneously are added to the new one
1487     #  @return an instance of SMESH_Group
1488     #  @ingroup l2_grps_operon
1489     def IntersectListOfGroups(self, groups, name):
1490       return self.mesh.IntersectListOfGroups(groups, name)
1491
1492     ## Produces a cut of two groups
1493     #  A new group is created. All mesh elements that are present in
1494     #  the main group but are not present in the tool group are added to the new one
1495     #  @return an instance of SMESH_Group
1496     #  @ingroup l2_grps_operon
1497     def CutGroups(self, main_group, tool_group, name):
1498         return self.mesh.CutGroups(main_group, tool_group, name)
1499         
1500     ## Produces a cut of groups
1501     #  A new group is created. All mesh elements that are present in main groups 
1502     #  but do not present in tool groups are added to the new one
1503     #  @return an instance of SMESH_Group
1504     #  @ingroup l2_grps_operon
1505     def CutListOfGroups(self, main_groups, tool_groups, name):
1506       return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1507       
1508     ## Produces a group of elements with specified element type using list of existing groups
1509     #  A new group is created. System 
1510     #  1) extract all nodes on which groups elements are built
1511     #  2) combine all elements of specified dimension laying on these nodes
1512     #  @return an instance of SMESH_Group
1513     #  @ingroup l2_grps_operon
1514     def CreateDimGroup(self, groups, elem_type, name):
1515       return self.mesh.CreateDimGroup(groups, elem_type, name)
1516
1517
1518     ## Convert group on geom into standalone group
1519     #  @ingroup l2_grps_delete
1520     def ConvertToStandalone(self, group):
1521         return self.mesh.ConvertToStandalone(group)
1522
1523     # Get some info about mesh:
1524     # ------------------------
1525
1526     ## Returns the log of nodes and elements added or removed
1527     #  since the previous clear of the log.
1528     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
1529     #  @return list of log_block structures:
1530     #                                        commandType
1531     #                                        number
1532     #                                        coords
1533     #                                        indexes
1534     #  @ingroup l1_auxiliary
1535     def GetLog(self, clearAfterGet):
1536         return self.mesh.GetLog(clearAfterGet)
1537
1538     ## Clears the log of nodes and elements added or removed since the previous
1539     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
1540     #  @ingroup l1_auxiliary
1541     def ClearLog(self):
1542         self.mesh.ClearLog()
1543
1544     ## Toggles auto color mode on the object.
1545     #  @param theAutoColor the flag which toggles auto color mode.
1546     #  @ingroup l1_auxiliary
1547     def SetAutoColor(self, theAutoColor):
1548         self.mesh.SetAutoColor(theAutoColor)
1549
1550     ## Gets flag of object auto color mode.
1551     #  @return True or False
1552     #  @ingroup l1_auxiliary
1553     def GetAutoColor(self):
1554         return self.mesh.GetAutoColor()
1555
1556     ## Gets the internal ID
1557     #  @return integer value, which is the internal Id of the mesh
1558     #  @ingroup l1_auxiliary
1559     def GetId(self):
1560         return self.mesh.GetId()
1561
1562     ## Get the study Id
1563     #  @return integer value, which is the study Id of the mesh
1564     #  @ingroup l1_auxiliary
1565     def GetStudyId(self):
1566         return self.mesh.GetStudyId()
1567
1568     ## Checks the group names for duplications.
1569     #  Consider the maximum group name length stored in MED file.
1570     #  @return True or False
1571     #  @ingroup l1_auxiliary
1572     def HasDuplicatedGroupNamesMED(self):
1573         return self.mesh.HasDuplicatedGroupNamesMED()
1574
1575     ## Obtains the mesh editor tool
1576     #  @return an instance of SMESH_MeshEditor
1577     #  @ingroup l1_modifying
1578     def GetMeshEditor(self):
1579         return self.mesh.GetMeshEditor()
1580
1581     ## Gets MED Mesh
1582     #  @return an instance of SALOME_MED::MESH
1583     #  @ingroup l1_auxiliary
1584     def GetMEDMesh(self):
1585         return self.mesh.GetMEDMesh()
1586
1587
1588     # Get informations about mesh contents:
1589     # ------------------------------------
1590
1591     ## Returns the number of nodes in the mesh
1592     #  @return an integer value
1593     #  @ingroup l1_meshinfo
1594     def NbNodes(self):
1595         return self.mesh.NbNodes()
1596
1597     ## Returns the number of elements in the mesh
1598     #  @return an integer value
1599     #  @ingroup l1_meshinfo
1600     def NbElements(self):
1601         return self.mesh.NbElements()
1602
1603     ## Returns the number of edges in the mesh
1604     #  @return an integer value
1605     #  @ingroup l1_meshinfo
1606     def NbEdges(self):
1607         return self.mesh.NbEdges()
1608
1609     ## Returns the number of edges with the given order in the mesh
1610     #  @param elementOrder the order of elements:
1611     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1612     #  @return an integer value
1613     #  @ingroup l1_meshinfo
1614     def NbEdgesOfOrder(self, elementOrder):
1615         return self.mesh.NbEdgesOfOrder(elementOrder)
1616
1617     ## Returns the number of faces in the mesh
1618     #  @return an integer value
1619     #  @ingroup l1_meshinfo
1620     def NbFaces(self):
1621         return self.mesh.NbFaces()
1622
1623     ## Returns the number of faces with the given order in the mesh
1624     #  @param elementOrder the order of elements:
1625     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1626     #  @return an integer value
1627     #  @ingroup l1_meshinfo
1628     def NbFacesOfOrder(self, elementOrder):
1629         return self.mesh.NbFacesOfOrder(elementOrder)
1630
1631     ## Returns the number of triangles in the mesh
1632     #  @return an integer value
1633     #  @ingroup l1_meshinfo
1634     def NbTriangles(self):
1635         return self.mesh.NbTriangles()
1636
1637     ## Returns the number of triangles with the given order in the mesh
1638     #  @param elementOrder is the order of elements:
1639     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1640     #  @return an integer value
1641     #  @ingroup l1_meshinfo
1642     def NbTrianglesOfOrder(self, elementOrder):
1643         return self.mesh.NbTrianglesOfOrder(elementOrder)
1644
1645     ## Returns the number of quadrangles in the mesh
1646     #  @return an integer value
1647     #  @ingroup l1_meshinfo
1648     def NbQuadrangles(self):
1649         return self.mesh.NbQuadrangles()
1650
1651     ## Returns the number of quadrangles with the given order in the mesh
1652     #  @param elementOrder the order of elements:
1653     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1654     #  @return an integer value
1655     #  @ingroup l1_meshinfo
1656     def NbQuadranglesOfOrder(self, elementOrder):
1657         return self.mesh.NbQuadranglesOfOrder(elementOrder)
1658
1659     ## Returns the number of polygons in the mesh
1660     #  @return an integer value
1661     #  @ingroup l1_meshinfo
1662     def NbPolygons(self):
1663         return self.mesh.NbPolygons()
1664
1665     ## Returns the number of volumes in the mesh
1666     #  @return an integer value
1667     #  @ingroup l1_meshinfo
1668     def NbVolumes(self):
1669         return self.mesh.NbVolumes()
1670
1671     ## Returns the number of volumes with the given order in the mesh
1672     #  @param elementOrder  the order of elements:
1673     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1674     #  @return an integer value
1675     #  @ingroup l1_meshinfo
1676     def NbVolumesOfOrder(self, elementOrder):
1677         return self.mesh.NbVolumesOfOrder(elementOrder)
1678
1679     ## Returns the number of tetrahedrons in the mesh
1680     #  @return an integer value
1681     #  @ingroup l1_meshinfo
1682     def NbTetras(self):
1683         return self.mesh.NbTetras()
1684
1685     ## Returns the number of tetrahedrons with the given order in the mesh
1686     #  @param elementOrder  the order of elements:
1687     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1688     #  @return an integer value
1689     #  @ingroup l1_meshinfo
1690     def NbTetrasOfOrder(self, elementOrder):
1691         return self.mesh.NbTetrasOfOrder(elementOrder)
1692
1693     ## Returns the number of hexahedrons in the mesh
1694     #  @return an integer value
1695     #  @ingroup l1_meshinfo
1696     def NbHexas(self):
1697         return self.mesh.NbHexas()
1698
1699     ## Returns the number of hexahedrons with the given order in the mesh
1700     #  @param elementOrder  the order of elements:
1701     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1702     #  @return an integer value
1703     #  @ingroup l1_meshinfo
1704     def NbHexasOfOrder(self, elementOrder):
1705         return self.mesh.NbHexasOfOrder(elementOrder)
1706
1707     ## Returns the number of pyramids in the mesh
1708     #  @return an integer value
1709     #  @ingroup l1_meshinfo
1710     def NbPyramids(self):
1711         return self.mesh.NbPyramids()
1712
1713     ## Returns the number of pyramids with the given order in the mesh
1714     #  @param elementOrder  the order of elements:
1715     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1716     #  @return an integer value
1717     #  @ingroup l1_meshinfo
1718     def NbPyramidsOfOrder(self, elementOrder):
1719         return self.mesh.NbPyramidsOfOrder(elementOrder)
1720
1721     ## Returns the number of prisms in the mesh
1722     #  @return an integer value
1723     #  @ingroup l1_meshinfo
1724     def NbPrisms(self):
1725         return self.mesh.NbPrisms()
1726
1727     ## Returns the number of prisms with the given order in the mesh
1728     #  @param elementOrder  the order of elements:
1729     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1730     #  @return an integer value
1731     #  @ingroup l1_meshinfo
1732     def NbPrismsOfOrder(self, elementOrder):
1733         return self.mesh.NbPrismsOfOrder(elementOrder)
1734
1735     ## Returns the number of polyhedrons in the mesh
1736     #  @return an integer value
1737     #  @ingroup l1_meshinfo
1738     def NbPolyhedrons(self):
1739         return self.mesh.NbPolyhedrons()
1740
1741     ## Returns the number of submeshes in the mesh
1742     #  @return an integer value
1743     #  @ingroup l1_meshinfo
1744     def NbSubMesh(self):
1745         return self.mesh.NbSubMesh()
1746
1747     ## Returns the list of mesh elements IDs
1748     #  @return the list of integer values
1749     #  @ingroup l1_meshinfo
1750     def GetElementsId(self):
1751         return self.mesh.GetElementsId()
1752
1753     ## Returns the list of IDs of mesh elements with the given type
1754     #  @param elementType  the required type of elements
1755     #  @return list of integer values
1756     #  @ingroup l1_meshinfo
1757     def GetElementsByType(self, elementType):
1758         return self.mesh.GetElementsByType(elementType)
1759
1760     ## Returns the list of mesh nodes IDs
1761     #  @return the list of integer values
1762     #  @ingroup l1_meshinfo
1763     def GetNodesId(self):
1764         return self.mesh.GetNodesId()
1765
1766     # Get the information about mesh elements:
1767     # ------------------------------------
1768
1769     ## Returns the type of mesh element
1770     #  @return the value from SMESH::ElementType enumeration
1771     #  @ingroup l1_meshinfo
1772     def GetElementType(self, id, iselem):
1773         return self.mesh.GetElementType(id, iselem)
1774
1775     ## Returns the list of submesh elements IDs
1776     #  @param Shape a geom object(subshape) IOR
1777     #         Shape must be the subshape of a ShapeToMesh()
1778     #  @return the list of integer values
1779     #  @ingroup l1_meshinfo
1780     def GetSubMeshElementsId(self, Shape):
1781         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1782             ShapeID = Shape.GetSubShapeIndices()[0]
1783         else:
1784             ShapeID = Shape
1785         return self.mesh.GetSubMeshElementsId(ShapeID)
1786
1787     ## Returns the list of submesh nodes IDs
1788     #  @param Shape a geom object(subshape) IOR
1789     #         Shape must be the subshape of a ShapeToMesh()
1790     #  @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1791     #  @return the list of integer values
1792     #  @ingroup l1_meshinfo
1793     def GetSubMeshNodesId(self, Shape, all):
1794         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1795             ShapeID = Shape.GetSubShapeIndices()[0]
1796         else:
1797             ShapeID = Shape
1798         return self.mesh.GetSubMeshNodesId(ShapeID, all)
1799
1800     ## Returns type of elements on given shape
1801     #  @param Shape a geom object(subshape) IOR
1802     #         Shape must be a subshape of a ShapeToMesh()
1803     #  @return element type
1804     #  @ingroup l1_meshinfo
1805     def GetSubMeshElementType(self, Shape):
1806         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1807             ShapeID = Shape.GetSubShapeIndices()[0]
1808         else:
1809             ShapeID = Shape
1810         return self.mesh.GetSubMeshElementType(ShapeID)
1811
1812     ## Gets the mesh description
1813     #  @return string value
1814     #  @ingroup l1_meshinfo
1815     def Dump(self):
1816         return self.mesh.Dump()
1817
1818
1819     # Get the information about nodes and elements of a mesh by its IDs:
1820     # -----------------------------------------------------------
1821
1822     ## Gets XYZ coordinates of a node
1823     #  \n If there is no nodes for the given ID - returns an empty list
1824     #  @return a list of double precision values
1825     #  @ingroup l1_meshinfo
1826     def GetNodeXYZ(self, id):
1827         return self.mesh.GetNodeXYZ(id)
1828
1829     ## Returns list of IDs of inverse elements for the given node
1830     #  \n If there is no node for the given ID - returns an empty list
1831     #  @return a list of integer values
1832     #  @ingroup l1_meshinfo
1833     def GetNodeInverseElements(self, id):
1834         return self.mesh.GetNodeInverseElements(id)
1835
1836     ## @brief Returns the position of a node on the shape
1837     #  @return SMESH::NodePosition
1838     #  @ingroup l1_meshinfo
1839     def GetNodePosition(self,NodeID):
1840         return self.mesh.GetNodePosition(NodeID)
1841
1842     ## If the given element is a node, returns the ID of shape
1843     #  \n If there is no node for the given ID - returns -1
1844     #  @return an integer value
1845     #  @ingroup l1_meshinfo
1846     def GetShapeID(self, id):
1847         return self.mesh.GetShapeID(id)
1848
1849     ## Returns the ID of the result shape after
1850     #  FindShape() from SMESH_MeshEditor for the given element
1851     #  \n If there is no element for the given ID - returns -1
1852     #  @return an integer value
1853     #  @ingroup l1_meshinfo
1854     def GetShapeIDForElem(self,id):
1855         return self.mesh.GetShapeIDForElem(id)
1856
1857     ## Returns the number of nodes for the given element
1858     #  \n If there is no element for the given ID - returns -1
1859     #  @return an integer value
1860     #  @ingroup l1_meshinfo
1861     def GetElemNbNodes(self, id):
1862         return self.mesh.GetElemNbNodes(id)
1863
1864     ## Returns the node ID the given index for the given element
1865     #  \n If there is no element for the given ID - returns -1
1866     #  \n If there is no node for the given index - returns -2
1867     #  @return an integer value
1868     #  @ingroup l1_meshinfo
1869     def GetElemNode(self, id, index):
1870         return self.mesh.GetElemNode(id, index)
1871
1872     ## Returns the IDs of nodes of the given element
1873     #  @return a list of integer values
1874     #  @ingroup l1_meshinfo
1875     def GetElemNodes(self, id):
1876         return self.mesh.GetElemNodes(id)
1877
1878     ## Returns true if the given node is the medium node in the given quadratic element
1879     #  @ingroup l1_meshinfo
1880     def IsMediumNode(self, elementID, nodeID):
1881         return self.mesh.IsMediumNode(elementID, nodeID)
1882
1883     ## Returns true if the given node is the medium node in one of quadratic elements
1884     #  @ingroup l1_meshinfo
1885     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1886         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1887
1888     ## Returns the number of edges for the given element
1889     #  @ingroup l1_meshinfo
1890     def ElemNbEdges(self, id):
1891         return self.mesh.ElemNbEdges(id)
1892
1893     ## Returns the number of faces for the given element
1894     #  @ingroup l1_meshinfo
1895     def ElemNbFaces(self, id):
1896         return self.mesh.ElemNbFaces(id)
1897
1898     ## Returns true if the given element is a polygon
1899     #  @ingroup l1_meshinfo
1900     def IsPoly(self, id):
1901         return self.mesh.IsPoly(id)
1902
1903     ## Returns true if the given element is quadratic
1904     #  @ingroup l1_meshinfo
1905     def IsQuadratic(self, id):
1906         return self.mesh.IsQuadratic(id)
1907
1908     ## Returns XYZ coordinates of the barycenter of the given element
1909     #  \n If there is no element for the given ID - returns an empty list
1910     #  @return a list of three double values
1911     #  @ingroup l1_meshinfo
1912     def BaryCenter(self, id):
1913         return self.mesh.BaryCenter(id)
1914
1915
1916     # Mesh edition (SMESH_MeshEditor functionality):
1917     # ---------------------------------------------
1918
1919     ## Removes the elements from the mesh by ids
1920     #  @param IDsOfElements is a list of ids of elements to remove
1921     #  @return True or False
1922     #  @ingroup l2_modif_del
1923     def RemoveElements(self, IDsOfElements):
1924         return self.editor.RemoveElements(IDsOfElements)
1925
1926     ## Removes nodes from mesh by ids
1927     #  @param IDsOfNodes is a list of ids of nodes to remove
1928     #  @return True or False
1929     #  @ingroup l2_modif_del
1930     def RemoveNodes(self, IDsOfNodes):
1931         return self.editor.RemoveNodes(IDsOfNodes)
1932
1933     ## Add a node to the mesh by coordinates
1934     #  @return Id of the new node
1935     #  @ingroup l2_modif_add
1936     def AddNode(self, x, y, z):
1937         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1938         self.mesh.SetParameters(Parameters)
1939         return self.editor.AddNode( x, y, z)
1940
1941     ## Creates a linear or quadratic edge (this is determined
1942     #  by the number of given nodes).
1943     #  @param IDsOfNodes the list of node IDs for creation of the element.
1944     #  The order of nodes in this list should correspond to the description
1945     #  of MED. \n This description is located by the following link:
1946     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1947     #  @return the Id of the new edge
1948     #  @ingroup l2_modif_add
1949     def AddEdge(self, IDsOfNodes):
1950         return self.editor.AddEdge(IDsOfNodes)
1951
1952     ## Creates a linear or quadratic face (this is determined
1953     #  by the number of given nodes).
1954     #  @param IDsOfNodes the list of node IDs for creation of the element.
1955     #  The order of nodes in this list should correspond to the description
1956     #  of MED. \n This description is located by the following link:
1957     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1958     #  @return the Id of the new face
1959     #  @ingroup l2_modif_add
1960     def AddFace(self, IDsOfNodes):
1961         return self.editor.AddFace(IDsOfNodes)
1962
1963     ## Adds a polygonal face to the mesh by the list of node IDs
1964     #  @param IdsOfNodes the list of node IDs for creation of the element.
1965     #  @return the Id of the new face
1966     #  @ingroup l2_modif_add
1967     def AddPolygonalFace(self, IdsOfNodes):
1968         return self.editor.AddPolygonalFace(IdsOfNodes)
1969
1970     ## Creates both simple and quadratic volume (this is determined
1971     #  by the number of given nodes).
1972     #  @param IDsOfNodes the list of node IDs for creation of the element.
1973     #  The order of nodes in this list should correspond to the description
1974     #  of MED. \n This description is located by the following link:
1975     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1976     #  @return the Id of the new volumic element
1977     #  @ingroup l2_modif_add
1978     def AddVolume(self, IDsOfNodes):
1979         return self.editor.AddVolume(IDsOfNodes)
1980
1981     ## Creates a volume of many faces, giving nodes for each face.
1982     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
1983     #  @param Quantities the list of integer values, Quantities[i]
1984     #         gives the quantity of nodes in face number i.
1985     #  @return the Id of the new volumic element
1986     #  @ingroup l2_modif_add
1987     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1988         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1989
1990     ## Creates a volume of many faces, giving the IDs of the existing faces.
1991     #  @param IdsOfFaces the list of face IDs for volume creation.
1992     #
1993     #  Note:  The created volume will refer only to the nodes
1994     #         of the given faces, not to the faces themselves.
1995     #  @return the Id of the new volumic element
1996     #  @ingroup l2_modif_add
1997     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1998         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1999
2000
2001     ## @brief Binds a node to a vertex
2002     #  @param NodeID a node ID
2003     #  @param Vertex a vertex or vertex ID
2004     #  @return True if succeed else raises an exception
2005     #  @ingroup l2_modif_add
2006     def SetNodeOnVertex(self, NodeID, Vertex):
2007         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2008             VertexID = Vertex.GetSubShapeIndices()[0]
2009         else:
2010             VertexID = Vertex
2011         try:
2012             self.editor.SetNodeOnVertex(NodeID, VertexID)
2013         except SALOME.SALOME_Exception, inst:
2014             raise ValueError, inst.details.text
2015         return True
2016
2017
2018     ## @brief Stores the node position on an edge
2019     #  @param NodeID a node ID
2020     #  @param Edge an edge or edge ID
2021     #  @param paramOnEdge a parameter on the edge where the node is located
2022     #  @return True if succeed else raises an exception
2023     #  @ingroup l2_modif_add
2024     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2025         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2026             EdgeID = Edge.GetSubShapeIndices()[0]
2027         else:
2028             EdgeID = Edge
2029         try:
2030             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2031         except SALOME.SALOME_Exception, inst:
2032             raise ValueError, inst.details.text
2033         return True
2034
2035     ## @brief Stores node position on a face
2036     #  @param NodeID a node ID
2037     #  @param Face a face or face ID
2038     #  @param u U parameter on the face where the node is located
2039     #  @param v V parameter on the face where the node is located
2040     #  @return True if succeed else raises an exception
2041     #  @ingroup l2_modif_add
2042     def SetNodeOnFace(self, NodeID, Face, u, v):
2043         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2044             FaceID = Face.GetSubShapeIndices()[0]
2045         else:
2046             FaceID = Face
2047         try:
2048             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2049         except SALOME.SALOME_Exception, inst:
2050             raise ValueError, inst.details.text
2051         return True
2052
2053     ## @brief Binds a node to a solid
2054     #  @param NodeID a node ID
2055     #  @param Solid  a solid or solid ID
2056     #  @return True if succeed else raises an exception
2057     #  @ingroup l2_modif_add
2058     def SetNodeInVolume(self, NodeID, Solid):
2059         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2060             SolidID = Solid.GetSubShapeIndices()[0]
2061         else:
2062             SolidID = Solid
2063         try:
2064             self.editor.SetNodeInVolume(NodeID, SolidID)
2065         except SALOME.SALOME_Exception, inst:
2066             raise ValueError, inst.details.text
2067         return True
2068
2069     ## @brief Bind an element to a shape
2070     #  @param ElementID an element ID
2071     #  @param Shape a shape or shape ID
2072     #  @return True if succeed else raises an exception
2073     #  @ingroup l2_modif_add
2074     def SetMeshElementOnShape(self, ElementID, Shape):
2075         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2076             ShapeID = Shape.GetSubShapeIndices()[0]
2077         else:
2078             ShapeID = Shape
2079         try:
2080             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2081         except SALOME.SALOME_Exception, inst:
2082             raise ValueError, inst.details.text
2083         return True
2084
2085
2086     ## Moves the node with the given id
2087     #  @param NodeID the id of the node
2088     #  @param x  a new X coordinate
2089     #  @param y  a new Y coordinate
2090     #  @param z  a new Z coordinate
2091     #  @return True if succeed else False
2092     #  @ingroup l2_modif_movenode
2093     def MoveNode(self, NodeID, x, y, z):
2094         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2095         self.mesh.SetParameters(Parameters)
2096         return self.editor.MoveNode(NodeID, x, y, z)
2097
2098     ## Finds the node closest to a point and moves it to a point location
2099     #  @param x  the X coordinate of a point
2100     #  @param y  the Y coordinate of a point
2101     #  @param z  the Z coordinate of a point
2102     #  @return the ID of a node
2103     #  @ingroup l2_modif_throughp
2104     def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2105         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2106         self.mesh.SetParameters(Parameters)
2107         return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2108
2109     ## Finds the node closest to a point
2110     #  @param x  the X coordinate of a point
2111     #  @param y  the Y coordinate of a point
2112     #  @param z  the Z coordinate of a point
2113     #  @return the ID of a node
2114     #  @ingroup l2_modif_throughp
2115     def FindNodeClosestTo(self, x, y, z):
2116         preview = self.mesh.GetMeshEditPreviewer()
2117         return preview.MoveClosestNodeToPoint(x, y, z, -1)
2118
2119     ## Finds the node closest to a point and moves it to a point location
2120     #  @param x  the X coordinate of a point
2121     #  @param y  the Y coordinate of a point
2122     #  @param z  the Z coordinate of a point
2123     #  @return the ID of a moved node
2124     #  @ingroup l2_modif_throughp
2125     def MeshToPassThroughAPoint(self, x, y, z):
2126         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2127
2128     ## Replaces two neighbour triangles sharing Node1-Node2 link
2129     #  with the triangles built on the same 4 nodes but having other common link.
2130     #  @param NodeID1  the ID of the first node
2131     #  @param NodeID2  the ID of the second node
2132     #  @return false if proper faces were not found
2133     #  @ingroup l2_modif_invdiag
2134     def InverseDiag(self, NodeID1, NodeID2):
2135         return self.editor.InverseDiag(NodeID1, NodeID2)
2136
2137     ## Replaces two neighbour triangles sharing Node1-Node2 link
2138     #  with a quadrangle built on the same 4 nodes.
2139     #  @param NodeID1  the ID of the first node
2140     #  @param NodeID2  the ID of the second node
2141     #  @return false if proper faces were not found
2142     #  @ingroup l2_modif_unitetri
2143     def DeleteDiag(self, NodeID1, NodeID2):
2144         return self.editor.DeleteDiag(NodeID1, NodeID2)
2145
2146     ## Reorients elements by ids
2147     #  @param IDsOfElements if undefined reorients all mesh elements
2148     #  @return True if succeed else False
2149     #  @ingroup l2_modif_changori
2150     def Reorient(self, IDsOfElements=None):
2151         if IDsOfElements == None:
2152             IDsOfElements = self.GetElementsId()
2153         return self.editor.Reorient(IDsOfElements)
2154
2155     ## Reorients all elements of the object
2156     #  @param theObject mesh, submesh or group
2157     #  @return True if succeed else False
2158     #  @ingroup l2_modif_changori
2159     def ReorientObject(self, theObject):
2160         if ( isinstance( theObject, Mesh )):
2161             theObject = theObject.GetMesh()
2162         return self.editor.ReorientObject(theObject)
2163
2164     ## Fuses the neighbouring triangles into quadrangles.
2165     #  @param IDsOfElements The triangles to be fused,
2166     #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
2167     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
2168     #                       is still performed; theMaxAngle is mesured in radians.
2169     #                       Also it could be a name of variable which defines angle in degrees.
2170     #  @return TRUE in case of success, FALSE otherwise.
2171     #  @ingroup l2_modif_unitetri
2172     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2173         flag = False
2174         if isinstance(MaxAngle,str):
2175             flag = True
2176         MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2177         if flag:
2178             MaxAngle = DegreesToRadians(MaxAngle)
2179         if IDsOfElements == []:
2180             IDsOfElements = self.GetElementsId()
2181         self.mesh.SetParameters(Parameters)
2182         Functor = 0
2183         if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2184             Functor = theCriterion
2185         else:
2186             Functor = self.smeshpyD.GetFunctor(theCriterion)
2187         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2188
2189     ## Fuses the neighbouring triangles of the object into quadrangles
2190     #  @param theObject is mesh, submesh or group
2191     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2192     #  @param MaxAngle   a max angle between element normals at which the fusion
2193     #                   is still performed; theMaxAngle is mesured in radians.
2194     #  @return TRUE in case of success, FALSE otherwise.
2195     #  @ingroup l2_modif_unitetri
2196     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2197         if ( isinstance( theObject, Mesh )):
2198             theObject = theObject.GetMesh()
2199         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2200
2201     ## Splits quadrangles into triangles.
2202     #  @param IDsOfElements the faces to be splitted.
2203     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2204     #  @return TRUE in case of success, FALSE otherwise.
2205     #  @ingroup l2_modif_cutquadr
2206     def QuadToTri (self, IDsOfElements, theCriterion):
2207         if IDsOfElements == []:
2208             IDsOfElements = self.GetElementsId()
2209         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2210
2211     ## Splits quadrangles into triangles.
2212     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
2213     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2214     #  @return TRUE in case of success, FALSE otherwise.
2215     #  @ingroup l2_modif_cutquadr
2216     def QuadToTriObject (self, theObject, theCriterion):
2217         if ( isinstance( theObject, Mesh )):
2218             theObject = theObject.GetMesh()
2219         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2220
2221     ## Splits quadrangles into triangles.
2222     #  @param IDsOfElements the faces to be splitted
2223     #  @param Diag13        is used to choose a diagonal for splitting.
2224     #  @return TRUE in case of success, FALSE otherwise.
2225     #  @ingroup l2_modif_cutquadr
2226     def SplitQuad (self, IDsOfElements, Diag13):
2227         if IDsOfElements == []:
2228             IDsOfElements = self.GetElementsId()
2229         return self.editor.SplitQuad(IDsOfElements, Diag13)
2230
2231     ## Splits quadrangles into triangles.
2232     #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2233     #  @param Diag13    is used to choose a diagonal for splitting.
2234     #  @return TRUE in case of success, FALSE otherwise.
2235     #  @ingroup l2_modif_cutquadr
2236     def SplitQuadObject (self, theObject, Diag13):
2237         if ( isinstance( theObject, Mesh )):
2238             theObject = theObject.GetMesh()
2239         return self.editor.SplitQuadObject(theObject, Diag13)
2240
2241     ## Finds a better splitting of the given quadrangle.
2242     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
2243     #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
2244     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
2245     #          diagonal is better, 0 if error occurs.
2246     #  @ingroup l2_modif_cutquadr
2247     def BestSplit (self, IDOfQuad, theCriterion):
2248         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2249
2250     ## Splits quadrangle faces near triangular facets of volumes
2251     #
2252     #  @ingroup l1_auxiliary
2253     def SplitQuadsNearTriangularFacets(self):
2254         faces_array = self.GetElementsByType(SMESH.FACE)
2255         for face_id in faces_array:
2256             if self.GetElemNbNodes(face_id) == 4: # quadrangle
2257                 quad_nodes = self.mesh.GetElemNodes(face_id)
2258                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2259                 isVolumeFound = False
2260                 for node1_elem in node1_elems:
2261                     if not isVolumeFound:
2262                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2263                             nb_nodes = self.GetElemNbNodes(node1_elem)
2264                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2265                                 volume_elem = node1_elem
2266                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2267                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2268                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2269                                         isVolumeFound = True
2270                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2271                                             self.SplitQuad([face_id], False) # diagonal 2-4
2272                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2273                                         isVolumeFound = True
2274                                         self.SplitQuad([face_id], True) # diagonal 1-3
2275                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2276                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2277                                         isVolumeFound = True
2278                                         self.SplitQuad([face_id], True) # diagonal 1-3
2279
2280     ## @brief Splits hexahedrons into tetrahedrons.
2281     #
2282     #  This operation uses pattern mapping functionality for splitting.
2283     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2284     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2285     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2286     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2287     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2288     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2289     #  @return TRUE in case of success, FALSE otherwise.
2290     #  @ingroup l1_auxiliary
2291     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2292         # Pattern:     5.---------.6
2293         #              /|#*      /|
2294         #             / | #*    / |
2295         #            /  |  # * /  |
2296         #           /   |   # /*  |
2297         # (0,0,1) 4.---------.7 * |
2298         #          |#*  |1   | # *|
2299         #          | # *.----|---#.2
2300         #          |  #/ *   |   /
2301         #          |  /#  *  |  /
2302         #          | /   # * | /
2303         #          |/      #*|/
2304         # (0,0,0) 0.---------.3
2305         pattern_tetra = "!!! Nb of points: \n 8 \n\
2306         !!! Points: \n\
2307         0 0 0  !- 0 \n\
2308         0 1 0  !- 1 \n\
2309         1 1 0  !- 2 \n\
2310         1 0 0  !- 3 \n\
2311         0 0 1  !- 4 \n\
2312         0 1 1  !- 5 \n\
2313         1 1 1  !- 6 \n\
2314         1 0 1  !- 7 \n\
2315         !!! Indices of points of 6 tetras: \n\
2316         0 3 4 1 \n\
2317         7 4 3 1 \n\
2318         4 7 5 1 \n\
2319         6 2 5 7 \n\
2320         1 5 2 7 \n\
2321         2 3 1 7 \n"
2322
2323         pattern = self.smeshpyD.GetPattern()
2324         isDone  = pattern.LoadFromFile(pattern_tetra)
2325         if not isDone:
2326             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2327             return isDone
2328
2329         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2330         isDone = pattern.MakeMesh(self.mesh, False, False)
2331         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2332
2333         # split quafrangle faces near triangular facets of volumes
2334         self.SplitQuadsNearTriangularFacets()
2335
2336         return isDone
2337
2338     ## @brief Split hexahedrons into prisms.
2339     #
2340     #  Uses the pattern mapping functionality for splitting.
2341     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2342     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2343     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2344     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2345     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2346     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2347     #  @return TRUE in case of success, FALSE otherwise.
2348     #  @ingroup l1_auxiliary
2349     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2350         # Pattern:     5.---------.6
2351         #              /|#       /|
2352         #             / | #     / |
2353         #            /  |  #   /  |
2354         #           /   |   # /   |
2355         # (0,0,1) 4.---------.7   |
2356         #          |    |    |    |
2357         #          |   1.----|----.2
2358         #          |   / *   |   /
2359         #          |  /   *  |  /
2360         #          | /     * | /
2361         #          |/       *|/
2362         # (0,0,0) 0.---------.3
2363         pattern_prism = "!!! Nb of points: \n 8 \n\
2364         !!! Points: \n\
2365         0 0 0  !- 0 \n\
2366         0 1 0  !- 1 \n\
2367         1 1 0  !- 2 \n\
2368         1 0 0  !- 3 \n\
2369         0 0 1  !- 4 \n\
2370         0 1 1  !- 5 \n\
2371         1 1 1  !- 6 \n\
2372         1 0 1  !- 7 \n\
2373         !!! Indices of points of 2 prisms: \n\
2374         0 1 3 4 5 7 \n\
2375         2 3 1 6 7 5 \n"
2376
2377         pattern = self.smeshpyD.GetPattern()
2378         isDone  = pattern.LoadFromFile(pattern_prism)
2379         if not isDone:
2380             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2381             return isDone
2382
2383         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2384         isDone = pattern.MakeMesh(self.mesh, False, False)
2385         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2386
2387         # Splits quafrangle faces near triangular facets of volumes
2388         self.SplitQuadsNearTriangularFacets()
2389
2390         return isDone
2391
2392     ## Smoothes elements
2393     #  @param IDsOfElements the list if ids of elements to smooth
2394     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2395     #  Note that nodes built on edges and boundary nodes are always fixed.
2396     #  @param MaxNbOfIterations the maximum number of iterations
2397     #  @param MaxAspectRatio varies in range [1.0, inf]
2398     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2399     #  @return TRUE in case of success, FALSE otherwise.
2400     #  @ingroup l2_modif_smooth
2401     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2402                MaxNbOfIterations, MaxAspectRatio, Method):
2403         if IDsOfElements == []:
2404             IDsOfElements = self.GetElementsId()
2405         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2406         self.mesh.SetParameters(Parameters)
2407         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2408                                   MaxNbOfIterations, MaxAspectRatio, Method)
2409
2410     ## Smoothes elements which belong to the given object
2411     #  @param theObject the object to smooth
2412     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2413     #  Note that nodes built on edges and boundary nodes are always fixed.
2414     #  @param MaxNbOfIterations the maximum number of iterations
2415     #  @param MaxAspectRatio varies in range [1.0, inf]
2416     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2417     #  @return TRUE in case of success, FALSE otherwise.
2418     #  @ingroup l2_modif_smooth
2419     def SmoothObject(self, theObject, IDsOfFixedNodes,
2420                      MaxNbOfIterations, MaxAspectRatio, Method):
2421         if ( isinstance( theObject, Mesh )):
2422             theObject = theObject.GetMesh()
2423         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2424                                         MaxNbOfIterations, MaxAspectRatio, Method)
2425
2426     ## Parametrically smoothes the given elements
2427     #  @param IDsOfElements the list if ids of elements to smooth
2428     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2429     #  Note that nodes built on edges and boundary nodes are always fixed.
2430     #  @param MaxNbOfIterations the maximum number of iterations
2431     #  @param MaxAspectRatio varies in range [1.0, inf]
2432     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2433     #  @return TRUE in case of success, FALSE otherwise.
2434     #  @ingroup l2_modif_smooth
2435     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2436                          MaxNbOfIterations, MaxAspectRatio, Method):
2437         if IDsOfElements == []:
2438             IDsOfElements = self.GetElementsId()
2439         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2440         self.mesh.SetParameters(Parameters)
2441         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2442                                             MaxNbOfIterations, MaxAspectRatio, Method)
2443
2444     ## Parametrically smoothes the elements which belong to the given object
2445     #  @param theObject the object to smooth
2446     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2447     #  Note that nodes built on edges and boundary nodes are always fixed.
2448     #  @param MaxNbOfIterations the maximum number of iterations
2449     #  @param MaxAspectRatio varies in range [1.0, inf]
2450     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2451     #  @return TRUE in case of success, FALSE otherwise.
2452     #  @ingroup l2_modif_smooth
2453     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2454                                MaxNbOfIterations, MaxAspectRatio, Method):
2455         if ( isinstance( theObject, Mesh )):
2456             theObject = theObject.GetMesh()
2457         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2458                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2459
2460     ## Converts the mesh to quadratic, deletes old elements, replacing
2461     #  them with quadratic with the same id.
2462     #  @ingroup l2_modif_tofromqu
2463     def ConvertToQuadratic(self, theForce3d):
2464         self.editor.ConvertToQuadratic(theForce3d)
2465
2466     ## Converts the mesh from quadratic to ordinary,
2467     #  deletes old quadratic elements, \n replacing
2468     #  them with ordinary mesh elements with the same id.
2469     #  @return TRUE in case of success, FALSE otherwise.
2470     #  @ingroup l2_modif_tofromqu
2471     def ConvertFromQuadratic(self):
2472         return self.editor.ConvertFromQuadratic()
2473
2474     ## Renumber mesh nodes
2475     #  @ingroup l2_modif_renumber
2476     def RenumberNodes(self):
2477         self.editor.RenumberNodes()
2478
2479     ## Renumber mesh elements
2480     #  @ingroup l2_modif_renumber
2481     def RenumberElements(self):
2482         self.editor.RenumberElements()
2483
2484     ## Generates new elements by rotation of the elements around the axis
2485     #  @param IDsOfElements the list of ids of elements to sweep
2486     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2487     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2488     #  @param NbOfSteps the number of steps
2489     #  @param Tolerance tolerance
2490     #  @param MakeGroups forces the generation of new groups from existing ones
2491     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2492     #                    of all steps, else - size of each step
2493     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2494     #  @ingroup l2_modif_extrurev
2495     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2496                       MakeGroups=False, TotalAngle=False):
2497         flag = False
2498         if isinstance(AngleInRadians,str):
2499             flag = True
2500         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2501         if flag:
2502             AngleInRadians = DegreesToRadians(AngleInRadians)
2503         if IDsOfElements == []:
2504             IDsOfElements = self.GetElementsId()
2505         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2506             Axis = self.smeshpyD.GetAxisStruct(Axis)
2507         Axis,AxisParameters = ParseAxisStruct(Axis)
2508         if TotalAngle and NbOfSteps:
2509             AngleInRadians /= NbOfSteps
2510         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2511         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2512         self.mesh.SetParameters(Parameters)
2513         if MakeGroups:
2514             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2515                                                        AngleInRadians, NbOfSteps, Tolerance)
2516         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2517         return []
2518
2519     ## Generates new elements by rotation of the elements of object around the axis
2520     #  @param theObject object which elements should be sweeped
2521     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2522     #  @param AngleInRadians the angle of Rotation
2523     #  @param NbOfSteps number of steps
2524     #  @param Tolerance tolerance
2525     #  @param MakeGroups forces the generation of new groups from existing ones
2526     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2527     #                    of all steps, else - size of each step
2528     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2529     #  @ingroup l2_modif_extrurev
2530     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2531                             MakeGroups=False, TotalAngle=False):
2532         flag = False
2533         if isinstance(AngleInRadians,str):
2534             flag = True
2535         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2536         if flag:
2537             AngleInRadians = DegreesToRadians(AngleInRadians)
2538         if ( isinstance( theObject, Mesh )):
2539             theObject = theObject.GetMesh()
2540         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2541             Axis = self.smeshpyD.GetAxisStruct(Axis)
2542         Axis,AxisParameters = ParseAxisStruct(Axis)
2543         if TotalAngle and NbOfSteps:
2544             AngleInRadians /= NbOfSteps
2545         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2546         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2547         self.mesh.SetParameters(Parameters)
2548         if MakeGroups:
2549             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2550                                                              NbOfSteps, Tolerance)
2551         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2552         return []
2553
2554     ## Generates new elements by rotation of the elements of object around the axis
2555     #  @param theObject object which elements should be sweeped
2556     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2557     #  @param AngleInRadians the angle of Rotation
2558     #  @param NbOfSteps number of steps
2559     #  @param Tolerance tolerance
2560     #  @param MakeGroups forces the generation of new groups from existing ones
2561     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2562     #                    of all steps, else - size of each step
2563     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2564     #  @ingroup l2_modif_extrurev
2565     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2566                               MakeGroups=False, TotalAngle=False):
2567         flag = False
2568         if isinstance(AngleInRadians,str):
2569             flag = True
2570         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2571         if flag:
2572             AngleInRadians = DegreesToRadians(AngleInRadians)
2573         if ( isinstance( theObject, Mesh )):
2574             theObject = theObject.GetMesh()
2575         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2576             Axis = self.smeshpyD.GetAxisStruct(Axis)
2577         Axis,AxisParameters = ParseAxisStruct(Axis)
2578         if TotalAngle and NbOfSteps:
2579             AngleInRadians /= NbOfSteps
2580         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2581         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2582         self.mesh.SetParameters(Parameters)
2583         if MakeGroups:
2584             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2585                                                                NbOfSteps, Tolerance)
2586         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2587         return []
2588
2589     ## Generates new elements by rotation of the elements of object around the axis
2590     #  @param theObject object which elements should be sweeped
2591     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2592     #  @param AngleInRadians the angle of Rotation
2593     #  @param NbOfSteps number of steps
2594     #  @param Tolerance tolerance
2595     #  @param MakeGroups forces the generation of new groups from existing ones
2596     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2597     #                    of all steps, else - size of each step
2598     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2599     #  @ingroup l2_modif_extrurev
2600     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2601                               MakeGroups=False, TotalAngle=False):
2602         flag = False
2603         if isinstance(AngleInRadians,str):
2604             flag = True
2605         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2606         if flag:
2607             AngleInRadians = DegreesToRadians(AngleInRadians)
2608         if ( isinstance( theObject, Mesh )):
2609             theObject = theObject.GetMesh()
2610         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2611             Axis = self.smeshpyD.GetAxisStruct(Axis)
2612         Axis,AxisParameters = ParseAxisStruct(Axis)
2613         if TotalAngle and NbOfSteps:
2614             AngleInRadians /= NbOfSteps
2615         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2616         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2617         self.mesh.SetParameters(Parameters)
2618         if MakeGroups:
2619             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2620                                                              NbOfSteps, Tolerance)
2621         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2622         return []
2623
2624     ## Generates new elements by extrusion of the elements with given ids
2625     #  @param IDsOfElements the list of elements ids for extrusion
2626     #  @param StepVector vector, defining the direction and value of extrusion
2627     #  @param NbOfSteps the number of steps
2628     #  @param MakeGroups forces the generation of new groups from existing ones
2629     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2630     #  @ingroup l2_modif_extrurev
2631     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2632         if IDsOfElements == []:
2633             IDsOfElements = self.GetElementsId()
2634         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2635             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2636         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2637         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2638         Parameters = StepVectorParameters + var_separator + Parameters
2639         self.mesh.SetParameters(Parameters)
2640         if MakeGroups:
2641             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2642         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2643         return []
2644
2645     ## Generates new elements by extrusion of the elements with given ids
2646     #  @param IDsOfElements is ids of elements
2647     #  @param StepVector vector, defining the direction and value of extrusion
2648     #  @param NbOfSteps the number of steps
2649     #  @param ExtrFlags sets flags for extrusion
2650     #  @param SewTolerance uses for comparing locations of nodes if flag
2651     #         EXTRUSION_FLAG_SEW is set
2652     #  @param MakeGroups forces the generation of new groups from existing ones
2653     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2654     #  @ingroup l2_modif_extrurev
2655     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2656                           ExtrFlags, SewTolerance, MakeGroups=False):
2657         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2658             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2659         if MakeGroups:
2660             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2661                                                            ExtrFlags, SewTolerance)
2662         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2663                                       ExtrFlags, SewTolerance)
2664         return []
2665
2666     ## Generates new elements by extrusion of the elements which belong to the object
2667     #  @param theObject the object which elements should be processed
2668     #  @param StepVector vector, defining the direction and value of extrusion
2669     #  @param NbOfSteps the number of steps
2670     #  @param MakeGroups forces the generation of new groups from existing ones
2671     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2672     #  @ingroup l2_modif_extrurev
2673     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2674         if ( isinstance( theObject, Mesh )):
2675             theObject = theObject.GetMesh()
2676         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2677             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2678         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2679         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2680         Parameters = StepVectorParameters + var_separator + Parameters
2681         self.mesh.SetParameters(Parameters)
2682         if MakeGroups:
2683             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2684         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2685         return []
2686
2687     ## Generates new elements by extrusion of the elements which belong to the object
2688     #  @param theObject object which elements should be processed
2689     #  @param StepVector vector, defining the direction and value of extrusion
2690     #  @param NbOfSteps the number of steps
2691     #  @param MakeGroups to generate new groups from existing ones
2692     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2693     #  @ingroup l2_modif_extrurev
2694     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2695         if ( isinstance( theObject, Mesh )):
2696             theObject = theObject.GetMesh()
2697         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2698             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2699         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2700         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2701         Parameters = StepVectorParameters + var_separator + Parameters
2702         self.mesh.SetParameters(Parameters)
2703         if MakeGroups:
2704             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2705         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2706         return []
2707
2708     ## Generates new elements by extrusion of the elements which belong to the object
2709     #  @param theObject object which elements should be processed
2710     #  @param StepVector vector, defining the direction and value of extrusion
2711     #  @param NbOfSteps the number of steps
2712     #  @param MakeGroups forces the generation of new groups from existing ones
2713     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2714     #  @ingroup l2_modif_extrurev
2715     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2716         if ( isinstance( theObject, Mesh )):
2717             theObject = theObject.GetMesh()
2718         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2719             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2720         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2721         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2722         Parameters = StepVectorParameters + var_separator + Parameters
2723         self.mesh.SetParameters(Parameters)
2724         if MakeGroups:
2725             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2726         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2727         return []
2728
2729
2730
2731     ## Generates new elements by extrusion of the given elements
2732     #  The path of extrusion must be a meshed edge.
2733     #  @param Base mesh or list of ids of elements for extrusion
2734     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2735     #  @param NodeStart the start node from Path. Defines the direction of extrusion
2736     #  @param HasAngles allows the shape to be rotated around the path
2737     #                   to get the resulting mesh in a helical fashion
2738     #  @param Angles list of angles in radians
2739     #  @param LinearVariation forces the computation of rotation angles as linear
2740     #                         variation of the given Angles along path steps
2741     #  @param HasRefPoint allows using the reference point
2742     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2743     #         The User can specify any point as the Reference Point.
2744     #  @param MakeGroups forces the generation of new groups from existing ones
2745     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
2746     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2747     #          only SMESH::Extrusion_Error otherwise
2748     #  @ingroup l2_modif_extrurev
2749     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2750                             HasAngles, Angles, LinearVariation,
2751                             HasRefPoint, RefPoint, MakeGroups, ElemType):
2752         Angles,AnglesParameters = ParseAngles(Angles)
2753         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2754         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2755             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2756             pass
2757         Parameters = AnglesParameters + var_separator + RefPointParameters
2758         self.mesh.SetParameters(Parameters)
2759
2760         if isinstance(Base,list):
2761             IDsOfElements = []
2762             if Base == []: IDsOfElements = self.GetElementsId()
2763             else: IDsOfElements = Base
2764             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2765                                                    HasAngles, Angles, LinearVariation,
2766                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
2767         else:
2768             if isinstance(Base,Mesh):
2769                 return self.editor.ExtrusionAlongPathObjX(Base.GetMesh(), Path, NodeStart,
2770                                                           HasAngles, Angles, LinearVariation,
2771                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
2772             else:
2773                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2774
2775
2776     ## Generates new elements by extrusion of the given elements
2777     #  The path of extrusion must be a meshed edge.
2778     #  @param IDsOfElements ids of elements
2779     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2780     #  @param PathShape shape(edge) defines the sub-mesh for the path
2781     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2782     #  @param HasAngles allows the shape to be rotated around the path
2783     #                   to get the resulting mesh in a helical fashion
2784     #  @param Angles list of angles in radians
2785     #  @param HasRefPoint allows using the reference point
2786     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2787     #         The User can specify any point as the Reference Point.
2788     #  @param MakeGroups forces the generation of new groups from existing ones
2789     #  @param LinearVariation forces the computation of rotation angles as linear
2790     #                         variation of the given Angles along path steps
2791     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2792     #          only SMESH::Extrusion_Error otherwise
2793     #  @ingroup l2_modif_extrurev
2794     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2795                            HasAngles, Angles, HasRefPoint, RefPoint,
2796                            MakeGroups=False, LinearVariation=False):
2797         Angles,AnglesParameters = ParseAngles(Angles)
2798         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2799         if IDsOfElements == []:
2800             IDsOfElements = self.GetElementsId()
2801         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2802             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2803             pass
2804         if ( isinstance( PathMesh, Mesh )):
2805             PathMesh = PathMesh.GetMesh()
2806         if HasAngles and Angles and LinearVariation:
2807             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2808             pass
2809         Parameters = AnglesParameters + var_separator + RefPointParameters
2810         self.mesh.SetParameters(Parameters)
2811         if MakeGroups:
2812             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2813                                                             PathShape, NodeStart, HasAngles,
2814                                                             Angles, HasRefPoint, RefPoint)
2815         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2816                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2817
2818     ## Generates new elements by extrusion of the elements which belong to the object
2819     #  The path of extrusion must be a meshed edge.
2820     #  @param theObject the object which elements should be processed
2821     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2822     #  @param PathShape shape(edge) defines the sub-mesh for the path
2823     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2824     #  @param HasAngles allows the shape to be rotated around the path
2825     #                   to get the resulting mesh in a helical fashion
2826     #  @param Angles list of angles
2827     #  @param HasRefPoint allows using the reference point
2828     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2829     #         The User can specify any point as the Reference Point.
2830     #  @param MakeGroups forces the generation of new groups from existing ones
2831     #  @param LinearVariation forces the computation of rotation angles as linear
2832     #                         variation of the given Angles along path steps
2833     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2834     #          only SMESH::Extrusion_Error otherwise
2835     #  @ingroup l2_modif_extrurev
2836     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2837                                  HasAngles, Angles, HasRefPoint, RefPoint,
2838                                  MakeGroups=False, LinearVariation=False):
2839         Angles,AnglesParameters = ParseAngles(Angles)
2840         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2841         if ( isinstance( theObject, Mesh )):
2842             theObject = theObject.GetMesh()
2843         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2844             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2845         if ( isinstance( PathMesh, Mesh )):
2846             PathMesh = PathMesh.GetMesh()
2847         if HasAngles and Angles and LinearVariation:
2848             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2849             pass
2850         Parameters = AnglesParameters + var_separator + RefPointParameters
2851         self.mesh.SetParameters(Parameters)
2852         if MakeGroups:
2853             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2854                                                                   PathShape, NodeStart, HasAngles,
2855                                                                   Angles, HasRefPoint, RefPoint)
2856         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2857                                                     NodeStart, HasAngles, Angles, HasRefPoint,
2858                                                     RefPoint)
2859
2860     ## Generates new elements by extrusion of the elements which belong to the object
2861     #  The path of extrusion must be a meshed edge.
2862     #  @param theObject the object which elements should be processed
2863     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2864     #  @param PathShape shape(edge) defines the sub-mesh for the path
2865     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2866     #  @param HasAngles allows the shape to be rotated around the path
2867     #                   to get the resulting mesh in a helical fashion
2868     #  @param Angles list of angles
2869     #  @param HasRefPoint allows using the reference point
2870     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2871     #         The User can specify any point as the Reference Point.
2872     #  @param MakeGroups forces the generation of new groups from existing ones
2873     #  @param LinearVariation forces the computation of rotation angles as linear
2874     #                         variation of the given Angles along path steps
2875     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2876     #          only SMESH::Extrusion_Error otherwise
2877     #  @ingroup l2_modif_extrurev
2878     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2879                                    HasAngles, Angles, HasRefPoint, RefPoint,
2880                                    MakeGroups=False, LinearVariation=False):
2881         Angles,AnglesParameters = ParseAngles(Angles)
2882         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2883         if ( isinstance( theObject, Mesh )):
2884             theObject = theObject.GetMesh()
2885         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2886             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2887         if ( isinstance( PathMesh, Mesh )):
2888             PathMesh = PathMesh.GetMesh()
2889         if HasAngles and Angles and LinearVariation:
2890             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2891             pass
2892         Parameters = AnglesParameters + var_separator + RefPointParameters
2893         self.mesh.SetParameters(Parameters)
2894         if MakeGroups:
2895             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2896                                                                     PathShape, NodeStart, HasAngles,
2897                                                                     Angles, HasRefPoint, RefPoint)
2898         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2899                                                       NodeStart, HasAngles, Angles, HasRefPoint,
2900                                                       RefPoint)
2901
2902     ## Generates new elements by extrusion of the elements which belong to the object
2903     #  The path of extrusion must be a meshed edge.
2904     #  @param theObject the object which elements should be processed
2905     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2906     #  @param PathShape shape(edge) defines the sub-mesh for the path
2907     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2908     #  @param HasAngles allows the shape to be rotated around the path
2909     #                   to get the resulting mesh in a helical fashion
2910     #  @param Angles list of angles
2911     #  @param HasRefPoint allows using the reference point
2912     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2913     #         The User can specify any point as the Reference Point.
2914     #  @param MakeGroups forces the generation of new groups from existing ones
2915     #  @param LinearVariation forces the computation of rotation angles as linear
2916     #                         variation of the given Angles along path steps
2917     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2918     #          only SMESH::Extrusion_Error otherwise
2919     #  @ingroup l2_modif_extrurev
2920     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2921                                    HasAngles, Angles, HasRefPoint, RefPoint,
2922                                    MakeGroups=False, LinearVariation=False):
2923         Angles,AnglesParameters = ParseAngles(Angles)
2924         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2925         if ( isinstance( theObject, Mesh )):
2926             theObject = theObject.GetMesh()
2927         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2928             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2929         if ( isinstance( PathMesh, Mesh )):
2930             PathMesh = PathMesh.GetMesh()
2931         if HasAngles and Angles and LinearVariation:
2932             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2933             pass
2934         Parameters = AnglesParameters + var_separator + RefPointParameters
2935         self.mesh.SetParameters(Parameters)
2936         if MakeGroups:
2937             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2938                                                                     PathShape, NodeStart, HasAngles,
2939                                                                     Angles, HasRefPoint, RefPoint)
2940         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2941                                                       NodeStart, HasAngles, Angles, HasRefPoint,
2942                                                       RefPoint)
2943
2944     ## Creates a symmetrical copy of mesh elements
2945     #  @param IDsOfElements list of elements ids
2946     #  @param Mirror is AxisStruct or geom object(point, line, plane)
2947     #  @param theMirrorType is  POINT, AXIS or PLANE
2948     #  If the Mirror is a geom object this parameter is unnecessary
2949     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2950     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2951     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2952     #  @ingroup l2_modif_trsf
2953     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2954         if IDsOfElements == []:
2955             IDsOfElements = self.GetElementsId()
2956         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2957             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2958         Mirror,Parameters = ParseAxisStruct(Mirror)
2959         self.mesh.SetParameters(Parameters)
2960         if Copy and MakeGroups:
2961             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2962         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2963         return []
2964
2965     ## Creates a new mesh by a symmetrical copy of mesh elements
2966     #  @param IDsOfElements the list of elements ids
2967     #  @param Mirror is AxisStruct or geom object (point, line, plane)
2968     #  @param theMirrorType is  POINT, AXIS or PLANE
2969     #  If the Mirror is a geom object this parameter is unnecessary
2970     #  @param MakeGroups to generate new groups from existing ones
2971     #  @param NewMeshName a name of the new mesh to create
2972     #  @return instance of Mesh class
2973     #  @ingroup l2_modif_trsf
2974     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2975         if IDsOfElements == []:
2976             IDsOfElements = self.GetElementsId()
2977         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2978             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2979         Mirror,Parameters = ParseAxisStruct(Mirror)
2980         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2981                                           MakeGroups, NewMeshName)
2982         mesh.SetParameters(Parameters)
2983         return Mesh(self.smeshpyD,self.geompyD,mesh)
2984
2985     ## Creates a symmetrical copy of the object
2986     #  @param theObject mesh, submesh or group
2987     #  @param Mirror AxisStruct or geom object (point, line, plane)
2988     #  @param theMirrorType is  POINT, AXIS or PLANE
2989     #  If the Mirror is a geom object this parameter is unnecessary
2990     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2991     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2992     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2993     #  @ingroup l2_modif_trsf
2994     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2995         if ( isinstance( theObject, Mesh )):
2996             theObject = theObject.GetMesh()
2997         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2998             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2999         Mirror,Parameters = ParseAxisStruct(Mirror)
3000         self.mesh.SetParameters(Parameters)
3001         if Copy and MakeGroups:
3002             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3003         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3004         return []
3005
3006     ## Creates a new mesh by a symmetrical copy of the object
3007     #  @param theObject mesh, submesh or group
3008     #  @param Mirror AxisStruct or geom object (point, line, plane)
3009     #  @param theMirrorType POINT, AXIS or PLANE
3010     #  If the Mirror is a geom object this parameter is unnecessary
3011     #  @param MakeGroups forces the generation of new groups from existing ones
3012     #  @param NewMeshName the name of the new mesh to create
3013     #  @return instance of Mesh class
3014     #  @ingroup l2_modif_trsf
3015     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3016         if ( isinstance( theObject, Mesh )):
3017             theObject = theObject.GetMesh()
3018         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3019             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3020         Mirror,Parameters = ParseAxisStruct(Mirror)
3021         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3022                                                 MakeGroups, NewMeshName)
3023         mesh.SetParameters(Parameters)
3024         return Mesh( self.smeshpyD,self.geompyD,mesh )
3025
3026     ## Translates the elements
3027     #  @param IDsOfElements list of elements ids
3028     #  @param Vector the direction of translation (DirStruct or vector)
3029     #  @param Copy allows copying the translated elements
3030     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3031     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3032     #  @ingroup l2_modif_trsf
3033     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3034         if IDsOfElements == []:
3035             IDsOfElements = self.GetElementsId()
3036         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3037             Vector = self.smeshpyD.GetDirStruct(Vector)
3038         Vector,Parameters = ParseDirStruct(Vector)
3039         self.mesh.SetParameters(Parameters)
3040         if Copy and MakeGroups:
3041             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3042         self.editor.Translate(IDsOfElements, Vector, Copy)
3043         return []
3044
3045     ## Creates a new mesh of translated elements
3046     #  @param IDsOfElements list of elements ids
3047     #  @param Vector the direction of translation (DirStruct or vector)
3048     #  @param MakeGroups forces the generation of new groups from existing ones
3049     #  @param NewMeshName the name of the newly created mesh
3050     #  @return instance of Mesh class
3051     #  @ingroup l2_modif_trsf
3052     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3053         if IDsOfElements == []:
3054             IDsOfElements = self.GetElementsId()
3055         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3056             Vector = self.smeshpyD.GetDirStruct(Vector)
3057         Vector,Parameters = ParseDirStruct(Vector)
3058         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3059         mesh.SetParameters(Parameters)
3060         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3061
3062     ## Translates the object
3063     #  @param theObject the object to translate (mesh, submesh, or group)
3064     #  @param Vector direction of translation (DirStruct or geom vector)
3065     #  @param Copy allows copying the translated elements
3066     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3067     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3068     #  @ingroup l2_modif_trsf
3069     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3070         if ( isinstance( theObject, Mesh )):
3071             theObject = theObject.GetMesh()
3072         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3073             Vector = self.smeshpyD.GetDirStruct(Vector)
3074         Vector,Parameters = ParseDirStruct(Vector)
3075         self.mesh.SetParameters(Parameters)
3076         if Copy and MakeGroups:
3077             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3078         self.editor.TranslateObject(theObject, Vector, Copy)
3079         return []
3080
3081     ## Creates a new mesh from the translated object
3082     #  @param theObject the object to translate (mesh, submesh, or group)
3083     #  @param Vector the direction of translation (DirStruct or geom vector)
3084     #  @param MakeGroups forces the generation of new groups from existing ones
3085     #  @param NewMeshName the name of the newly created mesh
3086     #  @return instance of Mesh class
3087     #  @ingroup l2_modif_trsf
3088     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3089         if (isinstance(theObject, Mesh)):
3090             theObject = theObject.GetMesh()
3091         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3092             Vector = self.smeshpyD.GetDirStruct(Vector)
3093         Vector,Parameters = ParseDirStruct(Vector)
3094         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3095         mesh.SetParameters(Parameters)
3096         return Mesh( self.smeshpyD, self.geompyD, mesh )
3097
3098     ## Rotates the elements
3099     #  @param IDsOfElements list of elements ids
3100     #  @param Axis the axis of rotation (AxisStruct or geom line)
3101     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3102     #  @param Copy allows copying the rotated elements
3103     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3104     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3105     #  @ingroup l2_modif_trsf
3106     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3107         flag = False
3108         if isinstance(AngleInRadians,str):
3109             flag = True
3110         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3111         if flag:
3112             AngleInRadians = DegreesToRadians(AngleInRadians)
3113         if IDsOfElements == []:
3114             IDsOfElements = self.GetElementsId()
3115         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3116             Axis = self.smeshpyD.GetAxisStruct(Axis)
3117         Axis,AxisParameters = ParseAxisStruct(Axis)
3118         Parameters = AxisParameters + var_separator + Parameters
3119         self.mesh.SetParameters(Parameters)
3120         if Copy and MakeGroups:
3121             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3122         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3123         return []
3124
3125     ## Creates a new mesh of rotated elements
3126     #  @param IDsOfElements list of element ids
3127     #  @param Axis the axis of rotation (AxisStruct or geom line)
3128     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3129     #  @param MakeGroups forces the generation of new groups from existing ones
3130     #  @param NewMeshName the name of the newly created mesh
3131     #  @return instance of Mesh class
3132     #  @ingroup l2_modif_trsf
3133     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3134         flag = False
3135         if isinstance(AngleInRadians,str):
3136             flag = True
3137         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3138         if flag:
3139             AngleInRadians = DegreesToRadians(AngleInRadians)
3140         if IDsOfElements == []:
3141             IDsOfElements = self.GetElementsId()
3142         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3143             Axis = self.smeshpyD.GetAxisStruct(Axis)
3144         Axis,AxisParameters = ParseAxisStruct(Axis)
3145         Parameters = AxisParameters + var_separator + Parameters
3146         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3147                                           MakeGroups, NewMeshName)
3148         mesh.SetParameters(Parameters)
3149         return Mesh( self.smeshpyD, self.geompyD, mesh )
3150
3151     ## Rotates the object
3152     #  @param theObject the object to rotate( mesh, submesh, or group)
3153     #  @param Axis the axis of rotation (AxisStruct or geom line)
3154     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3155     #  @param Copy allows copying the rotated elements
3156     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3157     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3158     #  @ingroup l2_modif_trsf
3159     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3160         flag = False
3161         if isinstance(AngleInRadians,str):
3162             flag = True
3163         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3164         if flag:
3165             AngleInRadians = DegreesToRadians(AngleInRadians)
3166         if (isinstance(theObject, Mesh)):
3167             theObject = theObject.GetMesh()
3168         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3169             Axis = self.smeshpyD.GetAxisStruct(Axis)
3170         Axis,AxisParameters = ParseAxisStruct(Axis)
3171         Parameters = AxisParameters + ":" + Parameters
3172         self.mesh.SetParameters(Parameters)
3173         if Copy and MakeGroups:
3174             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3175         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3176         return []
3177
3178     ## Creates a new mesh from the rotated object
3179     #  @param theObject the object to rotate (mesh, submesh, or group)
3180     #  @param Axis the axis of rotation (AxisStruct or geom line)
3181     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
3182     #  @param MakeGroups forces the generation of new groups from existing ones
3183     #  @param NewMeshName the name of the newly created mesh
3184     #  @return instance of Mesh class
3185     #  @ingroup l2_modif_trsf
3186     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3187         flag = False
3188         if isinstance(AngleInRadians,str):
3189             flag = True
3190         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3191         if flag:
3192             AngleInRadians = DegreesToRadians(AngleInRadians)
3193         if (isinstance( theObject, Mesh )):
3194             theObject = theObject.GetMesh()
3195         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3196             Axis = self.smeshpyD.GetAxisStruct(Axis)
3197         Axis,AxisParameters = ParseAxisStruct(Axis)
3198         Parameters = AxisParameters + ":" + Parameters
3199         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3200                                                        MakeGroups, NewMeshName)
3201         mesh.SetParameters(Parameters)
3202         return Mesh( self.smeshpyD, self.geompyD, mesh )
3203
3204     ## Finds groups of ajacent nodes within Tolerance.
3205     #  @param Tolerance the value of tolerance
3206     #  @return the list of groups of nodes
3207     #  @ingroup l2_modif_trsf
3208     def FindCoincidentNodes (self, Tolerance):
3209         return self.editor.FindCoincidentNodes(Tolerance)
3210
3211     ## Finds groups of ajacent nodes within Tolerance.
3212     #  @param Tolerance the value of tolerance
3213     #  @param SubMeshOrGroup SubMesh or Group
3214     #  @return the list of groups of nodes
3215     #  @ingroup l2_modif_trsf
3216     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3217         return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3218
3219     ## Merges nodes
3220     #  @param GroupsOfNodes the list of groups of nodes
3221     #  @ingroup l2_modif_trsf
3222     def MergeNodes (self, GroupsOfNodes):
3223         self.editor.MergeNodes(GroupsOfNodes)
3224
3225     ## Finds the elements built on the same nodes.
3226     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3227     #  @return a list of groups of equal elements
3228     #  @ingroup l2_modif_trsf
3229     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3230         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3231
3232     ## Merges elements in each given group.
3233     #  @param GroupsOfElementsID groups of elements for merging
3234     #  @ingroup l2_modif_trsf
3235     def MergeElements(self, GroupsOfElementsID):
3236         self.editor.MergeElements(GroupsOfElementsID)
3237
3238     ## Leaves one element and removes all other elements built on the same nodes.
3239     #  @ingroup l2_modif_trsf
3240     def MergeEqualElements(self):
3241         self.editor.MergeEqualElements()
3242
3243     ## Sews free borders
3244     #  @return SMESH::Sew_Error
3245     #  @ingroup l2_modif_trsf
3246     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3247                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3248                         CreatePolygons, CreatePolyedrs):
3249         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3250                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3251                                           CreatePolygons, CreatePolyedrs)
3252
3253     ## Sews conform free borders
3254     #  @return SMESH::Sew_Error
3255     #  @ingroup l2_modif_trsf
3256     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3257                                FirstNodeID2, SecondNodeID2):
3258         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3259                                                  FirstNodeID2, SecondNodeID2)
3260
3261     ## Sews border to side
3262     #  @return SMESH::Sew_Error
3263     #  @ingroup l2_modif_trsf
3264     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3265                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3266         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3267                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3268
3269     ## Sews two sides of a mesh. The nodes belonging to Side1 are
3270     #  merged with the nodes of elements of Side2.
3271     #  The number of elements in theSide1 and in theSide2 must be
3272     #  equal and they should have similar nodal connectivity.
3273     #  The nodes to merge should belong to side borders and
3274     #  the first node should be linked to the second.
3275     #  @return SMESH::Sew_Error
3276     #  @ingroup l2_modif_trsf
3277     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3278                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3279                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3280         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3281                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3282                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3283
3284     ## Sets new nodes for the given element.
3285     #  @param ide the element id
3286     #  @param newIDs nodes ids
3287     #  @return If the number of nodes does not correspond to the type of element - returns false
3288     #  @ingroup l2_modif_edit
3289     def ChangeElemNodes(self, ide, newIDs):
3290         return self.editor.ChangeElemNodes(ide, newIDs)
3291
3292     ## If during the last operation of MeshEditor some nodes were
3293     #  created, this method returns the list of their IDs, \n
3294     #  if new nodes were not created - returns empty list
3295     #  @return the list of integer values (can be empty)
3296     #  @ingroup l1_auxiliary
3297     def GetLastCreatedNodes(self):
3298         return self.editor.GetLastCreatedNodes()
3299
3300     ## If during the last operation of MeshEditor some elements were
3301     #  created this method returns the list of their IDs, \n
3302     #  if new elements were not created - returns empty list
3303     #  @return the list of integer values (can be empty)
3304     #  @ingroup l1_auxiliary
3305     def GetLastCreatedElems(self):
3306         return self.editor.GetLastCreatedElems()
3307     
3308     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3309     #  @param theNodes identifiers of nodes to be doubled
3310     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled) 
3311     #         nodes. If list of element identifiers is empty then nodes are doubled but 
3312     #         they not assigned to elements
3313     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3314     #  @ingroup l2_modif_edit
3315     def DoubleNodes(self, theNodes, theModifiedElems):
3316         return self.editor.DoubleNodes(theNodes, theModifiedElems)
3317         
3318     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3319     #  This method provided for convenience works as DoubleNodes() described above.
3320     #  @param theNodes identifiers of node to be doubled
3321     #  @param theModifiedElems identifiers of elements to be updated
3322     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3323     #  @ingroup l2_modif_edit
3324     def DoubleNode(self, theNodeId, theModifiedElems):
3325         return self.editor.DoubleNode(theNodeId, theModifiedElems)
3326         
3327     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3328     #  This method provided for convenience works as DoubleNodes() described above.
3329     #  @param theNodes group of nodes to be doubled
3330     #  @param theModifiedElems group of elements to be updated.
3331     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3332     #  @ingroup l2_modif_edit
3333     def DoubleNodeGroup(self, theNodes, theModifiedElems):
3334         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3335         
3336     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3337     #  This method provided for convenience works as DoubleNodes() described above.
3338     #  @param theNodes list of groups of nodes to be doubled
3339     #  @param theModifiedElems list of groups of elements to be updated.
3340     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3341     #  @ingroup l2_modif_edit
3342     def DoubleNodeGroups(self, theNodes, theModifiedElems):
3343         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3344
3345 ## The mother class to define algorithm, it is not recommended to use it directly.
3346 #
3347 #  More details.
3348 #  @ingroup l2_algorithms
3349 class Mesh_Algorithm:
3350     #  @class Mesh_Algorithm
3351     #  @brief Class Mesh_Algorithm
3352
3353     #def __init__(self,smesh):
3354     #    self.smesh=smesh
3355     def __init__(self):
3356         self.mesh = None
3357         self.geom = None
3358         self.subm = None
3359         self.algo = None
3360
3361     ## Finds a hypothesis in the study by its type name and parameters.
3362     #  Finds only the hypotheses created in smeshpyD engine.
3363     #  @return SMESH.SMESH_Hypothesis
3364     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3365         study = smeshpyD.GetCurrentStudy()
3366         #to do: find component by smeshpyD object, not by its data type
3367         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3368         if scomp is not None:
3369             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3370             # Check if the root label of the hypotheses exists
3371             if res and hypRoot is not None:
3372                 iter = study.NewChildIterator(hypRoot)
3373                 # Check all published hypotheses
3374                 while iter.More():
3375                     hypo_so_i = iter.Value()
3376                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3377                     if attr is not None:
3378                         anIOR = attr.Value()
3379                         hypo_o_i = salome.orb.string_to_object(anIOR)
3380                         if hypo_o_i is not None:
3381                             # Check if this is a hypothesis
3382                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3383                             if hypo_i is not None:
3384                                 # Check if the hypothesis belongs to current engine
3385                                 if smeshpyD.GetObjectId(hypo_i) > 0:
3386                                     # Check if this is the required hypothesis
3387                                     if hypo_i.GetName() == hypname:
3388                                         # Check arguments
3389                                         if CompareMethod(hypo_i, args):
3390                                             # found!!!
3391                                             return hypo_i
3392                                         pass
3393                                     pass
3394                                 pass
3395                             pass
3396                         pass
3397                     iter.Next()
3398                     pass
3399                 pass
3400             pass
3401         return None
3402
3403     ## Finds the algorithm in the study by its type name.
3404     #  Finds only the algorithms, which have been created in smeshpyD engine.
3405     #  @return SMESH.SMESH_Algo
3406     def FindAlgorithm (self, algoname, smeshpyD):
3407         study = smeshpyD.GetCurrentStudy()
3408         #to do: find component by smeshpyD object, not by its data type
3409         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3410         if scomp is not None:
3411             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3412             # Check if the root label of the algorithms exists
3413             if res and hypRoot is not None:
3414                 iter = study.NewChildIterator(hypRoot)
3415                 # Check all published algorithms
3416                 while iter.More():
3417                     algo_so_i = iter.Value()
3418                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3419                     if attr is not None:
3420                         anIOR = attr.Value()
3421                         algo_o_i = salome.orb.string_to_object(anIOR)
3422                         if algo_o_i is not None:
3423                             # Check if this is an algorithm
3424                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3425                             if algo_i is not None:
3426                                 # Checks if the algorithm belongs to the current engine
3427                                 if smeshpyD.GetObjectId(algo_i) > 0:
3428                                     # Check if this is the required algorithm
3429                                     if algo_i.GetName() == algoname:
3430                                         # found!!!
3431                                         return algo_i
3432                                     pass
3433                                 pass
3434                             pass
3435                         pass
3436                     iter.Next()
3437                     pass
3438                 pass
3439             pass
3440         return None
3441
3442     ## If the algorithm is global, returns 0; \n
3443     #  else returns the submesh associated to this algorithm.
3444     def GetSubMesh(self):
3445         return self.subm
3446
3447     ## Returns the wrapped mesher.
3448     def GetAlgorithm(self):
3449         return self.algo
3450
3451     ## Gets the list of hypothesis that can be used with this algorithm
3452     def GetCompatibleHypothesis(self):
3453         mylist = []
3454         if self.algo:
3455             mylist = self.algo.GetCompatibleHypothesis()
3456         return mylist
3457
3458     ## Gets the name of the algorithm
3459     def GetName(self):
3460         GetName(self.algo)
3461
3462     ## Sets the name to the algorithm
3463     def SetName(self, name):
3464         self.mesh.smeshpyD.SetName(self.algo, name)
3465
3466     ## Gets the id of the algorithm
3467     def GetId(self):
3468         return self.algo.GetId()
3469
3470     ## Private method.
3471     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3472         if geom is None:
3473             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3474         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3475         if algo is None:
3476             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3477             pass
3478         self.Assign(algo, mesh, geom)
3479         return self.algo
3480
3481     ## Private method
3482     def Assign(self, algo, mesh, geom):
3483         if geom is None:
3484             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3485         self.mesh = mesh
3486         piece = mesh.geom
3487         if not geom:
3488             self.geom = piece
3489         else:
3490             self.geom = geom
3491             name = GetName(geom)
3492             if name==NO_NAME:
3493                 name = mesh.geompyD.SubShapeName(geom, piece)
3494                 mesh.geompyD.addToStudyInFather(piece, geom, name)
3495             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3496
3497         self.algo = algo
3498         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3499         TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3500
3501     def CompareHyp (self, hyp, args):
3502         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3503         return False
3504
3505     def CompareEqualHyp (self, hyp, args):
3506         return True
3507
3508     ## Private method
3509     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3510                     UseExisting=0, CompareMethod=""):
3511         hypo = None
3512         if UseExisting:
3513             if CompareMethod == "": CompareMethod = self.CompareHyp
3514             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3515             pass
3516         if hypo is None:
3517             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3518             a = ""
3519             s = "="
3520             i = 0
3521             n = len(args)
3522             while i<n:
3523                 a = a + s + str(args[i])
3524                 s = ","
3525                 i = i + 1
3526                 pass
3527             self.mesh.smeshpyD.SetName(hypo, hyp + a)
3528             pass
3529         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3530         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3531         return hypo
3532
3533
3534 # Public class: Mesh_Segment
3535 # --------------------------
3536
3537 ## Class to define a segment 1D algorithm for discretization
3538 #
3539 #  More details.
3540 #  @ingroup l3_algos_basic
3541 class Mesh_Segment(Mesh_Algorithm):
3542
3543     ## Private constructor.
3544     def __init__(self, mesh, geom=0):
3545         Mesh_Algorithm.__init__(self)
3546         self.Create(mesh, geom, "Regular_1D")
3547
3548     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3549     #  @param l for the length of segments that cut an edge
3550     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3551     #                    the same parameters, else (default) - creates a new one
3552     #  @param p precision, used for calculation of the number of segments.
3553     #           The precision should be a positive, meaningful value within the range [0,1].
3554     #           In general, the number of segments is calculated with the formula:
3555     #           nb = ceil((edge_length / l) - p)
3556     #           Function ceil rounds its argument to the higher integer.
3557     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
3558     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
3559     #               p=1 means rounding of (edge_length / l) to the lower integer.
3560     #           Default value is 1e-07.
3561     #  @return an instance of StdMeshers_LocalLength hypothesis
3562     #  @ingroup l3_hypos_1dhyps
3563     def LocalLength(self, l, UseExisting=0, p=1e-07):
3564         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3565                               CompareMethod=self.CompareLocalLength)
3566         hyp.SetLength(l)
3567         hyp.SetPrecision(p)
3568         return hyp
3569
3570     ## Private method
3571     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3572     def CompareLocalLength(self, hyp, args):
3573         if IsEqual(hyp.GetLength(), args[0]):
3574             return IsEqual(hyp.GetPrecision(), args[1])
3575         return False
3576
3577     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3578     #  @param length is optional maximal allowed length of segment, if it is omitted
3579     #                the preestimated length is used that depends on geometry size
3580     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3581     #                     the same parameters, else (default) - create a new one
3582     #  @return an instance of StdMeshers_MaxLength hypothesis
3583     #  @ingroup l3_hypos_1dhyps
3584     def MaxSize(self, length=0.0, UseExisting=0):
3585         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3586         if length > 0.0:
3587             # set given length
3588             hyp.SetLength(length)
3589         if not UseExisting:
3590             # set preestimated length
3591             gen = self.mesh.smeshpyD
3592             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3593                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
3594                                                        False) # <- byMesh
3595             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3596             if preHyp:
3597                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3598                 pass
3599             pass
3600         hyp.SetUsePreestimatedLength( length == 0.0 )
3601         return hyp
3602         
3603     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3604     #  @param n for the number of segments that cut an edge
3605     #  @param s for the scale factor (optional)
3606     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3607     #                     the same parameters, else (default) - create a new one
3608     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
3609     #  @ingroup l3_hypos_1dhyps
3610     def NumberOfSegments(self, n, s=[], UseExisting=0):
3611         if s == []:
3612             hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3613                                   CompareMethod=self.CompareNumberOfSegments)
3614         else:
3615             hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3616                                   CompareMethod=self.CompareNumberOfSegments)
3617             hyp.SetDistrType( 1 )
3618             hyp.SetScaleFactor(s)
3619         hyp.SetNumberOfSegments(n)
3620         return hyp
3621
3622     ## Private method
3623     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3624     def CompareNumberOfSegments(self, hyp, args):
3625         if hyp.GetNumberOfSegments() == args[0]:
3626             if len(args) == 1:
3627                 return True
3628             else:
3629                 if hyp.GetDistrType() == 1:
3630                     if IsEqual(hyp.GetScaleFactor(), args[1]):
3631                         return True
3632         return False
3633
3634     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3635     #  @param start defines the length of the first segment
3636     #  @param end   defines the length of the last  segment
3637     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3638     #                     the same parameters, else (default) - creates a new one
3639     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
3640     #  @ingroup l3_hypos_1dhyps
3641     def Arithmetic1D(self, start, end, UseExisting=0):
3642         hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3643                               CompareMethod=self.CompareArithmetic1D)
3644         hyp.SetLength(start, 1)
3645         hyp.SetLength(end  , 0)
3646         return hyp
3647
3648     ## Private method
3649     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3650     def CompareArithmetic1D(self, hyp, args):
3651         if IsEqual(hyp.GetLength(1), args[0]):
3652             if IsEqual(hyp.GetLength(0), args[1]):
3653                 return True
3654         return False
3655
3656     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3657     #  @param start defines the length of the first segment
3658     #  @param end   defines the length of the last  segment
3659     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3660     #                     the same parameters, else (default) - creates a new one
3661     #  @return an instance of StdMeshers_StartEndLength hypothesis
3662     #  @ingroup l3_hypos_1dhyps
3663     def StartEndLength(self, start, end, UseExisting=0):
3664         hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3665                               CompareMethod=self.CompareStartEndLength)
3666         hyp.SetLength(start, 1)
3667         hyp.SetLength(end  , 0)
3668         return hyp
3669
3670     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3671     def CompareStartEndLength(self, hyp, args):
3672         if IsEqual(hyp.GetLength(1), args[0]):
3673             if IsEqual(hyp.GetLength(0), args[1]):
3674                 return True
3675         return False
3676
3677     ## Defines "Deflection1D" hypothesis
3678     #  @param d for the deflection
3679     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3680     #                     the same parameters, else (default) - create a new one
3681     #  @ingroup l3_hypos_1dhyps
3682     def Deflection1D(self, d, UseExisting=0):
3683         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3684                               CompareMethod=self.CompareDeflection1D)
3685         hyp.SetDeflection(d)
3686         return hyp
3687
3688     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3689     def CompareDeflection1D(self, hyp, args):
3690         return IsEqual(hyp.GetDeflection(), args[0])
3691
3692     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3693     #  the opposite side in case of quadrangular faces
3694     #  @ingroup l3_hypos_additi
3695     def Propagation(self):
3696         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3697
3698     ## Defines "AutomaticLength" hypothesis
3699     #  @param fineness for the fineness [0-1]
3700     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
3701     #                     same parameters, else (default) - create a new one
3702     #  @ingroup l3_hypos_1dhyps
3703     def AutomaticLength(self, fineness=0, UseExisting=0):
3704         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3705                               CompareMethod=self.CompareAutomaticLength)
3706         hyp.SetFineness( fineness )
3707         return hyp
3708
3709     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3710     def CompareAutomaticLength(self, hyp, args):
3711         return IsEqual(hyp.GetFineness(), args[0])
3712
3713     ## Defines "SegmentLengthAroundVertex" hypothesis
3714     #  @param length for the segment length
3715     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
3716     #         Any other integer value means that the hypothesis will be set on the
3717     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
3718     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3719     #                   the same parameters, else (default) - creates a new one
3720     #  @ingroup l3_algos_segmarv
3721     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3722         import types
3723         store_geom = self.geom
3724         if type(vertex) is types.IntType:
3725             if vertex == 0 or vertex == 1:
3726                 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3727                 self.geom = vertex
3728                 pass
3729             pass
3730         else:
3731             self.geom = vertex
3732             pass
3733         ### 0D algorithm
3734         if self.geom is None:
3735             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3736         name = GetName(self.geom)
3737         if name == NO_NAME:
3738             piece = self.mesh.geom
3739             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3740             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3741         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3742         if algo is None:
3743             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3744             pass
3745         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3746         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3747         ###
3748         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3749                               CompareMethod=self.CompareLengthNearVertex)
3750         self.geom = store_geom
3751         hyp.SetLength( length )
3752         return hyp
3753
3754     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3755     #  @ingroup l3_algos_segmarv
3756     def CompareLengthNearVertex(self, hyp, args):
3757         return IsEqual(hyp.GetLength(), args[0])
3758
3759     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3760     #  If the 2D mesher sees that all boundary edges are quadratic,
3761     #  it generates quadratic faces, else it generates linear faces using
3762     #  medium nodes as if they are vertices.
3763     #  The 3D mesher generates quadratic volumes only if all boundary faces
3764     #  are quadratic, else it fails.
3765     #
3766     #  @ingroup l3_hypos_additi
3767     def QuadraticMesh(self):
3768         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3769         return hyp
3770
3771 # Public class: Mesh_CompositeSegment
3772 # --------------------------
3773
3774 ## Defines a segment 1D algorithm for discretization
3775 #
3776 #  @ingroup l3_algos_basic
3777 class Mesh_CompositeSegment(Mesh_Segment):
3778
3779     ## Private constructor.
3780     def __init__(self, mesh, geom=0):
3781         self.Create(mesh, geom, "CompositeSegment_1D")
3782
3783
3784 # Public class: Mesh_Segment_Python
3785 # ---------------------------------
3786
3787 ## Defines a segment 1D algorithm for discretization with python function
3788 #
3789 #  @ingroup l3_algos_basic
3790 class Mesh_Segment_Python(Mesh_Segment):
3791
3792     ## Private constructor.
3793     def __init__(self, mesh, geom=0):
3794         import Python1dPlugin
3795         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3796
3797     ## Defines "PythonSplit1D" hypothesis
3798     #  @param n for the number of segments that cut an edge
3799     #  @param func for the python function that calculates the length of all segments
3800     #  @param UseExisting if ==true - searches for the existing hypothesis created with
3801     #                     the same parameters, else (default) - creates a new one
3802     #  @ingroup l3_hypos_1dhyps
3803     def PythonSplit1D(self, n, func, UseExisting=0):
3804         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3805                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3806         hyp.SetNumberOfSegments(n)
3807         hyp.SetPythonLog10RatioFunction(func)
3808         return hyp
3809
3810     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3811     def ComparePythonSplit1D(self, hyp, args):
3812         #if hyp.GetNumberOfSegments() == args[0]:
3813         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
3814         #        return True
3815         return False
3816
3817 # Public class: Mesh_Triangle
3818 # ---------------------------
3819
3820 ## Defines a triangle 2D algorithm
3821 #
3822 #  @ingroup l3_algos_basic
3823 class Mesh_Triangle(Mesh_Algorithm):
3824
3825     # default values
3826     algoType = 0
3827     params = 0
3828
3829     _angleMeshS = 8
3830     _gradation  = 1.1
3831
3832     ## Private constructor.
3833     def __init__(self, mesh, algoType, geom=0):
3834         Mesh_Algorithm.__init__(self)
3835
3836         self.algoType = algoType
3837         if algoType == MEFISTO:
3838             self.Create(mesh, geom, "MEFISTO_2D")
3839             pass
3840         elif algoType == BLSURF:
3841             import BLSURFPlugin
3842             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3843             #self.SetPhysicalMesh() - PAL19680
3844         elif algoType == NETGEN:
3845             if noNETGENPlugin:
3846                 print "Warning: NETGENPlugin module unavailable"
3847                 pass
3848             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3849             pass
3850         elif algoType == NETGEN_2D:
3851             if noNETGENPlugin:
3852                 print "Warning: NETGENPlugin module unavailable"
3853                 pass
3854             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3855             pass
3856
3857     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3858     #  @param area for the maximum area of each triangle
3859     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
3860     #                     same parameters, else (default) - creates a new one
3861     #
3862     #  Only for algoType == MEFISTO || NETGEN_2D
3863     #  @ingroup l3_hypos_2dhyps
3864     def MaxElementArea(self, area, UseExisting=0):
3865         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3866             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3867                                   CompareMethod=self.CompareMaxElementArea)
3868         elif self.algoType == NETGEN:
3869             hyp = self.Parameters(SIMPLE)
3870         hyp.SetMaxElementArea(area)
3871         return hyp
3872
3873     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3874     def CompareMaxElementArea(self, hyp, args):
3875         return IsEqual(hyp.GetMaxElementArea(), args[0])
3876
3877     ## Defines "LengthFromEdges" hypothesis to build triangles
3878     #  based on the length of the edges taken from the wire
3879     #
3880     #  Only for algoType == MEFISTO || NETGEN_2D
3881     #  @ingroup l3_hypos_2dhyps
3882     def LengthFromEdges(self):
3883         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3884             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3885             return hyp
3886         elif self.algoType == NETGEN:
3887             hyp = self.Parameters(SIMPLE)
3888             hyp.LengthFromEdges()
3889             return hyp
3890
3891     ## Sets a way to define size of mesh elements to generate.
3892     #  @param thePhysicalMesh is: DefaultSize or Custom.
3893     #  @ingroup l3_hypos_blsurf
3894     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3895         # Parameter of BLSURF algo
3896         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3897
3898     ## Sets size of mesh elements to generate.
3899     #  @ingroup l3_hypos_blsurf
3900     def SetPhySize(self, theVal):
3901         # Parameter of BLSURF algo
3902         self.Parameters().SetPhySize(theVal)
3903
3904     ## Sets lower boundary of mesh element size (PhySize).
3905     #  @ingroup l3_hypos_blsurf
3906     def SetPhyMin(self, theVal=-1):
3907         #  Parameter of BLSURF algo
3908         self.Parameters().SetPhyMin(theVal)
3909
3910     ## Sets upper boundary of mesh element size (PhySize).
3911     #  @ingroup l3_hypos_blsurf
3912     def SetPhyMax(self, theVal=-1):
3913         #  Parameter of BLSURF algo
3914         self.Parameters().SetPhyMax(theVal)
3915
3916     ## Sets a way to define maximum angular deflection of mesh from CAD model.
3917     #  @param theGeometricMesh is: DefaultGeom or Custom
3918     #  @ingroup l3_hypos_blsurf
3919     def SetGeometricMesh(self, theGeometricMesh=0):
3920         #  Parameter of BLSURF algo
3921         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3922         self.params.SetGeometricMesh(theGeometricMesh)
3923
3924     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3925     #  @ingroup l3_hypos_blsurf
3926     def SetAngleMeshS(self, theVal=_angleMeshS):
3927         #  Parameter of BLSURF algo
3928         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3929         self.params.SetAngleMeshS(theVal)
3930
3931     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3932     #  @ingroup l3_hypos_blsurf
3933     def SetAngleMeshC(self, theVal=_angleMeshS):
3934         #  Parameter of BLSURF algo
3935         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3936         self.params.SetAngleMeshC(theVal)
3937
3938     ## Sets lower boundary of mesh element size computed to respect angular deflection.
3939     #  @ingroup l3_hypos_blsurf
3940     def SetGeoMin(self, theVal=-1):
3941         #  Parameter of BLSURF algo
3942         self.Parameters().SetGeoMin(theVal)
3943
3944     ## Sets upper boundary of mesh element size computed to respect angular deflection.
3945     #  @ingroup l3_hypos_blsurf
3946     def SetGeoMax(self, theVal=-1):
3947         #  Parameter of BLSURF algo
3948         self.Parameters().SetGeoMax(theVal)
3949
3950     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3951     #  @ingroup l3_hypos_blsurf
3952     def SetGradation(self, theVal=_gradation):
3953         #  Parameter of BLSURF algo
3954         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3955         self.params.SetGradation(theVal)
3956
3957     ## Sets topology usage way.
3958     # @param way defines how mesh conformity is assured <ul>
3959     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3960     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3961     #  @ingroup l3_hypos_blsurf
3962     def SetTopology(self, way):
3963         #  Parameter of BLSURF algo
3964         self.Parameters().SetTopology(way)
3965
3966     ## To respect geometrical edges or not.
3967     #  @ingroup l3_hypos_blsurf
3968     def SetDecimesh(self, toIgnoreEdges=False):
3969         #  Parameter of BLSURF algo
3970         self.Parameters().SetDecimesh(toIgnoreEdges)
3971
3972     ## Sets verbosity level in the range 0 to 100.
3973     #  @ingroup l3_hypos_blsurf
3974     def SetVerbosity(self, level):
3975         #  Parameter of BLSURF algo
3976         self.Parameters().SetVerbosity(level)
3977
3978     ## Sets advanced option value.
3979     #  @ingroup l3_hypos_blsurf
3980     def SetOptionValue(self, optionName, level):
3981         #  Parameter of BLSURF algo
3982         self.Parameters().SetOptionValue(optionName,level)
3983
3984     ## Sets QuadAllowed flag.
3985     #  Only for algoType == NETGEN || NETGEN_2D || BLSURF
3986     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
3987     def SetQuadAllowed(self, toAllow=True):
3988         if self.algoType == NETGEN_2D:
3989             if toAllow: # add QuadranglePreference
3990                 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3991             else:       # remove QuadranglePreference
3992                 for hyp in self.mesh.GetHypothesisList( self.geom ):
3993                     if hyp.GetName() == "QuadranglePreference":
3994                         self.mesh.RemoveHypothesis( self.geom, hyp )
3995                         pass
3996                     pass
3997                 pass
3998             return
3999         if self.Parameters():
4000             self.params.SetQuadAllowed(toAllow)
4001             return
4002
4003     ## Defines hypothesis having several parameters
4004     #
4005     #  @ingroup l3_hypos_netgen
4006     def Parameters(self, which=SOLE):
4007         if self.params:
4008             return self.params
4009         if self.algoType == NETGEN:
4010             if which == SIMPLE:
4011                 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4012                                               "libNETGENEngine.so", UseExisting=0)
4013             else:
4014                 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4015                                               "libNETGENEngine.so", UseExisting=0)
4016             return self.params
4017         elif self.algoType == MEFISTO:
4018             print "Mefisto algo support no multi-parameter hypothesis"
4019             return None
4020         elif self.algoType == NETGEN_2D:
4021             print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4022             print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4023             return None
4024         elif self.algoType == BLSURF:
4025             self.params = self.Hypothesis("BLSURF_Parameters", [],
4026                                           "libBLSURFEngine.so", UseExisting=0)
4027             return self.params
4028         else:
4029             print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4030         return None
4031
4032     ## Sets MaxSize
4033     #
4034     #  Only for algoType == NETGEN
4035     #  @ingroup l3_hypos_netgen
4036     def SetMaxSize(self, theSize):
4037         if self.Parameters():
4038             self.params.SetMaxSize(theSize)
4039
4040     ## Sets SecondOrder flag
4041     #
4042     #  Only for algoType == NETGEN
4043     #  @ingroup l3_hypos_netgen
4044     def SetSecondOrder(self, theVal):
4045         if self.Parameters():
4046             self.params.SetSecondOrder(theVal)
4047
4048     ## Sets Optimize flag
4049     #
4050     #  Only for algoType == NETGEN
4051     #  @ingroup l3_hypos_netgen
4052     def SetOptimize(self, theVal):
4053         if self.Parameters():
4054             self.params.SetOptimize(theVal)
4055
4056     ## Sets Fineness
4057     #  @param theFineness is:
4058     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4059     #
4060     #  Only for algoType == NETGEN
4061     #  @ingroup l3_hypos_netgen
4062     def SetFineness(self, theFineness):
4063         if self.Parameters():
4064             self.params.SetFineness(theFineness)
4065
4066     ## Sets GrowthRate
4067     #
4068     #  Only for algoType == NETGEN
4069     #  @ingroup l3_hypos_netgen
4070     def SetGrowthRate(self, theRate):
4071         if self.Parameters():
4072             self.params.SetGrowthRate(theRate)
4073
4074     ## Sets NbSegPerEdge
4075     #
4076     #  Only for algoType == NETGEN
4077     #  @ingroup l3_hypos_netgen
4078     def SetNbSegPerEdge(self, theVal):
4079         if self.Parameters():
4080             self.params.SetNbSegPerEdge(theVal)
4081
4082     ## Sets NbSegPerRadius
4083     #
4084     #  Only for algoType == NETGEN
4085     #  @ingroup l3_hypos_netgen
4086     def SetNbSegPerRadius(self, theVal):
4087         if self.Parameters():
4088             self.params.SetNbSegPerRadius(theVal)
4089
4090     ## Sets number of segments overriding value set by SetLocalLength()
4091     #
4092     #  Only for algoType == NETGEN
4093     #  @ingroup l3_hypos_netgen
4094     def SetNumberOfSegments(self, theVal):
4095         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4096
4097     ## Sets number of segments overriding value set by SetNumberOfSegments()
4098     #
4099     #  Only for algoType == NETGEN
4100     #  @ingroup l3_hypos_netgen
4101     def SetLocalLength(self, theVal):
4102         self.Parameters(SIMPLE).SetLocalLength(theVal)
4103
4104     pass
4105
4106
4107 # Public class: Mesh_Quadrangle
4108 # -----------------------------
4109
4110 ## Defines a quadrangle 2D algorithm
4111 #
4112 #  @ingroup l3_algos_basic
4113 class Mesh_Quadrangle(Mesh_Algorithm):
4114
4115     ## Private constructor.
4116     def __init__(self, mesh, geom=0):
4117         Mesh_Algorithm.__init__(self)
4118         self.Create(mesh, geom, "Quadrangle_2D")
4119
4120     ## Defines "QuadranglePreference" hypothesis, forcing construction
4121     #  of quadrangles if the number of nodes on the opposite edges is not the same
4122     #  while the total number of nodes on edges is even
4123     #
4124     #  @ingroup l3_hypos_additi
4125     def QuadranglePreference(self):
4126         hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4127                               CompareMethod=self.CompareEqualHyp)
4128         return hyp
4129
4130     ## Defines "TrianglePreference" hypothesis, forcing construction
4131     #  of triangles in the refinement area if the number of nodes
4132     #  on the opposite edges is not the same
4133     #
4134     #  @ingroup l3_hypos_additi
4135     def TrianglePreference(self):
4136         hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4137                               CompareMethod=self.CompareEqualHyp)
4138         return hyp
4139
4140 # Public class: Mesh_Tetrahedron
4141 # ------------------------------
4142
4143 ## Defines a tetrahedron 3D algorithm
4144 #
4145 #  @ingroup l3_algos_basic
4146 class Mesh_Tetrahedron(Mesh_Algorithm):
4147
4148     params = 0
4149     algoType = 0
4150
4151     ## Private constructor.
4152     def __init__(self, mesh, algoType, geom=0):
4153         Mesh_Algorithm.__init__(self)
4154
4155         if algoType == NETGEN:
4156             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4157             pass
4158
4159         elif algoType == FULL_NETGEN:
4160             if noNETGENPlugin:
4161                 print "Warning: NETGENPlugin module has not been imported."
4162             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4163             pass
4164
4165         elif algoType == GHS3D:
4166             import GHS3DPlugin
4167             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4168             pass
4169
4170         elif algoType == GHS3DPRL:
4171             import GHS3DPRLPlugin
4172             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4173             pass
4174
4175         self.algoType = algoType
4176
4177     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4178     #  @param vol for the maximum volume of each tetrahedron
4179     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4180     #                   the same parameters, else (default) - creates a new one
4181     #  @ingroup l3_hypos_maxvol
4182     def MaxElementVolume(self, vol, UseExisting=0):
4183         if self.algoType == NETGEN:
4184             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4185                                   CompareMethod=self.CompareMaxElementVolume)
4186             hyp.SetMaxElementVolume(vol)
4187             return hyp
4188         elif self.algoType == FULL_NETGEN:
4189             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4190         return None
4191
4192     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4193     def CompareMaxElementVolume(self, hyp, args):
4194         return IsEqual(hyp.GetMaxElementVolume(), args[0])
4195
4196     ## Defines hypothesis having several parameters
4197     #
4198     #  @ingroup l3_hypos_netgen
4199     def Parameters(self, which=SOLE):
4200         if self.params:
4201             return self.params
4202
4203         if self.algoType == FULL_NETGEN:
4204             if which == SIMPLE:
4205                 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4206                                               "libNETGENEngine.so", UseExisting=0)
4207             else:
4208                 self.params = self.Hypothesis("NETGEN_Parameters", [],
4209                                               "libNETGENEngine.so", UseExisting=0)
4210             return self.params
4211
4212         if self.algoType == GHS3D:
4213             self.params = self.Hypothesis("GHS3D_Parameters", [],
4214                                           "libGHS3DEngine.so", UseExisting=0)
4215             return self.params
4216
4217         if self.algoType == GHS3DPRL:
4218             self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4219                                           "libGHS3DPRLEngine.so", UseExisting=0)
4220             return self.params
4221
4222         print "Algo supports no multi-parameter hypothesis"
4223         return None
4224
4225     ## Sets MaxSize
4226     #  Parameter of FULL_NETGEN
4227     #  @ingroup l3_hypos_netgen
4228     def SetMaxSize(self, theSize):
4229         self.Parameters().SetMaxSize(theSize)
4230
4231     ## Sets SecondOrder flag
4232     #  Parameter of FULL_NETGEN
4233     #  @ingroup l3_hypos_netgen
4234     def SetSecondOrder(self, theVal):
4235         self.Parameters().SetSecondOrder(theVal)
4236
4237     ## Sets Optimize flag
4238     #  Parameter of FULL_NETGEN
4239     #  @ingroup l3_hypos_netgen
4240     def SetOptimize(self, theVal):
4241         self.Parameters().SetOptimize(theVal)
4242
4243     ## Sets Fineness
4244     #  @param theFineness is:
4245     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4246     #  Parameter of FULL_NETGEN
4247     #  @ingroup l3_hypos_netgen
4248     def SetFineness(self, theFineness):
4249         self.Parameters().SetFineness(theFineness)
4250
4251     ## Sets GrowthRate
4252     #  Parameter of FULL_NETGEN
4253     #  @ingroup l3_hypos_netgen
4254     def SetGrowthRate(self, theRate):
4255         self.Parameters().SetGrowthRate(theRate)
4256
4257     ## Sets NbSegPerEdge
4258     #  Parameter of FULL_NETGEN
4259     #  @ingroup l3_hypos_netgen
4260     def SetNbSegPerEdge(self, theVal):
4261         self.Parameters().SetNbSegPerEdge(theVal)
4262
4263     ## Sets NbSegPerRadius
4264     #  Parameter of FULL_NETGEN
4265     #  @ingroup l3_hypos_netgen
4266     def SetNbSegPerRadius(self, theVal):
4267         self.Parameters().SetNbSegPerRadius(theVal)
4268
4269     ## Sets number of segments overriding value set by SetLocalLength()
4270     #  Only for algoType == NETGEN_FULL
4271     #  @ingroup l3_hypos_netgen
4272     def SetNumberOfSegments(self, theVal):
4273         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4274
4275     ## Sets number of segments overriding value set by SetNumberOfSegments()
4276     #  Only for algoType == NETGEN_FULL
4277     #  @ingroup l3_hypos_netgen
4278     def SetLocalLength(self, theVal):
4279         self.Parameters(SIMPLE).SetLocalLength(theVal)
4280
4281     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4282     #  Overrides value set by LengthFromEdges()
4283     #  Only for algoType == NETGEN_FULL
4284     #  @ingroup l3_hypos_netgen
4285     def MaxElementArea(self, area):
4286         self.Parameters(SIMPLE).SetMaxElementArea(area)
4287
4288     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4289     #  Overrides value set by MaxElementArea()
4290     #  Only for algoType == NETGEN_FULL
4291     #  @ingroup l3_hypos_netgen
4292     def LengthFromEdges(self):
4293         self.Parameters(SIMPLE).LengthFromEdges()
4294
4295     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4296     #  Overrides value set by MaxElementVolume()
4297     #  Only for algoType == NETGEN_FULL
4298     #  @ingroup l3_hypos_netgen
4299     def LengthFromFaces(self):
4300         self.Parameters(SIMPLE).LengthFromFaces()
4301
4302     ## To mesh "holes" in a solid or not. Default is to mesh.
4303     #  @ingroup l3_hypos_ghs3dh
4304     def SetToMeshHoles(self, toMesh):
4305         #  Parameter of GHS3D
4306         self.Parameters().SetToMeshHoles(toMesh)
4307
4308     ## Set Optimization level:
4309     #   None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4310     #  Default is Medium_Optimization
4311     #  @ingroup l3_hypos_ghs3dh
4312     def SetOptimizationLevel(self, level):
4313         #  Parameter of GHS3D
4314         self.Parameters().SetOptimizationLevel(level)
4315
4316     ## Maximal size of memory to be used by the algorithm (in Megabytes).
4317     #  @ingroup l3_hypos_ghs3dh
4318     def SetMaximumMemory(self, MB):
4319         #  Advanced parameter of GHS3D
4320         self.Parameters().SetMaximumMemory(MB)
4321
4322     ## Initial size of memory to be used by the algorithm (in Megabytes) in
4323     #  automatic memory adjustment mode.
4324     #  @ingroup l3_hypos_ghs3dh
4325     def SetInitialMemory(self, MB):
4326         #  Advanced parameter of GHS3D
4327         self.Parameters().SetInitialMemory(MB)
4328
4329     ## Path to working directory.
4330     #  @ingroup l3_hypos_ghs3dh
4331     def SetWorkingDirectory(self, path):
4332         #  Advanced parameter of GHS3D
4333         self.Parameters().SetWorkingDirectory(path)
4334
4335     ## To keep working files or remove them. Log file remains in case of errors anyway.
4336     #  @ingroup l3_hypos_ghs3dh
4337     def SetKeepFiles(self, toKeep):
4338         #  Advanced parameter of GHS3D and GHS3DPRL
4339         self.Parameters().SetKeepFiles(toKeep)
4340
4341     ## To set verbose level [0-10]. <ul>
4342     #<li> 0 - no standard output,
4343     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4344     #     indicates when the final mesh is being saved. In addition the software
4345     #     gives indication regarding the CPU time.
4346     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4347     #     histogram of the skin mesh, quality statistics histogram together with
4348     #     the characteristics of the final mesh.</ul>
4349     #  @ingroup l3_hypos_ghs3dh
4350     def SetVerboseLevel(self, level):
4351         #  Advanced parameter of GHS3D
4352         self.Parameters().SetVerboseLevel(level)
4353
4354     ## To create new nodes.
4355     #  @ingroup l3_hypos_ghs3dh
4356     def SetToCreateNewNodes(self, toCreate):
4357         #  Advanced parameter of GHS3D
4358         self.Parameters().SetToCreateNewNodes(toCreate)
4359
4360     ## To use boundary recovery version which tries to create mesh on a very poor
4361     #  quality surface mesh.
4362     #  @ingroup l3_hypos_ghs3dh
4363     def SetToUseBoundaryRecoveryVersion(self, toUse):
4364         #  Advanced parameter of GHS3D
4365         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4366
4367     ## Sets command line option as text.
4368     #  @ingroup l3_hypos_ghs3dh
4369     def SetTextOption(self, option):
4370         #  Advanced parameter of GHS3D
4371         self.Parameters().SetTextOption(option)
4372
4373     ## Sets MED files name and path.
4374     def SetMEDName(self, value):
4375         self.Parameters().SetMEDName(value)
4376
4377     ## Sets the number of partition of the initial mesh
4378     def SetNbPart(self, value):
4379         self.Parameters().SetNbPart(value)
4380
4381     ## When big mesh, start tepal in background
4382     def SetBackground(self, value):
4383         self.Parameters().SetBackground(value)
4384
4385 # Public class: Mesh_Hexahedron
4386 # ------------------------------
4387
4388 ## Defines a hexahedron 3D algorithm
4389 #
4390 #  @ingroup l3_algos_basic
4391 class Mesh_Hexahedron(Mesh_Algorithm):
4392
4393     params = 0
4394     algoType = 0
4395
4396     ## Private constructor.
4397     def __init__(self, mesh, algoType=Hexa, geom=0):
4398         Mesh_Algorithm.__init__(self)
4399
4400         self.algoType = algoType
4401
4402         if algoType == Hexa:
4403             self.Create(mesh, geom, "Hexa_3D")
4404             pass
4405
4406         elif algoType == Hexotic:
4407             import HexoticPlugin
4408             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4409             pass
4410
4411     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4412     #  @ingroup l3_hypos_hexotic
4413     def MinMaxQuad(self, min=3, max=8, quad=True):
4414         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4415                                       UseExisting=0)
4416         self.params.SetHexesMinLevel(min)
4417         self.params.SetHexesMaxLevel(max)
4418         self.params.SetHexoticQuadrangles(quad)
4419         return self.params
4420
4421 # Deprecated, only for compatibility!
4422 # Public class: Mesh_Netgen
4423 # ------------------------------
4424
4425 ## Defines a NETGEN-based 2D or 3D algorithm
4426 #  that needs no discrete boundary (i.e. independent)
4427 #
4428 #  This class is deprecated, only for compatibility!
4429 #
4430 #  More details.
4431 #  @ingroup l3_algos_basic
4432 class Mesh_Netgen(Mesh_Algorithm):
4433
4434     is3D = 0
4435
4436     ## Private constructor.
4437     def __init__(self, mesh, is3D, geom=0):
4438         Mesh_Algorithm.__init__(self)
4439
4440         if noNETGENPlugin:
4441             print "Warning: NETGENPlugin module has not been imported."
4442
4443         self.is3D = is3D
4444         if is3D:
4445             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4446             pass
4447
4448         else:
4449             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4450             pass
4451
4452     ## Defines the hypothesis containing parameters of the algorithm
4453     def Parameters(self):
4454         if self.is3D:
4455             hyp = self.Hypothesis("NETGEN_Parameters", [],
4456                                   "libNETGENEngine.so", UseExisting=0)
4457         else:
4458             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4459                                   "libNETGENEngine.so", UseExisting=0)
4460         return hyp
4461
4462 # Public class: Mesh_Projection1D
4463 # ------------------------------
4464
4465 ## Defines a projection 1D algorithm
4466 #  @ingroup l3_algos_proj
4467 #
4468 class Mesh_Projection1D(Mesh_Algorithm):
4469
4470     ## Private constructor.
4471     def __init__(self, mesh, geom=0):
4472         Mesh_Algorithm.__init__(self)
4473         self.Create(mesh, geom, "Projection_1D")
4474
4475     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4476     #  a mesh pattern is taken, and, optionally, the association of vertices
4477     #  between the source edge and a target edge (to which a hypothesis is assigned)
4478     #  @param edge from which nodes distribution is taken
4479     #  @param mesh from which nodes distribution is taken (optional)
4480     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4481     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4482     #  to associate with \a srcV (optional)
4483     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4484     #                     the same parameters, else (default) - creates a new one
4485     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4486         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4487                               UseExisting=0)
4488                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4489         hyp.SetSourceEdge( edge )
4490         if not mesh is None and isinstance(mesh, Mesh):
4491             mesh = mesh.GetMesh()
4492         hyp.SetSourceMesh( mesh )
4493         hyp.SetVertexAssociation( srcV, tgtV )
4494         return hyp
4495
4496     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4497     #def CompareSourceEdge(self, hyp, args):
4498     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4499     #    return False
4500
4501
4502 # Public class: Mesh_Projection2D
4503 # ------------------------------
4504
4505 ## Defines a projection 2D algorithm
4506 #  @ingroup l3_algos_proj
4507 #
4508 class Mesh_Projection2D(Mesh_Algorithm):
4509
4510     ## Private constructor.
4511     def __init__(self, mesh, geom=0):
4512         Mesh_Algorithm.__init__(self)
4513         self.Create(mesh, geom, "Projection_2D")
4514
4515     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4516     #  a mesh pattern is taken, and, optionally, the association of vertices
4517     #  between the source face and the target face (to which a hypothesis is assigned)
4518     #  @param face from which the mesh pattern is taken
4519     #  @param mesh from which the mesh pattern is taken (optional)
4520     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4521     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4522     #               to associate with \a srcV1 (optional)
4523     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4524     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4525     #               to associate with \a srcV2 (optional)
4526     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
4527     #                     the same parameters, else (default) - forces the creation a new one
4528     #
4529     #  Note: all association vertices must belong to one edge of a face
4530     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4531                    srcV2=None, tgtV2=None, UseExisting=0):
4532         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4533                               UseExisting=0)
4534                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4535         hyp.SetSourceFace( face )
4536         if not mesh is None and isinstance(mesh, Mesh):
4537             mesh = mesh.GetMesh()
4538         hyp.SetSourceMesh( mesh )
4539         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4540         return hyp
4541
4542     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4543     #def CompareSourceFace(self, hyp, args):
4544     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4545     #    return False
4546
4547 # Public class: Mesh_Projection3D
4548 # ------------------------------
4549
4550 ## Defines a projection 3D algorithm
4551 #  @ingroup l3_algos_proj
4552 #
4553 class Mesh_Projection3D(Mesh_Algorithm):
4554
4555     ## Private constructor.
4556     def __init__(self, mesh, geom=0):
4557         Mesh_Algorithm.__init__(self)
4558         self.Create(mesh, geom, "Projection_3D")
4559
4560     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4561     #  the mesh pattern is taken, and, optionally, the  association of vertices
4562     #  between the source and the target solid  (to which a hipothesis is assigned)
4563     #  @param solid from where the mesh pattern is taken
4564     #  @param mesh from where the mesh pattern is taken (optional)
4565     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4566     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4567     #  to associate with \a srcV1 (optional)
4568     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4569     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4570     #  to associate with \a srcV2 (optional)
4571     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
4572     #                     the same parameters, else (default) - creates a new one
4573     #
4574     #  Note: association vertices must belong to one edge of a solid
4575     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4576                       srcV2=0, tgtV2=0, UseExisting=0):
4577         hyp = self.Hypothesis("ProjectionSource3D",
4578                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4579                               UseExisting=0)
4580                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4581         hyp.SetSource3DShape( solid )
4582         if not mesh is None and isinstance(mesh, Mesh):
4583             mesh = mesh.GetMesh()
4584         hyp.SetSourceMesh( mesh )
4585         if srcV1 and srcV2 and tgtV1 and tgtV2:
4586             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4587         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4588         return hyp
4589
4590     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4591     #def CompareSourceShape3D(self, hyp, args):
4592     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4593     #    return False
4594
4595
4596 # Public class: Mesh_Prism
4597 # ------------------------
4598
4599 ## Defines a 3D extrusion algorithm
4600 #  @ingroup l3_algos_3dextr
4601 #
4602 class Mesh_Prism3D(Mesh_Algorithm):
4603
4604     ## Private constructor.
4605     def __init__(self, mesh, geom=0):
4606         Mesh_Algorithm.__init__(self)
4607         self.Create(mesh, geom, "Prism_3D")
4608
4609 # Public class: Mesh_RadialPrism
4610 # -------------------------------
4611
4612 ## Defines a Radial Prism 3D algorithm
4613 #  @ingroup l3_algos_radialp
4614 #
4615 class Mesh_RadialPrism3D(Mesh_Algorithm):
4616
4617     ## Private constructor.
4618     def __init__(self, mesh, geom=0):
4619         Mesh_Algorithm.__init__(self)
4620         self.Create(mesh, geom, "RadialPrism_3D")
4621
4622         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4623         self.nbLayers = None
4624
4625     ## Return 3D hypothesis holding the 1D one
4626     def Get3DHypothesis(self):
4627         return self.distribHyp
4628
4629     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4630     #  hypothesis. Returns the created hypothesis
4631     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4632         #print "OwnHypothesis",hypType
4633         if not self.nbLayers is None:
4634             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4635             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4636         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4637         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4638         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4639         self.distribHyp.SetLayerDistribution( hyp )
4640         return hyp
4641
4642     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4643     #  prisms to build between the inner and outer shells
4644     #  @param n number of layers
4645     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4646     #                     the same parameters, else (default) - creates a new one
4647     def NumberOfLayers(self, n, UseExisting=0):
4648         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4649         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4650                                         CompareMethod=self.CompareNumberOfLayers)
4651         self.nbLayers.SetNumberOfLayers( n )
4652         return self.nbLayers
4653
4654     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4655     def CompareNumberOfLayers(self, hyp, args):
4656         return IsEqual(hyp.GetNumberOfLayers(), args[0])
4657
4658     ## Defines "LocalLength" hypothesis, specifying the segment length
4659     #  to build between the inner and the outer shells
4660     #  @param l the length of segments
4661     #  @param p the precision of rounding
4662     def LocalLength(self, l, p=1e-07):
4663         hyp = self.OwnHypothesis("LocalLength", [l,p])
4664         hyp.SetLength(l)
4665         hyp.SetPrecision(p)
4666         return hyp
4667
4668     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4669     #  prisms to build between the inner and the outer shells.
4670     #  @param n the number of layers
4671     #  @param s the scale factor (optional)
4672     def NumberOfSegments(self, n, s=[]):
4673         if s == []:
4674             hyp = self.OwnHypothesis("NumberOfSegments", [n])
4675         else:
4676             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4677             hyp.SetDistrType( 1 )
4678             hyp.SetScaleFactor(s)
4679         hyp.SetNumberOfSegments(n)
4680         return hyp
4681
4682     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4683     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
4684     #  @param start  the length of the first segment
4685     #  @param end    the length of the last  segment
4686     def Arithmetic1D(self, start, end ):
4687         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4688         hyp.SetLength(start, 1)
4689         hyp.SetLength(end  , 0)
4690         return hyp
4691
4692     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4693     #  to build between the inner and the outer shells as geometric length increasing
4694     #  @param start for the length of the first segment
4695     #  @param end   for the length of the last  segment
4696     def StartEndLength(self, start, end):
4697         hyp = self.OwnHypothesis("StartEndLength", [start, end])
4698         hyp.SetLength(start, 1)
4699         hyp.SetLength(end  , 0)
4700         return hyp
4701
4702     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4703     #  to build between the inner and outer shells
4704     #  @param fineness defines the quality of the mesh within the range [0-1]
4705     def AutomaticLength(self, fineness=0):
4706         hyp = self.OwnHypothesis("AutomaticLength")
4707         hyp.SetFineness( fineness )
4708         return hyp
4709
4710 # Private class: Mesh_UseExisting
4711 # -------------------------------
4712 class Mesh_UseExisting(Mesh_Algorithm):
4713
4714     def __init__(self, dim, mesh, geom=0):
4715         if dim == 1:
4716             self.Create(mesh, geom, "UseExisting_1D")
4717         else:
4718             self.Create(mesh, geom, "UseExisting_2D")
4719
4720
4721 import salome_notebook
4722 notebook = salome_notebook.notebook
4723
4724 ##Return values of the notebook variables
4725 def ParseParameters(last, nbParams,nbParam, value):
4726     result = None
4727     strResult = ""
4728     counter = 0
4729     listSize = len(last)
4730     for n in range(0,nbParams):
4731         if n+1 != nbParam:
4732             if counter < listSize:
4733                 strResult = strResult + last[counter]
4734             else:
4735                 strResult = strResult + ""
4736         else:
4737             if isinstance(value, str):
4738                 if notebook.isVariable(value):
4739                     result = notebook.get(value)
4740                     strResult=strResult+value
4741                 else:
4742                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4743             else:
4744                 strResult=strResult+str(value)
4745                 result = value
4746         if nbParams - 1 != counter:
4747             strResult=strResult+var_separator #":"
4748         counter = counter+1
4749     return result, strResult
4750
4751 #Wrapper class for StdMeshers_LocalLength hypothesis
4752 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4753
4754     ## Set Length parameter value
4755     #  @param length numerical value or name of variable from notebook
4756     def SetLength(self, length):
4757         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4758         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4759         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4760
4761    ## Set Precision parameter value
4762    #  @param precision numerical value or name of variable from notebook
4763     def SetPrecision(self, precision):
4764         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4765         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4766         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4767
4768 #Registering the new proxy for LocalLength
4769 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4770
4771
4772 #Wrapper class for StdMeshers_LayerDistribution hypothesis
4773 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
4774     
4775     def SetLayerDistribution(self, hypo):
4776         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
4777         hypo.ClearParameters();
4778         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
4779
4780 #Registering the new proxy for LayerDistribution
4781 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
4782
4783 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4784 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4785     
4786     ## Set Length parameter value
4787     #  @param length numerical value or name of variable from notebook    
4788     def SetLength(self, length):
4789         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4790         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4791         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4792
4793 #Registering the new proxy for SegmentLengthAroundVertex
4794 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4795
4796
4797 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4798 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4799     
4800     ## Set Length parameter value
4801     #  @param length   numerical value or name of variable from notebook
4802     #  @param isStart  true is length is Start Length, otherwise false
4803     def SetLength(self, length, isStart):
4804         nb = 2
4805         if isStart:
4806             nb = 1
4807         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4808         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4809         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4810         
4811 #Registering the new proxy for Arithmetic1D
4812 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4813
4814 #Wrapper class for StdMeshers_Deflection1D hypothesis
4815 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4816     
4817     ## Set Deflection parameter value
4818     #  @param deflection numerical value or name of variable from notebook    
4819     def SetDeflection(self, deflection):
4820         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4821         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4822         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4823
4824 #Registering the new proxy for Deflection1D
4825 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4826
4827 #Wrapper class for StdMeshers_StartEndLength hypothesis
4828 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4829     
4830     ## Set Length parameter value
4831     #  @param length  numerical value or name of variable from notebook
4832     #  @param isStart true is length is Start Length, otherwise false
4833     def SetLength(self, length, isStart):
4834         nb = 2
4835         if isStart:
4836             nb = 1
4837         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4838         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4839         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4840         
4841 #Registering the new proxy for StartEndLength
4842 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4843
4844 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4845 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4846     
4847     ## Set Max Element Area parameter value
4848     #  @param area  numerical value or name of variable from notebook
4849     def SetMaxElementArea(self, area):
4850         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4851         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4852         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4853         
4854 #Registering the new proxy for MaxElementArea
4855 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4856
4857
4858 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
4859 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
4860     
4861     ## Set Max Element Volume parameter value
4862     #  @param area  numerical value or name of variable from notebook
4863     def SetMaxElementVolume(self, volume):
4864         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
4865         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
4866         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
4867         
4868 #Registering the new proxy for MaxElementVolume
4869 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
4870
4871
4872 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4873 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4874     
4875     ## Set Number Of Layers parameter value
4876     #  @param nbLayers  numerical value or name of variable from notebook
4877     def SetNumberOfLayers(self, nbLayers):
4878         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4879         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4880         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4881         
4882 #Registering the new proxy for NumberOfLayers
4883 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4884
4885 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4886 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4887     
4888     ## Set Number Of Segments parameter value
4889     #  @param nbSeg numerical value or name of variable from notebook
4890     def SetNumberOfSegments(self, nbSeg):
4891         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4892         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4893         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4894         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4895         
4896     ## Set Scale Factor parameter value
4897     #  @param factor numerical value or name of variable from notebook
4898     def SetScaleFactor(self, factor):
4899         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4900         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4901         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4902         
4903 #Registering the new proxy for NumberOfSegments
4904 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
4905
4906
4907 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
4908 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
4909
4910     ## Set Max Size parameter value
4911     #  @param maxsize numerical value or name of variable from notebook
4912     def SetMaxSize(self, maxsize):
4913         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4914         maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
4915         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4916         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
4917         
4918     ## Set Growth Rate parameter value
4919     #  @param value  numerical value or name of variable from notebook
4920     def SetGrowthRate(self, value):
4921         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4922         value, parameters = ParseParameters(lastParameters,4,2,value)
4923         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4924         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
4925         
4926     ## Set Number of Segments per Edge parameter value
4927     #  @param value  numerical value or name of variable from notebook
4928     def SetNbSegPerEdge(self, value):
4929         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4930         value, parameters = ParseParameters(lastParameters,4,3,value)
4931         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4932         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
4933         
4934     ## Set Number of Segments per Radius parameter value
4935     #  @param value  numerical value or name of variable from notebook
4936     def SetNbSegPerRadius(self, value):
4937         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4938         value, parameters = ParseParameters(lastParameters,4,4,value)
4939         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4940         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
4941         
4942 #Registering the new proxy for NETGENPlugin_Hypothesis
4943 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
4944
4945
4946 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
4947 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
4948     pass
4949
4950 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
4951 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
4952
4953 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
4954 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
4955     
4956     ## Set Number of Segments parameter value
4957     #  @param nbSeg numerical value or name of variable from notebook
4958     def SetNumberOfSegments(self, nbSeg):
4959         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4960         nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
4961         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4962         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
4963
4964     ## Set Local Length parameter value
4965     #  @param length numerical value or name of variable from notebook
4966     def SetLocalLength(self, length):
4967         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4968         length, parameters = ParseParameters(lastParameters,2,1,length)
4969         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4970         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
4971
4972     ## Set Max Element Area parameter value
4973     #  @param area numerical value or name of variable from notebook    
4974     def SetMaxElementArea(self, area):
4975         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4976         area, parameters = ParseParameters(lastParameters,2,2,area)
4977         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4978         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
4979
4980     def LengthFromEdges(self):
4981         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4982         value = 0;
4983         value, parameters = ParseParameters(lastParameters,2,2,value)
4984         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4985         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
4986         
4987 #Registering the new proxy for NETGEN_SimpleParameters_2D
4988 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
4989
4990
4991 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
4992 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
4993     ## Set Max Element Volume parameter value
4994     #  @param volume numerical value or name of variable from notebook    
4995     def SetMaxElementVolume(self, volume):
4996         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4997         volume, parameters = ParseParameters(lastParameters,3,3,volume)
4998         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4999         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5000
5001     def LengthFromFaces(self):
5002         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5003         value = 0;
5004         value, parameters = ParseParameters(lastParameters,3,3,value)
5005         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5006         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5007         
5008 #Registering the new proxy for NETGEN_SimpleParameters_3D
5009 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5010
5011 class Pattern(SMESH._objref_SMESH_Pattern):
5012
5013     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5014         flag = False
5015         if isinstance(theNodeIndexOnKeyPoint1,str):
5016             flag = True
5017         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5018         if flag:
5019             theNodeIndexOnKeyPoint1 -= 1
5020         theMesh.SetParameters(Parameters)
5021         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5022
5023     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5024         flag0 = False
5025         flag1 = False
5026         if isinstance(theNode000Index,str):
5027             flag0 = True
5028         if isinstance(theNode001Index,str):
5029             flag1 = True
5030         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5031         if flag0:
5032             theNode000Index -= 1
5033         if flag1:
5034             theNode001Index -= 1
5035         theMesh.SetParameters(Parameters)
5036         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5037
5038 #Registering the new proxy for Pattern
5039 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)