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