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