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