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