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