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