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