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