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