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