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