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