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