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