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