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