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