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