Salome HOME
0020095: EDF 896 SMESH : Advanced Mesh info on a group
[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     ## Gets the mesh stattistic
1592     #  @return dictionary type element - count of elements
1593     #  @ingroup l1_meshinfo
1594     def GetMeshInfo(self, obj = None):
1595         if not obj: obj = self.mesh
1596         d = {}
1597         if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
1598             values = obj.GetMeshInfo() 
1599             for i in range(SMESH.Entity_Last._v):
1600                 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1601             pass
1602         return d
1603
1604     ## Returns the number of nodes in the mesh
1605     #  @return an integer value
1606     #  @ingroup l1_meshinfo
1607     def NbNodes(self):
1608         return self.mesh.NbNodes()
1609
1610     ## Returns the number of elements in the mesh
1611     #  @return an integer value
1612     #  @ingroup l1_meshinfo
1613     def NbElements(self):
1614         return self.mesh.NbElements()
1615
1616     ## Returns the number of 0d elements in the mesh
1617     #  @return an integer value
1618     #  @ingroup l1_meshinfo
1619     def Nb0DElements(self):
1620         return self.mesh.Nb0DElements()
1621
1622     ## Returns the number of edges in the mesh
1623     #  @return an integer value
1624     #  @ingroup l1_meshinfo
1625     def NbEdges(self):
1626         return self.mesh.NbEdges()
1627
1628     ## Returns the number of edges with the given order in the mesh
1629     #  @param elementOrder the order of elements:
1630     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1631     #  @return an integer value
1632     #  @ingroup l1_meshinfo
1633     def NbEdgesOfOrder(self, elementOrder):
1634         return self.mesh.NbEdgesOfOrder(elementOrder)
1635
1636     ## Returns the number of faces in the mesh
1637     #  @return an integer value
1638     #  @ingroup l1_meshinfo
1639     def NbFaces(self):
1640         return self.mesh.NbFaces()
1641
1642     ## Returns the number of faces with the given order in the mesh
1643     #  @param elementOrder the order of elements:
1644     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1645     #  @return an integer value
1646     #  @ingroup l1_meshinfo
1647     def NbFacesOfOrder(self, elementOrder):
1648         return self.mesh.NbFacesOfOrder(elementOrder)
1649
1650     ## Returns the number of triangles in the mesh
1651     #  @return an integer value
1652     #  @ingroup l1_meshinfo
1653     def NbTriangles(self):
1654         return self.mesh.NbTriangles()
1655
1656     ## Returns the number of triangles with the given order in the mesh
1657     #  @param elementOrder is the order of elements:
1658     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1659     #  @return an integer value
1660     #  @ingroup l1_meshinfo
1661     def NbTrianglesOfOrder(self, elementOrder):
1662         return self.mesh.NbTrianglesOfOrder(elementOrder)
1663
1664     ## Returns the number of quadrangles in the mesh
1665     #  @return an integer value
1666     #  @ingroup l1_meshinfo
1667     def NbQuadrangles(self):
1668         return self.mesh.NbQuadrangles()
1669
1670     ## Returns the number of quadrangles with the given order in the mesh
1671     #  @param elementOrder the order of elements:
1672     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1673     #  @return an integer value
1674     #  @ingroup l1_meshinfo
1675     def NbQuadranglesOfOrder(self, elementOrder):
1676         return self.mesh.NbQuadranglesOfOrder(elementOrder)
1677
1678     ## Returns the number of polygons in the mesh
1679     #  @return an integer value
1680     #  @ingroup l1_meshinfo
1681     def NbPolygons(self):
1682         return self.mesh.NbPolygons()
1683
1684     ## Returns the number of volumes in the mesh
1685     #  @return an integer value
1686     #  @ingroup l1_meshinfo
1687     def NbVolumes(self):
1688         return self.mesh.NbVolumes()
1689
1690     ## Returns the number of volumes with the given order in the mesh
1691     #  @param elementOrder  the order of elements:
1692     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1693     #  @return an integer value
1694     #  @ingroup l1_meshinfo
1695     def NbVolumesOfOrder(self, elementOrder):
1696         return self.mesh.NbVolumesOfOrder(elementOrder)
1697
1698     ## Returns the number of tetrahedrons in the mesh
1699     #  @return an integer value
1700     #  @ingroup l1_meshinfo
1701     def NbTetras(self):
1702         return self.mesh.NbTetras()
1703
1704     ## Returns the number of tetrahedrons with the given order in the mesh
1705     #  @param elementOrder  the order of elements:
1706     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1707     #  @return an integer value
1708     #  @ingroup l1_meshinfo
1709     def NbTetrasOfOrder(self, elementOrder):
1710         return self.mesh.NbTetrasOfOrder(elementOrder)
1711
1712     ## Returns the number of hexahedrons in the mesh
1713     #  @return an integer value
1714     #  @ingroup l1_meshinfo
1715     def NbHexas(self):
1716         return self.mesh.NbHexas()
1717
1718     ## Returns the number of hexahedrons with the given order in the mesh
1719     #  @param elementOrder  the order of elements:
1720     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1721     #  @return an integer value
1722     #  @ingroup l1_meshinfo
1723     def NbHexasOfOrder(self, elementOrder):
1724         return self.mesh.NbHexasOfOrder(elementOrder)
1725
1726     ## Returns the number of pyramids in the mesh
1727     #  @return an integer value
1728     #  @ingroup l1_meshinfo
1729     def NbPyramids(self):
1730         return self.mesh.NbPyramids()
1731
1732     ## Returns the number of pyramids with the given order in the mesh
1733     #  @param elementOrder  the order of elements:
1734     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1735     #  @return an integer value
1736     #  @ingroup l1_meshinfo
1737     def NbPyramidsOfOrder(self, elementOrder):
1738         return self.mesh.NbPyramidsOfOrder(elementOrder)
1739
1740     ## Returns the number of prisms in the mesh
1741     #  @return an integer value
1742     #  @ingroup l1_meshinfo
1743     def NbPrisms(self):
1744         return self.mesh.NbPrisms()
1745
1746     ## Returns the number of prisms with the given order in the mesh
1747     #  @param elementOrder  the order of elements:
1748     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1749     #  @return an integer value
1750     #  @ingroup l1_meshinfo
1751     def NbPrismsOfOrder(self, elementOrder):
1752         return self.mesh.NbPrismsOfOrder(elementOrder)
1753
1754     ## Returns the number of polyhedrons in the mesh
1755     #  @return an integer value
1756     #  @ingroup l1_meshinfo
1757     def NbPolyhedrons(self):
1758         return self.mesh.NbPolyhedrons()
1759
1760     ## Returns the number of submeshes in the mesh
1761     #  @return an integer value
1762     #  @ingroup l1_meshinfo
1763     def NbSubMesh(self):
1764         return self.mesh.NbSubMesh()
1765
1766     ## Returns the list of mesh elements IDs
1767     #  @return the list of integer values
1768     #  @ingroup l1_meshinfo
1769     def GetElementsId(self):
1770         return self.mesh.GetElementsId()
1771
1772     ## Returns the list of IDs of mesh elements with the given type
1773     #  @param elementType  the required type of elements
1774     #  @return list of integer values
1775     #  @ingroup l1_meshinfo
1776     def GetElementsByType(self, elementType):
1777         return self.mesh.GetElementsByType(elementType)
1778
1779     ## Returns the list of mesh nodes IDs
1780     #  @return the list of integer values
1781     #  @ingroup l1_meshinfo
1782     def GetNodesId(self):
1783         return self.mesh.GetNodesId()
1784
1785     # Get the information about mesh elements:
1786     # ------------------------------------
1787
1788     ## Returns the type of mesh element
1789     #  @return the value from SMESH::ElementType enumeration
1790     #  @ingroup l1_meshinfo
1791     def GetElementType(self, id, iselem):
1792         return self.mesh.GetElementType(id, iselem)
1793
1794     ## Returns the list of submesh elements IDs
1795     #  @param Shape a geom object(subshape) IOR
1796     #         Shape must be the subshape of a ShapeToMesh()
1797     #  @return the list of integer values
1798     #  @ingroup l1_meshinfo
1799     def GetSubMeshElementsId(self, Shape):
1800         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1801             ShapeID = Shape.GetSubShapeIndices()[0]
1802         else:
1803             ShapeID = Shape
1804         return self.mesh.GetSubMeshElementsId(ShapeID)
1805
1806     ## Returns the list of submesh nodes IDs
1807     #  @param Shape a geom object(subshape) IOR
1808     #         Shape must be the subshape of a ShapeToMesh()
1809     #  @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1810     #  @return the list of integer values
1811     #  @ingroup l1_meshinfo
1812     def GetSubMeshNodesId(self, Shape, all):
1813         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1814             ShapeID = Shape.GetSubShapeIndices()[0]
1815         else:
1816             ShapeID = Shape
1817         return self.mesh.GetSubMeshNodesId(ShapeID, all)
1818
1819     ## Returns type of elements on given shape
1820     #  @param Shape a geom object(subshape) IOR
1821     #         Shape must be a subshape of a ShapeToMesh()
1822     #  @return element type
1823     #  @ingroup l1_meshinfo
1824     def GetSubMeshElementType(self, Shape):
1825         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1826             ShapeID = Shape.GetSubShapeIndices()[0]
1827         else:
1828             ShapeID = Shape
1829         return self.mesh.GetSubMeshElementType(ShapeID)
1830
1831     ## Gets the mesh description
1832     #  @return string value
1833     #  @ingroup l1_meshinfo
1834     def Dump(self):
1835         return self.mesh.Dump()
1836
1837
1838     # Get the information about nodes and elements of a mesh by its IDs:
1839     # -----------------------------------------------------------
1840
1841     ## Gets XYZ coordinates of a node
1842     #  \n If there is no nodes for the given ID - returns an empty list
1843     #  @return a list of double precision values
1844     #  @ingroup l1_meshinfo
1845     def GetNodeXYZ(self, id):
1846         return self.mesh.GetNodeXYZ(id)
1847
1848     ## Returns list of IDs of inverse elements for the given node
1849     #  \n If there is no node for the given ID - returns an empty list
1850     #  @return a list of integer values
1851     #  @ingroup l1_meshinfo
1852     def GetNodeInverseElements(self, id):
1853         return self.mesh.GetNodeInverseElements(id)
1854
1855     ## @brief Returns the position of a node on the shape
1856     #  @return SMESH::NodePosition
1857     #  @ingroup l1_meshinfo
1858     def GetNodePosition(self,NodeID):
1859         return self.mesh.GetNodePosition(NodeID)
1860
1861     ## If the given element is a node, returns the ID of shape
1862     #  \n If there is no node for the given ID - returns -1
1863     #  @return an integer value
1864     #  @ingroup l1_meshinfo
1865     def GetShapeID(self, id):
1866         return self.mesh.GetShapeID(id)
1867
1868     ## Returns the ID of the result shape after
1869     #  FindShape() from SMESH_MeshEditor for the given element
1870     #  \n If there is no element for the given ID - returns -1
1871     #  @return an integer value
1872     #  @ingroup l1_meshinfo
1873     def GetShapeIDForElem(self,id):
1874         return self.mesh.GetShapeIDForElem(id)
1875
1876     ## Returns the number of nodes for the given element
1877     #  \n If there is no element for the given ID - returns -1
1878     #  @return an integer value
1879     #  @ingroup l1_meshinfo
1880     def GetElemNbNodes(self, id):
1881         return self.mesh.GetElemNbNodes(id)
1882
1883     ## Returns the node ID the given index for the given element
1884     #  \n If there is no element for the given ID - returns -1
1885     #  \n If there is no node for the given index - returns -2
1886     #  @return an integer value
1887     #  @ingroup l1_meshinfo
1888     def GetElemNode(self, id, index):
1889         return self.mesh.GetElemNode(id, index)
1890
1891     ## Returns the IDs of nodes of the given element
1892     #  @return a list of integer values
1893     #  @ingroup l1_meshinfo
1894     def GetElemNodes(self, id):
1895         return self.mesh.GetElemNodes(id)
1896
1897     ## Returns true if the given node is the medium node in the given quadratic element
1898     #  @ingroup l1_meshinfo
1899     def IsMediumNode(self, elementID, nodeID):
1900         return self.mesh.IsMediumNode(elementID, nodeID)
1901
1902     ## Returns true if the given node is the medium node in one of quadratic elements
1903     #  @ingroup l1_meshinfo
1904     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1905         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1906
1907     ## Returns the number of edges for the given element
1908     #  @ingroup l1_meshinfo
1909     def ElemNbEdges(self, id):
1910         return self.mesh.ElemNbEdges(id)
1911
1912     ## Returns the number of faces for the given element
1913     #  @ingroup l1_meshinfo
1914     def ElemNbFaces(self, id):
1915         return self.mesh.ElemNbFaces(id)
1916
1917     ## Returns true if the given element is a polygon
1918     #  @ingroup l1_meshinfo
1919     def IsPoly(self, id):
1920         return self.mesh.IsPoly(id)
1921
1922     ## Returns true if the given element is quadratic
1923     #  @ingroup l1_meshinfo
1924     def IsQuadratic(self, id):
1925         return self.mesh.IsQuadratic(id)
1926
1927     ## Returns XYZ coordinates of the barycenter of the given element
1928     #  \n If there is no element for the given ID - returns an empty list
1929     #  @return a list of three double values
1930     #  @ingroup l1_meshinfo
1931     def BaryCenter(self, id):
1932         return self.mesh.BaryCenter(id)
1933
1934
1935     # Mesh edition (SMESH_MeshEditor functionality):
1936     # ---------------------------------------------
1937
1938     ## Removes the elements from the mesh by ids
1939     #  @param IDsOfElements is a list of ids of elements to remove
1940     #  @return True or False
1941     #  @ingroup l2_modif_del
1942     def RemoveElements(self, IDsOfElements):
1943         return self.editor.RemoveElements(IDsOfElements)
1944
1945     ## Removes nodes from mesh by ids
1946     #  @param IDsOfNodes is a list of ids of nodes to remove
1947     #  @return True or False
1948     #  @ingroup l2_modif_del
1949     def RemoveNodes(self, IDsOfNodes):
1950         return self.editor.RemoveNodes(IDsOfNodes)
1951
1952     ## Add a node to the mesh by coordinates
1953     #  @return Id of the new node
1954     #  @ingroup l2_modif_add
1955     def AddNode(self, x, y, z):
1956         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1957         self.mesh.SetParameters(Parameters)
1958         return self.editor.AddNode( x, y, z)
1959
1960     ## Creates a 0D element on a node with given number.
1961     #  @param IDOfNode the ID of node for creation of the element.
1962     #  @return the Id of the new 0D element
1963     #  @ingroup l2_modif_add
1964     def Add0DElement(self, IDOfNode):
1965         return self.editor.Add0DElement(IDOfNode)
1966
1967     ## Creates a linear or quadratic edge (this is determined
1968     #  by the number of given nodes).
1969     #  @param IDsOfNodes the list of node IDs for creation of the element.
1970     #  The order of nodes in this list should correspond to the description
1971     #  of MED. \n This description is located by the following link:
1972     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1973     #  @return the Id of the new edge
1974     #  @ingroup l2_modif_add
1975     def AddEdge(self, IDsOfNodes):
1976         return self.editor.AddEdge(IDsOfNodes)
1977
1978     ## Creates a linear or quadratic face (this is determined
1979     #  by the number of given nodes).
1980     #  @param IDsOfNodes the list of node IDs for creation of the element.
1981     #  The order of nodes in this list should correspond to the description
1982     #  of MED. \n This description is located by the following link:
1983     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1984     #  @return the Id of the new face
1985     #  @ingroup l2_modif_add
1986     def AddFace(self, IDsOfNodes):
1987         return self.editor.AddFace(IDsOfNodes)
1988
1989     ## Adds a polygonal face to the mesh by the list of node IDs
1990     #  @param IdsOfNodes the list of node IDs for creation of the element.
1991     #  @return the Id of the new face
1992     #  @ingroup l2_modif_add
1993     def AddPolygonalFace(self, IdsOfNodes):
1994         return self.editor.AddPolygonalFace(IdsOfNodes)
1995
1996     ## Creates both simple and quadratic volume (this is determined
1997     #  by the number of given nodes).
1998     #  @param IDsOfNodes the list of node IDs for creation of the element.
1999     #  The order of nodes in this list should correspond to the description
2000     #  of MED. \n This description is located by the following link:
2001     #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2002     #  @return the Id of the new volumic element
2003     #  @ingroup l2_modif_add
2004     def AddVolume(self, IDsOfNodes):
2005         return self.editor.AddVolume(IDsOfNodes)
2006
2007     ## Creates a volume of many faces, giving nodes for each face.
2008     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
2009     #  @param Quantities the list of integer values, Quantities[i]
2010     #         gives the quantity of nodes in face number i.
2011     #  @return the Id of the new volumic element
2012     #  @ingroup l2_modif_add
2013     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2014         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2015
2016     ## Creates a volume of many faces, giving the IDs of the existing faces.
2017     #  @param IdsOfFaces the list of face IDs for volume creation.
2018     #
2019     #  Note:  The created volume will refer only to the nodes
2020     #         of the given faces, not to the faces themselves.
2021     #  @return the Id of the new volumic element
2022     #  @ingroup l2_modif_add
2023     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2024         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2025
2026
2027     ## @brief Binds a node to a vertex
2028     #  @param NodeID a node ID
2029     #  @param Vertex a vertex or vertex ID
2030     #  @return True if succeed else raises an exception
2031     #  @ingroup l2_modif_add
2032     def SetNodeOnVertex(self, NodeID, Vertex):
2033         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2034             VertexID = Vertex.GetSubShapeIndices()[0]
2035         else:
2036             VertexID = Vertex
2037         try:
2038             self.editor.SetNodeOnVertex(NodeID, VertexID)
2039         except SALOME.SALOME_Exception, inst:
2040             raise ValueError, inst.details.text
2041         return True
2042
2043
2044     ## @brief Stores the node position on an edge
2045     #  @param NodeID a node ID
2046     #  @param Edge an edge or edge ID
2047     #  @param paramOnEdge a parameter on the edge where the node is located
2048     #  @return True if succeed else raises an exception
2049     #  @ingroup l2_modif_add
2050     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2051         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2052             EdgeID = Edge.GetSubShapeIndices()[0]
2053         else:
2054             EdgeID = Edge
2055         try:
2056             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2057         except SALOME.SALOME_Exception, inst:
2058             raise ValueError, inst.details.text
2059         return True
2060
2061     ## @brief Stores node position on a face
2062     #  @param NodeID a node ID
2063     #  @param Face a face or face ID
2064     #  @param u U parameter on the face where the node is located
2065     #  @param v V parameter on the face where the node is located
2066     #  @return True if succeed else raises an exception
2067     #  @ingroup l2_modif_add
2068     def SetNodeOnFace(self, NodeID, Face, u, v):
2069         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2070             FaceID = Face.GetSubShapeIndices()[0]
2071         else:
2072             FaceID = Face
2073         try:
2074             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2075         except SALOME.SALOME_Exception, inst:
2076             raise ValueError, inst.details.text
2077         return True
2078
2079     ## @brief Binds a node to a solid
2080     #  @param NodeID a node ID
2081     #  @param Solid  a solid or solid ID
2082     #  @return True if succeed else raises an exception
2083     #  @ingroup l2_modif_add
2084     def SetNodeInVolume(self, NodeID, Solid):
2085         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2086             SolidID = Solid.GetSubShapeIndices()[0]
2087         else:
2088             SolidID = Solid
2089         try:
2090             self.editor.SetNodeInVolume(NodeID, SolidID)
2091         except SALOME.SALOME_Exception, inst:
2092             raise ValueError, inst.details.text
2093         return True
2094
2095     ## @brief Bind an element to a shape
2096     #  @param ElementID an element ID
2097     #  @param Shape a shape or shape ID
2098     #  @return True if succeed else raises an exception
2099     #  @ingroup l2_modif_add
2100     def SetMeshElementOnShape(self, ElementID, Shape):
2101         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2102             ShapeID = Shape.GetSubShapeIndices()[0]
2103         else:
2104             ShapeID = Shape
2105         try:
2106             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2107         except SALOME.SALOME_Exception, inst:
2108             raise ValueError, inst.details.text
2109         return True
2110
2111
2112     ## Moves the node with the given id
2113     #  @param NodeID the id of the node
2114     #  @param x  a new X coordinate
2115     #  @param y  a new Y coordinate
2116     #  @param z  a new Z coordinate
2117     #  @return True if succeed else False
2118     #  @ingroup l2_modif_movenode
2119     def MoveNode(self, NodeID, x, y, z):
2120         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2121         self.mesh.SetParameters(Parameters)
2122         return self.editor.MoveNode(NodeID, x, y, z)
2123
2124     ## Finds the node closest to a point and moves it to a point location
2125     #  @param x  the X coordinate of a point
2126     #  @param y  the Y coordinate of a point
2127     #  @param z  the Z coordinate of a point
2128     #  @return the ID of a node
2129     #  @ingroup l2_modif_throughp
2130     def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2131         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2132         self.mesh.SetParameters(Parameters)
2133         return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2134
2135     ## Finds the node closest to a point
2136     #  @param x  the X coordinate of a point
2137     #  @param y  the Y coordinate of a point
2138     #  @param z  the Z coordinate of a point
2139     #  @return the ID of a node
2140     #  @ingroup l2_modif_throughp
2141     def FindNodeClosestTo(self, x, y, z):
2142         preview = self.mesh.GetMeshEditPreviewer()
2143         return preview.MoveClosestNodeToPoint(x, y, z, -1)
2144
2145     ## Finds the node closest to a point and moves it to a point location
2146     #  @param x  the X coordinate of a point
2147     #  @param y  the Y coordinate of a point
2148     #  @param z  the Z coordinate of a point
2149     #  @return the ID of a moved node
2150     #  @ingroup l2_modif_throughp
2151     def MeshToPassThroughAPoint(self, x, y, z):
2152         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2153
2154     ## Replaces two neighbour triangles sharing Node1-Node2 link
2155     #  with the triangles built on the same 4 nodes but having other common link.
2156     #  @param NodeID1  the ID of the first node
2157     #  @param NodeID2  the ID of the second node
2158     #  @return false if proper faces were not found
2159     #  @ingroup l2_modif_invdiag
2160     def InverseDiag(self, NodeID1, NodeID2):
2161         return self.editor.InverseDiag(NodeID1, NodeID2)
2162
2163     ## Replaces two neighbour triangles sharing Node1-Node2 link
2164     #  with a quadrangle built on the same 4 nodes.
2165     #  @param NodeID1  the ID of the first node
2166     #  @param NodeID2  the ID of the second node
2167     #  @return false if proper faces were not found
2168     #  @ingroup l2_modif_unitetri
2169     def DeleteDiag(self, NodeID1, NodeID2):
2170         return self.editor.DeleteDiag(NodeID1, NodeID2)
2171
2172     ## Reorients elements by ids
2173     #  @param IDsOfElements if undefined reorients all mesh elements
2174     #  @return True if succeed else False
2175     #  @ingroup l2_modif_changori
2176     def Reorient(self, IDsOfElements=None):
2177         if IDsOfElements == None:
2178             IDsOfElements = self.GetElementsId()
2179         return self.editor.Reorient(IDsOfElements)
2180
2181     ## Reorients all elements of the object
2182     #  @param theObject mesh, submesh or group
2183     #  @return True if succeed else False
2184     #  @ingroup l2_modif_changori
2185     def ReorientObject(self, theObject):
2186         if ( isinstance( theObject, Mesh )):
2187             theObject = theObject.GetMesh()
2188         return self.editor.ReorientObject(theObject)
2189
2190     ## Fuses the neighbouring triangles into quadrangles.
2191     #  @param IDsOfElements The triangles to be fused,
2192     #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
2193     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
2194     #                       is still performed; theMaxAngle is mesured in radians.
2195     #                       Also it could be a name of variable which defines angle in degrees.
2196     #  @return TRUE in case of success, FALSE otherwise.
2197     #  @ingroup l2_modif_unitetri
2198     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2199         flag = False
2200         if isinstance(MaxAngle,str):
2201             flag = True
2202         MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2203         if flag:
2204             MaxAngle = DegreesToRadians(MaxAngle)
2205         if IDsOfElements == []:
2206             IDsOfElements = self.GetElementsId()
2207         self.mesh.SetParameters(Parameters)
2208         Functor = 0
2209         if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2210             Functor = theCriterion
2211         else:
2212             Functor = self.smeshpyD.GetFunctor(theCriterion)
2213         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2214
2215     ## Fuses the neighbouring triangles of the object into quadrangles
2216     #  @param theObject is mesh, submesh or group
2217     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2218     #  @param MaxAngle   a max angle between element normals at which the fusion
2219     #                   is still performed; theMaxAngle is mesured in radians.
2220     #  @return TRUE in case of success, FALSE otherwise.
2221     #  @ingroup l2_modif_unitetri
2222     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2223         if ( isinstance( theObject, Mesh )):
2224             theObject = theObject.GetMesh()
2225         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2226
2227     ## Splits quadrangles into triangles.
2228     #  @param IDsOfElements the faces to be splitted.
2229     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2230     #  @return TRUE in case of success, FALSE otherwise.
2231     #  @ingroup l2_modif_cutquadr
2232     def QuadToTri (self, IDsOfElements, theCriterion):
2233         if IDsOfElements == []:
2234             IDsOfElements = self.GetElementsId()
2235         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2236
2237     ## Splits quadrangles into triangles.
2238     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
2239     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
2240     #  @return TRUE in case of success, FALSE otherwise.
2241     #  @ingroup l2_modif_cutquadr
2242     def QuadToTriObject (self, theObject, theCriterion):
2243         if ( isinstance( theObject, Mesh )):
2244             theObject = theObject.GetMesh()
2245         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2246
2247     ## Splits quadrangles into triangles.
2248     #  @param IDsOfElements the faces to be splitted
2249     #  @param Diag13        is used to choose a diagonal for splitting.
2250     #  @return TRUE in case of success, FALSE otherwise.
2251     #  @ingroup l2_modif_cutquadr
2252     def SplitQuad (self, IDsOfElements, Diag13):
2253         if IDsOfElements == []:
2254             IDsOfElements = self.GetElementsId()
2255         return self.editor.SplitQuad(IDsOfElements, Diag13)
2256
2257     ## Splits quadrangles into triangles.
2258     #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2259     #  @param Diag13    is used to choose a diagonal for splitting.
2260     #  @return TRUE in case of success, FALSE otherwise.
2261     #  @ingroup l2_modif_cutquadr
2262     def SplitQuadObject (self, theObject, Diag13):
2263         if ( isinstance( theObject, Mesh )):
2264             theObject = theObject.GetMesh()
2265         return self.editor.SplitQuadObject(theObject, Diag13)
2266
2267     ## Finds a better splitting of the given quadrangle.
2268     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
2269     #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
2270     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
2271     #          diagonal is better, 0 if error occurs.
2272     #  @ingroup l2_modif_cutquadr
2273     def BestSplit (self, IDOfQuad, theCriterion):
2274         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2275
2276     ## Splits quadrangle faces near triangular facets of volumes
2277     #
2278     #  @ingroup l1_auxiliary
2279     def SplitQuadsNearTriangularFacets(self):
2280         faces_array = self.GetElementsByType(SMESH.FACE)
2281         for face_id in faces_array:
2282             if self.GetElemNbNodes(face_id) == 4: # quadrangle
2283                 quad_nodes = self.mesh.GetElemNodes(face_id)
2284                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2285                 isVolumeFound = False
2286                 for node1_elem in node1_elems:
2287                     if not isVolumeFound:
2288                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2289                             nb_nodes = self.GetElemNbNodes(node1_elem)
2290                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2291                                 volume_elem = node1_elem
2292                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2293                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2294                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2295                                         isVolumeFound = True
2296                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2297                                             self.SplitQuad([face_id], False) # diagonal 2-4
2298                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2299                                         isVolumeFound = True
2300                                         self.SplitQuad([face_id], True) # diagonal 1-3
2301                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2302                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2303                                         isVolumeFound = True
2304                                         self.SplitQuad([face_id], True) # diagonal 1-3
2305
2306     ## @brief Splits hexahedrons into tetrahedrons.
2307     #
2308     #  This operation uses pattern mapping functionality for splitting.
2309     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2310     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2311     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2312     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2313     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2314     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2315     #  @return TRUE in case of success, FALSE otherwise.
2316     #  @ingroup l1_auxiliary
2317     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2318         # Pattern:     5.---------.6
2319         #              /|#*      /|
2320         #             / | #*    / |
2321         #            /  |  # * /  |
2322         #           /   |   # /*  |
2323         # (0,0,1) 4.---------.7 * |
2324         #          |#*  |1   | # *|
2325         #          | # *.----|---#.2
2326         #          |  #/ *   |   /
2327         #          |  /#  *  |  /
2328         #          | /   # * | /
2329         #          |/      #*|/
2330         # (0,0,0) 0.---------.3
2331         pattern_tetra = "!!! Nb of points: \n 8 \n\
2332         !!! Points: \n\
2333         0 0 0  !- 0 \n\
2334         0 1 0  !- 1 \n\
2335         1 1 0  !- 2 \n\
2336         1 0 0  !- 3 \n\
2337         0 0 1  !- 4 \n\
2338         0 1 1  !- 5 \n\
2339         1 1 1  !- 6 \n\
2340         1 0 1  !- 7 \n\
2341         !!! Indices of points of 6 tetras: \n\
2342         0 3 4 1 \n\
2343         7 4 3 1 \n\
2344         4 7 5 1 \n\
2345         6 2 5 7 \n\
2346         1 5 2 7 \n\
2347         2 3 1 7 \n"
2348
2349         pattern = self.smeshpyD.GetPattern()
2350         isDone  = pattern.LoadFromFile(pattern_tetra)
2351         if not isDone:
2352             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2353             return isDone
2354
2355         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2356         isDone = pattern.MakeMesh(self.mesh, False, False)
2357         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2358
2359         # split quafrangle faces near triangular facets of volumes
2360         self.SplitQuadsNearTriangularFacets()
2361
2362         return isDone
2363
2364     ## @brief Split hexahedrons into prisms.
2365     #
2366     #  Uses the pattern mapping functionality for splitting.
2367     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2368     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2369     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2370     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2371     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2372     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2373     #  @return TRUE in case of success, FALSE otherwise.
2374     #  @ingroup l1_auxiliary
2375     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2376         # Pattern:     5.---------.6
2377         #              /|#       /|
2378         #             / | #     / |
2379         #            /  |  #   /  |
2380         #           /   |   # /   |
2381         # (0,0,1) 4.---------.7   |
2382         #          |    |    |    |
2383         #          |   1.----|----.2
2384         #          |   / *   |   /
2385         #          |  /   *  |  /
2386         #          | /     * | /
2387         #          |/       *|/
2388         # (0,0,0) 0.---------.3
2389         pattern_prism = "!!! Nb of points: \n 8 \n\
2390         !!! Points: \n\
2391         0 0 0  !- 0 \n\
2392         0 1 0  !- 1 \n\
2393         1 1 0  !- 2 \n\
2394         1 0 0  !- 3 \n\
2395         0 0 1  !- 4 \n\
2396         0 1 1  !- 5 \n\
2397         1 1 1  !- 6 \n\
2398         1 0 1  !- 7 \n\
2399         !!! Indices of points of 2 prisms: \n\
2400         0 1 3 4 5 7 \n\
2401         2 3 1 6 7 5 \n"
2402
2403         pattern = self.smeshpyD.GetPattern()
2404         isDone  = pattern.LoadFromFile(pattern_prism)
2405         if not isDone:
2406             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2407             return isDone
2408
2409         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2410         isDone = pattern.MakeMesh(self.mesh, False, False)
2411         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2412
2413         # Splits quafrangle faces near triangular facets of volumes
2414         self.SplitQuadsNearTriangularFacets()
2415
2416         return isDone
2417
2418     ## Smoothes elements
2419     #  @param IDsOfElements the list if ids of elements to smooth
2420     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2421     #  Note that nodes built on edges and boundary nodes are always fixed.
2422     #  @param MaxNbOfIterations the maximum number of iterations
2423     #  @param MaxAspectRatio varies in range [1.0, inf]
2424     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2425     #  @return TRUE in case of success, FALSE otherwise.
2426     #  @ingroup l2_modif_smooth
2427     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2428                MaxNbOfIterations, MaxAspectRatio, Method):
2429         if IDsOfElements == []:
2430             IDsOfElements = self.GetElementsId()
2431         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2432         self.mesh.SetParameters(Parameters)
2433         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2434                                   MaxNbOfIterations, MaxAspectRatio, Method)
2435
2436     ## Smoothes elements which belong to the given object
2437     #  @param theObject the object to smooth
2438     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2439     #  Note that nodes built on edges and boundary nodes are always fixed.
2440     #  @param MaxNbOfIterations the maximum number of iterations
2441     #  @param MaxAspectRatio varies in range [1.0, inf]
2442     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2443     #  @return TRUE in case of success, FALSE otherwise.
2444     #  @ingroup l2_modif_smooth
2445     def SmoothObject(self, theObject, IDsOfFixedNodes,
2446                      MaxNbOfIterations, MaxAspectRatio, Method):
2447         if ( isinstance( theObject, Mesh )):
2448             theObject = theObject.GetMesh()
2449         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2450                                         MaxNbOfIterations, MaxAspectRatio, Method)
2451
2452     ## Parametrically smoothes the given elements
2453     #  @param IDsOfElements the list if ids of elements to smooth
2454     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2455     #  Note that nodes built on edges and boundary nodes are always fixed.
2456     #  @param MaxNbOfIterations the maximum number of iterations
2457     #  @param MaxAspectRatio varies in range [1.0, inf]
2458     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2459     #  @return TRUE in case of success, FALSE otherwise.
2460     #  @ingroup l2_modif_smooth
2461     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2462                          MaxNbOfIterations, MaxAspectRatio, Method):
2463         if IDsOfElements == []:
2464             IDsOfElements = self.GetElementsId()
2465         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2466         self.mesh.SetParameters(Parameters)
2467         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2468                                             MaxNbOfIterations, MaxAspectRatio, Method)
2469
2470     ## Parametrically smoothes the elements which belong to the given object
2471     #  @param theObject the object to smooth
2472     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
2473     #  Note that nodes built on edges and boundary nodes are always fixed.
2474     #  @param MaxNbOfIterations the maximum number of iterations
2475     #  @param MaxAspectRatio varies in range [1.0, inf]
2476     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2477     #  @return TRUE in case of success, FALSE otherwise.
2478     #  @ingroup l2_modif_smooth
2479     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2480                                MaxNbOfIterations, MaxAspectRatio, Method):
2481         if ( isinstance( theObject, Mesh )):
2482             theObject = theObject.GetMesh()
2483         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2484                                                   MaxNbOfIterations, MaxAspectRatio, Method)
2485
2486     ## Converts the mesh to quadratic, deletes old elements, replacing
2487     #  them with quadratic with the same id.
2488     #  @ingroup l2_modif_tofromqu
2489     def ConvertToQuadratic(self, theForce3d):
2490         self.editor.ConvertToQuadratic(theForce3d)
2491
2492     ## Converts the mesh from quadratic to ordinary,
2493     #  deletes old quadratic elements, \n replacing
2494     #  them with ordinary mesh elements with the same id.
2495     #  @return TRUE in case of success, FALSE otherwise.
2496     #  @ingroup l2_modif_tofromqu
2497     def ConvertFromQuadratic(self):
2498         return self.editor.ConvertFromQuadratic()
2499
2500     ## Renumber mesh nodes
2501     #  @ingroup l2_modif_renumber
2502     def RenumberNodes(self):
2503         self.editor.RenumberNodes()
2504
2505     ## Renumber mesh elements
2506     #  @ingroup l2_modif_renumber
2507     def RenumberElements(self):
2508         self.editor.RenumberElements()
2509
2510     ## Generates new elements by rotation of the elements around the axis
2511     #  @param IDsOfElements the list of ids of elements to sweep
2512     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2513     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2514     #  @param NbOfSteps the number of steps
2515     #  @param Tolerance tolerance
2516     #  @param MakeGroups forces the generation of new groups from existing ones
2517     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2518     #                    of all steps, else - size of each step
2519     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2520     #  @ingroup l2_modif_extrurev
2521     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2522                       MakeGroups=False, TotalAngle=False):
2523         flag = False
2524         if isinstance(AngleInRadians,str):
2525             flag = True
2526         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2527         if flag:
2528             AngleInRadians = DegreesToRadians(AngleInRadians)
2529         if IDsOfElements == []:
2530             IDsOfElements = self.GetElementsId()
2531         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2532             Axis = self.smeshpyD.GetAxisStruct(Axis)
2533         Axis,AxisParameters = ParseAxisStruct(Axis)
2534         if TotalAngle and NbOfSteps:
2535             AngleInRadians /= NbOfSteps
2536         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2537         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2538         self.mesh.SetParameters(Parameters)
2539         if MakeGroups:
2540             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2541                                                        AngleInRadians, NbOfSteps, Tolerance)
2542         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2543         return []
2544
2545     ## Generates new elements by rotation of the elements of object around the axis
2546     #  @param theObject object which elements should be sweeped
2547     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2548     #  @param AngleInRadians the angle of Rotation
2549     #  @param NbOfSteps number of steps
2550     #  @param Tolerance tolerance
2551     #  @param MakeGroups forces the generation of new groups from existing ones
2552     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2553     #                    of all steps, else - size of each step
2554     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2555     #  @ingroup l2_modif_extrurev
2556     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2557                             MakeGroups=False, TotalAngle=False):
2558         flag = False
2559         if isinstance(AngleInRadians,str):
2560             flag = True
2561         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2562         if flag:
2563             AngleInRadians = DegreesToRadians(AngleInRadians)
2564         if ( isinstance( theObject, Mesh )):
2565             theObject = theObject.GetMesh()
2566         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2567             Axis = self.smeshpyD.GetAxisStruct(Axis)
2568         Axis,AxisParameters = ParseAxisStruct(Axis)
2569         if TotalAngle and NbOfSteps:
2570             AngleInRadians /= NbOfSteps
2571         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2572         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2573         self.mesh.SetParameters(Parameters)
2574         if MakeGroups:
2575             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2576                                                              NbOfSteps, Tolerance)
2577         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2578         return []
2579
2580     ## Generates new elements by rotation of the elements of object around the axis
2581     #  @param theObject object which elements should be sweeped
2582     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2583     #  @param AngleInRadians the angle of Rotation
2584     #  @param NbOfSteps number of steps
2585     #  @param Tolerance tolerance
2586     #  @param MakeGroups forces the generation of new groups from existing ones
2587     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2588     #                    of all steps, else - size of each step
2589     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2590     #  @ingroup l2_modif_extrurev
2591     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2592                               MakeGroups=False, TotalAngle=False):
2593         flag = False
2594         if isinstance(AngleInRadians,str):
2595             flag = True
2596         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2597         if flag:
2598             AngleInRadians = DegreesToRadians(AngleInRadians)
2599         if ( isinstance( theObject, Mesh )):
2600             theObject = theObject.GetMesh()
2601         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2602             Axis = self.smeshpyD.GetAxisStruct(Axis)
2603         Axis,AxisParameters = ParseAxisStruct(Axis)
2604         if TotalAngle and NbOfSteps:
2605             AngleInRadians /= NbOfSteps
2606         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2607         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2608         self.mesh.SetParameters(Parameters)
2609         if MakeGroups:
2610             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2611                                                                NbOfSteps, Tolerance)
2612         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2613         return []
2614
2615     ## Generates new elements by rotation of the elements of object around the axis
2616     #  @param theObject object which elements should be sweeped
2617     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2618     #  @param AngleInRadians the angle of Rotation
2619     #  @param NbOfSteps number of steps
2620     #  @param Tolerance tolerance
2621     #  @param MakeGroups forces the generation of new groups from existing ones
2622     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2623     #                    of all steps, else - size of each step
2624     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2625     #  @ingroup l2_modif_extrurev
2626     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2627                               MakeGroups=False, TotalAngle=False):
2628         flag = False
2629         if isinstance(AngleInRadians,str):
2630             flag = True
2631         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2632         if flag:
2633             AngleInRadians = DegreesToRadians(AngleInRadians)
2634         if ( isinstance( theObject, Mesh )):
2635             theObject = theObject.GetMesh()
2636         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2637             Axis = self.smeshpyD.GetAxisStruct(Axis)
2638         Axis,AxisParameters = ParseAxisStruct(Axis)
2639         if TotalAngle and NbOfSteps:
2640             AngleInRadians /= NbOfSteps
2641         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2642         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2643         self.mesh.SetParameters(Parameters)
2644         if MakeGroups:
2645             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2646                                                              NbOfSteps, Tolerance)
2647         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2648         return []
2649
2650     ## Generates new elements by extrusion of the elements with given ids
2651     #  @param IDsOfElements the list of elements ids for extrusion
2652     #  @param StepVector vector, defining the direction and value of extrusion
2653     #  @param NbOfSteps the number of steps
2654     #  @param MakeGroups forces the generation of new groups from existing ones
2655     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2656     #  @ingroup l2_modif_extrurev
2657     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2658         if IDsOfElements == []:
2659             IDsOfElements = self.GetElementsId()
2660         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2661             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2662         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2663         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2664         Parameters = StepVectorParameters + var_separator + Parameters
2665         self.mesh.SetParameters(Parameters)
2666         if MakeGroups:
2667             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2668         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2669         return []
2670
2671     ## Generates new elements by extrusion of the elements with given ids
2672     #  @param IDsOfElements is ids of elements
2673     #  @param StepVector vector, defining the direction and value of extrusion
2674     #  @param NbOfSteps the number of steps
2675     #  @param ExtrFlags sets flags for extrusion
2676     #  @param SewTolerance uses for comparing locations of nodes if flag
2677     #         EXTRUSION_FLAG_SEW is set
2678     #  @param MakeGroups forces the generation of new groups from existing ones
2679     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2680     #  @ingroup l2_modif_extrurev
2681     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2682                           ExtrFlags, SewTolerance, MakeGroups=False):
2683         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2684             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2685         if MakeGroups:
2686             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2687                                                            ExtrFlags, SewTolerance)
2688         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2689                                       ExtrFlags, SewTolerance)
2690         return []
2691
2692     ## Generates new elements by extrusion of the elements which belong to the object
2693     #  @param theObject the object which elements should be processed
2694     #  @param StepVector vector, defining the direction and value of extrusion
2695     #  @param NbOfSteps the number of steps
2696     #  @param MakeGroups forces the generation of new groups from existing ones
2697     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2698     #  @ingroup l2_modif_extrurev
2699     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2700         if ( isinstance( theObject, Mesh )):
2701             theObject = theObject.GetMesh()
2702         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2703             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2704         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2705         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2706         Parameters = StepVectorParameters + var_separator + Parameters
2707         self.mesh.SetParameters(Parameters)
2708         if MakeGroups:
2709             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2710         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2711         return []
2712
2713     ## Generates new elements by extrusion of the elements which belong to the object
2714     #  @param theObject object which elements should be processed
2715     #  @param StepVector vector, defining the direction and value of extrusion
2716     #  @param NbOfSteps the number of steps
2717     #  @param MakeGroups to generate new groups from existing ones
2718     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2719     #  @ingroup l2_modif_extrurev
2720     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2721         if ( isinstance( theObject, Mesh )):
2722             theObject = theObject.GetMesh()
2723         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2724             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2725         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2726         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2727         Parameters = StepVectorParameters + var_separator + Parameters
2728         self.mesh.SetParameters(Parameters)
2729         if MakeGroups:
2730             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2731         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2732         return []
2733
2734     ## Generates new elements by extrusion of the elements which belong to the object
2735     #  @param theObject object which elements should be processed
2736     #  @param StepVector vector, defining the direction and value of extrusion
2737     #  @param NbOfSteps the number of steps
2738     #  @param MakeGroups forces the generation of new groups from existing ones
2739     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2740     #  @ingroup l2_modif_extrurev
2741     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2742         if ( isinstance( theObject, Mesh )):
2743             theObject = theObject.GetMesh()
2744         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2745             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2746         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2747         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2748         Parameters = StepVectorParameters + var_separator + Parameters
2749         self.mesh.SetParameters(Parameters)
2750         if MakeGroups:
2751             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2752         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2753         return []
2754
2755
2756
2757     ## Generates new elements by extrusion of the given elements
2758     #  The path of extrusion must be a meshed edge.
2759     #  @param Base mesh or list of ids of elements for extrusion
2760     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2761     #  @param NodeStart the start node from Path. Defines the direction of extrusion
2762     #  @param HasAngles allows the shape to be rotated around the path
2763     #                   to get the resulting mesh in a helical fashion
2764     #  @param Angles list of angles in radians
2765     #  @param LinearVariation forces the computation of rotation angles as linear
2766     #                         variation of the given Angles along path steps
2767     #  @param HasRefPoint allows using the reference point
2768     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2769     #         The User can specify any point as the Reference Point.
2770     #  @param MakeGroups forces the generation of new groups from existing ones
2771     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
2772     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2773     #          only SMESH::Extrusion_Error otherwise
2774     #  @ingroup l2_modif_extrurev
2775     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2776                             HasAngles, Angles, LinearVariation,
2777                             HasRefPoint, RefPoint, MakeGroups, ElemType):
2778         Angles,AnglesParameters = ParseAngles(Angles)
2779         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2780         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2781             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2782             pass
2783         Parameters = AnglesParameters + var_separator + RefPointParameters
2784         self.mesh.SetParameters(Parameters)
2785
2786         if isinstance(Base,list):
2787             IDsOfElements = []
2788             if Base == []: IDsOfElements = self.GetElementsId()
2789             else: IDsOfElements = Base
2790             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2791                                                    HasAngles, Angles, LinearVariation,
2792                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
2793         else:
2794             if isinstance(Base,Mesh):
2795                 return self.editor.ExtrusionAlongPathObjX(Base.GetMesh(), Path, NodeStart,
2796                                                           HasAngles, Angles, LinearVariation,
2797                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
2798             else:
2799                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2800
2801
2802     ## Generates new elements by extrusion of the given elements
2803     #  The path of extrusion must be a meshed edge.
2804     #  @param IDsOfElements ids of elements
2805     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2806     #  @param PathShape shape(edge) defines the sub-mesh for the path
2807     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2808     #  @param HasAngles allows the shape to be rotated around the path
2809     #                   to get the resulting mesh in a helical fashion
2810     #  @param Angles list of angles in radians
2811     #  @param HasRefPoint allows using the reference point
2812     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2813     #         The User can specify any point as the Reference Point.
2814     #  @param MakeGroups forces the generation of new groups from existing ones
2815     #  @param LinearVariation forces the computation of rotation angles as linear
2816     #                         variation of the given Angles along path steps
2817     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2818     #          only SMESH::Extrusion_Error otherwise
2819     #  @ingroup l2_modif_extrurev
2820     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2821                            HasAngles, Angles, HasRefPoint, RefPoint,
2822                            MakeGroups=False, LinearVariation=False):
2823         Angles,AnglesParameters = ParseAngles(Angles)
2824         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2825         if IDsOfElements == []:
2826             IDsOfElements = self.GetElementsId()
2827         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2828             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2829             pass
2830         if ( isinstance( PathMesh, Mesh )):
2831             PathMesh = PathMesh.GetMesh()
2832         if HasAngles and Angles and LinearVariation:
2833             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2834             pass
2835         Parameters = AnglesParameters + var_separator + RefPointParameters
2836         self.mesh.SetParameters(Parameters)
2837         if MakeGroups:
2838             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2839                                                             PathShape, NodeStart, HasAngles,
2840                                                             Angles, HasRefPoint, RefPoint)
2841         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2842                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2843
2844     ## Generates new elements by extrusion of the elements which belong to the object
2845     #  The path of extrusion must be a meshed edge.
2846     #  @param theObject the object which elements should be processed
2847     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2848     #  @param PathShape shape(edge) defines the sub-mesh for the path
2849     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2850     #  @param HasAngles allows the shape to be rotated around the path
2851     #                   to get the resulting mesh in a helical fashion
2852     #  @param Angles list of angles
2853     #  @param HasRefPoint allows using the reference point
2854     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2855     #         The User can specify any point as the Reference Point.
2856     #  @param MakeGroups forces the generation of new groups from existing ones
2857     #  @param LinearVariation forces the computation of rotation angles as linear
2858     #                         variation of the given Angles along path steps
2859     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2860     #          only SMESH::Extrusion_Error otherwise
2861     #  @ingroup l2_modif_extrurev
2862     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2863                                  HasAngles, Angles, HasRefPoint, RefPoint,
2864                                  MakeGroups=False, LinearVariation=False):
2865         Angles,AnglesParameters = ParseAngles(Angles)
2866         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2867         if ( isinstance( theObject, Mesh )):
2868             theObject = theObject.GetMesh()
2869         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2870             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2871         if ( isinstance( PathMesh, Mesh )):
2872             PathMesh = PathMesh.GetMesh()
2873         if HasAngles and Angles and LinearVariation:
2874             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2875             pass
2876         Parameters = AnglesParameters + var_separator + RefPointParameters
2877         self.mesh.SetParameters(Parameters)
2878         if MakeGroups:
2879             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2880                                                                   PathShape, NodeStart, HasAngles,
2881                                                                   Angles, HasRefPoint, RefPoint)
2882         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2883                                                     NodeStart, HasAngles, Angles, HasRefPoint,
2884                                                     RefPoint)
2885
2886     ## Generates new elements by extrusion of the elements which belong to the object
2887     #  The path of extrusion must be a meshed edge.
2888     #  @param theObject the object which elements should be processed
2889     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2890     #  @param PathShape shape(edge) defines the sub-mesh for the path
2891     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2892     #  @param HasAngles allows the shape to be rotated around the path
2893     #                   to get the resulting mesh in a helical fashion
2894     #  @param Angles list of angles
2895     #  @param HasRefPoint allows using the reference point
2896     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2897     #         The User can specify any point as the Reference Point.
2898     #  @param MakeGroups forces the generation of new groups from existing ones
2899     #  @param LinearVariation forces the computation of rotation angles as linear
2900     #                         variation of the given Angles along path steps
2901     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2902     #          only SMESH::Extrusion_Error otherwise
2903     #  @ingroup l2_modif_extrurev
2904     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2905                                    HasAngles, Angles, HasRefPoint, RefPoint,
2906                                    MakeGroups=False, LinearVariation=False):
2907         Angles,AnglesParameters = ParseAngles(Angles)
2908         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2909         if ( isinstance( theObject, Mesh )):
2910             theObject = theObject.GetMesh()
2911         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2912             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2913         if ( isinstance( PathMesh, Mesh )):
2914             PathMesh = PathMesh.GetMesh()
2915         if HasAngles and Angles and LinearVariation:
2916             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2917             pass
2918         Parameters = AnglesParameters + var_separator + RefPointParameters
2919         self.mesh.SetParameters(Parameters)
2920         if MakeGroups:
2921             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2922                                                                     PathShape, NodeStart, HasAngles,
2923                                                                     Angles, HasRefPoint, RefPoint)
2924         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2925                                                       NodeStart, HasAngles, Angles, HasRefPoint,
2926                                                       RefPoint)
2927
2928     ## Generates new elements by extrusion of the elements which belong to the object
2929     #  The path of extrusion must be a meshed edge.
2930     #  @param theObject the object which elements should be processed
2931     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2932     #  @param PathShape shape(edge) defines the sub-mesh for the path
2933     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2934     #  @param HasAngles allows the shape to be rotated around the path
2935     #                   to get the resulting mesh in a helical fashion
2936     #  @param Angles list of angles
2937     #  @param HasRefPoint allows using the reference point
2938     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2939     #         The User can specify any point as the Reference Point.
2940     #  @param MakeGroups forces the generation of new groups from existing ones
2941     #  @param LinearVariation forces the computation of rotation angles as linear
2942     #                         variation of the given Angles along path steps
2943     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2944     #          only SMESH::Extrusion_Error otherwise
2945     #  @ingroup l2_modif_extrurev
2946     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2947                                    HasAngles, Angles, HasRefPoint, RefPoint,
2948                                    MakeGroups=False, LinearVariation=False):
2949         Angles,AnglesParameters = ParseAngles(Angles)
2950         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2951         if ( isinstance( theObject, Mesh )):
2952             theObject = theObject.GetMesh()
2953         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2954             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2955         if ( isinstance( PathMesh, Mesh )):
2956             PathMesh = PathMesh.GetMesh()
2957         if HasAngles and Angles and LinearVariation:
2958             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2959             pass
2960         Parameters = AnglesParameters + var_separator + RefPointParameters
2961         self.mesh.SetParameters(Parameters)
2962         if MakeGroups:
2963             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2964                                                                     PathShape, NodeStart, HasAngles,
2965                                                                     Angles, HasRefPoint, RefPoint)
2966         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2967                                                       NodeStart, HasAngles, Angles, HasRefPoint,
2968                                                       RefPoint)
2969
2970     ## Creates a symmetrical copy of mesh elements
2971     #  @param IDsOfElements list of elements ids
2972     #  @param Mirror is AxisStruct or geom object(point, line, plane)
2973     #  @param theMirrorType is  POINT, AXIS or PLANE
2974     #  If the Mirror is a geom object this parameter is unnecessary
2975     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2976     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2977     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2978     #  @ingroup l2_modif_trsf
2979     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2980         if IDsOfElements == []:
2981             IDsOfElements = self.GetElementsId()
2982         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2983             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2984         Mirror,Parameters = ParseAxisStruct(Mirror)
2985         self.mesh.SetParameters(Parameters)
2986         if Copy and MakeGroups:
2987             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2988         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2989         return []
2990
2991     ## Creates a new mesh by a symmetrical copy of mesh elements
2992     #  @param IDsOfElements the list of elements ids
2993     #  @param Mirror is AxisStruct or geom object (point, line, plane)
2994     #  @param theMirrorType is  POINT, AXIS or PLANE
2995     #  If the Mirror is a geom object this parameter is unnecessary
2996     #  @param MakeGroups to generate new groups from existing ones
2997     #  @param NewMeshName a name of the new mesh to create
2998     #  @return instance of Mesh class
2999     #  @ingroup l2_modif_trsf
3000     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3001         if IDsOfElements == []:
3002             IDsOfElements = self.GetElementsId()
3003         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3004             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3005         Mirror,Parameters = ParseAxisStruct(Mirror)
3006         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3007                                           MakeGroups, NewMeshName)
3008         mesh.SetParameters(Parameters)
3009         return Mesh(self.smeshpyD,self.geompyD,mesh)
3010
3011     ## Creates a symmetrical copy of the object
3012     #  @param theObject mesh, submesh or group
3013     #  @param Mirror AxisStruct or geom object (point, line, plane)
3014     #  @param theMirrorType is  POINT, AXIS or PLANE
3015     #  If the Mirror is a geom object this parameter is unnecessary
3016     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3017     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3018     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3019     #  @ingroup l2_modif_trsf
3020     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3021         if ( isinstance( theObject, Mesh )):
3022             theObject = theObject.GetMesh()
3023         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3024             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3025         Mirror,Parameters = ParseAxisStruct(Mirror)
3026         self.mesh.SetParameters(Parameters)
3027         if Copy and MakeGroups:
3028             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3029         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3030         return []
3031
3032     ## Creates a new mesh by a symmetrical copy of the object
3033     #  @param theObject mesh, submesh or group
3034     #  @param Mirror AxisStruct or geom object (point, line, plane)
3035     #  @param theMirrorType POINT, AXIS or PLANE
3036     #  If the Mirror is a geom object this parameter is unnecessary
3037     #  @param MakeGroups forces the generation of new groups from existing ones
3038     #  @param NewMeshName the name of the new mesh to create
3039     #  @return instance of Mesh class
3040     #  @ingroup l2_modif_trsf
3041     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3042         if ( isinstance( theObject, Mesh )):
3043             theObject = theObject.GetMesh()
3044         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3045             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3046         Mirror,Parameters = ParseAxisStruct(Mirror)
3047         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3048                                                 MakeGroups, NewMeshName)
3049         mesh.SetParameters(Parameters)
3050         return Mesh( self.smeshpyD,self.geompyD,mesh )
3051
3052     ## Translates the elements
3053     #  @param IDsOfElements list of elements ids
3054     #  @param Vector the direction of translation (DirStruct or vector)
3055     #  @param Copy allows copying the translated elements
3056     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3057     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3058     #  @ingroup l2_modif_trsf
3059     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3060         if IDsOfElements == []:
3061             IDsOfElements = self.GetElementsId()
3062         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3063             Vector = self.smeshpyD.GetDirStruct(Vector)
3064         Vector,Parameters = ParseDirStruct(Vector)
3065         self.mesh.SetParameters(Parameters)
3066         if Copy and MakeGroups:
3067             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3068         self.editor.Translate(IDsOfElements, Vector, Copy)
3069         return []
3070
3071     ## Creates a new mesh of translated elements
3072     #  @param IDsOfElements list of elements ids
3073     #  @param Vector the direction of translation (DirStruct or vector)
3074     #  @param MakeGroups forces the generation of new groups from existing ones
3075     #  @param NewMeshName the name of the newly created mesh
3076     #  @return instance of Mesh class
3077     #  @ingroup l2_modif_trsf
3078     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3079         if IDsOfElements == []:
3080             IDsOfElements = self.GetElementsId()
3081         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3082             Vector = self.smeshpyD.GetDirStruct(Vector)
3083         Vector,Parameters = ParseDirStruct(Vector)
3084         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3085         mesh.SetParameters(Parameters)
3086         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3087
3088     ## Translates the object
3089     #  @param theObject the object to translate (mesh, submesh, or group)
3090     #  @param Vector direction of translation (DirStruct or geom vector)
3091     #  @param Copy allows copying the translated elements
3092     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3093     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3094     #  @ingroup l2_modif_trsf
3095     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3096         if ( isinstance( theObject, Mesh )):
3097             theObject = theObject.GetMesh()
3098         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3099             Vector = self.smeshpyD.GetDirStruct(Vector)
3100         Vector,Parameters = ParseDirStruct(Vector)
3101         self.mesh.SetParameters(Parameters)
3102         if Copy and MakeGroups:
3103             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3104         self.editor.TranslateObject(theObject, Vector, Copy)
3105         return []
3106
3107     ## Creates a new mesh from the translated object
3108     #  @param theObject the object to translate (mesh, submesh, or group)
3109     #  @param Vector the direction of translation (DirStruct or geom vector)
3110     #  @param MakeGroups forces the generation of new groups from existing ones
3111     #  @param NewMeshName the name of the newly created mesh
3112     #  @return instance of Mesh class
3113     #  @ingroup l2_modif_trsf
3114     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3115         if (isinstance(theObject, Mesh)):
3116             theObject = theObject.GetMesh()
3117         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3118             Vector = self.smeshpyD.GetDirStruct(Vector)
3119         Vector,Parameters = ParseDirStruct(Vector)
3120         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3121         mesh.SetParameters(Parameters)
3122         return Mesh( self.smeshpyD, self.geompyD, mesh )
3123
3124     ## Rotates the elements
3125     #  @param IDsOfElements list of elements ids
3126     #  @param Axis the axis of rotation (AxisStruct or geom line)
3127     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3128     #  @param Copy allows copying the rotated elements
3129     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3130     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3131     #  @ingroup l2_modif_trsf
3132     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3133         flag = False
3134         if isinstance(AngleInRadians,str):
3135             flag = True
3136         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3137         if flag:
3138             AngleInRadians = DegreesToRadians(AngleInRadians)
3139         if IDsOfElements == []:
3140             IDsOfElements = self.GetElementsId()
3141         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3142             Axis = self.smeshpyD.GetAxisStruct(Axis)
3143         Axis,AxisParameters = ParseAxisStruct(Axis)
3144         Parameters = AxisParameters + var_separator + Parameters
3145         self.mesh.SetParameters(Parameters)
3146         if Copy and MakeGroups:
3147             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3148         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3149         return []
3150
3151     ## Creates a new mesh of rotated elements
3152     #  @param IDsOfElements list of element ids
3153     #  @param Axis the axis of rotation (AxisStruct or geom line)
3154     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3155     #  @param MakeGroups forces the generation of new groups from existing ones
3156     #  @param NewMeshName the name of the newly created mesh
3157     #  @return instance of Mesh class
3158     #  @ingroup l2_modif_trsf
3159     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3160         flag = False
3161         if isinstance(AngleInRadians,str):
3162             flag = True
3163         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3164         if flag:
3165             AngleInRadians = DegreesToRadians(AngleInRadians)
3166         if IDsOfElements == []:
3167             IDsOfElements = self.GetElementsId()
3168         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3169             Axis = self.smeshpyD.GetAxisStruct(Axis)
3170         Axis,AxisParameters = ParseAxisStruct(Axis)
3171         Parameters = AxisParameters + var_separator + Parameters
3172         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3173                                           MakeGroups, NewMeshName)
3174         mesh.SetParameters(Parameters)
3175         return Mesh( self.smeshpyD, self.geompyD, mesh )
3176
3177     ## Rotates the object
3178     #  @param theObject the object to rotate( mesh, submesh, or group)
3179     #  @param Axis the axis of rotation (AxisStruct or geom line)
3180     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3181     #  @param Copy allows copying the rotated elements
3182     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3183     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3184     #  @ingroup l2_modif_trsf
3185     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3186         flag = False
3187         if isinstance(AngleInRadians,str):
3188             flag = True
3189         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3190         if flag:
3191             AngleInRadians = DegreesToRadians(AngleInRadians)
3192         if (isinstance(theObject, Mesh)):
3193             theObject = theObject.GetMesh()
3194         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3195             Axis = self.smeshpyD.GetAxisStruct(Axis)
3196         Axis,AxisParameters = ParseAxisStruct(Axis)
3197         Parameters = AxisParameters + ":" + Parameters
3198         self.mesh.SetParameters(Parameters)
3199         if Copy and MakeGroups:
3200             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3201         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3202         return []
3203
3204     ## Creates a new mesh from the rotated object
3205     #  @param theObject the object to rotate (mesh, submesh, or group)
3206     #  @param Axis the axis of rotation (AxisStruct or geom line)
3207     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
3208     #  @param MakeGroups forces the generation of new groups from existing ones
3209     #  @param NewMeshName the name of the newly created mesh
3210     #  @return instance of Mesh class
3211     #  @ingroup l2_modif_trsf
3212     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3213         flag = False
3214         if isinstance(AngleInRadians,str):
3215             flag = True
3216         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3217         if flag:
3218             AngleInRadians = DegreesToRadians(AngleInRadians)
3219         if (isinstance( theObject, Mesh )):
3220             theObject = theObject.GetMesh()
3221         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3222             Axis = self.smeshpyD.GetAxisStruct(Axis)
3223         Axis,AxisParameters = ParseAxisStruct(Axis)
3224         Parameters = AxisParameters + ":" + Parameters
3225         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3226                                                        MakeGroups, NewMeshName)
3227         mesh.SetParameters(Parameters)
3228         return Mesh( self.smeshpyD, self.geompyD, mesh )
3229
3230     ## Finds groups of ajacent nodes within Tolerance.
3231     #  @param Tolerance the value of tolerance
3232     #  @return the list of groups of nodes
3233     #  @ingroup l2_modif_trsf
3234     def FindCoincidentNodes (self, Tolerance):
3235         return self.editor.FindCoincidentNodes(Tolerance)
3236
3237     ## Finds groups of ajacent nodes within Tolerance.
3238     #  @param Tolerance the value of tolerance
3239     #  @param SubMeshOrGroup SubMesh or Group
3240     #  @return the list of groups of nodes
3241     #  @ingroup l2_modif_trsf
3242     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3243         return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3244
3245     ## Merges nodes
3246     #  @param GroupsOfNodes the list of groups of nodes
3247     #  @ingroup l2_modif_trsf
3248     def MergeNodes (self, GroupsOfNodes):
3249         self.editor.MergeNodes(GroupsOfNodes)
3250
3251     ## Finds the elements built on the same nodes.
3252     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3253     #  @return a list of groups of equal elements
3254     #  @ingroup l2_modif_trsf
3255     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3256         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3257
3258     ## Merges elements in each given group.
3259     #  @param GroupsOfElementsID groups of elements for merging
3260     #  @ingroup l2_modif_trsf
3261     def MergeElements(self, GroupsOfElementsID):
3262         self.editor.MergeElements(GroupsOfElementsID)
3263
3264     ## Leaves one element and removes all other elements built on the same nodes.
3265     #  @ingroup l2_modif_trsf
3266     def MergeEqualElements(self):
3267         self.editor.MergeEqualElements()
3268
3269     ## Sews free borders
3270     #  @return SMESH::Sew_Error
3271     #  @ingroup l2_modif_trsf
3272     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3273                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3274                         CreatePolygons, CreatePolyedrs):
3275         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3276                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3277                                           CreatePolygons, CreatePolyedrs)
3278
3279     ## Sews conform free borders
3280     #  @return SMESH::Sew_Error
3281     #  @ingroup l2_modif_trsf
3282     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3283                                FirstNodeID2, SecondNodeID2):
3284         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3285                                                  FirstNodeID2, SecondNodeID2)
3286
3287     ## Sews border to side
3288     #  @return SMESH::Sew_Error
3289     #  @ingroup l2_modif_trsf
3290     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3291                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3292         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3293                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3294
3295     ## Sews two sides of a mesh. The nodes belonging to Side1 are
3296     #  merged with the nodes of elements of Side2.
3297     #  The number of elements in theSide1 and in theSide2 must be
3298     #  equal and they should have similar nodal connectivity.
3299     #  The nodes to merge should belong to side borders and
3300     #  the first node should be linked to the second.
3301     #  @return SMESH::Sew_Error
3302     #  @ingroup l2_modif_trsf
3303     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3304                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3305                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3306         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3307                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3308                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3309
3310     ## Sets new nodes for the given element.
3311     #  @param ide the element id
3312     #  @param newIDs nodes ids
3313     #  @return If the number of nodes does not correspond to the type of element - returns false
3314     #  @ingroup l2_modif_edit
3315     def ChangeElemNodes(self, ide, newIDs):
3316         return self.editor.ChangeElemNodes(ide, newIDs)
3317
3318     ## If during the last operation of MeshEditor some nodes were
3319     #  created, this method returns the list of their IDs, \n
3320     #  if new nodes were not created - returns empty list
3321     #  @return the list of integer values (can be empty)
3322     #  @ingroup l1_auxiliary
3323     def GetLastCreatedNodes(self):
3324         return self.editor.GetLastCreatedNodes()
3325
3326     ## If during the last operation of MeshEditor some elements were
3327     #  created this method returns the list of their IDs, \n
3328     #  if new elements were not created - returns empty list
3329     #  @return the list of integer values (can be empty)
3330     #  @ingroup l1_auxiliary
3331     def GetLastCreatedElems(self):
3332         return self.editor.GetLastCreatedElems()
3333     
3334     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3335     #  @param theElems - the list of elements (edges or faces) to be replicated
3336     #         The nodes for duplication could be found from these elements
3337     #  @param theNodesNot - list of nodes to NOT replicate
3338     #  @param theAffectedElems - the list of elements (cells and edges) to which the 
3339     #         replicated nodes should be associated to.
3340     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3341     #  @ingroup l2_modif_edit
3342     def DoubleNodes(self, theElems, theNodesNot, theAffectedElems):
3343         return self.editor.DoubleNodes(theElems, theNodesNot, theAffectedElems)
3344         
3345     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3346     #  @param theElems - the list of elements (edges or faces) to be replicated
3347     #         The nodes for duplication could be found from these elements
3348     #  @param theNodesNot - list of nodes to NOT replicate
3349     #  @param theShape - shape to detect affected elements (element which geometric center
3350     #         located on or inside shape).
3351     #         The replicated nodes should be associated to affected elements.
3352     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3353     #  @ingroup l2_modif_edit
3354     def DoubleNodesInRegion(self, theElems, theNodesNot, theShape):
3355         return self.editor.DoubleNodesInRegion(theElems, theNodesNot, theShape)
3356     
3357     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3358     #  This method provided for convenience works as DoubleNodes() described above.
3359     #  @param theElems - group of of elements (edges or faces) to be replicated
3360     #  @param theNodesNot - group of nodes not to replicated
3361     #  @param theAffectedElems - group of elements to which the replicated nodes
3362     #         should be associated to.
3363     #  @ingroup l2_modif_edit
3364     def DoubleNodeGroup(self, theElems, theNodesNot, theAffectedElems):
3365         return self.editor.DoubleNodeGroup(theElems, theNodesNot, theAffectedElems)
3366         
3367     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3368     #  This method provided for convenience works as DoubleNodes() described above.
3369     #  @param theElems - group of of elements (edges or faces) to be replicated
3370     #  @param theNodesNot - group of nodes not to replicated
3371     #  @param theShape - shape to detect affected elements (element which geometric center
3372     #         located on or inside shape).
3373     #         The replicated nodes should be associated to affected elements.
3374     #  @ingroup l2_modif_edit
3375     def DoubleNodeGroupInRegion(self, theElems, theNodesNot, theShape):
3376         return self.editor.DoubleNodeGroup(theElems, theNodesNot, theShape)
3377         
3378     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3379     #  This method provided for convenience works as DoubleNodes() described above.
3380     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3381     #  @param theNodesNot - list of groups of nodes not to replicated
3382     #  @param theAffectedElems - group of elements to which the replicated nodes
3383     #         should be associated to.
3384     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3385     #  @ingroup l2_modif_edit
3386     def DoubleNodeGroups(self, theElems, theNodesNot, theAffectedElems):
3387         return self.editor.DoubleNodeGroups(theElems, theNodesNot, theAffectedElems)
3388
3389     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3390     #  This method provided for convenience works as DoubleNodes() described above.
3391     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3392     #  @param theNodesNot - list of groups of nodes not to replicated
3393     #  @param theShape - shape to detect affected elements (element which geometric center
3394     #         located on or inside shape).
3395     #         The replicated nodes should be associated to affected elements.
3396     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3397     #  @ingroup l2_modif_edit
3398     def DoubleNodeGroupsInRegion(self, theElems, theNodesNot, theShape):
3399         return self.editor.DoubleNodeGroupsInRegion(theElems, theNodesNot, theShape)
3400
3401 ## The mother class to define algorithm, it is not recommended to use it directly.
3402 #
3403 #  More details.
3404 #  @ingroup l2_algorithms
3405 class Mesh_Algorithm:
3406     #  @class Mesh_Algorithm
3407     #  @brief Class Mesh_Algorithm
3408
3409     #def __init__(self,smesh):
3410     #    self.smesh=smesh
3411     def __init__(self):
3412         self.mesh = None
3413         self.geom = None
3414         self.subm = None
3415         self.algo = None
3416
3417     ## Finds a hypothesis in the study by its type name and parameters.
3418     #  Finds only the hypotheses created in smeshpyD engine.
3419     #  @return SMESH.SMESH_Hypothesis
3420     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3421         study = smeshpyD.GetCurrentStudy()
3422         #to do: find component by smeshpyD object, not by its data type
3423         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3424         if scomp is not None:
3425             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3426             # Check if the root label of the hypotheses exists
3427             if res and hypRoot is not None:
3428                 iter = study.NewChildIterator(hypRoot)
3429                 # Check all published hypotheses
3430                 while iter.More():
3431                     hypo_so_i = iter.Value()
3432                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3433                     if attr is not None:
3434                         anIOR = attr.Value()
3435                         hypo_o_i = salome.orb.string_to_object(anIOR)
3436                         if hypo_o_i is not None:
3437                             # Check if this is a hypothesis
3438                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3439                             if hypo_i is not None:
3440                                 # Check if the hypothesis belongs to current engine
3441                                 if smeshpyD.GetObjectId(hypo_i) > 0:
3442                                     # Check if this is the required hypothesis
3443                                     if hypo_i.GetName() == hypname:
3444                                         # Check arguments
3445                                         if CompareMethod(hypo_i, args):
3446                                             # found!!!
3447                                             return hypo_i
3448                                         pass
3449                                     pass
3450                                 pass
3451                             pass
3452                         pass
3453                     iter.Next()
3454                     pass
3455                 pass
3456             pass
3457         return None
3458
3459     ## Finds the algorithm in the study by its type name.
3460     #  Finds only the algorithms, which have been created in smeshpyD engine.
3461     #  @return SMESH.SMESH_Algo
3462     def FindAlgorithm (self, algoname, smeshpyD):
3463         study = smeshpyD.GetCurrentStudy()
3464         #to do: find component by smeshpyD object, not by its data type
3465         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3466         if scomp is not None:
3467             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3468             # Check if the root label of the algorithms exists
3469             if res and hypRoot is not None:
3470                 iter = study.NewChildIterator(hypRoot)
3471                 # Check all published algorithms
3472                 while iter.More():
3473                     algo_so_i = iter.Value()
3474                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3475                     if attr is not None:
3476                         anIOR = attr.Value()
3477                         algo_o_i = salome.orb.string_to_object(anIOR)
3478                         if algo_o_i is not None:
3479                             # Check if this is an algorithm
3480                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3481                             if algo_i is not None:
3482                                 # Checks if the algorithm belongs to the current engine
3483                                 if smeshpyD.GetObjectId(algo_i) > 0:
3484                                     # Check if this is the required algorithm
3485                                     if algo_i.GetName() == algoname:
3486                                         # found!!!
3487                                         return algo_i
3488                                     pass
3489                                 pass
3490                             pass
3491                         pass
3492                     iter.Next()
3493                     pass
3494                 pass
3495             pass
3496         return None
3497
3498     ## If the algorithm is global, returns 0; \n
3499     #  else returns the submesh associated to this algorithm.
3500     def GetSubMesh(self):
3501         return self.subm
3502
3503     ## Returns the wrapped mesher.
3504     def GetAlgorithm(self):
3505         return self.algo
3506
3507     ## Gets the list of hypothesis that can be used with this algorithm
3508     def GetCompatibleHypothesis(self):
3509         mylist = []
3510         if self.algo:
3511             mylist = self.algo.GetCompatibleHypothesis()
3512         return mylist
3513
3514     ## Gets the name of the algorithm
3515     def GetName(self):
3516         GetName(self.algo)
3517
3518     ## Sets the name to the algorithm
3519     def SetName(self, name):
3520         self.mesh.smeshpyD.SetName(self.algo, name)
3521
3522     ## Gets the id of the algorithm
3523     def GetId(self):
3524         return self.algo.GetId()
3525
3526     ## Private method.
3527     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3528         if geom is None:
3529             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3530         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3531         if algo is None:
3532             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3533             pass
3534         self.Assign(algo, mesh, geom)
3535         return self.algo
3536
3537     ## Private method
3538     def Assign(self, algo, mesh, geom):
3539         if geom is None:
3540             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3541         self.mesh = mesh
3542         piece = mesh.geom
3543         if not geom:
3544             self.geom = piece
3545         else:
3546             self.geom = geom
3547             name = GetName(geom)
3548             if name==NO_NAME:
3549                 name = mesh.geompyD.SubShapeName(geom, piece)
3550                 mesh.geompyD.addToStudyInFather(piece, geom, name)
3551             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3552
3553         self.algo = algo
3554         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3555         TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3556
3557     def CompareHyp (self, hyp, args):
3558         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3559         return False
3560
3561     def CompareEqualHyp (self, hyp, args):
3562         return True
3563
3564     ## Private method
3565     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3566                     UseExisting=0, CompareMethod=""):
3567         hypo = None
3568         if UseExisting:
3569             if CompareMethod == "": CompareMethod = self.CompareHyp
3570             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3571             pass
3572         if hypo is None:
3573             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3574             a = ""
3575             s = "="
3576             i = 0
3577             n = len(args)
3578             while i<n:
3579                 a = a + s + str(args[i])
3580                 s = ","
3581                 i = i + 1
3582                 pass
3583             self.mesh.smeshpyD.SetName(hypo, hyp + a)
3584             pass
3585         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3586         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3587         return hypo
3588
3589     ## Returns entry of the shape to mesh in the study
3590     def MainShapeEntry(self):
3591         entry = ""
3592         if not self.mesh or not self.mesh.GetMesh(): return entry
3593         if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3594         study = self.mesh.smeshpyD.GetCurrentStudy()
3595         ior  = salome.orb.object_to_string( self.mesh.GetShape() )
3596         sobj = study.FindObjectIOR(ior)
3597         if sobj: entry = sobj.GetID()
3598         if not entry: return ""
3599         return entry
3600
3601 # Public class: Mesh_Segment
3602 # --------------------------
3603
3604 ## Class to define a segment 1D algorithm for discretization
3605 #
3606 #  More details.
3607 #  @ingroup l3_algos_basic
3608 class Mesh_Segment(Mesh_Algorithm):
3609
3610     ## Private constructor.
3611     def __init__(self, mesh, geom=0):
3612         Mesh_Algorithm.__init__(self)
3613         self.Create(mesh, geom, "Regular_1D")
3614
3615     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3616     #  @param l for the length of segments that cut an edge
3617     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3618     #                    the same parameters, else (default) - creates a new one
3619     #  @param p precision, used for calculation of the number of segments.
3620     #           The precision should be a positive, meaningful value within the range [0,1].
3621     #           In general, the number of segments is calculated with the formula:
3622     #           nb = ceil((edge_length / l) - p)
3623     #           Function ceil rounds its argument to the higher integer.
3624     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
3625     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
3626     #               p=1 means rounding of (edge_length / l) to the lower integer.
3627     #           Default value is 1e-07.
3628     #  @return an instance of StdMeshers_LocalLength hypothesis
3629     #  @ingroup l3_hypos_1dhyps
3630     def LocalLength(self, l, UseExisting=0, p=1e-07):
3631         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3632                               CompareMethod=self.CompareLocalLength)
3633         hyp.SetLength(l)
3634         hyp.SetPrecision(p)
3635         return hyp
3636
3637     ## Private method
3638     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3639     def CompareLocalLength(self, hyp, args):
3640         if IsEqual(hyp.GetLength(), args[0]):
3641             return IsEqual(hyp.GetPrecision(), args[1])
3642         return False
3643
3644     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3645     #  @param length is optional maximal allowed length of segment, if it is omitted
3646     #                the preestimated length is used that depends on geometry size
3647     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3648     #                     the same parameters, else (default) - create a new one
3649     #  @return an instance of StdMeshers_MaxLength hypothesis
3650     #  @ingroup l3_hypos_1dhyps
3651     def MaxSize(self, length=0.0, UseExisting=0):
3652         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3653         if length > 0.0:
3654             # set given length
3655             hyp.SetLength(length)
3656         if not UseExisting:
3657             # set preestimated length
3658             gen = self.mesh.smeshpyD
3659             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3660                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
3661                                                        False) # <- byMesh
3662             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3663             if preHyp:
3664                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3665                 pass
3666             pass
3667         hyp.SetUsePreestimatedLength( length == 0.0 )
3668         return hyp
3669         
3670     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3671     #  @param n for the number of segments that cut an edge
3672     #  @param s for the scale factor (optional)
3673     #  @param reversedEdges is a list of edges to mesh using reversed orientation
3674     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3675     #                     the same parameters, else (default) - create a new one
3676     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
3677     #  @ingroup l3_hypos_1dhyps
3678     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3679         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3680             reversedEdges, UseExisting = [], reversedEdges
3681         entry = self.MainShapeEntry()
3682         if s == []:
3683             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3684                                   UseExisting=UseExisting,
3685                                   CompareMethod=self.CompareNumberOfSegments)
3686         else:
3687             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3688                                   UseExisting=UseExisting,
3689                                   CompareMethod=self.CompareNumberOfSegments)
3690             hyp.SetDistrType( 1 )
3691             hyp.SetScaleFactor(s)
3692         hyp.SetNumberOfSegments(n)
3693         hyp.SetReversedEdges( reversedEdges )
3694         hyp.SetObjectEntry( entry )
3695         return hyp
3696
3697     ## Private method
3698     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3699     def CompareNumberOfSegments(self, hyp, args):
3700         if hyp.GetNumberOfSegments() == args[0]:
3701             if len(args) == 3:
3702                 if hyp.GetReversedEdges() == args[1]:
3703                     if not args[1] or hyp.GetObjectEntry() == args[2]:
3704                         return True
3705             else:
3706                 if hyp.GetReversedEdges() == args[2]:
3707                     if not args[2] or hyp.GetObjectEntry() == args[3]:
3708                         if hyp.GetDistrType() == 1:
3709                             if IsEqual(hyp.GetScaleFactor(), args[1]):
3710                                 return True
3711         return False
3712
3713     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3714     #  @param start defines the length of the first segment
3715     #  @param end   defines the length of the last  segment
3716     #  @param reversedEdges is a list of edges to mesh using reversed orientation
3717     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3718     #                     the same parameters, else (default) - creates a new one
3719     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
3720     #  @ingroup l3_hypos_1dhyps
3721     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3722         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3723             reversedEdges, UseExisting = [], reversedEdges
3724         entry = self.MainShapeEntry()
3725         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3726                               UseExisting=UseExisting,
3727                               CompareMethod=self.CompareArithmetic1D)
3728         hyp.SetStartLength(start)
3729         hyp.SetEndLength(end)
3730         hyp.SetReversedEdges( reversedEdges )
3731         hyp.SetObjectEntry( entry )
3732         return hyp
3733
3734     ## Private method
3735     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3736     def CompareArithmetic1D(self, hyp, args):
3737         if IsEqual(hyp.GetLength(1), args[0]):
3738             if IsEqual(hyp.GetLength(0), args[1]):
3739                 if hyp.GetReversedEdges() == args[2]:
3740                     if not args[2] or hyp.GetObjectEntry() == args[3]:
3741                         return True
3742         return False
3743
3744     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3745     #  @param start defines the length of the first segment
3746     #  @param end   defines the length of the last  segment
3747     #  @param reversedEdges is a list of edges to mesh using reversed orientation
3748     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3749     #                     the same parameters, else (default) - creates a new one
3750     #  @return an instance of StdMeshers_StartEndLength hypothesis
3751     #  @ingroup l3_hypos_1dhyps
3752     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3753         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3754             reversedEdges, UseExisting = [], reversedEdges
3755         entry = self.MainShapeEntry()
3756         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3757                               UseExisting=UseExisting,
3758                               CompareMethod=self.CompareStartEndLength)
3759         hyp.SetStartLength(start)
3760         hyp.SetEndLength(end)
3761         hyp.SetReversedEdges( reversedEdges )
3762         hyp.SetObjectEntry( entry )
3763         return hyp
3764
3765     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3766     def CompareStartEndLength(self, hyp, args):
3767         if IsEqual(hyp.GetLength(1), args[0]):
3768             if IsEqual(hyp.GetLength(0), args[1]):
3769                 if hyp.GetReversedEdges() == args[2]:
3770                     if not args[2] or hyp.GetObjectEntry() == args[3]:
3771                         return True
3772         return False
3773
3774     ## Defines "Deflection1D" hypothesis
3775     #  @param d for the deflection
3776     #  @param UseExisting if ==true - searches for an existing hypothesis created with
3777     #                     the same parameters, else (default) - create a new one
3778     #  @ingroup l3_hypos_1dhyps
3779     def Deflection1D(self, d, UseExisting=0):
3780         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3781                               CompareMethod=self.CompareDeflection1D)
3782         hyp.SetDeflection(d)
3783         return hyp
3784
3785     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3786     def CompareDeflection1D(self, hyp, args):
3787         return IsEqual(hyp.GetDeflection(), args[0])
3788
3789     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3790     #  the opposite side in case of quadrangular faces
3791     #  @ingroup l3_hypos_additi
3792     def Propagation(self):
3793         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3794
3795     ## Defines "AutomaticLength" hypothesis
3796     #  @param fineness for the fineness [0-1]
3797     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
3798     #                     same parameters, else (default) - create a new one
3799     #  @ingroup l3_hypos_1dhyps
3800     def AutomaticLength(self, fineness=0, UseExisting=0):
3801         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3802                               CompareMethod=self.CompareAutomaticLength)
3803         hyp.SetFineness( fineness )
3804         return hyp
3805
3806     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3807     def CompareAutomaticLength(self, hyp, args):
3808         return IsEqual(hyp.GetFineness(), args[0])
3809
3810     ## Defines "SegmentLengthAroundVertex" hypothesis
3811     #  @param length for the segment length
3812     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
3813     #         Any other integer value means that the hypothesis will be set on the
3814     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
3815     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
3816     #                   the same parameters, else (default) - creates a new one
3817     #  @ingroup l3_algos_segmarv
3818     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3819         import types
3820         store_geom = self.geom
3821         if type(vertex) is types.IntType:
3822             if vertex == 0 or vertex == 1:
3823                 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3824                 self.geom = vertex
3825                 pass
3826             pass
3827         else:
3828             self.geom = vertex
3829             pass
3830         ### 0D algorithm
3831         if self.geom is None:
3832             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3833         name = GetName(self.geom)
3834         if name == NO_NAME:
3835             piece = self.mesh.geom
3836             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3837             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3838         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3839         if algo is None:
3840             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3841             pass
3842         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3843         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3844         ###
3845         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3846                               CompareMethod=self.CompareLengthNearVertex)
3847         self.geom = store_geom
3848         hyp.SetLength( length )
3849         return hyp
3850
3851     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3852     #  @ingroup l3_algos_segmarv
3853     def CompareLengthNearVertex(self, hyp, args):
3854         return IsEqual(hyp.GetLength(), args[0])
3855
3856     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3857     #  If the 2D mesher sees that all boundary edges are quadratic,
3858     #  it generates quadratic faces, else it generates linear faces using
3859     #  medium nodes as if they are vertices.
3860     #  The 3D mesher generates quadratic volumes only if all boundary faces
3861     #  are quadratic, else it fails.
3862     #
3863     #  @ingroup l3_hypos_additi
3864     def QuadraticMesh(self):
3865         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3866         return hyp
3867
3868 # Public class: Mesh_CompositeSegment
3869 # --------------------------
3870
3871 ## Defines a segment 1D algorithm for discretization
3872 #
3873 #  @ingroup l3_algos_basic
3874 class Mesh_CompositeSegment(Mesh_Segment):
3875
3876     ## Private constructor.
3877     def __init__(self, mesh, geom=0):
3878         self.Create(mesh, geom, "CompositeSegment_1D")
3879
3880
3881 # Public class: Mesh_Segment_Python
3882 # ---------------------------------
3883
3884 ## Defines a segment 1D algorithm for discretization with python function
3885 #
3886 #  @ingroup l3_algos_basic
3887 class Mesh_Segment_Python(Mesh_Segment):
3888
3889     ## Private constructor.
3890     def __init__(self, mesh, geom=0):
3891         import Python1dPlugin
3892         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3893
3894     ## Defines "PythonSplit1D" hypothesis
3895     #  @param n for the number of segments that cut an edge
3896     #  @param func for the python function that calculates the length of all segments
3897     #  @param UseExisting if ==true - searches for the existing hypothesis created with
3898     #                     the same parameters, else (default) - creates a new one
3899     #  @ingroup l3_hypos_1dhyps
3900     def PythonSplit1D(self, n, func, UseExisting=0):
3901         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3902                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3903         hyp.SetNumberOfSegments(n)
3904         hyp.SetPythonLog10RatioFunction(func)
3905         return hyp
3906
3907     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3908     def ComparePythonSplit1D(self, hyp, args):
3909         #if hyp.GetNumberOfSegments() == args[0]:
3910         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
3911         #        return True
3912         return False
3913
3914 # Public class: Mesh_Triangle
3915 # ---------------------------
3916
3917 ## Defines a triangle 2D algorithm
3918 #
3919 #  @ingroup l3_algos_basic
3920 class Mesh_Triangle(Mesh_Algorithm):
3921
3922     # default values
3923     algoType = 0
3924     params = 0
3925
3926     _angleMeshS = 8
3927     _gradation  = 1.1
3928
3929     ## Private constructor.
3930     def __init__(self, mesh, algoType, geom=0):
3931         Mesh_Algorithm.__init__(self)
3932
3933         self.algoType = algoType
3934         if algoType == MEFISTO:
3935             self.Create(mesh, geom, "MEFISTO_2D")
3936             pass
3937         elif algoType == BLSURF:
3938             import BLSURFPlugin
3939             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3940             #self.SetPhysicalMesh() - PAL19680
3941         elif algoType == NETGEN:
3942             if noNETGENPlugin:
3943                 print "Warning: NETGENPlugin module unavailable"
3944                 pass
3945             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3946             pass
3947         elif algoType == NETGEN_2D:
3948             if noNETGENPlugin:
3949                 print "Warning: NETGENPlugin module unavailable"
3950                 pass
3951             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3952             pass
3953
3954     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3955     #  @param area for the maximum area of each triangle
3956     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
3957     #                     same parameters, else (default) - creates a new one
3958     #
3959     #  Only for algoType == MEFISTO || NETGEN_2D
3960     #  @ingroup l3_hypos_2dhyps
3961     def MaxElementArea(self, area, UseExisting=0):
3962         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3963             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3964                                   CompareMethod=self.CompareMaxElementArea)
3965         elif self.algoType == NETGEN:
3966             hyp = self.Parameters(SIMPLE)
3967         hyp.SetMaxElementArea(area)
3968         return hyp
3969
3970     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3971     def CompareMaxElementArea(self, hyp, args):
3972         return IsEqual(hyp.GetMaxElementArea(), args[0])
3973
3974     ## Defines "LengthFromEdges" hypothesis to build triangles
3975     #  based on the length of the edges taken from the wire
3976     #
3977     #  Only for algoType == MEFISTO || NETGEN_2D
3978     #  @ingroup l3_hypos_2dhyps
3979     def LengthFromEdges(self):
3980         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3981             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3982             return hyp
3983         elif self.algoType == NETGEN:
3984             hyp = self.Parameters(SIMPLE)
3985             hyp.LengthFromEdges()
3986             return hyp
3987
3988     ## Sets a way to define size of mesh elements to generate.
3989     #  @param thePhysicalMesh is: DefaultSize or Custom.
3990     #  @ingroup l3_hypos_blsurf
3991     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3992         # Parameter of BLSURF algo
3993         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3994
3995     ## Sets size of mesh elements to generate.
3996     #  @ingroup l3_hypos_blsurf
3997     def SetPhySize(self, theVal):
3998         # Parameter of BLSURF algo
3999         self.Parameters().SetPhySize(theVal)
4000
4001     ## Sets lower boundary of mesh element size (PhySize).
4002     #  @ingroup l3_hypos_blsurf
4003     def SetPhyMin(self, theVal=-1):
4004         #  Parameter of BLSURF algo
4005         self.Parameters().SetPhyMin(theVal)
4006
4007     ## Sets upper boundary of mesh element size (PhySize).
4008     #  @ingroup l3_hypos_blsurf
4009     def SetPhyMax(self, theVal=-1):
4010         #  Parameter of BLSURF algo
4011         self.Parameters().SetPhyMax(theVal)
4012
4013     ## Sets a way to define maximum angular deflection of mesh from CAD model.
4014     #  @param theGeometricMesh is: DefaultGeom or Custom
4015     #  @ingroup l3_hypos_blsurf
4016     def SetGeometricMesh(self, theGeometricMesh=0):
4017         #  Parameter of BLSURF algo
4018         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4019         self.params.SetGeometricMesh(theGeometricMesh)
4020
4021     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4022     #  @ingroup l3_hypos_blsurf
4023     def SetAngleMeshS(self, theVal=_angleMeshS):
4024         #  Parameter of BLSURF algo
4025         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4026         self.params.SetAngleMeshS(theVal)
4027
4028     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4029     #  @ingroup l3_hypos_blsurf
4030     def SetAngleMeshC(self, theVal=_angleMeshS):
4031         #  Parameter of BLSURF algo
4032         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4033         self.params.SetAngleMeshC(theVal)
4034
4035     ## Sets lower boundary of mesh element size computed to respect angular deflection.
4036     #  @ingroup l3_hypos_blsurf
4037     def SetGeoMin(self, theVal=-1):
4038         #  Parameter of BLSURF algo
4039         self.Parameters().SetGeoMin(theVal)
4040
4041     ## Sets upper boundary of mesh element size computed to respect angular deflection.
4042     #  @ingroup l3_hypos_blsurf
4043     def SetGeoMax(self, theVal=-1):
4044         #  Parameter of BLSURF algo
4045         self.Parameters().SetGeoMax(theVal)
4046
4047     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4048     #  @ingroup l3_hypos_blsurf
4049     def SetGradation(self, theVal=_gradation):
4050         #  Parameter of BLSURF algo
4051         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4052         self.params.SetGradation(theVal)
4053
4054     ## Sets topology usage way.
4055     # @param way defines how mesh conformity is assured <ul>
4056     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4057     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4058     #  @ingroup l3_hypos_blsurf
4059     def SetTopology(self, way):
4060         #  Parameter of BLSURF algo
4061         self.Parameters().SetTopology(way)
4062
4063     ## To respect geometrical edges or not.
4064     #  @ingroup l3_hypos_blsurf
4065     def SetDecimesh(self, toIgnoreEdges=False):
4066         #  Parameter of BLSURF algo
4067         self.Parameters().SetDecimesh(toIgnoreEdges)
4068
4069     ## Sets verbosity level in the range 0 to 100.
4070     #  @ingroup l3_hypos_blsurf
4071     def SetVerbosity(self, level):
4072         #  Parameter of BLSURF algo
4073         self.Parameters().SetVerbosity(level)
4074
4075     ## Sets advanced option value.
4076     #  @ingroup l3_hypos_blsurf
4077     def SetOptionValue(self, optionName, level):
4078         #  Parameter of BLSURF algo
4079         self.Parameters().SetOptionValue(optionName,level)
4080
4081     ## Sets QuadAllowed flag.
4082     #  Only for algoType == NETGEN || NETGEN_2D || BLSURF
4083     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
4084     def SetQuadAllowed(self, toAllow=True):
4085         if self.algoType == NETGEN_2D:
4086             if toAllow: # add QuadranglePreference
4087                 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4088             else:       # remove QuadranglePreference
4089                 for hyp in self.mesh.GetHypothesisList( self.geom ):
4090                     if hyp.GetName() == "QuadranglePreference":
4091                         self.mesh.RemoveHypothesis( self.geom, hyp )
4092                         pass
4093                     pass
4094                 pass
4095             return
4096         if self.Parameters():
4097             self.params.SetQuadAllowed(toAllow)
4098             return
4099
4100     ## Defines hypothesis having several parameters
4101     #
4102     #  @ingroup l3_hypos_netgen
4103     def Parameters(self, which=SOLE):
4104         if self.params:
4105             return self.params
4106         if self.algoType == NETGEN:
4107             if which == SIMPLE:
4108                 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4109                                               "libNETGENEngine.so", UseExisting=0)
4110             else:
4111                 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4112                                               "libNETGENEngine.so", UseExisting=0)
4113             return self.params
4114         elif self.algoType == MEFISTO:
4115             print "Mefisto algo support no multi-parameter hypothesis"
4116             return None
4117         elif self.algoType == NETGEN_2D:
4118             print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4119             print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4120             return None
4121         elif self.algoType == BLSURF:
4122             self.params = self.Hypothesis("BLSURF_Parameters", [],
4123                                           "libBLSURFEngine.so", UseExisting=0)
4124             return self.params
4125         else:
4126             print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4127         return None
4128
4129     ## Sets MaxSize
4130     #
4131     #  Only for algoType == NETGEN
4132     #  @ingroup l3_hypos_netgen
4133     def SetMaxSize(self, theSize):
4134         if self.Parameters():
4135             self.params.SetMaxSize(theSize)
4136
4137     ## Sets SecondOrder flag
4138     #
4139     #  Only for algoType == NETGEN
4140     #  @ingroup l3_hypos_netgen
4141     def SetSecondOrder(self, theVal):
4142         if self.Parameters():
4143             self.params.SetSecondOrder(theVal)
4144
4145     ## Sets Optimize flag
4146     #
4147     #  Only for algoType == NETGEN
4148     #  @ingroup l3_hypos_netgen
4149     def SetOptimize(self, theVal):
4150         if self.Parameters():
4151             self.params.SetOptimize(theVal)
4152
4153     ## Sets Fineness
4154     #  @param theFineness is:
4155     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4156     #
4157     #  Only for algoType == NETGEN
4158     #  @ingroup l3_hypos_netgen
4159     def SetFineness(self, theFineness):
4160         if self.Parameters():
4161             self.params.SetFineness(theFineness)
4162
4163     ## Sets GrowthRate
4164     #
4165     #  Only for algoType == NETGEN
4166     #  @ingroup l3_hypos_netgen
4167     def SetGrowthRate(self, theRate):
4168         if self.Parameters():
4169             self.params.SetGrowthRate(theRate)
4170
4171     ## Sets NbSegPerEdge
4172     #
4173     #  Only for algoType == NETGEN
4174     #  @ingroup l3_hypos_netgen
4175     def SetNbSegPerEdge(self, theVal):
4176         if self.Parameters():
4177             self.params.SetNbSegPerEdge(theVal)
4178
4179     ## Sets NbSegPerRadius
4180     #
4181     #  Only for algoType == NETGEN
4182     #  @ingroup l3_hypos_netgen
4183     def SetNbSegPerRadius(self, theVal):
4184         if self.Parameters():
4185             self.params.SetNbSegPerRadius(theVal)
4186
4187     ## Sets number of segments overriding value set by SetLocalLength()
4188     #
4189     #  Only for algoType == NETGEN
4190     #  @ingroup l3_hypos_netgen
4191     def SetNumberOfSegments(self, theVal):
4192         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4193
4194     ## Sets number of segments overriding value set by SetNumberOfSegments()
4195     #
4196     #  Only for algoType == NETGEN
4197     #  @ingroup l3_hypos_netgen
4198     def SetLocalLength(self, theVal):
4199         self.Parameters(SIMPLE).SetLocalLength(theVal)
4200
4201     pass
4202
4203
4204 # Public class: Mesh_Quadrangle
4205 # -----------------------------
4206
4207 ## Defines a quadrangle 2D algorithm
4208 #
4209 #  @ingroup l3_algos_basic
4210 class Mesh_Quadrangle(Mesh_Algorithm):
4211
4212     ## Private constructor.
4213     def __init__(self, mesh, geom=0):
4214         Mesh_Algorithm.__init__(self)
4215         self.Create(mesh, geom, "Quadrangle_2D")
4216
4217     ## Defines "QuadranglePreference" hypothesis, forcing construction
4218     #  of quadrangles if the number of nodes on the opposite edges is not the same
4219     #  while the total number of nodes on edges is even
4220     #
4221     #  @ingroup l3_hypos_additi
4222     def QuadranglePreference(self):
4223         hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4224                               CompareMethod=self.CompareEqualHyp)
4225         return hyp
4226
4227     ## Defines "TrianglePreference" hypothesis, forcing construction
4228     #  of triangles in the refinement area if the number of nodes
4229     #  on the opposite edges is not the same
4230     #
4231     #  @ingroup l3_hypos_additi
4232     def TrianglePreference(self):
4233         hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4234                               CompareMethod=self.CompareEqualHyp)
4235         return hyp
4236
4237 # Public class: Mesh_Tetrahedron
4238 # ------------------------------
4239
4240 ## Defines a tetrahedron 3D algorithm
4241 #
4242 #  @ingroup l3_algos_basic
4243 class Mesh_Tetrahedron(Mesh_Algorithm):
4244
4245     params = 0
4246     algoType = 0
4247
4248     ## Private constructor.
4249     def __init__(self, mesh, algoType, geom=0):
4250         Mesh_Algorithm.__init__(self)
4251
4252         if algoType == NETGEN:
4253             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4254             pass
4255
4256         elif algoType == FULL_NETGEN:
4257             if noNETGENPlugin:
4258                 print "Warning: NETGENPlugin module has not been imported."
4259             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4260             pass
4261
4262         elif algoType == GHS3D:
4263             import GHS3DPlugin
4264             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4265             pass
4266
4267         elif algoType == GHS3DPRL:
4268             import GHS3DPRLPlugin
4269             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4270             pass
4271
4272         self.algoType = algoType
4273
4274     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4275     #  @param vol for the maximum volume of each tetrahedron
4276     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4277     #                   the same parameters, else (default) - creates a new one
4278     #  @ingroup l3_hypos_maxvol
4279     def MaxElementVolume(self, vol, UseExisting=0):
4280         if self.algoType == NETGEN:
4281             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4282                                   CompareMethod=self.CompareMaxElementVolume)
4283             hyp.SetMaxElementVolume(vol)
4284             return hyp
4285         elif self.algoType == FULL_NETGEN:
4286             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4287         return None
4288
4289     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4290     def CompareMaxElementVolume(self, hyp, args):
4291         return IsEqual(hyp.GetMaxElementVolume(), args[0])
4292
4293     ## Defines hypothesis having several parameters
4294     #
4295     #  @ingroup l3_hypos_netgen
4296     def Parameters(self, which=SOLE):
4297         if self.params:
4298             return self.params
4299
4300         if self.algoType == FULL_NETGEN:
4301             if which == SIMPLE:
4302                 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4303                                               "libNETGENEngine.so", UseExisting=0)
4304             else:
4305                 self.params = self.Hypothesis("NETGEN_Parameters", [],
4306                                               "libNETGENEngine.so", UseExisting=0)
4307             return self.params
4308
4309         if self.algoType == GHS3D:
4310             self.params = self.Hypothesis("GHS3D_Parameters", [],
4311                                           "libGHS3DEngine.so", UseExisting=0)
4312             return self.params
4313
4314         if self.algoType == GHS3DPRL:
4315             self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4316                                           "libGHS3DPRLEngine.so", UseExisting=0)
4317             return self.params
4318
4319         print "Algo supports no multi-parameter hypothesis"
4320         return None
4321
4322     ## Sets MaxSize
4323     #  Parameter of FULL_NETGEN
4324     #  @ingroup l3_hypos_netgen
4325     def SetMaxSize(self, theSize):
4326         self.Parameters().SetMaxSize(theSize)
4327
4328     ## Sets SecondOrder flag
4329     #  Parameter of FULL_NETGEN
4330     #  @ingroup l3_hypos_netgen
4331     def SetSecondOrder(self, theVal):
4332         self.Parameters().SetSecondOrder(theVal)
4333
4334     ## Sets Optimize flag
4335     #  Parameter of FULL_NETGEN
4336     #  @ingroup l3_hypos_netgen
4337     def SetOptimize(self, theVal):
4338         self.Parameters().SetOptimize(theVal)
4339
4340     ## Sets Fineness
4341     #  @param theFineness is:
4342     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4343     #  Parameter of FULL_NETGEN
4344     #  @ingroup l3_hypos_netgen
4345     def SetFineness(self, theFineness):
4346         self.Parameters().SetFineness(theFineness)
4347
4348     ## Sets GrowthRate
4349     #  Parameter of FULL_NETGEN
4350     #  @ingroup l3_hypos_netgen
4351     def SetGrowthRate(self, theRate):
4352         self.Parameters().SetGrowthRate(theRate)
4353
4354     ## Sets NbSegPerEdge
4355     #  Parameter of FULL_NETGEN
4356     #  @ingroup l3_hypos_netgen
4357     def SetNbSegPerEdge(self, theVal):
4358         self.Parameters().SetNbSegPerEdge(theVal)
4359
4360     ## Sets NbSegPerRadius
4361     #  Parameter of FULL_NETGEN
4362     #  @ingroup l3_hypos_netgen
4363     def SetNbSegPerRadius(self, theVal):
4364         self.Parameters().SetNbSegPerRadius(theVal)
4365
4366     ## Sets number of segments overriding value set by SetLocalLength()
4367     #  Only for algoType == NETGEN_FULL
4368     #  @ingroup l3_hypos_netgen
4369     def SetNumberOfSegments(self, theVal):
4370         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4371
4372     ## Sets number of segments overriding value set by SetNumberOfSegments()
4373     #  Only for algoType == NETGEN_FULL
4374     #  @ingroup l3_hypos_netgen
4375     def SetLocalLength(self, theVal):
4376         self.Parameters(SIMPLE).SetLocalLength(theVal)
4377
4378     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4379     #  Overrides value set by LengthFromEdges()
4380     #  Only for algoType == NETGEN_FULL
4381     #  @ingroup l3_hypos_netgen
4382     def MaxElementArea(self, area):
4383         self.Parameters(SIMPLE).SetMaxElementArea(area)
4384
4385     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4386     #  Overrides value set by MaxElementArea()
4387     #  Only for algoType == NETGEN_FULL
4388     #  @ingroup l3_hypos_netgen
4389     def LengthFromEdges(self):
4390         self.Parameters(SIMPLE).LengthFromEdges()
4391
4392     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4393     #  Overrides value set by MaxElementVolume()
4394     #  Only for algoType == NETGEN_FULL
4395     #  @ingroup l3_hypos_netgen
4396     def LengthFromFaces(self):
4397         self.Parameters(SIMPLE).LengthFromFaces()
4398
4399     ## To mesh "holes" in a solid or not. Default is to mesh.
4400     #  @ingroup l3_hypos_ghs3dh
4401     def SetToMeshHoles(self, toMesh):
4402         #  Parameter of GHS3D
4403         self.Parameters().SetToMeshHoles(toMesh)
4404
4405     ## Set Optimization level:
4406     #   None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4407     #  Default is Medium_Optimization
4408     #  @ingroup l3_hypos_ghs3dh
4409     def SetOptimizationLevel(self, level):
4410         #  Parameter of GHS3D
4411         self.Parameters().SetOptimizationLevel(level)
4412
4413     ## Maximal size of memory to be used by the algorithm (in Megabytes).
4414     #  @ingroup l3_hypos_ghs3dh
4415     def SetMaximumMemory(self, MB):
4416         #  Advanced parameter of GHS3D
4417         self.Parameters().SetMaximumMemory(MB)
4418
4419     ## Initial size of memory to be used by the algorithm (in Megabytes) in
4420     #  automatic memory adjustment mode.
4421     #  @ingroup l3_hypos_ghs3dh
4422     def SetInitialMemory(self, MB):
4423         #  Advanced parameter of GHS3D
4424         self.Parameters().SetInitialMemory(MB)
4425
4426     ## Path to working directory.
4427     #  @ingroup l3_hypos_ghs3dh
4428     def SetWorkingDirectory(self, path):
4429         #  Advanced parameter of GHS3D
4430         self.Parameters().SetWorkingDirectory(path)
4431
4432     ## To keep working files or remove them. Log file remains in case of errors anyway.
4433     #  @ingroup l3_hypos_ghs3dh
4434     def SetKeepFiles(self, toKeep):
4435         #  Advanced parameter of GHS3D and GHS3DPRL
4436         self.Parameters().SetKeepFiles(toKeep)
4437
4438     ## To set verbose level [0-10]. <ul>
4439     #<li> 0 - no standard output,
4440     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4441     #     indicates when the final mesh is being saved. In addition the software
4442     #     gives indication regarding the CPU time.
4443     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4444     #     histogram of the skin mesh, quality statistics histogram together with
4445     #     the characteristics of the final mesh.</ul>
4446     #  @ingroup l3_hypos_ghs3dh
4447     def SetVerboseLevel(self, level):
4448         #  Advanced parameter of GHS3D
4449         self.Parameters().SetVerboseLevel(level)
4450
4451     ## To create new nodes.
4452     #  @ingroup l3_hypos_ghs3dh
4453     def SetToCreateNewNodes(self, toCreate):
4454         #  Advanced parameter of GHS3D
4455         self.Parameters().SetToCreateNewNodes(toCreate)
4456
4457     ## To use boundary recovery version which tries to create mesh on a very poor
4458     #  quality surface mesh.
4459     #  @ingroup l3_hypos_ghs3dh
4460     def SetToUseBoundaryRecoveryVersion(self, toUse):
4461         #  Advanced parameter of GHS3D
4462         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4463
4464     ## Sets command line option as text.
4465     #  @ingroup l3_hypos_ghs3dh
4466     def SetTextOption(self, option):
4467         #  Advanced parameter of GHS3D
4468         self.Parameters().SetTextOption(option)
4469
4470     ## Sets MED files name and path.
4471     def SetMEDName(self, value):
4472         self.Parameters().SetMEDName(value)
4473
4474     ## Sets the number of partition of the initial mesh
4475     def SetNbPart(self, value):
4476         self.Parameters().SetNbPart(value)
4477
4478     ## When big mesh, start tepal in background
4479     def SetBackground(self, value):
4480         self.Parameters().SetBackground(value)
4481
4482 # Public class: Mesh_Hexahedron
4483 # ------------------------------
4484
4485 ## Defines a hexahedron 3D algorithm
4486 #
4487 #  @ingroup l3_algos_basic
4488 class Mesh_Hexahedron(Mesh_Algorithm):
4489
4490     params = 0
4491     algoType = 0
4492
4493     ## Private constructor.
4494     def __init__(self, mesh, algoType=Hexa, geom=0):
4495         Mesh_Algorithm.__init__(self)
4496
4497         self.algoType = algoType
4498
4499         if algoType == Hexa:
4500             self.Create(mesh, geom, "Hexa_3D")
4501             pass
4502
4503         elif algoType == Hexotic:
4504             import HexoticPlugin
4505             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4506             pass
4507
4508     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4509     #  @ingroup l3_hypos_hexotic
4510     def MinMaxQuad(self, min=3, max=8, quad=True):
4511         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4512                                       UseExisting=0)
4513         self.params.SetHexesMinLevel(min)
4514         self.params.SetHexesMaxLevel(max)
4515         self.params.SetHexoticQuadrangles(quad)
4516         return self.params
4517
4518 # Deprecated, only for compatibility!
4519 # Public class: Mesh_Netgen
4520 # ------------------------------
4521
4522 ## Defines a NETGEN-based 2D or 3D algorithm
4523 #  that needs no discrete boundary (i.e. independent)
4524 #
4525 #  This class is deprecated, only for compatibility!
4526 #
4527 #  More details.
4528 #  @ingroup l3_algos_basic
4529 class Mesh_Netgen(Mesh_Algorithm):
4530
4531     is3D = 0
4532
4533     ## Private constructor.
4534     def __init__(self, mesh, is3D, geom=0):
4535         Mesh_Algorithm.__init__(self)
4536
4537         if noNETGENPlugin:
4538             print "Warning: NETGENPlugin module has not been imported."
4539
4540         self.is3D = is3D
4541         if is3D:
4542             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4543             pass
4544
4545         else:
4546             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4547             pass
4548
4549     ## Defines the hypothesis containing parameters of the algorithm
4550     def Parameters(self):
4551         if self.is3D:
4552             hyp = self.Hypothesis("NETGEN_Parameters", [],
4553                                   "libNETGENEngine.so", UseExisting=0)
4554         else:
4555             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4556                                   "libNETGENEngine.so", UseExisting=0)
4557         return hyp
4558
4559 # Public class: Mesh_Projection1D
4560 # ------------------------------
4561
4562 ## Defines a projection 1D algorithm
4563 #  @ingroup l3_algos_proj
4564 #
4565 class Mesh_Projection1D(Mesh_Algorithm):
4566
4567     ## Private constructor.
4568     def __init__(self, mesh, geom=0):
4569         Mesh_Algorithm.__init__(self)
4570         self.Create(mesh, geom, "Projection_1D")
4571
4572     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4573     #  a mesh pattern is taken, and, optionally, the association of vertices
4574     #  between the source edge and a target edge (to which a hypothesis is assigned)
4575     #  @param edge from which nodes distribution is taken
4576     #  @param mesh from which nodes distribution is taken (optional)
4577     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4578     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4579     #  to associate with \a srcV (optional)
4580     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4581     #                     the same parameters, else (default) - creates a new one
4582     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4583         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4584                               UseExisting=0)
4585                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4586         hyp.SetSourceEdge( edge )
4587         if not mesh is None and isinstance(mesh, Mesh):
4588             mesh = mesh.GetMesh()
4589         hyp.SetSourceMesh( mesh )
4590         hyp.SetVertexAssociation( srcV, tgtV )
4591         return hyp
4592
4593     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4594     #def CompareSourceEdge(self, hyp, args):
4595     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4596     #    return False
4597
4598
4599 # Public class: Mesh_Projection2D
4600 # ------------------------------
4601
4602 ## Defines a projection 2D algorithm
4603 #  @ingroup l3_algos_proj
4604 #
4605 class Mesh_Projection2D(Mesh_Algorithm):
4606
4607     ## Private constructor.
4608     def __init__(self, mesh, geom=0):
4609         Mesh_Algorithm.__init__(self)
4610         self.Create(mesh, geom, "Projection_2D")
4611
4612     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4613     #  a mesh pattern is taken, and, optionally, the association of vertices
4614     #  between the source face and the target face (to which a hypothesis is assigned)
4615     #  @param face from which the mesh pattern is taken
4616     #  @param mesh from which the mesh pattern is taken (optional)
4617     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4618     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4619     #               to associate with \a srcV1 (optional)
4620     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4621     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4622     #               to associate with \a srcV2 (optional)
4623     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
4624     #                     the same parameters, else (default) - forces the creation a new one
4625     #
4626     #  Note: all association vertices must belong to one edge of a face
4627     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4628                    srcV2=None, tgtV2=None, UseExisting=0):
4629         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4630                               UseExisting=0)
4631                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4632         hyp.SetSourceFace( face )
4633         if not mesh is None and isinstance(mesh, Mesh):
4634             mesh = mesh.GetMesh()
4635         hyp.SetSourceMesh( mesh )
4636         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4637         return hyp
4638
4639     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4640     #def CompareSourceFace(self, hyp, args):
4641     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4642     #    return False
4643
4644 # Public class: Mesh_Projection3D
4645 # ------------------------------
4646
4647 ## Defines a projection 3D algorithm
4648 #  @ingroup l3_algos_proj
4649 #
4650 class Mesh_Projection3D(Mesh_Algorithm):
4651
4652     ## Private constructor.
4653     def __init__(self, mesh, geom=0):
4654         Mesh_Algorithm.__init__(self)
4655         self.Create(mesh, geom, "Projection_3D")
4656
4657     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4658     #  the mesh pattern is taken, and, optionally, the  association of vertices
4659     #  between the source and the target solid  (to which a hipothesis is assigned)
4660     #  @param solid from where the mesh pattern is taken
4661     #  @param mesh from where the mesh pattern is taken (optional)
4662     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4663     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4664     #  to associate with \a srcV1 (optional)
4665     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4666     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4667     #  to associate with \a srcV2 (optional)
4668     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
4669     #                     the same parameters, else (default) - creates a new one
4670     #
4671     #  Note: association vertices must belong to one edge of a solid
4672     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4673                       srcV2=0, tgtV2=0, UseExisting=0):
4674         hyp = self.Hypothesis("ProjectionSource3D",
4675                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4676                               UseExisting=0)
4677                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4678         hyp.SetSource3DShape( solid )
4679         if not mesh is None and isinstance(mesh, Mesh):
4680             mesh = mesh.GetMesh()
4681         hyp.SetSourceMesh( mesh )
4682         if srcV1 and srcV2 and tgtV1 and tgtV2:
4683             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4684         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4685         return hyp
4686
4687     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4688     #def CompareSourceShape3D(self, hyp, args):
4689     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4690     #    return False
4691
4692
4693 # Public class: Mesh_Prism
4694 # ------------------------
4695
4696 ## Defines a 3D extrusion algorithm
4697 #  @ingroup l3_algos_3dextr
4698 #
4699 class Mesh_Prism3D(Mesh_Algorithm):
4700
4701     ## Private constructor.
4702     def __init__(self, mesh, geom=0):
4703         Mesh_Algorithm.__init__(self)
4704         self.Create(mesh, geom, "Prism_3D")
4705
4706 # Public class: Mesh_RadialPrism
4707 # -------------------------------
4708
4709 ## Defines a Radial Prism 3D algorithm
4710 #  @ingroup l3_algos_radialp
4711 #
4712 class Mesh_RadialPrism3D(Mesh_Algorithm):
4713
4714     ## Private constructor.
4715     def __init__(self, mesh, geom=0):
4716         Mesh_Algorithm.__init__(self)
4717         self.Create(mesh, geom, "RadialPrism_3D")
4718
4719         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4720         self.nbLayers = None
4721
4722     ## Return 3D hypothesis holding the 1D one
4723     def Get3DHypothesis(self):
4724         return self.distribHyp
4725
4726     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4727     #  hypothesis. Returns the created hypothesis
4728     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4729         #print "OwnHypothesis",hypType
4730         if not self.nbLayers is None:
4731             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4732             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4733         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4734         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4735         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4736         self.distribHyp.SetLayerDistribution( hyp )
4737         return hyp
4738
4739     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4740     #  prisms to build between the inner and outer shells
4741     #  @param n number of layers
4742     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4743     #                     the same parameters, else (default) - creates a new one
4744     def NumberOfLayers(self, n, UseExisting=0):
4745         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4746         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4747                                         CompareMethod=self.CompareNumberOfLayers)
4748         self.nbLayers.SetNumberOfLayers( n )
4749         return self.nbLayers
4750
4751     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4752     def CompareNumberOfLayers(self, hyp, args):
4753         return IsEqual(hyp.GetNumberOfLayers(), args[0])
4754
4755     ## Defines "LocalLength" hypothesis, specifying the segment length
4756     #  to build between the inner and the outer shells
4757     #  @param l the length of segments
4758     #  @param p the precision of rounding
4759     def LocalLength(self, l, p=1e-07):
4760         hyp = self.OwnHypothesis("LocalLength", [l,p])
4761         hyp.SetLength(l)
4762         hyp.SetPrecision(p)
4763         return hyp
4764
4765     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4766     #  prisms to build between the inner and the outer shells.
4767     #  @param n the number of layers
4768     #  @param s the scale factor (optional)
4769     def NumberOfSegments(self, n, s=[]):
4770         if s == []:
4771             hyp = self.OwnHypothesis("NumberOfSegments", [n])
4772         else:
4773             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4774             hyp.SetDistrType( 1 )
4775             hyp.SetScaleFactor(s)
4776         hyp.SetNumberOfSegments(n)
4777         return hyp
4778
4779     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4780     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
4781     #  @param start  the length of the first segment
4782     #  @param end    the length of the last  segment
4783     def Arithmetic1D(self, start, end ):
4784         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4785         hyp.SetLength(start, 1)
4786         hyp.SetLength(end  , 0)
4787         return hyp
4788
4789     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4790     #  to build between the inner and the outer shells as geometric length increasing
4791     #  @param start for the length of the first segment
4792     #  @param end   for the length of the last  segment
4793     def StartEndLength(self, start, end):
4794         hyp = self.OwnHypothesis("StartEndLength", [start, end])
4795         hyp.SetLength(start, 1)
4796         hyp.SetLength(end  , 0)
4797         return hyp
4798
4799     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4800     #  to build between the inner and outer shells
4801     #  @param fineness defines the quality of the mesh within the range [0-1]
4802     def AutomaticLength(self, fineness=0):
4803         hyp = self.OwnHypothesis("AutomaticLength")
4804         hyp.SetFineness( fineness )
4805         return hyp
4806
4807 # Private class: Mesh_UseExisting
4808 # -------------------------------
4809 class Mesh_UseExisting(Mesh_Algorithm):
4810
4811     def __init__(self, dim, mesh, geom=0):
4812         if dim == 1:
4813             self.Create(mesh, geom, "UseExisting_1D")
4814         else:
4815             self.Create(mesh, geom, "UseExisting_2D")
4816
4817
4818 import salome_notebook
4819 notebook = salome_notebook.notebook
4820
4821 ##Return values of the notebook variables
4822 def ParseParameters(last, nbParams,nbParam, value):
4823     result = None
4824     strResult = ""
4825     counter = 0
4826     listSize = len(last)
4827     for n in range(0,nbParams):
4828         if n+1 != nbParam:
4829             if counter < listSize:
4830                 strResult = strResult + last[counter]
4831             else:
4832                 strResult = strResult + ""
4833         else:
4834             if isinstance(value, str):
4835                 if notebook.isVariable(value):
4836                     result = notebook.get(value)
4837                     strResult=strResult+value
4838                 else:
4839                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4840             else:
4841                 strResult=strResult+str(value)
4842                 result = value
4843         if nbParams - 1 != counter:
4844             strResult=strResult+var_separator #":"
4845         counter = counter+1
4846     return result, strResult
4847
4848 #Wrapper class for StdMeshers_LocalLength hypothesis
4849 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4850
4851     ## Set Length parameter value
4852     #  @param length numerical value or name of variable from notebook
4853     def SetLength(self, length):
4854         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4855         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4856         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4857
4858    ## Set Precision parameter value
4859    #  @param precision numerical value or name of variable from notebook
4860     def SetPrecision(self, precision):
4861         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4862         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4863         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4864
4865 #Registering the new proxy for LocalLength
4866 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4867
4868
4869 #Wrapper class for StdMeshers_LayerDistribution hypothesis
4870 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
4871     
4872     def SetLayerDistribution(self, hypo):
4873         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
4874         hypo.ClearParameters();
4875         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
4876
4877 #Registering the new proxy for LayerDistribution
4878 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
4879
4880 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4881 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4882     
4883     ## Set Length parameter value
4884     #  @param length numerical value or name of variable from notebook    
4885     def SetLength(self, length):
4886         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4887         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4888         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4889
4890 #Registering the new proxy for SegmentLengthAroundVertex
4891 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4892
4893
4894 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4895 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4896     
4897     ## Set Length parameter value
4898     #  @param length   numerical value or name of variable from notebook
4899     #  @param isStart  true is length is Start Length, otherwise false
4900     def SetLength(self, length, isStart):
4901         nb = 2
4902         if isStart:
4903             nb = 1
4904         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4905         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4906         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4907         
4908 #Registering the new proxy for Arithmetic1D
4909 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4910
4911 #Wrapper class for StdMeshers_Deflection1D hypothesis
4912 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4913     
4914     ## Set Deflection parameter value
4915     #  @param deflection numerical value or name of variable from notebook    
4916     def SetDeflection(self, deflection):
4917         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4918         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4919         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4920
4921 #Registering the new proxy for Deflection1D
4922 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4923
4924 #Wrapper class for StdMeshers_StartEndLength hypothesis
4925 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4926     
4927     ## Set Length parameter value
4928     #  @param length  numerical value or name of variable from notebook
4929     #  @param isStart true is length is Start Length, otherwise false
4930     def SetLength(self, length, isStart):
4931         nb = 2
4932         if isStart:
4933             nb = 1
4934         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4935         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4936         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4937         
4938 #Registering the new proxy for StartEndLength
4939 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4940
4941 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4942 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4943     
4944     ## Set Max Element Area parameter value
4945     #  @param area  numerical value or name of variable from notebook
4946     def SetMaxElementArea(self, area):
4947         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4948         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4949         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4950         
4951 #Registering the new proxy for MaxElementArea
4952 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4953
4954
4955 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
4956 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
4957     
4958     ## Set Max Element Volume parameter value
4959     #  @param area  numerical value or name of variable from notebook
4960     def SetMaxElementVolume(self, volume):
4961         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
4962         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
4963         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
4964         
4965 #Registering the new proxy for MaxElementVolume
4966 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
4967
4968
4969 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4970 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4971     
4972     ## Set Number Of Layers parameter value
4973     #  @param nbLayers  numerical value or name of variable from notebook
4974     def SetNumberOfLayers(self, nbLayers):
4975         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4976         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4977         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4978         
4979 #Registering the new proxy for NumberOfLayers
4980 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4981
4982 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4983 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4984     
4985     ## Set Number Of Segments parameter value
4986     #  @param nbSeg numerical value or name of variable from notebook
4987     def SetNumberOfSegments(self, nbSeg):
4988         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4989         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4990         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4991         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4992         
4993     ## Set Scale Factor parameter value
4994     #  @param factor numerical value or name of variable from notebook
4995     def SetScaleFactor(self, factor):
4996         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4997         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4998         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4999         
5000 #Registering the new proxy for NumberOfSegments
5001 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5002
5003
5004 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5005 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5006
5007     ## Set Max Size parameter value
5008     #  @param maxsize numerical value or name of variable from notebook
5009     def SetMaxSize(self, maxsize):
5010         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5011         maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5012         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5013         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5014         
5015     ## Set Growth Rate parameter value
5016     #  @param value  numerical value or name of variable from notebook
5017     def SetGrowthRate(self, value):
5018         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5019         value, parameters = ParseParameters(lastParameters,4,2,value)
5020         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5021         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5022         
5023     ## Set Number of Segments per Edge parameter value
5024     #  @param value  numerical value or name of variable from notebook
5025     def SetNbSegPerEdge(self, value):
5026         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5027         value, parameters = ParseParameters(lastParameters,4,3,value)
5028         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5029         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5030         
5031     ## Set Number of Segments per Radius parameter value
5032     #  @param value  numerical value or name of variable from notebook
5033     def SetNbSegPerRadius(self, value):
5034         lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5035         value, parameters = ParseParameters(lastParameters,4,4,value)
5036         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5037         NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5038         
5039 #Registering the new proxy for NETGENPlugin_Hypothesis
5040 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5041
5042
5043 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5044 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5045     pass
5046
5047 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5048 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5049
5050 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5051 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5052     
5053     ## Set Number of Segments parameter value
5054     #  @param nbSeg numerical value or name of variable from notebook
5055     def SetNumberOfSegments(self, nbSeg):
5056         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5057         nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5058         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5059         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5060
5061     ## Set Local Length parameter value
5062     #  @param length numerical value or name of variable from notebook
5063     def SetLocalLength(self, length):
5064         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5065         length, parameters = ParseParameters(lastParameters,2,1,length)
5066         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5067         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5068
5069     ## Set Max Element Area parameter value
5070     #  @param area numerical value or name of variable from notebook    
5071     def SetMaxElementArea(self, area):
5072         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5073         area, parameters = ParseParameters(lastParameters,2,2,area)
5074         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5075         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5076
5077     def LengthFromEdges(self):
5078         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5079         value = 0;
5080         value, parameters = ParseParameters(lastParameters,2,2,value)
5081         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5082         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5083         
5084 #Registering the new proxy for NETGEN_SimpleParameters_2D
5085 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5086
5087
5088 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5089 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5090     ## Set Max Element Volume parameter value
5091     #  @param volume numerical value or name of variable from notebook    
5092     def SetMaxElementVolume(self, volume):
5093         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5094         volume, parameters = ParseParameters(lastParameters,3,3,volume)
5095         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5096         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5097
5098     def LengthFromFaces(self):
5099         lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5100         value = 0;
5101         value, parameters = ParseParameters(lastParameters,3,3,value)
5102         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5103         NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5104         
5105 #Registering the new proxy for NETGEN_SimpleParameters_3D
5106 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5107
5108 class Pattern(SMESH._objref_SMESH_Pattern):
5109
5110     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5111         flag = False
5112         if isinstance(theNodeIndexOnKeyPoint1,str):
5113             flag = True
5114         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5115         if flag:
5116             theNodeIndexOnKeyPoint1 -= 1
5117         theMesh.SetParameters(Parameters)
5118         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5119
5120     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5121         flag0 = False
5122         flag1 = False
5123         if isinstance(theNode000Index,str):
5124             flag0 = True
5125         if isinstance(theNode001Index,str):
5126             flag1 = True
5127         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5128         if flag0:
5129             theNode000Index -= 1
5130         if flag1:
5131             theNode001Index -= 1
5132         theMesh.SetParameters(Parameters)
5133         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5134
5135 #Registering the new proxy for Pattern
5136 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)