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