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