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