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