Salome HOME
0021014: EDF 1583 SMESH: Improvement of the Python Dump for the creation of groups
[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 objects 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     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4153     #  @ingroup l2_modif_edit
4154     def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4155         if theMakeGroup:
4156             return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4157         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4158
4159     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4160     #  @param theElems - the list of elements (edges or faces) to be replicated
4161     #         The nodes for duplication could be found from these elements
4162     #  @param theNodesNot - list of nodes to NOT replicate
4163     #  @param theAffectedElems - the list of elements (cells and edges) to which the
4164     #         replicated nodes should be associated to.
4165     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4166     #  @ingroup l2_modif_edit
4167     def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4168         return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4169
4170     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4171     #  @param theElems - the list of elements (edges or faces) to be replicated
4172     #         The nodes for duplication could be found from these elements
4173     #  @param theNodesNot - list of nodes to NOT replicate
4174     #  @param theShape - shape to detect affected elements (element which geometric center
4175     #         located on or inside shape).
4176     #         The replicated nodes should be associated to affected elements.
4177     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4178     #  @ingroup l2_modif_edit
4179     def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4180         return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4181
4182     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4183     #  This method provided for convenience works as DoubleNodes() described above.
4184     #  @param theElems - group of of elements (edges or faces) to be replicated
4185     #  @param theNodesNot - group of nodes not to replicated
4186     #  @param theAffectedElems - group of elements to which the replicated nodes
4187     #         should be associated to.
4188     #  @param theMakeGroup forces the generation of a group containing new elements.
4189     #  @return TRUE or a created group if operation has been completed successfully,
4190     #          FALSE or None otherwise
4191     #  @ingroup l2_modif_edit
4192     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4193         if theMakeGroup:
4194             return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4195         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4196
4197     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4198     #  This method provided for convenience works as DoubleNodes() described above.
4199     #  @param theElems - group of of elements (edges or faces) to be replicated
4200     #  @param theNodesNot - group of nodes not to replicated
4201     #  @param theShape - shape to detect affected elements (element which geometric center
4202     #         located on or inside shape).
4203     #         The replicated nodes should be associated to affected elements.
4204     #  @ingroup l2_modif_edit
4205     def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4206         return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4207
4208     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4209     #  This method provided for convenience works as DoubleNodes() described above.
4210     #  @param theElems - list of groups of elements (edges or faces) to be replicated
4211     #  @param theNodesNot - list of groups of nodes not to replicated
4212     #  @param theAffectedElems - group of elements to which the replicated nodes
4213     #         should be associated to.
4214     #  @param theMakeGroup forces the generation of a group containing new elements.
4215     #  @return TRUE or a created group if operation has been completed successfully,
4216     #          FALSE or None otherwise
4217     #  @ingroup l2_modif_edit
4218     def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4219         if theMakeGroup:
4220             return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4221         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4222
4223     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4224     #  This method provided for convenience works as DoubleNodes() described above.
4225     #  @param theElems - list of groups of elements (edges or faces) to be replicated
4226     #  @param theNodesNot - list of groups of nodes not to replicated
4227     #  @param theShape - shape to detect affected elements (element which geometric center
4228     #         located on or inside shape).
4229     #         The replicated nodes should be associated to affected elements.
4230     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4231     #  @ingroup l2_modif_edit
4232     def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4233         return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4234
4235     ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4236     # The list of groups must describe a partition of the mesh volumes.
4237     # The nodes of the internal faces at the boundaries of the groups are doubled.
4238     # In option, the internal faces are replaced by flat elements.
4239     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4240     # @param theDomains - list of groups of volumes
4241     # @param createJointElems - if TRUE, create the elements
4242     # @return TRUE if operation has been completed successfully, FALSE otherwise
4243     def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4244        return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4245
4246     ## Double nodes on some external faces and create flat elements.
4247     # Flat elements are mainly used by some types of mechanic calculations.
4248     #
4249     # Each group of the list must be constituted of faces.
4250     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4251     # @param theGroupsOfFaces - list of groups of faces
4252     # @return TRUE if operation has been completed successfully, FALSE otherwise
4253     def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
4254         return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
4255
4256     def _valueFromFunctor(self, funcType, elemId):
4257         fn = self.smeshpyD.GetFunctor(funcType)
4258         fn.SetMesh(self.mesh)
4259         if fn.GetElementType() == self.GetElementType(elemId, True):
4260             val = fn.GetValue(elemId)
4261         else:
4262             val = 0
4263         return val
4264
4265     ## Get length of 1D element.
4266     #  @param elemId mesh element ID
4267     #  @return element's length value
4268     #  @ingroup l1_measurements
4269     def GetLength(self, elemId):
4270         return self._valueFromFunctor(SMESH.FT_Length, elemId)
4271
4272     ## Get area of 2D element.
4273     #  @param elemId mesh element ID
4274     #  @return element's area value
4275     #  @ingroup l1_measurements
4276     def GetArea(self, elemId):
4277         return self._valueFromFunctor(SMESH.FT_Area, elemId)
4278
4279     ## Get volume of 3D element.
4280     #  @param elemId mesh element ID
4281     #  @return element's volume value
4282     #  @ingroup l1_measurements
4283     def GetVolume(self, elemId):
4284         return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4285
4286     ## Get maximum element length.
4287     #  @param elemId mesh element ID
4288     #  @return element's maximum length value
4289     #  @ingroup l1_measurements
4290     def GetMaxElementLength(self, elemId):
4291         if self.GetElementType(elemId, True) == SMESH.VOLUME:
4292             ftype = SMESH.FT_MaxElementLength3D
4293         else:
4294             ftype = SMESH.FT_MaxElementLength2D
4295         return self._valueFromFunctor(ftype, elemId)
4296
4297     ## Get aspect ratio of 2D or 3D element.
4298     #  @param elemId mesh element ID
4299     #  @return element's aspect ratio value
4300     #  @ingroup l1_measurements
4301     def GetAspectRatio(self, elemId):
4302         if self.GetElementType(elemId, True) == SMESH.VOLUME:
4303             ftype = SMESH.FT_AspectRatio3D
4304         else:
4305             ftype = SMESH.FT_AspectRatio
4306         return self._valueFromFunctor(ftype, elemId)
4307
4308     ## Get warping angle of 2D element.
4309     #  @param elemId mesh element ID
4310     #  @return element's warping angle value
4311     #  @ingroup l1_measurements
4312     def GetWarping(self, elemId):
4313         return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4314
4315     ## Get minimum angle of 2D element.
4316     #  @param elemId mesh element ID
4317     #  @return element's minimum angle value
4318     #  @ingroup l1_measurements
4319     def GetMinimumAngle(self, elemId):
4320         return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4321
4322     ## Get taper of 2D element.
4323     #  @param elemId mesh element ID
4324     #  @return element's taper value
4325     #  @ingroup l1_measurements
4326     def GetTaper(self, elemId):
4327         return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4328
4329     ## Get skew of 2D element.
4330     #  @param elemId mesh element ID
4331     #  @return element's skew value
4332     #  @ingroup l1_measurements
4333     def GetSkew(self, elemId):
4334         return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4335
4336 ## The mother class to define algorithm, it is not recommended to use it directly.
4337 #
4338 #  More details.
4339 #  @ingroup l2_algorithms
4340 class Mesh_Algorithm:
4341     #  @class Mesh_Algorithm
4342     #  @brief Class Mesh_Algorithm
4343
4344     #def __init__(self,smesh):
4345     #    self.smesh=smesh
4346     def __init__(self):
4347         self.mesh = None
4348         self.geom = None
4349         self.subm = None
4350         self.algo = None
4351
4352     ## Finds a hypothesis in the study by its type name and parameters.
4353     #  Finds only the hypotheses created in smeshpyD engine.
4354     #  @return SMESH.SMESH_Hypothesis
4355     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4356         study = smeshpyD.GetCurrentStudy()
4357         #to do: find component by smeshpyD object, not by its data type
4358         scomp = study.FindComponent(smeshpyD.ComponentDataType())
4359         if scomp is not None:
4360             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4361             # Check if the root label of the hypotheses exists
4362             if res and hypRoot is not None:
4363                 iter = study.NewChildIterator(hypRoot)
4364                 # Check all published hypotheses
4365                 while iter.More():
4366                     hypo_so_i = iter.Value()
4367                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4368                     if attr is not None:
4369                         anIOR = attr.Value()
4370                         hypo_o_i = salome.orb.string_to_object(anIOR)
4371                         if hypo_o_i is not None:
4372                             # Check if this is a hypothesis
4373                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4374                             if hypo_i is not None:
4375                                 # Check if the hypothesis belongs to current engine
4376                                 if smeshpyD.GetObjectId(hypo_i) > 0:
4377                                     # Check if this is the required hypothesis
4378                                     if hypo_i.GetName() == hypname:
4379                                         # Check arguments
4380                                         if CompareMethod(hypo_i, args):
4381                                             # found!!!
4382                                             return hypo_i
4383                                         pass
4384                                     pass
4385                                 pass
4386                             pass
4387                         pass
4388                     iter.Next()
4389                     pass
4390                 pass
4391             pass
4392         return None
4393
4394     ## Finds the algorithm in the study by its type name.
4395     #  Finds only the algorithms, which have been created in smeshpyD engine.
4396     #  @return SMESH.SMESH_Algo
4397     def FindAlgorithm (self, algoname, smeshpyD):
4398         study = smeshpyD.GetCurrentStudy()
4399         #to do: find component by smeshpyD object, not by its data type
4400         scomp = study.FindComponent(smeshpyD.ComponentDataType())
4401         if scomp is not None:
4402             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4403             # Check if the root label of the algorithms exists
4404             if res and hypRoot is not None:
4405                 iter = study.NewChildIterator(hypRoot)
4406                 # Check all published algorithms
4407                 while iter.More():
4408                     algo_so_i = iter.Value()
4409                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4410                     if attr is not None:
4411                         anIOR = attr.Value()
4412                         algo_o_i = salome.orb.string_to_object(anIOR)
4413                         if algo_o_i is not None:
4414                             # Check if this is an algorithm
4415                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4416                             if algo_i is not None:
4417                                 # Checks if the algorithm belongs to the current engine
4418                                 if smeshpyD.GetObjectId(algo_i) > 0:
4419                                     # Check if this is the required algorithm
4420                                     if algo_i.GetName() == algoname:
4421                                         # found!!!
4422                                         return algo_i
4423                                     pass
4424                                 pass
4425                             pass
4426                         pass
4427                     iter.Next()
4428                     pass
4429                 pass
4430             pass
4431         return None
4432
4433     ## If the algorithm is global, returns 0; \n
4434     #  else returns the submesh associated to this algorithm.
4435     def GetSubMesh(self):
4436         return self.subm
4437
4438     ## Returns the wrapped mesher.
4439     def GetAlgorithm(self):
4440         return self.algo
4441
4442     ## Gets the list of hypothesis that can be used with this algorithm
4443     def GetCompatibleHypothesis(self):
4444         mylist = []
4445         if self.algo:
4446             mylist = self.algo.GetCompatibleHypothesis()
4447         return mylist
4448
4449     ## Gets the name of the algorithm
4450     def GetName(self):
4451         GetName(self.algo)
4452
4453     ## Sets the name to the algorithm
4454     def SetName(self, name):
4455         self.mesh.smeshpyD.SetName(self.algo, name)
4456
4457     ## Gets the id of the algorithm
4458     def GetId(self):
4459         return self.algo.GetId()
4460
4461     ## Private method.
4462     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4463         if geom is None:
4464             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4465         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4466         if algo is None:
4467             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4468             pass
4469         self.Assign(algo, mesh, geom)
4470         return self.algo
4471
4472     ## Private method
4473     def Assign(self, algo, mesh, geom):
4474         if geom is None:
4475             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4476         self.mesh = mesh
4477         name = ""
4478         if not geom:
4479             self.geom = mesh.geom
4480         else:
4481             self.geom = geom
4482             self.AssureGeomPublished( geom )
4483             try:
4484                 name = GetName(geom)
4485                 pass
4486             except:
4487                 pass
4488             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4489         self.algo = algo
4490         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4491         TreatHypoStatus( status, algo.GetName(), name, True )
4492         return
4493
4494     ## Private method. Add geom into the study if not yet there
4495     def AssureGeomPublished(self, geom, name=''):
4496         if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
4497             return
4498         if not geom.IsSame( self.mesh.geom ) and not geom.GetStudyEntry():
4499             ## set the study
4500             studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4501             if studyID != self.mesh.geompyD.myStudyId:
4502                 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4503             ## get a name
4504             if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4505                 # for all groups SubShapeName() returns "Compound_-1"
4506                 name = self.mesh.geompyD.SubShapeName(geom, self.mesh.geom)
4507             if not name:
4508                 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4509             ## publish
4510             self.mesh.geompyD.addToStudyInFather( self.mesh.geom, geom, name )
4511         return
4512
4513     def CompareHyp (self, hyp, args):
4514         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4515         return False
4516
4517     def CompareEqualHyp (self, hyp, args):
4518         return True
4519
4520     ## Private method
4521     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4522                     UseExisting=0, CompareMethod=""):
4523         hypo = None
4524         if UseExisting:
4525             if CompareMethod == "": CompareMethod = self.CompareHyp
4526             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4527             pass
4528         if hypo is None:
4529             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4530             a = ""
4531             s = "="
4532             i = 0
4533             n = len(args)
4534             while i<n:
4535                 a = a + s + str(args[i])
4536                 s = ","
4537                 i = i + 1
4538                 pass
4539             self.mesh.smeshpyD.SetName(hypo, hyp + a)
4540             pass
4541         geomName=""
4542         if self.geom:
4543             geomName = GetName(self.geom)
4544         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4545         TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4546         return hypo
4547
4548     ## Returns entry of the shape to mesh in the study
4549     def MainShapeEntry(self):
4550         entry = ""
4551         if not self.mesh or not self.mesh.GetMesh(): return entry
4552         if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4553         study = self.mesh.smeshpyD.GetCurrentStudy()
4554         ior  = salome.orb.object_to_string( self.mesh.GetShape() )
4555         sobj = study.FindObjectIOR(ior)
4556         if sobj: entry = sobj.GetID()
4557         if not entry: return ""
4558         return entry
4559
4560     ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4561     #  near mesh boundary. This hypothesis can be used by several 3D algorithms:
4562     #  NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4563     #  @param thickness total thickness of layers of prisms
4564     #  @param numberOfLayers number of layers of prisms
4565     #  @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4566     #  @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4567     #  @ingroup l3_hypos_additi
4568     def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4569         if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4570             raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4571         if not "ViscousLayers" in self.GetCompatibleHypothesis():
4572             raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4573         if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4574             ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4575         hyp = self.Hypothesis("ViscousLayers",
4576                               [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4577         hyp.SetTotalThickness(thickness)
4578         hyp.SetNumberLayers(numberOfLayers)
4579         hyp.SetStretchFactor(stretchFactor)
4580         hyp.SetIgnoreFaces(ignoreFaces)
4581         return hyp
4582
4583 # Public class: Mesh_Segment
4584 # --------------------------
4585
4586 ## Class to define a segment 1D algorithm for discretization
4587 #
4588 #  More details.
4589 #  @ingroup l3_algos_basic
4590 class Mesh_Segment(Mesh_Algorithm):
4591
4592     ## Private constructor.
4593     def __init__(self, mesh, geom=0):
4594         Mesh_Algorithm.__init__(self)
4595         self.Create(mesh, geom, "Regular_1D")
4596
4597     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4598     #  @param l for the length of segments that cut an edge
4599     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
4600     #                    the same parameters, else (default) - creates a new one
4601     #  @param p precision, used for calculation of the number of segments.
4602     #           The precision should be a positive, meaningful value within the range [0,1].
4603     #           In general, the number of segments is calculated with the formula:
4604     #           nb = ceil((edge_length / l) - p)
4605     #           Function ceil rounds its argument to the higher integer.
4606     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
4607     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
4608     #               p=1 means rounding of (edge_length / l) to the lower integer.
4609     #           Default value is 1e-07.
4610     #  @return an instance of StdMeshers_LocalLength hypothesis
4611     #  @ingroup l3_hypos_1dhyps
4612     def LocalLength(self, l, UseExisting=0, p=1e-07):
4613         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4614                               CompareMethod=self.CompareLocalLength)
4615         hyp.SetLength(l)
4616         hyp.SetPrecision(p)
4617         return hyp
4618
4619     ## Private method
4620     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4621     def CompareLocalLength(self, hyp, args):
4622         if IsEqual(hyp.GetLength(), args[0]):
4623             return IsEqual(hyp.GetPrecision(), args[1])
4624         return False
4625
4626     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4627     #  @param length is optional maximal allowed length of segment, if it is omitted
4628     #                the preestimated length is used that depends on geometry size
4629     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4630     #                     the same parameters, else (default) - create a new one
4631     #  @return an instance of StdMeshers_MaxLength hypothesis
4632     #  @ingroup l3_hypos_1dhyps
4633     def MaxSize(self, length=0.0, UseExisting=0):
4634         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4635         if length > 0.0:
4636             # set given length
4637             hyp.SetLength(length)
4638         if not UseExisting:
4639             # set preestimated length
4640             gen = self.mesh.smeshpyD
4641             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4642                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
4643                                                        False) # <- byMesh
4644             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4645             if preHyp:
4646                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4647                 pass
4648             pass
4649         hyp.SetUsePreestimatedLength( length == 0.0 )
4650         return hyp
4651
4652     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4653     #  @param n for the number of segments that cut an edge
4654     #  @param s for the scale factor (optional)
4655     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4656     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4657     #                     the same parameters, else (default) - create a new one
4658     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
4659     #  @ingroup l3_hypos_1dhyps
4660     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4661         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4662             reversedEdges, UseExisting = [], reversedEdges
4663         entry = self.MainShapeEntry()
4664         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4665             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4666         if s == []:
4667             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4668                                   UseExisting=UseExisting,
4669                                   CompareMethod=self.CompareNumberOfSegments)
4670         else:
4671             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4672                                   UseExisting=UseExisting,
4673                                   CompareMethod=self.CompareNumberOfSegments)
4674             hyp.SetDistrType( 1 )
4675             hyp.SetScaleFactor(s)
4676         hyp.SetNumberOfSegments(n)
4677         hyp.SetReversedEdges( reversedEdges )
4678         hyp.SetObjectEntry( entry )
4679         return hyp
4680
4681     ## Private method
4682     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4683     def CompareNumberOfSegments(self, hyp, args):
4684         if hyp.GetNumberOfSegments() == args[0]:
4685             if len(args) == 3:
4686                 if hyp.GetReversedEdges() == args[1]:
4687                     if not args[1] or hyp.GetObjectEntry() == args[2]:
4688                         return True
4689             else:
4690                 if hyp.GetReversedEdges() == args[2]:
4691                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4692                         if hyp.GetDistrType() == 1:
4693                             if IsEqual(hyp.GetScaleFactor(), args[1]):
4694                                 return True
4695         return False
4696
4697     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4698     #  @param start defines the length of the first segment
4699     #  @param end   defines the length of the last  segment
4700     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4701     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4702     #                     the same parameters, else (default) - creates a new one
4703     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4704     #  @ingroup l3_hypos_1dhyps
4705     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4706         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4707             reversedEdges, UseExisting = [], reversedEdges
4708         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4709             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4710         entry = self.MainShapeEntry()
4711         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4712                               UseExisting=UseExisting,
4713                               CompareMethod=self.CompareArithmetic1D)
4714         hyp.SetStartLength(start)
4715         hyp.SetEndLength(end)
4716         hyp.SetReversedEdges( reversedEdges )
4717         hyp.SetObjectEntry( entry )
4718         return hyp
4719
4720     ## Private method
4721     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4722     def CompareArithmetic1D(self, hyp, args):
4723         if IsEqual(hyp.GetLength(1), args[0]):
4724             if IsEqual(hyp.GetLength(0), args[1]):
4725                 if hyp.GetReversedEdges() == args[2]:
4726                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4727                         return True
4728         return False
4729
4730
4731     ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4732     # on curve from 0 to 1 (additionally it is neecessary to check
4733     # orientation of edges and create list of reversed edges if it is
4734     # needed) and sets numbers of segments between given points (default
4735     # values are equals 1
4736     #  @param points defines the list of parameters on curve
4737     #  @param nbSegs defines the list of numbers of segments
4738     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4739     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4740     #                     the same parameters, else (default) - creates a new one
4741     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4742     #  @ingroup l3_hypos_1dhyps
4743     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4744         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4745             reversedEdges, UseExisting = [], reversedEdges
4746         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4747             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4748         entry = self.MainShapeEntry()
4749         hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4750                               UseExisting=UseExisting,
4751                               CompareMethod=self.CompareFixedPoints1D)
4752         hyp.SetPoints(points)
4753         hyp.SetNbSegments(nbSegs)
4754         hyp.SetReversedEdges(reversedEdges)
4755         hyp.SetObjectEntry(entry)
4756         return hyp
4757
4758     ## Private method
4759     ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4760     ## as the given arguments
4761     def CompareFixedPoints1D(self, hyp, args):
4762         if hyp.GetPoints() == args[0]:
4763             if hyp.GetNbSegments() == args[1]:
4764                 if hyp.GetReversedEdges() == args[2]:
4765                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4766                         return True
4767         return False
4768
4769
4770
4771     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4772     #  @param start defines the length of the first segment
4773     #  @param end   defines the length of the last  segment
4774     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4775     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4776     #                     the same parameters, else (default) - creates a new one
4777     #  @return an instance of StdMeshers_StartEndLength hypothesis
4778     #  @ingroup l3_hypos_1dhyps
4779     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4780         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4781             reversedEdges, UseExisting = [], reversedEdges
4782         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4783             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4784         entry = self.MainShapeEntry()
4785         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4786                               UseExisting=UseExisting,
4787                               CompareMethod=self.CompareStartEndLength)
4788         hyp.SetStartLength(start)
4789         hyp.SetEndLength(end)
4790         hyp.SetReversedEdges( reversedEdges )
4791         hyp.SetObjectEntry( entry )
4792         return hyp
4793
4794     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4795     def CompareStartEndLength(self, hyp, args):
4796         if IsEqual(hyp.GetLength(1), args[0]):
4797             if IsEqual(hyp.GetLength(0), args[1]):
4798                 if hyp.GetReversedEdges() == args[2]:
4799                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4800                         return True
4801         return False
4802
4803     ## Defines "Deflection1D" hypothesis
4804     #  @param d for the deflection
4805     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4806     #                     the same parameters, else (default) - create a new one
4807     #  @ingroup l3_hypos_1dhyps
4808     def Deflection1D(self, d, UseExisting=0):
4809         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4810                               CompareMethod=self.CompareDeflection1D)
4811         hyp.SetDeflection(d)
4812         return hyp
4813
4814     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4815     def CompareDeflection1D(self, hyp, args):
4816         return IsEqual(hyp.GetDeflection(), args[0])
4817
4818     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4819     #  the opposite side in case of quadrangular faces
4820     #  @ingroup l3_hypos_additi
4821     def Propagation(self):
4822         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4823
4824     ## Defines "AutomaticLength" hypothesis
4825     #  @param fineness for the fineness [0-1]
4826     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
4827     #                     same parameters, else (default) - create a new one
4828     #  @ingroup l3_hypos_1dhyps
4829     def AutomaticLength(self, fineness=0, UseExisting=0):
4830         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4831                               CompareMethod=self.CompareAutomaticLength)
4832         hyp.SetFineness( fineness )
4833         return hyp
4834
4835     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4836     def CompareAutomaticLength(self, hyp, args):
4837         return IsEqual(hyp.GetFineness(), args[0])
4838
4839     ## Defines "SegmentLengthAroundVertex" hypothesis
4840     #  @param length for the segment length
4841     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
4842     #         Any other integer value means that the hypothesis will be set on the
4843     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
4844     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
4845     #                   the same parameters, else (default) - creates a new one
4846     #  @ingroup l3_algos_segmarv
4847     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4848         import types
4849         store_geom = self.geom
4850         if type(vertex) is types.IntType:
4851             if vertex == 0 or vertex == 1:
4852                 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4853                 self.geom = vertex
4854                 pass
4855             pass
4856         else:
4857             self.geom = vertex
4858             pass
4859         ### 0D algorithm
4860         if self.geom is None:
4861             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4862         self.AssureGeomPublished( self.geom )
4863         name = GetName(self.geom)
4864
4865         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4866         if algo is None:
4867             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4868             pass
4869         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4870         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4871         ###
4872         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4873                               CompareMethod=self.CompareLengthNearVertex)
4874         self.geom = store_geom
4875         hyp.SetLength( length )
4876         return hyp
4877
4878     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4879     #  @ingroup l3_algos_segmarv
4880     def CompareLengthNearVertex(self, hyp, args):
4881         return IsEqual(hyp.GetLength(), args[0])
4882
4883     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4884     #  If the 2D mesher sees that all boundary edges are quadratic,
4885     #  it generates quadratic faces, else it generates linear faces using
4886     #  medium nodes as if they are vertices.
4887     #  The 3D mesher generates quadratic volumes only if all boundary faces
4888     #  are quadratic, else it fails.
4889     #
4890     #  @ingroup l3_hypos_additi
4891     def QuadraticMesh(self):
4892         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4893         return hyp
4894
4895 # Public class: Mesh_CompositeSegment
4896 # --------------------------
4897
4898 ## Defines a segment 1D algorithm for discretization
4899 #
4900 #  @ingroup l3_algos_basic
4901 class Mesh_CompositeSegment(Mesh_Segment):
4902
4903     ## Private constructor.
4904     def __init__(self, mesh, geom=0):
4905         self.Create(mesh, geom, "CompositeSegment_1D")
4906
4907
4908 # Public class: Mesh_Segment_Python
4909 # ---------------------------------
4910
4911 ## Defines a segment 1D algorithm for discretization with python function
4912 #
4913 #  @ingroup l3_algos_basic
4914 class Mesh_Segment_Python(Mesh_Segment):
4915
4916     ## Private constructor.
4917     def __init__(self, mesh, geom=0):
4918         import Python1dPlugin
4919         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4920
4921     ## Defines "PythonSplit1D" hypothesis
4922     #  @param n for the number of segments that cut an edge
4923     #  @param func for the python function that calculates the length of all segments
4924     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4925     #                     the same parameters, else (default) - creates a new one
4926     #  @ingroup l3_hypos_1dhyps
4927     def PythonSplit1D(self, n, func, UseExisting=0):
4928         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4929                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4930         hyp.SetNumberOfSegments(n)
4931         hyp.SetPythonLog10RatioFunction(func)
4932         return hyp
4933
4934     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4935     def ComparePythonSplit1D(self, hyp, args):
4936         #if hyp.GetNumberOfSegments() == args[0]:
4937         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
4938         #        return True
4939         return False
4940
4941 # Public class: Mesh_Triangle
4942 # ---------------------------
4943
4944 ## Defines a triangle 2D algorithm
4945 #
4946 #  @ingroup l3_algos_basic
4947 class Mesh_Triangle(Mesh_Algorithm):
4948
4949     # default values
4950     algoType = 0
4951     params = 0
4952
4953     _angleMeshS = 8
4954     _gradation  = 1.1
4955
4956     ## Private constructor.
4957     def __init__(self, mesh, algoType, geom=0):
4958         Mesh_Algorithm.__init__(self)
4959
4960         self.algoType = algoType
4961         if algoType == MEFISTO:
4962             self.Create(mesh, geom, "MEFISTO_2D")
4963             pass
4964         elif algoType == BLSURF:
4965             CheckPlugin(BLSURF)
4966             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4967             #self.SetPhysicalMesh() - PAL19680
4968         elif algoType == NETGEN:
4969             CheckPlugin(NETGEN)
4970             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4971             pass
4972         elif algoType == NETGEN_2D:
4973             CheckPlugin(NETGEN)
4974             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4975             pass
4976
4977     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4978     #  @param area for the maximum area of each triangle
4979     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
4980     #                     same parameters, else (default) - creates a new one
4981     #
4982     #  Only for algoType == MEFISTO || NETGEN_2D
4983     #  @ingroup l3_hypos_2dhyps
4984     def MaxElementArea(self, area, UseExisting=0):
4985         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4986             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4987                                   CompareMethod=self.CompareMaxElementArea)
4988         elif self.algoType == NETGEN:
4989             hyp = self.Parameters(SIMPLE)
4990         hyp.SetMaxElementArea(area)
4991         return hyp
4992
4993     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4994     def CompareMaxElementArea(self, hyp, args):
4995         return IsEqual(hyp.GetMaxElementArea(), args[0])
4996
4997     ## Defines "LengthFromEdges" hypothesis to build triangles
4998     #  based on the length of the edges taken from the wire
4999     #
5000     #  Only for algoType == MEFISTO || NETGEN_2D
5001     #  @ingroup l3_hypos_2dhyps
5002     def LengthFromEdges(self):
5003         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
5004             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5005             return hyp
5006         elif self.algoType == NETGEN:
5007             hyp = self.Parameters(SIMPLE)
5008             hyp.LengthFromEdges()
5009             return hyp
5010
5011     ## Sets a way to define size of mesh elements to generate.
5012     #  @param thePhysicalMesh is: DefaultSize or Custom.
5013     #  @ingroup l3_hypos_blsurf
5014     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
5015         # Parameter of BLSURF algo
5016         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
5017
5018     ## Sets size of mesh elements to generate.
5019     #  @ingroup l3_hypos_blsurf
5020     def SetPhySize(self, theVal):
5021         # Parameter of BLSURF algo
5022         self.SetPhysicalMesh(1) #Custom - else why to set the size?
5023         self.Parameters().SetPhySize(theVal)
5024
5025     ## Sets lower boundary of mesh element size (PhySize).
5026     #  @ingroup l3_hypos_blsurf
5027     def SetPhyMin(self, theVal=-1):
5028         #  Parameter of BLSURF algo
5029         self.Parameters().SetPhyMin(theVal)
5030
5031     ## Sets upper boundary of mesh element size (PhySize).
5032     #  @ingroup l3_hypos_blsurf
5033     def SetPhyMax(self, theVal=-1):
5034         #  Parameter of BLSURF algo
5035         self.Parameters().SetPhyMax(theVal)
5036
5037     ## Sets a way to define maximum angular deflection of mesh from CAD model.
5038     #  @param theGeometricMesh is: 0 (None) or 1 (Custom)
5039     #  @ingroup l3_hypos_blsurf
5040     def SetGeometricMesh(self, theGeometricMesh=0):
5041         #  Parameter of BLSURF algo
5042         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
5043         self.params.SetGeometricMesh(theGeometricMesh)
5044
5045     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
5046     #  @ingroup l3_hypos_blsurf
5047     def SetAngleMeshS(self, theVal=_angleMeshS):
5048         #  Parameter of BLSURF algo
5049         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
5050         self.params.SetAngleMeshS(theVal)
5051
5052     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
5053     #  @ingroup l3_hypos_blsurf
5054     def SetAngleMeshC(self, theVal=_angleMeshS):
5055         #  Parameter of BLSURF algo
5056         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
5057         self.params.SetAngleMeshC(theVal)
5058
5059     ## Sets lower boundary of mesh element size computed to respect angular deflection.
5060     #  @ingroup l3_hypos_blsurf
5061     def SetGeoMin(self, theVal=-1):
5062         #  Parameter of BLSURF algo
5063         self.Parameters().SetGeoMin(theVal)
5064
5065     ## Sets upper boundary of mesh element size computed to respect angular deflection.
5066     #  @ingroup l3_hypos_blsurf
5067     def SetGeoMax(self, theVal=-1):
5068         #  Parameter of BLSURF algo
5069         self.Parameters().SetGeoMax(theVal)
5070
5071     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
5072     #  @ingroup l3_hypos_blsurf
5073     def SetGradation(self, theVal=_gradation):
5074         #  Parameter of BLSURF algo
5075         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
5076         self.params.SetGradation(theVal)
5077
5078     ## Sets topology usage way.
5079     # @param way defines how mesh conformity is assured <ul>
5080     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
5081     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
5082     #  @ingroup l3_hypos_blsurf
5083     def SetTopology(self, way):
5084         #  Parameter of BLSURF algo
5085         self.Parameters().SetTopology(way)
5086
5087     ## To respect geometrical edges or not.
5088     #  @ingroup l3_hypos_blsurf
5089     def SetDecimesh(self, toIgnoreEdges=False):
5090         #  Parameter of BLSURF algo
5091         self.Parameters().SetDecimesh(toIgnoreEdges)
5092
5093     ## Sets verbosity level in the range 0 to 100.
5094     #  @ingroup l3_hypos_blsurf
5095     def SetVerbosity(self, level):
5096         #  Parameter of BLSURF algo
5097         self.Parameters().SetVerbosity(level)
5098
5099     ## Sets advanced option value.
5100     #  @ingroup l3_hypos_blsurf
5101     def SetOptionValue(self, optionName, level):
5102         #  Parameter of BLSURF algo
5103         self.Parameters().SetOptionValue(optionName,level)
5104
5105     ## 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 ] 
5106     #  @param theFace      : face on which the attractor will be defined
5107     #  @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially   
5108     #  @param theStartSize : mesh size on theAttractor      
5109     #  @param theEndSize   : maximum size that will be reached on theFace                                                     
5110     #  @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)                                                      
5111     #  @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace                                                      
5112     #  @ingroup l3_hypos_blsurf
5113     def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
5114         self.AssureGeomPublished( theFace )
5115         self.AssureGeomPublished( theAttractor )
5116         #  Parameter of BLSURF algo
5117         self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
5118         
5119     ## Unsets an attractor on the chosen face. 
5120     #  @param theFace      : face on which the attractor has to be removed                               
5121     #  @ingroup l3_hypos_blsurf
5122     def UnsetAttractorGeom(self, theFace):
5123         self.AssureGeomPublished( theFace )
5124         #  Parameter of BLSURF algo
5125         self.Parameters().SetAttractorGeom(theFace)
5126
5127     ## Sets QuadAllowed flag.
5128     #  Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5129     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
5130     def SetQuadAllowed(self, toAllow=True):
5131         if self.algoType == NETGEN_2D:
5132             if not self.params:
5133                 # use simple hyps
5134                 hasSimpleHyps = False
5135                 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5136                 for hyp in self.mesh.GetHypothesisList( self.geom ):
5137                     if hyp.GetName() in simpleHyps:
5138                         hasSimpleHyps = True
5139                         if hyp.GetName() == "QuadranglePreference":
5140                             if not toAllow: # remove QuadranglePreference
5141                                 self.mesh.RemoveHypothesis( self.geom, hyp )
5142                                 pass
5143                             return
5144                         pass
5145                     pass
5146                 if hasSimpleHyps:
5147                     if toAllow: # add QuadranglePreference
5148                         self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5149                         pass
5150                     return
5151                 pass
5152             pass
5153         if self.Parameters():
5154             self.params.SetQuadAllowed(toAllow)
5155             return
5156
5157     ## Defines hypothesis having several parameters
5158     #
5159     #  @ingroup l3_hypos_netgen
5160     def Parameters(self, which=SOLE):
5161         if not self.params:
5162             if self.algoType == NETGEN:
5163                 if which == SIMPLE:
5164                     self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5165                                                   "libNETGENEngine.so", UseExisting=0)
5166                 else:
5167                     self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5168                                                   "libNETGENEngine.so", UseExisting=0)
5169             elif self.algoType == MEFISTO:
5170                 print "Mefisto algo support no multi-parameter hypothesis"
5171             elif self.algoType == NETGEN_2D:
5172                 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5173                                               "libNETGENEngine.so", UseExisting=0)
5174             elif self.algoType == BLSURF:
5175                 self.params = self.Hypothesis("BLSURF_Parameters", [],
5176                                               "libBLSURFEngine.so", UseExisting=0)
5177             else:
5178                 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5179         return self.params
5180
5181     ## Sets MaxSize
5182     #
5183     #  Only for algoType == NETGEN
5184     #  @ingroup l3_hypos_netgen
5185     def SetMaxSize(self, theSize):
5186         if self.Parameters():
5187             self.params.SetMaxSize(theSize)
5188
5189     ## Sets SecondOrder flag
5190     #
5191     #  Only for algoType == NETGEN
5192     #  @ingroup l3_hypos_netgen
5193     def SetSecondOrder(self, theVal):
5194         if self.Parameters():
5195             self.params.SetSecondOrder(theVal)
5196
5197     ## Sets Optimize flag
5198     #
5199     #  Only for algoType == NETGEN
5200     #  @ingroup l3_hypos_netgen
5201     def SetOptimize(self, theVal):
5202         if self.Parameters():
5203             self.params.SetOptimize(theVal)
5204
5205     ## Sets Fineness
5206     #  @param theFineness is:
5207     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5208     #
5209     #  Only for algoType == NETGEN
5210     #  @ingroup l3_hypos_netgen
5211     def SetFineness(self, theFineness):
5212         if self.Parameters():
5213             self.params.SetFineness(theFineness)
5214
5215     ## Sets GrowthRate
5216     #
5217     #  Only for algoType == NETGEN
5218     #  @ingroup l3_hypos_netgen
5219     def SetGrowthRate(self, theRate):
5220         if self.Parameters():
5221             self.params.SetGrowthRate(theRate)
5222
5223     ## Sets NbSegPerEdge
5224     #
5225     #  Only for algoType == NETGEN
5226     #  @ingroup l3_hypos_netgen
5227     def SetNbSegPerEdge(self, theVal):
5228         if self.Parameters():
5229             self.params.SetNbSegPerEdge(theVal)
5230
5231     ## Sets NbSegPerRadius
5232     #
5233     #  Only for algoType == NETGEN
5234     #  @ingroup l3_hypos_netgen
5235     def SetNbSegPerRadius(self, theVal):
5236         if self.Parameters():
5237             self.params.SetNbSegPerRadius(theVal)
5238
5239     ## Sets number of segments overriding value set by SetLocalLength()
5240     #
5241     #  Only for algoType == NETGEN
5242     #  @ingroup l3_hypos_netgen
5243     def SetNumberOfSegments(self, theVal):
5244         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5245
5246     ## Sets number of segments overriding value set by SetNumberOfSegments()
5247     #
5248     #  Only for algoType == NETGEN
5249     #  @ingroup l3_hypos_netgen
5250     def SetLocalLength(self, theVal):
5251         self.Parameters(SIMPLE).SetLocalLength(theVal)
5252
5253     pass
5254
5255
5256 # Public class: Mesh_Quadrangle
5257 # -----------------------------
5258
5259 ## Defines a quadrangle 2D algorithm
5260 #
5261 #  @ingroup l3_algos_basic
5262 class Mesh_Quadrangle(Mesh_Algorithm):
5263
5264     params=0
5265
5266     ## Private constructor.
5267     def __init__(self, mesh, geom=0):
5268         Mesh_Algorithm.__init__(self)
5269         self.Create(mesh, geom, "Quadrangle_2D")
5270         return
5271
5272     ## Defines "QuadrangleParameters" hypothesis
5273     #  @param quadType defines the algorithm of transition between differently descretized
5274     #                  sides of a geometrical face:
5275     #  - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5276     #                    area along the finer meshed sides.
5277     #  - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5278     #                    finer meshed sides.
5279     #  - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5280     #                    the finer meshed sides, iff the total quantity of segments on
5281     #                    all four sides of the face is even (divisible by 2).
5282     #  - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5283     #                    area is located along the coarser meshed sides.
5284     #  - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5285     #                    is made gradually, layer by layer. This type has a limitation on
5286     #                    the number of segments: one pair of opposite sides must have the
5287     #                    same number of segments, the other pair must have an even difference
5288     #                    between the numbers of segments on the sides.
5289     #  @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5290     #                  will be created while other elements will be quadrangles.
5291     #                  Vertex can be either a GEOM_Object or a vertex ID within the
5292     #                  shape to mesh
5293     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
5294     #                  the same parameters, else (default) - creates a new one
5295     #  @ingroup l3_hypos_quad
5296     def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5297         vertexID = triangleVertex
5298         if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5299             vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5300         if not self.params:
5301             compFun = lambda hyp,args: \
5302                       hyp.GetQuadType() == args[0] and \
5303                       ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5304             self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5305                                           UseExisting = UseExisting, CompareMethod=compFun)
5306             pass
5307         if self.params.GetQuadType() != quadType:
5308             self.params.SetQuadType(quadType)
5309         if vertexID > 0:
5310             self.params.SetTriaVertex( vertexID )
5311         return self.params
5312
5313     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5314     #   quadrangles are built in the transition area along the finer meshed sides,
5315     #   iff the total quantity of segments on all four sides of the face is even.
5316     #  @param reversed if True, transition area is located along the coarser meshed sides.
5317     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
5318     #                  the same parameters, else (default) - creates a new one
5319     #  @ingroup l3_hypos_quad
5320     def QuadranglePreference(self, reversed=False, UseExisting=0):
5321         if reversed:
5322             return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5323         return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5324
5325     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5326     #   triangles are built in the transition area along the finer meshed sides.
5327     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
5328     #                  the same parameters, else (default) - creates a new one
5329     #  @ingroup l3_hypos_quad
5330     def TrianglePreference(self, UseExisting=0):
5331         return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5332
5333     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5334     #   quadrangles are built and the transition between the sides is made gradually,
5335     #   layer by layer. This type has a limitation on the number of segments: one pair
5336     #   of opposite sides must have the same number of segments, the other pair must
5337     #   have an even difference between the numbers of segments on the sides.
5338     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
5339     #                  the same parameters, else (default) - creates a new one
5340     #  @ingroup l3_hypos_quad
5341     def Reduced(self, UseExisting=0):
5342         return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5343
5344     ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5345     #  @param vertex: vertex of a trilateral geometrical face, around which triangles
5346     #                 will be created while other elements will be quadrangles.
5347     #                 Vertex can be either a GEOM_Object or a vertex ID within the
5348     #                 shape to mesh
5349     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
5350     #                   the same parameters, else (default) - creates a new one
5351     #  @ingroup l3_hypos_quad
5352     def TriangleVertex(self, vertex, UseExisting=0):
5353         return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5354
5355
5356 # Public class: Mesh_Tetrahedron
5357 # ------------------------------
5358
5359 ## Defines a tetrahedron 3D algorithm
5360 #
5361 #  @ingroup l3_algos_basic
5362 class Mesh_Tetrahedron(Mesh_Algorithm):
5363
5364     params = 0
5365     algoType = 0
5366
5367     ## Private constructor.
5368     def __init__(self, mesh, algoType, geom=0):
5369         Mesh_Algorithm.__init__(self)
5370
5371         if algoType == NETGEN:
5372             CheckPlugin(NETGEN)
5373             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5374             pass
5375
5376         elif algoType == FULL_NETGEN:
5377             CheckPlugin(NETGEN)
5378             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5379             pass
5380
5381         elif algoType == GHS3D:
5382             CheckPlugin(GHS3D)
5383             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5384             pass
5385
5386         elif algoType == GHS3DPRL:
5387             CheckPlugin(GHS3DPRL)
5388             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5389             pass
5390
5391         self.algoType = algoType
5392
5393     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5394     #  @param vol for the maximum volume of each tetrahedron
5395     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5396     #                   the same parameters, else (default) - creates a new one
5397     #  @ingroup l3_hypos_maxvol
5398     def MaxElementVolume(self, vol, UseExisting=0):
5399         if self.algoType == NETGEN:
5400             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5401                                   CompareMethod=self.CompareMaxElementVolume)
5402             hyp.SetMaxElementVolume(vol)
5403             return hyp
5404         elif self.algoType == FULL_NETGEN:
5405             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5406         return None
5407
5408     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5409     def CompareMaxElementVolume(self, hyp, args):
5410         return IsEqual(hyp.GetMaxElementVolume(), args[0])
5411
5412     ## Defines hypothesis having several parameters
5413     #
5414     #  @ingroup l3_hypos_netgen
5415     def Parameters(self, which=SOLE):
5416         if not self.params:
5417
5418             if self.algoType == FULL_NETGEN:
5419                 if which == SIMPLE:
5420                     self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5421                                                   "libNETGENEngine.so", UseExisting=0)
5422                 else:
5423                     self.params = self.Hypothesis("NETGEN_Parameters", [],
5424                                                   "libNETGENEngine.so", UseExisting=0)
5425
5426             elif self.algoType == NETGEN:
5427                 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5428                                               "libNETGENEngine.so", UseExisting=0)
5429
5430             elif self.algoType == GHS3D:
5431                 self.params = self.Hypothesis("GHS3D_Parameters", [],
5432                                               "libGHS3DEngine.so", UseExisting=0)
5433
5434             elif self.algoType == GHS3DPRL:
5435                 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5436                                               "libGHS3DPRLEngine.so", UseExisting=0)
5437             else:
5438                 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5439
5440         return self.params
5441
5442     ## Sets MaxSize
5443     #  Parameter of FULL_NETGEN and NETGEN
5444     #  @ingroup l3_hypos_netgen
5445     def SetMaxSize(self, theSize):
5446         self.Parameters().SetMaxSize(theSize)
5447
5448     ## Sets SecondOrder flag
5449     #  Parameter of FULL_NETGEN
5450     #  @ingroup l3_hypos_netgen
5451     def SetSecondOrder(self, theVal):
5452         self.Parameters().SetSecondOrder(theVal)
5453
5454     ## Sets Optimize flag
5455     #  Parameter of FULL_NETGEN and NETGEN
5456     #  @ingroup l3_hypos_netgen
5457     def SetOptimize(self, theVal):
5458         self.Parameters().SetOptimize(theVal)
5459
5460     ## Sets Fineness
5461     #  @param theFineness is:
5462     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5463     #  Parameter of FULL_NETGEN
5464     #  @ingroup l3_hypos_netgen
5465     def SetFineness(self, theFineness):
5466         self.Parameters().SetFineness(theFineness)
5467
5468     ## Sets GrowthRate
5469     #  Parameter of FULL_NETGEN
5470     #  @ingroup l3_hypos_netgen
5471     def SetGrowthRate(self, theRate):
5472         self.Parameters().SetGrowthRate(theRate)
5473
5474     ## Sets NbSegPerEdge
5475     #  Parameter of FULL_NETGEN
5476     #  @ingroup l3_hypos_netgen
5477     def SetNbSegPerEdge(self, theVal):
5478         self.Parameters().SetNbSegPerEdge(theVal)
5479
5480     ## Sets NbSegPerRadius
5481     #  Parameter of FULL_NETGEN
5482     #  @ingroup l3_hypos_netgen
5483     def SetNbSegPerRadius(self, theVal):
5484         self.Parameters().SetNbSegPerRadius(theVal)
5485
5486     ## Sets number of segments overriding value set by SetLocalLength()
5487     #  Only for algoType == NETGEN_FULL
5488     #  @ingroup l3_hypos_netgen
5489     def SetNumberOfSegments(self, theVal):
5490         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5491
5492     ## Sets number of segments overriding value set by SetNumberOfSegments()
5493     #  Only for algoType == NETGEN_FULL
5494     #  @ingroup l3_hypos_netgen
5495     def SetLocalLength(self, theVal):
5496         self.Parameters(SIMPLE).SetLocalLength(theVal)
5497
5498     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5499     #  Overrides value set by LengthFromEdges()
5500     #  Only for algoType == NETGEN_FULL
5501     #  @ingroup l3_hypos_netgen
5502     def MaxElementArea(self, area):
5503         self.Parameters(SIMPLE).SetMaxElementArea(area)
5504
5505     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5506     #  Overrides value set by MaxElementArea()
5507     #  Only for algoType == NETGEN_FULL
5508     #  @ingroup l3_hypos_netgen
5509     def LengthFromEdges(self):
5510         self.Parameters(SIMPLE).LengthFromEdges()
5511
5512     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5513     #  Overrides value set by MaxElementVolume()
5514     #  Only for algoType == NETGEN_FULL
5515     #  @ingroup l3_hypos_netgen
5516     def LengthFromFaces(self):
5517         self.Parameters(SIMPLE).LengthFromFaces()
5518
5519     ## To mesh "holes" in a solid or not. Default is to mesh.
5520     #  @ingroup l3_hypos_ghs3dh
5521     def SetToMeshHoles(self, toMesh):
5522         #  Parameter of GHS3D
5523         self.Parameters().SetToMeshHoles(toMesh)
5524
5525     ## Set Optimization level:
5526     #   None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5527     #   Strong_Optimization.
5528     # Default is Standard_Optimization
5529     #  @ingroup l3_hypos_ghs3dh
5530     def SetOptimizationLevel(self, level):
5531         #  Parameter of GHS3D
5532         self.Parameters().SetOptimizationLevel(level)
5533
5534     ## Maximal size of memory to be used by the algorithm (in Megabytes).
5535     #  @ingroup l3_hypos_ghs3dh
5536     def SetMaximumMemory(self, MB):
5537         #  Advanced parameter of GHS3D
5538         self.Parameters().SetMaximumMemory(MB)
5539
5540     ## Initial size of memory to be used by the algorithm (in Megabytes) in
5541     #  automatic memory adjustment mode.
5542     #  @ingroup l3_hypos_ghs3dh
5543     def SetInitialMemory(self, MB):
5544         #  Advanced parameter of GHS3D
5545         self.Parameters().SetInitialMemory(MB)
5546
5547     ## Path to working directory.
5548     #  @ingroup l3_hypos_ghs3dh
5549     def SetWorkingDirectory(self, path):
5550         #  Advanced parameter of GHS3D
5551         self.Parameters().SetWorkingDirectory(path)
5552
5553     ## To keep working files or remove them. Log file remains in case of errors anyway.
5554     #  @ingroup l3_hypos_ghs3dh
5555     def SetKeepFiles(self, toKeep):
5556         #  Advanced parameter of GHS3D and GHS3DPRL
5557         self.Parameters().SetKeepFiles(toKeep)
5558
5559     ## To set verbose level [0-10]. <ul>
5560     #<li> 0 - no standard output,
5561     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5562     #     indicates when the final mesh is being saved. In addition the software
5563     #     gives indication regarding the CPU time.
5564     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5565     #     histogram of the skin mesh, quality statistics histogram together with
5566     #     the characteristics of the final mesh.</ul>
5567     #  @ingroup l3_hypos_ghs3dh
5568     def SetVerboseLevel(self, level):
5569         #  Advanced parameter of GHS3D
5570         self.Parameters().SetVerboseLevel(level)
5571
5572     ## To create new nodes.
5573     #  @ingroup l3_hypos_ghs3dh
5574     def SetToCreateNewNodes(self, toCreate):
5575         #  Advanced parameter of GHS3D
5576         self.Parameters().SetToCreateNewNodes(toCreate)
5577
5578     ## To use boundary recovery version which tries to create mesh on a very poor
5579     #  quality surface mesh.
5580     #  @ingroup l3_hypos_ghs3dh
5581     def SetToUseBoundaryRecoveryVersion(self, toUse):
5582         #  Advanced parameter of GHS3D
5583         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5584
5585     ## Applies finite-element correction by replacing overconstrained elements where
5586     #  it is possible. The process is cutting first the overconstrained edges and
5587     #  second the overconstrained facets. This insure that no edges have two boundary
5588     #  vertices and that no facets have three boundary vertices.
5589     #  @ingroup l3_hypos_ghs3dh
5590     def SetFEMCorrection(self, toUseFem):
5591         #  Advanced parameter of GHS3D
5592         self.Parameters().SetFEMCorrection(toUseFem)
5593
5594     ## To removes initial central point.
5595     #  @ingroup l3_hypos_ghs3dh
5596     def SetToRemoveCentralPoint(self, toRemove):
5597         #  Advanced parameter of GHS3D
5598         self.Parameters().SetToRemoveCentralPoint(toRemove)
5599
5600     ## To set an enforced vertex.
5601     #  @ingroup l3_hypos_ghs3dh
5602     def SetEnforcedVertex(self, x, y, z, size):
5603         #  Advanced parameter of GHS3D
5604         return self.Parameters().SetEnforcedVertex(x, y, z, size)
5605
5606     ## To set an enforced vertex and add it in the group "groupName".
5607     #  Only on meshes w/o geometry
5608     #  @ingroup l3_hypos_ghs3dh
5609     def SetEnforcedVertexWithGroup(self, x, y, z, size, groupName):
5610         #  Advanced parameter of GHS3D
5611         return self.Parameters().SetEnforcedVertex(x, y, z, size,groupName)
5612
5613     ## To remove an enforced vertex.
5614     #  @ingroup l3_hypos_ghs3dh
5615     def RemoveEnforcedVertex(self, x, y, z):
5616         #  Advanced parameter of GHS3D
5617         return self.Parameters().RemoveEnforcedVertex(x, y, z)
5618
5619     ## To set an enforced vertex given a GEOM vertex, group or compound.
5620     #  @ingroup l3_hypos_ghs3dh
5621     def SetEnforcedVertexGeom(self, theVertex, size):
5622         self.AssureGeomPublished( theVertex )
5623         #  Advanced parameter of GHS3D
5624         return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
5625
5626     ## To set an enforced vertex given a GEOM vertex, group or compound
5627     #  and add it in the group "groupName".
5628     #  Only on meshes w/o geometry
5629     #  @ingroup l3_hypos_ghs3dh
5630     def SetEnforcedVertexGeomWithGroup(self, theVertex, size, groupName):
5631         self.AssureGeomPublished( theVertex )
5632         #  Advanced parameter of GHS3D
5633         return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size,groupName)
5634
5635     ## To remove an enforced vertex given a GEOM vertex, group or compound.
5636     #  @ingroup l3_hypos_ghs3dh
5637     def RemoveEnforcedVertexGeom(self, theVertex):
5638         self.AssureGeomPublished( theVertex )
5639         #  Advanced parameter of GHS3D
5640         return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
5641
5642     ## To set an enforced mesh.
5643     #  @ingroup l3_hypos_ghs3dh
5644     def SetEnforcedMesh(self, theSource, elementType):
5645         #  Advanced parameter of GHS3D
5646         return self.Parameters().SetEnforcedMesh(theSource, elementType)
5647
5648     ## To set an enforced mesh and add the enforced elements in the group "groupName".
5649     #  @ingroup l3_hypos_ghs3dh
5650     def SetEnforcedMeshWithGroup(self, theSource, elementType, groupName):
5651         #  Advanced parameter of GHS3D
5652         return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
5653
5654     ## To set an enforced mesh with given size.
5655     #  @ingroup l3_hypos_ghs3dh
5656     def SetEnforcedMeshSize(self, theSource, elementType, size):
5657         #  Advanced parameter of GHS3D
5658         return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
5659
5660     ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
5661     #  @ingroup l3_hypos_ghs3dh
5662     def SetEnforcedMeshSizeWithGroup(self, theSource, elementType, size, groupName):
5663         #  Advanced parameter of GHS3D
5664         return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
5665
5666     ## Sets command line option as text.
5667     #  @ingroup l3_hypos_ghs3dh
5668     def SetTextOption(self, option):
5669         #  Advanced parameter of GHS3D
5670         self.Parameters().SetTextOption(option)
5671
5672     ## Sets MED files name and path.
5673     def SetMEDName(self, value):
5674         self.Parameters().SetMEDName(value)
5675
5676     ## Sets the number of partition of the initial mesh
5677     def SetNbPart(self, value):
5678         self.Parameters().SetNbPart(value)
5679
5680     ## When big mesh, start tepal in background
5681     def SetBackground(self, value):
5682         self.Parameters().SetBackground(value)
5683
5684 # Public class: Mesh_Hexahedron
5685 # ------------------------------
5686
5687 ## Defines a hexahedron 3D algorithm
5688 #
5689 #  @ingroup l3_algos_basic
5690 class Mesh_Hexahedron(Mesh_Algorithm):
5691
5692     params = 0
5693     algoType = 0
5694
5695     ## Private constructor.
5696     def __init__(self, mesh, algoType=Hexa, geom=0):
5697         Mesh_Algorithm.__init__(self)
5698
5699         self.algoType = algoType
5700
5701         if algoType == Hexa:
5702             self.Create(mesh, geom, "Hexa_3D")
5703             pass
5704
5705         elif algoType == Hexotic:
5706             CheckPlugin(Hexotic)
5707             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5708             pass
5709
5710     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5711     #  @ingroup l3_hypos_hexotic
5712     def MinMaxQuad(self, min=3, max=8, quad=True):
5713         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5714                                       UseExisting=0)
5715         self.params.SetHexesMinLevel(min)
5716         self.params.SetHexesMaxLevel(max)
5717         self.params.SetHexoticQuadrangles(quad)
5718         return self.params
5719
5720 # Deprecated, only for compatibility!
5721 # Public class: Mesh_Netgen
5722 # ------------------------------
5723
5724 ## Defines a NETGEN-based 2D or 3D algorithm
5725 #  that needs no discrete boundary (i.e. independent)
5726 #
5727 #  This class is deprecated, only for compatibility!
5728 #
5729 #  More details.
5730 #  @ingroup l3_algos_basic
5731 class Mesh_Netgen(Mesh_Algorithm):
5732
5733     is3D = 0
5734
5735     ## Private constructor.
5736     def __init__(self, mesh, is3D, geom=0):
5737         Mesh_Algorithm.__init__(self)
5738
5739         CheckPlugin(NETGEN)
5740
5741         self.is3D = is3D
5742         if is3D:
5743             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5744             pass
5745
5746         else:
5747             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5748             pass
5749
5750     ## Defines the hypothesis containing parameters of the algorithm
5751     def Parameters(self):
5752         if self.is3D:
5753             hyp = self.Hypothesis("NETGEN_Parameters", [],
5754                                   "libNETGENEngine.so", UseExisting=0)
5755         else:
5756             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5757                                   "libNETGENEngine.so", UseExisting=0)
5758         return hyp
5759
5760 # Public class: Mesh_Projection1D
5761 # ------------------------------
5762
5763 ## Defines a projection 1D algorithm
5764 #  @ingroup l3_algos_proj
5765 #
5766 class Mesh_Projection1D(Mesh_Algorithm):
5767
5768     ## Private constructor.
5769     def __init__(self, mesh, geom=0):
5770         Mesh_Algorithm.__init__(self)
5771         self.Create(mesh, geom, "Projection_1D")
5772
5773     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5774     #  a mesh pattern is taken, and, optionally, the association of vertices
5775     #  between the source edge and a target edge (to which a hypothesis is assigned)
5776     #  @param edge from which nodes distribution is taken
5777     #  @param mesh from which nodes distribution is taken (optional)
5778     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5779     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5780     #  to associate with \a srcV (optional)
5781     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5782     #                     the same parameters, else (default) - creates a new one
5783     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5784         self.AssureGeomPublished( edge )
5785         self.AssureGeomPublished( srcV )
5786         self.AssureGeomPublished( tgtV )
5787         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5788                               UseExisting=0)
5789                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5790         hyp.SetSourceEdge( edge )
5791         if not mesh is None and isinstance(mesh, Mesh):
5792             mesh = mesh.GetMesh()
5793         hyp.SetSourceMesh( mesh )
5794         hyp.SetVertexAssociation( srcV, tgtV )
5795         return hyp
5796
5797     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5798     #def CompareSourceEdge(self, hyp, args):
5799     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5800     #    return False
5801
5802
5803 # Public class: Mesh_Projection2D
5804 # ------------------------------
5805
5806 ## Defines a projection 2D algorithm
5807 #  @ingroup l3_algos_proj
5808 #
5809 class Mesh_Projection2D(Mesh_Algorithm):
5810
5811     ## Private constructor.
5812     def __init__(self, mesh, geom=0):
5813         Mesh_Algorithm.__init__(self)
5814         self.Create(mesh, geom, "Projection_2D")
5815
5816     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5817     #  a mesh pattern is taken, and, optionally, the association of vertices
5818     #  between the source face and the target face (to which a hypothesis is assigned)
5819     #  @param face from which the mesh pattern is taken
5820     #  @param mesh from which the mesh pattern is taken (optional)
5821     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5822     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5823     #               to associate with \a srcV1 (optional)
5824     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5825     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5826     #               to associate with \a srcV2 (optional)
5827     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
5828     #                     the same parameters, else (default) - forces the creation a new one
5829     #
5830     #  Note: all association vertices must belong to one edge of a face
5831     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5832                    srcV2=None, tgtV2=None, UseExisting=0):
5833         for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
5834             self.AssureGeomPublished( geom )
5835         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5836                               UseExisting=0)
5837                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5838         hyp.SetSourceFace( face )
5839         if isinstance(mesh, Mesh):
5840             mesh = mesh.GetMesh()
5841         hyp.SetSourceMesh( mesh )
5842         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5843         return hyp
5844
5845     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5846     #def CompareSourceFace(self, hyp, args):
5847     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5848     #    return False
5849
5850 # Public class: Mesh_Projection3D
5851 # ------------------------------
5852
5853 ## Defines a projection 3D algorithm
5854 #  @ingroup l3_algos_proj
5855 #
5856 class Mesh_Projection3D(Mesh_Algorithm):
5857
5858     ## Private constructor.
5859     def __init__(self, mesh, geom=0):
5860         Mesh_Algorithm.__init__(self)
5861         self.Create(mesh, geom, "Projection_3D")
5862
5863     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5864     #  the mesh pattern is taken, and, optionally, the  association of vertices
5865     #  between the source and the target solid  (to which a hipothesis is assigned)
5866     #  @param solid from where the mesh pattern is taken
5867     #  @param mesh from where the mesh pattern is taken (optional)
5868     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5869     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5870     #  to associate with \a srcV1 (optional)
5871     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5872     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5873     #  to associate with \a srcV2 (optional)
5874     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
5875     #                     the same parameters, else (default) - creates a new one
5876     #
5877     #  Note: association vertices must belong to one edge of a solid
5878     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5879                       srcV2=0, tgtV2=0, UseExisting=0):
5880         for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
5881             self.AssureGeomPublished( geom )
5882         hyp = self.Hypothesis("ProjectionSource3D",
5883                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5884                               UseExisting=0)
5885                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5886         hyp.SetSource3DShape( solid )
5887         if not mesh is None and isinstance(mesh, Mesh):
5888             mesh = mesh.GetMesh()
5889         hyp.SetSourceMesh( mesh )
5890         if srcV1 and srcV2 and tgtV1 and tgtV2:
5891             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5892         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5893         return hyp
5894
5895     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5896     #def CompareSourceShape3D(self, hyp, args):
5897     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5898     #    return False
5899
5900
5901 # Public class: Mesh_Prism
5902 # ------------------------
5903
5904 ## Defines a 3D extrusion algorithm
5905 #  @ingroup l3_algos_3dextr
5906 #
5907 class Mesh_Prism3D(Mesh_Algorithm):
5908
5909     ## Private constructor.
5910     def __init__(self, mesh, geom=0):
5911         Mesh_Algorithm.__init__(self)
5912         self.Create(mesh, geom, "Prism_3D")
5913
5914 # Public class: Mesh_RadialPrism
5915 # -------------------------------
5916
5917 ## Defines a Radial Prism 3D algorithm
5918 #  @ingroup l3_algos_radialp
5919 #
5920 class Mesh_RadialPrism3D(Mesh_Algorithm):
5921
5922     ## Private constructor.
5923     def __init__(self, mesh, geom=0):
5924         Mesh_Algorithm.__init__(self)
5925         self.Create(mesh, geom, "RadialPrism_3D")
5926
5927         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5928         self.nbLayers = None
5929
5930     ## Return 3D hypothesis holding the 1D one
5931     def Get3DHypothesis(self):
5932         return self.distribHyp
5933
5934     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5935     #  hypothesis. Returns the created hypothesis
5936     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5937         #print "OwnHypothesis",hypType
5938         if not self.nbLayers is None:
5939             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5940             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5941         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5942         self.mesh.smeshpyD.SetCurrentStudy( None )
5943         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5944         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5945         self.distribHyp.SetLayerDistribution( hyp )
5946         return hyp
5947
5948     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5949     #  prisms to build between the inner and outer shells
5950     #  @param n number of layers
5951     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5952     #                     the same parameters, else (default) - creates a new one
5953     def NumberOfLayers(self, n, UseExisting=0):
5954         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5955         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5956                                         CompareMethod=self.CompareNumberOfLayers)
5957         self.nbLayers.SetNumberOfLayers( n )
5958         return self.nbLayers
5959
5960     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5961     def CompareNumberOfLayers(self, hyp, args):
5962         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5963
5964     ## Defines "LocalLength" hypothesis, specifying the segment length
5965     #  to build between the inner and the outer shells
5966     #  @param l the length of segments
5967     #  @param p the precision of rounding
5968     def LocalLength(self, l, p=1e-07):
5969         hyp = self.OwnHypothesis("LocalLength", [l,p])
5970         hyp.SetLength(l)
5971         hyp.SetPrecision(p)
5972         return hyp
5973
5974     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5975     #  prisms to build between the inner and the outer shells.
5976     #  @param n the number of layers
5977     #  @param s the scale factor (optional)
5978     def NumberOfSegments(self, n, s=[]):
5979         if s == []:
5980             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5981         else:
5982             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5983             hyp.SetDistrType( 1 )
5984             hyp.SetScaleFactor(s)
5985         hyp.SetNumberOfSegments(n)
5986         return hyp
5987
5988     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5989     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
5990     #  @param start  the length of the first segment
5991     #  @param end    the length of the last  segment
5992     def Arithmetic1D(self, start, end ):
5993         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5994         hyp.SetLength(start, 1)
5995         hyp.SetLength(end  , 0)
5996         return hyp
5997
5998     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5999     #  to build between the inner and the outer shells as geometric length increasing
6000     #  @param start for the length of the first segment
6001     #  @param end   for the length of the last  segment
6002     def StartEndLength(self, start, end):
6003         hyp = self.OwnHypothesis("StartEndLength", [start, end])
6004         hyp.SetLength(start, 1)
6005         hyp.SetLength(end  , 0)
6006         return hyp
6007
6008     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6009     #  to build between the inner and outer shells
6010     #  @param fineness defines the quality of the mesh within the range [0-1]
6011     def AutomaticLength(self, fineness=0):
6012         hyp = self.OwnHypothesis("AutomaticLength")
6013         hyp.SetFineness( fineness )
6014         return hyp
6015
6016 # Public class: Mesh_RadialQuadrangle1D2D
6017 # -------------------------------
6018
6019 ## Defines a Radial Quadrangle 1D2D algorithm
6020 #  @ingroup l2_algos_radialq
6021 #
6022 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
6023
6024     ## Private constructor.
6025     def __init__(self, mesh, geom=0):
6026         Mesh_Algorithm.__init__(self)
6027         self.Create(mesh, geom, "RadialQuadrangle_1D2D")
6028
6029         self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
6030         self.nbLayers = None
6031
6032     ## Return 2D hypothesis holding the 1D one
6033     def Get2DHypothesis(self):
6034         return self.distribHyp
6035
6036     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
6037     #  hypothesis. Returns the created hypothesis
6038     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
6039         #print "OwnHypothesis",hypType
6040         if self.nbLayers:
6041             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
6042         if self.distribHyp is None:
6043             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
6044         else:
6045             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
6046         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
6047         self.mesh.smeshpyD.SetCurrentStudy( None )
6048         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
6049         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
6050         self.distribHyp.SetLayerDistribution( hyp )
6051         return hyp
6052
6053     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
6054     #  @param n number of layers
6055     #  @param UseExisting if ==true - searches for the existing hypothesis created with
6056     #                     the same parameters, else (default) - creates a new one
6057     def NumberOfLayers(self, n, UseExisting=0):
6058         if self.distribHyp:
6059             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
6060         self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
6061                                         CompareMethod=self.CompareNumberOfLayers)
6062         self.nbLayers.SetNumberOfLayers( n )
6063         return self.nbLayers
6064
6065     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
6066     def CompareNumberOfLayers(self, hyp, args):
6067         return IsEqual(hyp.GetNumberOfLayers(), args[0])
6068
6069     ## Defines "LocalLength" hypothesis, specifying the segment length
6070     #  @param l the length of segments
6071     #  @param p the precision of rounding
6072     def LocalLength(self, l, p=1e-07):
6073         hyp = self.OwnHypothesis("LocalLength", [l,p])
6074         hyp.SetLength(l)
6075         hyp.SetPrecision(p)
6076         return hyp
6077
6078     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
6079     #  @param n the number of layers
6080     #  @param s the scale factor (optional)
6081     def NumberOfSegments(self, n, s=[]):
6082         if s == []:
6083             hyp = self.OwnHypothesis("NumberOfSegments", [n])
6084         else:
6085             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
6086             hyp.SetDistrType( 1 )
6087             hyp.SetScaleFactor(s)
6088         hyp.SetNumberOfSegments(n)
6089         return hyp
6090
6091     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
6092     #  with a length that changes in arithmetic progression
6093     #  @param start  the length of the first segment
6094     #  @param end    the length of the last  segment
6095     def Arithmetic1D(self, start, end ):
6096         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
6097         hyp.SetLength(start, 1)
6098         hyp.SetLength(end  , 0)
6099         return hyp
6100
6101     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
6102     #  as geometric length increasing
6103     #  @param start for the length of the first segment
6104     #  @param end   for the length of the last  segment
6105     def StartEndLength(self, start, end):
6106         hyp = self.OwnHypothesis("StartEndLength", [start, end])
6107         hyp.SetLength(start, 1)
6108         hyp.SetLength(end  , 0)
6109         return hyp
6110
6111     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
6112     #  @param fineness defines the quality of the mesh within the range [0-1]
6113     def AutomaticLength(self, fineness=0):
6114         hyp = self.OwnHypothesis("AutomaticLength")
6115         hyp.SetFineness( fineness )
6116         return hyp
6117
6118
6119 # Public class: Mesh_UseExistingElements
6120 # --------------------------------------
6121 ## Defines a Radial Quadrangle 1D2D algorithm
6122 #  @ingroup l3_algos_basic
6123 #
6124 class Mesh_UseExistingElements(Mesh_Algorithm):
6125
6126     def __init__(self, dim, mesh, geom=0):
6127         if dim == 1:
6128             self.Create(mesh, geom, "Import_1D")
6129         else:
6130             self.Create(mesh, geom, "Import_1D2D")
6131         return
6132
6133     ## Defines "Source edges" hypothesis, specifying groups of edges to import
6134     #  @param groups list of groups of edges
6135     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6136     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6137     #  @param UseExisting if ==true - searches for the existing hypothesis created with
6138     #                     the same parameters, else (default) - creates a new one
6139     def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6140         if self.algo.GetName() == "Import_2D":
6141             raise ValueError, "algoritm dimension mismatch"
6142         for group in groups:
6143             self.AssureGeomPublished( group )
6144         hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
6145                               UseExisting=UseExisting, CompareMethod=self._compareHyp)
6146         hyp.SetSourceEdges(groups)
6147         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6148         return hyp
6149
6150     ## Defines "Source faces" hypothesis, specifying groups of faces to import
6151     #  @param groups list of groups of faces
6152     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
6153     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
6154     #  @param UseExisting if ==true - searches for the existing hypothesis created with
6155     #                     the same parameters, else (default) - creates a new one
6156     def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
6157         if self.algo.GetName() == "Import_1D":
6158             raise ValueError, "algoritm dimension mismatch"
6159         for group in groups:
6160             self.AssureGeomPublished( group )
6161         hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
6162                               UseExisting=UseExisting, CompareMethod=self._compareHyp)
6163         hyp.SetSourceFaces(groups)
6164         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
6165         return hyp
6166
6167     def _compareHyp(self,hyp,args):
6168         if hasattr( hyp, "GetSourceEdges"):
6169             entries = hyp.GetSourceEdges()
6170         else:
6171             entries = hyp.GetSourceFaces()
6172         groups = args[0]
6173         toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
6174         if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
6175             entries2 = []
6176             study = self.mesh.smeshpyD.GetCurrentStudy()
6177             if study:
6178                 for g in groups:
6179                     ior  = salome.orb.object_to_string(g)
6180                     sobj = study.FindObjectIOR(ior)
6181                     if sobj: entries2.append( sobj.GetID() )
6182                     pass
6183                 pass
6184             entries.sort()
6185             entries2.sort()
6186             return entries == entries2
6187         return False
6188
6189
6190 # Private class: Mesh_UseExisting
6191 # -------------------------------
6192 class Mesh_UseExisting(Mesh_Algorithm):
6193
6194     def __init__(self, dim, mesh, geom=0):
6195         if dim == 1:
6196             self.Create(mesh, geom, "UseExisting_1D")
6197         else:
6198             self.Create(mesh, geom, "UseExisting_2D")
6199
6200
6201 import salome_notebook
6202 notebook = salome_notebook.notebook
6203
6204 ##Return values of the notebook variables
6205 def ParseParameters(last, nbParams,nbParam, value):
6206     result = None
6207     strResult = ""
6208     counter = 0
6209     listSize = len(last)
6210     for n in range(0,nbParams):
6211         if n+1 != nbParam:
6212             if counter < listSize:
6213                 strResult = strResult + last[counter]
6214             else:
6215                 strResult = strResult + ""
6216         else:
6217             if isinstance(value, str):
6218                 if notebook.isVariable(value):
6219                     result = notebook.get(value)
6220                     strResult=strResult+value
6221                 else:
6222                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6223             else:
6224                 strResult=strResult+str(value)
6225                 result = value
6226         if nbParams - 1 != counter:
6227             strResult=strResult+var_separator #":"
6228         counter = counter+1
6229     return result, strResult
6230
6231 #Wrapper class for StdMeshers_LocalLength hypothesis
6232 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6233
6234     ## Set Length parameter value
6235     #  @param length numerical value or name of variable from notebook
6236     def SetLength(self, length):
6237         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6238         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6239         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6240
6241    ## Set Precision parameter value
6242    #  @param precision numerical value or name of variable from notebook
6243     def SetPrecision(self, precision):
6244         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6245         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6246         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6247
6248 #Registering the new proxy for LocalLength
6249 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6250
6251
6252 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6253 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6254
6255     def SetLayerDistribution(self, hypo):
6256         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6257         hypo.ClearParameters();
6258         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6259
6260 #Registering the new proxy for LayerDistribution
6261 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6262
6263 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6264 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6265
6266     ## Set Length parameter value
6267     #  @param length numerical value or name of variable from notebook
6268     def SetLength(self, length):
6269         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6270         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6271         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6272
6273 #Registering the new proxy for SegmentLengthAroundVertex
6274 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6275
6276
6277 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6278 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6279
6280     ## Set Length parameter value
6281     #  @param length   numerical value or name of variable from notebook
6282     #  @param isStart  true is length is Start Length, otherwise false
6283     def SetLength(self, length, isStart):
6284         nb = 2
6285         if isStart:
6286             nb = 1
6287         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6288         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6289         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6290
6291 #Registering the new proxy for Arithmetic1D
6292 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6293
6294 #Wrapper class for StdMeshers_Deflection1D hypothesis
6295 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6296
6297     ## Set Deflection parameter value
6298     #  @param deflection numerical value or name of variable from notebook
6299     def SetDeflection(self, deflection):
6300         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6301         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6302         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6303
6304 #Registering the new proxy for Deflection1D
6305 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6306
6307 #Wrapper class for StdMeshers_StartEndLength hypothesis
6308 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6309
6310     ## Set Length parameter value
6311     #  @param length  numerical value or name of variable from notebook
6312     #  @param isStart true is length is Start Length, otherwise false
6313     def SetLength(self, length, isStart):
6314         nb = 2
6315         if isStart:
6316             nb = 1
6317         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6318         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6319         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6320
6321 #Registering the new proxy for StartEndLength
6322 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6323
6324 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6325 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6326
6327     ## Set Max Element Area parameter value
6328     #  @param area  numerical value or name of variable from notebook
6329     def SetMaxElementArea(self, area):
6330         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6331         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6332         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6333
6334 #Registering the new proxy for MaxElementArea
6335 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6336
6337
6338 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6339 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6340
6341     ## Set Max Element Volume parameter value
6342     #  @param volume numerical value or name of variable from notebook
6343     def SetMaxElementVolume(self, volume):
6344         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6345         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6346         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6347
6348 #Registering the new proxy for MaxElementVolume
6349 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6350
6351
6352 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6353 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6354
6355     ## Set Number Of Layers parameter value
6356     #  @param nbLayers  numerical value or name of variable from notebook
6357     def SetNumberOfLayers(self, nbLayers):
6358         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6359         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6360         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6361
6362 #Registering the new proxy for NumberOfLayers
6363 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6364
6365 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6366 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6367
6368     ## Set Number Of Segments parameter value
6369     #  @param nbSeg numerical value or name of variable from notebook
6370     def SetNumberOfSegments(self, nbSeg):
6371         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6372         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6373         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6374         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6375
6376     ## Set Scale Factor parameter value
6377     #  @param factor numerical value or name of variable from notebook
6378     def SetScaleFactor(self, factor):
6379         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6380         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6381         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6382
6383 #Registering the new proxy for NumberOfSegments
6384 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6385
6386 if not noNETGENPlugin:
6387     #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6388     class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6389
6390         ## Set Max Size parameter value
6391         #  @param maxsize numerical value or name of variable from notebook
6392         def SetMaxSize(self, maxsize):
6393             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6394             maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6395             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6396             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6397
6398         ## Set Growth Rate parameter value
6399         #  @param value  numerical value or name of variable from notebook
6400         def SetGrowthRate(self, value):
6401             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6402             value, parameters = ParseParameters(lastParameters,4,2,value)
6403             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6404             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6405
6406         ## Set Number of Segments per Edge parameter value
6407         #  @param value  numerical value or name of variable from notebook
6408         def SetNbSegPerEdge(self, value):
6409             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6410             value, parameters = ParseParameters(lastParameters,4,3,value)
6411             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6412             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6413
6414         ## Set Number of Segments per Radius parameter value
6415         #  @param value  numerical value or name of variable from notebook
6416         def SetNbSegPerRadius(self, value):
6417             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6418             value, parameters = ParseParameters(lastParameters,4,4,value)
6419             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6420             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6421
6422     #Registering the new proxy for NETGENPlugin_Hypothesis
6423     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6424
6425
6426     #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6427     class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6428         pass
6429
6430     #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6431     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6432
6433     #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6434     class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6435
6436         ## Set Number of Segments parameter value
6437         #  @param nbSeg numerical value or name of variable from notebook
6438         def SetNumberOfSegments(self, nbSeg):
6439             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6440             nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6441             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6442             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6443
6444         ## Set Local Length parameter value
6445         #  @param length numerical value or name of variable from notebook
6446         def SetLocalLength(self, length):
6447             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6448             length, parameters = ParseParameters(lastParameters,2,1,length)
6449             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6450             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6451
6452         ## Set Max Element Area parameter value
6453         #  @param area numerical value or name of variable from notebook
6454         def SetMaxElementArea(self, area):
6455             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6456             area, parameters = ParseParameters(lastParameters,2,2,area)
6457             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6458             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6459
6460         def LengthFromEdges(self):
6461             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6462             value = 0;
6463             value, parameters = ParseParameters(lastParameters,2,2,value)
6464             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6465             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6466
6467     #Registering the new proxy for NETGEN_SimpleParameters_2D
6468     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6469
6470
6471     #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6472     class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6473         ## Set Max Element Volume parameter value
6474         #  @param volume numerical value or name of variable from notebook
6475         def SetMaxElementVolume(self, volume):
6476             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6477             volume, parameters = ParseParameters(lastParameters,3,3,volume)
6478             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6479             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6480
6481         def LengthFromFaces(self):
6482             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6483             value = 0;
6484             value, parameters = ParseParameters(lastParameters,3,3,value)
6485             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6486             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6487
6488     #Registering the new proxy for NETGEN_SimpleParameters_3D
6489     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6490
6491     pass # if not noNETGENPlugin:
6492
6493 class Pattern(SMESH._objref_SMESH_Pattern):
6494
6495     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6496         flag = False
6497         if isinstance(theNodeIndexOnKeyPoint1,str):
6498             flag = True
6499         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6500         if flag:
6501             theNodeIndexOnKeyPoint1 -= 1
6502         theMesh.SetParameters(Parameters)
6503         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6504
6505     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6506         flag0 = False
6507         flag1 = False
6508         if isinstance(theNode000Index,str):
6509             flag0 = True
6510         if isinstance(theNode001Index,str):
6511             flag1 = True
6512         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6513         if flag0:
6514             theNode000Index -= 1
6515         if flag1:
6516             theNode001Index -= 1
6517         theMesh.SetParameters(Parameters)
6518         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6519
6520 #Registering the new proxy for Pattern
6521 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)