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