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