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