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