Salome HOME
improve comments of MakeBoundaryMesh()
[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                     name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1095                     geompyD.addToStudy( self.geom, 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     ## Renumber mesh nodes
3113     #  @ingroup l2_modif_renumber
3114     def RenumberNodes(self):
3115         self.editor.RenumberNodes()
3116
3117     ## Renumber mesh elements
3118     #  @ingroup l2_modif_renumber
3119     def RenumberElements(self):
3120         self.editor.RenumberElements()
3121
3122     ## Generates new elements by rotation of the elements around the axis
3123     #  @param IDsOfElements the list of ids of elements to sweep
3124     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
3125     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3126     #  @param NbOfSteps the number of steps
3127     #  @param Tolerance tolerance
3128     #  @param MakeGroups forces the generation of new groups from existing ones
3129     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3130     #                    of all steps, else - size of each step
3131     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3132     #  @ingroup l2_modif_extrurev
3133     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3134                       MakeGroups=False, TotalAngle=False):
3135         flag = False
3136         if isinstance(AngleInRadians,str):
3137             flag = True
3138         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3139         if flag:
3140             AngleInRadians = DegreesToRadians(AngleInRadians)
3141         if IDsOfElements == []:
3142             IDsOfElements = self.GetElementsId()
3143         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3144             Axis = self.smeshpyD.GetAxisStruct(Axis)
3145         Axis,AxisParameters = ParseAxisStruct(Axis)
3146         if TotalAngle and NbOfSteps:
3147             AngleInRadians /= NbOfSteps
3148         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3149         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3150         self.mesh.SetParameters(Parameters)
3151         if MakeGroups:
3152             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3153                                                        AngleInRadians, NbOfSteps, Tolerance)
3154         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3155         return []
3156
3157     ## Generates new elements by rotation of the elements of object around the axis
3158     #  @param theObject object which elements should be sweeped.
3159     #                   It can be a mesh, a sub mesh or a group.
3160     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
3161     #  @param AngleInRadians the angle of Rotation
3162     #  @param NbOfSteps number of steps
3163     #  @param Tolerance tolerance
3164     #  @param MakeGroups forces the generation of new groups from existing ones
3165     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3166     #                    of all steps, else - size of each step
3167     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3168     #  @ingroup l2_modif_extrurev
3169     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3170                             MakeGroups=False, TotalAngle=False):
3171         flag = False
3172         if isinstance(AngleInRadians,str):
3173             flag = True
3174         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3175         if flag:
3176             AngleInRadians = DegreesToRadians(AngleInRadians)
3177         if ( isinstance( theObject, Mesh )):
3178             theObject = theObject.GetMesh()
3179         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3180             Axis = self.smeshpyD.GetAxisStruct(Axis)
3181         Axis,AxisParameters = ParseAxisStruct(Axis)
3182         if TotalAngle and NbOfSteps:
3183             AngleInRadians /= NbOfSteps
3184         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3185         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3186         self.mesh.SetParameters(Parameters)
3187         if MakeGroups:
3188             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3189                                                              NbOfSteps, Tolerance)
3190         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3191         return []
3192
3193     ## Generates new elements by rotation of the elements of object around the axis
3194     #  @param theObject object which elements should be sweeped.
3195     #                   It can be a mesh, a sub mesh or a group.
3196     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
3197     #  @param AngleInRadians the angle of Rotation
3198     #  @param NbOfSteps number of steps
3199     #  @param Tolerance tolerance
3200     #  @param MakeGroups forces the generation of new groups from existing ones
3201     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3202     #                    of all steps, else - size of each step
3203     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3204     #  @ingroup l2_modif_extrurev
3205     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3206                               MakeGroups=False, TotalAngle=False):
3207         flag = False
3208         if isinstance(AngleInRadians,str):
3209             flag = True
3210         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3211         if flag:
3212             AngleInRadians = DegreesToRadians(AngleInRadians)
3213         if ( isinstance( theObject, Mesh )):
3214             theObject = theObject.GetMesh()
3215         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3216             Axis = self.smeshpyD.GetAxisStruct(Axis)
3217         Axis,AxisParameters = ParseAxisStruct(Axis)
3218         if TotalAngle and NbOfSteps:
3219             AngleInRadians /= NbOfSteps
3220         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3221         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3222         self.mesh.SetParameters(Parameters)
3223         if MakeGroups:
3224             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3225                                                                NbOfSteps, Tolerance)
3226         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3227         return []
3228
3229     ## Generates new elements by rotation of the elements of object around the axis
3230     #  @param theObject object which elements should be sweeped.
3231     #                   It can be a mesh, a sub mesh or a group.
3232     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
3233     #  @param AngleInRadians the angle of Rotation
3234     #  @param NbOfSteps number of steps
3235     #  @param Tolerance tolerance
3236     #  @param MakeGroups forces the generation of new groups from existing ones
3237     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3238     #                    of all steps, else - size of each step
3239     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3240     #  @ingroup l2_modif_extrurev
3241     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3242                               MakeGroups=False, TotalAngle=False):
3243         flag = False
3244         if isinstance(AngleInRadians,str):
3245             flag = True
3246         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3247         if flag:
3248             AngleInRadians = DegreesToRadians(AngleInRadians)
3249         if ( isinstance( theObject, Mesh )):
3250             theObject = theObject.GetMesh()
3251         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3252             Axis = self.smeshpyD.GetAxisStruct(Axis)
3253         Axis,AxisParameters = ParseAxisStruct(Axis)
3254         if TotalAngle and NbOfSteps:
3255             AngleInRadians /= NbOfSteps
3256         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3257         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3258         self.mesh.SetParameters(Parameters)
3259         if MakeGroups:
3260             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3261                                                              NbOfSteps, Tolerance)
3262         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3263         return []
3264
3265     ## Generates new elements by extrusion of the elements with given ids
3266     #  @param IDsOfElements the list of elements ids for extrusion
3267     #  @param StepVector vector or DirStruct, defining the direction and value of extrusion
3268     #  @param NbOfSteps the number of steps
3269     #  @param MakeGroups forces the generation of new groups from existing ones
3270     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3271     #  @ingroup l2_modif_extrurev
3272     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3273         if IDsOfElements == []:
3274             IDsOfElements = self.GetElementsId()
3275         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3276             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3277         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3278         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3279         Parameters = StepVectorParameters + var_separator + Parameters
3280         self.mesh.SetParameters(Parameters)
3281         if MakeGroups:
3282             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3283         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3284         return []
3285
3286     ## Generates new elements by extrusion of the elements with given ids
3287     #  @param IDsOfElements is ids of elements
3288     #  @param StepVector vector, defining the direction and value of extrusion
3289     #  @param NbOfSteps the number of steps
3290     #  @param ExtrFlags sets flags for extrusion
3291     #  @param SewTolerance uses for comparing locations of nodes if flag
3292     #         EXTRUSION_FLAG_SEW is set
3293     #  @param MakeGroups forces the generation of new groups from existing ones
3294     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3295     #  @ingroup l2_modif_extrurev
3296     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3297                           ExtrFlags, SewTolerance, MakeGroups=False):
3298         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3299             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3300         if MakeGroups:
3301             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3302                                                            ExtrFlags, SewTolerance)
3303         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3304                                       ExtrFlags, SewTolerance)
3305         return []
3306
3307     ## Generates new elements by extrusion of the elements which belong to the object
3308     #  @param theObject the object which elements should be processed.
3309     #                   It can be a mesh, a sub mesh or a group.
3310     #  @param StepVector vector, defining the direction and value of extrusion
3311     #  @param NbOfSteps the number of steps
3312     #  @param MakeGroups forces the generation of new groups from existing ones
3313     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3314     #  @ingroup l2_modif_extrurev
3315     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3316         if ( isinstance( theObject, Mesh )):
3317             theObject = theObject.GetMesh()
3318         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3319             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3320         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3321         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3322         Parameters = StepVectorParameters + var_separator + Parameters
3323         self.mesh.SetParameters(Parameters)
3324         if MakeGroups:
3325             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3326         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3327         return []
3328
3329     ## Generates new elements by extrusion of the elements which belong to the object
3330     #  @param theObject object which elements should be processed.
3331     #                   It can be a mesh, a sub mesh or a group.
3332     #  @param StepVector vector, defining the direction and value of extrusion
3333     #  @param NbOfSteps the number of steps
3334     #  @param MakeGroups to generate new groups from existing ones
3335     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3336     #  @ingroup l2_modif_extrurev
3337     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3338         if ( isinstance( theObject, Mesh )):
3339             theObject = theObject.GetMesh()
3340         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3341             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3342         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3343         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3344         Parameters = StepVectorParameters + var_separator + Parameters
3345         self.mesh.SetParameters(Parameters)
3346         if MakeGroups:
3347             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3348         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3349         return []
3350
3351     ## Generates new elements by extrusion of the elements which belong to the object
3352     #  @param theObject object which elements should be processed.
3353     #                   It can be a mesh, a sub mesh or a group.
3354     #  @param StepVector vector, defining the direction and value of extrusion
3355     #  @param NbOfSteps the number of steps
3356     #  @param MakeGroups forces the generation of new groups from existing ones
3357     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3358     #  @ingroup l2_modif_extrurev
3359     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3360         if ( isinstance( theObject, Mesh )):
3361             theObject = theObject.GetMesh()
3362         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3363             StepVector = self.smeshpyD.GetDirStruct(StepVector)
3364         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3365         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3366         Parameters = StepVectorParameters + var_separator + Parameters
3367         self.mesh.SetParameters(Parameters)
3368         if MakeGroups:
3369             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3370         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3371         return []
3372
3373
3374
3375     ## Generates new elements by extrusion of the given elements
3376     #  The path of extrusion must be a meshed edge.
3377     #  @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3378     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3379     #  @param NodeStart the start node from Path. Defines the direction of extrusion
3380     #  @param HasAngles allows the shape to be rotated around the path
3381     #                   to get the resulting mesh in a helical fashion
3382     #  @param Angles list of angles in radians
3383     #  @param LinearVariation forces the computation of rotation angles as linear
3384     #                         variation of the given Angles along path steps
3385     #  @param HasRefPoint allows using the reference point
3386     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3387     #         The User can specify any point as the Reference Point.
3388     #  @param MakeGroups forces the generation of new groups from existing ones
3389     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
3390     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3391     #          only SMESH::Extrusion_Error otherwise
3392     #  @ingroup l2_modif_extrurev
3393     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3394                             HasAngles, Angles, LinearVariation,
3395                             HasRefPoint, RefPoint, MakeGroups, ElemType):
3396         Angles,AnglesParameters = ParseAngles(Angles)
3397         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3398         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3399             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3400             pass
3401         Parameters = AnglesParameters + var_separator + RefPointParameters
3402         self.mesh.SetParameters(Parameters)
3403
3404         if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3405
3406         if isinstance(Base, list):
3407             IDsOfElements = []
3408             if Base == []: IDsOfElements = self.GetElementsId()
3409             else: IDsOfElements = Base
3410             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3411                                                    HasAngles, Angles, LinearVariation,
3412                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
3413         else:
3414             if isinstance(Base, Mesh): Base = Base.GetMesh()
3415             if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3416                 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3417                                                           HasAngles, Angles, LinearVariation,
3418                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
3419             else:
3420                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3421
3422
3423     ## Generates new elements by extrusion of the given elements
3424     #  The path of extrusion must be a meshed edge.
3425     #  @param IDsOfElements ids of elements
3426     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3427     #  @param PathShape shape(edge) defines the sub-mesh for the path
3428     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3429     #  @param HasAngles allows the shape to be rotated around the path
3430     #                   to get the resulting mesh in a helical fashion
3431     #  @param Angles list of angles in radians
3432     #  @param HasRefPoint allows using the reference point
3433     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3434     #         The User can specify any point as the Reference Point.
3435     #  @param MakeGroups forces the generation of new groups from existing ones
3436     #  @param LinearVariation forces the computation of rotation angles as linear
3437     #                         variation of the given Angles along path steps
3438     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3439     #          only SMESH::Extrusion_Error otherwise
3440     #  @ingroup l2_modif_extrurev
3441     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3442                            HasAngles, Angles, HasRefPoint, RefPoint,
3443                            MakeGroups=False, LinearVariation=False):
3444         Angles,AnglesParameters = ParseAngles(Angles)
3445         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3446         if IDsOfElements == []:
3447             IDsOfElements = self.GetElementsId()
3448         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3449             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3450             pass
3451         if ( isinstance( PathMesh, Mesh )):
3452             PathMesh = PathMesh.GetMesh()
3453         if HasAngles and Angles and LinearVariation:
3454             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3455             pass
3456         Parameters = AnglesParameters + var_separator + RefPointParameters
3457         self.mesh.SetParameters(Parameters)
3458         if MakeGroups:
3459             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3460                                                             PathShape, NodeStart, HasAngles,
3461                                                             Angles, HasRefPoint, RefPoint)
3462         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3463                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3464
3465     ## Generates new elements by extrusion of the elements which belong to the object
3466     #  The path of extrusion must be a meshed edge.
3467     #  @param theObject the object which elements should be processed.
3468     #                   It can be a mesh, a sub mesh or a group.
3469     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3470     #  @param PathShape shape(edge) defines the sub-mesh for the path
3471     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3472     #  @param HasAngles allows the shape to be rotated around the path
3473     #                   to get the resulting mesh in a helical fashion
3474     #  @param Angles list of angles
3475     #  @param HasRefPoint allows using the reference point
3476     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3477     #         The User can specify any point as the Reference Point.
3478     #  @param MakeGroups forces the generation of new groups from existing ones
3479     #  @param LinearVariation forces the computation of rotation angles as linear
3480     #                         variation of the given Angles along path steps
3481     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3482     #          only SMESH::Extrusion_Error otherwise
3483     #  @ingroup l2_modif_extrurev
3484     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3485                                  HasAngles, Angles, HasRefPoint, RefPoint,
3486                                  MakeGroups=False, LinearVariation=False):
3487         Angles,AnglesParameters = ParseAngles(Angles)
3488         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3489         if ( isinstance( theObject, Mesh )):
3490             theObject = theObject.GetMesh()
3491         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3492             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3493         if ( isinstance( PathMesh, Mesh )):
3494             PathMesh = PathMesh.GetMesh()
3495         if HasAngles and Angles and LinearVariation:
3496             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3497             pass
3498         Parameters = AnglesParameters + var_separator + RefPointParameters
3499         self.mesh.SetParameters(Parameters)
3500         if MakeGroups:
3501             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3502                                                                   PathShape, NodeStart, HasAngles,
3503                                                                   Angles, HasRefPoint, RefPoint)
3504         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3505                                                     NodeStart, HasAngles, Angles, HasRefPoint,
3506                                                     RefPoint)
3507
3508     ## Generates new elements by extrusion of the elements which belong to the object
3509     #  The path of extrusion must be a meshed edge.
3510     #  @param theObject the object which elements should be processed.
3511     #                   It can be a mesh, a sub mesh or a group.
3512     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3513     #  @param PathShape shape(edge) defines the sub-mesh for the path
3514     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3515     #  @param HasAngles allows the shape to be rotated around the path
3516     #                   to get the resulting mesh in a helical fashion
3517     #  @param Angles list of angles
3518     #  @param HasRefPoint allows using the reference point
3519     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3520     #         The User can specify any point as the Reference Point.
3521     #  @param MakeGroups forces the generation of new groups from existing ones
3522     #  @param LinearVariation forces the computation of rotation angles as linear
3523     #                         variation of the given Angles along path steps
3524     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3525     #          only SMESH::Extrusion_Error otherwise
3526     #  @ingroup l2_modif_extrurev
3527     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3528                                    HasAngles, Angles, HasRefPoint, RefPoint,
3529                                    MakeGroups=False, LinearVariation=False):
3530         Angles,AnglesParameters = ParseAngles(Angles)
3531         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3532         if ( isinstance( theObject, Mesh )):
3533             theObject = theObject.GetMesh()
3534         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3535             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3536         if ( isinstance( PathMesh, Mesh )):
3537             PathMesh = PathMesh.GetMesh()
3538         if HasAngles and Angles and LinearVariation:
3539             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3540             pass
3541         Parameters = AnglesParameters + var_separator + RefPointParameters
3542         self.mesh.SetParameters(Parameters)
3543         if MakeGroups:
3544             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3545                                                                     PathShape, NodeStart, HasAngles,
3546                                                                     Angles, HasRefPoint, RefPoint)
3547         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3548                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3549                                                       RefPoint)
3550
3551     ## Generates new elements by extrusion of the elements which belong to the object
3552     #  The path of extrusion must be a meshed edge.
3553     #  @param theObject the object which elements should be processed.
3554     #                   It can be a mesh, a sub mesh or a group.
3555     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3556     #  @param PathShape shape(edge) defines the sub-mesh for the path
3557     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3558     #  @param HasAngles allows the shape to be rotated around the path
3559     #                   to get the resulting mesh in a helical fashion
3560     #  @param Angles list of angles
3561     #  @param HasRefPoint allows using the reference point
3562     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3563     #         The User can specify any point as the Reference Point.
3564     #  @param MakeGroups forces the generation of new groups from existing ones
3565     #  @param LinearVariation forces the computation of rotation angles as linear
3566     #                         variation of the given Angles along path steps
3567     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3568     #          only SMESH::Extrusion_Error otherwise
3569     #  @ingroup l2_modif_extrurev
3570     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3571                                    HasAngles, Angles, HasRefPoint, RefPoint,
3572                                    MakeGroups=False, LinearVariation=False):
3573         Angles,AnglesParameters = ParseAngles(Angles)
3574         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3575         if ( isinstance( theObject, Mesh )):
3576             theObject = theObject.GetMesh()
3577         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3578             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3579         if ( isinstance( PathMesh, Mesh )):
3580             PathMesh = PathMesh.GetMesh()
3581         if HasAngles and Angles and LinearVariation:
3582             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3583             pass
3584         Parameters = AnglesParameters + var_separator + RefPointParameters
3585         self.mesh.SetParameters(Parameters)
3586         if MakeGroups:
3587             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3588                                                                     PathShape, NodeStart, HasAngles,
3589                                                                     Angles, HasRefPoint, RefPoint)
3590         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3591                                                       NodeStart, HasAngles, Angles, HasRefPoint,
3592                                                       RefPoint)
3593
3594     ## Creates a symmetrical copy of mesh elements
3595     #  @param IDsOfElements list of elements ids
3596     #  @param Mirror is AxisStruct or geom object(point, line, plane)
3597     #  @param theMirrorType is  POINT, AXIS or PLANE
3598     #  If the Mirror is a geom object this parameter is unnecessary
3599     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3600     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3601     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3602     #  @ingroup l2_modif_trsf
3603     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3604         if IDsOfElements == []:
3605             IDsOfElements = self.GetElementsId()
3606         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3607             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3608         Mirror,Parameters = ParseAxisStruct(Mirror)
3609         self.mesh.SetParameters(Parameters)
3610         if Copy and MakeGroups:
3611             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3612         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3613         return []
3614
3615     ## Creates a new mesh by a symmetrical copy of mesh elements
3616     #  @param IDsOfElements the list of elements ids
3617     #  @param Mirror is AxisStruct or geom object (point, line, plane)
3618     #  @param theMirrorType is  POINT, AXIS or PLANE
3619     #  If the Mirror is a geom object this parameter is unnecessary
3620     #  @param MakeGroups to generate new groups from existing ones
3621     #  @param NewMeshName a name of the new mesh to create
3622     #  @return instance of Mesh class
3623     #  @ingroup l2_modif_trsf
3624     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3625         if IDsOfElements == []:
3626             IDsOfElements = self.GetElementsId()
3627         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3628             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3629         Mirror,Parameters = ParseAxisStruct(Mirror)
3630         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3631                                           MakeGroups, NewMeshName)
3632         mesh.SetParameters(Parameters)
3633         return Mesh(self.smeshpyD,self.geompyD,mesh)
3634
3635     ## Creates a symmetrical copy of the object
3636     #  @param theObject mesh, submesh or group
3637     #  @param Mirror AxisStruct or geom object (point, line, plane)
3638     #  @param theMirrorType is  POINT, AXIS or PLANE
3639     #  If the Mirror is a geom object this parameter is unnecessary
3640     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3641     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3642     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3643     #  @ingroup l2_modif_trsf
3644     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3645         if ( isinstance( theObject, Mesh )):
3646             theObject = theObject.GetMesh()
3647         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3648             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3649         Mirror,Parameters = ParseAxisStruct(Mirror)
3650         self.mesh.SetParameters(Parameters)
3651         if Copy and MakeGroups:
3652             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3653         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3654         return []
3655
3656     ## Creates a new mesh by a symmetrical copy of the object
3657     #  @param theObject mesh, submesh or group
3658     #  @param Mirror AxisStruct or geom object (point, line, plane)
3659     #  @param theMirrorType POINT, AXIS or PLANE
3660     #  If the Mirror is a geom object this parameter is unnecessary
3661     #  @param MakeGroups forces the generation of new groups from existing ones
3662     #  @param NewMeshName the name of the new mesh to create
3663     #  @return instance of Mesh class
3664     #  @ingroup l2_modif_trsf
3665     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3666         if ( isinstance( theObject, Mesh )):
3667             theObject = theObject.GetMesh()
3668         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3669             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3670         Mirror,Parameters = ParseAxisStruct(Mirror)
3671         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3672                                                 MakeGroups, NewMeshName)
3673         mesh.SetParameters(Parameters)
3674         return Mesh( self.smeshpyD,self.geompyD,mesh )
3675
3676     ## Translates the elements
3677     #  @param IDsOfElements list of elements ids
3678     #  @param Vector the direction of translation (DirStruct or vector)
3679     #  @param Copy allows copying the translated elements
3680     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3681     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3682     #  @ingroup l2_modif_trsf
3683     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3684         if IDsOfElements == []:
3685             IDsOfElements = self.GetElementsId()
3686         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3687             Vector = self.smeshpyD.GetDirStruct(Vector)
3688         Vector,Parameters = ParseDirStruct(Vector)
3689         self.mesh.SetParameters(Parameters)
3690         if Copy and MakeGroups:
3691             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3692         self.editor.Translate(IDsOfElements, Vector, Copy)
3693         return []
3694
3695     ## Creates a new mesh of translated elements
3696     #  @param IDsOfElements list of elements ids
3697     #  @param Vector the direction of translation (DirStruct or vector)
3698     #  @param MakeGroups forces the generation of new groups from existing ones
3699     #  @param NewMeshName the name of the newly created mesh
3700     #  @return instance of Mesh class
3701     #  @ingroup l2_modif_trsf
3702     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3703         if IDsOfElements == []:
3704             IDsOfElements = self.GetElementsId()
3705         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3706             Vector = self.smeshpyD.GetDirStruct(Vector)
3707         Vector,Parameters = ParseDirStruct(Vector)
3708         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3709         mesh.SetParameters(Parameters)
3710         return Mesh ( self.smeshpyD, self.geompyD, mesh )
3711
3712     ## Translates the object
3713     #  @param theObject the object to translate (mesh, submesh, or group)
3714     #  @param Vector direction of translation (DirStruct or geom vector)
3715     #  @param Copy allows copying the translated elements
3716     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3717     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3718     #  @ingroup l2_modif_trsf
3719     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3720         if ( isinstance( theObject, Mesh )):
3721             theObject = theObject.GetMesh()
3722         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3723             Vector = self.smeshpyD.GetDirStruct(Vector)
3724         Vector,Parameters = ParseDirStruct(Vector)
3725         self.mesh.SetParameters(Parameters)
3726         if Copy and MakeGroups:
3727             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3728         self.editor.TranslateObject(theObject, Vector, Copy)
3729         return []
3730
3731     ## Creates a new mesh from the translated object
3732     #  @param theObject the object to translate (mesh, submesh, or group)
3733     #  @param Vector the direction of translation (DirStruct or geom vector)
3734     #  @param MakeGroups forces the generation of new groups from existing ones
3735     #  @param NewMeshName the name of the newly created mesh
3736     #  @return instance of Mesh class
3737     #  @ingroup l2_modif_trsf
3738     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3739         if (isinstance(theObject, Mesh)):
3740             theObject = theObject.GetMesh()
3741         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3742             Vector = self.smeshpyD.GetDirStruct(Vector)
3743         Vector,Parameters = ParseDirStruct(Vector)
3744         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3745         mesh.SetParameters(Parameters)
3746         return Mesh( self.smeshpyD, self.geompyD, mesh )
3747
3748
3749
3750     ## Scales the object
3751     #  @param theObject - the object to translate (mesh, submesh, or group)
3752     #  @param thePoint - base point for scale
3753     #  @param theScaleFact - list of 1-3 scale factors for axises
3754     #  @param Copy - allows copying the translated elements
3755     #  @param MakeGroups - forces the generation of new groups from existing
3756     #                      ones (if Copy)
3757     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3758     #          empty list otherwise
3759     def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3760         if ( isinstance( theObject, Mesh )):
3761             theObject = theObject.GetMesh()
3762         if ( isinstance( theObject, list )):
3763             theObject = self.GetIDSource(theObject, SMESH.ALL)
3764
3765         thePoint, Parameters = ParsePointStruct(thePoint)
3766         self.mesh.SetParameters(Parameters)
3767
3768         if Copy and MakeGroups:
3769             return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3770         self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3771         return []
3772
3773     ## Creates a new mesh from the translated object
3774     #  @param theObject - the object to translate (mesh, submesh, or group)
3775     #  @param thePoint - base point for scale
3776     #  @param theScaleFact - list of 1-3 scale factors for axises
3777     #  @param MakeGroups - forces the generation of new groups from existing ones
3778     #  @param NewMeshName - the name of the newly created mesh
3779     #  @return instance of Mesh class
3780     def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3781         if (isinstance(theObject, Mesh)):
3782             theObject = theObject.GetMesh()
3783         if ( isinstance( theObject, list )):
3784             theObject = self.GetIDSource(theObject,SMESH.ALL)
3785
3786         mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3787                                          MakeGroups, NewMeshName)
3788         #mesh.SetParameters(Parameters)
3789         return Mesh( self.smeshpyD, self.geompyD, mesh )
3790
3791
3792
3793     ## Rotates the elements
3794     #  @param IDsOfElements list of elements ids
3795     #  @param Axis the axis of rotation (AxisStruct or geom line)
3796     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3797     #  @param Copy allows copying the rotated elements
3798     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3799     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3800     #  @ingroup l2_modif_trsf
3801     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3802         flag = False
3803         if isinstance(AngleInRadians,str):
3804             flag = True
3805         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3806         if flag:
3807             AngleInRadians = DegreesToRadians(AngleInRadians)
3808         if IDsOfElements == []:
3809             IDsOfElements = self.GetElementsId()
3810         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3811             Axis = self.smeshpyD.GetAxisStruct(Axis)
3812         Axis,AxisParameters = ParseAxisStruct(Axis)
3813         Parameters = AxisParameters + var_separator + Parameters
3814         self.mesh.SetParameters(Parameters)
3815         if Copy and MakeGroups:
3816             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3817         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3818         return []
3819
3820     ## Creates a new mesh of rotated elements
3821     #  @param IDsOfElements list of element ids
3822     #  @param Axis the axis of rotation (AxisStruct or geom line)
3823     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3824     #  @param MakeGroups forces the generation of new groups from existing ones
3825     #  @param NewMeshName the name of the newly created mesh
3826     #  @return instance of Mesh class
3827     #  @ingroup l2_modif_trsf
3828     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3829         flag = False
3830         if isinstance(AngleInRadians,str):
3831             flag = True
3832         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3833         if flag:
3834             AngleInRadians = DegreesToRadians(AngleInRadians)
3835         if IDsOfElements == []:
3836             IDsOfElements = self.GetElementsId()
3837         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3838             Axis = self.smeshpyD.GetAxisStruct(Axis)
3839         Axis,AxisParameters = ParseAxisStruct(Axis)
3840         Parameters = AxisParameters + var_separator + Parameters
3841         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3842                                           MakeGroups, NewMeshName)
3843         mesh.SetParameters(Parameters)
3844         return Mesh( self.smeshpyD, self.geompyD, mesh )
3845
3846     ## Rotates the object
3847     #  @param theObject the object to rotate( mesh, submesh, or group)
3848     #  @param Axis the axis of rotation (AxisStruct or geom line)
3849     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3850     #  @param Copy allows copying the rotated elements
3851     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3852     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3853     #  @ingroup l2_modif_trsf
3854     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3855         flag = False
3856         if isinstance(AngleInRadians,str):
3857             flag = True
3858         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3859         if flag:
3860             AngleInRadians = DegreesToRadians(AngleInRadians)
3861         if (isinstance(theObject, Mesh)):
3862             theObject = theObject.GetMesh()
3863         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3864             Axis = self.smeshpyD.GetAxisStruct(Axis)
3865         Axis,AxisParameters = ParseAxisStruct(Axis)
3866         Parameters = AxisParameters + ":" + Parameters
3867         self.mesh.SetParameters(Parameters)
3868         if Copy and MakeGroups:
3869             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3870         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3871         return []
3872
3873     ## Creates a new mesh from the rotated object
3874     #  @param theObject the object to rotate (mesh, submesh, or group)
3875     #  @param Axis the axis of rotation (AxisStruct or geom line)
3876     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
3877     #  @param MakeGroups forces the generation of new groups from existing ones
3878     #  @param NewMeshName the name of the newly created mesh
3879     #  @return instance of Mesh class
3880     #  @ingroup l2_modif_trsf
3881     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3882         flag = False
3883         if isinstance(AngleInRadians,str):
3884             flag = True
3885         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3886         if flag:
3887             AngleInRadians = DegreesToRadians(AngleInRadians)
3888         if (isinstance( theObject, Mesh )):
3889             theObject = theObject.GetMesh()
3890         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3891             Axis = self.smeshpyD.GetAxisStruct(Axis)
3892         Axis,AxisParameters = ParseAxisStruct(Axis)
3893         Parameters = AxisParameters + ":" + Parameters
3894         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3895                                                        MakeGroups, NewMeshName)
3896         mesh.SetParameters(Parameters)
3897         return Mesh( self.smeshpyD, self.geompyD, mesh )
3898
3899     ## Finds groups of ajacent nodes within Tolerance.
3900     #  @param Tolerance the value of tolerance
3901     #  @return the list of groups of nodes
3902     #  @ingroup l2_modif_trsf
3903     def FindCoincidentNodes (self, Tolerance):
3904         return self.editor.FindCoincidentNodes(Tolerance)
3905
3906     ## Finds groups of ajacent nodes within Tolerance.
3907     #  @param Tolerance the value of tolerance
3908     #  @param SubMeshOrGroup SubMesh or Group
3909     #  @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3910     #  @return the list of groups of nodes
3911     #  @ingroup l2_modif_trsf
3912     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3913         if (isinstance( SubMeshOrGroup, Mesh )):
3914             SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3915         if not isinstance( exceptNodes, list):
3916             exceptNodes = [ exceptNodes ]
3917         if exceptNodes and isinstance( exceptNodes[0], int):
3918             exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3919         return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3920
3921     ## Merges nodes
3922     #  @param GroupsOfNodes the list of groups of nodes
3923     #  @ingroup l2_modif_trsf
3924     def MergeNodes (self, GroupsOfNodes):
3925         self.editor.MergeNodes(GroupsOfNodes)
3926
3927     ## Finds the elements built on the same nodes.
3928     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3929     #  @return a list of groups of equal elements
3930     #  @ingroup l2_modif_trsf
3931     def FindEqualElements (self, MeshOrSubMeshOrGroup):
3932         if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3933             MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3934         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3935
3936     ## Merges elements in each given group.
3937     #  @param GroupsOfElementsID groups of elements for merging
3938     #  @ingroup l2_modif_trsf
3939     def MergeElements(self, GroupsOfElementsID):
3940         self.editor.MergeElements(GroupsOfElementsID)
3941
3942     ## Leaves one element and removes all other elements built on the same nodes.
3943     #  @ingroup l2_modif_trsf
3944     def MergeEqualElements(self):
3945         self.editor.MergeEqualElements()
3946
3947     ## Sews free borders
3948     #  @return SMESH::Sew_Error
3949     #  @ingroup l2_modif_trsf
3950     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3951                         FirstNodeID2, SecondNodeID2, LastNodeID2,
3952                         CreatePolygons, CreatePolyedrs):
3953         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3954                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
3955                                           CreatePolygons, CreatePolyedrs)
3956
3957     ## Sews conform free borders
3958     #  @return SMESH::Sew_Error
3959     #  @ingroup l2_modif_trsf
3960     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3961                                FirstNodeID2, SecondNodeID2):
3962         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3963                                                  FirstNodeID2, SecondNodeID2)
3964
3965     ## Sews border to side
3966     #  @return SMESH::Sew_Error
3967     #  @ingroup l2_modif_trsf
3968     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3969                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3970         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3971                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3972
3973     ## Sews two sides of a mesh. The nodes belonging to Side1 are
3974     #  merged with the nodes of elements of Side2.
3975     #  The number of elements in theSide1 and in theSide2 must be
3976     #  equal and they should have similar nodal connectivity.
3977     #  The nodes to merge should belong to side borders and
3978     #  the first node should be linked to the second.
3979     #  @return SMESH::Sew_Error
3980     #  @ingroup l2_modif_trsf
3981     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3982                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3983                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3984         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3985                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3986                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3987
3988     ## Sets new nodes for the given element.
3989     #  @param ide the element id
3990     #  @param newIDs nodes ids
3991     #  @return If the number of nodes does not correspond to the type of element - returns false
3992     #  @ingroup l2_modif_edit
3993     def ChangeElemNodes(self, ide, newIDs):
3994         return self.editor.ChangeElemNodes(ide, newIDs)
3995
3996     ## If during the last operation of MeshEditor some nodes were
3997     #  created, this method returns the list of their IDs, \n
3998     #  if new nodes were not created - returns empty list
3999     #  @return the list of integer values (can be empty)
4000     #  @ingroup l1_auxiliary
4001     def GetLastCreatedNodes(self):
4002         return self.editor.GetLastCreatedNodes()
4003
4004     ## If during the last operation of MeshEditor some elements were
4005     #  created this method returns the list of their IDs, \n
4006     #  if new elements were not created - returns empty list
4007     #  @return the list of integer values (can be empty)
4008     #  @ingroup l1_auxiliary
4009     def GetLastCreatedElems(self):
4010         return self.editor.GetLastCreatedElems()
4011
4012      ## Creates a hole in a mesh by doubling the nodes of some particular elements
4013     #  @param theNodes identifiers of nodes to be doubled
4014     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4015     #         nodes. If list of element identifiers is empty then nodes are doubled but
4016     #         they not assigned to elements
4017     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4018     #  @ingroup l2_modif_edit
4019     def DoubleNodes(self, theNodes, theModifiedElems):
4020         return self.editor.DoubleNodes(theNodes, theModifiedElems)
4021
4022     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4023     #  This method provided for convenience works as DoubleNodes() described above.
4024     #  @param theNodeId identifiers of node to be doubled
4025     #  @param theModifiedElems identifiers of elements to be updated
4026     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4027     #  @ingroup l2_modif_edit
4028     def DoubleNode(self, theNodeId, theModifiedElems):
4029         return self.editor.DoubleNode(theNodeId, theModifiedElems)
4030
4031     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4032     #  This method provided for convenience works as DoubleNodes() described above.
4033     #  @param theNodes group of nodes to be doubled
4034     #  @param theModifiedElems group of elements to be updated.
4035     #  @param theMakeGroup forces the generation of a group containing new nodes.
4036     #  @return TRUE or a created group if operation has been completed successfully,
4037     #          FALSE or None otherwise
4038     #  @ingroup l2_modif_edit
4039     def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4040         if theMakeGroup:
4041             return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4042         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4043
4044     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4045     #  This method provided for convenience works as DoubleNodes() described above.
4046     #  @param theNodes list of groups of nodes to be doubled
4047     #  @param theModifiedElems list of groups of elements to be updated.
4048     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4049     #  @ingroup l2_modif_edit
4050     def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4051         if theMakeGroup:
4052             return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4053         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4054
4055     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4056     #  @param theElems - the list of elements (edges or faces) to be replicated
4057     #         The nodes for duplication could be found from these elements
4058     #  @param theNodesNot - list of nodes to NOT replicate
4059     #  @param theAffectedElems - the list of elements (cells and edges) to which the
4060     #         replicated nodes should be associated to.
4061     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4062     #  @ingroup l2_modif_edit
4063     def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4064         return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4065
4066     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4067     #  @param theElems - the list of elements (edges or faces) to be replicated
4068     #         The nodes for duplication could be found from these elements
4069     #  @param theNodesNot - list of nodes to NOT replicate
4070     #  @param theShape - shape to detect affected elements (element which geometric center
4071     #         located on or inside shape).
4072     #         The replicated nodes should be associated to affected elements.
4073     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4074     #  @ingroup l2_modif_edit
4075     def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4076         return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4077
4078     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4079     #  This method provided for convenience works as DoubleNodes() described above.
4080     #  @param theElems - group of of elements (edges or faces) to be replicated
4081     #  @param theNodesNot - group of nodes not to replicated
4082     #  @param theAffectedElems - group of elements to which the replicated nodes
4083     #         should be associated to.
4084     #  @param theMakeGroup forces the generation of a group containing new elements.
4085     #  @return TRUE or a created group if operation has been completed successfully,
4086     #          FALSE or None otherwise
4087     #  @ingroup l2_modif_edit
4088     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4089         if theMakeGroup:
4090             return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4091         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4092
4093     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4094     #  This method provided for convenience works as DoubleNodes() described above.
4095     #  @param theElems - group of of elements (edges or faces) to be replicated
4096     #  @param theNodesNot - group of nodes not to replicated
4097     #  @param theShape - shape to detect affected elements (element which geometric center
4098     #         located on or inside shape).
4099     #         The replicated nodes should be associated to affected elements.
4100     #  @ingroup l2_modif_edit
4101     def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4102         return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4103
4104     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4105     #  This method provided for convenience works as DoubleNodes() described above.
4106     #  @param theElems - list of groups of elements (edges or faces) to be replicated
4107     #  @param theNodesNot - list of groups of nodes not to replicated
4108     #  @param theAffectedElems - group of elements to which the replicated nodes
4109     #         should be associated to.
4110     #  @param theMakeGroup forces the generation of a group containing new elements.
4111     #  @return TRUE or a created group if operation has been completed successfully,
4112     #          FALSE or None otherwise
4113     #  @ingroup l2_modif_edit
4114     def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4115         if theMakeGroup:
4116             return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4117         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4118
4119     ## Creates a hole in a mesh by doubling the nodes of some particular elements
4120     #  This method provided for convenience works as DoubleNodes() described above.
4121     #  @param theElems - list of groups of elements (edges or faces) to be replicated
4122     #  @param theNodesNot - list of groups of nodes not to replicated
4123     #  @param theShape - shape to detect affected elements (element which geometric center
4124     #         located on or inside shape).
4125     #         The replicated nodes should be associated to affected elements.
4126     #  @return TRUE if operation has been completed successfully, FALSE otherwise
4127     #  @ingroup l2_modif_edit
4128     def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4129         return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4130
4131     ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4132     # The list of groups must describe a partition of the mesh volumes.
4133     # The nodes of the internal faces at the boundaries of the groups are doubled.
4134     # In option, the internal faces are replaced by flat elements.
4135     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4136     # @param theDomains - list of groups of volumes
4137     # @param createJointElems - if TRUE, create the elements
4138     # @return TRUE if operation has been completed successfully, FALSE otherwise
4139     def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4140        return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4141
4142     def _valueFromFunctor(self, funcType, elemId):
4143         fn = self.smeshpyD.GetFunctor(funcType)
4144         fn.SetMesh(self.mesh)
4145         if fn.GetElementType() == self.GetElementType(elemId, True):
4146             val = fn.GetValue(elemId)
4147         else:
4148             val = 0
4149         return val
4150
4151     ## Get length of 1D element.
4152     #  @param elemId mesh element ID
4153     #  @return element's length value
4154     #  @ingroup l1_measurements
4155     def GetLength(self, elemId):
4156         return self._valueFromFunctor(SMESH.FT_Length, elemId)
4157
4158     ## Get area of 2D element.
4159     #  @param elemId mesh element ID
4160     #  @return element's area value
4161     #  @ingroup l1_measurements
4162     def GetArea(self, elemId):
4163         return self._valueFromFunctor(SMESH.FT_Area, elemId)
4164
4165     ## Get volume of 3D element.
4166     #  @param elemId mesh element ID
4167     #  @return element's volume value
4168     #  @ingroup l1_measurements
4169     def GetVolume(self, elemId):
4170         return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4171
4172     ## Get maximum element length.
4173     #  @param elemId mesh element ID
4174     #  @return element's maximum length value
4175     #  @ingroup l1_measurements
4176     def GetMaxElementLength(self, elemId):
4177         if self.GetElementType(elemId, True) == SMESH.VOLUME:
4178             ftype = SMESH.FT_MaxElementLength3D
4179         else:
4180             ftype = SMESH.FT_MaxElementLength2D
4181         return self._valueFromFunctor(ftype, elemId)
4182
4183     ## Get aspect ratio of 2D or 3D element.
4184     #  @param elemId mesh element ID
4185     #  @return element's aspect ratio value
4186     #  @ingroup l1_measurements
4187     def GetAspectRatio(self, elemId):
4188         if self.GetElementType(elemId, True) == SMESH.VOLUME:
4189             ftype = SMESH.FT_AspectRatio3D
4190         else:
4191             ftype = SMESH.FT_AspectRatio
4192         return self._valueFromFunctor(ftype, elemId)
4193
4194     ## Get warping angle of 2D element.
4195     #  @param elemId mesh element ID
4196     #  @return element's warping angle value
4197     #  @ingroup l1_measurements
4198     def GetWarping(self, elemId):
4199         return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4200
4201     ## Get minimum angle of 2D element.
4202     #  @param elemId mesh element ID
4203     #  @return element's minimum angle value
4204     #  @ingroup l1_measurements
4205     def GetMinimumAngle(self, elemId):
4206         return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4207
4208     ## Get taper of 2D element.
4209     #  @param elemId mesh element ID
4210     #  @return element's taper value
4211     #  @ingroup l1_measurements
4212     def GetTaper(self, elemId):
4213         return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4214
4215     ## Get skew of 2D element.
4216     #  @param elemId mesh element ID
4217     #  @return element's skew value
4218     #  @ingroup l1_measurements
4219     def GetSkew(self, elemId):
4220         return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4221
4222 ## The mother class to define algorithm, it is not recommended to use it directly.
4223 #
4224 #  More details.
4225 #  @ingroup l2_algorithms
4226 class Mesh_Algorithm:
4227     #  @class Mesh_Algorithm
4228     #  @brief Class Mesh_Algorithm
4229
4230     #def __init__(self,smesh):
4231     #    self.smesh=smesh
4232     def __init__(self):
4233         self.mesh = None
4234         self.geom = None
4235         self.subm = None
4236         self.algo = None
4237
4238     ## Finds a hypothesis in the study by its type name and parameters.
4239     #  Finds only the hypotheses created in smeshpyD engine.
4240     #  @return SMESH.SMESH_Hypothesis
4241     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4242         study = smeshpyD.GetCurrentStudy()
4243         #to do: find component by smeshpyD object, not by its data type
4244         scomp = study.FindComponent(smeshpyD.ComponentDataType())
4245         if scomp is not None:
4246             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4247             # Check if the root label of the hypotheses exists
4248             if res and hypRoot is not None:
4249                 iter = study.NewChildIterator(hypRoot)
4250                 # Check all published hypotheses
4251                 while iter.More():
4252                     hypo_so_i = iter.Value()
4253                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4254                     if attr is not None:
4255                         anIOR = attr.Value()
4256                         hypo_o_i = salome.orb.string_to_object(anIOR)
4257                         if hypo_o_i is not None:
4258                             # Check if this is a hypothesis
4259                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4260                             if hypo_i is not None:
4261                                 # Check if the hypothesis belongs to current engine
4262                                 if smeshpyD.GetObjectId(hypo_i) > 0:
4263                                     # Check if this is the required hypothesis
4264                                     if hypo_i.GetName() == hypname:
4265                                         # Check arguments
4266                                         if CompareMethod(hypo_i, args):
4267                                             # found!!!
4268                                             return hypo_i
4269                                         pass
4270                                     pass
4271                                 pass
4272                             pass
4273                         pass
4274                     iter.Next()
4275                     pass
4276                 pass
4277             pass
4278         return None
4279
4280     ## Finds the algorithm in the study by its type name.
4281     #  Finds only the algorithms, which have been created in smeshpyD engine.
4282     #  @return SMESH.SMESH_Algo
4283     def FindAlgorithm (self, algoname, smeshpyD):
4284         study = smeshpyD.GetCurrentStudy()
4285         #to do: find component by smeshpyD object, not by its data type
4286         scomp = study.FindComponent(smeshpyD.ComponentDataType())
4287         if scomp is not None:
4288             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4289             # Check if the root label of the algorithms exists
4290             if res and hypRoot is not None:
4291                 iter = study.NewChildIterator(hypRoot)
4292                 # Check all published algorithms
4293                 while iter.More():
4294                     algo_so_i = iter.Value()
4295                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4296                     if attr is not None:
4297                         anIOR = attr.Value()
4298                         algo_o_i = salome.orb.string_to_object(anIOR)
4299                         if algo_o_i is not None:
4300                             # Check if this is an algorithm
4301                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4302                             if algo_i is not None:
4303                                 # Checks if the algorithm belongs to the current engine
4304                                 if smeshpyD.GetObjectId(algo_i) > 0:
4305                                     # Check if this is the required algorithm
4306                                     if algo_i.GetName() == algoname:
4307                                         # found!!!
4308                                         return algo_i
4309                                     pass
4310                                 pass
4311                             pass
4312                         pass
4313                     iter.Next()
4314                     pass
4315                 pass
4316             pass
4317         return None
4318
4319     ## If the algorithm is global, returns 0; \n
4320     #  else returns the submesh associated to this algorithm.
4321     def GetSubMesh(self):
4322         return self.subm
4323
4324     ## Returns the wrapped mesher.
4325     def GetAlgorithm(self):
4326         return self.algo
4327
4328     ## Gets the list of hypothesis that can be used with this algorithm
4329     def GetCompatibleHypothesis(self):
4330         mylist = []
4331         if self.algo:
4332             mylist = self.algo.GetCompatibleHypothesis()
4333         return mylist
4334
4335     ## Gets the name of the algorithm
4336     def GetName(self):
4337         GetName(self.algo)
4338
4339     ## Sets the name to the algorithm
4340     def SetName(self, name):
4341         self.mesh.smeshpyD.SetName(self.algo, name)
4342
4343     ## Gets the id of the algorithm
4344     def GetId(self):
4345         return self.algo.GetId()
4346
4347     ## Private method.
4348     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4349         if geom is None:
4350             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4351         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4352         if algo is None:
4353             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4354             pass
4355         self.Assign(algo, mesh, geom)
4356         return self.algo
4357
4358     ## Private method
4359     def Assign(self, algo, mesh, geom):
4360         if geom is None:
4361             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4362         self.mesh = mesh
4363         piece = mesh.geom
4364         name = ""
4365         if not geom:
4366             self.geom = piece
4367         else:
4368             self.geom = geom
4369             try:
4370                 name = GetName(geom)
4371                 pass
4372             except:
4373                 pass
4374             if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4375                 # for all groups SubShapeName() returns "Compound_-1"
4376                 name = mesh.geompyD.SubShapeName(geom, piece)
4377             if not name:
4378                 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4379             # publish geom of sub-mesh (issue 0021122)
4380             if not self.geom.IsSame( self.mesh.geom ) and not self.geom.GetStudyEntry():
4381                 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4382                 if studyID != self.mesh.geompyD.myStudyId:
4383                     self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4384                 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, self.geom, name )
4385                 pass
4386             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4387         self.algo = algo
4388         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4389         TreatHypoStatus( status, algo.GetName(), name, True )
4390
4391     def CompareHyp (self, hyp, args):
4392         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4393         return False
4394
4395     def CompareEqualHyp (self, hyp, args):
4396         return True
4397
4398     ## Private method
4399     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4400                     UseExisting=0, CompareMethod=""):
4401         hypo = None
4402         if UseExisting:
4403             if CompareMethod == "": CompareMethod = self.CompareHyp
4404             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4405             pass
4406         if hypo is None:
4407             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4408             a = ""
4409             s = "="
4410             i = 0
4411             n = len(args)
4412             while i<n:
4413                 a = a + s + str(args[i])
4414                 s = ","
4415                 i = i + 1
4416                 pass
4417             self.mesh.smeshpyD.SetName(hypo, hyp + a)
4418             pass
4419         geomName=""
4420         if self.geom:
4421             geomName = GetName(self.geom)
4422         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4423         TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4424         return hypo
4425
4426     ## Returns entry of the shape to mesh in the study
4427     def MainShapeEntry(self):
4428         entry = ""
4429         if not self.mesh or not self.mesh.GetMesh(): return entry
4430         if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4431         study = self.mesh.smeshpyD.GetCurrentStudy()
4432         ior  = salome.orb.object_to_string( self.mesh.GetShape() )
4433         sobj = study.FindObjectIOR(ior)
4434         if sobj: entry = sobj.GetID()
4435         if not entry: return ""
4436         return entry
4437
4438     ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4439     #  near mesh boundary. This hypothesis can be used by several 3D algorithms:
4440     #  NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4441     #  @param thickness total thickness of layers of prisms
4442     #  @param numberOfLayers number of layers of prisms
4443     #  @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4444     #  @param ignoreFaces geometrical face (or their ids) not to generate layers on
4445     #  @ingroup l3_hypos_additi
4446     def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4447         if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4448             raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4449         if not "ViscousLayers" in self.GetCompatibleHypothesis():
4450             raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4451         if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4452             ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4453         hyp = self.Hypothesis("ViscousLayers",
4454                               [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4455         hyp.SetTotalThickness(thickness)
4456         hyp.SetNumberLayers(numberOfLayers)
4457         hyp.SetStretchFactor(stretchFactor)
4458         hyp.SetIgnoreFaces(ignoreFaces)
4459         return hyp
4460
4461 # Public class: Mesh_Segment
4462 # --------------------------
4463
4464 ## Class to define a segment 1D algorithm for discretization
4465 #
4466 #  More details.
4467 #  @ingroup l3_algos_basic
4468 class Mesh_Segment(Mesh_Algorithm):
4469
4470     ## Private constructor.
4471     def __init__(self, mesh, geom=0):
4472         Mesh_Algorithm.__init__(self)
4473         self.Create(mesh, geom, "Regular_1D")
4474
4475     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4476     #  @param l for the length of segments that cut an edge
4477     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
4478     #                    the same parameters, else (default) - creates a new one
4479     #  @param p precision, used for calculation of the number of segments.
4480     #           The precision should be a positive, meaningful value within the range [0,1].
4481     #           In general, the number of segments is calculated with the formula:
4482     #           nb = ceil((edge_length / l) - p)
4483     #           Function ceil rounds its argument to the higher integer.
4484     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
4485     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
4486     #               p=1 means rounding of (edge_length / l) to the lower integer.
4487     #           Default value is 1e-07.
4488     #  @return an instance of StdMeshers_LocalLength hypothesis
4489     #  @ingroup l3_hypos_1dhyps
4490     def LocalLength(self, l, UseExisting=0, p=1e-07):
4491         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4492                               CompareMethod=self.CompareLocalLength)
4493         hyp.SetLength(l)
4494         hyp.SetPrecision(p)
4495         return hyp
4496
4497     ## Private method
4498     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4499     def CompareLocalLength(self, hyp, args):
4500         if IsEqual(hyp.GetLength(), args[0]):
4501             return IsEqual(hyp.GetPrecision(), args[1])
4502         return False
4503
4504     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4505     #  @param length is optional maximal allowed length of segment, if it is omitted
4506     #                the preestimated length is used that depends on geometry size
4507     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4508     #                     the same parameters, else (default) - create a new one
4509     #  @return an instance of StdMeshers_MaxLength hypothesis
4510     #  @ingroup l3_hypos_1dhyps
4511     def MaxSize(self, length=0.0, UseExisting=0):
4512         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4513         if length > 0.0:
4514             # set given length
4515             hyp.SetLength(length)
4516         if not UseExisting:
4517             # set preestimated length
4518             gen = self.mesh.smeshpyD
4519             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4520                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
4521                                                        False) # <- byMesh
4522             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4523             if preHyp:
4524                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4525                 pass
4526             pass
4527         hyp.SetUsePreestimatedLength( length == 0.0 )
4528         return hyp
4529
4530     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4531     #  @param n for the number of segments that cut an edge
4532     #  @param s for the scale factor (optional)
4533     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4534     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4535     #                     the same parameters, else (default) - create a new one
4536     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
4537     #  @ingroup l3_hypos_1dhyps
4538     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4539         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4540             reversedEdges, UseExisting = [], reversedEdges
4541         entry = self.MainShapeEntry()
4542         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4543             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4544         if s == []:
4545             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4546                                   UseExisting=UseExisting,
4547                                   CompareMethod=self.CompareNumberOfSegments)
4548         else:
4549             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4550                                   UseExisting=UseExisting,
4551                                   CompareMethod=self.CompareNumberOfSegments)
4552             hyp.SetDistrType( 1 )
4553             hyp.SetScaleFactor(s)
4554         hyp.SetNumberOfSegments(n)
4555         hyp.SetReversedEdges( reversedEdges )
4556         hyp.SetObjectEntry( entry )
4557         return hyp
4558
4559     ## Private method
4560     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4561     def CompareNumberOfSegments(self, hyp, args):
4562         if hyp.GetNumberOfSegments() == args[0]:
4563             if len(args) == 3:
4564                 if hyp.GetReversedEdges() == args[1]:
4565                     if not args[1] or hyp.GetObjectEntry() == args[2]:
4566                         return True
4567             else:
4568                 if hyp.GetReversedEdges() == args[2]:
4569                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4570                         if hyp.GetDistrType() == 1:
4571                             if IsEqual(hyp.GetScaleFactor(), args[1]):
4572                                 return True
4573         return False
4574
4575     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4576     #  @param start defines the length of the first segment
4577     #  @param end   defines the length of the last  segment
4578     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4579     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4580     #                     the same parameters, else (default) - creates a new one
4581     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4582     #  @ingroup l3_hypos_1dhyps
4583     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4584         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4585             reversedEdges, UseExisting = [], reversedEdges
4586         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4587             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4588         entry = self.MainShapeEntry()
4589         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4590                               UseExisting=UseExisting,
4591                               CompareMethod=self.CompareArithmetic1D)
4592         hyp.SetStartLength(start)
4593         hyp.SetEndLength(end)
4594         hyp.SetReversedEdges( reversedEdges )
4595         hyp.SetObjectEntry( entry )
4596         return hyp
4597
4598     ## Private method
4599     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4600     def CompareArithmetic1D(self, hyp, args):
4601         if IsEqual(hyp.GetLength(1), args[0]):
4602             if IsEqual(hyp.GetLength(0), args[1]):
4603                 if hyp.GetReversedEdges() == args[2]:
4604                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4605                         return True
4606         return False
4607
4608
4609     ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4610     # on curve from 0 to 1 (additionally it is neecessary to check
4611     # orientation of edges and create list of reversed edges if it is
4612     # needed) and sets numbers of segments between given points (default
4613     # values are equals 1
4614     #  @param points defines the list of parameters on curve
4615     #  @param nbSegs defines the list of numbers of segments
4616     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4617     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4618     #                     the same parameters, else (default) - creates a new one
4619     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
4620     #  @ingroup l3_hypos_1dhyps
4621     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4622         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4623             reversedEdges, UseExisting = [], reversedEdges
4624         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4625             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4626         entry = self.MainShapeEntry()
4627         hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4628                               UseExisting=UseExisting,
4629                               CompareMethod=self.CompareFixedPoints1D)
4630         hyp.SetPoints(points)
4631         hyp.SetNbSegments(nbSegs)
4632         hyp.SetReversedEdges(reversedEdges)
4633         hyp.SetObjectEntry(entry)
4634         return hyp
4635
4636     ## Private method
4637     ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4638     ## as the given arguments
4639     def CompareFixedPoints1D(self, hyp, args):
4640         if hyp.GetPoints() == args[0]:
4641             if hyp.GetNbSegments() == args[1]:
4642                 if hyp.GetReversedEdges() == args[2]:
4643                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4644                         return True
4645         return False
4646
4647
4648
4649     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4650     #  @param start defines the length of the first segment
4651     #  @param end   defines the length of the last  segment
4652     #  @param reversedEdges is a list of edges to mesh using reversed orientation
4653     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4654     #                     the same parameters, else (default) - creates a new one
4655     #  @return an instance of StdMeshers_StartEndLength hypothesis
4656     #  @ingroup l3_hypos_1dhyps
4657     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4658         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4659             reversedEdges, UseExisting = [], reversedEdges
4660         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4661             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4662         entry = self.MainShapeEntry()
4663         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4664                               UseExisting=UseExisting,
4665                               CompareMethod=self.CompareStartEndLength)
4666         hyp.SetStartLength(start)
4667         hyp.SetEndLength(end)
4668         hyp.SetReversedEdges( reversedEdges )
4669         hyp.SetObjectEntry( entry )
4670         return hyp
4671
4672     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4673     def CompareStartEndLength(self, hyp, args):
4674         if IsEqual(hyp.GetLength(1), args[0]):
4675             if IsEqual(hyp.GetLength(0), args[1]):
4676                 if hyp.GetReversedEdges() == args[2]:
4677                     if not args[2] or hyp.GetObjectEntry() == args[3]:
4678                         return True
4679         return False
4680
4681     ## Defines "Deflection1D" hypothesis
4682     #  @param d for the deflection
4683     #  @param UseExisting if ==true - searches for an existing hypothesis created with
4684     #                     the same parameters, else (default) - create a new one
4685     #  @ingroup l3_hypos_1dhyps
4686     def Deflection1D(self, d, UseExisting=0):
4687         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4688                               CompareMethod=self.CompareDeflection1D)
4689         hyp.SetDeflection(d)
4690         return hyp
4691
4692     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4693     def CompareDeflection1D(self, hyp, args):
4694         return IsEqual(hyp.GetDeflection(), args[0])
4695
4696     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4697     #  the opposite side in case of quadrangular faces
4698     #  @ingroup l3_hypos_additi
4699     def Propagation(self):
4700         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4701
4702     ## Defines "AutomaticLength" hypothesis
4703     #  @param fineness for the fineness [0-1]
4704     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
4705     #                     same parameters, else (default) - create a new one
4706     #  @ingroup l3_hypos_1dhyps
4707     def AutomaticLength(self, fineness=0, UseExisting=0):
4708         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4709                               CompareMethod=self.CompareAutomaticLength)
4710         hyp.SetFineness( fineness )
4711         return hyp
4712
4713     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4714     def CompareAutomaticLength(self, hyp, args):
4715         return IsEqual(hyp.GetFineness(), args[0])
4716
4717     ## Defines "SegmentLengthAroundVertex" hypothesis
4718     #  @param length for the segment length
4719     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
4720     #         Any other integer value means that the hypothesis will be set on the
4721     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
4722     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
4723     #                   the same parameters, else (default) - creates a new one
4724     #  @ingroup l3_algos_segmarv
4725     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4726         import types
4727         store_geom = self.geom
4728         if type(vertex) is types.IntType:
4729             if vertex == 0 or vertex == 1:
4730                 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4731                 self.geom = vertex
4732                 pass
4733             pass
4734         else:
4735             self.geom = vertex
4736             pass
4737         ### 0D algorithm
4738         if self.geom is None:
4739             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4740         try:
4741             name = GetName(self.geom)
4742             pass
4743         except:
4744             piece = self.mesh.geom
4745             name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4746             self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4747             pass
4748         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4749         if algo is None:
4750             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4751             pass
4752         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4753         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4754         ###
4755         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4756                               CompareMethod=self.CompareLengthNearVertex)
4757         self.geom = store_geom
4758         hyp.SetLength( length )
4759         return hyp
4760
4761     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4762     #  @ingroup l3_algos_segmarv
4763     def CompareLengthNearVertex(self, hyp, args):
4764         return IsEqual(hyp.GetLength(), args[0])
4765
4766     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4767     #  If the 2D mesher sees that all boundary edges are quadratic,
4768     #  it generates quadratic faces, else it generates linear faces using
4769     #  medium nodes as if they are vertices.
4770     #  The 3D mesher generates quadratic volumes only if all boundary faces
4771     #  are quadratic, else it fails.
4772     #
4773     #  @ingroup l3_hypos_additi
4774     def QuadraticMesh(self):
4775         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4776         return hyp
4777
4778 # Public class: Mesh_CompositeSegment
4779 # --------------------------
4780
4781 ## Defines a segment 1D algorithm for discretization
4782 #
4783 #  @ingroup l3_algos_basic
4784 class Mesh_CompositeSegment(Mesh_Segment):
4785
4786     ## Private constructor.
4787     def __init__(self, mesh, geom=0):
4788         self.Create(mesh, geom, "CompositeSegment_1D")
4789
4790
4791 # Public class: Mesh_Segment_Python
4792 # ---------------------------------
4793
4794 ## Defines a segment 1D algorithm for discretization with python function
4795 #
4796 #  @ingroup l3_algos_basic
4797 class Mesh_Segment_Python(Mesh_Segment):
4798
4799     ## Private constructor.
4800     def __init__(self, mesh, geom=0):
4801         import Python1dPlugin
4802         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4803
4804     ## Defines "PythonSplit1D" hypothesis
4805     #  @param n for the number of segments that cut an edge
4806     #  @param func for the python function that calculates the length of all segments
4807     #  @param UseExisting if ==true - searches for the existing hypothesis created with
4808     #                     the same parameters, else (default) - creates a new one
4809     #  @ingroup l3_hypos_1dhyps
4810     def PythonSplit1D(self, n, func, UseExisting=0):
4811         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4812                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4813         hyp.SetNumberOfSegments(n)
4814         hyp.SetPythonLog10RatioFunction(func)
4815         return hyp
4816
4817     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4818     def ComparePythonSplit1D(self, hyp, args):
4819         #if hyp.GetNumberOfSegments() == args[0]:
4820         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
4821         #        return True
4822         return False
4823
4824 # Public class: Mesh_Triangle
4825 # ---------------------------
4826
4827 ## Defines a triangle 2D algorithm
4828 #
4829 #  @ingroup l3_algos_basic
4830 class Mesh_Triangle(Mesh_Algorithm):
4831
4832     # default values
4833     algoType = 0
4834     params = 0
4835
4836     _angleMeshS = 8
4837     _gradation  = 1.1
4838
4839     ## Private constructor.
4840     def __init__(self, mesh, algoType, geom=0):
4841         Mesh_Algorithm.__init__(self)
4842
4843         self.algoType = algoType
4844         if algoType == MEFISTO:
4845             self.Create(mesh, geom, "MEFISTO_2D")
4846             pass
4847         elif algoType == BLSURF:
4848             CheckPlugin(BLSURF)
4849             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4850             #self.SetPhysicalMesh() - PAL19680
4851         elif algoType == NETGEN:
4852             CheckPlugin(NETGEN)
4853             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4854             pass
4855         elif algoType == NETGEN_2D:
4856             CheckPlugin(NETGEN)
4857             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4858             pass
4859
4860     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4861     #  @param area for the maximum area of each triangle
4862     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
4863     #                     same parameters, else (default) - creates a new one
4864     #
4865     #  Only for algoType == MEFISTO || NETGEN_2D
4866     #  @ingroup l3_hypos_2dhyps
4867     def MaxElementArea(self, area, UseExisting=0):
4868         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4869             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4870                                   CompareMethod=self.CompareMaxElementArea)
4871         elif self.algoType == NETGEN:
4872             hyp = self.Parameters(SIMPLE)
4873         hyp.SetMaxElementArea(area)
4874         return hyp
4875
4876     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4877     def CompareMaxElementArea(self, hyp, args):
4878         return IsEqual(hyp.GetMaxElementArea(), args[0])
4879
4880     ## Defines "LengthFromEdges" hypothesis to build triangles
4881     #  based on the length of the edges taken from the wire
4882     #
4883     #  Only for algoType == MEFISTO || NETGEN_2D
4884     #  @ingroup l3_hypos_2dhyps
4885     def LengthFromEdges(self):
4886         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4887             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4888             return hyp
4889         elif self.algoType == NETGEN:
4890             hyp = self.Parameters(SIMPLE)
4891             hyp.LengthFromEdges()
4892             return hyp
4893
4894     ## Sets a way to define size of mesh elements to generate.
4895     #  @param thePhysicalMesh is: DefaultSize or Custom.
4896     #  @ingroup l3_hypos_blsurf
4897     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4898         # Parameter of BLSURF algo
4899         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4900
4901     ## Sets size of mesh elements to generate.
4902     #  @ingroup l3_hypos_blsurf
4903     def SetPhySize(self, theVal):
4904         # Parameter of BLSURF algo
4905         self.SetPhysicalMesh(1) #Custom - else why to set the size?
4906         self.Parameters().SetPhySize(theVal)
4907
4908     ## Sets lower boundary of mesh element size (PhySize).
4909     #  @ingroup l3_hypos_blsurf
4910     def SetPhyMin(self, theVal=-1):
4911         #  Parameter of BLSURF algo
4912         self.Parameters().SetPhyMin(theVal)
4913
4914     ## Sets upper boundary of mesh element size (PhySize).
4915     #  @ingroup l3_hypos_blsurf
4916     def SetPhyMax(self, theVal=-1):
4917         #  Parameter of BLSURF algo
4918         self.Parameters().SetPhyMax(theVal)
4919
4920     ## Sets a way to define maximum angular deflection of mesh from CAD model.
4921     #  @param theGeometricMesh is: 0 (None) or 1 (Custom)
4922     #  @ingroup l3_hypos_blsurf
4923     def SetGeometricMesh(self, theGeometricMesh=0):
4924         #  Parameter of BLSURF algo
4925         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4926         self.params.SetGeometricMesh(theGeometricMesh)
4927
4928     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4929     #  @ingroup l3_hypos_blsurf
4930     def SetAngleMeshS(self, theVal=_angleMeshS):
4931         #  Parameter of BLSURF algo
4932         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4933         self.params.SetAngleMeshS(theVal)
4934
4935     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4936     #  @ingroup l3_hypos_blsurf
4937     def SetAngleMeshC(self, theVal=_angleMeshS):
4938         #  Parameter of BLSURF algo
4939         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4940         self.params.SetAngleMeshC(theVal)
4941
4942     ## Sets lower boundary of mesh element size computed to respect angular deflection.
4943     #  @ingroup l3_hypos_blsurf
4944     def SetGeoMin(self, theVal=-1):
4945         #  Parameter of BLSURF algo
4946         self.Parameters().SetGeoMin(theVal)
4947
4948     ## Sets upper boundary of mesh element size computed to respect angular deflection.
4949     #  @ingroup l3_hypos_blsurf
4950     def SetGeoMax(self, theVal=-1):
4951         #  Parameter of BLSURF algo
4952         self.Parameters().SetGeoMax(theVal)
4953
4954     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4955     #  @ingroup l3_hypos_blsurf
4956     def SetGradation(self, theVal=_gradation):
4957         #  Parameter of BLSURF algo
4958         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4959         self.params.SetGradation(theVal)
4960
4961     ## Sets topology usage way.
4962     # @param way defines how mesh conformity is assured <ul>
4963     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4964     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4965     #  @ingroup l3_hypos_blsurf
4966     def SetTopology(self, way):
4967         #  Parameter of BLSURF algo
4968         self.Parameters().SetTopology(way)
4969
4970     ## To respect geometrical edges or not.
4971     #  @ingroup l3_hypos_blsurf
4972     def SetDecimesh(self, toIgnoreEdges=False):
4973         #  Parameter of BLSURF algo
4974         self.Parameters().SetDecimesh(toIgnoreEdges)
4975
4976     ## Sets verbosity level in the range 0 to 100.
4977     #  @ingroup l3_hypos_blsurf
4978     def SetVerbosity(self, level):
4979         #  Parameter of BLSURF algo
4980         self.Parameters().SetVerbosity(level)
4981
4982     ## Sets advanced option value.
4983     #  @ingroup l3_hypos_blsurf
4984     def SetOptionValue(self, optionName, level):
4985         #  Parameter of BLSURF algo
4986         self.Parameters().SetOptionValue(optionName,level)
4987
4988     ## Sets QuadAllowed flag.
4989     #  Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
4990     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
4991     def SetQuadAllowed(self, toAllow=True):
4992         if self.algoType == NETGEN_2D:
4993             if not self.params:
4994                 # use simple hyps
4995                 hasSimpleHyps = False
4996                 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
4997                 for hyp in self.mesh.GetHypothesisList( self.geom ):
4998                     if hyp.GetName() in simpleHyps:
4999                         hasSimpleHyps = True
5000                         if hyp.GetName() == "QuadranglePreference":
5001                             if not toAllow: # remove QuadranglePreference
5002                                 self.mesh.RemoveHypothesis( self.geom, hyp )
5003                                 pass
5004                             return
5005                         pass
5006                     pass
5007                 if hasSimpleHyps:
5008                     if toAllow: # add QuadranglePreference
5009                         self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5010                         pass
5011                     return
5012                 pass
5013             pass
5014         if self.Parameters():
5015             self.params.SetQuadAllowed(toAllow)
5016             return
5017
5018     ## Defines hypothesis having several parameters
5019     #
5020     #  @ingroup l3_hypos_netgen
5021     def Parameters(self, which=SOLE):
5022         if not self.params:
5023             if self.algoType == NETGEN:
5024                 if which == SIMPLE:
5025                     self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5026                                                   "libNETGENEngine.so", UseExisting=0)
5027                 else:
5028                     self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5029                                                   "libNETGENEngine.so", UseExisting=0)
5030             elif self.algoType == MEFISTO:
5031                 print "Mefisto algo support no multi-parameter hypothesis"
5032             elif self.algoType == NETGEN_2D:
5033                 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5034                                               "libNETGENEngine.so", UseExisting=0)
5035             elif self.algoType == BLSURF:
5036                 self.params = self.Hypothesis("BLSURF_Parameters", [],
5037                                               "libBLSURFEngine.so", UseExisting=0)
5038             else:
5039                 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5040         return self.params
5041
5042     ## Sets MaxSize
5043     #
5044     #  Only for algoType == NETGEN
5045     #  @ingroup l3_hypos_netgen
5046     def SetMaxSize(self, theSize):
5047         if self.Parameters():
5048             self.params.SetMaxSize(theSize)
5049
5050     ## Sets SecondOrder flag
5051     #
5052     #  Only for algoType == NETGEN
5053     #  @ingroup l3_hypos_netgen
5054     def SetSecondOrder(self, theVal):
5055         if self.Parameters():
5056             self.params.SetSecondOrder(theVal)
5057
5058     ## Sets Optimize flag
5059     #
5060     #  Only for algoType == NETGEN
5061     #  @ingroup l3_hypos_netgen
5062     def SetOptimize(self, theVal):
5063         if self.Parameters():
5064             self.params.SetOptimize(theVal)
5065
5066     ## Sets Fineness
5067     #  @param theFineness is:
5068     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5069     #
5070     #  Only for algoType == NETGEN
5071     #  @ingroup l3_hypos_netgen
5072     def SetFineness(self, theFineness):
5073         if self.Parameters():
5074             self.params.SetFineness(theFineness)
5075
5076     ## Sets GrowthRate
5077     #
5078     #  Only for algoType == NETGEN
5079     #  @ingroup l3_hypos_netgen
5080     def SetGrowthRate(self, theRate):
5081         if self.Parameters():
5082             self.params.SetGrowthRate(theRate)
5083
5084     ## Sets NbSegPerEdge
5085     #
5086     #  Only for algoType == NETGEN
5087     #  @ingroup l3_hypos_netgen
5088     def SetNbSegPerEdge(self, theVal):
5089         if self.Parameters():
5090             self.params.SetNbSegPerEdge(theVal)
5091
5092     ## Sets NbSegPerRadius
5093     #
5094     #  Only for algoType == NETGEN
5095     #  @ingroup l3_hypos_netgen
5096     def SetNbSegPerRadius(self, theVal):
5097         if self.Parameters():
5098             self.params.SetNbSegPerRadius(theVal)
5099
5100     ## Sets number of segments overriding value set by SetLocalLength()
5101     #
5102     #  Only for algoType == NETGEN
5103     #  @ingroup l3_hypos_netgen
5104     def SetNumberOfSegments(self, theVal):
5105         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5106
5107     ## Sets number of segments overriding value set by SetNumberOfSegments()
5108     #
5109     #  Only for algoType == NETGEN
5110     #  @ingroup l3_hypos_netgen
5111     def SetLocalLength(self, theVal):
5112         self.Parameters(SIMPLE).SetLocalLength(theVal)
5113
5114     pass
5115
5116
5117 # Public class: Mesh_Quadrangle
5118 # -----------------------------
5119
5120 ## Defines a quadrangle 2D algorithm
5121 #
5122 #  @ingroup l3_algos_basic
5123 class Mesh_Quadrangle(Mesh_Algorithm):
5124
5125     params=0
5126
5127     ## Private constructor.
5128     def __init__(self, mesh, geom=0):
5129         Mesh_Algorithm.__init__(self)
5130         self.Create(mesh, geom, "Quadrangle_2D")
5131         return
5132
5133     ## Defines "QuadrangleParameters" hypothesis
5134     #  @param quadType defines the algorithm of transition between differently descretized
5135     #                  sides of a geometrical face:
5136     #  - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5137     #                    area along the finer meshed sides.
5138     #  - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5139     #                    finer meshed sides.
5140     #  - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5141     #                    the finer meshed sides, iff the total quantity of segments on
5142     #                    all four sides of the face is even (divisible by 2).
5143     #  - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5144     #                    area is located along the coarser meshed sides.
5145     #  - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5146     #                    is made gradually, layer by layer. This type has a limitation on
5147     #                    the number of segments: one pair of opposite sides must have the
5148     #                    same number of segments, the other pair must have an even difference
5149     #                    between the numbers of segments on the sides.
5150     #  @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5151     #                  will be created while other elements will be quadrangles.
5152     #                  Vertex can be either a GEOM_Object or a vertex ID within the
5153     #                  shape to mesh
5154     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
5155     #                  the same parameters, else (default) - creates a new one
5156     #  @ingroup l3_hypos_quad
5157     def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5158         vertexID = triangleVertex
5159         if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5160             vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5161         if not self.params:
5162             compFun = lambda hyp,args: \
5163                       hyp.GetQuadType() == args[0] and \
5164                       ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5165             self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5166                                           UseExisting = UseExisting, CompareMethod=compFun)
5167             pass
5168         if self.params.GetQuadType() != quadType:
5169             self.params.SetQuadType(quadType)
5170         if vertexID > 0:
5171             self.params.SetTriaVertex( vertexID )
5172         return self.params
5173
5174     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5175     #   quadrangles are built in the transition area along the finer meshed sides,
5176     #   iff the total quantity of segments on all four sides of the face is even.
5177     #  @param reversed if True, transition area is located along the coarser meshed sides.
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 QuadranglePreference(self, reversed=False, UseExisting=0):
5182         if reversed:
5183             return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5184         return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5185
5186     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5187     #   triangles are built in the transition area along the finer meshed sides.
5188     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
5189     #                  the same parameters, else (default) - creates a new one
5190     #  @ingroup l3_hypos_quad
5191     def TrianglePreference(self, UseExisting=0):
5192         return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5193
5194     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5195     #   quadrangles are built and the transition between the sides is made gradually,
5196     #   layer by layer. This type has a limitation on the number of segments: one pair
5197     #   of opposite sides must have the same number of segments, the other pair must
5198     #   have an even difference between the numbers of segments on the sides.
5199     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
5200     #                  the same parameters, else (default) - creates a new one
5201     #  @ingroup l3_hypos_quad
5202     def Reduced(self, UseExisting=0):
5203         return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5204
5205     ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5206     #  @param vertex: vertex of a trilateral geometrical face, around which triangles
5207     #                 will be created while other elements will be quadrangles.
5208     #                 Vertex can be either a GEOM_Object or a vertex ID within the
5209     #                 shape to mesh
5210     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
5211     #                   the same parameters, else (default) - creates a new one
5212     #  @ingroup l3_hypos_quad
5213     def TriangleVertex(self, vertex, UseExisting=0):
5214         return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5215
5216
5217 # Public class: Mesh_Tetrahedron
5218 # ------------------------------
5219
5220 ## Defines a tetrahedron 3D algorithm
5221 #
5222 #  @ingroup l3_algos_basic
5223 class Mesh_Tetrahedron(Mesh_Algorithm):
5224
5225     params = 0
5226     algoType = 0
5227
5228     ## Private constructor.
5229     def __init__(self, mesh, algoType, geom=0):
5230         Mesh_Algorithm.__init__(self)
5231
5232         if algoType == NETGEN:
5233             CheckPlugin(NETGEN)
5234             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5235             pass
5236
5237         elif algoType == FULL_NETGEN:
5238             CheckPlugin(NETGEN)
5239             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5240             pass
5241
5242         elif algoType == GHS3D:
5243             CheckPlugin(GHS3D)
5244             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5245             pass
5246
5247         elif algoType == GHS3DPRL:
5248             CheckPlugin(GHS3DPRL)
5249             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5250             pass
5251
5252         self.algoType = algoType
5253
5254     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5255     #  @param vol for the maximum volume of each tetrahedron
5256     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5257     #                   the same parameters, else (default) - creates a new one
5258     #  @ingroup l3_hypos_maxvol
5259     def MaxElementVolume(self, vol, UseExisting=0):
5260         if self.algoType == NETGEN:
5261             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5262                                   CompareMethod=self.CompareMaxElementVolume)
5263             hyp.SetMaxElementVolume(vol)
5264             return hyp
5265         elif self.algoType == FULL_NETGEN:
5266             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5267         return None
5268
5269     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5270     def CompareMaxElementVolume(self, hyp, args):
5271         return IsEqual(hyp.GetMaxElementVolume(), args[0])
5272
5273     ## Defines hypothesis having several parameters
5274     #
5275     #  @ingroup l3_hypos_netgen
5276     def Parameters(self, which=SOLE):
5277         if not self.params:
5278
5279             if self.algoType == FULL_NETGEN:
5280                 if which == SIMPLE:
5281                     self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5282                                                   "libNETGENEngine.so", UseExisting=0)
5283                 else:
5284                     self.params = self.Hypothesis("NETGEN_Parameters", [],
5285                                                   "libNETGENEngine.so", UseExisting=0)
5286
5287             elif self.algoType == NETGEN:
5288                 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5289                                               "libNETGENEngine.so", UseExisting=0)
5290
5291             elif self.algoType == GHS3D:
5292                 self.params = self.Hypothesis("GHS3D_Parameters", [],
5293                                               "libGHS3DEngine.so", UseExisting=0)
5294
5295             elif self.algoType == GHS3DPRL:
5296                 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5297                                               "libGHS3DPRLEngine.so", UseExisting=0)
5298             else:
5299                 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5300
5301         return self.params
5302
5303     ## Sets MaxSize
5304     #  Parameter of FULL_NETGEN and NETGEN
5305     #  @ingroup l3_hypos_netgen
5306     def SetMaxSize(self, theSize):
5307         self.Parameters().SetMaxSize(theSize)
5308
5309     ## Sets SecondOrder flag
5310     #  Parameter of FULL_NETGEN
5311     #  @ingroup l3_hypos_netgen
5312     def SetSecondOrder(self, theVal):
5313         self.Parameters().SetSecondOrder(theVal)
5314
5315     ## Sets Optimize flag
5316     #  Parameter of FULL_NETGEN and NETGEN
5317     #  @ingroup l3_hypos_netgen
5318     def SetOptimize(self, theVal):
5319         self.Parameters().SetOptimize(theVal)
5320
5321     ## Sets Fineness
5322     #  @param theFineness is:
5323     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5324     #  Parameter of FULL_NETGEN
5325     #  @ingroup l3_hypos_netgen
5326     def SetFineness(self, theFineness):
5327         self.Parameters().SetFineness(theFineness)
5328
5329     ## Sets GrowthRate
5330     #  Parameter of FULL_NETGEN
5331     #  @ingroup l3_hypos_netgen
5332     def SetGrowthRate(self, theRate):
5333         self.Parameters().SetGrowthRate(theRate)
5334
5335     ## Sets NbSegPerEdge
5336     #  Parameter of FULL_NETGEN
5337     #  @ingroup l3_hypos_netgen
5338     def SetNbSegPerEdge(self, theVal):
5339         self.Parameters().SetNbSegPerEdge(theVal)
5340
5341     ## Sets NbSegPerRadius
5342     #  Parameter of FULL_NETGEN
5343     #  @ingroup l3_hypos_netgen
5344     def SetNbSegPerRadius(self, theVal):
5345         self.Parameters().SetNbSegPerRadius(theVal)
5346
5347     ## Sets number of segments overriding value set by SetLocalLength()
5348     #  Only for algoType == NETGEN_FULL
5349     #  @ingroup l3_hypos_netgen
5350     def SetNumberOfSegments(self, theVal):
5351         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5352
5353     ## Sets number of segments overriding value set by SetNumberOfSegments()
5354     #  Only for algoType == NETGEN_FULL
5355     #  @ingroup l3_hypos_netgen
5356     def SetLocalLength(self, theVal):
5357         self.Parameters(SIMPLE).SetLocalLength(theVal)
5358
5359     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5360     #  Overrides value set by LengthFromEdges()
5361     #  Only for algoType == NETGEN_FULL
5362     #  @ingroup l3_hypos_netgen
5363     def MaxElementArea(self, area):
5364         self.Parameters(SIMPLE).SetMaxElementArea(area)
5365
5366     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5367     #  Overrides value set by MaxElementArea()
5368     #  Only for algoType == NETGEN_FULL
5369     #  @ingroup l3_hypos_netgen
5370     def LengthFromEdges(self):
5371         self.Parameters(SIMPLE).LengthFromEdges()
5372
5373     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5374     #  Overrides value set by MaxElementVolume()
5375     #  Only for algoType == NETGEN_FULL
5376     #  @ingroup l3_hypos_netgen
5377     def LengthFromFaces(self):
5378         self.Parameters(SIMPLE).LengthFromFaces()
5379
5380     ## To mesh "holes" in a solid or not. Default is to mesh.
5381     #  @ingroup l3_hypos_ghs3dh
5382     def SetToMeshHoles(self, toMesh):
5383         #  Parameter of GHS3D
5384         self.Parameters().SetToMeshHoles(toMesh)
5385
5386     ## Set Optimization level:
5387     #   None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5388     #   Strong_Optimization.
5389     # Default is Standard_Optimization
5390     #  @ingroup l3_hypos_ghs3dh
5391     def SetOptimizationLevel(self, level):
5392         #  Parameter of GHS3D
5393         self.Parameters().SetOptimizationLevel(level)
5394
5395     ## Maximal size of memory to be used by the algorithm (in Megabytes).
5396     #  @ingroup l3_hypos_ghs3dh
5397     def SetMaximumMemory(self, MB):
5398         #  Advanced parameter of GHS3D
5399         self.Parameters().SetMaximumMemory(MB)
5400
5401     ## Initial size of memory to be used by the algorithm (in Megabytes) in
5402     #  automatic memory adjustment mode.
5403     #  @ingroup l3_hypos_ghs3dh
5404     def SetInitialMemory(self, MB):
5405         #  Advanced parameter of GHS3D
5406         self.Parameters().SetInitialMemory(MB)
5407
5408     ## Path to working directory.
5409     #  @ingroup l3_hypos_ghs3dh
5410     def SetWorkingDirectory(self, path):
5411         #  Advanced parameter of GHS3D
5412         self.Parameters().SetWorkingDirectory(path)
5413
5414     ## To keep working files or remove them. Log file remains in case of errors anyway.
5415     #  @ingroup l3_hypos_ghs3dh
5416     def SetKeepFiles(self, toKeep):
5417         #  Advanced parameter of GHS3D and GHS3DPRL
5418         self.Parameters().SetKeepFiles(toKeep)
5419
5420     ## To set verbose level [0-10]. <ul>
5421     #<li> 0 - no standard output,
5422     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5423     #     indicates when the final mesh is being saved. In addition the software
5424     #     gives indication regarding the CPU time.
5425     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5426     #     histogram of the skin mesh, quality statistics histogram together with
5427     #     the characteristics of the final mesh.</ul>
5428     #  @ingroup l3_hypos_ghs3dh
5429     def SetVerboseLevel(self, level):
5430         #  Advanced parameter of GHS3D
5431         self.Parameters().SetVerboseLevel(level)
5432
5433     ## To create new nodes.
5434     #  @ingroup l3_hypos_ghs3dh
5435     def SetToCreateNewNodes(self, toCreate):
5436         #  Advanced parameter of GHS3D
5437         self.Parameters().SetToCreateNewNodes(toCreate)
5438
5439     ## To use boundary recovery version which tries to create mesh on a very poor
5440     #  quality surface mesh.
5441     #  @ingroup l3_hypos_ghs3dh
5442     def SetToUseBoundaryRecoveryVersion(self, toUse):
5443         #  Advanced parameter of GHS3D
5444         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5445
5446     ## Sets command line option as text.
5447     #  @ingroup l3_hypos_ghs3dh
5448     def SetTextOption(self, option):
5449         #  Advanced parameter of GHS3D
5450         self.Parameters().SetTextOption(option)
5451
5452     ## Sets MED files name and path.
5453     def SetMEDName(self, value):
5454         self.Parameters().SetMEDName(value)
5455
5456     ## Sets the number of partition of the initial mesh
5457     def SetNbPart(self, value):
5458         self.Parameters().SetNbPart(value)
5459
5460     ## When big mesh, start tepal in background
5461     def SetBackground(self, value):
5462         self.Parameters().SetBackground(value)
5463
5464 # Public class: Mesh_Hexahedron
5465 # ------------------------------
5466
5467 ## Defines a hexahedron 3D algorithm
5468 #
5469 #  @ingroup l3_algos_basic
5470 class Mesh_Hexahedron(Mesh_Algorithm):
5471
5472     params = 0
5473     algoType = 0
5474
5475     ## Private constructor.
5476     def __init__(self, mesh, algoType=Hexa, geom=0):
5477         Mesh_Algorithm.__init__(self)
5478
5479         self.algoType = algoType
5480
5481         if algoType == Hexa:
5482             self.Create(mesh, geom, "Hexa_3D")
5483             pass
5484
5485         elif algoType == Hexotic:
5486             CheckPlugin(Hexotic)
5487             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5488             pass
5489
5490     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5491     #  @ingroup l3_hypos_hexotic
5492     def MinMaxQuad(self, min=3, max=8, quad=True):
5493         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5494                                       UseExisting=0)
5495         self.params.SetHexesMinLevel(min)
5496         self.params.SetHexesMaxLevel(max)
5497         self.params.SetHexoticQuadrangles(quad)
5498         return self.params
5499
5500 # Deprecated, only for compatibility!
5501 # Public class: Mesh_Netgen
5502 # ------------------------------
5503
5504 ## Defines a NETGEN-based 2D or 3D algorithm
5505 #  that needs no discrete boundary (i.e. independent)
5506 #
5507 #  This class is deprecated, only for compatibility!
5508 #
5509 #  More details.
5510 #  @ingroup l3_algos_basic
5511 class Mesh_Netgen(Mesh_Algorithm):
5512
5513     is3D = 0
5514
5515     ## Private constructor.
5516     def __init__(self, mesh, is3D, geom=0):
5517         Mesh_Algorithm.__init__(self)
5518
5519         CheckPlugin(NETGEN)
5520
5521         self.is3D = is3D
5522         if is3D:
5523             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5524             pass
5525
5526         else:
5527             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5528             pass
5529
5530     ## Defines the hypothesis containing parameters of the algorithm
5531     def Parameters(self):
5532         if self.is3D:
5533             hyp = self.Hypothesis("NETGEN_Parameters", [],
5534                                   "libNETGENEngine.so", UseExisting=0)
5535         else:
5536             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5537                                   "libNETGENEngine.so", UseExisting=0)
5538         return hyp
5539
5540 # Public class: Mesh_Projection1D
5541 # ------------------------------
5542
5543 ## Defines a projection 1D algorithm
5544 #  @ingroup l3_algos_proj
5545 #
5546 class Mesh_Projection1D(Mesh_Algorithm):
5547
5548     ## Private constructor.
5549     def __init__(self, mesh, geom=0):
5550         Mesh_Algorithm.__init__(self)
5551         self.Create(mesh, geom, "Projection_1D")
5552
5553     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5554     #  a mesh pattern is taken, and, optionally, the association of vertices
5555     #  between the source edge and a target edge (to which a hypothesis is assigned)
5556     #  @param edge from which nodes distribution is taken
5557     #  @param mesh from which nodes distribution is taken (optional)
5558     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5559     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5560     #  to associate with \a srcV (optional)
5561     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5562     #                     the same parameters, else (default) - creates a new one
5563     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5564         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5565                               UseExisting=0)
5566                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5567         hyp.SetSourceEdge( edge )
5568         if not mesh is None and isinstance(mesh, Mesh):
5569             mesh = mesh.GetMesh()
5570         hyp.SetSourceMesh( mesh )
5571         hyp.SetVertexAssociation( srcV, tgtV )
5572         return hyp
5573
5574     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5575     #def CompareSourceEdge(self, hyp, args):
5576     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5577     #    return False
5578
5579
5580 # Public class: Mesh_Projection2D
5581 # ------------------------------
5582
5583 ## Defines a projection 2D algorithm
5584 #  @ingroup l3_algos_proj
5585 #
5586 class Mesh_Projection2D(Mesh_Algorithm):
5587
5588     ## Private constructor.
5589     def __init__(self, mesh, geom=0):
5590         Mesh_Algorithm.__init__(self)
5591         self.Create(mesh, geom, "Projection_2D")
5592
5593     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5594     #  a mesh pattern is taken, and, optionally, the association of vertices
5595     #  between the source face and the target face (to which a hypothesis is assigned)
5596     #  @param face from which the mesh pattern is taken
5597     #  @param mesh from which the mesh pattern is taken (optional)
5598     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5599     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5600     #               to associate with \a srcV1 (optional)
5601     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5602     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5603     #               to associate with \a srcV2 (optional)
5604     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
5605     #                     the same parameters, else (default) - forces the creation a new one
5606     #
5607     #  Note: all association vertices must belong to one edge of a face
5608     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5609                    srcV2=None, tgtV2=None, UseExisting=0):
5610         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5611                               UseExisting=0)
5612                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5613         hyp.SetSourceFace( face )
5614         if not mesh is None and isinstance(mesh, Mesh):
5615             mesh = mesh.GetMesh()
5616         hyp.SetSourceMesh( mesh )
5617         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5618         return hyp
5619
5620     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5621     #def CompareSourceFace(self, hyp, args):
5622     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5623     #    return False
5624
5625 # Public class: Mesh_Projection3D
5626 # ------------------------------
5627
5628 ## Defines a projection 3D algorithm
5629 #  @ingroup l3_algos_proj
5630 #
5631 class Mesh_Projection3D(Mesh_Algorithm):
5632
5633     ## Private constructor.
5634     def __init__(self, mesh, geom=0):
5635         Mesh_Algorithm.__init__(self)
5636         self.Create(mesh, geom, "Projection_3D")
5637
5638     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5639     #  the mesh pattern is taken, and, optionally, the  association of vertices
5640     #  between the source and the target solid  (to which a hipothesis is assigned)
5641     #  @param solid from where the mesh pattern is taken
5642     #  @param mesh from where the mesh pattern is taken (optional)
5643     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5644     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5645     #  to associate with \a srcV1 (optional)
5646     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5647     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5648     #  to associate with \a srcV2 (optional)
5649     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
5650     #                     the same parameters, else (default) - creates a new one
5651     #
5652     #  Note: association vertices must belong to one edge of a solid
5653     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5654                       srcV2=0, tgtV2=0, UseExisting=0):
5655         hyp = self.Hypothesis("ProjectionSource3D",
5656                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5657                               UseExisting=0)
5658                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5659         hyp.SetSource3DShape( solid )
5660         if not mesh is None and isinstance(mesh, Mesh):
5661             mesh = mesh.GetMesh()
5662         hyp.SetSourceMesh( mesh )
5663         if srcV1 and srcV2 and tgtV1 and tgtV2:
5664             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5665         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5666         return hyp
5667
5668     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5669     #def CompareSourceShape3D(self, hyp, args):
5670     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5671     #    return False
5672
5673
5674 # Public class: Mesh_Prism
5675 # ------------------------
5676
5677 ## Defines a 3D extrusion algorithm
5678 #  @ingroup l3_algos_3dextr
5679 #
5680 class Mesh_Prism3D(Mesh_Algorithm):
5681
5682     ## Private constructor.
5683     def __init__(self, mesh, geom=0):
5684         Mesh_Algorithm.__init__(self)
5685         self.Create(mesh, geom, "Prism_3D")
5686
5687 # Public class: Mesh_RadialPrism
5688 # -------------------------------
5689
5690 ## Defines a Radial Prism 3D algorithm
5691 #  @ingroup l3_algos_radialp
5692 #
5693 class Mesh_RadialPrism3D(Mesh_Algorithm):
5694
5695     ## Private constructor.
5696     def __init__(self, mesh, geom=0):
5697         Mesh_Algorithm.__init__(self)
5698         self.Create(mesh, geom, "RadialPrism_3D")
5699
5700         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5701         self.nbLayers = None
5702
5703     ## Return 3D hypothesis holding the 1D one
5704     def Get3DHypothesis(self):
5705         return self.distribHyp
5706
5707     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5708     #  hypothesis. Returns the created hypothesis
5709     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5710         #print "OwnHypothesis",hypType
5711         if not self.nbLayers is None:
5712             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5713             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5714         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5715         self.mesh.smeshpyD.SetCurrentStudy( None )
5716         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5717         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5718         self.distribHyp.SetLayerDistribution( hyp )
5719         return hyp
5720
5721     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5722     #  prisms to build between the inner and outer shells
5723     #  @param n number of layers
5724     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5725     #                     the same parameters, else (default) - creates a new one
5726     def NumberOfLayers(self, n, UseExisting=0):
5727         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5728         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5729                                         CompareMethod=self.CompareNumberOfLayers)
5730         self.nbLayers.SetNumberOfLayers( n )
5731         return self.nbLayers
5732
5733     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5734     def CompareNumberOfLayers(self, hyp, args):
5735         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5736
5737     ## Defines "LocalLength" hypothesis, specifying the segment length
5738     #  to build between the inner and the outer shells
5739     #  @param l the length of segments
5740     #  @param p the precision of rounding
5741     def LocalLength(self, l, p=1e-07):
5742         hyp = self.OwnHypothesis("LocalLength", [l,p])
5743         hyp.SetLength(l)
5744         hyp.SetPrecision(p)
5745         return hyp
5746
5747     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5748     #  prisms to build between the inner and the outer shells.
5749     #  @param n the number of layers
5750     #  @param s the scale factor (optional)
5751     def NumberOfSegments(self, n, s=[]):
5752         if s == []:
5753             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5754         else:
5755             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5756             hyp.SetDistrType( 1 )
5757             hyp.SetScaleFactor(s)
5758         hyp.SetNumberOfSegments(n)
5759         return hyp
5760
5761     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5762     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
5763     #  @param start  the length of the first segment
5764     #  @param end    the length of the last  segment
5765     def Arithmetic1D(self, start, end ):
5766         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5767         hyp.SetLength(start, 1)
5768         hyp.SetLength(end  , 0)
5769         return hyp
5770
5771     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5772     #  to build between the inner and the outer shells as geometric length increasing
5773     #  @param start for the length of the first segment
5774     #  @param end   for the length of the last  segment
5775     def StartEndLength(self, start, end):
5776         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5777         hyp.SetLength(start, 1)
5778         hyp.SetLength(end  , 0)
5779         return hyp
5780
5781     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5782     #  to build between the inner and outer shells
5783     #  @param fineness defines the quality of the mesh within the range [0-1]
5784     def AutomaticLength(self, fineness=0):
5785         hyp = self.OwnHypothesis("AutomaticLength")
5786         hyp.SetFineness( fineness )
5787         return hyp
5788
5789 # Public class: Mesh_RadialQuadrangle1D2D
5790 # -------------------------------
5791
5792 ## Defines a Radial Quadrangle 1D2D algorithm
5793 #  @ingroup l2_algos_radialq
5794 #
5795 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5796
5797     ## Private constructor.
5798     def __init__(self, mesh, geom=0):
5799         Mesh_Algorithm.__init__(self)
5800         self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5801
5802         self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5803         self.nbLayers = None
5804
5805     ## Return 2D hypothesis holding the 1D one
5806     def Get2DHypothesis(self):
5807         return self.distribHyp
5808
5809     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5810     #  hypothesis. Returns the created hypothesis
5811     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5812         #print "OwnHypothesis",hypType
5813         if self.nbLayers:
5814             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5815         if self.distribHyp is None:
5816             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5817         else:
5818             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5819         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5820         self.mesh.smeshpyD.SetCurrentStudy( None )
5821         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5822         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5823         self.distribHyp.SetLayerDistribution( hyp )
5824         return hyp
5825
5826     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5827     #  @param n number of layers
5828     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5829     #                     the same parameters, else (default) - creates a new one
5830     def NumberOfLayers(self, n, UseExisting=0):
5831         if self.distribHyp:
5832             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5833         self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5834                                         CompareMethod=self.CompareNumberOfLayers)
5835         self.nbLayers.SetNumberOfLayers( n )
5836         return self.nbLayers
5837
5838     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5839     def CompareNumberOfLayers(self, hyp, args):
5840         return IsEqual(hyp.GetNumberOfLayers(), args[0])
5841
5842     ## Defines "LocalLength" hypothesis, specifying the segment length
5843     #  @param l the length of segments
5844     #  @param p the precision of rounding
5845     def LocalLength(self, l, p=1e-07):
5846         hyp = self.OwnHypothesis("LocalLength", [l,p])
5847         hyp.SetLength(l)
5848         hyp.SetPrecision(p)
5849         return hyp
5850
5851     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5852     #  @param n the number of layers
5853     #  @param s the scale factor (optional)
5854     def NumberOfSegments(self, n, s=[]):
5855         if s == []:
5856             hyp = self.OwnHypothesis("NumberOfSegments", [n])
5857         else:
5858             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5859             hyp.SetDistrType( 1 )
5860             hyp.SetScaleFactor(s)
5861         hyp.SetNumberOfSegments(n)
5862         return hyp
5863
5864     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5865     #  with a length that changes in arithmetic progression
5866     #  @param start  the length of the first segment
5867     #  @param end    the length of the last  segment
5868     def Arithmetic1D(self, start, end ):
5869         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5870         hyp.SetLength(start, 1)
5871         hyp.SetLength(end  , 0)
5872         return hyp
5873
5874     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5875     #  as geometric length increasing
5876     #  @param start for the length of the first segment
5877     #  @param end   for the length of the last  segment
5878     def StartEndLength(self, start, end):
5879         hyp = self.OwnHypothesis("StartEndLength", [start, end])
5880         hyp.SetLength(start, 1)
5881         hyp.SetLength(end  , 0)
5882         return hyp
5883
5884     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5885     #  @param fineness defines the quality of the mesh within the range [0-1]
5886     def AutomaticLength(self, fineness=0):
5887         hyp = self.OwnHypothesis("AutomaticLength")
5888         hyp.SetFineness( fineness )
5889         return hyp
5890
5891
5892 # Public class: Mesh_UseExistingElements
5893 # --------------------------------------
5894 ## Defines a Radial Quadrangle 1D2D algorithm
5895 #  @ingroup l3_algos_basic
5896 #
5897 class Mesh_UseExistingElements(Mesh_Algorithm):
5898
5899     def __init__(self, dim, mesh, geom=0):
5900         if dim == 1:
5901             self.Create(mesh, geom, "Import_1D")
5902         else:
5903             self.Create(mesh, geom, "Import_1D2D")
5904         return
5905
5906     ## Defines "Source edges" hypothesis, specifying groups of edges to import
5907     #  @param groups list of groups of edges
5908     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5909     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5910     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5911     #                     the same parameters, else (default) - creates a new one
5912     def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5913         if self.algo.GetName() == "Import_2D":
5914             raise ValueError, "algoritm dimension mismatch"
5915         hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5916                               UseExisting=UseExisting, CompareMethod=self._compareHyp)
5917         hyp.SetSourceEdges(groups)
5918         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5919         return hyp
5920
5921     ## Defines "Source faces" hypothesis, specifying groups of faces to import
5922     #  @param groups list of groups of faces
5923     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5924     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5925     #  @param UseExisting if ==true - searches for the existing hypothesis created with
5926     #                     the same parameters, else (default) - creates a new one
5927     def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5928         if self.algo.GetName() == "Import_1D":
5929             raise ValueError, "algoritm dimension mismatch"
5930         hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5931                               UseExisting=UseExisting, CompareMethod=self._compareHyp)
5932         hyp.SetSourceFaces(groups)
5933         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5934         return hyp
5935
5936     def _compareHyp(self,hyp,args):
5937         if hasattr( hyp, "GetSourceEdges"):
5938             entries = hyp.GetSourceEdges()
5939         else:
5940             entries = hyp.GetSourceFaces()
5941         groups = args[0]
5942         toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5943         if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
5944             entries2 = []
5945             study = self.mesh.smeshpyD.GetCurrentStudy()
5946             if study:
5947                 for g in groups:
5948                     ior  = salome.orb.object_to_string(g)
5949                     sobj = study.FindObjectIOR(ior)
5950                     if sobj: entries2.append( sobj.GetID() )
5951                     pass
5952                 pass
5953             entries.sort()
5954             entries2.sort()
5955             return entries == entries2
5956         return False
5957
5958
5959 # Private class: Mesh_UseExisting
5960 # -------------------------------
5961 class Mesh_UseExisting(Mesh_Algorithm):
5962
5963     def __init__(self, dim, mesh, geom=0):
5964         if dim == 1:
5965             self.Create(mesh, geom, "UseExisting_1D")
5966         else:
5967             self.Create(mesh, geom, "UseExisting_2D")
5968
5969
5970 import salome_notebook
5971 notebook = salome_notebook.notebook
5972
5973 ##Return values of the notebook variables
5974 def ParseParameters(last, nbParams,nbParam, value):
5975     result = None
5976     strResult = ""
5977     counter = 0
5978     listSize = len(last)
5979     for n in range(0,nbParams):
5980         if n+1 != nbParam:
5981             if counter < listSize:
5982                 strResult = strResult + last[counter]
5983             else:
5984                 strResult = strResult + ""
5985         else:
5986             if isinstance(value, str):
5987                 if notebook.isVariable(value):
5988                     result = notebook.get(value)
5989                     strResult=strResult+value
5990                 else:
5991                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5992             else:
5993                 strResult=strResult+str(value)
5994                 result = value
5995         if nbParams - 1 != counter:
5996             strResult=strResult+var_separator #":"
5997         counter = counter+1
5998     return result, strResult
5999
6000 #Wrapper class for StdMeshers_LocalLength hypothesis
6001 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6002
6003     ## Set Length parameter value
6004     #  @param length numerical value or name of variable from notebook
6005     def SetLength(self, length):
6006         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6007         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6008         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6009
6010    ## Set Precision parameter value
6011    #  @param precision numerical value or name of variable from notebook
6012     def SetPrecision(self, precision):
6013         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6014         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6015         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6016
6017 #Registering the new proxy for LocalLength
6018 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6019
6020
6021 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6022 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6023
6024     def SetLayerDistribution(self, hypo):
6025         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6026         hypo.ClearParameters();
6027         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6028
6029 #Registering the new proxy for LayerDistribution
6030 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6031
6032 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6033 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6034
6035     ## Set Length parameter value
6036     #  @param length numerical value or name of variable from notebook
6037     def SetLength(self, length):
6038         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6039         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6040         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6041
6042 #Registering the new proxy for SegmentLengthAroundVertex
6043 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6044
6045
6046 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6047 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6048
6049     ## Set Length parameter value
6050     #  @param length   numerical value or name of variable from notebook
6051     #  @param isStart  true is length is Start Length, otherwise false
6052     def SetLength(self, length, isStart):
6053         nb = 2
6054         if isStart:
6055             nb = 1
6056         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6057         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6058         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6059
6060 #Registering the new proxy for Arithmetic1D
6061 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6062
6063 #Wrapper class for StdMeshers_Deflection1D hypothesis
6064 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6065
6066     ## Set Deflection parameter value
6067     #  @param deflection numerical value or name of variable from notebook
6068     def SetDeflection(self, deflection):
6069         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6070         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6071         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6072
6073 #Registering the new proxy for Deflection1D
6074 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6075
6076 #Wrapper class for StdMeshers_StartEndLength hypothesis
6077 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6078
6079     ## Set Length parameter value
6080     #  @param length  numerical value or name of variable from notebook
6081     #  @param isStart true is length is Start Length, otherwise false
6082     def SetLength(self, length, isStart):
6083         nb = 2
6084         if isStart:
6085             nb = 1
6086         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6087         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6088         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6089
6090 #Registering the new proxy for StartEndLength
6091 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6092
6093 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6094 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6095
6096     ## Set Max Element Area parameter value
6097     #  @param area  numerical value or name of variable from notebook
6098     def SetMaxElementArea(self, area):
6099         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6100         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6101         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6102
6103 #Registering the new proxy for MaxElementArea
6104 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6105
6106
6107 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6108 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6109
6110     ## Set Max Element Volume parameter value
6111     #  @param volume numerical value or name of variable from notebook
6112     def SetMaxElementVolume(self, volume):
6113         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6114         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6115         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6116
6117 #Registering the new proxy for MaxElementVolume
6118 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6119
6120
6121 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6122 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6123
6124     ## Set Number Of Layers parameter value
6125     #  @param nbLayers  numerical value or name of variable from notebook
6126     def SetNumberOfLayers(self, nbLayers):
6127         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6128         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6129         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6130
6131 #Registering the new proxy for NumberOfLayers
6132 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6133
6134 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6135 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6136
6137     ## Set Number Of Segments parameter value
6138     #  @param nbSeg numerical value or name of variable from notebook
6139     def SetNumberOfSegments(self, nbSeg):
6140         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6141         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6142         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6143         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6144
6145     ## Set Scale Factor parameter value
6146     #  @param factor numerical value or name of variable from notebook
6147     def SetScaleFactor(self, factor):
6148         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6149         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6150         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6151
6152 #Registering the new proxy for NumberOfSegments
6153 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6154
6155 if not noNETGENPlugin:
6156     #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6157     class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6158
6159         ## Set Max Size parameter value
6160         #  @param maxsize numerical value or name of variable from notebook
6161         def SetMaxSize(self, maxsize):
6162             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6163             maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6164             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6165             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6166
6167         ## Set Growth Rate parameter value
6168         #  @param value  numerical value or name of variable from notebook
6169         def SetGrowthRate(self, value):
6170             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6171             value, parameters = ParseParameters(lastParameters,4,2,value)
6172             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6173             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6174
6175         ## Set Number of Segments per Edge parameter value
6176         #  @param value  numerical value or name of variable from notebook
6177         def SetNbSegPerEdge(self, value):
6178             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6179             value, parameters = ParseParameters(lastParameters,4,3,value)
6180             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6181             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6182
6183         ## Set Number of Segments per Radius parameter value
6184         #  @param value  numerical value or name of variable from notebook
6185         def SetNbSegPerRadius(self, value):
6186             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6187             value, parameters = ParseParameters(lastParameters,4,4,value)
6188             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6189             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6190
6191     #Registering the new proxy for NETGENPlugin_Hypothesis
6192     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6193
6194
6195     #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6196     class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6197         pass
6198
6199     #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6200     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6201
6202     #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6203     class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6204
6205         ## Set Number of Segments parameter value
6206         #  @param nbSeg numerical value or name of variable from notebook
6207         def SetNumberOfSegments(self, nbSeg):
6208             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6209             nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6210             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6211             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6212
6213         ## Set Local Length parameter value
6214         #  @param length numerical value or name of variable from notebook
6215         def SetLocalLength(self, length):
6216             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6217             length, parameters = ParseParameters(lastParameters,2,1,length)
6218             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6219             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6220
6221         ## Set Max Element Area parameter value
6222         #  @param area numerical value or name of variable from notebook
6223         def SetMaxElementArea(self, area):
6224             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6225             area, parameters = ParseParameters(lastParameters,2,2,area)
6226             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6227             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6228
6229         def LengthFromEdges(self):
6230             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6231             value = 0;
6232             value, parameters = ParseParameters(lastParameters,2,2,value)
6233             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6234             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6235
6236     #Registering the new proxy for NETGEN_SimpleParameters_2D
6237     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6238
6239
6240     #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6241     class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6242         ## Set Max Element Volume parameter value
6243         #  @param volume numerical value or name of variable from notebook
6244         def SetMaxElementVolume(self, volume):
6245             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6246             volume, parameters = ParseParameters(lastParameters,3,3,volume)
6247             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6248             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6249
6250         def LengthFromFaces(self):
6251             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6252             value = 0;
6253             value, parameters = ParseParameters(lastParameters,3,3,value)
6254             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6255             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6256
6257     #Registering the new proxy for NETGEN_SimpleParameters_3D
6258     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6259
6260     pass # if not noNETGENPlugin:
6261
6262 class Pattern(SMESH._objref_SMESH_Pattern):
6263
6264     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6265         flag = False
6266         if isinstance(theNodeIndexOnKeyPoint1,str):
6267             flag = True
6268         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6269         if flag:
6270             theNodeIndexOnKeyPoint1 -= 1
6271         theMesh.SetParameters(Parameters)
6272         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6273
6274     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6275         flag0 = False
6276         flag1 = False
6277         if isinstance(theNode000Index,str):
6278             flag0 = True
6279         if isinstance(theNode001Index,str):
6280             flag1 = True
6281         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6282         if flag0:
6283             theNode000Index -= 1
6284         if flag1:
6285             theNode001Index -= 1
6286         theMesh.SetParameters(Parameters)
6287         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6288
6289 #Registering the new proxy for Pattern
6290 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)