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