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