Salome HOME
0020746: EDF 1274 SMESH : MergeAllNodesButNodesFromGroup feature
[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             elemType = SMESH.ALL
2819             if elements: elemType = self.GetElementType( elements[0], iselem=True)
2820             elements = self.editor.MakeIDSource(elements, elemType)
2821         mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
2822                                                    toCopyElements,toCopyExistingBondary)
2823         if mesh: mesh = self.smeshpyD.Mesh(mesh)
2824         return mesh, group
2825
2826     ## Renumber mesh nodes
2827     #  @ingroup l2_modif_renumber
2828     def RenumberNodes(self):
2829         self.editor.RenumberNodes()
2830
2831     ## Renumber mesh elements
2832     #  @ingroup l2_modif_renumber
2833     def RenumberElements(self):
2834         self.editor.RenumberElements()
2835
2836     ## Generates new elements by rotation of the elements around the axis
2837     #  @param IDsOfElements the list of ids of elements to sweep
2838     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2839     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2840     #  @param NbOfSteps the number of steps
2841     #  @param Tolerance tolerance
2842     #  @param MakeGroups forces the generation of new groups from existing ones
2843     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2844     #                    of all steps, else - size of each step
2845     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2846     #  @ingroup l2_modif_extrurev
2847     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2848                       MakeGroups=False, TotalAngle=False):
2849         flag = False
2850         if isinstance(AngleInRadians,str):
2851             flag = True
2852         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2853         if flag:
2854             AngleInRadians = DegreesToRadians(AngleInRadians)
2855         if IDsOfElements == []:
2856             IDsOfElements = self.GetElementsId()
2857         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2858             Axis = self.smeshpyD.GetAxisStruct(Axis)
2859         Axis,AxisParameters = ParseAxisStruct(Axis)
2860         if TotalAngle and NbOfSteps:
2861             AngleInRadians /= NbOfSteps
2862         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2863         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2864         self.mesh.SetParameters(Parameters)
2865         if MakeGroups:
2866             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2867                                                        AngleInRadians, NbOfSteps, Tolerance)
2868         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2869         return []
2870
2871     ## Generates new elements by rotation of the elements of object around the axis
2872     #  @param theObject object which elements should be sweeped
2873     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2874     #  @param AngleInRadians the angle of Rotation
2875     #  @param NbOfSteps number of steps
2876     #  @param Tolerance tolerance
2877     #  @param MakeGroups forces the generation of new groups from existing ones
2878     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2879     #                    of all steps, else - size of each step
2880     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2881     #  @ingroup l2_modif_extrurev
2882     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2883                             MakeGroups=False, TotalAngle=False):
2884         flag = False
2885         if isinstance(AngleInRadians,str):
2886             flag = True
2887         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2888         if flag:
2889             AngleInRadians = DegreesToRadians(AngleInRadians)
2890         if ( isinstance( theObject, Mesh )):
2891             theObject = theObject.GetMesh()
2892         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2893             Axis = self.smeshpyD.GetAxisStruct(Axis)
2894         Axis,AxisParameters = ParseAxisStruct(Axis)
2895         if TotalAngle and NbOfSteps:
2896             AngleInRadians /= NbOfSteps
2897         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2898         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2899         self.mesh.SetParameters(Parameters)
2900         if MakeGroups:
2901             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2902                                                              NbOfSteps, Tolerance)
2903         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2904         return []
2905
2906     ## Generates new elements by rotation of the elements of object around the axis
2907     #  @param theObject object which elements should be sweeped
2908     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2909     #  @param AngleInRadians the angle of Rotation
2910     #  @param NbOfSteps number of steps
2911     #  @param Tolerance tolerance
2912     #  @param MakeGroups forces the generation of new groups from existing ones
2913     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2914     #                    of all steps, else - size of each step
2915     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2916     #  @ingroup l2_modif_extrurev
2917     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2918                               MakeGroups=False, TotalAngle=False):
2919         flag = False
2920         if isinstance(AngleInRadians,str):
2921             flag = True
2922         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2923         if flag:
2924             AngleInRadians = DegreesToRadians(AngleInRadians)
2925         if ( isinstance( theObject, Mesh )):
2926             theObject = theObject.GetMesh()
2927         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2928             Axis = self.smeshpyD.GetAxisStruct(Axis)
2929         Axis,AxisParameters = ParseAxisStruct(Axis)
2930         if TotalAngle and NbOfSteps:
2931             AngleInRadians /= NbOfSteps
2932         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2933         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2934         self.mesh.SetParameters(Parameters)
2935         if MakeGroups:
2936             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2937                                                                NbOfSteps, Tolerance)
2938         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2939         return []
2940
2941     ## Generates new elements by rotation of the elements of object around the axis
2942     #  @param theObject object which elements should be sweeped
2943     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
2944     #  @param AngleInRadians the angle of Rotation
2945     #  @param NbOfSteps number of steps
2946     #  @param Tolerance tolerance
2947     #  @param MakeGroups forces the generation of new groups from existing ones
2948     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2949     #                    of all steps, else - size of each step
2950     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2951     #  @ingroup l2_modif_extrurev
2952     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2953                               MakeGroups=False, TotalAngle=False):
2954         flag = False
2955         if isinstance(AngleInRadians,str):
2956             flag = True
2957         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2958         if flag:
2959             AngleInRadians = DegreesToRadians(AngleInRadians)
2960         if ( isinstance( theObject, Mesh )):
2961             theObject = theObject.GetMesh()
2962         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2963             Axis = self.smeshpyD.GetAxisStruct(Axis)
2964         Axis,AxisParameters = ParseAxisStruct(Axis)
2965         if TotalAngle and NbOfSteps:
2966             AngleInRadians /= NbOfSteps
2967         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2968         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2969         self.mesh.SetParameters(Parameters)
2970         if MakeGroups:
2971             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2972                                                              NbOfSteps, Tolerance)
2973         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2974         return []
2975
2976     ## Generates new elements by extrusion of the elements with given ids
2977     #  @param IDsOfElements the list of elements ids for extrusion
2978     #  @param StepVector vector, defining the direction and value of extrusion
2979     #  @param NbOfSteps the number of steps
2980     #  @param MakeGroups forces the generation of new groups from existing ones
2981     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2982     #  @ingroup l2_modif_extrurev
2983     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2984         if IDsOfElements == []:
2985             IDsOfElements = self.GetElementsId()
2986         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2987             StepVector = self.smeshpyD.GetDirStruct(StepVector)
2988         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2989         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2990         Parameters = StepVectorParameters + var_separator + Parameters
2991         self.mesh.SetParameters(Parameters)
2992         if MakeGroups:
2993             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2994         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2995         return []
2996
2997     ## Generates new elements by extrusion of the elements with given ids
2998     #  @param IDsOfElements is ids of elements
2999     #  @param StepVector vector, defining the direction and value of extrusion
3000     #  @param NbOfSteps the number of steps
3001     #  @param ExtrFlags sets flags for extrusion
3002     #  @param SewTolerance uses for comparing locations of nodes if flag
3003     #         EXTRUSION_FLAG_SEW is set
3004     #  @param MakeGroups forces the generation of new groups from existing ones
3005     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3006     #  @ingroup l2_modif_extrurev
3007     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3008                           ExtrFlags, SewTolerance, MakeGroups=False):
3009         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3010             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3011         if MakeGroups:
3012             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3013                                                            ExtrFlags, SewTolerance)
3014         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3015                                       ExtrFlags, SewTolerance)
3016         return []
3017
3018     ## Generates new elements by extrusion of the elements which belong to the object
3019     #  @param theObject the object which elements should be processed
3020     #  @param StepVector vector, defining the direction and value of extrusion
3021     #  @param NbOfSteps the number of steps
3022     #  @param MakeGroups forces the generation of new groups from existing ones
3023     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3024     #  @ingroup l2_modif_extrurev
3025     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3026         if ( isinstance( theObject, Mesh )):
3027             theObject = theObject.GetMesh()
3028         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3029             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3030         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3031         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3032         Parameters = StepVectorParameters + var_separator + Parameters
3033         self.mesh.SetParameters(Parameters)
3034         if MakeGroups:
3035             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3036         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3037         return []
3038
3039     ## Generates new elements by extrusion of the elements which belong to the object
3040     #  @param theObject object which elements should be processed
3041     #  @param StepVector vector, defining the direction and value of extrusion
3042     #  @param NbOfSteps the number of steps
3043     #  @param MakeGroups to generate new groups from existing ones
3044     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3045     #  @ingroup l2_modif_extrurev
3046     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3047         if ( isinstance( theObject, Mesh )):
3048             theObject = theObject.GetMesh()
3049         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3050             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3051         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3052         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3053         Parameters = StepVectorParameters + var_separator + Parameters
3054         self.mesh.SetParameters(Parameters)
3055         if MakeGroups:
3056             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3057         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3058         return []
3059
3060     ## Generates new elements by extrusion of the elements which belong to the object
3061     #  @param theObject object which elements should be processed
3062     #  @param StepVector vector, defining the direction and value of extrusion
3063     #  @param NbOfSteps the number of steps
3064     #  @param MakeGroups forces the generation of new groups from existing ones
3065     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3066     #  @ingroup l2_modif_extrurev
3067     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3068         if ( isinstance( theObject, Mesh )):
3069             theObject = theObject.GetMesh()
3070         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3071             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3072         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3073         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3074         Parameters = StepVectorParameters + var_separator + Parameters
3075         self.mesh.SetParameters(Parameters)
3076         if MakeGroups:
3077             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3078         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3079         return []
3080
3081
3082
3083     ## Generates new elements by extrusion of the given elements
3084     #  The path of extrusion must be a meshed edge.
3085     #  @param Base mesh or list of ids of elements for extrusion
3086     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3087     #  @param NodeStart the start node from Path. Defines the direction of extrusion
3088     #  @param HasAngles allows the shape to be rotated around the path
3089     #                   to get the resulting mesh in a helical fashion
3090     #  @param Angles list of angles in radians
3091     #  @param LinearVariation forces the computation of rotation angles as linear
3092     #                         variation of the given Angles along path steps
3093     #  @param HasRefPoint allows using the reference point
3094     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3095     #         The User can specify any point as the Reference Point.
3096     #  @param MakeGroups forces the generation of new groups from existing ones
3097     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
3098     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3099     #          only SMESH::Extrusion_Error otherwise
3100     #  @ingroup l2_modif_extrurev
3101     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3102                             HasAngles, Angles, LinearVariation,
3103                             HasRefPoint, RefPoint, MakeGroups, ElemType):
3104         Angles,AnglesParameters = ParseAngles(Angles)
3105         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3106         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3107             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3108             pass
3109         Parameters = AnglesParameters + var_separator + RefPointParameters
3110         self.mesh.SetParameters(Parameters)
3111
3112         if isinstance(Base,list):
3113             IDsOfElements = []
3114             if Base == []: IDsOfElements = self.GetElementsId()
3115             else: IDsOfElements = Base
3116             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3117                                                    HasAngles, Angles, LinearVariation,
3118                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
3119         else:
3120             if isinstance(Base,Mesh):
3121                 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3122                                                           HasAngles, Angles, LinearVariation,
3123                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
3124             else:
3125                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3126
3127
3128     ## Generates new elements by extrusion of the given elements
3129     #  The path of extrusion must be a meshed edge.
3130     #  @param IDsOfElements ids of elements
3131     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3132     #  @param PathShape shape(edge) defines the sub-mesh for the path
3133     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3134     #  @param HasAngles allows the shape to be rotated around the path
3135     #                   to get the resulting mesh in a helical fashion
3136     #  @param Angles list of angles in radians
3137     #  @param HasRefPoint allows using the reference point
3138     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3139     #         The User can specify any point as the Reference Point.
3140     #  @param MakeGroups forces the generation of new groups from existing ones
3141     #  @param LinearVariation forces the computation of rotation angles as linear
3142     #                         variation of the given Angles along path steps
3143     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3144     #          only SMESH::Extrusion_Error otherwise
3145     #  @ingroup l2_modif_extrurev
3146     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3147                            HasAngles, Angles, HasRefPoint, RefPoint,
3148                            MakeGroups=False, LinearVariation=False):
3149         Angles,AnglesParameters = ParseAngles(Angles)
3150         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3151         if IDsOfElements == []:
3152             IDsOfElements = self.GetElementsId()
3153         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3154             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3155             pass
3156         if ( isinstance( PathMesh, Mesh )):
3157             PathMesh = PathMesh.GetMesh()
3158         if HasAngles and Angles and LinearVariation:
3159             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3160             pass
3161         Parameters = AnglesParameters + var_separator + RefPointParameters
3162         self.mesh.SetParameters(Parameters)
3163         if MakeGroups:
3164             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3165                                                             PathShape, NodeStart, HasAngles,
3166                                                             Angles, HasRefPoint, RefPoint)
3167         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3168                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3169
3170     ## Generates new elements by extrusion of the elements which belong to the object
3171     #  The path of extrusion must be a meshed edge.
3172     #  @param theObject the object which elements should be processed
3173     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3174     #  @param PathShape shape(edge) defines the sub-mesh for the path
3175     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3176     #  @param HasAngles allows the shape to be rotated around the path
3177     #                   to get the resulting mesh in a helical fashion
3178     #  @param Angles list of angles
3179     #  @param HasRefPoint allows using the reference point
3180     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3181     #         The User can specify any point as the Reference Point.
3182     #  @param MakeGroups forces the generation of new groups from existing ones
3183     #  @param LinearVariation forces the computation of rotation angles as linear
3184     #                         variation of the given Angles along path steps
3185     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3186     #          only SMESH::Extrusion_Error otherwise
3187     #  @ingroup l2_modif_extrurev
3188     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3189                                  HasAngles, Angles, HasRefPoint, RefPoint,
3190                                  MakeGroups=False, LinearVariation=False):
3191         Angles,AnglesParameters = ParseAngles(Angles)
3192         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3193         if ( isinstance( theObject, Mesh )):
3194             theObject = theObject.GetMesh()
3195         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3196             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3197         if ( isinstance( PathMesh, Mesh )):
3198             PathMesh = PathMesh.GetMesh()
3199         if HasAngles and Angles and LinearVariation:
3200             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3201             pass
3202         Parameters = AnglesParameters + var_separator + RefPointParameters
3203         self.mesh.SetParameters(Parameters)
3204         if MakeGroups:
3205             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3206                                                                   PathShape, NodeStart, HasAngles,
3207                                                                   Angles, HasRefPoint, RefPoint)
3208         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3209                                                     NodeStart, HasAngles, Angles, HasRefPoint,
3210                                                     RefPoint)
3211
3212     ## Generates new elements by extrusion of the elements which belong to the object
3213     #  The path of extrusion must be a meshed edge.
3214     #  @param theObject the object which elements should be processed
3215     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3216     #  @param PathShape shape(edge) defines the sub-mesh for the path
3217     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3218     #  @param HasAngles allows the shape to be rotated around the path
3219     #                   to get the resulting mesh in a helical fashion
3220     #  @param Angles list of angles
3221     #  @param HasRefPoint allows using the reference point
3222     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3223     #         The User can specify any point as the Reference Point.
3224     #  @param MakeGroups forces the generation of new groups from existing ones
3225     #  @param LinearVariation forces the computation of rotation angles as linear
3226     #                         variation of the given Angles along path steps
3227     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3228     #          only SMESH::Extrusion_Error otherwise
3229     #  @ingroup l2_modif_extrurev
3230     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3231                                    HasAngles, Angles, HasRefPoint, RefPoint,
3232                                    MakeGroups=False, LinearVariation=False):
3233         Angles,AnglesParameters = ParseAngles(Angles)
3234         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3235         if ( isinstance( theObject, Mesh )):
3236             theObject = theObject.GetMesh()
3237         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3238             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3239         if ( isinstance( PathMesh, Mesh )):
3240             PathMesh = PathMesh.GetMesh()
3241         if HasAngles and Angles and LinearVariation:
3242             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3243             pass
3244         Parameters = AnglesParameters + var_separator + RefPointParameters
3245         self.mesh.SetParameters(Parameters)
3246         if MakeGroups:
3247             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3248                                                                     PathShape, NodeStart, HasAngles,
3249                                                                     Angles, HasRefPoint, RefPoint)
3250         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3251                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3252                                                       RefPoint)
3253
3254     ## Generates new elements by extrusion of the elements which belong to the object
3255     #  The path of extrusion must be a meshed edge.
3256     #  @param theObject the object which elements should be processed
3257     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3258     #  @param PathShape shape(edge) defines the sub-mesh for the path
3259     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3260     #  @param HasAngles allows the shape to be rotated around the path
3261     #                   to get the resulting mesh in a helical fashion
3262     #  @param Angles list of angles
3263     #  @param HasRefPoint allows using the reference point
3264     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3265     #         The User can specify any point as the Reference Point.
3266     #  @param MakeGroups forces the generation of new groups from existing ones
3267     #  @param LinearVariation forces the computation of rotation angles as linear
3268     #                         variation of the given Angles along path steps
3269     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3270     #          only SMESH::Extrusion_Error otherwise
3271     #  @ingroup l2_modif_extrurev
3272     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3273                                    HasAngles, Angles, HasRefPoint, RefPoint,
3274                                    MakeGroups=False, LinearVariation=False):
3275         Angles,AnglesParameters = ParseAngles(Angles)
3276         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3277         if ( isinstance( theObject, Mesh )):
3278             theObject = theObject.GetMesh()
3279         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3280             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3281         if ( isinstance( PathMesh, Mesh )):
3282             PathMesh = PathMesh.GetMesh()
3283         if HasAngles and Angles and LinearVariation:
3284             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3285             pass
3286         Parameters = AnglesParameters + var_separator + RefPointParameters
3287         self.mesh.SetParameters(Parameters)
3288         if MakeGroups:
3289             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3290                                                                     PathShape, NodeStart, HasAngles,
3291                                                                     Angles, HasRefPoint, RefPoint)
3292         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3293                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3294                                                       RefPoint)
3295
3296     ## Creates a symmetrical copy of mesh elements
3297     #  @param IDsOfElements list of elements ids
3298     #  @param Mirror is AxisStruct or geom object(point, line, plane)
3299     #  @param theMirrorType is  POINT, AXIS or PLANE
3300     #  If the Mirror is a geom object this parameter is unnecessary
3301     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3302     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3303     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3304     #  @ingroup l2_modif_trsf
3305     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3306         if IDsOfElements == []:
3307             IDsOfElements = self.GetElementsId()
3308         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3309             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3310         Mirror,Parameters = ParseAxisStruct(Mirror)
3311         self.mesh.SetParameters(Parameters)
3312         if Copy and MakeGroups:
3313             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3314         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3315         return []
3316
3317     ## Creates a new mesh by a symmetrical copy of mesh elements
3318     #  @param IDsOfElements the list of elements ids
3319     #  @param Mirror is AxisStruct or geom object (point, line, plane)
3320     #  @param theMirrorType is  POINT, AXIS or PLANE
3321     #  If the Mirror is a geom object this parameter is unnecessary
3322     #  @param MakeGroups to generate new groups from existing ones
3323     #  @param NewMeshName a name of the new mesh to create
3324     #  @return instance of Mesh class
3325     #  @ingroup l2_modif_trsf
3326     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3327         if IDsOfElements == []:
3328             IDsOfElements = self.GetElementsId()
3329         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3330             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3331         Mirror,Parameters = ParseAxisStruct(Mirror)
3332         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3333                                           MakeGroups, NewMeshName)
3334         mesh.SetParameters(Parameters)
3335         return Mesh(self.smeshpyD,self.geompyD,mesh)
3336
3337     ## Creates a symmetrical copy of the object
3338     #  @param theObject mesh, submesh or group
3339     #  @param Mirror AxisStruct or geom object (point, line, plane)
3340     #  @param theMirrorType is  POINT, AXIS or PLANE
3341     #  If the Mirror is a geom object this parameter is unnecessary
3342     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3343     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3344     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3345     #  @ingroup l2_modif_trsf
3346     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3347         if ( isinstance( theObject, Mesh )):
3348             theObject = theObject.GetMesh()
3349         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3350             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3351         Mirror,Parameters = ParseAxisStruct(Mirror)
3352         self.mesh.SetParameters(Parameters)
3353         if Copy and MakeGroups:
3354             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3355         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3356         return []
3357
3358     ## Creates a new mesh by a symmetrical copy of the object
3359     #  @param theObject mesh, submesh or group
3360     #  @param Mirror AxisStruct or geom object (point, line, plane)
3361     #  @param theMirrorType POINT, AXIS or PLANE
3362     #  If the Mirror is a geom object this parameter is unnecessary
3363     #  @param MakeGroups forces the generation of new groups from existing ones
3364     #  @param NewMeshName the name of the new mesh to create
3365     #  @return instance of Mesh class
3366     #  @ingroup l2_modif_trsf
3367     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3368         if ( isinstance( theObject, Mesh )):
3369             theObject = theObject.GetMesh()
3370         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3371             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3372         Mirror,Parameters = ParseAxisStruct(Mirror)
3373         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3374                                                 MakeGroups, NewMeshName)
3375         mesh.SetParameters(Parameters)
3376         return Mesh( self.smeshpyD,self.geompyD,mesh )
3377
3378     ## Translates the elements
3379     #  @param IDsOfElements list of elements ids
3380     #  @param Vector the direction of translation (DirStruct or vector)
3381     #  @param Copy allows copying the translated elements
3382     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3383     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3384     #  @ingroup l2_modif_trsf
3385     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3386         if IDsOfElements == []:
3387             IDsOfElements = self.GetElementsId()
3388         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3389             Vector = self.smeshpyD.GetDirStruct(Vector)
3390         Vector,Parameters = ParseDirStruct(Vector)
3391         self.mesh.SetParameters(Parameters)
3392         if Copy and MakeGroups:
3393             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3394         self.editor.Translate(IDsOfElements, Vector, Copy)
3395         return []
3396
3397     ## Creates a new mesh of translated elements
3398     #  @param IDsOfElements list of elements ids
3399     #  @param Vector the direction of translation (DirStruct or vector)
3400     #  @param MakeGroups forces the generation of new groups from existing ones
3401     #  @param NewMeshName the name of the newly created mesh
3402     #  @return instance of Mesh class
3403     #  @ingroup l2_modif_trsf
3404     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3405         if IDsOfElements == []:
3406             IDsOfElements = self.GetElementsId()
3407         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3408             Vector = self.smeshpyD.GetDirStruct(Vector)
3409         Vector,Parameters = ParseDirStruct(Vector)
3410         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3411         mesh.SetParameters(Parameters)
3412         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3413
3414     ## Translates the object
3415     #  @param theObject the object to translate (mesh, submesh, or group)
3416     #  @param Vector direction of translation (DirStruct or geom vector)
3417     #  @param Copy allows copying the translated elements
3418     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3419     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3420     #  @ingroup l2_modif_trsf
3421     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3422         if ( isinstance( theObject, Mesh )):
3423             theObject = theObject.GetMesh()
3424         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3425             Vector = self.smeshpyD.GetDirStruct(Vector)
3426         Vector,Parameters = ParseDirStruct(Vector)
3427         self.mesh.SetParameters(Parameters)
3428         if Copy and MakeGroups:
3429             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3430         self.editor.TranslateObject(theObject, Vector, Copy)
3431         return []
3432
3433     ## Creates a new mesh from the translated object
3434     #  @param theObject the object to translate (mesh, submesh, or group)
3435     #  @param Vector the direction of translation (DirStruct or geom vector)
3436     #  @param MakeGroups forces the generation of new groups from existing ones
3437     #  @param NewMeshName the name of the newly created mesh
3438     #  @return instance of Mesh class
3439     #  @ingroup l2_modif_trsf
3440     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3441         if (isinstance(theObject, Mesh)):
3442             theObject = theObject.GetMesh()
3443         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3444             Vector = self.smeshpyD.GetDirStruct(Vector)
3445         Vector,Parameters = ParseDirStruct(Vector)
3446         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3447         mesh.SetParameters(Parameters)
3448         return Mesh( self.smeshpyD, self.geompyD, mesh )
3449
3450
3451
3452     ## Scales the object
3453     #  @param theObject - the object to translate (mesh, submesh, or group)
3454     #  @param thePoint - base point for scale
3455     #  @param theScaleFact - list of 1-3 scale factors for axises
3456     #  @param Copy - allows copying the translated elements
3457     #  @param MakeGroups - forces the generation of new groups from existing
3458     #                      ones (if Copy)
3459     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3460     #          empty list otherwise
3461     def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3462         if ( isinstance( theObject, Mesh )):
3463             theObject = theObject.GetMesh()
3464         if ( isinstance( theObject, list )):
3465             theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3466
3467         thePoint, Parameters = ParsePointStruct(thePoint)
3468         self.mesh.SetParameters(Parameters)
3469
3470         if Copy and MakeGroups:
3471             return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3472         self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3473         return []
3474
3475     ## Creates a new mesh from the translated object
3476     #  @param theObject - the object to translate (mesh, submesh, or group)
3477     #  @param thePoint - base point for scale
3478     #  @param theScaleFact - list of 1-3 scale factors for axises
3479     #  @param MakeGroups - forces the generation of new groups from existing ones
3480     #  @param NewMeshName - the name of the newly created mesh
3481     #  @return instance of Mesh class
3482     def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3483         if (isinstance(theObject, Mesh)):
3484             theObject = theObject.GetMesh()
3485         if ( isinstance( theObject, list )):
3486             theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3487
3488         mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3489                                          MakeGroups, NewMeshName)
3490         #mesh.SetParameters(Parameters)
3491         return Mesh( self.smeshpyD, self.geompyD, mesh )
3492
3493
3494
3495     ## Rotates the elements
3496     #  @param IDsOfElements list of elements ids
3497     #  @param Axis the axis of rotation (AxisStruct or geom line)
3498     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3499     #  @param Copy allows copying the rotated elements
3500     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3501     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3502     #  @ingroup l2_modif_trsf
3503     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3504         flag = False
3505         if isinstance(AngleInRadians,str):
3506             flag = True
3507         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3508         if flag:
3509             AngleInRadians = DegreesToRadians(AngleInRadians)
3510         if IDsOfElements == []:
3511             IDsOfElements = self.GetElementsId()
3512         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3513             Axis = self.smeshpyD.GetAxisStruct(Axis)
3514         Axis,AxisParameters = ParseAxisStruct(Axis)
3515         Parameters = AxisParameters + var_separator + Parameters
3516         self.mesh.SetParameters(Parameters)
3517         if Copy and MakeGroups:
3518             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3519         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3520         return []
3521
3522     ## Creates a new mesh of rotated elements
3523     #  @param IDsOfElements list of element ids
3524     #  @param Axis the axis of rotation (AxisStruct or geom line)
3525     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3526     #  @param MakeGroups forces the generation of new groups from existing ones
3527     #  @param NewMeshName the name of the newly created mesh
3528     #  @return instance of Mesh class
3529     #  @ingroup l2_modif_trsf
3530     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3531         flag = False
3532         if isinstance(AngleInRadians,str):
3533             flag = True
3534         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3535         if flag:
3536             AngleInRadians = DegreesToRadians(AngleInRadians)
3537         if IDsOfElements == []:
3538             IDsOfElements = self.GetElementsId()
3539         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3540             Axis = self.smeshpyD.GetAxisStruct(Axis)
3541         Axis,AxisParameters = ParseAxisStruct(Axis)
3542         Parameters = AxisParameters + var_separator + Parameters
3543         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3544                                           MakeGroups, NewMeshName)
3545         mesh.SetParameters(Parameters)
3546         return Mesh( self.smeshpyD, self.geompyD, mesh )
3547
3548     ## Rotates the object
3549     #  @param theObject the object to rotate( mesh, submesh, or group)
3550     #  @param Axis the axis of rotation (AxisStruct or geom line)
3551     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3552     #  @param Copy allows copying the rotated elements
3553     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3554     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3555     #  @ingroup l2_modif_trsf
3556     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3557         flag = False
3558         if isinstance(AngleInRadians,str):
3559             flag = True
3560         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3561         if flag:
3562             AngleInRadians = DegreesToRadians(AngleInRadians)
3563         if (isinstance(theObject, Mesh)):
3564             theObject = theObject.GetMesh()
3565         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3566             Axis = self.smeshpyD.GetAxisStruct(Axis)
3567         Axis,AxisParameters = ParseAxisStruct(Axis)
3568         Parameters = AxisParameters + ":" + Parameters
3569         self.mesh.SetParameters(Parameters)
3570         if Copy and MakeGroups:
3571             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3572         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3573         return []
3574
3575     ## Creates a new mesh from the rotated object
3576     #  @param theObject the object to rotate (mesh, submesh, or group)
3577     #  @param Axis the axis of rotation (AxisStruct or geom line)
3578     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
3579     #  @param MakeGroups forces the generation of new groups from existing ones
3580     #  @param NewMeshName the name of the newly created mesh
3581     #  @return instance of Mesh class
3582     #  @ingroup l2_modif_trsf
3583     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3584         flag = False
3585         if isinstance(AngleInRadians,str):
3586             flag = True
3587         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3588         if flag:
3589             AngleInRadians = DegreesToRadians(AngleInRadians)
3590         if (isinstance( theObject, Mesh )):
3591             theObject = theObject.GetMesh()
3592         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3593             Axis = self.smeshpyD.GetAxisStruct(Axis)
3594         Axis,AxisParameters = ParseAxisStruct(Axis)
3595         Parameters = AxisParameters + ":" + Parameters
3596         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3597                                                        MakeGroups, NewMeshName)
3598         mesh.SetParameters(Parameters)
3599         return Mesh( self.smeshpyD, self.geompyD, mesh )
3600
3601     ## Finds groups of ajacent nodes within Tolerance.
3602     #  @param Tolerance the value of tolerance
3603     #  @return the list of groups of nodes
3604     #  @ingroup l2_modif_trsf
3605     def FindCoincidentNodes (self, Tolerance):
3606         return self.editor.FindCoincidentNodes(Tolerance)
3607
3608     ## Finds groups of ajacent nodes within Tolerance.
3609     #  @param Tolerance the value of tolerance
3610     #  @param SubMeshOrGroup SubMesh or Group
3611     #  @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3612     #  @return the list of groups of nodes
3613     #  @ingroup l2_modif_trsf
3614     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3615         if (isinstance( SubMeshOrGroup, Mesh )):
3616             SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3617         if not isinstance( exceptNodes, list):
3618             exceptNodes = [ exceptNodes ]
3619         if exceptNodes and isinstance( exceptNodes[0], int):
3620             exceptNodes = [ self.editor.MakeIDSource( exceptNodes, SMESH.NODE)]
3621         return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3622
3623     ## Merges nodes
3624     #  @param GroupsOfNodes the list of groups of nodes
3625     #  @ingroup l2_modif_trsf
3626     def MergeNodes (self, GroupsOfNodes):
3627         self.editor.MergeNodes(GroupsOfNodes)
3628
3629     ## Finds the elements built on the same nodes.
3630     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3631     #  @return a list of groups of equal elements
3632     #  @ingroup l2_modif_trsf
3633     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3634         if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3635             MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3636         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3637
3638     ## Merges elements in each given group.
3639     #  @param GroupsOfElementsID groups of elements for merging
3640     #  @ingroup l2_modif_trsf
3641     def MergeElements(self, GroupsOfElementsID):
3642         self.editor.MergeElements(GroupsOfElementsID)
3643
3644     ## Leaves one element and removes all other elements built on the same nodes.
3645     #  @ingroup l2_modif_trsf
3646     def MergeEqualElements(self):
3647         self.editor.MergeEqualElements()
3648
3649     ## Sews free borders
3650     #  @return SMESH::Sew_Error
3651     #  @ingroup l2_modif_trsf
3652     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3653                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3654                         CreatePolygons, CreatePolyedrs):
3655         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3656                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3657                                           CreatePolygons, CreatePolyedrs)
3658
3659     ## Sews conform free borders
3660     #  @return SMESH::Sew_Error
3661     #  @ingroup l2_modif_trsf
3662     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3663                                FirstNodeID2, SecondNodeID2):
3664         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3665                                                  FirstNodeID2, SecondNodeID2)
3666
3667     ## Sews border to side
3668     #  @return SMESH::Sew_Error
3669     #  @ingroup l2_modif_trsf
3670     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3671                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3672         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3673                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3674
3675     ## Sews two sides of a mesh. The nodes belonging to Side1 are
3676     #  merged with the nodes of elements of Side2.
3677     #  The number of elements in theSide1 and in theSide2 must be
3678     #  equal and they should have similar nodal connectivity.
3679     #  The nodes to merge should belong to side borders and
3680     #  the first node should be linked to the second.
3681     #  @return SMESH::Sew_Error
3682     #  @ingroup l2_modif_trsf
3683     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3684                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3685                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3686         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3687                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3688                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3689
3690     ## Sets new nodes for the given element.
3691     #  @param ide the element id
3692     #  @param newIDs nodes ids
3693     #  @return If the number of nodes does not correspond to the type of element - returns false
3694     #  @ingroup l2_modif_edit
3695     def ChangeElemNodes(self, ide, newIDs):
3696         return self.editor.ChangeElemNodes(ide, newIDs)
3697
3698     ## If during the last operation of MeshEditor some nodes were
3699     #  created, this method returns the list of their IDs, \n
3700     #  if new nodes were not created - returns empty list
3701     #  @return the list of integer values (can be empty)
3702     #  @ingroup l1_auxiliary
3703     def GetLastCreatedNodes(self):
3704         return self.editor.GetLastCreatedNodes()
3705
3706     ## If during the last operation of MeshEditor some elements were
3707     #  created this method returns the list of their IDs, \n
3708     #  if new elements were not created - returns empty list
3709     #  @return the list of integer values (can be empty)
3710     #  @ingroup l1_auxiliary
3711     def GetLastCreatedElems(self):
3712         return self.editor.GetLastCreatedElems()
3713
3714      ## Creates a hole in a mesh by doubling the nodes of some particular elements
3715     #  @param theNodes identifiers of nodes to be doubled
3716     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled) 
3717     #         nodes. If list of element identifiers is empty then nodes are doubled but 
3718     #         they not assigned to elements
3719     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3720     #  @ingroup l2_modif_edit
3721     def DoubleNodes(self, theNodes, theModifiedElems):
3722         return self.editor.DoubleNodes(theNodes, theModifiedElems)
3723         
3724     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3725     #  This method provided for convenience works as DoubleNodes() described above.
3726     #  @param theNodeId identifiers of node to be doubled
3727     #  @param theModifiedElems identifiers of elements to be updated
3728     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3729     #  @ingroup l2_modif_edit
3730     def DoubleNode(self, theNodeId, theModifiedElems):
3731         return self.editor.DoubleNode(theNodeId, theModifiedElems)
3732         
3733     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3734     #  This method provided for convenience works as DoubleNodes() described above.
3735     #  @param theNodes group of nodes to be doubled
3736     #  @param theModifiedElems group of elements to be updated.
3737     #  @param theMakeGroup forces the generation of a group containing new nodes.
3738     #  @return TRUE or a created group if operation has been completed successfully,
3739     #          FALSE or None otherwise
3740     #  @ingroup l2_modif_edit
3741     def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3742         if theMakeGroup:
3743             return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3744         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3745
3746     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3747     #  This method provided for convenience works as DoubleNodes() described above.
3748     #  @param theNodes list of groups of nodes to be doubled
3749     #  @param theModifiedElems list of groups of elements to be updated.
3750     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3751     #  @ingroup l2_modif_edit
3752     def DoubleNodeGroups(self, theNodes, theModifiedElems):
3753         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3754     
3755     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3756     #  @param theElems - the list of elements (edges or faces) to be replicated
3757     #         The nodes for duplication could be found from these elements
3758     #  @param theNodesNot - list of nodes to NOT replicate
3759     #  @param theAffectedElems - the list of elements (cells and edges) to which the 
3760     #         replicated nodes should be associated to.
3761     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3762     #  @ingroup l2_modif_edit
3763     def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3764         return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3765         
3766     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3767     #  @param theElems - the list of elements (edges or faces) to be replicated
3768     #         The nodes for duplication could be found from these elements
3769     #  @param theNodesNot - list of nodes to NOT replicate
3770     #  @param theShape - shape to detect affected elements (element which geometric center
3771     #         located on or inside shape).
3772     #         The replicated nodes should be associated to affected elements.
3773     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3774     #  @ingroup l2_modif_edit
3775     def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3776         return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3777     
3778     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3779     #  This method provided for convenience works as DoubleNodes() described above.
3780     #  @param theElems - group of of elements (edges or faces) to be replicated
3781     #  @param theNodesNot - group of nodes not to replicated
3782     #  @param theAffectedElems - group of elements to which the replicated nodes
3783     #         should be associated to.
3784     #  @param theMakeGroup forces the generation of a group containing new elements.
3785     #  @ingroup l2_modif_edit
3786     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3787         if theMakeGroup:
3788             return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3789         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3790
3791     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3792     #  This method provided for convenience works as DoubleNodes() described above.
3793     #  @param theElems - group of of elements (edges or faces) to be replicated
3794     #  @param theNodesNot - group of nodes not to replicated
3795     #  @param theShape - shape to detect affected elements (element which geometric center
3796     #         located on or inside shape).
3797     #         The replicated nodes should be associated to affected elements.
3798     #  @ingroup l2_modif_edit
3799     def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3800         return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3801         
3802     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3803     #  This method provided for convenience works as DoubleNodes() described above.
3804     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3805     #  @param theNodesNot - list of groups of nodes not to replicated
3806     #  @param theAffectedElems - group of elements to which the replicated nodes
3807     #         should be associated to.
3808     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3809     #  @ingroup l2_modif_edit
3810     def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3811         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3812
3813     ## Creates a hole in a mesh by doubling the nodes of some particular elements
3814     #  This method provided for convenience works as DoubleNodes() described above.
3815     #  @param theElems - list of groups of elements (edges or faces) to be replicated
3816     #  @param theNodesNot - list of groups of nodes not to replicated
3817     #  @param theShape - shape to detect affected elements (element which geometric center
3818     #         located on or inside shape).
3819     #         The replicated nodes should be associated to affected elements.
3820     #  @return TRUE if operation has been completed successfully, FALSE otherwise
3821     #  @ingroup l2_modif_edit
3822     def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3823         return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3824
3825 ## The mother class to define algorithm, it is not recommended to use it directly.
3826 #
3827 #  More details.
3828 #  @ingroup l2_algorithms
3829 class Mesh_Algorithm:
3830     #  @class Mesh_Algorithm
3831     #  @brief Class Mesh_Algorithm
3832
3833     #def __init__(self,smesh):
3834     #    self.smesh=smesh
3835     def __init__(self):
3836         self.mesh = None
3837         self.geom = None
3838         self.subm = None
3839         self.algo = None
3840
3841     ## Finds a hypothesis in the study by its type name and parameters.
3842     #  Finds only the hypotheses created in smeshpyD engine.
3843     #  @return SMESH.SMESH_Hypothesis
3844     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3845         study = smeshpyD.GetCurrentStudy()
3846         #to do: find component by smeshpyD object, not by its data type
3847         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3848         if scomp is not None:
3849             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3850             # Check if the root label of the hypotheses exists
3851             if res and hypRoot is not None:
3852                 iter = study.NewChildIterator(hypRoot)
3853                 # Check all published hypotheses
3854                 while iter.More():
3855                     hypo_so_i = iter.Value()
3856                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3857                     if attr is not None:
3858                         anIOR = attr.Value()
3859                         hypo_o_i = salome.orb.string_to_object(anIOR)
3860                         if hypo_o_i is not None:
3861                             # Check if this is a hypothesis
3862                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3863                             if hypo_i is not None:
3864                                 # Check if the hypothesis belongs to current engine
3865                                 if smeshpyD.GetObjectId(hypo_i) > 0:
3866                                     # Check if this is the required hypothesis
3867                                     if hypo_i.GetName() == hypname:
3868                                         # Check arguments
3869                                         if CompareMethod(hypo_i, args):
3870                                             # found!!!
3871                                             return hypo_i
3872                                         pass
3873                                     pass
3874                                 pass
3875                             pass
3876                         pass
3877                     iter.Next()
3878                     pass
3879                 pass
3880             pass
3881         return None
3882
3883     ## Finds the algorithm in the study by its type name.
3884     #  Finds only the algorithms, which have been created in smeshpyD engine.
3885     #  @return SMESH.SMESH_Algo
3886     def FindAlgorithm (self, algoname, smeshpyD):
3887         study = smeshpyD.GetCurrentStudy()
3888         #to do: find component by smeshpyD object, not by its data type
3889         scomp = study.FindComponent(smeshpyD.ComponentDataType())
3890         if scomp is not None:
3891             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3892             # Check if the root label of the algorithms exists
3893             if res and hypRoot is not None:
3894                 iter = study.NewChildIterator(hypRoot)
3895                 # Check all published algorithms
3896                 while iter.More():
3897                     algo_so_i = iter.Value()
3898                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3899                     if attr is not None:
3900                         anIOR = attr.Value()
3901                         algo_o_i = salome.orb.string_to_object(anIOR)
3902                         if algo_o_i is not None:
3903                             # Check if this is an algorithm
3904                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3905                             if algo_i is not None:
3906                                 # Checks if the algorithm belongs to the current engine
3907                                 if smeshpyD.GetObjectId(algo_i) > 0:
3908                                     # Check if this is the required algorithm
3909                                     if algo_i.GetName() == algoname:
3910                                         # found!!!
3911                                         return algo_i
3912                                     pass
3913                                 pass
3914                             pass
3915                         pass
3916                     iter.Next()
3917                     pass
3918                 pass
3919             pass
3920         return None
3921
3922     ## If the algorithm is global, returns 0; \n
3923     #  else returns the submesh associated to this algorithm.
3924     def GetSubMesh(self):
3925         return self.subm
3926
3927     ## Returns the wrapped mesher.
3928     def GetAlgorithm(self):
3929         return self.algo
3930
3931     ## Gets the list of hypothesis that can be used with this algorithm
3932     def GetCompatibleHypothesis(self):
3933         mylist = []
3934         if self.algo:
3935             mylist = self.algo.GetCompatibleHypothesis()
3936         return mylist
3937
3938     ## Gets the name of the algorithm
3939     def GetName(self):
3940         GetName(self.algo)
3941
3942     ## Sets the name to the algorithm
3943     def SetName(self, name):
3944         self.mesh.smeshpyD.SetName(self.algo, name)
3945
3946     ## Gets the id of the algorithm
3947     def GetId(self):
3948         return self.algo.GetId()
3949
3950     ## Private method.
3951     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3952         if geom is None:
3953             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3954         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3955         if algo is None:
3956             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3957             pass
3958         self.Assign(algo, mesh, geom)
3959         return self.algo
3960
3961     ## Private method
3962     def Assign(self, algo, mesh, geom):
3963         if geom is None:
3964             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3965         self.mesh = mesh
3966         piece = mesh.geom
3967         name = ""
3968         if not geom:
3969             self.geom = piece
3970         else:
3971             self.geom = geom
3972             try:
3973                 name = GetName(geom)
3974                 pass
3975             except:
3976                 name = mesh.geompyD.SubShapeName(geom, piece)
3977                 mesh.geompyD.addToStudyInFather(piece, geom, name)
3978                 pass
3979             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3980
3981         self.algo = algo
3982         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3983         TreatHypoStatus( status, algo.GetName(), name, True )
3984
3985     def CompareHyp (self, hyp, args):
3986         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3987         return False
3988
3989     def CompareEqualHyp (self, hyp, args):
3990         return True
3991
3992     ## Private method
3993     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3994                     UseExisting=0, CompareMethod=""):
3995         hypo = None
3996         if UseExisting:
3997             if CompareMethod == "": CompareMethod = self.CompareHyp
3998             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3999             pass
4000         if hypo is None:
4001             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4002             a = ""
4003             s = "="
4004             i = 0
4005             n = len(args)
4006             while i<n:
4007                 a = a + s + str(args[i])
4008                 s = ","
4009                 i = i + 1
4010                 pass
4011             self.mesh.smeshpyD.SetName(hypo, hyp + a)
4012             pass
4013         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4014         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4015         return hypo
4016
4017     ## Returns entry of the shape to mesh in the study
4018     def MainShapeEntry(self):
4019         entry = ""
4020         if not self.mesh or not self.mesh.GetMesh(): return entry
4021         if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4022         study = self.mesh.smeshpyD.GetCurrentStudy()
4023         ior  = salome.orb.object_to_string( self.mesh.GetShape() )
4024         sobj = study.FindObjectIOR(ior)
4025         if sobj: entry = sobj.GetID()
4026         if not entry: return ""
4027         return entry
4028
4029 # Public class: Mesh_Segment
4030 # --------------------------
4031
4032 ## Class to define a segment 1D algorithm for discretization
4033 #
4034 #  More details.
4035 #  @ingroup l3_algos_basic
4036 class Mesh_Segment(Mesh_Algorithm):
4037
4038     ## Private constructor.
4039     def __init__(self, mesh, geom=0):
4040         Mesh_Algorithm.__init__(self)
4041         self.Create(mesh, geom, "Regular_1D")
4042
4043     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4044     #  @param l for the length of segments that cut an edge
4045     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
4046     #                    the same parameters, else (default) - creates a new one
4047     #  @param p precision, used for calculation of the number of segments.
4048     #           The precision should be a positive, meaningful value within the range [0,1].
4049     #           In general, the number of segments is calculated with the formula:
4050     #           nb = ceil((edge_length / l) - p)
4051     #           Function ceil rounds its argument to the higher integer.
4052     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
4053     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
4054     #               p=1 means rounding of (edge_length / l) to the lower integer.
4055     #           Default value is 1e-07.
4056     #  @return an instance of StdMeshers_LocalLength hypothesis
4057     #  @ingroup l3_hypos_1dhyps
4058     def LocalLength(self, l, UseExisting=0, p=1e-07):
4059         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4060                               CompareMethod=self.CompareLocalLength)
4061         hyp.SetLength(l)
4062         hyp.SetPrecision(p)
4063         return hyp
4064
4065     ## Private method
4066     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4067     def CompareLocalLength(self, hyp, args):
4068         if IsEqual(hyp.GetLength(), args[0]):
4069             return IsEqual(hyp.GetPrecision(), args[1])
4070         return False
4071
4072     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4073     #  @param length is optional maximal allowed length of segment, if it is omitted
4074     #                the preestimated length is used that depends on geometry size
4075     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4076     #                     the same parameters, else (default) - create a new one
4077     #  @return an instance of StdMeshers_MaxLength hypothesis
4078     #  @ingroup l3_hypos_1dhyps
4079     def MaxSize(self, length=0.0, UseExisting=0):
4080         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4081         if length > 0.0:
4082             # set given length
4083             hyp.SetLength(length)
4084         if not UseExisting:
4085             # set preestimated length
4086             gen = self.mesh.smeshpyD
4087             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4088                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
4089                                                        False) # <- byMesh
4090             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4091             if preHyp:
4092                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4093                 pass
4094             pass
4095         hyp.SetUsePreestimatedLength( length == 0.0 )
4096         return hyp
4097         
4098     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4099     #  @param n for the number of segments that cut an edge
4100     #  @param s for the scale factor (optional)
4101     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4102     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4103     #                     the same parameters, else (default) - create a new one
4104     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
4105     #  @ingroup l3_hypos_1dhyps
4106     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4107         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4108             reversedEdges, UseExisting = [], reversedEdges
4109         entry = self.MainShapeEntry()
4110         if s == []:
4111             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4112                                   UseExisting=UseExisting,
4113                                   CompareMethod=self.CompareNumberOfSegments)
4114         else:
4115             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4116                                   UseExisting=UseExisting,
4117                                   CompareMethod=self.CompareNumberOfSegments)
4118             hyp.SetDistrType( 1 )
4119             hyp.SetScaleFactor(s)
4120         hyp.SetNumberOfSegments(n)
4121         hyp.SetReversedEdges( reversedEdges )
4122         hyp.SetObjectEntry( entry )
4123         return hyp
4124
4125     ## Private method
4126     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4127     def CompareNumberOfSegments(self, hyp, args):
4128         if hyp.GetNumberOfSegments() == args[0]:
4129             if len(args) == 3:
4130                 if hyp.GetReversedEdges() == args[1]:
4131                     if not args[1] or hyp.GetObjectEntry() == args[2]:
4132                         return True
4133             else:
4134                 if hyp.GetReversedEdges() == args[2]:
4135                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4136                         if hyp.GetDistrType() == 1:
4137                             if IsEqual(hyp.GetScaleFactor(), args[1]):
4138                                 return True
4139         return False
4140
4141     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4142     #  @param start defines the length of the first segment
4143     #  @param end   defines the length of the last  segment
4144     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4145     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4146     #                     the same parameters, else (default) - creates a new one
4147     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4148     #  @ingroup l3_hypos_1dhyps
4149     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4150         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4151             reversedEdges, UseExisting = [], reversedEdges
4152         entry = self.MainShapeEntry()
4153         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4154                               UseExisting=UseExisting,
4155                               CompareMethod=self.CompareArithmetic1D)
4156         hyp.SetStartLength(start)
4157         hyp.SetEndLength(end)
4158         hyp.SetReversedEdges( reversedEdges )
4159         hyp.SetObjectEntry( entry )
4160         return hyp
4161
4162     ## Private method
4163     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4164     def CompareArithmetic1D(self, hyp, args):
4165         if IsEqual(hyp.GetLength(1), args[0]):
4166             if IsEqual(hyp.GetLength(0), args[1]):
4167                 if hyp.GetReversedEdges() == args[2]:
4168                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4169                         return True
4170         return False
4171
4172
4173     ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4174     # on curve from 0 to 1 (additionally it is neecessary to check
4175     # orientation of edges and create list of reversed edges if it is
4176     # needed) and sets numbers of segments between given points (default
4177     # values are equals 1
4178     #  @param points defines the list of parameters on curve
4179     #  @param nbSegs defines the list of numbers of segments
4180     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4181     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4182     #                     the same parameters, else (default) - creates a new one
4183     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4184     #  @ingroup l3_hypos_1dhyps
4185     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4186         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4187             reversedEdges, UseExisting = [], reversedEdges
4188         if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4189             for i in range( len( reversedEdges )):
4190                 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4191         entry = self.MainShapeEntry()
4192         hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4193                               UseExisting=UseExisting,
4194                               CompareMethod=self.CompareFixedPoints1D)
4195         hyp.SetPoints(points)
4196         hyp.SetNbSegments(nbSegs)
4197         hyp.SetReversedEdges(reversedEdges)
4198         hyp.SetObjectEntry(entry)
4199         return hyp
4200
4201     ## Private method
4202     ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4203     ## as the given arguments
4204     def CompareFixedPoints1D(self, hyp, args):
4205         if hyp.GetPoints() == args[0]:
4206             if hyp.GetNbSegments() == args[1]:
4207                 if hyp.GetReversedEdges() == args[2]:
4208                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4209                         return True
4210         return False
4211
4212
4213
4214     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4215     #  @param start defines the length of the first segment
4216     #  @param end   defines the length of the last  segment
4217     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4218     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4219     #                     the same parameters, else (default) - creates a new one
4220     #  @return an instance of StdMeshers_StartEndLength hypothesis
4221     #  @ingroup l3_hypos_1dhyps
4222     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4223         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4224             reversedEdges, UseExisting = [], reversedEdges
4225         entry = self.MainShapeEntry()
4226         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4227                               UseExisting=UseExisting,
4228                               CompareMethod=self.CompareStartEndLength)
4229         hyp.SetStartLength(start)
4230         hyp.SetEndLength(end)
4231         hyp.SetReversedEdges( reversedEdges )
4232         hyp.SetObjectEntry( entry )
4233         return hyp
4234
4235     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4236     def CompareStartEndLength(self, hyp, args):
4237         if IsEqual(hyp.GetLength(1), args[0]):
4238             if IsEqual(hyp.GetLength(0), args[1]):
4239                 if hyp.GetReversedEdges() == args[2]:
4240                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4241                         return True
4242         return False
4243
4244     ## Defines "Deflection1D" hypothesis
4245     #  @param d for the deflection
4246     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4247     #                     the same parameters, else (default) - create a new one
4248     #  @ingroup l3_hypos_1dhyps
4249     def Deflection1D(self, d, UseExisting=0):
4250         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4251                               CompareMethod=self.CompareDeflection1D)
4252         hyp.SetDeflection(d)
4253         return hyp
4254
4255     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4256     def CompareDeflection1D(self, hyp, args):
4257         return IsEqual(hyp.GetDeflection(), args[0])
4258
4259     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4260     #  the opposite side in case of quadrangular faces
4261     #  @ingroup l3_hypos_additi
4262     def Propagation(self):
4263         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4264
4265     ## Defines "AutomaticLength" hypothesis
4266     #  @param fineness for the fineness [0-1]
4267     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
4268     #                     same parameters, else (default) - create a new one
4269     #  @ingroup l3_hypos_1dhyps
4270     def AutomaticLength(self, fineness=0, UseExisting=0):
4271         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4272                               CompareMethod=self.CompareAutomaticLength)
4273         hyp.SetFineness( fineness )
4274         return hyp
4275
4276     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4277     def CompareAutomaticLength(self, hyp, args):
4278         return IsEqual(hyp.GetFineness(), args[0])
4279
4280     ## Defines "SegmentLengthAroundVertex" hypothesis
4281     #  @param length for the segment length
4282     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
4283     #         Any other integer value means that the hypothesis will be set on the
4284     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
4285     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
4286     #                   the same parameters, else (default) - creates a new one
4287     #  @ingroup l3_algos_segmarv
4288     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4289         import types
4290         store_geom = self.geom
4291         if type(vertex) is types.IntType:
4292             if vertex == 0 or vertex == 1:
4293                 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4294                 self.geom = vertex
4295                 pass
4296             pass
4297         else:
4298             self.geom = vertex
4299             pass
4300         ### 0D algorithm
4301         if self.geom is None:
4302             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4303         try:
4304             name = GetName(self.geom)
4305             pass
4306         except:
4307             piece = self.mesh.geom
4308             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4309             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4310             pass
4311         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4312         if algo is None:
4313             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4314             pass
4315         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4316         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4317         ###
4318         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4319                               CompareMethod=self.CompareLengthNearVertex)
4320         self.geom = store_geom
4321         hyp.SetLength( length )
4322         return hyp
4323
4324     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4325     #  @ingroup l3_algos_segmarv
4326     def CompareLengthNearVertex(self, hyp, args):
4327         return IsEqual(hyp.GetLength(), args[0])
4328
4329     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4330     #  If the 2D mesher sees that all boundary edges are quadratic,
4331     #  it generates quadratic faces, else it generates linear faces using
4332     #  medium nodes as if they are vertices.
4333     #  The 3D mesher generates quadratic volumes only if all boundary faces
4334     #  are quadratic, else it fails.
4335     #
4336     #  @ingroup l3_hypos_additi
4337     def QuadraticMesh(self):
4338         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4339         return hyp
4340
4341 # Public class: Mesh_CompositeSegment
4342 # --------------------------
4343
4344 ## Defines a segment 1D algorithm for discretization
4345 #
4346 #  @ingroup l3_algos_basic
4347 class Mesh_CompositeSegment(Mesh_Segment):
4348
4349     ## Private constructor.
4350     def __init__(self, mesh, geom=0):
4351         self.Create(mesh, geom, "CompositeSegment_1D")
4352
4353
4354 # Public class: Mesh_Segment_Python
4355 # ---------------------------------
4356
4357 ## Defines a segment 1D algorithm for discretization with python function
4358 #
4359 #  @ingroup l3_algos_basic
4360 class Mesh_Segment_Python(Mesh_Segment):
4361
4362     ## Private constructor.
4363     def __init__(self, mesh, geom=0):
4364         import Python1dPlugin
4365         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4366
4367     ## Defines "PythonSplit1D" hypothesis
4368     #  @param n for the number of segments that cut an edge
4369     #  @param func for the python function that calculates the length of all segments
4370     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4371     #                     the same parameters, else (default) - creates a new one
4372     #  @ingroup l3_hypos_1dhyps
4373     def PythonSplit1D(self, n, func, UseExisting=0):
4374         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4375                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4376         hyp.SetNumberOfSegments(n)
4377         hyp.SetPythonLog10RatioFunction(func)
4378         return hyp
4379
4380     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4381     def ComparePythonSplit1D(self, hyp, args):
4382         #if hyp.GetNumberOfSegments() == args[0]:
4383         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
4384         #        return True
4385         return False
4386
4387 # Public class: Mesh_Triangle
4388 # ---------------------------
4389
4390 ## Defines a triangle 2D algorithm
4391 #
4392 #  @ingroup l3_algos_basic
4393 class Mesh_Triangle(Mesh_Algorithm):
4394
4395     # default values
4396     algoType = 0
4397     params = 0
4398
4399     _angleMeshS = 8
4400     _gradation  = 1.1
4401
4402     ## Private constructor.
4403     def __init__(self, mesh, algoType, geom=0):
4404         Mesh_Algorithm.__init__(self)
4405
4406         self.algoType = algoType
4407         if algoType == MEFISTO:
4408             self.Create(mesh, geom, "MEFISTO_2D")
4409             pass
4410         elif algoType == BLSURF:
4411             CheckPlugin(BLSURF)
4412             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4413             #self.SetPhysicalMesh() - PAL19680
4414         elif algoType == NETGEN:
4415             CheckPlugin(NETGEN)
4416             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4417             pass
4418         elif algoType == NETGEN_2D:
4419             CheckPlugin(NETGEN)
4420             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4421             pass
4422
4423     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4424     #  @param area for the maximum area of each triangle
4425     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
4426     #                     same parameters, else (default) - creates a new one
4427     #
4428     #  Only for algoType == MEFISTO || NETGEN_2D
4429     #  @ingroup l3_hypos_2dhyps
4430     def MaxElementArea(self, area, UseExisting=0):
4431         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4432             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4433                                   CompareMethod=self.CompareMaxElementArea)
4434         elif self.algoType == NETGEN:
4435             hyp = self.Parameters(SIMPLE)
4436         hyp.SetMaxElementArea(area)
4437         return hyp
4438
4439     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4440     def CompareMaxElementArea(self, hyp, args):
4441         return IsEqual(hyp.GetMaxElementArea(), args[0])
4442
4443     ## Defines "LengthFromEdges" hypothesis to build triangles
4444     #  based on the length of the edges taken from the wire
4445     #
4446     #  Only for algoType == MEFISTO || NETGEN_2D
4447     #  @ingroup l3_hypos_2dhyps
4448     def LengthFromEdges(self):
4449         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4450             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4451             return hyp
4452         elif self.algoType == NETGEN:
4453             hyp = self.Parameters(SIMPLE)
4454             hyp.LengthFromEdges()
4455             return hyp
4456
4457     ## Sets a way to define size of mesh elements to generate.
4458     #  @param thePhysicalMesh is: DefaultSize or Custom.
4459     #  @ingroup l3_hypos_blsurf
4460     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4461         # Parameter of BLSURF algo
4462         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4463
4464     ## Sets size of mesh elements to generate.
4465     #  @ingroup l3_hypos_blsurf
4466     def SetPhySize(self, theVal):
4467         # Parameter of BLSURF algo
4468         self.SetPhysicalMesh(1) #Custom - else why to set the size?
4469         self.Parameters().SetPhySize(theVal)
4470
4471     ## Sets lower boundary of mesh element size (PhySize).
4472     #  @ingroup l3_hypos_blsurf
4473     def SetPhyMin(self, theVal=-1):
4474         #  Parameter of BLSURF algo
4475         self.Parameters().SetPhyMin(theVal)
4476
4477     ## Sets upper boundary of mesh element size (PhySize).
4478     #  @ingroup l3_hypos_blsurf
4479     def SetPhyMax(self, theVal=-1):
4480         #  Parameter of BLSURF algo
4481         self.Parameters().SetPhyMax(theVal)
4482
4483     ## Sets a way to define maximum angular deflection of mesh from CAD model.
4484     #  @param theGeometricMesh is: 0 (None) or 1 (Custom)
4485     #  @ingroup l3_hypos_blsurf
4486     def SetGeometricMesh(self, theGeometricMesh=0):
4487         #  Parameter of BLSURF algo
4488         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4489         self.params.SetGeometricMesh(theGeometricMesh)
4490
4491     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4492     #  @ingroup l3_hypos_blsurf
4493     def SetAngleMeshS(self, theVal=_angleMeshS):
4494         #  Parameter of BLSURF algo
4495         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4496         self.params.SetAngleMeshS(theVal)
4497
4498     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4499     #  @ingroup l3_hypos_blsurf
4500     def SetAngleMeshC(self, theVal=_angleMeshS):
4501         #  Parameter of BLSURF algo
4502         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4503         self.params.SetAngleMeshC(theVal)
4504
4505     ## Sets lower boundary of mesh element size computed to respect angular deflection.
4506     #  @ingroup l3_hypos_blsurf
4507     def SetGeoMin(self, theVal=-1):
4508         #  Parameter of BLSURF algo
4509         self.Parameters().SetGeoMin(theVal)
4510
4511     ## Sets upper boundary of mesh element size computed to respect angular deflection.
4512     #  @ingroup l3_hypos_blsurf
4513     def SetGeoMax(self, theVal=-1):
4514         #  Parameter of BLSURF algo
4515         self.Parameters().SetGeoMax(theVal)
4516
4517     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4518     #  @ingroup l3_hypos_blsurf
4519     def SetGradation(self, theVal=_gradation):
4520         #  Parameter of BLSURF algo
4521         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4522         self.params.SetGradation(theVal)
4523
4524     ## Sets topology usage way.
4525     # @param way defines how mesh conformity is assured <ul>
4526     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4527     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4528     #  @ingroup l3_hypos_blsurf
4529     def SetTopology(self, way):
4530         #  Parameter of BLSURF algo
4531         self.Parameters().SetTopology(way)
4532
4533     ## To respect geometrical edges or not.
4534     #  @ingroup l3_hypos_blsurf
4535     def SetDecimesh(self, toIgnoreEdges=False):
4536         #  Parameter of BLSURF algo
4537         self.Parameters().SetDecimesh(toIgnoreEdges)
4538
4539     ## Sets verbosity level in the range 0 to 100.
4540     #  @ingroup l3_hypos_blsurf
4541     def SetVerbosity(self, level):
4542         #  Parameter of BLSURF algo
4543         self.Parameters().SetVerbosity(level)
4544
4545     ## Sets advanced option value.
4546     #  @ingroup l3_hypos_blsurf
4547     def SetOptionValue(self, optionName, level):
4548         #  Parameter of BLSURF algo
4549         self.Parameters().SetOptionValue(optionName,level)
4550
4551     ## Sets QuadAllowed flag.
4552     #  Only for algoType == NETGEN || NETGEN_2D || BLSURF
4553     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
4554     def SetQuadAllowed(self, toAllow=True):
4555         if self.algoType == NETGEN_2D:
4556             if toAllow: # add QuadranglePreference
4557                 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4558             else:       # remove QuadranglePreference
4559                 for hyp in self.mesh.GetHypothesisList( self.geom ):
4560                     if hyp.GetName() == "QuadranglePreference":
4561                         self.mesh.RemoveHypothesis( self.geom, hyp )
4562                         pass
4563                     pass
4564                 pass
4565             return
4566         if self.Parameters():
4567             self.params.SetQuadAllowed(toAllow)
4568             return
4569
4570     ## Defines hypothesis having several parameters
4571     #
4572     #  @ingroup l3_hypos_netgen
4573     def Parameters(self, which=SOLE):
4574         if self.params:
4575             return self.params
4576         if self.algoType == NETGEN:
4577             if which == SIMPLE:
4578                 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4579                                               "libNETGENEngine.so", UseExisting=0)
4580             else:
4581                 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4582                                               "libNETGENEngine.so", UseExisting=0)
4583             return self.params
4584         elif self.algoType == MEFISTO:
4585             print "Mefisto algo support no multi-parameter hypothesis"
4586             return None
4587         elif self.algoType == NETGEN_2D:
4588             print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4589             print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4590             return None
4591         elif self.algoType == BLSURF:
4592             self.params = self.Hypothesis("BLSURF_Parameters", [],
4593                                           "libBLSURFEngine.so", UseExisting=0)
4594             return self.params
4595         else:
4596             print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4597         return None
4598
4599     ## Sets MaxSize
4600     #
4601     #  Only for algoType == NETGEN
4602     #  @ingroup l3_hypos_netgen
4603     def SetMaxSize(self, theSize):
4604         if self.Parameters():
4605             self.params.SetMaxSize(theSize)
4606
4607     ## Sets SecondOrder flag
4608     #
4609     #  Only for algoType == NETGEN
4610     #  @ingroup l3_hypos_netgen
4611     def SetSecondOrder(self, theVal):
4612         if self.Parameters():
4613             self.params.SetSecondOrder(theVal)
4614
4615     ## Sets Optimize flag
4616     #
4617     #  Only for algoType == NETGEN
4618     #  @ingroup l3_hypos_netgen
4619     def SetOptimize(self, theVal):
4620         if self.Parameters():
4621             self.params.SetOptimize(theVal)
4622
4623     ## Sets Fineness
4624     #  @param theFineness is:
4625     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4626     #
4627     #  Only for algoType == NETGEN
4628     #  @ingroup l3_hypos_netgen
4629     def SetFineness(self, theFineness):
4630         if self.Parameters():
4631             self.params.SetFineness(theFineness)
4632
4633     ## Sets GrowthRate
4634     #
4635     #  Only for algoType == NETGEN
4636     #  @ingroup l3_hypos_netgen
4637     def SetGrowthRate(self, theRate):
4638         if self.Parameters():
4639             self.params.SetGrowthRate(theRate)
4640
4641     ## Sets NbSegPerEdge
4642     #
4643     #  Only for algoType == NETGEN
4644     #  @ingroup l3_hypos_netgen
4645     def SetNbSegPerEdge(self, theVal):
4646         if self.Parameters():
4647             self.params.SetNbSegPerEdge(theVal)
4648
4649     ## Sets NbSegPerRadius
4650     #
4651     #  Only for algoType == NETGEN
4652     #  @ingroup l3_hypos_netgen
4653     def SetNbSegPerRadius(self, theVal):
4654         if self.Parameters():
4655             self.params.SetNbSegPerRadius(theVal)
4656
4657     ## Sets number of segments overriding value set by SetLocalLength()
4658     #
4659     #  Only for algoType == NETGEN
4660     #  @ingroup l3_hypos_netgen
4661     def SetNumberOfSegments(self, theVal):
4662         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4663
4664     ## Sets number of segments overriding value set by SetNumberOfSegments()
4665     #
4666     #  Only for algoType == NETGEN
4667     #  @ingroup l3_hypos_netgen
4668     def SetLocalLength(self, theVal):
4669         self.Parameters(SIMPLE).SetLocalLength(theVal)
4670
4671     pass
4672
4673
4674 # Public class: Mesh_Quadrangle
4675 # -----------------------------
4676
4677 ## Defines a quadrangle 2D algorithm
4678 #
4679 #  @ingroup l3_algos_basic
4680 class Mesh_Quadrangle(Mesh_Algorithm):
4681
4682     ## Private constructor.
4683     def __init__(self, mesh, geom=0):
4684         Mesh_Algorithm.__init__(self)
4685         self.Create(mesh, geom, "Quadrangle_2D")
4686
4687     ## Defines "QuadranglePreference" hypothesis, forcing construction
4688     #  of quadrangles if the number of nodes on the opposite edges is not the same
4689     #  while the total number of nodes on edges is even
4690     #
4691     #  @ingroup l3_hypos_additi
4692     def QuadranglePreference(self):
4693         hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4694                               CompareMethod=self.CompareEqualHyp)
4695         return hyp
4696
4697     ## Defines "TrianglePreference" hypothesis, forcing construction
4698     #  of triangles in the refinement area if the number of nodes
4699     #  on the opposite edges is not the same
4700     #
4701     #  @ingroup l3_hypos_additi
4702     def TrianglePreference(self):
4703         hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4704                               CompareMethod=self.CompareEqualHyp)
4705         return hyp
4706
4707     ## Defines "QuadrangleParams" hypothesis
4708     #  @param vertex: vertex of a trilateral geometrical face, around which triangles
4709     #                 will be created while other elements will be quadrangles.
4710     #                 Vertex can be either a GEOM_Object or a vertex ID within the
4711     #                 shape to mesh
4712     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
4713     #                   the same parameters, else (default) - creates a new one
4714     #
4715     #  @ingroup l3_hypos_additi
4716     def TriangleVertex(self, vertex, UseExisting=0):
4717         vertexID = vertex
4718         if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4719             vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4720         hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4721                               CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4722         hyp.SetTriaVertex( vertexID )
4723         return hyp
4724
4725
4726 # Public class: Mesh_Tetrahedron
4727 # ------------------------------
4728
4729 ## Defines a tetrahedron 3D algorithm
4730 #
4731 #  @ingroup l3_algos_basic
4732 class Mesh_Tetrahedron(Mesh_Algorithm):
4733
4734     params = 0
4735     algoType = 0
4736
4737     ## Private constructor.
4738     def __init__(self, mesh, algoType, geom=0):
4739         Mesh_Algorithm.__init__(self)
4740
4741         if algoType == NETGEN:
4742             CheckPlugin(NETGEN)
4743             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4744             pass
4745
4746         elif algoType == FULL_NETGEN:
4747             CheckPlugin(NETGEN)
4748             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4749             pass
4750
4751         elif algoType == GHS3D:
4752             CheckPlugin(GHS3D)
4753             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4754             pass
4755
4756         elif algoType == GHS3DPRL:
4757             CheckPlugin(GHS3DPRL)
4758             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4759             pass
4760
4761         self.algoType = algoType
4762
4763     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4764     #  @param vol for the maximum volume of each tetrahedron
4765     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4766     #                   the same parameters, else (default) - creates a new one
4767     #  @ingroup l3_hypos_maxvol
4768     def MaxElementVolume(self, vol, UseExisting=0):
4769         if self.algoType == NETGEN:
4770             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4771                                   CompareMethod=self.CompareMaxElementVolume)
4772             hyp.SetMaxElementVolume(vol)
4773             return hyp
4774         elif self.algoType == FULL_NETGEN:
4775             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4776         return None
4777
4778     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4779     def CompareMaxElementVolume(self, hyp, args):
4780         return IsEqual(hyp.GetMaxElementVolume(), args[0])
4781
4782     ## Defines hypothesis having several parameters
4783     #
4784     #  @ingroup l3_hypos_netgen
4785     def Parameters(self, which=SOLE):
4786         if self.params:
4787             return self.params
4788
4789         if self.algoType == FULL_NETGEN:
4790             if which == SIMPLE:
4791                 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4792                                               "libNETGENEngine.so", UseExisting=0)
4793             else:
4794                 self.params = self.Hypothesis("NETGEN_Parameters", [],
4795                                               "libNETGENEngine.so", UseExisting=0)
4796             return self.params
4797
4798         if self.algoType == GHS3D:
4799             self.params = self.Hypothesis("GHS3D_Parameters", [],
4800                                           "libGHS3DEngine.so", UseExisting=0)
4801             return self.params
4802
4803         if self.algoType == GHS3DPRL:
4804             self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4805                                           "libGHS3DPRLEngine.so", UseExisting=0)
4806             return self.params
4807
4808         print "Algo supports no multi-parameter hypothesis"
4809         return None
4810
4811     ## Sets MaxSize
4812     #  Parameter of FULL_NETGEN
4813     #  @ingroup l3_hypos_netgen
4814     def SetMaxSize(self, theSize):
4815         self.Parameters().SetMaxSize(theSize)
4816
4817     ## Sets SecondOrder flag
4818     #  Parameter of FULL_NETGEN
4819     #  @ingroup l3_hypos_netgen
4820     def SetSecondOrder(self, theVal):
4821         self.Parameters().SetSecondOrder(theVal)
4822
4823     ## Sets Optimize flag
4824     #  Parameter of FULL_NETGEN
4825     #  @ingroup l3_hypos_netgen
4826     def SetOptimize(self, theVal):
4827         self.Parameters().SetOptimize(theVal)
4828
4829     ## Sets Fineness
4830     #  @param theFineness is:
4831     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4832     #  Parameter of FULL_NETGEN
4833     #  @ingroup l3_hypos_netgen
4834     def SetFineness(self, theFineness):
4835         self.Parameters().SetFineness(theFineness)
4836
4837     ## Sets GrowthRate
4838     #  Parameter of FULL_NETGEN
4839     #  @ingroup l3_hypos_netgen
4840     def SetGrowthRate(self, theRate):
4841         self.Parameters().SetGrowthRate(theRate)
4842
4843     ## Sets NbSegPerEdge
4844     #  Parameter of FULL_NETGEN
4845     #  @ingroup l3_hypos_netgen
4846     def SetNbSegPerEdge(self, theVal):
4847         self.Parameters().SetNbSegPerEdge(theVal)
4848
4849     ## Sets NbSegPerRadius
4850     #  Parameter of FULL_NETGEN
4851     #  @ingroup l3_hypos_netgen
4852     def SetNbSegPerRadius(self, theVal):
4853         self.Parameters().SetNbSegPerRadius(theVal)
4854
4855     ## Sets number of segments overriding value set by SetLocalLength()
4856     #  Only for algoType == NETGEN_FULL
4857     #  @ingroup l3_hypos_netgen
4858     def SetNumberOfSegments(self, theVal):
4859         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4860
4861     ## Sets number of segments overriding value set by SetNumberOfSegments()
4862     #  Only for algoType == NETGEN_FULL
4863     #  @ingroup l3_hypos_netgen
4864     def SetLocalLength(self, theVal):
4865         self.Parameters(SIMPLE).SetLocalLength(theVal)
4866
4867     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4868     #  Overrides value set by LengthFromEdges()
4869     #  Only for algoType == NETGEN_FULL
4870     #  @ingroup l3_hypos_netgen
4871     def MaxElementArea(self, area):
4872         self.Parameters(SIMPLE).SetMaxElementArea(area)
4873
4874     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4875     #  Overrides value set by MaxElementArea()
4876     #  Only for algoType == NETGEN_FULL
4877     #  @ingroup l3_hypos_netgen
4878     def LengthFromEdges(self):
4879         self.Parameters(SIMPLE).LengthFromEdges()
4880
4881     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4882     #  Overrides value set by MaxElementVolume()
4883     #  Only for algoType == NETGEN_FULL
4884     #  @ingroup l3_hypos_netgen
4885     def LengthFromFaces(self):
4886         self.Parameters(SIMPLE).LengthFromFaces()
4887
4888     ## To mesh "holes" in a solid or not. Default is to mesh.
4889     #  @ingroup l3_hypos_ghs3dh
4890     def SetToMeshHoles(self, toMesh):
4891         #  Parameter of GHS3D
4892         self.Parameters().SetToMeshHoles(toMesh)
4893
4894     ## Set Optimization level:
4895     #   None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4896     #   Strong_Optimization.
4897     # Default is Standard_Optimization
4898     #  @ingroup l3_hypos_ghs3dh
4899     def SetOptimizationLevel(self, level):
4900         #  Parameter of GHS3D
4901         self.Parameters().SetOptimizationLevel(level)
4902
4903     ## Maximal size of memory to be used by the algorithm (in Megabytes).
4904     #  @ingroup l3_hypos_ghs3dh
4905     def SetMaximumMemory(self, MB):
4906         #  Advanced parameter of GHS3D
4907         self.Parameters().SetMaximumMemory(MB)
4908
4909     ## Initial size of memory to be used by the algorithm (in Megabytes) in
4910     #  automatic memory adjustment mode.
4911     #  @ingroup l3_hypos_ghs3dh
4912     def SetInitialMemory(self, MB):
4913         #  Advanced parameter of GHS3D
4914         self.Parameters().SetInitialMemory(MB)
4915
4916     ## Path to working directory.
4917     #  @ingroup l3_hypos_ghs3dh
4918     def SetWorkingDirectory(self, path):
4919         #  Advanced parameter of GHS3D
4920         self.Parameters().SetWorkingDirectory(path)
4921
4922     ## To keep working files or remove them. Log file remains in case of errors anyway.
4923     #  @ingroup l3_hypos_ghs3dh
4924     def SetKeepFiles(self, toKeep):
4925         #  Advanced parameter of GHS3D and GHS3DPRL
4926         self.Parameters().SetKeepFiles(toKeep)
4927
4928     ## To set verbose level [0-10]. <ul>
4929     #<li> 0 - no standard output,
4930     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4931     #     indicates when the final mesh is being saved. In addition the software
4932     #     gives indication regarding the CPU time.
4933     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4934     #     histogram of the skin mesh, quality statistics histogram together with
4935     #     the characteristics of the final mesh.</ul>
4936     #  @ingroup l3_hypos_ghs3dh
4937     def SetVerboseLevel(self, level):
4938         #  Advanced parameter of GHS3D
4939         self.Parameters().SetVerboseLevel(level)
4940
4941     ## To create new nodes.
4942     #  @ingroup l3_hypos_ghs3dh
4943     def SetToCreateNewNodes(self, toCreate):
4944         #  Advanced parameter of GHS3D
4945         self.Parameters().SetToCreateNewNodes(toCreate)
4946
4947     ## To use boundary recovery version which tries to create mesh on a very poor
4948     #  quality surface mesh.
4949     #  @ingroup l3_hypos_ghs3dh
4950     def SetToUseBoundaryRecoveryVersion(self, toUse):
4951         #  Advanced parameter of GHS3D
4952         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4953
4954     ## Sets command line option as text.
4955     #  @ingroup l3_hypos_ghs3dh
4956     def SetTextOption(self, option):
4957         #  Advanced parameter of GHS3D
4958         self.Parameters().SetTextOption(option)
4959
4960     ## Sets MED files name and path.
4961     def SetMEDName(self, value):
4962         self.Parameters().SetMEDName(value)
4963
4964     ## Sets the number of partition of the initial mesh
4965     def SetNbPart(self, value):
4966         self.Parameters().SetNbPart(value)
4967
4968     ## When big mesh, start tepal in background
4969     def SetBackground(self, value):
4970         self.Parameters().SetBackground(value)
4971
4972 # Public class: Mesh_Hexahedron
4973 # ------------------------------
4974
4975 ## Defines a hexahedron 3D algorithm
4976 #
4977 #  @ingroup l3_algos_basic
4978 class Mesh_Hexahedron(Mesh_Algorithm):
4979
4980     params = 0
4981     algoType = 0
4982
4983     ## Private constructor.
4984     def __init__(self, mesh, algoType=Hexa, geom=0):
4985         Mesh_Algorithm.__init__(self)
4986
4987         self.algoType = algoType
4988
4989         if algoType == Hexa:
4990             self.Create(mesh, geom, "Hexa_3D")
4991             pass
4992
4993         elif algoType == Hexotic:
4994             CheckPlugin(Hexotic)
4995             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4996             pass
4997
4998     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4999     #  @ingroup l3_hypos_hexotic
5000     def MinMaxQuad(self, min=3, max=8, quad=True):
5001         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5002                                       UseExisting=0)
5003         self.params.SetHexesMinLevel(min)
5004         self.params.SetHexesMaxLevel(max)
5005         self.params.SetHexoticQuadrangles(quad)
5006         return self.params
5007
5008 # Deprecated, only for compatibility!
5009 # Public class: Mesh_Netgen
5010 # ------------------------------
5011
5012 ## Defines a NETGEN-based 2D or 3D algorithm
5013 #  that needs no discrete boundary (i.e. independent)
5014 #
5015 #  This class is deprecated, only for compatibility!
5016 #
5017 #  More details.
5018 #  @ingroup l3_algos_basic
5019 class Mesh_Netgen(Mesh_Algorithm):
5020
5021     is3D = 0
5022
5023     ## Private constructor.
5024     def __init__(self, mesh, is3D, geom=0):
5025         Mesh_Algorithm.__init__(self)
5026
5027         CheckPlugin(NETGEN)
5028
5029         self.is3D = is3D
5030         if is3D:
5031             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5032             pass
5033
5034         else:
5035             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5036             pass
5037
5038     ## Defines the hypothesis containing parameters of the algorithm
5039     def Parameters(self):
5040         if self.is3D:
5041             hyp = self.Hypothesis("NETGEN_Parameters", [],
5042                                   "libNETGENEngine.so", UseExisting=0)
5043         else:
5044             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5045                                   "libNETGENEngine.so", UseExisting=0)
5046         return hyp
5047
5048 # Public class: Mesh_Projection1D
5049 # ------------------------------
5050
5051 ## Defines a projection 1D algorithm
5052 #  @ingroup l3_algos_proj
5053 #
5054 class Mesh_Projection1D(Mesh_Algorithm):
5055
5056     ## Private constructor.
5057     def __init__(self, mesh, geom=0):
5058         Mesh_Algorithm.__init__(self)
5059         self.Create(mesh, geom, "Projection_1D")
5060
5061     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5062     #  a mesh pattern is taken, and, optionally, the association of vertices
5063     #  between the source edge and a target edge (to which a hypothesis is assigned)
5064     #  @param edge from which nodes distribution is taken
5065     #  @param mesh from which nodes distribution is taken (optional)
5066     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5067     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5068     #  to associate with \a srcV (optional)
5069     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5070     #                     the same parameters, else (default) - creates a new one
5071     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5072         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5073                               UseExisting=0)
5074                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5075         hyp.SetSourceEdge( edge )
5076         if not mesh is None and isinstance(mesh, Mesh):
5077             mesh = mesh.GetMesh()
5078         hyp.SetSourceMesh( mesh )
5079         hyp.SetVertexAssociation( srcV, tgtV )
5080         return hyp
5081
5082     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5083     #def CompareSourceEdge(self, hyp, args):
5084     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5085     #    return False
5086
5087
5088 # Public class: Mesh_Projection2D
5089 # ------------------------------
5090
5091 ## Defines a projection 2D algorithm
5092 #  @ingroup l3_algos_proj
5093 #
5094 class Mesh_Projection2D(Mesh_Algorithm):
5095
5096     ## Private constructor.
5097     def __init__(self, mesh, geom=0):
5098         Mesh_Algorithm.__init__(self)
5099         self.Create(mesh, geom, "Projection_2D")
5100
5101     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5102     #  a mesh pattern is taken, and, optionally, the association of vertices
5103     #  between the source face and the target face (to which a hypothesis is assigned)
5104     #  @param face from which the mesh pattern is taken
5105     #  @param mesh from which the mesh pattern is taken (optional)
5106     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5107     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5108     #               to associate with \a srcV1 (optional)
5109     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5110     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5111     #               to associate with \a srcV2 (optional)
5112     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
5113     #                     the same parameters, else (default) - forces the creation a new one
5114     #
5115     #  Note: all association vertices must belong to one edge of a face
5116     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5117                    srcV2=None, tgtV2=None, UseExisting=0):
5118         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5119                               UseExisting=0)
5120                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5121         hyp.SetSourceFace( face )
5122         if not mesh is None and isinstance(mesh, Mesh):
5123             mesh = mesh.GetMesh()
5124         hyp.SetSourceMesh( mesh )
5125         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5126         return hyp
5127
5128     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5129     #def CompareSourceFace(self, hyp, args):
5130     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5131     #    return False
5132
5133 # Public class: Mesh_Projection3D
5134 # ------------------------------
5135
5136 ## Defines a projection 3D algorithm
5137 #  @ingroup l3_algos_proj
5138 #
5139 class Mesh_Projection3D(Mesh_Algorithm):
5140
5141     ## Private constructor.
5142     def __init__(self, mesh, geom=0):
5143         Mesh_Algorithm.__init__(self)
5144         self.Create(mesh, geom, "Projection_3D")
5145
5146     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5147     #  the mesh pattern is taken, and, optionally, the  association of vertices
5148     #  between the source and the target solid  (to which a hipothesis is assigned)
5149     #  @param solid from where the mesh pattern is taken
5150     #  @param mesh from where the mesh pattern is taken (optional)
5151     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5152     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5153     #  to associate with \a srcV1 (optional)
5154     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5155     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5156     #  to associate with \a srcV2 (optional)
5157     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
5158     #                     the same parameters, else (default) - creates a new one
5159     #
5160     #  Note: association vertices must belong to one edge of a solid
5161     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5162                       srcV2=0, tgtV2=0, UseExisting=0):
5163         hyp = self.Hypothesis("ProjectionSource3D",
5164                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5165                               UseExisting=0)
5166                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5167         hyp.SetSource3DShape( solid )
5168         if not mesh is None and isinstance(mesh, Mesh):
5169             mesh = mesh.GetMesh()
5170         hyp.SetSourceMesh( mesh )
5171         if srcV1 and srcV2 and tgtV1 and tgtV2:
5172             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5173         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5174         return hyp
5175
5176     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5177     #def CompareSourceShape3D(self, hyp, args):
5178     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5179     #    return False
5180
5181
5182 # Public class: Mesh_Prism
5183 # ------------------------
5184
5185 ## Defines a 3D extrusion algorithm
5186 #  @ingroup l3_algos_3dextr
5187 #
5188 class Mesh_Prism3D(Mesh_Algorithm):
5189
5190     ## Private constructor.
5191     def __init__(self, mesh, geom=0):
5192         Mesh_Algorithm.__init__(self)
5193         self.Create(mesh, geom, "Prism_3D")
5194
5195 # Public class: Mesh_RadialPrism
5196 # -------------------------------
5197
5198 ## Defines a Radial Prism 3D algorithm
5199 #  @ingroup l3_algos_radialp
5200 #
5201 class Mesh_RadialPrism3D(Mesh_Algorithm):
5202
5203     ## Private constructor.
5204     def __init__(self, mesh, geom=0):
5205         Mesh_Algorithm.__init__(self)
5206         self.Create(mesh, geom, "RadialPrism_3D")
5207
5208         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5209         self.nbLayers = None
5210
5211     ## Return 3D hypothesis holding the 1D one
5212     def Get3DHypothesis(self):
5213         return self.distribHyp
5214
5215     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5216     #  hypothesis. Returns the created hypothesis
5217     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5218         #print "OwnHypothesis",hypType
5219         if not self.nbLayers is None:
5220             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5221             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5222         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5223         self.mesh.smeshpyD.SetCurrentStudy( None )
5224         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5225         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5226         self.distribHyp.SetLayerDistribution( hyp )
5227         return hyp
5228
5229     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5230     #  prisms to build between the inner and outer shells
5231     #  @param n number of layers
5232     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5233     #                     the same parameters, else (default) - creates a new one
5234     def NumberOfLayers(self, n, UseExisting=0):
5235         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5236         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5237                                         CompareMethod=self.CompareNumberOfLayers)
5238         self.nbLayers.SetNumberOfLayers( n )
5239         return self.nbLayers
5240
5241     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5242     def CompareNumberOfLayers(self, hyp, args):
5243         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5244
5245     ## Defines "LocalLength" hypothesis, specifying the segment length
5246     #  to build between the inner and the outer shells
5247     #  @param l the length of segments
5248     #  @param p the precision of rounding
5249     def LocalLength(self, l, p=1e-07):
5250         hyp = self.OwnHypothesis("LocalLength", [l,p])
5251         hyp.SetLength(l)
5252         hyp.SetPrecision(p)
5253         return hyp
5254
5255     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5256     #  prisms to build between the inner and the outer shells.
5257     #  @param n the number of layers
5258     #  @param s the scale factor (optional)
5259     def NumberOfSegments(self, n, s=[]):
5260         if s == []:
5261             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5262         else:
5263             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5264             hyp.SetDistrType( 1 )
5265             hyp.SetScaleFactor(s)
5266         hyp.SetNumberOfSegments(n)
5267         return hyp
5268
5269     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5270     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
5271     #  @param start  the length of the first segment
5272     #  @param end    the length of the last  segment
5273     def Arithmetic1D(self, start, end ):
5274         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5275         hyp.SetLength(start, 1)
5276         hyp.SetLength(end  , 0)
5277         return hyp
5278
5279     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5280     #  to build between the inner and the outer shells as geometric length increasing
5281     #  @param start for the length of the first segment
5282     #  @param end   for the length of the last  segment
5283     def StartEndLength(self, start, end):
5284         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5285         hyp.SetLength(start, 1)
5286         hyp.SetLength(end  , 0)
5287         return hyp
5288
5289     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5290     #  to build between the inner and outer shells
5291     #  @param fineness defines the quality of the mesh within the range [0-1]
5292     def AutomaticLength(self, fineness=0):
5293         hyp = self.OwnHypothesis("AutomaticLength")
5294         hyp.SetFineness( fineness )
5295         return hyp
5296
5297 # Public class: Mesh_RadialQuadrangle1D2D
5298 # -------------------------------
5299
5300 ## Defines a Radial Quadrangle 1D2D algorithm
5301 #  @ingroup l2_algos_radialq
5302 #
5303 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5304
5305     ## Private constructor.
5306     def __init__(self, mesh, geom=0):
5307         Mesh_Algorithm.__init__(self)
5308         self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5309
5310         self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5311         self.nbLayers = None
5312
5313     ## Return 2D hypothesis holding the 1D one
5314     def Get2DHypothesis(self):
5315         return self.distribHyp
5316
5317     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5318     #  hypothesis. Returns the created hypothesis
5319     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5320         #print "OwnHypothesis",hypType
5321         if self.nbLayers:
5322             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5323         if self.distribHyp is None:
5324             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5325         else:
5326             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5327         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5328         self.mesh.smeshpyD.SetCurrentStudy( None )
5329         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5330         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5331         self.distribHyp.SetLayerDistribution( hyp )
5332         return hyp
5333
5334     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5335     #  @param n number of layers
5336     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5337     #                     the same parameters, else (default) - creates a new one
5338     def NumberOfLayers(self, n, UseExisting=0):
5339         if self.distribHyp:
5340             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5341         self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5342                                         CompareMethod=self.CompareNumberOfLayers)
5343         self.nbLayers.SetNumberOfLayers( n )
5344         return self.nbLayers
5345
5346     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5347     def CompareNumberOfLayers(self, hyp, args):
5348         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5349
5350     ## Defines "LocalLength" hypothesis, specifying the segment length
5351     #  @param l the length of segments
5352     #  @param p the precision of rounding
5353     def LocalLength(self, l, p=1e-07):
5354         hyp = self.OwnHypothesis("LocalLength", [l,p])
5355         hyp.SetLength(l)
5356         hyp.SetPrecision(p)
5357         return hyp
5358
5359     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5360     #  @param n the number of layers
5361     #  @param s the scale factor (optional)
5362     def NumberOfSegments(self, n, s=[]):
5363         if s == []:
5364             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5365         else:
5366             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5367             hyp.SetDistrType( 1 )
5368             hyp.SetScaleFactor(s)
5369         hyp.SetNumberOfSegments(n)
5370         return hyp
5371
5372     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5373     #  with a length that changes in arithmetic progression
5374     #  @param start  the length of the first segment
5375     #  @param end    the length of the last  segment
5376     def Arithmetic1D(self, start, end ):
5377         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5378         hyp.SetLength(start, 1)
5379         hyp.SetLength(end  , 0)
5380         return hyp
5381
5382     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5383     #  as geometric length increasing
5384     #  @param start for the length of the first segment
5385     #  @param end   for the length of the last  segment
5386     def StartEndLength(self, start, end):
5387         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5388         hyp.SetLength(start, 1)
5389         hyp.SetLength(end  , 0)
5390         return hyp
5391
5392     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5393     #  @param fineness defines the quality of the mesh within the range [0-1]
5394     def AutomaticLength(self, fineness=0):
5395         hyp = self.OwnHypothesis("AutomaticLength")
5396         hyp.SetFineness( fineness )
5397         return hyp
5398
5399
5400 # Private class: Mesh_UseExisting
5401 # -------------------------------
5402 class Mesh_UseExisting(Mesh_Algorithm):
5403
5404     def __init__(self, dim, mesh, geom=0):
5405         if dim == 1:
5406             self.Create(mesh, geom, "UseExisting_1D")
5407         else:
5408             self.Create(mesh, geom, "UseExisting_2D")
5409
5410
5411 import salome_notebook
5412 notebook = salome_notebook.notebook
5413
5414 ##Return values of the notebook variables
5415 def ParseParameters(last, nbParams,nbParam, value):
5416     result = None
5417     strResult = ""
5418     counter = 0
5419     listSize = len(last)
5420     for n in range(0,nbParams):
5421         if n+1 != nbParam:
5422             if counter < listSize:
5423                 strResult = strResult + last[counter]
5424             else:
5425                 strResult = strResult + ""
5426         else:
5427             if isinstance(value, str):
5428                 if notebook.isVariable(value):
5429                     result = notebook.get(value)
5430                     strResult=strResult+value
5431                 else:
5432                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5433             else:
5434                 strResult=strResult+str(value)
5435                 result = value
5436         if nbParams - 1 != counter:
5437             strResult=strResult+var_separator #":"
5438         counter = counter+1
5439     return result, strResult
5440
5441 #Wrapper class for StdMeshers_LocalLength hypothesis
5442 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5443
5444     ## Set Length parameter value
5445     #  @param length numerical value or name of variable from notebook
5446     def SetLength(self, length):
5447         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5448         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5449         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5450
5451    ## Set Precision parameter value
5452    #  @param precision numerical value or name of variable from notebook
5453     def SetPrecision(self, precision):
5454         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5455         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5456         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5457
5458 #Registering the new proxy for LocalLength
5459 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5460
5461
5462 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5463 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5464     
5465     def SetLayerDistribution(self, hypo):
5466         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5467         hypo.ClearParameters();
5468         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5469
5470 #Registering the new proxy for LayerDistribution
5471 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5472
5473 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5474 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5475     
5476     ## Set Length parameter value
5477     #  @param length numerical value or name of variable from notebook    
5478     def SetLength(self, length):
5479         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5480         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5481         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5482
5483 #Registering the new proxy for SegmentLengthAroundVertex
5484 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5485
5486
5487 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5488 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5489     
5490     ## Set Length parameter value
5491     #  @param length   numerical value or name of variable from notebook
5492     #  @param isStart  true is length is Start Length, otherwise false
5493     def SetLength(self, length, isStart):
5494         nb = 2
5495         if isStart:
5496             nb = 1
5497         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5498         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5499         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5500         
5501 #Registering the new proxy for Arithmetic1D
5502 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5503
5504 #Wrapper class for StdMeshers_Deflection1D hypothesis
5505 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5506     
5507     ## Set Deflection parameter value
5508     #  @param deflection numerical value or name of variable from notebook    
5509     def SetDeflection(self, deflection):
5510         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5511         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5512         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5513
5514 #Registering the new proxy for Deflection1D
5515 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5516
5517 #Wrapper class for StdMeshers_StartEndLength hypothesis
5518 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5519     
5520     ## Set Length parameter value
5521     #  @param length  numerical value or name of variable from notebook
5522     #  @param isStart true is length is Start Length, otherwise false
5523     def SetLength(self, length, isStart):
5524         nb = 2
5525         if isStart:
5526             nb = 1
5527         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5528         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5529         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5530         
5531 #Registering the new proxy for StartEndLength
5532 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5533
5534 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5535 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5536     
5537     ## Set Max Element Area parameter value
5538     #  @param area  numerical value or name of variable from notebook
5539     def SetMaxElementArea(self, area):
5540         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5541         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5542         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5543         
5544 #Registering the new proxy for MaxElementArea
5545 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5546
5547
5548 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5549 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5550     
5551     ## Set Max Element Volume parameter value
5552     #  @param volume numerical value or name of variable from notebook
5553     def SetMaxElementVolume(self, volume):
5554         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5555         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5556         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5557         
5558 #Registering the new proxy for MaxElementVolume
5559 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5560
5561
5562 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5563 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5564     
5565     ## Set Number Of Layers parameter value
5566     #  @param nbLayers  numerical value or name of variable from notebook
5567     def SetNumberOfLayers(self, nbLayers):
5568         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5569         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5570         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5571         
5572 #Registering the new proxy for NumberOfLayers
5573 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5574
5575 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5576 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5577     
5578     ## Set Number Of Segments parameter value
5579     #  @param nbSeg numerical value or name of variable from notebook
5580     def SetNumberOfSegments(self, nbSeg):
5581         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5582         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5583         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5584         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5585         
5586     ## Set Scale Factor parameter value
5587     #  @param factor numerical value or name of variable from notebook
5588     def SetScaleFactor(self, factor):
5589         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5590         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5591         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5592         
5593 #Registering the new proxy for NumberOfSegments
5594 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5595
5596 if not noNETGENPlugin:
5597     #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5598     class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5599
5600         ## Set Max Size parameter value
5601         #  @param maxsize numerical value or name of variable from notebook
5602         def SetMaxSize(self, maxsize):
5603             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5604             maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5605             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5606             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5607
5608         ## Set Growth Rate parameter value
5609         #  @param value  numerical value or name of variable from notebook
5610         def SetGrowthRate(self, value):
5611             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5612             value, parameters = ParseParameters(lastParameters,4,2,value)
5613             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5614             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5615
5616         ## Set Number of Segments per Edge parameter value
5617         #  @param value  numerical value or name of variable from notebook
5618         def SetNbSegPerEdge(self, value):
5619             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5620             value, parameters = ParseParameters(lastParameters,4,3,value)
5621             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5622             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5623
5624         ## Set Number of Segments per Radius parameter value
5625         #  @param value  numerical value or name of variable from notebook
5626         def SetNbSegPerRadius(self, value):
5627             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5628             value, parameters = ParseParameters(lastParameters,4,4,value)
5629             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5630             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5631
5632     #Registering the new proxy for NETGENPlugin_Hypothesis
5633     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5634
5635
5636     #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5637     class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5638         pass
5639
5640     #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5641     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5642
5643     #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5644     class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5645
5646         ## Set Number of Segments parameter value
5647         #  @param nbSeg numerical value or name of variable from notebook
5648         def SetNumberOfSegments(self, nbSeg):
5649             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5650             nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5651             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5652             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5653
5654         ## Set Local Length parameter value
5655         #  @param length numerical value or name of variable from notebook
5656         def SetLocalLength(self, length):
5657             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5658             length, parameters = ParseParameters(lastParameters,2,1,length)
5659             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5660             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5661
5662         ## Set Max Element Area parameter value
5663         #  @param area numerical value or name of variable from notebook    
5664         def SetMaxElementArea(self, area):
5665             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5666             area, parameters = ParseParameters(lastParameters,2,2,area)
5667             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5668             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5669
5670         def LengthFromEdges(self):
5671             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5672             value = 0;
5673             value, parameters = ParseParameters(lastParameters,2,2,value)
5674             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5675             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5676
5677     #Registering the new proxy for NETGEN_SimpleParameters_2D
5678     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5679
5680
5681     #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5682     class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5683         ## Set Max Element Volume parameter value
5684         #  @param volume numerical value or name of variable from notebook    
5685         def SetMaxElementVolume(self, volume):
5686             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5687             volume, parameters = ParseParameters(lastParameters,3,3,volume)
5688             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5689             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5690
5691         def LengthFromFaces(self):
5692             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5693             value = 0;
5694             value, parameters = ParseParameters(lastParameters,3,3,value)
5695             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5696             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5697
5698     #Registering the new proxy for NETGEN_SimpleParameters_3D
5699     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5700
5701     pass # if not noNETGENPlugin:
5702
5703 class Pattern(SMESH._objref_SMESH_Pattern):
5704
5705     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5706         flag = False
5707         if isinstance(theNodeIndexOnKeyPoint1,str):
5708             flag = True
5709         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5710         if flag:
5711             theNodeIndexOnKeyPoint1 -= 1
5712         theMesh.SetParameters(Parameters)
5713         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5714
5715     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5716         flag0 = False
5717         flag1 = False
5718         if isinstance(theNode000Index,str):
5719             flag0 = True
5720         if isinstance(theNode001Index,str):
5721             flag1 = True
5722         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5723         if flag0:
5724             theNode000Index -= 1
5725         if flag1:
5726             theNode001Index -= 1
5727         theMesh.SetParameters(Parameters)
5728         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5729
5730 #Registering the new proxy for Pattern
5731 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)