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