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