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