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