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