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