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