Version: 6.3.1

src/SMESH_SWIG/smeshDC.py

Go to the documentation of this file.
00001 # Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 #  File   : smesh.py
00020 #  Author : Francis KLOSS, OCC
00021 #  Module : SMESH
00022 
00023 """
00024  \namespace smesh
00025  \brief Module smesh
00026 """
00027 
00028 ## @defgroup l1_auxiliary Auxiliary methods and structures
00029 ## @defgroup l1_creating  Creating meshes
00030 ## @{
00031 ##   @defgroup l2_impexp     Importing and exporting meshes
00032 ##   @defgroup l2_construct  Constructing meshes
00033 ##   @defgroup l2_algorithms Defining Algorithms
00034 ##   @{
00035 ##     @defgroup l3_algos_basic   Basic meshing algorithms
00036 ##     @defgroup l3_algos_proj    Projection Algorithms
00037 ##     @defgroup l3_algos_radialp Radial Prism
00038 ##     @defgroup l3_algos_segmarv Segments around Vertex
00039 ##     @defgroup l3_algos_3dextr  3D extrusion meshing algorithm
00040 
00041 ##   @}
00042 ##   @defgroup l2_hypotheses Defining hypotheses
00043 ##   @{
00044 ##     @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
00045 ##     @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
00046 ##     @defgroup l3_hypos_maxvol Max Element Volume hypothesis
00047 ##     @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
00048 ##     @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
00049 ##     @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
00050 ##     @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
00051 ##     @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
00052 ##     @defgroup l3_hypos_additi Additional Hypotheses
00053 
00054 ##   @}
00055 ##   @defgroup l2_submeshes Constructing submeshes
00056 ##   @defgroup l2_compounds Building Compounds
00057 ##   @defgroup l2_editing   Editing Meshes
00058 
00059 ## @}
00060 ## @defgroup l1_meshinfo  Mesh Information
00061 ## @defgroup l1_controls  Quality controls and Filtering
00062 ## @defgroup l1_grouping  Grouping elements
00063 ## @{
00064 ##   @defgroup l2_grps_create Creating groups
00065 ##   @defgroup l2_grps_edit   Editing groups
00066 ##   @defgroup l2_grps_operon Using operations on groups
00067 ##   @defgroup l2_grps_delete Deleting Groups
00068 
00069 ## @}
00070 ## @defgroup l1_modifying Modifying meshes
00071 ## @{
00072 ##   @defgroup l2_modif_add      Adding nodes and elements
00073 ##   @defgroup l2_modif_del      Removing nodes and elements
00074 ##   @defgroup l2_modif_edit     Modifying nodes and elements
00075 ##   @defgroup l2_modif_renumber Renumbering nodes and elements
00076 ##   @defgroup l2_modif_trsf     Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
00077 ##   @defgroup l2_modif_movenode Moving nodes
00078 ##   @defgroup l2_modif_throughp Mesh through point
00079 ##   @defgroup l2_modif_invdiag  Diagonal inversion of elements
00080 ##   @defgroup l2_modif_unitetri Uniting triangles
00081 ##   @defgroup l2_modif_changori Changing orientation of elements
00082 ##   @defgroup l2_modif_cutquadr Cutting quadrangles
00083 ##   @defgroup l2_modif_smooth   Smoothing
00084 ##   @defgroup l2_modif_extrurev Extrusion and Revolution
00085 ##   @defgroup l2_modif_patterns Pattern mapping
00086 ##   @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
00087 
00088 ## @}
00089 ## @defgroup l1_measurements Measurements
00090 
00091 import salome
00092 import geompyDC
00093 
00094 import SMESH # This is necessary for back compatibility
00095 from   SMESH import *
00096 
00097 import StdMeshers
00098 
00099 import SALOME
00100 import SALOMEDS
00101 
00102 # import NETGENPlugin module if possible
00103 noNETGENPlugin = 0
00104 try:
00105     import NETGENPlugin
00106 except ImportError:
00107     noNETGENPlugin = 1
00108     pass
00109 
00110 # import GHS3DPlugin module if possible
00111 noGHS3DPlugin = 0
00112 try:
00113     import GHS3DPlugin
00114 except ImportError:
00115     noGHS3DPlugin = 1
00116     pass
00117 
00118 # import GHS3DPRLPlugin module if possible
00119 noGHS3DPRLPlugin = 0
00120 try:
00121     import GHS3DPRLPlugin
00122 except ImportError:
00123     noGHS3DPRLPlugin = 1
00124     pass
00125 
00126 # import HexoticPlugin module if possible
00127 noHexoticPlugin = 0
00128 try:
00129     import HexoticPlugin
00130 except ImportError:
00131     noHexoticPlugin = 1
00132     pass
00133 
00134 # import BLSURFPlugin module if possible
00135 noBLSURFPlugin = 0
00136 try:
00137     import BLSURFPlugin
00138 except ImportError:
00139     noBLSURFPlugin = 1
00140     pass
00141 
00142 ## @addtogroup l1_auxiliary
00143 ## @{
00144 
00145 # Types of algorithms
00146 REGULAR    = 1
00147 PYTHON     = 2
00148 COMPOSITE  = 3
00149 SOLE       = 0
00150 SIMPLE     = 1
00151 
00152 MEFISTO       = 3
00153 NETGEN        = 4
00154 GHS3D         = 5
00155 FULL_NETGEN   = 6
00156 NETGEN_2D     = 7
00157 NETGEN_1D2D   = NETGEN
00158 NETGEN_1D2D3D = FULL_NETGEN
00159 NETGEN_FULL   = FULL_NETGEN
00160 Hexa    = 8
00161 Hexotic = 9
00162 BLSURF  = 10
00163 GHS3DPRL = 11
00164 QUADRANGLE = 0
00165 RADIAL_QUAD = 1
00166 
00167 # MirrorType enumeration
00168 POINT = SMESH_MeshEditor.POINT
00169 AXIS =  SMESH_MeshEditor.AXIS
00170 PLANE = SMESH_MeshEditor.PLANE
00171 
00172 # Smooth_Method enumeration
00173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
00174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
00175 
00176 # Fineness enumeration (for NETGEN)
00177 VeryCoarse = 0
00178 Coarse     = 1
00179 Moderate   = 2
00180 Fine       = 3
00181 VeryFine   = 4
00182 Custom     = 5
00183 
00184 # Optimization level of GHS3D
00185 # V3.1
00186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
00187 # V4.1 (partialy redefines V3.1). Issue 0020574
00188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
00189 
00190 # Topology treatment way of BLSURF
00191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
00192 
00193 # Element size flag of BLSURF
00194 DefaultSize, DefaultGeom, Custom = 0,0,1
00195 
00196 PrecisionConfusion = 1e-07
00197 
00198 # TopAbs_State enumeration
00199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
00200 
00201 # Methods of splitting a hexahedron into tetrahedra
00202 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
00203 
00204 # import items of enum QuadType
00205 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
00206 
00207 ## Converts an angle from degrees to radians
00208 def DegreesToRadians(AngleInDegrees):
00209     from math import pi
00210     return AngleInDegrees * pi / 180.0
00211 
00212 # Salome notebook variable separator
00213 var_separator = ":"
00214 
00215 # Parametrized substitute for PointStruct
00216 class PointStructStr:
00217 
00218     x = 0
00219     y = 0
00220     z = 0
00221     xStr = ""
00222     yStr = ""
00223     zStr = ""
00224 
00225     def __init__(self, xStr, yStr, zStr):
00226         self.xStr = xStr
00227         self.yStr = yStr
00228         self.zStr = zStr
00229         if isinstance(xStr, str) and notebook.isVariable(xStr):
00230             self.x = notebook.get(xStr)
00231         else:
00232             self.x = xStr
00233         if isinstance(yStr, str) and notebook.isVariable(yStr):
00234             self.y = notebook.get(yStr)
00235         else:
00236             self.y = yStr
00237         if isinstance(zStr, str) and notebook.isVariable(zStr):
00238             self.z = notebook.get(zStr)
00239         else:
00240             self.z = zStr
00241 
00242 # Parametrized substitute for PointStruct (with 6 parameters)
00243 class PointStructStr6:
00244 
00245     x1 = 0
00246     y1 = 0
00247     z1 = 0
00248     x2 = 0
00249     y2 = 0
00250     z2 = 0
00251     xStr1 = ""
00252     yStr1 = ""
00253     zStr1 = ""
00254     xStr2 = ""
00255     yStr2 = ""
00256     zStr2 = ""
00257 
00258     def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
00259         self.x1Str = x1Str
00260         self.x2Str = x2Str
00261         self.y1Str = y1Str
00262         self.y2Str = y2Str
00263         self.z1Str = z1Str
00264         self.z2Str = z2Str
00265         if isinstance(x1Str, str) and notebook.isVariable(x1Str):
00266             self.x1 = notebook.get(x1Str)
00267         else:
00268             self.x1 = x1Str
00269         if isinstance(x2Str, str) and notebook.isVariable(x2Str):
00270             self.x2 = notebook.get(x2Str)
00271         else:
00272             self.x2 = x2Str
00273         if isinstance(y1Str, str) and notebook.isVariable(y1Str):
00274             self.y1 = notebook.get(y1Str)
00275         else:
00276             self.y1 = y1Str
00277         if isinstance(y2Str, str) and notebook.isVariable(y2Str):
00278             self.y2 = notebook.get(y2Str)
00279         else:
00280             self.y2 = y2Str
00281         if isinstance(z1Str, str) and notebook.isVariable(z1Str):
00282             self.z1 = notebook.get(z1Str)
00283         else:
00284             self.z1 = z1Str
00285         if isinstance(z2Str, str) and notebook.isVariable(z2Str):
00286             self.z2 = notebook.get(z2Str)
00287         else:
00288             self.z2 = z2Str
00289 
00290 # Parametrized substitute for AxisStruct
00291 class AxisStructStr:
00292 
00293     x = 0
00294     y = 0
00295     z = 0
00296     dx = 0
00297     dy = 0
00298     dz = 0
00299     xStr = ""
00300     yStr = ""
00301     zStr = ""
00302     dxStr = ""
00303     dyStr = ""
00304     dzStr = ""
00305 
00306     def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
00307         self.xStr = xStr
00308         self.yStr = yStr
00309         self.zStr = zStr
00310         self.dxStr = dxStr
00311         self.dyStr = dyStr
00312         self.dzStr = dzStr
00313         if isinstance(xStr, str) and notebook.isVariable(xStr):
00314             self.x = notebook.get(xStr)
00315         else:
00316             self.x = xStr
00317         if isinstance(yStr, str) and notebook.isVariable(yStr):
00318             self.y = notebook.get(yStr)
00319         else:
00320             self.y = yStr
00321         if isinstance(zStr, str) and notebook.isVariable(zStr):
00322             self.z = notebook.get(zStr)
00323         else:
00324             self.z = zStr
00325         if isinstance(dxStr, str) and notebook.isVariable(dxStr):
00326             self.dx = notebook.get(dxStr)
00327         else:
00328             self.dx = dxStr
00329         if isinstance(dyStr, str) and notebook.isVariable(dyStr):
00330             self.dy = notebook.get(dyStr)
00331         else:
00332             self.dy = dyStr
00333         if isinstance(dzStr, str) and notebook.isVariable(dzStr):
00334             self.dz = notebook.get(dzStr)
00335         else:
00336             self.dz = dzStr
00337 
00338 # Parametrized substitute for DirStruct
00339 class DirStructStr:
00340 
00341     def __init__(self, pointStruct):
00342         self.pointStruct = pointStruct
00343 
00344 # Returns list of variable values from salome notebook
00345 def ParsePointStruct(Point):
00346     Parameters = 2*var_separator
00347     if isinstance(Point, PointStructStr):
00348         Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
00349         Point = PointStruct(Point.x, Point.y, Point.z)
00350     return Point, Parameters
00351 
00352 # Returns list of variable values from salome notebook
00353 def ParseDirStruct(Dir):
00354     Parameters = 2*var_separator
00355     if isinstance(Dir, DirStructStr):
00356         pntStr = Dir.pointStruct
00357         if isinstance(pntStr, PointStructStr6):
00358             Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
00359             Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
00360             Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
00361             Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
00362         else:
00363             Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
00364             Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
00365         Dir = DirStruct(Point)
00366     return Dir, Parameters
00367 
00368 # Returns list of variable values from salome notebook
00369 def ParseAxisStruct(Axis):
00370     Parameters = 5*var_separator
00371     if isinstance(Axis, AxisStructStr):
00372         Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
00373         Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
00374         Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
00375     return Axis, Parameters
00376 
00377 ## Return list of variable values from salome notebook
00378 def ParseAngles(list):
00379     Result = []
00380     Parameters = ""
00381     for parameter in list:
00382         if isinstance(parameter,str) and notebook.isVariable(parameter):
00383             Result.append(DegreesToRadians(notebook.get(parameter)))
00384             pass
00385         else:
00386             Result.append(parameter)
00387             pass
00388 
00389         Parameters = Parameters + str(parameter)
00390         Parameters = Parameters + var_separator
00391         pass
00392     Parameters = Parameters[:len(Parameters)-1]
00393     return Result, Parameters
00394 
00395 def IsEqual(val1, val2, tol=PrecisionConfusion):
00396     if abs(val1 - val2) < tol:
00397         return True
00398     return False
00399 
00400 NO_NAME = "NoName"
00401 
00402 ## Gets object name
00403 def GetName(obj):
00404     if obj:
00405         # object not null
00406         if isinstance(obj, SALOMEDS._objref_SObject):
00407             # study object
00408             return obj.GetName()
00409         ior  = salome.orb.object_to_string(obj)
00410         if ior:
00411             # CORBA object
00412             studies = salome.myStudyManager.GetOpenStudies()
00413             for sname in studies:
00414                 s = salome.myStudyManager.GetStudyByName(sname)
00415                 if not s: continue
00416                 sobj = s.FindObjectIOR(ior)
00417                 if not sobj: continue
00418                 return sobj.GetName()
00419             if hasattr(obj, "GetName"):
00420                 # unknown CORBA object, having GetName() method
00421                 return obj.GetName()
00422             else:
00423                 # unknown CORBA object, no GetName() method
00424                 return NO_NAME
00425             pass
00426         if hasattr(obj, "GetName"):
00427             # unknown non-CORBA object, having GetName() method
00428             return obj.GetName()
00429         pass
00430     raise RuntimeError, "Null or invalid object"
00431 
00432 ## Prints error message if a hypothesis was not assigned.
00433 def TreatHypoStatus(status, hypName, geomName, isAlgo):
00434     if isAlgo:
00435         hypType = "algorithm"
00436     else:
00437         hypType = "hypothesis"
00438         pass
00439     if status == HYP_UNKNOWN_FATAL :
00440         reason = "for unknown reason"
00441     elif status == HYP_INCOMPATIBLE :
00442         reason = "this hypothesis mismatches the algorithm"
00443     elif status == HYP_NOTCONFORM :
00444         reason = "a non-conform mesh would be built"
00445     elif status == HYP_ALREADY_EXIST :
00446         if isAlgo: return # it does not influence anything
00447         reason = hypType + " of the same dimension is already assigned to this shape"
00448     elif status == HYP_BAD_DIM :
00449         reason = hypType + " mismatches the shape"
00450     elif status == HYP_CONCURENT :
00451         reason = "there are concurrent hypotheses on sub-shapes"
00452     elif status == HYP_BAD_SUBSHAPE :
00453         reason = "the shape is neither the main one, nor its subshape, nor a valid group"
00454     elif status == HYP_BAD_GEOMETRY:
00455         reason = "geometry mismatches the expectation of the algorithm"
00456     elif status == HYP_HIDDEN_ALGO:
00457         reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
00458     elif status == HYP_HIDING_ALGO:
00459         reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
00460     elif status == HYP_NEED_SHAPE:
00461         reason = "Algorithm can't work without shape"
00462     else:
00463         return
00464     hypName = '"' + hypName + '"'
00465     geomName= '"' + geomName+ '"'
00466     if status < HYP_UNKNOWN_FATAL and not geomName =='""':
00467         print hypName, "was assigned to",    geomName,"but", reason
00468     elif not geomName == '""':
00469         print hypName, "was not assigned to",geomName,":", reason
00470     else:
00471         print hypName, "was not assigned:", reason
00472         pass
00473 
00474 ## Check meshing plugin availability
00475 def CheckPlugin(plugin):
00476     if plugin == NETGEN and noNETGENPlugin:
00477         print "Warning: NETGENPlugin module unavailable"
00478         return False
00479     elif plugin == GHS3D and noGHS3DPlugin:
00480         print "Warning: GHS3DPlugin module unavailable"
00481         return False
00482     elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
00483         print "Warning: GHS3DPRLPlugin module unavailable"
00484         return False
00485     elif plugin == Hexotic and noHexoticPlugin:
00486         print "Warning: HexoticPlugin module unavailable"
00487         return False
00488     elif plugin == BLSURF and noBLSURFPlugin:
00489         print "Warning: BLSURFPlugin module unavailable"
00490         return False
00491     return True
00492 
00493 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
00494 def AssureGeomPublished(mesh, geom, name=''):
00495     if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
00496         return
00497     if not geom.IsSame( mesh.geom ) and not geom.GetStudyEntry():
00498         ## set the study
00499         studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
00500         if studyID != mesh.geompyD.myStudyId:
00501             mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
00502         ## get a name
00503         if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
00504             # for all groups SubShapeName() returns "Compound_-1"
00505             name = mesh.geompyD.SubShapeName(geom, mesh.geom)
00506         if not name:
00507             name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
00508         ## publish
00509         mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
00510     return
00511 
00512 # end of l1_auxiliary
00513 ## @}
00514 
00515 # All methods of this class are accessible directly from the smesh.py package.
00516 class smeshDC(SMESH._objref_SMESH_Gen):
00517 
00518     ## Dump component to the Python script
00519     #  This method overrides IDL function to allow default values for the parameters.
00520     def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
00521         return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
00522 
00523     ## Sets the current study and Geometry component
00524     #  @ingroup l1_auxiliary
00525     def init_smesh(self,theStudy,geompyD):
00526         self.SetCurrentStudy(theStudy,geompyD)
00527 
00528     ## Creates an empty Mesh. This mesh can have an underlying geometry.
00529     #  @param obj the Geometrical object on which the mesh is built. If not defined,
00530     #             the mesh will have no underlying geometry.
00531     #  @param name the name for the new mesh.
00532     #  @return an instance of Mesh class.
00533     #  @ingroup l2_construct
00534     def Mesh(self, obj=0, name=0):
00535         if isinstance(obj,str):
00536             obj,name = name,obj
00537         return Mesh(self,self.geompyD,obj,name)
00538 
00539     ## Returns a long value from enumeration
00540     #  Should be used for SMESH.FunctorType enumeration
00541     #  @ingroup l1_controls
00542     def EnumToLong(self,theItem):
00543         return theItem._v
00544 
00545     ## Returns a string representation of the color.
00546     #  To be used with filters.
00547     #  @param c color value (SALOMEDS.Color)
00548     #  @ingroup l1_controls
00549     def ColorToString(self,c):
00550         val = ""
00551         if isinstance(c, SALOMEDS.Color):
00552             val = "%s;%s;%s" % (c.R, c.G, c.B)
00553         elif isinstance(c, str):
00554             val = c
00555         else:
00556             raise ValueError, "Color value should be of string or SALOMEDS.Color type"
00557         return val
00558 
00559     ## Gets PointStruct from vertex
00560     #  @param theVertex a GEOM object(vertex)
00561     #  @return SMESH.PointStruct
00562     #  @ingroup l1_auxiliary
00563     def GetPointStruct(self,theVertex):
00564         [x, y, z] = self.geompyD.PointCoordinates(theVertex)
00565         return PointStruct(x,y,z)
00566 
00567     ## Gets DirStruct from vector
00568     #  @param theVector a GEOM object(vector)
00569     #  @return SMESH.DirStruct
00570     #  @ingroup l1_auxiliary
00571     def GetDirStruct(self,theVector):
00572         vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
00573         if(len(vertices) != 2):
00574             print "Error: vector object is incorrect."
00575             return None
00576         p1 = self.geompyD.PointCoordinates(vertices[0])
00577         p2 = self.geompyD.PointCoordinates(vertices[1])
00578         pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
00579         dirst = DirStruct(pnt)
00580         return dirst
00581 
00582     ## Makes DirStruct from a triplet
00583     #  @param x,y,z vector components
00584     #  @return SMESH.DirStruct
00585     #  @ingroup l1_auxiliary
00586     def MakeDirStruct(self,x,y,z):
00587         pnt = PointStruct(x,y,z)
00588         return DirStruct(pnt)
00589 
00590     ## Get AxisStruct from object
00591     #  @param theObj a GEOM object (line or plane)
00592     #  @return SMESH.AxisStruct
00593     #  @ingroup l1_auxiliary
00594     def GetAxisStruct(self,theObj):
00595         edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
00596         if len(edges) > 1:
00597             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
00598             vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
00599             vertex1 = self.geompyD.PointCoordinates(vertex1)
00600             vertex2 = self.geompyD.PointCoordinates(vertex2)
00601             vertex3 = self.geompyD.PointCoordinates(vertex3)
00602             vertex4 = self.geompyD.PointCoordinates(vertex4)
00603             v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
00604             v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
00605             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] ]
00606             axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
00607             return axis
00608         elif len(edges) == 1:
00609             vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
00610             p1 = self.geompyD.PointCoordinates( vertex1 )
00611             p2 = self.geompyD.PointCoordinates( vertex2 )
00612             axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
00613             return axis
00614         return None
00615 
00616     # From SMESH_Gen interface:
00617     # ------------------------
00618 
00619     ## Sets the given name to the object
00620     #  @param obj the object to rename
00621     #  @param name a new object name
00622     #  @ingroup l1_auxiliary
00623     def SetName(self, obj, name):
00624         if isinstance( obj, Mesh ):
00625             obj = obj.GetMesh()
00626         elif isinstance( obj, Mesh_Algorithm ):
00627             obj = obj.GetAlgorithm()
00628         ior  = salome.orb.object_to_string(obj)
00629         SMESH._objref_SMESH_Gen.SetName(self, ior, name)
00630 
00631     ## Sets the current mode
00632     #  @ingroup l1_auxiliary
00633     def SetEmbeddedMode( self,theMode ):
00634         #self.SetEmbeddedMode(theMode)
00635         SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
00636 
00637     ## Gets the current mode
00638     #  @ingroup l1_auxiliary
00639     def IsEmbeddedMode(self):
00640         #return self.IsEmbeddedMode()
00641         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
00642 
00643     ## Sets the current study
00644     #  @ingroup l1_auxiliary
00645     def SetCurrentStudy( self, theStudy, geompyD = None ):
00646         #self.SetCurrentStudy(theStudy)
00647         if not geompyD:
00648             import geompy
00649             geompyD = geompy.geom
00650             pass
00651         self.geompyD=geompyD
00652         self.SetGeomEngine(geompyD)
00653         SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
00654 
00655     ## Gets the current study
00656     #  @ingroup l1_auxiliary
00657     def GetCurrentStudy(self):
00658         #return self.GetCurrentStudy()
00659         return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
00660 
00661     ## Creates a Mesh object importing data from the given UNV file
00662     #  @return an instance of Mesh class
00663     #  @ingroup l2_impexp
00664     def CreateMeshesFromUNV( self,theFileName ):
00665         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
00666         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
00667         return aMesh
00668 
00669     ## Creates a Mesh object(s) importing data from the given MED file
00670     #  @return a list of Mesh class instances
00671     #  @ingroup l2_impexp
00672     def CreateMeshesFromMED( self,theFileName ):
00673         aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
00674         aMeshes = []
00675         for iMesh in range(len(aSmeshMeshes)) :
00676             aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
00677             aMeshes.append(aMesh)
00678         return aMeshes, aStatus
00679 
00680     ## Creates a Mesh object importing data from the given STL file
00681     #  @return an instance of Mesh class
00682     #  @ingroup l2_impexp
00683     def CreateMeshesFromSTL( self, theFileName ):
00684         aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
00685         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
00686         return aMesh
00687 
00688     ## Concatenate the given meshes into one mesh.
00689     #  @return an instance of Mesh class
00690     #  @param meshes the meshes to combine into one mesh
00691     #  @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
00692     #  @param mergeNodesAndElements if true, equal nodes and elements aremerged
00693     #  @param mergeTolerance tolerance for merging nodes
00694     #  @param allGroups forces creation of groups of all elements
00695     def Concatenate( self, meshes, uniteIdenticalGroups,
00696                      mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
00697         mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
00698         for i,m in enumerate(meshes):
00699             if isinstance(m, Mesh):
00700                 meshes[i] = m.GetMesh()
00701         if allGroups:
00702             aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
00703                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
00704         else:
00705             aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
00706                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
00707         aSmeshMesh.SetParameters(Parameters)
00708         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
00709         return aMesh
00710 
00711     ## Create a mesh by copying a part of another mesh.
00712     #  @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
00713     #                  to copy nodes or elements not contained in any mesh object,
00714     #                  pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
00715     #  @param meshName a name of the new mesh
00716     #  @param toCopyGroups to create in the new mesh groups the copied elements belongs to
00717     #  @param toKeepIDs to preserve IDs of the copied elements or not
00718     #  @return an instance of Mesh class
00719     def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
00720         if (isinstance( meshPart, Mesh )):
00721             meshPart = meshPart.GetMesh()
00722         mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
00723         return Mesh(self, self.geompyD, mesh)
00724 
00725     ## From SMESH_Gen interface
00726     #  @return the list of integer values
00727     #  @ingroup l1_auxiliary
00728     def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
00729         return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
00730 
00731     ## From SMESH_Gen interface. Creates a pattern
00732     #  @return an instance of SMESH_Pattern
00733     #
00734     #  <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
00735     #  @ingroup l2_modif_patterns
00736     def GetPattern(self):
00737         return SMESH._objref_SMESH_Gen.GetPattern(self)
00738 
00739     ## Sets number of segments per diagonal of boundary box of geometry by which
00740     #  default segment length of appropriate 1D hypotheses is defined.
00741     #  Default value is 10
00742     #  @ingroup l1_auxiliary
00743     def SetBoundaryBoxSegmentation(self, nbSegments):
00744         SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
00745 
00746     # Filtering. Auxiliary functions:
00747     # ------------------------------
00748 
00749     ## Creates an empty criterion
00750     #  @return SMESH.Filter.Criterion
00751     #  @ingroup l1_controls
00752     def GetEmptyCriterion(self):
00753         Type = self.EnumToLong(FT_Undefined)
00754         Compare = self.EnumToLong(FT_Undefined)
00755         Threshold = 0
00756         ThresholdStr = ""
00757         ThresholdID = ""
00758         UnaryOp = self.EnumToLong(FT_Undefined)
00759         BinaryOp = self.EnumToLong(FT_Undefined)
00760         Tolerance = 1e-07
00761         TypeOfElement = ALL
00762         Precision = -1 ##@1e-07
00763         return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
00764                                 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
00765 
00766     ## Creates a criterion by the given parameters
00767     #  \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
00768     #  @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
00769     #  @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
00770     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
00771     #  @param Treshold the threshold value (range of ids as string, shape, numeric)
00772     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
00773     #  @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
00774     #                  FT_Undefined (must be for the last criterion of all criteria)
00775     #  @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
00776     #         FT_LyingOnGeom, FT_CoplanarFaces criteria
00777     #  @return SMESH.Filter.Criterion
00778     #
00779     #  <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
00780     #  @ingroup l1_controls
00781     def GetCriterion(self,elementType,
00782                      CritType,
00783                      Compare = FT_EqualTo,
00784                      Treshold="",
00785                      UnaryOp=FT_Undefined,
00786                      BinaryOp=FT_Undefined,
00787                      Tolerance=1e-07):
00788         aCriterion = self.GetEmptyCriterion()
00789         aCriterion.TypeOfElement = elementType
00790         aCriterion.Type = self.EnumToLong(CritType)
00791         aCriterion.Tolerance = Tolerance
00792 
00793         aTreshold = Treshold
00794 
00795         if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
00796             aCriterion.Compare = self.EnumToLong(Compare)
00797         elif Compare == "=" or Compare == "==":
00798             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
00799         elif Compare == "<":
00800             aCriterion.Compare = self.EnumToLong(FT_LessThan)
00801         elif Compare == ">":
00802             aCriterion.Compare = self.EnumToLong(FT_MoreThan)
00803         else:
00804             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
00805             aTreshold = Compare
00806 
00807         if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
00808                         FT_BelongToCylinder, FT_LyingOnGeom]:
00809             # Checks the treshold
00810             if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
00811                 aCriterion.ThresholdStr = GetName(aTreshold)
00812                 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
00813             else:
00814                 print "Error: The treshold should be a shape."
00815                 return None
00816             if isinstance(UnaryOp,float):
00817                 aCriterion.Tolerance = UnaryOp
00818                 UnaryOp = FT_Undefined
00819                 pass
00820         elif CritType == FT_RangeOfIds:
00821             # Checks the treshold
00822             if isinstance(aTreshold, str):
00823                 aCriterion.ThresholdStr = aTreshold
00824             else:
00825                 print "Error: The treshold should be a string."
00826                 return None
00827         elif CritType == FT_CoplanarFaces:
00828             # Checks the treshold
00829             if isinstance(aTreshold, int):
00830                 aCriterion.ThresholdID = "%s"%aTreshold
00831             elif isinstance(aTreshold, str):
00832                 ID = int(aTreshold)
00833                 if ID < 1:
00834                     raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
00835                 aCriterion.ThresholdID = aTreshold
00836             else:
00837                 raise ValueError,\
00838                       "The treshold should be an ID of mesh face and not '%s'"%aTreshold
00839         elif CritType == FT_ElemGeomType:
00840             # Checks the treshold
00841             try:
00842                 aCriterion.Threshold = self.EnumToLong(aTreshold)
00843             except:
00844                 if isinstance(aTreshold, int):
00845                     aCriterion.Threshold = aTreshold
00846                 else:
00847                     print "Error: The treshold should be an integer or SMESH.GeometryType."
00848                     return None
00849                 pass
00850             pass
00851         elif CritType == FT_GroupColor:
00852             # Checks the treshold
00853             try:
00854                 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
00855             except:
00856                 print "Error: The threshold value should be of SALOMEDS.Color type"
00857                 return None
00858             pass
00859         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
00860                           FT_FreeFaces, FT_LinearOrQuadratic,
00861                           FT_BareBorderFace, FT_BareBorderVolume,
00862                           FT_OverConstrainedFace, FT_OverConstrainedVolume]:
00863             # At this point the treshold is unnecessary
00864             if aTreshold ==  FT_LogicalNOT:
00865                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
00866             elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
00867                 aCriterion.BinaryOp = aTreshold
00868         else:
00869             # Check treshold
00870             try:
00871                 aTreshold = float(aTreshold)
00872                 aCriterion.Threshold = aTreshold
00873             except:
00874                 print "Error: The treshold should be a number."
00875                 return None
00876 
00877         if Treshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
00878             aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
00879 
00880         if Treshold in [FT_LogicalAND, FT_LogicalOR]:
00881             aCriterion.BinaryOp = self.EnumToLong(Treshold)
00882 
00883         if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
00884             aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
00885 
00886         if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
00887             aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
00888 
00889         return aCriterion
00890 
00891     ## Creates a filter with the given parameters
00892     #  @param elementType the type of elements in the group
00893     #  @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
00894     #  @param Compare  belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
00895     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
00896     #  @param UnaryOp  FT_LogicalNOT or FT_Undefined
00897     #  @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
00898     #         FT_LyingOnGeom, FT_CoplanarFaces criteria
00899     #  @return SMESH_Filter
00900     #
00901     #  <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
00902     #  @ingroup l1_controls
00903     def GetFilter(self,elementType,
00904                   CritType=FT_Undefined,
00905                   Compare=FT_EqualTo,
00906                   Treshold="",
00907                   UnaryOp=FT_Undefined,
00908                   Tolerance=1e-07):
00909         aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
00910         aFilterMgr = self.CreateFilterManager()
00911         aFilter = aFilterMgr.CreateFilter()
00912         aCriteria = []
00913         aCriteria.append(aCriterion)
00914         aFilter.SetCriteria(aCriteria)
00915         aFilterMgr.UnRegister()
00916         return aFilter
00917 
00918     ## Creates a numerical functor by its type
00919     #  @param theCriterion FT_...; functor type
00920     #  @return SMESH_NumericalFunctor
00921     #  @ingroup l1_controls
00922     def GetFunctor(self,theCriterion):
00923         aFilterMgr = self.CreateFilterManager()
00924         if theCriterion == FT_AspectRatio:
00925             return aFilterMgr.CreateAspectRatio()
00926         elif theCriterion == FT_AspectRatio3D:
00927             return aFilterMgr.CreateAspectRatio3D()
00928         elif theCriterion == FT_Warping:
00929             return aFilterMgr.CreateWarping()
00930         elif theCriterion == FT_MinimumAngle:
00931             return aFilterMgr.CreateMinimumAngle()
00932         elif theCriterion == FT_Taper:
00933             return aFilterMgr.CreateTaper()
00934         elif theCriterion == FT_Skew:
00935             return aFilterMgr.CreateSkew()
00936         elif theCriterion == FT_Area:
00937             return aFilterMgr.CreateArea()
00938         elif theCriterion == FT_Volume3D:
00939             return aFilterMgr.CreateVolume3D()
00940         elif theCriterion == FT_MaxElementLength2D:
00941             return aFilterMgr.CreateMaxElementLength2D()
00942         elif theCriterion == FT_MaxElementLength3D:
00943             return aFilterMgr.CreateMaxElementLength3D()
00944         elif theCriterion == FT_MultiConnection:
00945             return aFilterMgr.CreateMultiConnection()
00946         elif theCriterion == FT_MultiConnection2D:
00947             return aFilterMgr.CreateMultiConnection2D()
00948         elif theCriterion == FT_Length:
00949             return aFilterMgr.CreateLength()
00950         elif theCriterion == FT_Length2D:
00951             return aFilterMgr.CreateLength2D()
00952         else:
00953             print "Error: given parameter is not numerucal functor type."
00954 
00955     ## Creates hypothesis
00956     #  @param theHType mesh hypothesis type (string)
00957     #  @param theLibName mesh plug-in library name
00958     #  @return created hypothesis instance
00959     def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
00960         return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
00961 
00962     ## Gets the mesh stattistic
00963     #  @return dictionary type element - count of elements
00964     #  @ingroup l1_meshinfo
00965     def GetMeshInfo(self, obj):
00966         if isinstance( obj, Mesh ):
00967             obj = obj.GetMesh()
00968         d = {}
00969         if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
00970             values = obj.GetMeshInfo()
00971             for i in range(SMESH.Entity_Last._v):
00972                 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
00973             pass
00974         return d
00975 
00976     ## Get minimum distance between two objects
00977     #
00978     #  If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
00979     #  If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
00980     #
00981     #  @param src1 first source object
00982     #  @param src2 second source object
00983     #  @param id1 node/element id from the first source
00984     #  @param id2 node/element id from the second (or first) source
00985     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
00986     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
00987     #  @return minimum distance value
00988     #  @sa GetMinDistance()
00989     #  @ingroup l1_measurements
00990     def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
00991         result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
00992         if result is None:
00993             result = 0.0
00994         else:
00995             result = result.value
00996         return result
00997 
00998     ## Get measure structure specifying minimum distance data between two objects
00999     #
01000     #  If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
01001     #  If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
01002     #
01003     #  @param src1 first source object
01004     #  @param src2 second source object
01005     #  @param id1 node/element id from the first source
01006     #  @param id2 node/element id from the second (or first) source
01007     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
01008     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
01009     #  @return Measure structure or None if input data is invalid
01010     #  @sa MinDistance()
01011     #  @ingroup l1_measurements
01012     def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
01013         if isinstance(src1, Mesh): src1 = src1.mesh
01014         if isinstance(src2, Mesh): src2 = src2.mesh
01015         if src2 is None and id2 != 0: src2 = src1
01016         if not hasattr(src1, "_narrow"): return None
01017         src1 = src1._narrow(SMESH.SMESH_IDSource)
01018         if not src1: return None
01019         if id1 != 0:
01020             m = src1.GetMesh()
01021             e = m.GetMeshEditor()
01022             if isElem1:
01023                 src1 = e.MakeIDSource([id1], SMESH.FACE)
01024             else:
01025                 src1 = e.MakeIDSource([id1], SMESH.NODE)
01026             pass
01027         if hasattr(src2, "_narrow"):
01028             src2 = src2._narrow(SMESH.SMESH_IDSource)
01029             if src2 and id2 != 0:
01030                 m = src2.GetMesh()
01031                 e = m.GetMeshEditor()
01032                 if isElem2:
01033                     src2 = e.MakeIDSource([id2], SMESH.FACE)
01034                 else:
01035                     src2 = e.MakeIDSource([id2], SMESH.NODE)
01036                 pass
01037             pass
01038         aMeasurements = self.CreateMeasurements()
01039         result = aMeasurements.MinDistance(src1, src2)
01040         aMeasurements.UnRegister()
01041         return result
01042 
01043     ## Get bounding box of the specified object(s)
01044     #  @param objects single source object or list of source objects
01045     #  @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
01046     #  @sa GetBoundingBox()
01047     #  @ingroup l1_measurements
01048     def BoundingBox(self, objects):
01049         result = self.GetBoundingBox(objects)
01050         if result is None:
01051             result = (0.0,)*6
01052         else:
01053             result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
01054         return result
01055 
01056     ## Get measure structure specifying bounding box data of the specified object(s)
01057     #  @param objects single source object or list of source objects
01058     #  @return Measure structure
01059     #  @sa BoundingBox()
01060     #  @ingroup l1_measurements
01061     def GetBoundingBox(self, objects):
01062         if isinstance(objects, tuple):
01063             objects = list(objects)
01064         if not isinstance(objects, list):
01065             objects = [objects]
01066         srclist = []
01067         for o in objects:
01068             if isinstance(o, Mesh):
01069                 srclist.append(o.mesh)
01070             elif hasattr(o, "_narrow"):
01071                 src = o._narrow(SMESH.SMESH_IDSource)
01072                 if src: srclist.append(src)
01073                 pass
01074             pass
01075         aMeasurements = self.CreateMeasurements()
01076         result = aMeasurements.BoundingBox(srclist)
01077         aMeasurements.UnRegister()
01078         return result
01079 
01080 import omniORB
01081 #Registering the new proxy for SMESH_Gen
01082 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
01083 
01084 
01085 # Public class: Mesh
01086 # ==================
01087 
01088 ## This class allows defining and managing a mesh.
01089 #  It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
01090 #  It also has methods to define groups of mesh elements, to modify a mesh (by addition of
01091 #  new nodes and elements and by changing the existing entities), to get information
01092 #  about a mesh and to export a mesh into different formats.
01093 class Mesh:
01094 
01095     geom = 0
01096     mesh = 0
01097     editor = 0
01098 
01099     ## Constructor
01100     #
01101     #  Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
01102     #  sets the GUI name of this mesh to \a name.
01103     #  @param smeshpyD an instance of smeshDC class
01104     #  @param geompyD an instance of geompyDC class
01105     #  @param obj Shape to be meshed or SMESH_Mesh object
01106     #  @param name Study name of the mesh
01107     #  @ingroup l2_construct
01108     def __init__(self, smeshpyD, geompyD, obj=0, name=0):
01109         self.smeshpyD=smeshpyD
01110         self.geompyD=geompyD
01111         if obj is None:
01112             obj = 0
01113         if obj != 0:
01114             if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
01115                 self.geom = obj
01116                 # publish geom of mesh (issue 0021122)
01117                 if not self.geom.GetStudyEntry():
01118                     studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
01119                     if studyID != geompyD.myStudyId:
01120                         geompyD.init_geom( smeshpyD.GetCurrentStudy())
01121                         pass
01122                     geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
01123                     geompyD.addToStudy( self.geom, geo_name )
01124                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
01125 
01126             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
01127                 self.SetMesh(obj)
01128         else:
01129             self.mesh = self.smeshpyD.CreateEmptyMesh()
01130         if name != 0:
01131             self.smeshpyD.SetName(self.mesh, name)
01132         elif obj != 0:
01133             self.smeshpyD.SetName(self.mesh, GetName(obj))
01134 
01135         if not self.geom:
01136             self.geom = self.mesh.GetShapeToMesh()
01137 
01138         self.editor = self.mesh.GetMeshEditor()
01139 
01140     ## Initializes the Mesh object from an instance of SMESH_Mesh interface
01141     #  @param theMesh a SMESH_Mesh object
01142     #  @ingroup l2_construct
01143     def SetMesh(self, theMesh):
01144         self.mesh = theMesh
01145         self.geom = self.mesh.GetShapeToMesh()
01146 
01147     ## Returns the mesh, that is an instance of SMESH_Mesh interface
01148     #  @return a SMESH_Mesh object
01149     #  @ingroup l2_construct
01150     def GetMesh(self):
01151         return self.mesh
01152 
01153     ## Gets the name of the mesh
01154     #  @return the name of the mesh as a string
01155     #  @ingroup l2_construct
01156     def GetName(self):
01157         name = GetName(self.GetMesh())
01158         return name
01159 
01160     ## Sets a name to the mesh
01161     #  @param name a new name of the mesh
01162     #  @ingroup l2_construct
01163     def SetName(self, name):
01164         self.smeshpyD.SetName(self.GetMesh(), name)
01165 
01166     ## Gets the subMesh object associated to a \a theSubObject geometrical object.
01167     #  The subMesh object gives access to the IDs of nodes and elements.
01168     #  @param geom a geometrical object (shape)
01169     #  @param name a name for the submesh
01170     #  @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
01171     #  @ingroup l2_submeshes
01172     def GetSubMesh(self, geom, name):
01173         AssureGeomPublished( self, geom, name )
01174         submesh = self.mesh.GetSubMesh( geom, name )
01175         return submesh
01176 
01177     ## Returns the shape associated to the mesh
01178     #  @return a GEOM_Object
01179     #  @ingroup l2_construct
01180     def GetShape(self):
01181         return self.geom
01182 
01183     ## Associates the given shape to the mesh (entails the recreation of the mesh)
01184     #  @param geom the shape to be meshed (GEOM_Object)
01185     #  @ingroup l2_construct
01186     def SetShape(self, geom):
01187         self.mesh = self.smeshpyD.CreateMesh(geom)
01188 
01189     ## Returns true if the hypotheses are defined well
01190     #  @param theSubObject a subshape of a mesh shape
01191     #  @return True or False
01192     #  @ingroup l2_construct
01193     def IsReadyToCompute(self, theSubObject):
01194         return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
01195 
01196     ## Returns errors of hypotheses definition.
01197     #  The list of errors is empty if everything is OK.
01198     #  @param theSubObject a subshape of a mesh shape
01199     #  @return a list of errors
01200     #  @ingroup l2_construct
01201     def GetAlgoState(self, theSubObject):
01202         return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
01203 
01204     ## Returns a geometrical object on which the given element was built.
01205     #  The returned geometrical object, if not nil, is either found in the
01206     #  study or published by this method with the given name
01207     #  @param theElementID the id of the mesh element
01208     #  @param theGeomName the user-defined name of the geometrical object
01209     #  @return GEOM::GEOM_Object instance
01210     #  @ingroup l2_construct
01211     def GetGeometryByMeshElement(self, theElementID, theGeomName):
01212         return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
01213 
01214     ## Returns the mesh dimension depending on the dimension of the underlying shape
01215     #  @return mesh dimension as an integer value [0,3]
01216     #  @ingroup l1_auxiliary
01217     def MeshDimension(self):
01218         shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
01219         if len( shells ) > 0 :
01220             return 3
01221         elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
01222             return 2
01223         elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
01224             return 1
01225         else:
01226             return 0;
01227         pass
01228 
01229     ## Creates a segment discretization 1D algorithm.
01230     #  If the optional \a algo parameter is not set, this algorithm is REGULAR.
01231     #  \n If the optional \a geom parameter is not set, this algorithm is global.
01232     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
01233     #  @param algo the type of the required algorithm. Possible values are:
01234     #     - smesh.REGULAR,
01235     #     - smesh.PYTHON for discretization via a python function,
01236     #     - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
01237     #  @param geom If defined is the subshape to be meshed
01238     #  @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
01239     #  @ingroup l3_algos_basic
01240     def Segment(self, algo=REGULAR, geom=0):
01241         ## if Segment(geom) is called by mistake
01242         if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
01243             algo, geom = geom, algo
01244             if not algo: algo = REGULAR
01245             pass
01246         if algo == REGULAR:
01247             return Mesh_Segment(self,  geom)
01248         elif algo == PYTHON:
01249             return Mesh_Segment_Python(self, geom)
01250         elif algo == COMPOSITE:
01251             return Mesh_CompositeSegment(self, geom)
01252         else:
01253             return Mesh_Segment(self, geom)
01254 
01255     ## Creates 1D algorithm importing segments conatined in groups of other mesh.
01256     #  If the optional \a geom parameter is not set, this algorithm is global.
01257     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
01258     #  @param geom If defined the subshape is to be meshed
01259     #  @return an instance of Mesh_UseExistingElements class
01260     #  @ingroup l3_algos_basic
01261     def UseExisting1DElements(self, geom=0):
01262         return Mesh_UseExistingElements(1,self, geom)
01263 
01264     ## Creates 2D algorithm importing faces conatined in groups of other mesh.
01265     #  If the optional \a geom parameter is not set, this algorithm is global.
01266     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
01267     #  @param geom If defined the subshape is to be meshed
01268     #  @return an instance of Mesh_UseExistingElements class
01269     #  @ingroup l3_algos_basic
01270     def UseExisting2DElements(self, geom=0):
01271         return Mesh_UseExistingElements(2,self, geom)
01272 
01273     ## Enables creation of nodes and segments usable by 2D algoritms.
01274     #  The added nodes and segments must be bound to edges and vertices by
01275     #  SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
01276     #  If the optional \a geom parameter is not set, this algorithm is global.
01277     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
01278     #  @param geom the subshape to be manually meshed
01279     #  @return StdMeshers_UseExisting_1D algorithm that generates nothing
01280     #  @ingroup l3_algos_basic
01281     def UseExistingSegments(self, geom=0):
01282         algo = Mesh_UseExisting(1,self,geom)
01283         return algo.GetAlgorithm()
01284 
01285     ## Enables creation of nodes and faces usable by 3D algoritms.
01286     #  The added nodes and faces must be bound to geom faces by SetNodeOnFace()
01287     #  and SetMeshElementOnShape()
01288     #  If the optional \a geom parameter is not set, this algorithm is global.
01289     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
01290     #  @param geom the subshape to be manually meshed
01291     #  @return StdMeshers_UseExisting_2D algorithm that generates nothing
01292     #  @ingroup l3_algos_basic
01293     def UseExistingFaces(self, geom=0):
01294         algo = Mesh_UseExisting(2,self,geom)
01295         return algo.GetAlgorithm()
01296 
01297     ## Creates a triangle 2D algorithm for faces.
01298     #  If the optional \a geom parameter is not set, this algorithm is global.
01299     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
01300     #  @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
01301     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
01302     #  @return an instance of Mesh_Triangle algorithm
01303     #  @ingroup l3_algos_basic
01304     def Triangle(self, algo=MEFISTO, geom=0):
01305         ## if Triangle(geom) is called by mistake
01306         if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
01307             geom = algo
01308             algo = MEFISTO
01309         return Mesh_Triangle(self, algo, geom)
01310 
01311     ## Creates a quadrangle 2D algorithm for faces.
01312     #  If the optional \a geom parameter is not set, this algorithm is global.
01313     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
01314     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
01315     #  @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
01316     #  @return an instance of Mesh_Quadrangle algorithm
01317     #  @ingroup l3_algos_basic
01318     def Quadrangle(self, geom=0, algo=QUADRANGLE):
01319         if algo==RADIAL_QUAD:
01320             return Mesh_RadialQuadrangle1D2D(self,geom)
01321         else:
01322             return Mesh_Quadrangle(self, geom)
01323 
01324     ## Creates a tetrahedron 3D algorithm for solids.
01325     #  The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
01326     #  If the optional \a geom parameter is not set, this algorithm is global.
01327     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
01328     #  @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
01329     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
01330     #  @return an instance of Mesh_Tetrahedron algorithm
01331     #  @ingroup l3_algos_basic
01332     def Tetrahedron(self, algo=NETGEN, geom=0):
01333         ## if Tetrahedron(geom) is called by mistake
01334         if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
01335             algo, geom = geom, algo
01336             if not algo: algo = NETGEN
01337             pass
01338         return Mesh_Tetrahedron(self,  algo, geom)
01339 
01340     ## Creates a hexahedron 3D algorithm for solids.
01341     #  If the optional \a geom parameter is not set, this algorithm is global.
01342     #  \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
01343     #  @param algo possible values are: smesh.Hexa, smesh.Hexotic
01344     #  @param geom If defined, the subshape to be meshed (GEOM_Object)
01345     #  @return an instance of Mesh_Hexahedron algorithm
01346     #  @ingroup l3_algos_basic
01347     def Hexahedron(self, algo=Hexa, geom=0):
01348         ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
01349         if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
01350             if   geom in [Hexa, Hexotic]: algo, geom = geom, algo
01351             elif geom == 0:               algo, geom = Hexa, algo
01352         return Mesh_Hexahedron(self, algo, geom)
01353 
01354     ## Deprecated, used only for compatibility!
01355     #  @return an instance of Mesh_Netgen algorithm
01356     #  @ingroup l3_algos_basic
01357     def Netgen(self, is3D, geom=0):
01358         return Mesh_Netgen(self,  is3D, geom)
01359 
01360     ## Creates a projection 1D algorithm for edges.
01361     #  If the optional \a geom parameter is not set, this algorithm is global.
01362     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
01363     #  @param geom If defined, the subshape to be meshed
01364     #  @return an instance of Mesh_Projection1D algorithm
01365     #  @ingroup l3_algos_proj
01366     def Projection1D(self, geom=0):
01367         return Mesh_Projection1D(self,  geom)
01368 
01369     ## Creates a projection 2D algorithm for faces.
01370     #  If the optional \a geom parameter is not set, this algorithm is global.
01371     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
01372     #  @param geom If defined, the subshape to be meshed
01373     #  @return an instance of Mesh_Projection2D algorithm
01374     #  @ingroup l3_algos_proj
01375     def Projection2D(self, geom=0):
01376         return Mesh_Projection2D(self,  geom)
01377 
01378     ## Creates a projection 3D algorithm for solids.
01379     #  If the optional \a geom parameter is not set, this algorithm is global.
01380     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
01381     #  @param geom If defined, the subshape to be meshed
01382     #  @return an instance of Mesh_Projection3D algorithm
01383     #  @ingroup l3_algos_proj
01384     def Projection3D(self, geom=0):
01385         return Mesh_Projection3D(self,  geom)
01386 
01387     ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
01388     #  If the optional \a geom parameter is not set, this algorithm is global.
01389     #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
01390     #  @param geom If defined, the subshape to be meshed
01391     #  @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
01392     #  @ingroup l3_algos_radialp l3_algos_3dextr
01393     def Prism(self, geom=0):
01394         shape = geom
01395         if shape==0:
01396             shape = self.geom
01397         nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
01398         nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
01399         if nbSolids == 0 or nbSolids == nbShells:
01400             return Mesh_Prism3D(self,  geom)
01401         return Mesh_RadialPrism3D(self,  geom)
01402 
01403     ## Evaluates size of prospective mesh on a shape
01404     #  @return a list where i-th element is a number of elements of i-th SMESH.EntityType
01405     #  To know predicted number of e.g. edges, inquire it this way
01406     #  Evaluate()[ EnumToLong( Entity_Edge )]
01407     def Evaluate(self, geom=0):
01408         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
01409             if self.geom == 0:
01410                 geom = self.mesh.GetShapeToMesh()
01411             else:
01412                 geom = self.geom
01413         return self.smeshpyD.Evaluate(self.mesh, geom)
01414 
01415 
01416     ## Computes the mesh and returns the status of the computation
01417     #  @param geom geomtrical shape on which mesh data should be computed
01418     #  @param discardModifs if True and the mesh has been edited since
01419     #         a last total re-compute and that may prevent successful partial re-compute,
01420     #         then the mesh is cleaned before Compute()
01421     #  @return True or False
01422     #  @ingroup l2_construct
01423     def Compute(self, geom=0, discardModifs=False):
01424         if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
01425             if self.geom == 0:
01426                 geom = self.mesh.GetShapeToMesh()
01427             else:
01428                 geom = self.geom
01429         ok = False
01430         try:
01431             if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
01432                 self.mesh.Clear()
01433             ok = self.smeshpyD.Compute(self.mesh, geom)
01434         except SALOME.SALOME_Exception, ex:
01435             print "Mesh computation failed, exception caught:"
01436             print "    ", ex.details.text
01437         except:
01438             import traceback
01439             print "Mesh computation failed, exception caught:"
01440             traceback.print_exc()
01441         if True:#not ok:
01442             allReasons = ""
01443 
01444             # Treat compute errors
01445             computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
01446             for err in computeErrors:
01447                 shapeText = ""
01448                 if self.mesh.HasShapeToMesh():
01449                     try:
01450                         mainIOR  = salome.orb.object_to_string(geom)
01451                         for sname in salome.myStudyManager.GetOpenStudies():
01452                             s = salome.myStudyManager.GetStudyByName(sname)
01453                             if not s: continue
01454                             mainSO = s.FindObjectIOR(mainIOR)
01455                             if not mainSO: continue
01456                             if err.subShapeID == 1:
01457                                 shapeText = ' on "%s"' % mainSO.GetName()
01458                             subIt = s.NewChildIterator(mainSO)
01459                             while subIt.More():
01460                                 subSO = subIt.Value()
01461                                 subIt.Next()
01462                                 obj = subSO.GetObject()
01463                                 if not obj: continue
01464                                 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
01465                                 if not go: continue
01466                                 ids = go.GetSubShapeIndices()
01467                                 if len(ids) == 1 and ids[0] == err.subShapeID:
01468                                     shapeText = ' on "%s"' % subSO.GetName()
01469                                     break
01470                         if not shapeText:
01471                             shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
01472                             if shape:
01473                                 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
01474                             else:
01475                                 shapeText = " on subshape #%s" % (err.subShapeID)
01476                     except:
01477                         shapeText = " on subshape #%s" % (err.subShapeID)
01478                 errText = ""
01479                 stdErrors = ["OK",                 #COMPERR_OK
01480                              "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
01481                              "std::exception",     #COMPERR_STD_EXCEPTION
01482                              "OCC exception",      #COMPERR_OCC_EXCEPTION
01483                              "SALOME exception",   #COMPERR_SLM_EXCEPTION
01484                              "Unknown exception",  #COMPERR_EXCEPTION
01485                              "Memory allocation problem", #COMPERR_MEMORY_PB
01486                              "Algorithm failed",   #COMPERR_ALGO_FAILED
01487                              "Unexpected geometry"]#COMPERR_BAD_SHAPE
01488                 if err.code > 0:
01489                     if err.code < len(stdErrors): errText = stdErrors[err.code]
01490                 else:
01491                     errText = "code %s" % -err.code
01492                 if errText: errText += ". "
01493                 errText += err.comment
01494                 if allReasons != "":allReasons += "\n"
01495                 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
01496                 pass
01497 
01498             # Treat hyp errors
01499             errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
01500             for err in errors:
01501                 if err.isGlobalAlgo:
01502                     glob = "global"
01503                 else:
01504                     glob = "local"
01505                     pass
01506                 dim = err.algoDim
01507                 name = err.algoName
01508                 if len(name) == 0:
01509                     reason = '%s %sD algorithm is missing' % (glob, dim)
01510                 elif err.state == HYP_MISSING:
01511                     reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
01512                               % (glob, dim, name, dim))
01513                 elif err.state == HYP_NOTCONFORM:
01514                     reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
01515                 elif err.state == HYP_BAD_PARAMETER:
01516                     reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
01517                               % ( glob, dim, name ))
01518                 elif err.state == HYP_BAD_GEOMETRY:
01519                     reason = ('%s %sD algorithm "%s" is assigned to mismatching'
01520                               'geometry' % ( glob, dim, name ))
01521                 else:
01522                     reason = "For unknown reason."+\
01523                              " Revise Mesh.Compute() implementation in smeshDC.py!"
01524                     pass
01525                 if allReasons != "":allReasons += "\n"
01526                 allReasons += reason
01527                 pass
01528             if allReasons != "":
01529                 print '"' + GetName(self.mesh) + '"',"has not been computed:"
01530                 print allReasons
01531                 ok = False
01532             elif not ok:
01533                 print '"' + GetName(self.mesh) + '"',"has not been computed."
01534                 pass
01535             pass
01536         if salome.sg.hasDesktop():
01537             smeshgui = salome.ImportComponentGUI("SMESH")
01538             smeshgui.Init(self.mesh.GetStudyId())
01539             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
01540             salome.sg.updateObjBrowser(1)
01541             pass
01542         return ok
01543 
01544     ## Return submesh objects list in meshing order
01545     #  @return list of list of submesh objects
01546     #  @ingroup l2_construct
01547     def GetMeshOrder(self):
01548         return self.mesh.GetMeshOrder()
01549 
01550     ## Return submesh objects list in meshing order
01551     #  @return list of list of submesh objects
01552     #  @ingroup l2_construct
01553     def SetMeshOrder(self, submeshes):
01554         return self.mesh.SetMeshOrder(submeshes)
01555 
01556     ## Removes all nodes and elements
01557     #  @ingroup l2_construct
01558     def Clear(self):
01559         self.mesh.Clear()
01560         if salome.sg.hasDesktop():
01561             smeshgui = salome.ImportComponentGUI("SMESH")
01562             smeshgui.Init(self.mesh.GetStudyId())
01563             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
01564             salome.sg.updateObjBrowser(1)
01565 
01566     ## Removes all nodes and elements of indicated shape
01567     #  @ingroup l2_construct
01568     def ClearSubMesh(self, geomId):
01569         self.mesh.ClearSubMesh(geomId)
01570         if salome.sg.hasDesktop():
01571             smeshgui = salome.ImportComponentGUI("SMESH")
01572             smeshgui.Init(self.mesh.GetStudyId())
01573             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
01574             salome.sg.updateObjBrowser(1)
01575 
01576     ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
01577     #  @param fineness [0.0,1.0] defines mesh fineness
01578     #  @return True or False
01579     #  @ingroup l3_algos_basic
01580     def AutomaticTetrahedralization(self, fineness=0):
01581         dim = self.MeshDimension()
01582         # assign hypotheses
01583         self.RemoveGlobalHypotheses()
01584         self.Segment().AutomaticLength(fineness)
01585         if dim > 1 :
01586             self.Triangle().LengthFromEdges()
01587             pass
01588         if dim > 2 :
01589             self.Tetrahedron(NETGEN)
01590             pass
01591         return self.Compute()
01592 
01593     ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
01594     #  @param fineness [0.0, 1.0] defines mesh fineness
01595     #  @return True or False
01596     #  @ingroup l3_algos_basic
01597     def AutomaticHexahedralization(self, fineness=0):
01598         dim = self.MeshDimension()
01599         # assign the hypotheses
01600         self.RemoveGlobalHypotheses()
01601         self.Segment().AutomaticLength(fineness)
01602         if dim > 1 :
01603             self.Quadrangle()
01604             pass
01605         if dim > 2 :
01606             self.Hexahedron()
01607             pass
01608         return self.Compute()
01609 
01610     ## Assigns a hypothesis
01611     #  @param hyp a hypothesis to assign
01612     #  @param geom a subhape of mesh geometry
01613     #  @return SMESH.Hypothesis_Status
01614     #  @ingroup l2_hypotheses
01615     def AddHypothesis(self, hyp, geom=0):
01616         if isinstance( hyp, Mesh_Algorithm ):
01617             hyp = hyp.GetAlgorithm()
01618             pass
01619         if not geom:
01620             geom = self.geom
01621             if not geom:
01622                 geom = self.mesh.GetShapeToMesh()
01623             pass
01624         status = self.mesh.AddHypothesis(geom, hyp)
01625         isAlgo = hyp._narrow( SMESH_Algo )
01626         hyp_name = GetName( hyp )
01627         geom_name = ""
01628         if geom:
01629             geom_name = GetName( geom )
01630         TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
01631         return status
01632 
01633     ## Unassigns a hypothesis
01634     #  @param hyp a hypothesis to unassign
01635     #  @param geom a subshape of mesh geometry
01636     #  @return SMESH.Hypothesis_Status
01637     #  @ingroup l2_hypotheses
01638     def RemoveHypothesis(self, hyp, geom=0):
01639         if isinstance( hyp, Mesh_Algorithm ):
01640             hyp = hyp.GetAlgorithm()
01641             pass
01642         if not geom:
01643             geom = self.geom
01644             pass
01645         status = self.mesh.RemoveHypothesis(geom, hyp)
01646         return status
01647 
01648     ## Gets the list of hypotheses added on a geometry
01649     #  @param geom a subshape of mesh geometry
01650     #  @return the sequence of SMESH_Hypothesis
01651     #  @ingroup l2_hypotheses
01652     def GetHypothesisList(self, geom):
01653         return self.mesh.GetHypothesisList( geom )
01654 
01655     ## Removes all global hypotheses
01656     #  @ingroup l2_hypotheses
01657     def RemoveGlobalHypotheses(self):
01658         current_hyps = self.mesh.GetHypothesisList( self.geom )
01659         for hyp in current_hyps:
01660             self.mesh.RemoveHypothesis( self.geom, hyp )
01661             pass
01662         pass
01663 
01664     ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
01665     #  Exports the mesh in a file in MED format and chooses the \a version of MED format
01666     ## allowing to overwrite the file if it exists or add the exported data to its contents
01667     #  @param f the file name
01668     #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
01669     #  @param opt boolean parameter for creating/not creating
01670     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ...
01671     #  @param overwrite boolean parameter for overwriting/not overwriting the file
01672     #  @ingroup l2_impexp
01673     def ExportToMED(self, f, version, opt=0, overwrite=1):
01674         self.mesh.ExportToMEDX(f, opt, version, overwrite)
01675 
01676     ## Exports the mesh in a file in MED format and chooses the \a version of MED format
01677     ## allowing to overwrite the file if it exists or add the exported data to its contents
01678     #  @param f is the file name
01679     #  @param auto_groups boolean parameter for creating/not creating
01680     #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
01681     #  the typical use is auto_groups=false.
01682     #  @param version MED format version(MED_V2_1 or MED_V2_2)
01683     #  @param overwrite boolean parameter for overwriting/not overwriting the file
01684     #  @ingroup l2_impexp
01685     def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
01686         self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
01687 
01688     ## Exports the mesh in a file in DAT format
01689     #  @param f the file name
01690     #  @ingroup l2_impexp
01691     def ExportDAT(self, f):
01692         self.mesh.ExportDAT(f)
01693 
01694     ## Exports the mesh in a file in UNV format
01695     #  @param f the file name
01696     #  @ingroup l2_impexp
01697     def ExportUNV(self, f):
01698         self.mesh.ExportUNV(f)
01699 
01700     ## Export the mesh in a file in STL format
01701     #  @param f the file name
01702     #  @param ascii defines the file encoding
01703     #  @ingroup l2_impexp
01704     def ExportSTL(self, f, ascii=1):
01705         self.mesh.ExportSTL(f, ascii)
01706 
01707 
01708     # Operations with groups:
01709     # ----------------------
01710 
01711     ## Creates an empty mesh group
01712     #  @param elementType the type of elements in the group
01713     #  @param name the name of the mesh group
01714     #  @return SMESH_Group
01715     #  @ingroup l2_grps_create
01716     def CreateEmptyGroup(self, elementType, name):
01717         return self.mesh.CreateGroup(elementType, name)
01718 
01719     ## Creates a mesh group based on the geometric object \a grp
01720     #  and gives a \a name, \n if this parameter is not defined
01721     #  the name is the same as the geometric group name \n
01722     #  Note: Works like GroupOnGeom().
01723     #  @param grp  a geometric group, a vertex, an edge, a face or a solid
01724     #  @param name the name of the mesh group
01725     #  @return SMESH_GroupOnGeom
01726     #  @ingroup l2_grps_create
01727     def Group(self, grp, name=""):
01728         return self.GroupOnGeom(grp, name)
01729 
01730     ## Creates a mesh group based on the geometrical object \a grp
01731     #  and gives a \a name, \n if this parameter is not defined
01732     #  the name is the same as the geometrical group name
01733     #  @param grp  a geometrical group, a vertex, an edge, a face or a solid
01734     #  @param name the name of the mesh group
01735     #  @param typ  the type of elements in the group. If not set, it is
01736     #              automatically detected by the type of the geometry
01737     #  @return SMESH_GroupOnGeom
01738     #  @ingroup l2_grps_create
01739     def GroupOnGeom(self, grp, name="", typ=None):
01740         AssureGeomPublished( self, grp, name )
01741         if name == "":
01742             name = grp.GetName()
01743         if not typ:
01744             typ = self._groupTypeFromShape( grp )
01745         return self.mesh.CreateGroupFromGEOM(typ, name, grp)
01746 
01747     ## Pivate method to get a type of group on geometry
01748     def _groupTypeFromShape( self, shape ):
01749         tgeo = str(shape.GetShapeType())
01750         if tgeo == "VERTEX":
01751             typ = NODE
01752         elif tgeo == "EDGE":
01753             typ = EDGE
01754         elif tgeo == "FACE" or tgeo == "SHELL":
01755             typ = FACE
01756         elif tgeo == "SOLID" or tgeo == "COMPSOLID":
01757             typ = VOLUME
01758         elif tgeo == "COMPOUND":
01759             sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
01760             if not sub:
01761                 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
01762             return self._groupTypeFromShape( sub[0] )
01763         else:
01764             raise ValueError, \
01765                   "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
01766         return typ
01767 
01768     ## Creates a mesh group by the given ids of elements
01769     #  @param groupName the name of the mesh group
01770     #  @param elementType the type of elements in the group
01771     #  @param elemIDs the list of ids
01772     #  @return SMESH_Group
01773     #  @ingroup l2_grps_create
01774     def MakeGroupByIds(self, groupName, elementType, elemIDs):
01775         group = self.mesh.CreateGroup(elementType, groupName)
01776         group.Add(elemIDs)
01777         return group
01778 
01779     ## Creates a mesh group by the given conditions
01780     #  @param groupName the name of the mesh group
01781     #  @param elementType the type of elements in the group
01782     #  @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
01783     #  @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
01784     #  @param Treshold the threshold value (range of id ids as string, shape, numeric)
01785     #  @param UnaryOp FT_LogicalNOT or FT_Undefined
01786     #  @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
01787     #         FT_LyingOnGeom, FT_CoplanarFaces criteria
01788     #  @return SMESH_Group
01789     #  @ingroup l2_grps_create
01790     def MakeGroup(self,
01791                   groupName,
01792                   elementType,
01793                   CritType=FT_Undefined,
01794                   Compare=FT_EqualTo,
01795                   Treshold="",
01796                   UnaryOp=FT_Undefined,
01797                   Tolerance=1e-07):
01798         aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
01799         group = self.MakeGroupByCriterion(groupName, aCriterion)
01800         return group
01801 
01802     ## Creates a mesh group by the given criterion
01803     #  @param groupName the name of the mesh group
01804     #  @param Criterion the instance of Criterion class
01805     #  @return SMESH_Group
01806     #  @ingroup l2_grps_create
01807     def MakeGroupByCriterion(self, groupName, Criterion):
01808         aFilterMgr = self.smeshpyD.CreateFilterManager()
01809         aFilter = aFilterMgr.CreateFilter()
01810         aCriteria = []
01811         aCriteria.append(Criterion)
01812         aFilter.SetCriteria(aCriteria)
01813         group = self.MakeGroupByFilter(groupName, aFilter)
01814         aFilterMgr.UnRegister()
01815         return group
01816 
01817     ## Creates a mesh group by the given criteria (list of criteria)
01818     #  @param groupName the name of the mesh group
01819     #  @param theCriteria the list of criteria
01820     #  @return SMESH_Group
01821     #  @ingroup l2_grps_create
01822     def MakeGroupByCriteria(self, groupName, theCriteria):
01823         aFilterMgr = self.smeshpyD.CreateFilterManager()
01824         aFilter = aFilterMgr.CreateFilter()
01825         aFilter.SetCriteria(theCriteria)
01826         group = self.MakeGroupByFilter(groupName, aFilter)
01827         aFilterMgr.UnRegister()
01828         return group
01829 
01830     ## Creates a mesh group by the given filter
01831     #  @param groupName the name of the mesh group
01832     #  @param theFilter the instance of Filter class
01833     #  @return SMESH_Group
01834     #  @ingroup l2_grps_create
01835     def MakeGroupByFilter(self, groupName, theFilter):
01836         group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
01837         theFilter.SetMesh( self.mesh )
01838         group.AddFrom( theFilter )
01839         return group
01840 
01841     ## Passes mesh elements through the given filter and return IDs of fitting elements
01842     #  @param theFilter SMESH_Filter
01843     #  @return a list of ids
01844     #  @ingroup l1_controls
01845     def GetIdsFromFilter(self, theFilter):
01846         theFilter.SetMesh( self.mesh )
01847         return theFilter.GetIDs()
01848 
01849     ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
01850     #  Returns a list of special structures (borders).
01851     #  @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
01852     #  @ingroup l1_controls
01853     def GetFreeBorders(self):
01854         aFilterMgr = self.smeshpyD.CreateFilterManager()
01855         aPredicate = aFilterMgr.CreateFreeEdges()
01856         aPredicate.SetMesh(self.mesh)
01857         aBorders = aPredicate.GetBorders()
01858         aFilterMgr.UnRegister()
01859         return aBorders
01860 
01861     ## Removes a group
01862     #  @ingroup l2_grps_delete
01863     def RemoveGroup(self, group):
01864         self.mesh.RemoveGroup(group)
01865 
01866     ## Removes a group with its contents
01867     #  @ingroup l2_grps_delete
01868     def RemoveGroupWithContents(self, group):
01869         self.mesh.RemoveGroupWithContents(group)
01870 
01871     ## Gets the list of groups existing in the mesh
01872     #  @return a sequence of SMESH_GroupBase
01873     #  @ingroup l2_grps_create
01874     def GetGroups(self):
01875         return self.mesh.GetGroups()
01876 
01877     ## Gets the number of groups existing in the mesh
01878     #  @return the quantity of groups as an integer value
01879     #  @ingroup l2_grps_create
01880     def NbGroups(self):
01881         return self.mesh.NbGroups()
01882 
01883     ## Gets the list of names of groups existing in the mesh
01884     #  @return list of strings
01885     #  @ingroup l2_grps_create
01886     def GetGroupNames(self):
01887         groups = self.GetGroups()
01888         names = []
01889         for group in groups:
01890             names.append(group.GetName())
01891         return names
01892 
01893     ## Produces a union of two groups
01894     #  A new group is created. All mesh elements that are
01895     #  present in the initial groups are added to the new one
01896     #  @return an instance of SMESH_Group
01897     #  @ingroup l2_grps_operon
01898     def UnionGroups(self, group1, group2, name):
01899         return self.mesh.UnionGroups(group1, group2, name)
01900 
01901     ## Produces a union list of groups
01902     #  New group is created. All mesh elements that are present in
01903     #  initial groups are added to the new one
01904     #  @return an instance of SMESH_Group
01905     #  @ingroup l2_grps_operon
01906     def UnionListOfGroups(self, groups, name):
01907       return self.mesh.UnionListOfGroups(groups, name)
01908 
01909     ## Prodices an intersection of two groups
01910     #  A new group is created. All mesh elements that are common
01911     #  for the two initial groups are added to the new one.
01912     #  @return an instance of SMESH_Group
01913     #  @ingroup l2_grps_operon
01914     def IntersectGroups(self, group1, group2, name):
01915         return self.mesh.IntersectGroups(group1, group2, name)
01916 
01917     ## Produces an intersection of groups
01918     #  New group is created. All mesh elements that are present in all
01919     #  initial groups simultaneously are added to the new one
01920     #  @return an instance of SMESH_Group
01921     #  @ingroup l2_grps_operon
01922     def IntersectListOfGroups(self, groups, name):
01923       return self.mesh.IntersectListOfGroups(groups, name)
01924 
01925     ## Produces a cut of two groups
01926     #  A new group is created. All mesh elements that are present in
01927     #  the main group but are not present in the tool group are added to the new one
01928     #  @return an instance of SMESH_Group
01929     #  @ingroup l2_grps_operon
01930     def CutGroups(self, main_group, tool_group, name):
01931         return self.mesh.CutGroups(main_group, tool_group, name)
01932 
01933     ## Produces a cut of groups
01934     #  A new group is created. All mesh elements that are present in main groups
01935     #  but do not present in tool groups are added to the new one
01936     #  @return an instance of SMESH_Group
01937     #  @ingroup l2_grps_operon
01938     def CutListOfGroups(self, main_groups, tool_groups, name):
01939       return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
01940 
01941     ## Produces a group of elements of specified type using list of existing groups
01942     #  A new group is created. System
01943     #  1) extracts all nodes on which groups elements are built
01944     #  2) combines all elements of specified dimension laying on these nodes
01945     #  @return an instance of SMESH_Group
01946     #  @ingroup l2_grps_operon
01947     def CreateDimGroup(self, groups, elem_type, name):
01948       return self.mesh.CreateDimGroup(groups, elem_type, name)
01949 
01950 
01951     ## Convert group on geom into standalone group
01952     #  @ingroup l2_grps_delete
01953     def ConvertToStandalone(self, group):
01954         return self.mesh.ConvertToStandalone(group)
01955 
01956     # Get some info about mesh:
01957     # ------------------------
01958 
01959     ## Returns the log of nodes and elements added or removed
01960     #  since the previous clear of the log.
01961     #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
01962     #  @return list of log_block structures:
01963     #                                        commandType
01964     #                                        number
01965     #                                        coords
01966     #                                        indexes
01967     #  @ingroup l1_auxiliary
01968     def GetLog(self, clearAfterGet):
01969         return self.mesh.GetLog(clearAfterGet)
01970 
01971     ## Clears the log of nodes and elements added or removed since the previous
01972     #  clear. Must be used immediately after GetLog if clearAfterGet is false.
01973     #  @ingroup l1_auxiliary
01974     def ClearLog(self):
01975         self.mesh.ClearLog()
01976 
01977     ## Toggles auto color mode on the object.
01978     #  @param theAutoColor the flag which toggles auto color mode.
01979     #  @ingroup l1_auxiliary
01980     def SetAutoColor(self, theAutoColor):
01981         self.mesh.SetAutoColor(theAutoColor)
01982 
01983     ## Gets flag of object auto color mode.
01984     #  @return True or False
01985     #  @ingroup l1_auxiliary
01986     def GetAutoColor(self):
01987         return self.mesh.GetAutoColor()
01988 
01989     ## Gets the internal ID
01990     #  @return integer value, which is the internal Id of the mesh
01991     #  @ingroup l1_auxiliary
01992     def GetId(self):
01993         return self.mesh.GetId()
01994 
01995     ## Get the study Id
01996     #  @return integer value, which is the study Id of the mesh
01997     #  @ingroup l1_auxiliary
01998     def GetStudyId(self):
01999         return self.mesh.GetStudyId()
02000 
02001     ## Checks the group names for duplications.
02002     #  Consider the maximum group name length stored in MED file.
02003     #  @return True or False
02004     #  @ingroup l1_auxiliary
02005     def HasDuplicatedGroupNamesMED(self):
02006         return self.mesh.HasDuplicatedGroupNamesMED()
02007 
02008     ## Obtains the mesh editor tool
02009     #  @return an instance of SMESH_MeshEditor
02010     #  @ingroup l1_modifying
02011     def GetMeshEditor(self):
02012         return self.mesh.GetMeshEditor()
02013 
02014     ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
02015     #  can be passed as argument to accepting mesh, group or sub-mesh
02016     #  @return an instance of SMESH_IDSource
02017     #  @ingroup l1_auxiliary
02018     def GetIDSource(self, ids, elemType):
02019         return self.GetMeshEditor().MakeIDSource(ids, elemType)
02020 
02021     ## Gets MED Mesh
02022     #  @return an instance of SALOME_MED::MESH
02023     #  @ingroup l1_auxiliary
02024     def GetMEDMesh(self):
02025         return self.mesh.GetMEDMesh()
02026 
02027 
02028     # Get informations about mesh contents:
02029     # ------------------------------------
02030 
02031     ## Gets the mesh stattistic
02032     #  @return dictionary type element - count of elements
02033     #  @ingroup l1_meshinfo
02034     def GetMeshInfo(self, obj = None):
02035         if not obj: obj = self.mesh
02036         return self.smeshpyD.GetMeshInfo(obj)
02037 
02038     ## Returns the number of nodes in the mesh
02039     #  @return an integer value
02040     #  @ingroup l1_meshinfo
02041     def NbNodes(self):
02042         return self.mesh.NbNodes()
02043 
02044     ## Returns the number of elements in the mesh
02045     #  @return an integer value
02046     #  @ingroup l1_meshinfo
02047     def NbElements(self):
02048         return self.mesh.NbElements()
02049 
02050     ## Returns the number of 0d elements in the mesh
02051     #  @return an integer value
02052     #  @ingroup l1_meshinfo
02053     def Nb0DElements(self):
02054         return self.mesh.Nb0DElements()
02055 
02056     ## Returns the number of edges in the mesh
02057     #  @return an integer value
02058     #  @ingroup l1_meshinfo
02059     def NbEdges(self):
02060         return self.mesh.NbEdges()
02061 
02062     ## Returns the number of edges with the given order in the mesh
02063     #  @param elementOrder the order of elements:
02064     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
02065     #  @return an integer value
02066     #  @ingroup l1_meshinfo
02067     def NbEdgesOfOrder(self, elementOrder):
02068         return self.mesh.NbEdgesOfOrder(elementOrder)
02069 
02070     ## Returns the number of faces in the mesh
02071     #  @return an integer value
02072     #  @ingroup l1_meshinfo
02073     def NbFaces(self):
02074         return self.mesh.NbFaces()
02075 
02076     ## Returns the number of faces with the given order in the mesh
02077     #  @param elementOrder the order of elements:
02078     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
02079     #  @return an integer value
02080     #  @ingroup l1_meshinfo
02081     def NbFacesOfOrder(self, elementOrder):
02082         return self.mesh.NbFacesOfOrder(elementOrder)
02083 
02084     ## Returns the number of triangles in the mesh
02085     #  @return an integer value
02086     #  @ingroup l1_meshinfo
02087     def NbTriangles(self):
02088         return self.mesh.NbTriangles()
02089 
02090     ## Returns the number of triangles with the given order in the mesh
02091     #  @param elementOrder is the order of elements:
02092     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
02093     #  @return an integer value
02094     #  @ingroup l1_meshinfo
02095     def NbTrianglesOfOrder(self, elementOrder):
02096         return self.mesh.NbTrianglesOfOrder(elementOrder)
02097 
02098     ## Returns the number of quadrangles in the mesh
02099     #  @return an integer value
02100     #  @ingroup l1_meshinfo
02101     def NbQuadrangles(self):
02102         return self.mesh.NbQuadrangles()
02103 
02104     ## Returns the number of quadrangles with the given order in the mesh
02105     #  @param elementOrder the order of elements:
02106     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
02107     #  @return an integer value
02108     #  @ingroup l1_meshinfo
02109     def NbQuadranglesOfOrder(self, elementOrder):
02110         return self.mesh.NbQuadranglesOfOrder(elementOrder)
02111 
02112     ## Returns the number of polygons in the mesh
02113     #  @return an integer value
02114     #  @ingroup l1_meshinfo
02115     def NbPolygons(self):
02116         return self.mesh.NbPolygons()
02117 
02118     ## Returns the number of volumes in the mesh
02119     #  @return an integer value
02120     #  @ingroup l1_meshinfo
02121     def NbVolumes(self):
02122         return self.mesh.NbVolumes()
02123 
02124     ## Returns the number of volumes with the given order in the mesh
02125     #  @param elementOrder  the order of elements:
02126     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
02127     #  @return an integer value
02128     #  @ingroup l1_meshinfo
02129     def NbVolumesOfOrder(self, elementOrder):
02130         return self.mesh.NbVolumesOfOrder(elementOrder)
02131 
02132     ## Returns the number of tetrahedrons in the mesh
02133     #  @return an integer value
02134     #  @ingroup l1_meshinfo
02135     def NbTetras(self):
02136         return self.mesh.NbTetras()
02137 
02138     ## Returns the number of tetrahedrons with the given order in the mesh
02139     #  @param elementOrder  the order of elements:
02140     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
02141     #  @return an integer value
02142     #  @ingroup l1_meshinfo
02143     def NbTetrasOfOrder(self, elementOrder):
02144         return self.mesh.NbTetrasOfOrder(elementOrder)
02145 
02146     ## Returns the number of hexahedrons in the mesh
02147     #  @return an integer value
02148     #  @ingroup l1_meshinfo
02149     def NbHexas(self):
02150         return self.mesh.NbHexas()
02151 
02152     ## Returns the number of hexahedrons with the given order in the mesh
02153     #  @param elementOrder  the order of elements:
02154     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
02155     #  @return an integer value
02156     #  @ingroup l1_meshinfo
02157     def NbHexasOfOrder(self, elementOrder):
02158         return self.mesh.NbHexasOfOrder(elementOrder)
02159 
02160     ## Returns the number of pyramids in the mesh
02161     #  @return an integer value
02162     #  @ingroup l1_meshinfo
02163     def NbPyramids(self):
02164         return self.mesh.NbPyramids()
02165 
02166     ## Returns the number of pyramids with the given order in the mesh
02167     #  @param elementOrder  the order of elements:
02168     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
02169     #  @return an integer value
02170     #  @ingroup l1_meshinfo
02171     def NbPyramidsOfOrder(self, elementOrder):
02172         return self.mesh.NbPyramidsOfOrder(elementOrder)
02173 
02174     ## Returns the number of prisms in the mesh
02175     #  @return an integer value
02176     #  @ingroup l1_meshinfo
02177     def NbPrisms(self):
02178         return self.mesh.NbPrisms()
02179 
02180     ## Returns the number of prisms with the given order in the mesh
02181     #  @param elementOrder  the order of elements:
02182     #         ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
02183     #  @return an integer value
02184     #  @ingroup l1_meshinfo
02185     def NbPrismsOfOrder(self, elementOrder):
02186         return self.mesh.NbPrismsOfOrder(elementOrder)
02187 
02188     ## Returns the number of polyhedrons in the mesh
02189     #  @return an integer value
02190     #  @ingroup l1_meshinfo
02191     def NbPolyhedrons(self):
02192         return self.mesh.NbPolyhedrons()
02193 
02194     ## Returns the number of submeshes in the mesh
02195     #  @return an integer value
02196     #  @ingroup l1_meshinfo
02197     def NbSubMesh(self):
02198         return self.mesh.NbSubMesh()
02199 
02200     ## Returns the list of mesh elements IDs
02201     #  @return the list of integer values
02202     #  @ingroup l1_meshinfo
02203     def GetElementsId(self):
02204         return self.mesh.GetElementsId()
02205 
02206     ## Returns the list of IDs of mesh elements with the given type
02207     #  @param elementType  the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
02208     #  @return list of integer values
02209     #  @ingroup l1_meshinfo
02210     def GetElementsByType(self, elementType):
02211         return self.mesh.GetElementsByType(elementType)
02212 
02213     ## Returns the list of mesh nodes IDs
02214     #  @return the list of integer values
02215     #  @ingroup l1_meshinfo
02216     def GetNodesId(self):
02217         return self.mesh.GetNodesId()
02218 
02219     # Get the information about mesh elements:
02220     # ------------------------------------
02221 
02222     ## Returns the type of mesh element
02223     #  @return the value from SMESH::ElementType enumeration
02224     #  @ingroup l1_meshinfo
02225     def GetElementType(self, id, iselem):
02226         return self.mesh.GetElementType(id, iselem)
02227 
02228     ## Returns the geometric type of mesh element
02229     #  @return the value from SMESH::EntityType enumeration
02230     #  @ingroup l1_meshinfo
02231     def GetElementGeomType(self, id):
02232         return self.mesh.GetElementGeomType(id)
02233 
02234     ## Returns the list of submesh elements IDs
02235     #  @param Shape a geom object(subshape) IOR
02236     #         Shape must be the subshape of a ShapeToMesh()
02237     #  @return the list of integer values
02238     #  @ingroup l1_meshinfo
02239     def GetSubMeshElementsId(self, Shape):
02240         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02241             ShapeID = Shape.GetSubShapeIndices()[0]
02242         else:
02243             ShapeID = Shape
02244         return self.mesh.GetSubMeshElementsId(ShapeID)
02245 
02246     ## Returns the list of submesh nodes IDs
02247     #  @param Shape a geom object(subshape) IOR
02248     #         Shape must be the subshape of a ShapeToMesh()
02249     #  @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
02250     #  @return the list of integer values
02251     #  @ingroup l1_meshinfo
02252     def GetSubMeshNodesId(self, Shape, all):
02253         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02254             ShapeID = Shape.GetSubShapeIndices()[0]
02255         else:
02256             ShapeID = Shape
02257         return self.mesh.GetSubMeshNodesId(ShapeID, all)
02258 
02259     ## Returns type of elements on given shape
02260     #  @param Shape a geom object(subshape) IOR
02261     #         Shape must be a subshape of a ShapeToMesh()
02262     #  @return element type
02263     #  @ingroup l1_meshinfo
02264     def GetSubMeshElementType(self, Shape):
02265         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02266             ShapeID = Shape.GetSubShapeIndices()[0]
02267         else:
02268             ShapeID = Shape
02269         return self.mesh.GetSubMeshElementType(ShapeID)
02270 
02271     ## Gets the mesh description
02272     #  @return string value
02273     #  @ingroup l1_meshinfo
02274     def Dump(self):
02275         return self.mesh.Dump()
02276 
02277 
02278     # Get the information about nodes and elements of a mesh by its IDs:
02279     # -----------------------------------------------------------
02280 
02281     ## Gets XYZ coordinates of a node
02282     #  \n If there is no nodes for the given ID - returns an empty list
02283     #  @return a list of double precision values
02284     #  @ingroup l1_meshinfo
02285     def GetNodeXYZ(self, id):
02286         return self.mesh.GetNodeXYZ(id)
02287 
02288     ## Returns list of IDs of inverse elements for the given node
02289     #  \n If there is no node for the given ID - returns an empty list
02290     #  @return a list of integer values
02291     #  @ingroup l1_meshinfo
02292     def GetNodeInverseElements(self, id):
02293         return self.mesh.GetNodeInverseElements(id)
02294 
02295     ## @brief Returns the position of a node on the shape
02296     #  @return SMESH::NodePosition
02297     #  @ingroup l1_meshinfo
02298     def GetNodePosition(self,NodeID):
02299         return self.mesh.GetNodePosition(NodeID)
02300 
02301     ## If the given element is a node, returns the ID of shape
02302     #  \n If there is no node for the given ID - returns -1
02303     #  @return an integer value
02304     #  @ingroup l1_meshinfo
02305     def GetShapeID(self, id):
02306         return self.mesh.GetShapeID(id)
02307 
02308     ## Returns the ID of the result shape after
02309     #  FindShape() from SMESH_MeshEditor for the given element
02310     #  \n If there is no element for the given ID - returns -1
02311     #  @return an integer value
02312     #  @ingroup l1_meshinfo
02313     def GetShapeIDForElem(self,id):
02314         return self.mesh.GetShapeIDForElem(id)
02315 
02316     ## Returns the number of nodes for the given element
02317     #  \n If there is no element for the given ID - returns -1
02318     #  @return an integer value
02319     #  @ingroup l1_meshinfo
02320     def GetElemNbNodes(self, id):
02321         return self.mesh.GetElemNbNodes(id)
02322 
02323     ## Returns the node ID the given index for the given element
02324     #  \n If there is no element for the given ID - returns -1
02325     #  \n If there is no node for the given index - returns -2
02326     #  @return an integer value
02327     #  @ingroup l1_meshinfo
02328     def GetElemNode(self, id, index):
02329         return self.mesh.GetElemNode(id, index)
02330 
02331     ## Returns the IDs of nodes of the given element
02332     #  @return a list of integer values
02333     #  @ingroup l1_meshinfo
02334     def GetElemNodes(self, id):
02335         return self.mesh.GetElemNodes(id)
02336 
02337     ## Returns true if the given node is the medium node in the given quadratic element
02338     #  @ingroup l1_meshinfo
02339     def IsMediumNode(self, elementID, nodeID):
02340         return self.mesh.IsMediumNode(elementID, nodeID)
02341 
02342     ## Returns true if the given node is the medium node in one of quadratic elements
02343     #  @ingroup l1_meshinfo
02344     def IsMediumNodeOfAnyElem(self, nodeID, elementType):
02345         return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
02346 
02347     ## Returns the number of edges for the given element
02348     #  @ingroup l1_meshinfo
02349     def ElemNbEdges(self, id):
02350         return self.mesh.ElemNbEdges(id)
02351 
02352     ## Returns the number of faces for the given element
02353     #  @ingroup l1_meshinfo
02354     def ElemNbFaces(self, id):
02355         return self.mesh.ElemNbFaces(id)
02356 
02357     ## Returns nodes of given face (counted from zero) for given volumic element.
02358     #  @ingroup l1_meshinfo
02359     def GetElemFaceNodes(self,elemId, faceIndex):
02360         return self.mesh.GetElemFaceNodes(elemId, faceIndex)
02361 
02362     ## Returns an element based on all given nodes.
02363     #  @ingroup l1_meshinfo
02364     def FindElementByNodes(self,nodes):
02365         return self.mesh.FindElementByNodes(nodes)
02366 
02367     ## Returns true if the given element is a polygon
02368     #  @ingroup l1_meshinfo
02369     def IsPoly(self, id):
02370         return self.mesh.IsPoly(id)
02371 
02372     ## Returns true if the given element is quadratic
02373     #  @ingroup l1_meshinfo
02374     def IsQuadratic(self, id):
02375         return self.mesh.IsQuadratic(id)
02376 
02377     ## Returns XYZ coordinates of the barycenter of the given element
02378     #  \n If there is no element for the given ID - returns an empty list
02379     #  @return a list of three double values
02380     #  @ingroup l1_meshinfo
02381     def BaryCenter(self, id):
02382         return self.mesh.BaryCenter(id)
02383 
02384 
02385     # Get mesh measurements information:
02386     # ------------------------------------
02387 
02388     ## Get minimum distance between two nodes, elements or distance to the origin
02389     #  @param id1 first node/element id
02390     #  @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
02391     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
02392     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
02393     #  @return minimum distance value
02394     #  @sa GetMinDistance()
02395     def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
02396         aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
02397         return aMeasure.value
02398 
02399     ## Get measure structure specifying minimum distance data between two objects
02400     #  @param id1 first node/element id
02401     #  @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
02402     #  @param isElem1 @c True if @a id1 is element id, @c False if it is node id
02403     #  @param isElem2 @c True if @a id2 is element id, @c False if it is node id
02404     #  @return Measure structure
02405     #  @sa MinDistance()
02406     def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
02407         if isElem1:
02408             id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
02409         else:
02410             id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
02411         if id2 != 0:
02412             if isElem2:
02413                 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
02414             else:
02415                 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
02416             pass
02417         else:
02418             id2 = None
02419 
02420         aMeasurements = self.smeshpyD.CreateMeasurements()
02421         aMeasure = aMeasurements.MinDistance(id1, id2)
02422         aMeasurements.UnRegister()
02423         return aMeasure
02424 
02425     ## Get bounding box of the specified object(s)
02426     #  @param objects single source object or list of source objects or list of nodes/elements IDs
02427     #  @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
02428     #  @c False specifies that @a objects are nodes
02429     #  @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
02430     #  @sa GetBoundingBox()
02431     def BoundingBox(self, objects=None, isElem=False):
02432         result = self.GetBoundingBox(objects, isElem)
02433         if result is None:
02434             result = (0.0,)*6
02435         else:
02436             result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
02437         return result
02438 
02439     ## Get measure structure specifying bounding box data of the specified object(s)
02440     #  @param objects single source object or list of source objects or list of nodes/elements IDs
02441     #  @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
02442     #  @c False specifies that @a objects are nodes
02443     #  @return Measure structure
02444     #  @sa BoundingBox()
02445     def GetBoundingBox(self, IDs=None, isElem=False):
02446         if IDs is None:
02447             IDs = [self.mesh]
02448         elif isinstance(IDs, tuple):
02449             IDs = list(IDs)
02450         if not isinstance(IDs, list):
02451             IDs = [IDs]
02452         if len(IDs) > 0 and isinstance(IDs[0], int):
02453             IDs = [IDs]
02454         srclist = []
02455         for o in IDs:
02456             if isinstance(o, Mesh):
02457                 srclist.append(o.mesh)
02458             elif hasattr(o, "_narrow"):
02459                 src = o._narrow(SMESH.SMESH_IDSource)
02460                 if src: srclist.append(src)
02461                 pass
02462             elif isinstance(o, list):
02463                 if isElem:
02464                     srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
02465                 else:
02466                     srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
02467                 pass
02468             pass
02469         aMeasurements = self.smeshpyD.CreateMeasurements()
02470         aMeasure = aMeasurements.BoundingBox(srclist)
02471         aMeasurements.UnRegister()
02472         return aMeasure
02473 
02474     # Mesh edition (SMESH_MeshEditor functionality):
02475     # ---------------------------------------------
02476 
02477     ## Removes the elements from the mesh by ids
02478     #  @param IDsOfElements is a list of ids of elements to remove
02479     #  @return True or False
02480     #  @ingroup l2_modif_del
02481     def RemoveElements(self, IDsOfElements):
02482         return self.editor.RemoveElements(IDsOfElements)
02483 
02484     ## Removes nodes from mesh by ids
02485     #  @param IDsOfNodes is a list of ids of nodes to remove
02486     #  @return True or False
02487     #  @ingroup l2_modif_del
02488     def RemoveNodes(self, IDsOfNodes):
02489         return self.editor.RemoveNodes(IDsOfNodes)
02490 
02491     ## Removes all orphan (free) nodes from mesh
02492     #  @return number of the removed nodes
02493     #  @ingroup l2_modif_del
02494     def RemoveOrphanNodes(self):
02495         return self.editor.RemoveOrphanNodes()
02496 
02497     ## Add a node to the mesh by coordinates
02498     #  @return Id of the new node
02499     #  @ingroup l2_modif_add
02500     def AddNode(self, x, y, z):
02501         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
02502         self.mesh.SetParameters(Parameters)
02503         return self.editor.AddNode( x, y, z)
02504 
02505     ## Creates a 0D element on a node with given number.
02506     #  @param IDOfNode the ID of node for creation of the element.
02507     #  @return the Id of the new 0D element
02508     #  @ingroup l2_modif_add
02509     def Add0DElement(self, IDOfNode):
02510         return self.editor.Add0DElement(IDOfNode)
02511 
02512     ## Creates a linear or quadratic edge (this is determined
02513     #  by the number of given nodes).
02514     #  @param IDsOfNodes the list of node IDs for creation of the element.
02515     #  The order of nodes in this list should correspond to the description
02516     #  of MED. \n This description is located by the following link:
02517     #  http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
02518     #  @return the Id of the new edge
02519     #  @ingroup l2_modif_add
02520     def AddEdge(self, IDsOfNodes):
02521         return self.editor.AddEdge(IDsOfNodes)
02522 
02523     ## Creates a linear or quadratic face (this is determined
02524     #  by the number of given nodes).
02525     #  @param IDsOfNodes the list of node IDs for creation of the element.
02526     #  The order of nodes in this list should correspond to the description
02527     #  of MED. \n This description is located by the following link:
02528     #  http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
02529     #  @return the Id of the new face
02530     #  @ingroup l2_modif_add
02531     def AddFace(self, IDsOfNodes):
02532         return self.editor.AddFace(IDsOfNodes)
02533 
02534     ## Adds a polygonal face to the mesh by the list of node IDs
02535     #  @param IdsOfNodes the list of node IDs for creation of the element.
02536     #  @return the Id of the new face
02537     #  @ingroup l2_modif_add
02538     def AddPolygonalFace(self, IdsOfNodes):
02539         return self.editor.AddPolygonalFace(IdsOfNodes)
02540 
02541     ## Creates both simple and quadratic volume (this is determined
02542     #  by the number of given nodes).
02543     #  @param IDsOfNodes the list of node IDs for creation of the element.
02544     #  The order of nodes in this list should correspond to the description
02545     #  of MED. \n This description is located by the following link:
02546     #  http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
02547     #  @return the Id of the new volumic element
02548     #  @ingroup l2_modif_add
02549     def AddVolume(self, IDsOfNodes):
02550         return self.editor.AddVolume(IDsOfNodes)
02551 
02552     ## Creates a volume of many faces, giving nodes for each face.
02553     #  @param IdsOfNodes the list of node IDs for volume creation face by face.
02554     #  @param Quantities the list of integer values, Quantities[i]
02555     #         gives the quantity of nodes in face number i.
02556     #  @return the Id of the new volumic element
02557     #  @ingroup l2_modif_add
02558     def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
02559         return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
02560 
02561     ## Creates a volume of many faces, giving the IDs of the existing faces.
02562     #  @param IdsOfFaces the list of face IDs for volume creation.
02563     #
02564     #  Note:  The created volume will refer only to the nodes
02565     #         of the given faces, not to the faces themselves.
02566     #  @return the Id of the new volumic element
02567     #  @ingroup l2_modif_add
02568     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
02569         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
02570 
02571 
02572     ## @brief Binds a node to a vertex
02573     #  @param NodeID a node ID
02574     #  @param Vertex a vertex or vertex ID
02575     #  @return True if succeed else raises an exception
02576     #  @ingroup l2_modif_add
02577     def SetNodeOnVertex(self, NodeID, Vertex):
02578         if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
02579             VertexID = Vertex.GetSubShapeIndices()[0]
02580         else:
02581             VertexID = Vertex
02582         try:
02583             self.editor.SetNodeOnVertex(NodeID, VertexID)
02584         except SALOME.SALOME_Exception, inst:
02585             raise ValueError, inst.details.text
02586         return True
02587 
02588 
02589     ## @brief Stores the node position on an edge
02590     #  @param NodeID a node ID
02591     #  @param Edge an edge or edge ID
02592     #  @param paramOnEdge a parameter on the edge where the node is located
02593     #  @return True if succeed else raises an exception
02594     #  @ingroup l2_modif_add
02595     def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
02596         if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
02597             EdgeID = Edge.GetSubShapeIndices()[0]
02598         else:
02599             EdgeID = Edge
02600         try:
02601             self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
02602         except SALOME.SALOME_Exception, inst:
02603             raise ValueError, inst.details.text
02604         return True
02605 
02606     ## @brief Stores node position on a face
02607     #  @param NodeID a node ID
02608     #  @param Face a face or face ID
02609     #  @param u U parameter on the face where the node is located
02610     #  @param v V parameter on the face where the node is located
02611     #  @return True if succeed else raises an exception
02612     #  @ingroup l2_modif_add
02613     def SetNodeOnFace(self, NodeID, Face, u, v):
02614         if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
02615             FaceID = Face.GetSubShapeIndices()[0]
02616         else:
02617             FaceID = Face
02618         try:
02619             self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
02620         except SALOME.SALOME_Exception, inst:
02621             raise ValueError, inst.details.text
02622         return True
02623 
02624     ## @brief Binds a node to a solid
02625     #  @param NodeID a node ID
02626     #  @param Solid  a solid or solid ID
02627     #  @return True if succeed else raises an exception
02628     #  @ingroup l2_modif_add
02629     def SetNodeInVolume(self, NodeID, Solid):
02630         if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
02631             SolidID = Solid.GetSubShapeIndices()[0]
02632         else:
02633             SolidID = Solid
02634         try:
02635             self.editor.SetNodeInVolume(NodeID, SolidID)
02636         except SALOME.SALOME_Exception, inst:
02637             raise ValueError, inst.details.text
02638         return True
02639 
02640     ## @brief Bind an element to a shape
02641     #  @param ElementID an element ID
02642     #  @param Shape a shape or shape ID
02643     #  @return True if succeed else raises an exception
02644     #  @ingroup l2_modif_add
02645     def SetMeshElementOnShape(self, ElementID, Shape):
02646         if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02647             ShapeID = Shape.GetSubShapeIndices()[0]
02648         else:
02649             ShapeID = Shape
02650         try:
02651             self.editor.SetMeshElementOnShape(ElementID, ShapeID)
02652         except SALOME.SALOME_Exception, inst:
02653             raise ValueError, inst.details.text
02654         return True
02655 
02656 
02657     ## Moves the node with the given id
02658     #  @param NodeID the id of the node
02659     #  @param x  a new X coordinate
02660     #  @param y  a new Y coordinate
02661     #  @param z  a new Z coordinate
02662     #  @return True if succeed else False
02663     #  @ingroup l2_modif_movenode
02664     def MoveNode(self, NodeID, x, y, z):
02665         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
02666         self.mesh.SetParameters(Parameters)
02667         return self.editor.MoveNode(NodeID, x, y, z)
02668 
02669     ## Finds the node closest to a point and moves it to a point location
02670     #  @param x  the X coordinate of a point
02671     #  @param y  the Y coordinate of a point
02672     #  @param z  the Z coordinate of a point
02673     #  @param NodeID if specified (>0), the node with this ID is moved,
02674     #  otherwise, the node closest to point (@a x,@a y,@a z) is moved
02675     #  @return the ID of a node
02676     #  @ingroup l2_modif_throughp
02677     def MoveClosestNodeToPoint(self, x, y, z, NodeID):
02678         x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
02679         self.mesh.SetParameters(Parameters)
02680         return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
02681 
02682     ## Finds the node closest to a point
02683     #  @param x  the X coordinate of a point
02684     #  @param y  the Y coordinate of a point
02685     #  @param z  the Z coordinate of a point
02686     #  @return the ID of a node
02687     #  @ingroup l2_modif_throughp
02688     def FindNodeClosestTo(self, x, y, z):
02689         #preview = self.mesh.GetMeshEditPreviewer()
02690         #return preview.MoveClosestNodeToPoint(x, y, z, -1)
02691         return self.editor.FindNodeClosestTo(x, y, z)
02692 
02693     ## Finds the elements where a point lays IN or ON
02694     #  @param x  the X coordinate of a point
02695     #  @param y  the Y coordinate of a point
02696     #  @param z  the Z coordinate of a point
02697     #  @param elementType type of elements to find (SMESH.ALL type
02698     #         means elements of any type excluding nodes and 0D elements)
02699     #  @return list of IDs of found elements
02700     #  @ingroup l2_modif_throughp
02701     def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
02702         return self.editor.FindElementsByPoint(x, y, z, elementType)
02703 
02704     # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
02705     # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
02706 
02707     def GetPointState(self, x, y, z):
02708         return self.editor.GetPointState(x, y, z)
02709 
02710     ## Finds the node closest to a point and moves it to a point location
02711     #  @param x  the X coordinate of a point
02712     #  @param y  the Y coordinate of a point
02713     #  @param z  the Z coordinate of a point
02714     #  @return the ID of a moved node
02715     #  @ingroup l2_modif_throughp
02716     def MeshToPassThroughAPoint(self, x, y, z):
02717         return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
02718 
02719     ## Replaces two neighbour triangles sharing Node1-Node2 link
02720     #  with the triangles built on the same 4 nodes but having other common link.
02721     #  @param NodeID1  the ID of the first node
02722     #  @param NodeID2  the ID of the second node
02723     #  @return false if proper faces were not found
02724     #  @ingroup l2_modif_invdiag
02725     def InverseDiag(self, NodeID1, NodeID2):
02726         return self.editor.InverseDiag(NodeID1, NodeID2)
02727 
02728     ## Replaces two neighbour triangles sharing Node1-Node2 link
02729     #  with a quadrangle built on the same 4 nodes.
02730     #  @param NodeID1  the ID of the first node
02731     #  @param NodeID2  the ID of the second node
02732     #  @return false if proper faces were not found
02733     #  @ingroup l2_modif_unitetri
02734     def DeleteDiag(self, NodeID1, NodeID2):
02735         return self.editor.DeleteDiag(NodeID1, NodeID2)
02736 
02737     ## Reorients elements by ids
02738     #  @param IDsOfElements if undefined reorients all mesh elements
02739     #  @return True if succeed else False
02740     #  @ingroup l2_modif_changori
02741     def Reorient(self, IDsOfElements=None):
02742         if IDsOfElements == None:
02743             IDsOfElements = self.GetElementsId()
02744         return self.editor.Reorient(IDsOfElements)
02745 
02746     ## Reorients all elements of the object
02747     #  @param theObject mesh, submesh or group
02748     #  @return True if succeed else False
02749     #  @ingroup l2_modif_changori
02750     def ReorientObject(self, theObject):
02751         if ( isinstance( theObject, Mesh )):
02752             theObject = theObject.GetMesh()
02753         return self.editor.ReorientObject(theObject)
02754 
02755     ## Fuses the neighbouring triangles into quadrangles.
02756     #  @param IDsOfElements The triangles to be fused,
02757     #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
02758     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
02759     #                       is still performed; theMaxAngle is mesured in radians.
02760     #                       Also it could be a name of variable which defines angle in degrees.
02761     #  @return TRUE in case of success, FALSE otherwise.
02762     #  @ingroup l2_modif_unitetri
02763     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
02764         flag = False
02765         if isinstance(MaxAngle,str):
02766             flag = True
02767         MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
02768         if flag:
02769             MaxAngle = DegreesToRadians(MaxAngle)
02770         if IDsOfElements == []:
02771             IDsOfElements = self.GetElementsId()
02772         self.mesh.SetParameters(Parameters)
02773         Functor = 0
02774         if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
02775             Functor = theCriterion
02776         else:
02777             Functor = self.smeshpyD.GetFunctor(theCriterion)
02778         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
02779 
02780     ## Fuses the neighbouring triangles of the object into quadrangles
02781     #  @param theObject is mesh, submesh or group
02782     #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
02783     #  @param MaxAngle   a max angle between element normals at which the fusion
02784     #                   is still performed; theMaxAngle is mesured in radians.
02785     #  @return TRUE in case of success, FALSE otherwise.
02786     #  @ingroup l2_modif_unitetri
02787     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
02788         if ( isinstance( theObject, Mesh )):
02789             theObject = theObject.GetMesh()
02790         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
02791 
02792     ## Splits quadrangles into triangles.
02793     #  @param IDsOfElements the faces to be splitted.
02794     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
02795     #  @return TRUE in case of success, FALSE otherwise.
02796     #  @ingroup l2_modif_cutquadr
02797     def QuadToTri (self, IDsOfElements, theCriterion):
02798         if IDsOfElements == []:
02799             IDsOfElements = self.GetElementsId()
02800         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
02801 
02802     ## Splits quadrangles into triangles.
02803     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
02804     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
02805     #  @return TRUE in case of success, FALSE otherwise.
02806     #  @ingroup l2_modif_cutquadr
02807     def QuadToTriObject (self, theObject, theCriterion):
02808         if ( isinstance( theObject, Mesh )):
02809             theObject = theObject.GetMesh()
02810         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
02811 
02812     ## Splits quadrangles into triangles.
02813     #  @param IDsOfElements the faces to be splitted
02814     #  @param Diag13        is used to choose a diagonal for splitting.
02815     #  @return TRUE in case of success, FALSE otherwise.
02816     #  @ingroup l2_modif_cutquadr
02817     def SplitQuad (self, IDsOfElements, Diag13):
02818         if IDsOfElements == []:
02819             IDsOfElements = self.GetElementsId()
02820         return self.editor.SplitQuad(IDsOfElements, Diag13)
02821 
02822     ## Splits quadrangles into triangles.
02823     #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
02824     #  @param Diag13    is used to choose a diagonal for splitting.
02825     #  @return TRUE in case of success, FALSE otherwise.
02826     #  @ingroup l2_modif_cutquadr
02827     def SplitQuadObject (self, theObject, Diag13):
02828         if ( isinstance( theObject, Mesh )):
02829             theObject = theObject.GetMesh()
02830         return self.editor.SplitQuadObject(theObject, Diag13)
02831 
02832     ## Finds a better splitting of the given quadrangle.
02833     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
02834     #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
02835     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
02836     #          diagonal is better, 0 if error occurs.
02837     #  @ingroup l2_modif_cutquadr
02838     def BestSplit (self, IDOfQuad, theCriterion):
02839         return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
02840 
02841     ## Splits volumic elements into tetrahedrons
02842     #  @param elemIDs either list of elements or mesh or group or submesh
02843     #  @param method  flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
02844     #         Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
02845     #  @ingroup l2_modif_cutquadr
02846     def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
02847         if isinstance( elemIDs, Mesh ):
02848             elemIDs = elemIDs.GetMesh()
02849         if ( isinstance( elemIDs, list )):
02850             elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
02851         self.editor.SplitVolumesIntoTetra(elemIDs, method)
02852 
02853     ## Splits quadrangle faces near triangular facets of volumes
02854     #
02855     #  @ingroup l1_auxiliary
02856     def SplitQuadsNearTriangularFacets(self):
02857         faces_array = self.GetElementsByType(SMESH.FACE)
02858         for face_id in faces_array:
02859             if self.GetElemNbNodes(face_id) == 4: # quadrangle
02860                 quad_nodes = self.mesh.GetElemNodes(face_id)
02861                 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
02862                 isVolumeFound = False
02863                 for node1_elem in node1_elems:
02864                     if not isVolumeFound:
02865                         if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
02866                             nb_nodes = self.GetElemNbNodes(node1_elem)
02867                             if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
02868                                 volume_elem = node1_elem
02869                                 volume_nodes = self.mesh.GetElemNodes(volume_elem)
02870                                 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
02871                                     if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
02872                                         isVolumeFound = True
02873                                         if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
02874                                             self.SplitQuad([face_id], False) # diagonal 2-4
02875                                     elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
02876                                         isVolumeFound = True
02877                                         self.SplitQuad([face_id], True) # diagonal 1-3
02878                                 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
02879                                     if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
02880                                         isVolumeFound = True
02881                                         self.SplitQuad([face_id], True) # diagonal 1-3
02882 
02883     ## @brief Splits hexahedrons into tetrahedrons.
02884     #
02885     #  This operation uses pattern mapping functionality for splitting.
02886     #  @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
02887     #  @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
02888     #         pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
02889     #         will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
02890     #         key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
02891     #         The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
02892     #  @return TRUE in case of success, FALSE otherwise.
02893     #  @ingroup l1_auxiliary
02894     def SplitHexaToTetras (self, theObject, theNode000, theNode001):
02895         # Pattern:     5.---------.6
02896         #              /|#*      /|
02897         #             / | #*    / |
02898         #            /  |  # * /  |
02899         #           /   |   # /*  |
02900         # (0,0,1) 4.---------.7 * |
02901         #          |#*  |1   | # *|
02902         #          | # *.----|---#.2
02903         #          |  #/ *   |   /
02904         #          |  /#  *  |  /
02905         #          | /   # * | /
02906         #          |/      #*|/
02907         # (0,0,0) 0.---------.3
02908         pattern_tetra = "!!! Nb of points: \n 8 \n\
02909         !!! Points: \n\
02910         0 0 0  !- 0 \n\
02911         0 1 0  !- 1 \n\
02912         1 1 0  !- 2 \n\
02913         1 0 0  !- 3 \n\
02914         0 0 1  !- 4 \n\
02915         0 1 1  !- 5 \n\
02916         1 1 1  !- 6 \n\
02917         1 0 1  !- 7 \n\
02918         !!! Indices of points of 6 tetras: \n\
02919         0 3 4 1 \n\
02920         7 4 3 1 \n\
02921         4 7 5 1 \n\
02922         6 2 5 7 \n\
02923         1 5 2 7 \n\
02924         2 3 1 7 \n"
02925 
02926         pattern = self.smeshpyD.GetPattern()
02927         isDone  = pattern.LoadFromFile(pattern_tetra)
02928         if not isDone:
02929             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
02930             return isDone
02931 
02932         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
02933         isDone = pattern.MakeMesh(self.mesh, False, False)
02934         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
02935 
02936         # split quafrangle faces near triangular facets of volumes
02937         self.SplitQuadsNearTriangularFacets()
02938 
02939         return isDone
02940 
02941     ## @brief Split hexahedrons into prisms.
02942     #
02943     #  Uses the pattern mapping functionality for splitting.
02944     #  @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
02945     #  @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
02946     #         pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
02947     #         will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
02948     #         will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
02949     #         Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
02950     #  @return TRUE in case of success, FALSE otherwise.
02951     #  @ingroup l1_auxiliary
02952     def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
02953         # Pattern:     5.---------.6
02954         #              /|#       /|
02955         #             / | #     / |
02956         #            /  |  #   /  |
02957         #           /   |   # /   |
02958         # (0,0,1) 4.---------.7   |
02959         #          |    |    |    |
02960         #          |   1.----|----.2
02961         #          |   / *   |   /
02962         #          |  /   *  |  /
02963         #          | /     * | /
02964         #          |/       *|/
02965         # (0,0,0) 0.---------.3
02966         pattern_prism = "!!! Nb of points: \n 8 \n\
02967         !!! Points: \n\
02968         0 0 0  !- 0 \n\
02969         0 1 0  !- 1 \n\
02970         1 1 0  !- 2 \n\
02971         1 0 0  !- 3 \n\
02972         0 0 1  !- 4 \n\
02973         0 1 1  !- 5 \n\
02974         1 1 1  !- 6 \n\
02975         1 0 1  !- 7 \n\
02976         !!! Indices of points of 2 prisms: \n\
02977         0 1 3 4 5 7 \n\
02978         2 3 1 6 7 5 \n"
02979 
02980         pattern = self.smeshpyD.GetPattern()
02981         isDone  = pattern.LoadFromFile(pattern_prism)
02982         if not isDone:
02983             print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
02984             return isDone
02985 
02986         pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
02987         isDone = pattern.MakeMesh(self.mesh, False, False)
02988         if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
02989 
02990         # Splits quafrangle faces near triangular facets of volumes
02991         self.SplitQuadsNearTriangularFacets()
02992 
02993         return isDone
02994 
02995     ## Smoothes elements
02996     #  @param IDsOfElements the list if ids of elements to smooth
02997     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
02998     #  Note that nodes built on edges and boundary nodes are always fixed.
02999     #  @param MaxNbOfIterations the maximum number of iterations
03000     #  @param MaxAspectRatio varies in range [1.0, inf]
03001     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
03002     #  @return TRUE in case of success, FALSE otherwise.
03003     #  @ingroup l2_modif_smooth
03004     def Smooth(self, IDsOfElements, IDsOfFixedNodes,
03005                MaxNbOfIterations, MaxAspectRatio, Method):
03006         if IDsOfElements == []:
03007             IDsOfElements = self.GetElementsId()
03008         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
03009         self.mesh.SetParameters(Parameters)
03010         return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
03011                                   MaxNbOfIterations, MaxAspectRatio, Method)
03012 
03013     ## Smoothes elements which belong to the given object
03014     #  @param theObject the object to smooth
03015     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
03016     #  Note that nodes built on edges and boundary nodes are always fixed.
03017     #  @param MaxNbOfIterations the maximum number of iterations
03018     #  @param MaxAspectRatio varies in range [1.0, inf]
03019     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
03020     #  @return TRUE in case of success, FALSE otherwise.
03021     #  @ingroup l2_modif_smooth
03022     def SmoothObject(self, theObject, IDsOfFixedNodes,
03023                      MaxNbOfIterations, MaxAspectRatio, Method):
03024         if ( isinstance( theObject, Mesh )):
03025             theObject = theObject.GetMesh()
03026         return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
03027                                         MaxNbOfIterations, MaxAspectRatio, Method)
03028 
03029     ## Parametrically smoothes the given elements
03030     #  @param IDsOfElements the list if ids of elements to smooth
03031     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
03032     #  Note that nodes built on edges and boundary nodes are always fixed.
03033     #  @param MaxNbOfIterations the maximum number of iterations
03034     #  @param MaxAspectRatio varies in range [1.0, inf]
03035     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
03036     #  @return TRUE in case of success, FALSE otherwise.
03037     #  @ingroup l2_modif_smooth
03038     def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
03039                          MaxNbOfIterations, MaxAspectRatio, Method):
03040         if IDsOfElements == []:
03041             IDsOfElements = self.GetElementsId()
03042         MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
03043         self.mesh.SetParameters(Parameters)
03044         return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
03045                                             MaxNbOfIterations, MaxAspectRatio, Method)
03046 
03047     ## Parametrically smoothes the elements which belong to the given object
03048     #  @param theObject the object to smooth
03049     #  @param IDsOfFixedNodes the list of ids of fixed nodes.
03050     #  Note that nodes built on edges and boundary nodes are always fixed.
03051     #  @param MaxNbOfIterations the maximum number of iterations
03052     #  @param MaxAspectRatio varies in range [1.0, inf]
03053     #  @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
03054     #  @return TRUE in case of success, FALSE otherwise.
03055     #  @ingroup l2_modif_smooth
03056     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
03057                                MaxNbOfIterations, MaxAspectRatio, Method):
03058         if ( isinstance( theObject, Mesh )):
03059             theObject = theObject.GetMesh()
03060         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
03061                                                   MaxNbOfIterations, MaxAspectRatio, Method)
03062 
03063     ## Converts the mesh to quadratic, deletes old elements, replacing
03064     #  them with quadratic with the same id.
03065     #  @param theForce3d new node creation method:
03066     #         0 - the medium node lies at the geometrical entity from which the mesh element is built
03067     #         1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
03068     #  @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
03069     #  @ingroup l2_modif_tofromqu
03070     def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
03071         if theSubMesh:
03072             self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
03073         else:
03074             self.editor.ConvertToQuadratic(theForce3d)
03075 
03076     ## Converts the mesh from quadratic to ordinary,
03077     #  deletes old quadratic elements, \n replacing
03078     #  them with ordinary mesh elements with the same id.
03079     #  @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
03080     #  @ingroup l2_modif_tofromqu
03081     def ConvertFromQuadratic(self, theSubMesh=None):
03082         if theSubMesh:
03083             self.editor.ConvertFromQuadraticObject(theSubMesh)
03084         else:
03085             return self.editor.ConvertFromQuadratic()
03086 
03087     ## Creates 2D mesh as skin on boundary faces of a 3D mesh
03088     #  @return TRUE if operation has been completed successfully, FALSE otherwise
03089     #  @ingroup l2_modif_edit
03090     def  Make2DMeshFrom3D(self):
03091         return self.editor. Make2DMeshFrom3D()
03092 
03093     ## Creates missing boundary elements
03094     #  @param elements - elements whose boundary is to be checked:
03095     #                    mesh, group, sub-mesh or list of elements
03096     #   if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
03097     #  @param dimension - defines type of boundary elements to create:
03098     #                     SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
03099     #    SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
03100     #  @param groupName - a name of group to store created boundary elements in,
03101     #                     "" means not to create the group
03102     #  @param meshName - a name of new mesh to store created boundary elements in,
03103     #                     "" means not to create the new mesh
03104     #  @param toCopyElements - if true, the checked elements will be copied into
03105     #     the new mesh else only boundary elements will be copied into the new mesh
03106     #  @param toCopyExistingBondary - if true, not only new but also pre-existing
03107     #     boundary elements will be copied into the new mesh
03108     #  @return tuple (mesh, group) where bondary elements were added to
03109     #  @ingroup l2_modif_edit
03110     def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
03111                          toCopyElements=False, toCopyExistingBondary=False):
03112         if isinstance( elements, Mesh ):
03113             elements = elements.GetMesh()
03114         if ( isinstance( elements, list )):
03115             elemType = SMESH.ALL
03116             if elements: elemType = self.GetElementType( elements[0], iselem=True)
03117             elements = self.editor.MakeIDSource(elements, elemType)
03118         mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
03119                                                    toCopyElements,toCopyExistingBondary)
03120         if mesh: mesh = self.smeshpyD.Mesh(mesh)
03121         return mesh, group
03122 
03123     ##
03124     # @brief Creates missing boundary elements around either the whole mesh or 
03125     #    groups of 2D elements
03126     #  @param dimension - defines type of boundary elements to create
03127     #  @param groupName - a name of group to store all boundary elements in,
03128     #    "" means not to create the group
03129     #  @param meshName - a name of a new mesh, which is a copy of the initial 
03130     #    mesh + created boundary elements; "" means not to create the new mesh
03131     #  @param toCopyAll - if true, the whole initial mesh will be copied into
03132     #    the new mesh else only boundary elements will be copied into the new mesh
03133     #  @param groups - groups of 2D elements to make boundary around
03134     #  @retval tuple( long, mesh, groups )
03135     #                 long - number of added boundary elements
03136     #                 mesh - the mesh where elements were added to
03137     #                 group - the group of boundary elements or None
03138     #
03139     def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
03140                              toCopyAll=False, groups=[]):
03141         nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
03142                                                            toCopyAll,groups)
03143         if mesh: mesh = self.smeshpyD.Mesh(mesh)
03144         return nb, mesh, group
03145 
03146     ## Renumber mesh nodes
03147     #  @ingroup l2_modif_renumber
03148     def RenumberNodes(self):
03149         self.editor.RenumberNodes()
03150 
03151     ## Renumber mesh elements
03152     #  @ingroup l2_modif_renumber
03153     def RenumberElements(self):
03154         self.editor.RenumberElements()
03155 
03156     ## Generates new elements by rotation of the elements around the axis
03157     #  @param IDsOfElements the list of ids of elements to sweep
03158     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
03159     #  @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
03160     #  @param NbOfSteps the number of steps
03161     #  @param Tolerance tolerance
03162     #  @param MakeGroups forces the generation of new groups from existing ones
03163     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
03164     #                    of all steps, else - size of each step
03165     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03166     #  @ingroup l2_modif_extrurev
03167     def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
03168                       MakeGroups=False, TotalAngle=False):
03169         flag = False
03170         if isinstance(AngleInRadians,str):
03171             flag = True
03172         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
03173         if flag:
03174             AngleInRadians = DegreesToRadians(AngleInRadians)
03175         if IDsOfElements == []:
03176             IDsOfElements = self.GetElementsId()
03177         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03178             Axis = self.smeshpyD.GetAxisStruct(Axis)
03179         Axis,AxisParameters = ParseAxisStruct(Axis)
03180         if TotalAngle and NbOfSteps:
03181             AngleInRadians /= NbOfSteps
03182         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
03183         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
03184         self.mesh.SetParameters(Parameters)
03185         if MakeGroups:
03186             return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
03187                                                        AngleInRadians, NbOfSteps, Tolerance)
03188         self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
03189         return []
03190 
03191     ## Generates new elements by rotation of the elements of object around the axis
03192     #  @param theObject object which elements should be sweeped.
03193     #                   It can be a mesh, a sub mesh or a group.
03194     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
03195     #  @param AngleInRadians the angle of Rotation
03196     #  @param NbOfSteps number of steps
03197     #  @param Tolerance tolerance
03198     #  @param MakeGroups forces the generation of new groups from existing ones
03199     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
03200     #                    of all steps, else - size of each step
03201     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03202     #  @ingroup l2_modif_extrurev
03203     def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
03204                             MakeGroups=False, TotalAngle=False):
03205         flag = False
03206         if isinstance(AngleInRadians,str):
03207             flag = True
03208         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
03209         if flag:
03210             AngleInRadians = DegreesToRadians(AngleInRadians)
03211         if ( isinstance( theObject, Mesh )):
03212             theObject = theObject.GetMesh()
03213         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03214             Axis = self.smeshpyD.GetAxisStruct(Axis)
03215         Axis,AxisParameters = ParseAxisStruct(Axis)
03216         if TotalAngle and NbOfSteps:
03217             AngleInRadians /= NbOfSteps
03218         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
03219         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
03220         self.mesh.SetParameters(Parameters)
03221         if MakeGroups:
03222             return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
03223                                                              NbOfSteps, Tolerance)
03224         self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
03225         return []
03226 
03227     ## Generates new elements by rotation of the elements of object around the axis
03228     #  @param theObject object which elements should be sweeped.
03229     #                   It can be a mesh, a sub mesh or a group.
03230     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
03231     #  @param AngleInRadians the angle of Rotation
03232     #  @param NbOfSteps number of steps
03233     #  @param Tolerance tolerance
03234     #  @param MakeGroups forces the generation of new groups from existing ones
03235     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
03236     #                    of all steps, else - size of each step
03237     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03238     #  @ingroup l2_modif_extrurev
03239     def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
03240                               MakeGroups=False, TotalAngle=False):
03241         flag = False
03242         if isinstance(AngleInRadians,str):
03243             flag = True
03244         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
03245         if flag:
03246             AngleInRadians = DegreesToRadians(AngleInRadians)
03247         if ( isinstance( theObject, Mesh )):
03248             theObject = theObject.GetMesh()
03249         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03250             Axis = self.smeshpyD.GetAxisStruct(Axis)
03251         Axis,AxisParameters = ParseAxisStruct(Axis)
03252         if TotalAngle and NbOfSteps:
03253             AngleInRadians /= NbOfSteps
03254         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
03255         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
03256         self.mesh.SetParameters(Parameters)
03257         if MakeGroups:
03258             return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
03259                                                                NbOfSteps, Tolerance)
03260         self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
03261         return []
03262 
03263     ## Generates new elements by rotation of the elements of object around the axis
03264     #  @param theObject object which elements should be sweeped.
03265     #                   It can be a mesh, a sub mesh or a group.
03266     #  @param Axis the axis of rotation, AxisStruct or line(geom object)
03267     #  @param AngleInRadians the angle of Rotation
03268     #  @param NbOfSteps number of steps
03269     #  @param Tolerance tolerance
03270     #  @param MakeGroups forces the generation of new groups from existing ones
03271     #  @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
03272     #                    of all steps, else - size of each step
03273     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03274     #  @ingroup l2_modif_extrurev
03275     def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
03276                               MakeGroups=False, TotalAngle=False):
03277         flag = False
03278         if isinstance(AngleInRadians,str):
03279             flag = True
03280         AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
03281         if flag:
03282             AngleInRadians = DegreesToRadians(AngleInRadians)
03283         if ( isinstance( theObject, Mesh )):
03284             theObject = theObject.GetMesh()
03285         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03286             Axis = self.smeshpyD.GetAxisStruct(Axis)
03287         Axis,AxisParameters = ParseAxisStruct(Axis)
03288         if TotalAngle and NbOfSteps:
03289             AngleInRadians /= NbOfSteps
03290         NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
03291         Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
03292         self.mesh.SetParameters(Parameters)
03293         if MakeGroups:
03294             return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
03295                                                              NbOfSteps, Tolerance)
03296         self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
03297         return []
03298 
03299     ## Generates new elements by extrusion of the elements with given ids
03300     #  @param IDsOfElements the list of elements ids for extrusion
03301     #  @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
03302     #  @param NbOfSteps the number of steps
03303     #  @param MakeGroups forces the generation of new groups from existing ones
03304     #  @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03305     #  @ingroup l2_modif_extrurev
03306     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
03307         if IDsOfElements == []:
03308             IDsOfElements = self.GetElementsId()
03309         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03310             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03311         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
03312         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
03313         Parameters = StepVectorParameters + var_separator + Parameters
03314         self.mesh.SetParameters(Parameters)
03315         if MakeGroups:
03316             return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
03317         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
03318         return []
03319 
03320     ## Generates new elements by extrusion of the elements with given ids
03321     #  @param IDsOfElements is ids of elements
03322     #  @param StepVector vector, defining the direction and value of extrusion
03323     #  @param NbOfSteps the number of steps
03324     #  @param ExtrFlags sets flags for extrusion
03325     #  @param SewTolerance uses for comparing locations of nodes if flag
03326     #         EXTRUSION_FLAG_SEW is set
03327     #  @param MakeGroups forces the generation of new groups from existing ones
03328     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03329     #  @ingroup l2_modif_extrurev
03330     def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
03331                           ExtrFlags, SewTolerance, MakeGroups=False):
03332         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03333             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03334         if MakeGroups:
03335             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
03336                                                            ExtrFlags, SewTolerance)
03337         self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
03338                                       ExtrFlags, SewTolerance)
03339         return []
03340 
03341     ## Generates new elements by extrusion of the elements which belong to the object
03342     #  @param theObject the object which elements should be processed.
03343     #                   It can be a mesh, a sub mesh or a group.
03344     #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
03345     #  @param NbOfSteps the number of steps
03346     #  @param MakeGroups forces the generation of new groups from existing ones
03347     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03348     #  @ingroup l2_modif_extrurev
03349     def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
03350         if ( isinstance( theObject, Mesh )):
03351             theObject = theObject.GetMesh()
03352         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03353             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03354         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
03355         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
03356         Parameters = StepVectorParameters + var_separator + Parameters
03357         self.mesh.SetParameters(Parameters)
03358         if MakeGroups:
03359             return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
03360         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
03361         return []
03362 
03363     ## Generates new elements by extrusion of the elements which belong to the object
03364     #  @param theObject object which elements should be processed.
03365     #                   It can be a mesh, a sub mesh or a group.
03366     #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
03367     #  @param NbOfSteps the number of steps
03368     #  @param MakeGroups to generate new groups from existing ones
03369     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03370     #  @ingroup l2_modif_extrurev
03371     def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
03372         if ( isinstance( theObject, Mesh )):
03373             theObject = theObject.GetMesh()
03374         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03375             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03376         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
03377         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
03378         Parameters = StepVectorParameters + var_separator + Parameters
03379         self.mesh.SetParameters(Parameters)
03380         if MakeGroups:
03381             return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
03382         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
03383         return []
03384 
03385     ## Generates new elements by extrusion of the elements which belong to the object
03386     #  @param theObject object which elements should be processed.
03387     #                   It can be a mesh, a sub mesh or a group.
03388     #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
03389     #  @param NbOfSteps the number of steps
03390     #  @param MakeGroups forces the generation of new groups from existing ones
03391     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03392     #  @ingroup l2_modif_extrurev
03393     def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
03394         if ( isinstance( theObject, Mesh )):
03395             theObject = theObject.GetMesh()
03396         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03397             StepVector = self.smeshpyD.GetDirStruct(StepVector)
03398         StepVector,StepVectorParameters = ParseDirStruct(StepVector)
03399         NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
03400         Parameters = StepVectorParameters + var_separator + Parameters
03401         self.mesh.SetParameters(Parameters)
03402         if MakeGroups:
03403             return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
03404         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
03405         return []
03406 
03407 
03408 
03409     ## Generates new elements by extrusion of the given elements
03410     #  The path of extrusion must be a meshed edge.
03411     #  @param Base mesh or group, or submesh, or list of ids of elements for extrusion
03412     #  @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
03413     #  @param NodeStart the start node from Path. Defines the direction of extrusion
03414     #  @param HasAngles allows the shape to be rotated around the path
03415     #                   to get the resulting mesh in a helical fashion
03416     #  @param Angles list of angles in radians
03417     #  @param LinearVariation forces the computation of rotation angles as linear
03418     #                         variation of the given Angles along path steps
03419     #  @param HasRefPoint allows using the reference point
03420     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03421     #         The User can specify any point as the Reference Point.
03422     #  @param MakeGroups forces the generation of new groups from existing ones
03423     #  @param ElemType type of elements for extrusion (if param Base is a mesh)
03424     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03425     #          only SMESH::Extrusion_Error otherwise
03426     #  @ingroup l2_modif_extrurev
03427     def ExtrusionAlongPathX(self, Base, Path, NodeStart,
03428                             HasAngles, Angles, LinearVariation,
03429                             HasRefPoint, RefPoint, MakeGroups, ElemType):
03430         Angles,AnglesParameters = ParseAngles(Angles)
03431         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03432         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03433             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03434             pass
03435         Parameters = AnglesParameters + var_separator + RefPointParameters
03436         self.mesh.SetParameters(Parameters)
03437 
03438         if (isinstance(Path, Mesh)): Path = Path.GetMesh()
03439 
03440         if isinstance(Base, list):
03441             IDsOfElements = []
03442             if Base == []: IDsOfElements = self.GetElementsId()
03443             else: IDsOfElements = Base
03444             return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
03445                                                    HasAngles, Angles, LinearVariation,
03446                                                    HasRefPoint, RefPoint, MakeGroups, ElemType)
03447         else:
03448             if isinstance(Base, Mesh): Base = Base.GetMesh()
03449             if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
03450                 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
03451                                                           HasAngles, Angles, LinearVariation,
03452                                                           HasRefPoint, RefPoint, MakeGroups, ElemType)
03453             else:
03454                 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
03455 
03456 
03457     ## Generates new elements by extrusion of the given elements
03458     #  The path of extrusion must be a meshed edge.
03459     #  @param IDsOfElements ids of elements
03460     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
03461     #  @param PathShape shape(edge) defines the sub-mesh for the path
03462     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
03463     #  @param HasAngles allows the shape to be rotated around the path
03464     #                   to get the resulting mesh in a helical fashion
03465     #  @param Angles list of angles in radians
03466     #  @param HasRefPoint allows using the reference point
03467     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03468     #         The User can specify any point as the Reference Point.
03469     #  @param MakeGroups forces the generation of new groups from existing ones
03470     #  @param LinearVariation forces the computation of rotation angles as linear
03471     #                         variation of the given Angles along path steps
03472     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03473     #          only SMESH::Extrusion_Error otherwise
03474     #  @ingroup l2_modif_extrurev
03475     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
03476                            HasAngles, Angles, HasRefPoint, RefPoint,
03477                            MakeGroups=False, LinearVariation=False):
03478         Angles,AnglesParameters = ParseAngles(Angles)
03479         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03480         if IDsOfElements == []:
03481             IDsOfElements = self.GetElementsId()
03482         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03483             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03484             pass
03485         if ( isinstance( PathMesh, Mesh )):
03486             PathMesh = PathMesh.GetMesh()
03487         if HasAngles and Angles and LinearVariation:
03488             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03489             pass
03490         Parameters = AnglesParameters + var_separator + RefPointParameters
03491         self.mesh.SetParameters(Parameters)
03492         if MakeGroups:
03493             return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
03494                                                             PathShape, NodeStart, HasAngles,
03495                                                             Angles, HasRefPoint, RefPoint)
03496         return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
03497                                               NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
03498 
03499     ## Generates new elements by extrusion of the elements which belong to the object
03500     #  The path of extrusion must be a meshed edge.
03501     #  @param theObject the object which elements should be processed.
03502     #                   It can be a mesh, a sub mesh or a group.
03503     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
03504     #  @param PathShape shape(edge) defines the sub-mesh for the path
03505     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
03506     #  @param HasAngles allows the shape to be rotated around the path
03507     #                   to get the resulting mesh in a helical fashion
03508     #  @param Angles list of angles
03509     #  @param HasRefPoint allows using the reference point
03510     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03511     #         The User can specify any point as the Reference Point.
03512     #  @param MakeGroups forces the generation of new groups from existing ones
03513     #  @param LinearVariation forces the computation of rotation angles as linear
03514     #                         variation of the given Angles along path steps
03515     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03516     #          only SMESH::Extrusion_Error otherwise
03517     #  @ingroup l2_modif_extrurev
03518     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
03519                                  HasAngles, Angles, HasRefPoint, RefPoint,
03520                                  MakeGroups=False, LinearVariation=False):
03521         Angles,AnglesParameters = ParseAngles(Angles)
03522         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03523         if ( isinstance( theObject, Mesh )):
03524             theObject = theObject.GetMesh()
03525         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03526             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03527         if ( isinstance( PathMesh, Mesh )):
03528             PathMesh = PathMesh.GetMesh()
03529         if HasAngles and Angles and LinearVariation:
03530             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03531             pass
03532         Parameters = AnglesParameters + var_separator + RefPointParameters
03533         self.mesh.SetParameters(Parameters)
03534         if MakeGroups:
03535             return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
03536                                                                   PathShape, NodeStart, HasAngles,
03537                                                                   Angles, HasRefPoint, RefPoint)
03538         return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
03539                                                     NodeStart, HasAngles, Angles, HasRefPoint,
03540                                                     RefPoint)
03541 
03542     ## Generates new elements by extrusion of the elements which belong to the object
03543     #  The path of extrusion must be a meshed edge.
03544     #  @param theObject the object which elements should be processed.
03545     #                   It can be a mesh, a sub mesh or a group.
03546     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
03547     #  @param PathShape shape(edge) defines the sub-mesh for the path
03548     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
03549     #  @param HasAngles allows the shape to be rotated around the path
03550     #                   to get the resulting mesh in a helical fashion
03551     #  @param Angles list of angles
03552     #  @param HasRefPoint allows using the reference point
03553     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03554     #         The User can specify any point as the Reference Point.
03555     #  @param MakeGroups forces the generation of new groups from existing ones
03556     #  @param LinearVariation forces the computation of rotation angles as linear
03557     #                         variation of the given Angles along path steps
03558     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03559     #          only SMESH::Extrusion_Error otherwise
03560     #  @ingroup l2_modif_extrurev
03561     def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
03562                                    HasAngles, Angles, HasRefPoint, RefPoint,
03563                                    MakeGroups=False, LinearVariation=False):
03564         Angles,AnglesParameters = ParseAngles(Angles)
03565         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03566         if ( isinstance( theObject, Mesh )):
03567             theObject = theObject.GetMesh()
03568         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03569             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03570         if ( isinstance( PathMesh, Mesh )):
03571             PathMesh = PathMesh.GetMesh()
03572         if HasAngles and Angles and LinearVariation:
03573             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03574             pass
03575         Parameters = AnglesParameters + var_separator + RefPointParameters
03576         self.mesh.SetParameters(Parameters)
03577         if MakeGroups:
03578             return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
03579                                                                     PathShape, NodeStart, HasAngles,
03580                                                                     Angles, HasRefPoint, RefPoint)
03581         return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
03582                                                       NodeStart, HasAngles, Angles, HasRefPoint,
03583                                                       RefPoint)
03584 
03585     ## Generates new elements by extrusion of the elements which belong to the object
03586     #  The path of extrusion must be a meshed edge.
03587     #  @param theObject the object which elements should be processed.
03588     #                   It can be a mesh, a sub mesh or a group.
03589     #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
03590     #  @param PathShape shape(edge) defines the sub-mesh for the path
03591     #  @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
03592     #  @param HasAngles allows the shape to be rotated around the path
03593     #                   to get the resulting mesh in a helical fashion
03594     #  @param Angles list of angles
03595     #  @param HasRefPoint allows using the reference point
03596     #  @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
03597     #         The User can specify any point as the Reference Point.
03598     #  @param MakeGroups forces the generation of new groups from existing ones
03599     #  @param LinearVariation forces the computation of rotation angles as linear
03600     #                         variation of the given Angles along path steps
03601     #  @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
03602     #          only SMESH::Extrusion_Error otherwise
03603     #  @ingroup l2_modif_extrurev
03604     def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
03605                                    HasAngles, Angles, HasRefPoint, RefPoint,
03606                                    MakeGroups=False, LinearVariation=False):
03607         Angles,AnglesParameters = ParseAngles(Angles)
03608         RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03609         if ( isinstance( theObject, Mesh )):
03610             theObject = theObject.GetMesh()
03611         if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03612             RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03613         if ( isinstance( PathMesh, Mesh )):
03614             PathMesh = PathMesh.GetMesh()
03615         if HasAngles and Angles and LinearVariation:
03616             Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03617             pass
03618         Parameters = AnglesParameters + var_separator + RefPointParameters
03619         self.mesh.SetParameters(Parameters)
03620         if MakeGroups:
03621             return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
03622                                                                     PathShape, NodeStart, HasAngles,
03623                                                                     Angles, HasRefPoint, RefPoint)
03624         return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
03625                                                       NodeStart, HasAngles, Angles, HasRefPoint,
03626                                                       RefPoint)
03627 
03628     ## Creates a symmetrical copy of mesh elements
03629     #  @param IDsOfElements list of elements ids
03630     #  @param Mirror is AxisStruct or geom object(point, line, plane)
03631     #  @param theMirrorType is  POINT, AXIS or PLANE
03632     #  If the Mirror is a geom object this parameter is unnecessary
03633     #  @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
03634     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03635     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03636     #  @ingroup l2_modif_trsf
03637     def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
03638         if IDsOfElements == []:
03639             IDsOfElements = self.GetElementsId()
03640         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03641             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03642         Mirror,Parameters = ParseAxisStruct(Mirror)
03643         self.mesh.SetParameters(Parameters)
03644         if Copy and MakeGroups:
03645             return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
03646         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
03647         return []
03648 
03649     ## Creates a new mesh by a symmetrical copy of mesh elements
03650     #  @param IDsOfElements the list of elements ids
03651     #  @param Mirror is AxisStruct or geom object (point, line, plane)
03652     #  @param theMirrorType is  POINT, AXIS or PLANE
03653     #  If the Mirror is a geom object this parameter is unnecessary
03654     #  @param MakeGroups to generate new groups from existing ones
03655     #  @param NewMeshName a name of the new mesh to create
03656     #  @return instance of Mesh class
03657     #  @ingroup l2_modif_trsf
03658     def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
03659         if IDsOfElements == []:
03660             IDsOfElements = self.GetElementsId()
03661         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03662             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03663         Mirror,Parameters = ParseAxisStruct(Mirror)
03664         mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
03665                                           MakeGroups, NewMeshName)
03666         mesh.SetParameters(Parameters)
03667         return Mesh(self.smeshpyD,self.geompyD,mesh)
03668 
03669     ## Creates a symmetrical copy of the object
03670     #  @param theObject mesh, submesh or group
03671     #  @param Mirror AxisStruct or geom object (point, line, plane)
03672     #  @param theMirrorType is  POINT, AXIS or PLANE
03673     #  If the Mirror is a geom object this parameter is unnecessary
03674     #  @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
03675     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03676     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03677     #  @ingroup l2_modif_trsf
03678     def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
03679         if ( isinstance( theObject, Mesh )):
03680             theObject = theObject.GetMesh()
03681         if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03682             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03683         Mirror,Parameters = ParseAxisStruct(Mirror)
03684         self.mesh.SetParameters(Parameters)
03685         if Copy and MakeGroups:
03686             return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
03687         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
03688         return []
03689 
03690     ## Creates a new mesh by a symmetrical copy of the object
03691     #  @param theObject mesh, submesh or group
03692     #  @param Mirror AxisStruct or geom object (point, line, plane)
03693     #  @param theMirrorType POINT, AXIS or PLANE
03694     #  If the Mirror is a geom object this parameter is unnecessary
03695     #  @param MakeGroups forces the generation of new groups from existing ones
03696     #  @param NewMeshName the name of the new mesh to create
03697     #  @return instance of Mesh class
03698     #  @ingroup l2_modif_trsf
03699     def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
03700         if ( isinstance( theObject, Mesh )):
03701             theObject = theObject.GetMesh()
03702         if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03703             Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03704         Mirror,Parameters = ParseAxisStruct(Mirror)
03705         mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
03706                                                 MakeGroups, NewMeshName)
03707         mesh.SetParameters(Parameters)
03708         return Mesh( self.smeshpyD,self.geompyD,mesh )
03709 
03710     ## Translates the elements
03711     #  @param IDsOfElements list of elements ids
03712     #  @param Vector the direction of translation (DirStruct or vector)
03713     #  @param Copy allows copying the translated elements
03714     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03715     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03716     #  @ingroup l2_modif_trsf
03717     def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
03718         if IDsOfElements == []:
03719             IDsOfElements = self.GetElementsId()
03720         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
03721             Vector = self.smeshpyD.GetDirStruct(Vector)
03722         Vector,Parameters = ParseDirStruct(Vector)
03723         self.mesh.SetParameters(Parameters)
03724         if Copy and MakeGroups:
03725             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
03726         self.editor.Translate(IDsOfElements, Vector, Copy)
03727         return []
03728 
03729     ## Creates a new mesh of translated elements
03730     #  @param IDsOfElements list of elements ids
03731     #  @param Vector the direction of translation (DirStruct or vector)
03732     #  @param MakeGroups forces the generation of new groups from existing ones
03733     #  @param NewMeshName the name of the newly created mesh
03734     #  @return instance of Mesh class
03735     #  @ingroup l2_modif_trsf
03736     def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
03737         if IDsOfElements == []:
03738             IDsOfElements = self.GetElementsId()
03739         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
03740             Vector = self.smeshpyD.GetDirStruct(Vector)
03741         Vector,Parameters = ParseDirStruct(Vector)
03742         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
03743         mesh.SetParameters(Parameters)
03744         return Mesh ( self.smeshpyD, self.geompyD, mesh )
03745 
03746     ## Translates the object
03747     #  @param theObject the object to translate (mesh, submesh, or group)
03748     #  @param Vector direction of translation (DirStruct or geom vector)
03749     #  @param Copy allows copying the translated elements
03750     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03751     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03752     #  @ingroup l2_modif_trsf
03753     def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
03754         if ( isinstance( theObject, Mesh )):
03755             theObject = theObject.GetMesh()
03756         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
03757             Vector = self.smeshpyD.GetDirStruct(Vector)
03758         Vector,Parameters = ParseDirStruct(Vector)
03759         self.mesh.SetParameters(Parameters)
03760         if Copy and MakeGroups:
03761             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
03762         self.editor.TranslateObject(theObject, Vector, Copy)
03763         return []
03764 
03765     ## Creates a new mesh from the translated object
03766     #  @param theObject the object to translate (mesh, submesh, or group)
03767     #  @param Vector the direction of translation (DirStruct or geom vector)
03768     #  @param MakeGroups forces the generation of new groups from existing ones
03769     #  @param NewMeshName the name of the newly created mesh
03770     #  @return instance of Mesh class
03771     #  @ingroup l2_modif_trsf
03772     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
03773         if (isinstance(theObject, Mesh)):
03774             theObject = theObject.GetMesh()
03775         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
03776             Vector = self.smeshpyD.GetDirStruct(Vector)
03777         Vector,Parameters = ParseDirStruct(Vector)
03778         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
03779         mesh.SetParameters(Parameters)
03780         return Mesh( self.smeshpyD, self.geompyD, mesh )
03781 
03782 
03783 
03784     ## Scales the object
03785     #  @param theObject - the object to translate (mesh, submesh, or group)
03786     #  @param thePoint - base point for scale
03787     #  @param theScaleFact - list of 1-3 scale factors for axises
03788     #  @param Copy - allows copying the translated elements
03789     #  @param MakeGroups - forces the generation of new groups from existing
03790     #                      ones (if Copy)
03791     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
03792     #          empty list otherwise
03793     def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
03794         if ( isinstance( theObject, Mesh )):
03795             theObject = theObject.GetMesh()
03796         if ( isinstance( theObject, list )):
03797             theObject = self.GetIDSource(theObject, SMESH.ALL)
03798 
03799         thePoint, Parameters = ParsePointStruct(thePoint)
03800         self.mesh.SetParameters(Parameters)
03801 
03802         if Copy and MakeGroups:
03803             return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
03804         self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
03805         return []
03806 
03807     ## Creates a new mesh from the translated object
03808     #  @param theObject - the object to translate (mesh, submesh, or group)
03809     #  @param thePoint - base point for scale
03810     #  @param theScaleFact - list of 1-3 scale factors for axises
03811     #  @param MakeGroups - forces the generation of new groups from existing ones
03812     #  @param NewMeshName - the name of the newly created mesh
03813     #  @return instance of Mesh class
03814     def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
03815         if (isinstance(theObject, Mesh)):
03816             theObject = theObject.GetMesh()
03817         if ( isinstance( theObject, list )):
03818             theObject = self.GetIDSource(theObject,SMESH.ALL)
03819 
03820         mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
03821                                          MakeGroups, NewMeshName)
03822         #mesh.SetParameters(Parameters)
03823         return Mesh( self.smeshpyD, self.geompyD, mesh )
03824 
03825 
03826 
03827     ## Rotates the elements
03828     #  @param IDsOfElements list of elements ids
03829     #  @param Axis the axis of rotation (AxisStruct or geom line)
03830     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
03831     #  @param Copy allows copying the rotated elements
03832     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03833     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03834     #  @ingroup l2_modif_trsf
03835     def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
03836         flag = False
03837         if isinstance(AngleInRadians,str):
03838             flag = True
03839         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
03840         if flag:
03841             AngleInRadians = DegreesToRadians(AngleInRadians)
03842         if IDsOfElements == []:
03843             IDsOfElements = self.GetElementsId()
03844         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03845             Axis = self.smeshpyD.GetAxisStruct(Axis)
03846         Axis,AxisParameters = ParseAxisStruct(Axis)
03847         Parameters = AxisParameters + var_separator + Parameters
03848         self.mesh.SetParameters(Parameters)
03849         if Copy and MakeGroups:
03850             return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
03851         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
03852         return []
03853 
03854     ## Creates a new mesh of rotated elements
03855     #  @param IDsOfElements list of element ids
03856     #  @param Axis the axis of rotation (AxisStruct or geom line)
03857     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
03858     #  @param MakeGroups forces the generation of new groups from existing ones
03859     #  @param NewMeshName the name of the newly created mesh
03860     #  @return instance of Mesh class
03861     #  @ingroup l2_modif_trsf
03862     def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
03863         flag = False
03864         if isinstance(AngleInRadians,str):
03865             flag = True
03866         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
03867         if flag:
03868             AngleInRadians = DegreesToRadians(AngleInRadians)
03869         if IDsOfElements == []:
03870             IDsOfElements = self.GetElementsId()
03871         if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03872             Axis = self.smeshpyD.GetAxisStruct(Axis)
03873         Axis,AxisParameters = ParseAxisStruct(Axis)
03874         Parameters = AxisParameters + var_separator + Parameters
03875         mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
03876                                           MakeGroups, NewMeshName)
03877         mesh.SetParameters(Parameters)
03878         return Mesh( self.smeshpyD, self.geompyD, mesh )
03879 
03880     ## Rotates the object
03881     #  @param theObject the object to rotate( mesh, submesh, or group)
03882     #  @param Axis the axis of rotation (AxisStruct or geom line)
03883     #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
03884     #  @param Copy allows copying the rotated elements
03885     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
03886     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
03887     #  @ingroup l2_modif_trsf
03888     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
03889         flag = False
03890         if isinstance(AngleInRadians,str):
03891             flag = True
03892         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
03893         if flag:
03894             AngleInRadians = DegreesToRadians(AngleInRadians)
03895         if (isinstance(theObject, Mesh)):
03896             theObject = theObject.GetMesh()
03897         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
03898             Axis = self.smeshpyD.GetAxisStruct(Axis)
03899         Axis,AxisParameters = ParseAxisStruct(Axis)
03900         Parameters = AxisParameters + ":" + Parameters
03901         self.mesh.SetParameters(Parameters)
03902         if Copy and MakeGroups:
03903             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
03904         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
03905         return []
03906 
03907     ## Creates a new mesh from the rotated object
03908     #  @param theObject the object to rotate (mesh, submesh, or group)
03909     #  @param Axis the axis of rotation (AxisStruct or geom line)
03910     #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
03911     #  @param MakeGroups forces the generation of new groups from existing ones
03912     #  @param NewMeshName the name of the newly created mesh
03913     #  @return instance of Mesh class
03914     #  @ingroup l2_modif_trsf
03915     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
03916         flag = False
03917         if isinstance(AngleInRadians,str):
03918             flag = True
03919         AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
03920         if flag:
03921             AngleInRadians = DegreesToRadians(AngleInRadians)
03922         if (isinstance( theObject, Mesh )):
03923             theObject = theObject.GetMesh()
03924         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
03925             Axis = self.smeshpyD.GetAxisStruct(Axis)
03926         Axis,AxisParameters = ParseAxisStruct(Axis)
03927         Parameters = AxisParameters + ":" + Parameters
03928         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
03929                                                        MakeGroups, NewMeshName)
03930         mesh.SetParameters(Parameters)
03931         return Mesh( self.smeshpyD, self.geompyD, mesh )
03932 
03933     ## Finds groups of ajacent nodes within Tolerance.
03934     #  @param Tolerance the value of tolerance
03935     #  @return the list of groups of nodes
03936     #  @ingroup l2_modif_trsf
03937     def FindCoincidentNodes (self, Tolerance):
03938         return self.editor.FindCoincidentNodes(Tolerance)
03939 
03940     ## Finds groups of ajacent nodes within Tolerance.
03941     #  @param Tolerance the value of tolerance
03942     #  @param SubMeshOrGroup SubMesh or Group
03943     #  @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
03944     #  @return the list of groups of nodes
03945     #  @ingroup l2_modif_trsf
03946     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
03947         if (isinstance( SubMeshOrGroup, Mesh )):
03948             SubMeshOrGroup = SubMeshOrGroup.GetMesh()
03949         if not isinstance( exceptNodes, list):
03950             exceptNodes = [ exceptNodes ]
03951         if exceptNodes and isinstance( exceptNodes[0], int):
03952             exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
03953         return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
03954 
03955     ## Merges nodes
03956     #  @param GroupsOfNodes the list of groups of nodes
03957     #  @ingroup l2_modif_trsf
03958     def MergeNodes (self, GroupsOfNodes):
03959         self.editor.MergeNodes(GroupsOfNodes)
03960 
03961     ## Finds the elements built on the same nodes.
03962     #  @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
03963     #  @return a list of groups of equal elements
03964     #  @ingroup l2_modif_trsf
03965     def FindEqualElements (self, MeshOrSubMeshOrGroup):
03966         if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
03967             MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
03968         return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
03969 
03970     ## Merges elements in each given group.
03971     #  @param GroupsOfElementsID groups of elements for merging
03972     #  @ingroup l2_modif_trsf
03973     def MergeElements(self, GroupsOfElementsID):
03974         self.editor.MergeElements(GroupsOfElementsID)
03975 
03976     ## Leaves one element and removes all other elements built on the same nodes.
03977     #  @ingroup l2_modif_trsf
03978     def MergeEqualElements(self):
03979         self.editor.MergeEqualElements()
03980 
03981     ## Sews free borders
03982     #  @return SMESH::Sew_Error
03983     #  @ingroup l2_modif_trsf
03984     def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
03985                         FirstNodeID2, SecondNodeID2, LastNodeID2,
03986                         CreatePolygons, CreatePolyedrs):
03987         return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
03988                                           FirstNodeID2, SecondNodeID2, LastNodeID2,
03989                                           CreatePolygons, CreatePolyedrs)
03990 
03991     ## Sews conform free borders
03992     #  @return SMESH::Sew_Error
03993     #  @ingroup l2_modif_trsf
03994     def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
03995                                FirstNodeID2, SecondNodeID2):
03996         return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
03997                                                  FirstNodeID2, SecondNodeID2)
03998 
03999     ## Sews border to side
04000     #  @return SMESH::Sew_Error
04001     #  @ingroup l2_modif_trsf
04002     def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
04003                          FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
04004         return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
04005                                            FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
04006 
04007     ## Sews two sides of a mesh. The nodes belonging to Side1 are
04008     #  merged with the nodes of elements of Side2.
04009     #  The number of elements in theSide1 and in theSide2 must be
04010     #  equal and they should have similar nodal connectivity.
04011     #  The nodes to merge should belong to side borders and
04012     #  the first node should be linked to the second.
04013     #  @return SMESH::Sew_Error
04014     #  @ingroup l2_modif_trsf
04015     def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
04016                          NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
04017                          NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
04018         return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
04019                                            NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
04020                                            NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
04021 
04022     ## Sets new nodes for the given element.
04023     #  @param ide the element id
04024     #  @param newIDs nodes ids
04025     #  @return If the number of nodes does not correspond to the type of element - returns false
04026     #  @ingroup l2_modif_edit
04027     def ChangeElemNodes(self, ide, newIDs):
04028         return self.editor.ChangeElemNodes(ide, newIDs)
04029 
04030     ## If during the last operation of MeshEditor some nodes were
04031     #  created, this method returns the list of their IDs, \n
04032     #  if new nodes were not created - returns empty list
04033     #  @return the list of integer values (can be empty)
04034     #  @ingroup l1_auxiliary
04035     def GetLastCreatedNodes(self):
04036         return self.editor.GetLastCreatedNodes()
04037 
04038     ## If during the last operation of MeshEditor some elements were
04039     #  created this method returns the list of their IDs, \n
04040     #  if new elements were not created - returns empty list
04041     #  @return the list of integer values (can be empty)
04042     #  @ingroup l1_auxiliary
04043     def GetLastCreatedElems(self):
04044         return self.editor.GetLastCreatedElems()
04045 
04046      ## Creates a hole in a mesh by doubling the nodes of some particular elements
04047     #  @param theNodes identifiers of nodes to be doubled
04048     #  @param theModifiedElems identifiers of elements to be updated by the new (doubled)
04049     #         nodes. If list of element identifiers is empty then nodes are doubled but
04050     #         they not assigned to elements
04051     #  @return TRUE if operation has been completed successfully, FALSE otherwise
04052     #  @ingroup l2_modif_edit
04053     def DoubleNodes(self, theNodes, theModifiedElems):
04054         return self.editor.DoubleNodes(theNodes, theModifiedElems)
04055 
04056     ## Creates a hole in a mesh by doubling the nodes of some particular elements
04057     #  This method provided for convenience works as DoubleNodes() described above.
04058     #  @param theNodeId identifiers of node to be doubled
04059     #  @param theModifiedElems identifiers of elements to be updated
04060     #  @return TRUE if operation has been completed successfully, FALSE otherwise
04061     #  @ingroup l2_modif_edit
04062     def DoubleNode(self, theNodeId, theModifiedElems):
04063         return self.editor.DoubleNode(theNodeId, theModifiedElems)
04064 
04065     ## Creates a hole in a mesh by doubling the nodes of some particular elements
04066     #  This method provided for convenience works as DoubleNodes() described above.
04067     #  @param theNodes group of nodes to be doubled
04068     #  @param theModifiedElems group of elements to be updated.
04069     #  @param theMakeGroup forces the generation of a group containing new nodes.
04070     #  @return TRUE or a created group if operation has been completed successfully,
04071     #          FALSE or None otherwise
04072     #  @ingroup l2_modif_edit
04073     def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
04074         if theMakeGroup:
04075             return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
04076         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
04077 
04078     ## Creates a hole in a mesh by doubling the nodes of some particular elements
04079     #  This method provided for convenience works as DoubleNodes() described above.
04080     #  @param theNodes list of groups of nodes to be doubled
04081     #  @param theModifiedElems list of groups of elements to be updated.
04082     #  @return TRUE if operation has been completed successfully, FALSE otherwise
04083     #  @ingroup l2_modif_edit
04084     def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
04085         if theMakeGroup:
04086             return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
04087         return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
04088 
04089     ## Creates a hole in a mesh by doubling the nodes of some particular elements
04090     #  @param theElems - the list of elements (edges or faces) to be replicated
04091     #         The nodes for duplication could be found from these elements
04092     #  @param theNodesNot - list of nodes to NOT replicate
04093     #  @param theAffectedElems - the list of elements (cells and edges) to which the
04094     #         replicated nodes should be associated to.
04095     #  @return TRUE if operation has been completed successfully, FALSE otherwise
04096     #  @ingroup l2_modif_edit
04097     def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
04098         return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
04099 
04100     ## Creates a hole in a mesh by doubling the nodes of some particular elements
04101     #  @param theElems - the list of elements (edges or faces) to be replicated
04102     #         The nodes for duplication could be found from these elements
04103     #  @param theNodesNot - list of nodes to NOT replicate
04104     #  @param theShape - shape to detect affected elements (element which geometric center
04105     #         located on or inside shape).
04106     #         The replicated nodes should be associated to affected elements.
04107     #  @return TRUE if operation has been completed successfully, FALSE otherwise
04108     #  @ingroup l2_modif_edit
04109     def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
04110         return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
04111 
04112     ## Creates a hole in a mesh by doubling the nodes of some particular elements
04113     #  This method provided for convenience works as DoubleNodes() described above.
04114     #  @param theElems - group of of elements (edges or faces) to be replicated
04115     #  @param theNodesNot - group of nodes not to replicated
04116     #  @param theAffectedElems - group of elements to which the replicated nodes
04117     #         should be associated to.
04118     #  @param theMakeGroup forces the generation of a group containing new elements.
04119     #  @return TRUE or a created group if operation has been completed successfully,
04120     #          FALSE or None otherwise
04121     #  @ingroup l2_modif_edit
04122     def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
04123         if theMakeGroup:
04124             return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
04125         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
04126 
04127     ## Creates a hole in a mesh by doubling the nodes of some particular elements
04128     #  This method provided for convenience works as DoubleNodes() described above.
04129     #  @param theElems - group of of elements (edges or faces) to be replicated
04130     #  @param theNodesNot - group of nodes not to replicated
04131     #  @param theShape - shape to detect affected elements (element which geometric center
04132     #         located on or inside shape).
04133     #         The replicated nodes should be associated to affected elements.
04134     #  @ingroup l2_modif_edit
04135     def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
04136         return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
04137 
04138     ## Creates a hole in a mesh by doubling the nodes of some particular elements
04139     #  This method provided for convenience works as DoubleNodes() described above.
04140     #  @param theElems - list of groups of elements (edges or faces) to be replicated
04141     #  @param theNodesNot - list of groups of nodes not to replicated
04142     #  @param theAffectedElems - group of elements to which the replicated nodes
04143     #         should be associated to.
04144     #  @param theMakeGroup forces the generation of a group containing new elements.
04145     #  @return TRUE or a created group if operation has been completed successfully,
04146     #          FALSE or None otherwise
04147     #  @ingroup l2_modif_edit
04148     def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
04149         if theMakeGroup:
04150             return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
04151         return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
04152 
04153     ## Creates a hole in a mesh by doubling the nodes of some particular elements
04154     #  This method provided for convenience works as DoubleNodes() described above.
04155     #  @param theElems - list of groups of elements (edges or faces) to be replicated
04156     #  @param theNodesNot - list of groups of nodes not to replicated
04157     #  @param theShape - shape to detect affected elements (element which geometric center
04158     #         located on or inside shape).
04159     #         The replicated nodes should be associated to affected elements.
04160     #  @return TRUE if operation has been completed successfully, FALSE otherwise
04161     #  @ingroup l2_modif_edit
04162     def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
04163         return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
04164 
04165     ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
04166     # The list of groups must describe a partition of the mesh volumes.
04167     # The nodes of the internal faces at the boundaries of the groups are doubled.
04168     # In option, the internal faces are replaced by flat elements.
04169     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
04170     # @param theDomains - list of groups of volumes
04171     # @param createJointElems - if TRUE, create the elements
04172     # @return TRUE if operation has been completed successfully, FALSE otherwise
04173     def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
04174        return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
04175 
04176     ## Double nodes on some external faces and create flat elements.
04177     # Flat elements are mainly used by some types of mechanic calculations.
04178     #
04179     # Each group of the list must be constituted of faces.
04180     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
04181     # @param theGroupsOfFaces - list of groups of faces
04182     # @return TRUE if operation has been completed successfully, FALSE otherwise
04183     def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
04184         return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
04185 
04186     def _valueFromFunctor(self, funcType, elemId):
04187         fn = self.smeshpyD.GetFunctor(funcType)
04188         fn.SetMesh(self.mesh)
04189         if fn.GetElementType() == self.GetElementType(elemId, True):
04190             val = fn.GetValue(elemId)
04191         else:
04192             val = 0
04193         return val
04194 
04195     ## Get length of 1D element.
04196     #  @param elemId mesh element ID
04197     #  @return element's length value
04198     #  @ingroup l1_measurements
04199     def GetLength(self, elemId):
04200         return self._valueFromFunctor(SMESH.FT_Length, elemId)
04201 
04202     ## Get area of 2D element.
04203     #  @param elemId mesh element ID
04204     #  @return element's area value
04205     #  @ingroup l1_measurements
04206     def GetArea(self, elemId):
04207         return self._valueFromFunctor(SMESH.FT_Area, elemId)
04208 
04209     ## Get volume of 3D element.
04210     #  @param elemId mesh element ID
04211     #  @return element's volume value
04212     #  @ingroup l1_measurements
04213     def GetVolume(self, elemId):
04214         return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
04215 
04216     ## Get maximum element length.
04217     #  @param elemId mesh element ID
04218     #  @return element's maximum length value
04219     #  @ingroup l1_measurements
04220     def GetMaxElementLength(self, elemId):
04221         if self.GetElementType(elemId, True) == SMESH.VOLUME:
04222             ftype = SMESH.FT_MaxElementLength3D
04223         else:
04224             ftype = SMESH.FT_MaxElementLength2D
04225         return self._valueFromFunctor(ftype, elemId)
04226 
04227     ## Get aspect ratio of 2D or 3D element.
04228     #  @param elemId mesh element ID
04229     #  @return element's aspect ratio value
04230     #  @ingroup l1_measurements
04231     def GetAspectRatio(self, elemId):
04232         if self.GetElementType(elemId, True) == SMESH.VOLUME:
04233             ftype = SMESH.FT_AspectRatio3D
04234         else:
04235             ftype = SMESH.FT_AspectRatio
04236         return self._valueFromFunctor(ftype, elemId)
04237 
04238     ## Get warping angle of 2D element.
04239     #  @param elemId mesh element ID
04240     #  @return element's warping angle value
04241     #  @ingroup l1_measurements
04242     def GetWarping(self, elemId):
04243         return self._valueFromFunctor(SMESH.FT_Warping, elemId)
04244 
04245     ## Get minimum angle of 2D element.
04246     #  @param elemId mesh element ID
04247     #  @return element's minimum angle value
04248     #  @ingroup l1_measurements
04249     def GetMinimumAngle(self, elemId):
04250         return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
04251 
04252     ## Get taper of 2D element.
04253     #  @param elemId mesh element ID
04254     #  @return element's taper value
04255     #  @ingroup l1_measurements
04256     def GetTaper(self, elemId):
04257         return self._valueFromFunctor(SMESH.FT_Taper, elemId)
04258 
04259     ## Get skew of 2D element.
04260     #  @param elemId mesh element ID
04261     #  @return element's skew value
04262     #  @ingroup l1_measurements
04263     def GetSkew(self, elemId):
04264         return self._valueFromFunctor(SMESH.FT_Skew, elemId)
04265 
04266 ## The mother class to define algorithm, it is not recommended to use it directly.
04267 #
04268 #  More details.
04269 #  @ingroup l2_algorithms
04270 class Mesh_Algorithm:
04271     #  @class Mesh_Algorithm
04272     #  @brief Class Mesh_Algorithm
04273 
04274     #def __init__(self,smesh):
04275     #    self.smesh=smesh
04276     def __init__(self):
04277         self.mesh = None
04278         self.geom = None
04279         self.subm = None
04280         self.algo = None
04281 
04282     ## Finds a hypothesis in the study by its type name and parameters.
04283     #  Finds only the hypotheses created in smeshpyD engine.
04284     #  @return SMESH.SMESH_Hypothesis
04285     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
04286         study = smeshpyD.GetCurrentStudy()
04287         #to do: find component by smeshpyD object, not by its data type
04288         scomp = study.FindComponent(smeshpyD.ComponentDataType())
04289         if scomp is not None:
04290             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
04291             # Check if the root label of the hypotheses exists
04292             if res and hypRoot is not None:
04293                 iter = study.NewChildIterator(hypRoot)
04294                 # Check all published hypotheses
04295                 while iter.More():
04296                     hypo_so_i = iter.Value()
04297                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
04298                     if attr is not None:
04299                         anIOR = attr.Value()
04300                         hypo_o_i = salome.orb.string_to_object(anIOR)
04301                         if hypo_o_i is not None:
04302                             # Check if this is a hypothesis
04303                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
04304                             if hypo_i is not None:
04305                                 # Check if the hypothesis belongs to current engine
04306                                 if smeshpyD.GetObjectId(hypo_i) > 0:
04307                                     # Check if this is the required hypothesis
04308                                     if hypo_i.GetName() == hypname:
04309                                         # Check arguments
04310                                         if CompareMethod(hypo_i, args):
04311                                             # found!!!
04312                                             return hypo_i
04313                                         pass
04314                                     pass
04315                                 pass
04316                             pass
04317                         pass
04318                     iter.Next()
04319                     pass
04320                 pass
04321             pass
04322         return None
04323 
04324     ## Finds the algorithm in the study by its type name.
04325     #  Finds only the algorithms, which have been created in smeshpyD engine.
04326     #  @return SMESH.SMESH_Algo
04327     def FindAlgorithm (self, algoname, smeshpyD):
04328         study = smeshpyD.GetCurrentStudy()
04329         #to do: find component by smeshpyD object, not by its data type
04330         scomp = study.FindComponent(smeshpyD.ComponentDataType())
04331         if scomp is not None:
04332             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
04333             # Check if the root label of the algorithms exists
04334             if res and hypRoot is not None:
04335                 iter = study.NewChildIterator(hypRoot)
04336                 # Check all published algorithms
04337                 while iter.More():
04338                     algo_so_i = iter.Value()
04339                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
04340                     if attr is not None:
04341                         anIOR = attr.Value()
04342                         algo_o_i = salome.orb.string_to_object(anIOR)
04343                         if algo_o_i is not None:
04344                             # Check if this is an algorithm
04345                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
04346                             if algo_i is not None:
04347                                 # Checks if the algorithm belongs to the current engine
04348                                 if smeshpyD.GetObjectId(algo_i) > 0:
04349                                     # Check if this is the required algorithm
04350                                     if algo_i.GetName() == algoname:
04351                                         # found!!!
04352                                         return algo_i
04353                                     pass
04354                                 pass
04355                             pass
04356                         pass
04357                     iter.Next()
04358                     pass
04359                 pass
04360             pass
04361         return None
04362 
04363     ## If the algorithm is global, returns 0; \n
04364     #  else returns the submesh associated to this algorithm.
04365     def GetSubMesh(self):
04366         return self.subm
04367 
04368     ## Returns the wrapped mesher.
04369     def GetAlgorithm(self):
04370         return self.algo
04371 
04372     ## Gets the list of hypothesis that can be used with this algorithm
04373     def GetCompatibleHypothesis(self):
04374         mylist = []
04375         if self.algo:
04376             mylist = self.algo.GetCompatibleHypothesis()
04377         return mylist
04378 
04379     ## Gets the name of the algorithm
04380     def GetName(self):
04381         GetName(self.algo)
04382 
04383     ## Sets the name to the algorithm
04384     def SetName(self, name):
04385         self.mesh.smeshpyD.SetName(self.algo, name)
04386 
04387     ## Gets the id of the algorithm
04388     def GetId(self):
04389         return self.algo.GetId()
04390 
04391     ## Private method.
04392     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
04393         if geom is None:
04394             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
04395         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
04396         if algo is None:
04397             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
04398             pass
04399         self.Assign(algo, mesh, geom)
04400         return self.algo
04401 
04402     ## Private method
04403     def Assign(self, algo, mesh, geom):
04404         if geom is None:
04405             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
04406         self.mesh = mesh
04407         name = ""
04408         if not geom:
04409             self.geom = mesh.geom
04410         else:
04411             self.geom = geom
04412             AssureGeomPublished( mesh, geom )
04413             try:
04414                 name = GetName(geom)
04415                 pass
04416             except:
04417                 pass
04418             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
04419         self.algo = algo
04420         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
04421         TreatHypoStatus( status, algo.GetName(), name, True )
04422         return
04423 
04424     def CompareHyp (self, hyp, args):
04425         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
04426         return False
04427 
04428     def CompareEqualHyp (self, hyp, args):
04429         return True
04430 
04431     ## Private method
04432     def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
04433                     UseExisting=0, CompareMethod=""):
04434         hypo = None
04435         if UseExisting:
04436             if CompareMethod == "": CompareMethod = self.CompareHyp
04437             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
04438             pass
04439         if hypo is None:
04440             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
04441             a = ""
04442             s = "="
04443             i = 0
04444             n = len(args)
04445             while i<n:
04446                 a = a + s + str(args[i])
04447                 s = ","
04448                 i = i + 1
04449                 pass
04450             self.mesh.smeshpyD.SetName(hypo, hyp + a)
04451             pass
04452         geomName=""
04453         if self.geom:
04454             geomName = GetName(self.geom)
04455         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
04456         TreatHypoStatus( status, GetName(hypo), geomName, 0 )
04457         return hypo
04458 
04459     ## Returns entry of the shape to mesh in the study
04460     def MainShapeEntry(self):
04461         entry = ""
04462         if not self.mesh or not self.mesh.GetMesh(): return entry
04463         if not self.mesh.GetMesh().HasShapeToMesh(): return entry
04464         study = self.mesh.smeshpyD.GetCurrentStudy()
04465         ior  = salome.orb.object_to_string( self.mesh.GetShape() )
04466         sobj = study.FindObjectIOR(ior)
04467         if sobj: entry = sobj.GetID()
04468         if not entry: return ""
04469         return entry
04470 
04471     ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
04472     #  near mesh boundary. This hypothesis can be used by several 3D algorithms:
04473     #  NETGEN 3D, GHS3D, Hexahedron(i,j,k)
04474     #  @param thickness total thickness of layers of prisms
04475     #  @param numberOfLayers number of layers of prisms
04476     #  @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
04477     #  @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
04478     #  @ingroup l3_hypos_additi
04479     def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
04480         if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
04481             raise TypeError, "ViscousLayers are supported by 3D algorithms only"
04482         if not "ViscousLayers" in self.GetCompatibleHypothesis():
04483             raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
04484         if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
04485             ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
04486         hyp = self.Hypothesis("ViscousLayers",
04487                               [thickness, numberOfLayers, stretchFactor, ignoreFaces])
04488         hyp.SetTotalThickness(thickness)
04489         hyp.SetNumberLayers(numberOfLayers)
04490         hyp.SetStretchFactor(stretchFactor)
04491         hyp.SetIgnoreFaces(ignoreFaces)
04492         return hyp
04493 
04494 # Public class: Mesh_Segment
04495 # --------------------------
04496 
04497 ## Class to define a segment 1D algorithm for discretization
04498 #
04499 #  More details.
04500 #  @ingroup l3_algos_basic
04501 class Mesh_Segment(Mesh_Algorithm):
04502 
04503     ## Private constructor.
04504     def __init__(self, mesh, geom=0):
04505         Mesh_Algorithm.__init__(self)
04506         self.Create(mesh, geom, "Regular_1D")
04507 
04508     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
04509     #  @param l for the length of segments that cut an edge
04510     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
04511     #                    the same parameters, else (default) - creates a new one
04512     #  @param p precision, used for calculation of the number of segments.
04513     #           The precision should be a positive, meaningful value within the range [0,1].
04514     #           In general, the number of segments is calculated with the formula:
04515     #           nb = ceil((edge_length / l) - p)
04516     #           Function ceil rounds its argument to the higher integer.
04517     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
04518     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
04519     #               p=1 means rounding of (edge_length / l) to the lower integer.
04520     #           Default value is 1e-07.
04521     #  @return an instance of StdMeshers_LocalLength hypothesis
04522     #  @ingroup l3_hypos_1dhyps
04523     def LocalLength(self, l, UseExisting=0, p=1e-07):
04524         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
04525                               CompareMethod=self.CompareLocalLength)
04526         hyp.SetLength(l)
04527         hyp.SetPrecision(p)
04528         return hyp
04529 
04530     ## Private method
04531     ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
04532     def CompareLocalLength(self, hyp, args):
04533         if IsEqual(hyp.GetLength(), args[0]):
04534             return IsEqual(hyp.GetPrecision(), args[1])
04535         return False
04536 
04537     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
04538     #  @param length is optional maximal allowed length of segment, if it is omitted
04539     #                the preestimated length is used that depends on geometry size
04540     #  @param UseExisting if ==true - searches for an existing hypothesis created with
04541     #                     the same parameters, else (default) - create a new one
04542     #  @return an instance of StdMeshers_MaxLength hypothesis
04543     #  @ingroup l3_hypos_1dhyps
04544     def MaxSize(self, length=0.0, UseExisting=0):
04545         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
04546         if length > 0.0:
04547             # set given length
04548             hyp.SetLength(length)
04549         if not UseExisting:
04550             # set preestimated length
04551             gen = self.mesh.smeshpyD
04552             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
04553                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
04554                                                        False) # <- byMesh
04555             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
04556             if preHyp:
04557                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
04558                 pass
04559             pass
04560         hyp.SetUsePreestimatedLength( length == 0.0 )
04561         return hyp
04562 
04563     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
04564     #  @param n for the number of segments that cut an edge
04565     #  @param s for the scale factor (optional)
04566     #  @param reversedEdges is a list of edges to mesh using reversed orientation
04567     #  @param UseExisting if ==true - searches for an existing hypothesis created with
04568     #                     the same parameters, else (default) - create a new one
04569     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
04570     #  @ingroup l3_hypos_1dhyps
04571     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
04572         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
04573             reversedEdges, UseExisting = [], reversedEdges
04574         entry = self.MainShapeEntry()
04575         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
04576             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
04577         if s == []:
04578             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
04579                                   UseExisting=UseExisting,
04580                                   CompareMethod=self.CompareNumberOfSegments)
04581         else:
04582             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
04583                                   UseExisting=UseExisting,
04584                                   CompareMethod=self.CompareNumberOfSegments)
04585             hyp.SetDistrType( 1 )
04586             hyp.SetScaleFactor(s)
04587         hyp.SetNumberOfSegments(n)
04588         hyp.SetReversedEdges( reversedEdges )
04589         hyp.SetObjectEntry( entry )
04590         return hyp
04591 
04592     ## Private method
04593     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
04594     def CompareNumberOfSegments(self, hyp, args):
04595         if hyp.GetNumberOfSegments() == args[0]:
04596             if len(args) == 3:
04597                 if hyp.GetReversedEdges() == args[1]:
04598                     if not args[1] or hyp.GetObjectEntry() == args[2]:
04599                         return True
04600             else:
04601                 if hyp.GetReversedEdges() == args[2]:
04602                     if not args[2] or hyp.GetObjectEntry() == args[3]:
04603                         if hyp.GetDistrType() == 1:
04604                             if IsEqual(hyp.GetScaleFactor(), args[1]):
04605                                 return True
04606         return False
04607 
04608     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
04609     #  @param start defines the length of the first segment
04610     #  @param end   defines the length of the last  segment
04611     #  @param reversedEdges is a list of edges to mesh using reversed orientation
04612     #  @param UseExisting if ==true - searches for an existing hypothesis created with
04613     #                     the same parameters, else (default) - creates a new one
04614     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
04615     #  @ingroup l3_hypos_1dhyps
04616     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
04617         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
04618             reversedEdges, UseExisting = [], reversedEdges
04619         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
04620             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
04621         entry = self.MainShapeEntry()
04622         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
04623                               UseExisting=UseExisting,
04624                               CompareMethod=self.CompareArithmetic1D)
04625         hyp.SetStartLength(start)
04626         hyp.SetEndLength(end)
04627         hyp.SetReversedEdges( reversedEdges )
04628         hyp.SetObjectEntry( entry )
04629         return hyp
04630 
04631     ## Private method
04632     ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
04633     def CompareArithmetic1D(self, hyp, args):
04634         if IsEqual(hyp.GetLength(1), args[0]):
04635             if IsEqual(hyp.GetLength(0), args[1]):
04636                 if hyp.GetReversedEdges() == args[2]:
04637                     if not args[2] or hyp.GetObjectEntry() == args[3]:
04638                         return True
04639         return False
04640 
04641 
04642     ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
04643     # on curve from 0 to 1 (additionally it is neecessary to check
04644     # orientation of edges and create list of reversed edges if it is
04645     # needed) and sets numbers of segments between given points (default
04646     # values are equals 1
04647     #  @param points defines the list of parameters on curve
04648     #  @param nbSegs defines the list of numbers of segments
04649     #  @param reversedEdges is a list of edges to mesh using reversed orientation
04650     #  @param UseExisting if ==true - searches for an existing hypothesis created with
04651     #                     the same parameters, else (default) - creates a new one
04652     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
04653     #  @ingroup l3_hypos_1dhyps
04654     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
04655         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
04656             reversedEdges, UseExisting = [], reversedEdges
04657         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
04658             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
04659         entry = self.MainShapeEntry()
04660         hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
04661                               UseExisting=UseExisting,
04662                               CompareMethod=self.CompareFixedPoints1D)
04663         hyp.SetPoints(points)
04664         hyp.SetNbSegments(nbSegs)
04665         hyp.SetReversedEdges(reversedEdges)
04666         hyp.SetObjectEntry(entry)
04667         return hyp
04668 
04669     ## Private method
04670     ## Check if the given "FixedPoints1D" hypothesis has the same parameters
04671     ## as the given arguments
04672     def CompareFixedPoints1D(self, hyp, args):
04673         if hyp.GetPoints() == args[0]:
04674             if hyp.GetNbSegments() == args[1]:
04675                 if hyp.GetReversedEdges() == args[2]:
04676                     if not args[2] or hyp.GetObjectEntry() == args[3]:
04677                         return True
04678         return False
04679 
04680 
04681 
04682     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
04683     #  @param start defines the length of the first segment
04684     #  @param end   defines the length of the last  segment
04685     #  @param reversedEdges is a list of edges to mesh using reversed orientation
04686     #  @param UseExisting if ==true - searches for an existing hypothesis created with
04687     #                     the same parameters, else (default) - creates a new one
04688     #  @return an instance of StdMeshers_StartEndLength hypothesis
04689     #  @ingroup l3_hypos_1dhyps
04690     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
04691         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
04692             reversedEdges, UseExisting = [], reversedEdges
04693         if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
04694             reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
04695         entry = self.MainShapeEntry()
04696         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
04697                               UseExisting=UseExisting,
04698                               CompareMethod=self.CompareStartEndLength)
04699         hyp.SetStartLength(start)
04700         hyp.SetEndLength(end)
04701         hyp.SetReversedEdges( reversedEdges )
04702         hyp.SetObjectEntry( entry )
04703         return hyp
04704 
04705     ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
04706     def CompareStartEndLength(self, hyp, args):
04707         if IsEqual(hyp.GetLength(1), args[0]):
04708             if IsEqual(hyp.GetLength(0), args[1]):
04709                 if hyp.GetReversedEdges() == args[2]:
04710                     if not args[2] or hyp.GetObjectEntry() == args[3]:
04711                         return True
04712         return False
04713 
04714     ## Defines "Deflection1D" hypothesis
04715     #  @param d for the deflection
04716     #  @param UseExisting if ==true - searches for an existing hypothesis created with
04717     #                     the same parameters, else (default) - create a new one
04718     #  @ingroup l3_hypos_1dhyps
04719     def Deflection1D(self, d, UseExisting=0):
04720         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
04721                               CompareMethod=self.CompareDeflection1D)
04722         hyp.SetDeflection(d)
04723         return hyp
04724 
04725     ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
04726     def CompareDeflection1D(self, hyp, args):
04727         return IsEqual(hyp.GetDeflection(), args[0])
04728 
04729     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
04730     #  the opposite side in case of quadrangular faces
04731     #  @ingroup l3_hypos_additi
04732     def Propagation(self):
04733         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
04734 
04735     ## Defines "AutomaticLength" hypothesis
04736     #  @param fineness for the fineness [0-1]
04737     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
04738     #                     same parameters, else (default) - create a new one
04739     #  @ingroup l3_hypos_1dhyps
04740     def AutomaticLength(self, fineness=0, UseExisting=0):
04741         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
04742                               CompareMethod=self.CompareAutomaticLength)
04743         hyp.SetFineness( fineness )
04744         return hyp
04745 
04746     ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
04747     def CompareAutomaticLength(self, hyp, args):
04748         return IsEqual(hyp.GetFineness(), args[0])
04749 
04750     ## Defines "SegmentLengthAroundVertex" hypothesis
04751     #  @param length for the segment length
04752     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
04753     #         Any other integer value means that the hypothesis will be set on the
04754     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
04755     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
04756     #                   the same parameters, else (default) - creates a new one
04757     #  @ingroup l3_algos_segmarv
04758     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
04759         import types
04760         store_geom = self.geom
04761         if type(vertex) is types.IntType:
04762             if vertex == 0 or vertex == 1:
04763                 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
04764                 self.geom = vertex
04765                 pass
04766             pass
04767         else:
04768             self.geom = vertex
04769             pass
04770         ### 0D algorithm
04771         if self.geom is None:
04772             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
04773         AssureGeomPublished( self.mesh, self.geom )
04774         name = GetName(self.geom)
04775 
04776         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
04777         if algo is None:
04778             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
04779             pass
04780         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
04781         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
04782         ###
04783         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
04784                               CompareMethod=self.CompareLengthNearVertex)
04785         self.geom = store_geom
04786         hyp.SetLength( length )
04787         return hyp
04788 
04789     ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
04790     #  @ingroup l3_algos_segmarv
04791     def CompareLengthNearVertex(self, hyp, args):
04792         return IsEqual(hyp.GetLength(), args[0])
04793 
04794     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
04795     #  If the 2D mesher sees that all boundary edges are quadratic,
04796     #  it generates quadratic faces, else it generates linear faces using
04797     #  medium nodes as if they are vertices.
04798     #  The 3D mesher generates quadratic volumes only if all boundary faces
04799     #  are quadratic, else it fails.
04800     #
04801     #  @ingroup l3_hypos_additi
04802     def QuadraticMesh(self):
04803         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
04804         return hyp
04805 
04806 # Public class: Mesh_CompositeSegment
04807 # --------------------------
04808 
04809 ## Defines a segment 1D algorithm for discretization
04810 #
04811 #  @ingroup l3_algos_basic
04812 class Mesh_CompositeSegment(Mesh_Segment):
04813 
04814     ## Private constructor.
04815     def __init__(self, mesh, geom=0):
04816         self.Create(mesh, geom, "CompositeSegment_1D")
04817 
04818 
04819 # Public class: Mesh_Segment_Python
04820 # ---------------------------------
04821 
04822 ## Defines a segment 1D algorithm for discretization with python function
04823 #
04824 #  @ingroup l3_algos_basic
04825 class Mesh_Segment_Python(Mesh_Segment):
04826 
04827     ## Private constructor.
04828     def __init__(self, mesh, geom=0):
04829         import Python1dPlugin
04830         self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
04831 
04832     ## Defines "PythonSplit1D" hypothesis
04833     #  @param n for the number of segments that cut an edge
04834     #  @param func for the python function that calculates the length of all segments
04835     #  @param UseExisting if ==true - searches for the existing hypothesis created with
04836     #                     the same parameters, else (default) - creates a new one
04837     #  @ingroup l3_hypos_1dhyps
04838     def PythonSplit1D(self, n, func, UseExisting=0):
04839         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
04840                               UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
04841         hyp.SetNumberOfSegments(n)
04842         hyp.SetPythonLog10RatioFunction(func)
04843         return hyp
04844 
04845     ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
04846     def ComparePythonSplit1D(self, hyp, args):
04847         #if hyp.GetNumberOfSegments() == args[0]:
04848         #    if hyp.GetPythonLog10RatioFunction() == args[1]:
04849         #        return True
04850         return False
04851 
04852 # Public class: Mesh_Triangle
04853 # ---------------------------
04854 
04855 ## Defines a triangle 2D algorithm
04856 #
04857 #  @ingroup l3_algos_basic
04858 class Mesh_Triangle(Mesh_Algorithm):
04859 
04860     # default values
04861     algoType = 0
04862     params = 0
04863 
04864     _angleMeshS = 8
04865     _gradation  = 1.1
04866 
04867     ## Private constructor.
04868     def __init__(self, mesh, algoType, geom=0):
04869         Mesh_Algorithm.__init__(self)
04870 
04871         self.algoType = algoType
04872         if algoType == MEFISTO:
04873             self.Create(mesh, geom, "MEFISTO_2D")
04874             pass
04875         elif algoType == BLSURF:
04876             CheckPlugin(BLSURF)
04877             self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
04878             #self.SetPhysicalMesh() - PAL19680
04879         elif algoType == NETGEN:
04880             CheckPlugin(NETGEN)
04881             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
04882             pass
04883         elif algoType == NETGEN_2D:
04884             CheckPlugin(NETGEN)
04885             self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
04886             pass
04887 
04888     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
04889     #  @param area for the maximum area of each triangle
04890     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
04891     #                     same parameters, else (default) - creates a new one
04892     #
04893     #  Only for algoType == MEFISTO || NETGEN_2D
04894     #  @ingroup l3_hypos_2dhyps
04895     def MaxElementArea(self, area, UseExisting=0):
04896         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
04897             hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
04898                                   CompareMethod=self.CompareMaxElementArea)
04899         elif self.algoType == NETGEN:
04900             hyp = self.Parameters(SIMPLE)
04901         hyp.SetMaxElementArea(area)
04902         return hyp
04903 
04904     ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
04905     def CompareMaxElementArea(self, hyp, args):
04906         return IsEqual(hyp.GetMaxElementArea(), args[0])
04907 
04908     ## Defines "LengthFromEdges" hypothesis to build triangles
04909     #  based on the length of the edges taken from the wire
04910     #
04911     #  Only for algoType == MEFISTO || NETGEN_2D
04912     #  @ingroup l3_hypos_2dhyps
04913     def LengthFromEdges(self):
04914         if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
04915             hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
04916             return hyp
04917         elif self.algoType == NETGEN:
04918             hyp = self.Parameters(SIMPLE)
04919             hyp.LengthFromEdges()
04920             return hyp
04921 
04922     ## Sets a way to define size of mesh elements to generate.
04923     #  @param thePhysicalMesh is: DefaultSize or Custom.
04924     #  @ingroup l3_hypos_blsurf
04925     def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
04926         # Parameter of BLSURF algo
04927         self.Parameters().SetPhysicalMesh(thePhysicalMesh)
04928 
04929     ## Sets size of mesh elements to generate.
04930     #  @ingroup l3_hypos_blsurf
04931     def SetPhySize(self, theVal):
04932         # Parameter of BLSURF algo
04933         self.SetPhysicalMesh(1) #Custom - else why to set the size?
04934         self.Parameters().SetPhySize(theVal)
04935 
04936     ## Sets lower boundary of mesh element size (PhySize).
04937     #  @ingroup l3_hypos_blsurf
04938     def SetPhyMin(self, theVal=-1):
04939         #  Parameter of BLSURF algo
04940         self.Parameters().SetPhyMin(theVal)
04941 
04942     ## Sets upper boundary of mesh element size (PhySize).
04943     #  @ingroup l3_hypos_blsurf
04944     def SetPhyMax(self, theVal=-1):
04945         #  Parameter of BLSURF algo
04946         self.Parameters().SetPhyMax(theVal)
04947 
04948     ## Sets a way to define maximum angular deflection of mesh from CAD model.
04949     #  @param theGeometricMesh is: 0 (None) or 1 (Custom)
04950     #  @ingroup l3_hypos_blsurf
04951     def SetGeometricMesh(self, theGeometricMesh=0):
04952         #  Parameter of BLSURF algo
04953         if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
04954         self.params.SetGeometricMesh(theGeometricMesh)
04955 
04956     ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
04957     #  @ingroup l3_hypos_blsurf
04958     def SetAngleMeshS(self, theVal=_angleMeshS):
04959         #  Parameter of BLSURF algo
04960         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
04961         self.params.SetAngleMeshS(theVal)
04962 
04963     ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
04964     #  @ingroup l3_hypos_blsurf
04965     def SetAngleMeshC(self, theVal=_angleMeshS):
04966         #  Parameter of BLSURF algo
04967         if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
04968         self.params.SetAngleMeshC(theVal)
04969 
04970     ## Sets lower boundary of mesh element size computed to respect angular deflection.
04971     #  @ingroup l3_hypos_blsurf
04972     def SetGeoMin(self, theVal=-1):
04973         #  Parameter of BLSURF algo
04974         self.Parameters().SetGeoMin(theVal)
04975 
04976     ## Sets upper boundary of mesh element size computed to respect angular deflection.
04977     #  @ingroup l3_hypos_blsurf
04978     def SetGeoMax(self, theVal=-1):
04979         #  Parameter of BLSURF algo
04980         self.Parameters().SetGeoMax(theVal)
04981 
04982     ## Sets maximal allowed ratio between the lengths of two adjacent edges.
04983     #  @ingroup l3_hypos_blsurf
04984     def SetGradation(self, theVal=_gradation):
04985         #  Parameter of BLSURF algo
04986         if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
04987         self.params.SetGradation(theVal)
04988 
04989     ## Sets topology usage way.
04990     # @param way defines how mesh conformity is assured <ul>
04991     # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
04992     # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
04993     #  @ingroup l3_hypos_blsurf
04994     def SetTopology(self, way):
04995         #  Parameter of BLSURF algo
04996         self.Parameters().SetTopology(way)
04997 
04998     ## To respect geometrical edges or not.
04999     #  @ingroup l3_hypos_blsurf
05000     def SetDecimesh(self, toIgnoreEdges=False):
05001         #  Parameter of BLSURF algo
05002         self.Parameters().SetDecimesh(toIgnoreEdges)
05003 
05004     ## Sets verbosity level in the range 0 to 100.
05005     #  @ingroup l3_hypos_blsurf
05006     def SetVerbosity(self, level):
05007         #  Parameter of BLSURF algo
05008         self.Parameters().SetVerbosity(level)
05009 
05010     ## Sets advanced option value.
05011     #  @ingroup l3_hypos_blsurf
05012     def SetOptionValue(self, optionName, level):
05013         #  Parameter of BLSURF algo
05014         self.Parameters().SetOptionValue(optionName,level)
05015 
05016     ## Sets an attractor on the chosen face. The mesh size will decrease exponentially with the distance from theAttractor, following the rule h(d) = theEndSize - (theEndSize - theStartSize) * exp [ - ( d / theInfluenceDistance ) ^ 2 ] 
05017     #  @param theFace      : face on which the attractor will be defined
05018     #  @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially   
05019     #  @param theStartSize : mesh size on theAttractor      
05020     #  @param theEndSize   : maximum size that will be reached on theFace                                                     
05021     #  @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)                                                      
05022     #  @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace                                                      
05023     #  @ingroup l3_hypos_blsurf
05024     def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
05025         AssureGeomPublished( self.mesh, theFace )
05026         AssureGeomPublished( self.mesh, theAttractor )
05027         #  Parameter of BLSURF algo
05028         self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
05029         
05030     ## Unsets an attractor on the chosen face. 
05031     #  @param theFace      : face on which the attractor has to be removed                               
05032     #  @ingroup l3_hypos_blsurf
05033     def UnsetAttractorGeom(self, theFace):
05034         AssureGeomPublished( self.mesh, theFace )
05035         #  Parameter of BLSURF algo
05036         self.Parameters().SetAttractorGeom(theFace)
05037 
05038     ## Sets QuadAllowed flag.
05039     #  Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
05040     #  @ingroup l3_hypos_netgen l3_hypos_blsurf
05041     def SetQuadAllowed(self, toAllow=True):
05042         if self.algoType == NETGEN_2D:
05043             if not self.params:
05044                 # use simple hyps
05045                 hasSimpleHyps = False
05046                 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
05047                 for hyp in self.mesh.GetHypothesisList( self.geom ):
05048                     if hyp.GetName() in simpleHyps:
05049                         hasSimpleHyps = True
05050                         if hyp.GetName() == "QuadranglePreference":
05051                             if not toAllow: # remove QuadranglePreference
05052                                 self.mesh.RemoveHypothesis( self.geom, hyp )
05053                                 pass
05054                             return
05055                         pass
05056                     pass
05057                 if hasSimpleHyps:
05058                     if toAllow: # add QuadranglePreference
05059                         self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
05060                         pass
05061                     return
05062                 pass
05063             pass
05064         if self.Parameters():
05065             self.params.SetQuadAllowed(toAllow)
05066             return
05067 
05068     ## Defines hypothesis having several parameters
05069     #
05070     #  @ingroup l3_hypos_netgen
05071     def Parameters(self, which=SOLE):
05072         if not self.params:
05073             if self.algoType == NETGEN:
05074                 if which == SIMPLE:
05075                     self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
05076                                                   "libNETGENEngine.so", UseExisting=0)
05077                 else:
05078                     self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
05079                                                   "libNETGENEngine.so", UseExisting=0)
05080             elif self.algoType == MEFISTO:
05081                 print "Mefisto algo support no multi-parameter hypothesis"
05082             elif self.algoType == NETGEN_2D:
05083                 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
05084                                               "libNETGENEngine.so", UseExisting=0)
05085             elif self.algoType == BLSURF:
05086                 self.params = self.Hypothesis("BLSURF_Parameters", [],
05087                                               "libBLSURFEngine.so", UseExisting=0)
05088             else:
05089                 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
05090         return self.params
05091 
05092     ## Sets MaxSize
05093     #
05094     #  Only for algoType == NETGEN
05095     #  @ingroup l3_hypos_netgen
05096     def SetMaxSize(self, theSize):
05097         if self.Parameters():
05098             self.params.SetMaxSize(theSize)
05099 
05100     ## Sets SecondOrder flag
05101     #
05102     #  Only for algoType == NETGEN
05103     #  @ingroup l3_hypos_netgen
05104     def SetSecondOrder(self, theVal):
05105         if self.Parameters():
05106             self.params.SetSecondOrder(theVal)
05107 
05108     ## Sets Optimize flag
05109     #
05110     #  Only for algoType == NETGEN
05111     #  @ingroup l3_hypos_netgen
05112     def SetOptimize(self, theVal):
05113         if self.Parameters():
05114             self.params.SetOptimize(theVal)
05115 
05116     ## Sets Fineness
05117     #  @param theFineness is:
05118     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
05119     #
05120     #  Only for algoType == NETGEN
05121     #  @ingroup l3_hypos_netgen
05122     def SetFineness(self, theFineness):
05123         if self.Parameters():
05124             self.params.SetFineness(theFineness)
05125 
05126     ## Sets GrowthRate
05127     #
05128     #  Only for algoType == NETGEN
05129     #  @ingroup l3_hypos_netgen
05130     def SetGrowthRate(self, theRate):
05131         if self.Parameters():
05132             self.params.SetGrowthRate(theRate)
05133 
05134     ## Sets NbSegPerEdge
05135     #
05136     #  Only for algoType == NETGEN
05137     #  @ingroup l3_hypos_netgen
05138     def SetNbSegPerEdge(self, theVal):
05139         if self.Parameters():
05140             self.params.SetNbSegPerEdge(theVal)
05141 
05142     ## Sets NbSegPerRadius
05143     #
05144     #  Only for algoType == NETGEN
05145     #  @ingroup l3_hypos_netgen
05146     def SetNbSegPerRadius(self, theVal):
05147         if self.Parameters():
05148             self.params.SetNbSegPerRadius(theVal)
05149 
05150     ## Sets number of segments overriding value set by SetLocalLength()
05151     #
05152     #  Only for algoType == NETGEN
05153     #  @ingroup l3_hypos_netgen
05154     def SetNumberOfSegments(self, theVal):
05155         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
05156 
05157     ## Sets number of segments overriding value set by SetNumberOfSegments()
05158     #
05159     #  Only for algoType == NETGEN
05160     #  @ingroup l3_hypos_netgen
05161     def SetLocalLength(self, theVal):
05162         self.Parameters(SIMPLE).SetLocalLength(theVal)
05163 
05164     pass
05165 
05166 
05167 # Public class: Mesh_Quadrangle
05168 # -----------------------------
05169 
05170 ## Defines a quadrangle 2D algorithm
05171 #
05172 #  @ingroup l3_algos_basic
05173 class Mesh_Quadrangle(Mesh_Algorithm):
05174 
05175     params=0
05176 
05177     ## Private constructor.
05178     def __init__(self, mesh, geom=0):
05179         Mesh_Algorithm.__init__(self)
05180         self.Create(mesh, geom, "Quadrangle_2D")
05181         return
05182 
05183     ## Defines "QuadrangleParameters" hypothesis
05184     #  @param quadType defines the algorithm of transition between differently descretized
05185     #                  sides of a geometrical face:
05186     #  - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
05187     #                    area along the finer meshed sides.
05188     #  - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
05189     #                    finer meshed sides.
05190     #  - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
05191     #                    the finer meshed sides, iff the total quantity of segments on
05192     #                    all four sides of the face is even (divisible by 2).
05193     #  - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
05194     #                    area is located along the coarser meshed sides.
05195     #  - QUAD_REDUCED - only quadrangles are built and the transition between the sides
05196     #                    is made gradually, layer by layer. This type has a limitation on
05197     #                    the number of segments: one pair of opposite sides must have the
05198     #                    same number of segments, the other pair must have an even difference
05199     #                    between the numbers of segments on the sides.
05200     #  @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
05201     #                  will be created while other elements will be quadrangles.
05202     #                  Vertex can be either a GEOM_Object or a vertex ID within the
05203     #                  shape to mesh
05204     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
05205     #                  the same parameters, else (default) - creates a new one
05206     #  @ingroup l3_hypos_quad
05207     def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
05208         vertexID = triangleVertex
05209         if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
05210             vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
05211         if not self.params:
05212             compFun = lambda hyp,args: \
05213                       hyp.GetQuadType() == args[0] and \
05214                       ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
05215             self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
05216                                           UseExisting = UseExisting, CompareMethod=compFun)
05217             pass
05218         if self.params.GetQuadType() != quadType:
05219             self.params.SetQuadType(quadType)
05220         if vertexID > 0:
05221             self.params.SetTriaVertex( vertexID )
05222         return self.params
05223 
05224     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
05225     #   quadrangles are built in the transition area along the finer meshed sides,
05226     #   iff the total quantity of segments on all four sides of the face is even.
05227     #  @param reversed if True, transition area is located along the coarser meshed sides.
05228     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
05229     #                  the same parameters, else (default) - creates a new one
05230     #  @ingroup l3_hypos_quad
05231     def QuadranglePreference(self, reversed=False, UseExisting=0):
05232         if reversed:
05233             return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
05234         return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
05235 
05236     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
05237     #   triangles are built in the transition area along the finer meshed sides.
05238     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
05239     #                  the same parameters, else (default) - creates a new one
05240     #  @ingroup l3_hypos_quad
05241     def TrianglePreference(self, UseExisting=0):
05242         return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
05243 
05244     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
05245     #   quadrangles are built and the transition between the sides is made gradually,
05246     #   layer by layer. This type has a limitation on the number of segments: one pair
05247     #   of opposite sides must have the same number of segments, the other pair must
05248     #   have an even difference between the numbers of segments on the sides.
05249     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
05250     #                  the same parameters, else (default) - creates a new one
05251     #  @ingroup l3_hypos_quad
05252     def Reduced(self, UseExisting=0):
05253         return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
05254 
05255     ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
05256     #  @param vertex: vertex of a trilateral geometrical face, around which triangles
05257     #                 will be created while other elements will be quadrangles.
05258     #                 Vertex can be either a GEOM_Object or a vertex ID within the
05259     #                 shape to mesh
05260     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
05261     #                   the same parameters, else (default) - creates a new one
05262     #  @ingroup l3_hypos_quad
05263     def TriangleVertex(self, vertex, UseExisting=0):
05264         return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
05265 
05266 
05267 # Public class: Mesh_Tetrahedron
05268 # ------------------------------
05269 
05270 ## Defines a tetrahedron 3D algorithm
05271 #
05272 #  @ingroup l3_algos_basic
05273 class Mesh_Tetrahedron(Mesh_Algorithm):
05274 
05275     params = 0
05276     algoType = 0
05277 
05278     ## Private constructor.
05279     def __init__(self, mesh, algoType, geom=0):
05280         Mesh_Algorithm.__init__(self)
05281 
05282         if algoType == NETGEN:
05283             CheckPlugin(NETGEN)
05284             self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
05285             pass
05286 
05287         elif algoType == FULL_NETGEN:
05288             CheckPlugin(NETGEN)
05289             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
05290             pass
05291 
05292         elif algoType == GHS3D:
05293             CheckPlugin(GHS3D)
05294             self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
05295             pass
05296 
05297         elif algoType == GHS3DPRL:
05298             CheckPlugin(GHS3DPRL)
05299             self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
05300             pass
05301 
05302         self.algoType = algoType
05303 
05304     ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
05305     #  @param vol for the maximum volume of each tetrahedron
05306     #  @param UseExisting if ==true - searches for the existing hypothesis created with
05307     #                   the same parameters, else (default) - creates a new one
05308     #  @ingroup l3_hypos_maxvol
05309     def MaxElementVolume(self, vol, UseExisting=0):
05310         if self.algoType == NETGEN:
05311             hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
05312                                   CompareMethod=self.CompareMaxElementVolume)
05313             hyp.SetMaxElementVolume(vol)
05314             return hyp
05315         elif self.algoType == FULL_NETGEN:
05316             self.Parameters(SIMPLE).SetMaxElementVolume(vol)
05317         return None
05318 
05319     ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
05320     def CompareMaxElementVolume(self, hyp, args):
05321         return IsEqual(hyp.GetMaxElementVolume(), args[0])
05322 
05323     ## Defines hypothesis having several parameters
05324     #
05325     #  @ingroup l3_hypos_netgen
05326     def Parameters(self, which=SOLE):
05327         if not self.params:
05328 
05329             if self.algoType == FULL_NETGEN:
05330                 if which == SIMPLE:
05331                     self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
05332                                                   "libNETGENEngine.so", UseExisting=0)
05333                 else:
05334                     self.params = self.Hypothesis("NETGEN_Parameters", [],
05335                                                   "libNETGENEngine.so", UseExisting=0)
05336 
05337             elif self.algoType == NETGEN:
05338                 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
05339                                               "libNETGENEngine.so", UseExisting=0)
05340 
05341             elif self.algoType == GHS3D:
05342                 self.params = self.Hypothesis("GHS3D_Parameters", [],
05343                                               "libGHS3DEngine.so", UseExisting=0)
05344 
05345             elif self.algoType == GHS3DPRL:
05346                 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
05347                                               "libGHS3DPRLEngine.so", UseExisting=0)
05348             else:
05349                 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
05350 
05351         return self.params
05352 
05353     ## Sets MaxSize
05354     #  Parameter of FULL_NETGEN and NETGEN
05355     #  @ingroup l3_hypos_netgen
05356     def SetMaxSize(self, theSize):
05357         self.Parameters().SetMaxSize(theSize)
05358 
05359     ## Sets SecondOrder flag
05360     #  Parameter of FULL_NETGEN
05361     #  @ingroup l3_hypos_netgen
05362     def SetSecondOrder(self, theVal):
05363         self.Parameters().SetSecondOrder(theVal)
05364 
05365     ## Sets Optimize flag
05366     #  Parameter of FULL_NETGEN and NETGEN
05367     #  @ingroup l3_hypos_netgen
05368     def SetOptimize(self, theVal):
05369         self.Parameters().SetOptimize(theVal)
05370 
05371     ## Sets Fineness
05372     #  @param theFineness is:
05373     #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
05374     #  Parameter of FULL_NETGEN
05375     #  @ingroup l3_hypos_netgen
05376     def SetFineness(self, theFineness):
05377         self.Parameters().SetFineness(theFineness)
05378 
05379     ## Sets GrowthRate
05380     #  Parameter of FULL_NETGEN
05381     #  @ingroup l3_hypos_netgen
05382     def SetGrowthRate(self, theRate):
05383         self.Parameters().SetGrowthRate(theRate)
05384 
05385     ## Sets NbSegPerEdge
05386     #  Parameter of FULL_NETGEN
05387     #  @ingroup l3_hypos_netgen
05388     def SetNbSegPerEdge(self, theVal):
05389         self.Parameters().SetNbSegPerEdge(theVal)
05390 
05391     ## Sets NbSegPerRadius
05392     #  Parameter of FULL_NETGEN
05393     #  @ingroup l3_hypos_netgen
05394     def SetNbSegPerRadius(self, theVal):
05395         self.Parameters().SetNbSegPerRadius(theVal)
05396 
05397     ## Sets number of segments overriding value set by SetLocalLength()
05398     #  Only for algoType == NETGEN_FULL
05399     #  @ingroup l3_hypos_netgen
05400     def SetNumberOfSegments(self, theVal):
05401         self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
05402 
05403     ## Sets number of segments overriding value set by SetNumberOfSegments()
05404     #  Only for algoType == NETGEN_FULL
05405     #  @ingroup l3_hypos_netgen
05406     def SetLocalLength(self, theVal):
05407         self.Parameters(SIMPLE).SetLocalLength(theVal)
05408 
05409     ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
05410     #  Overrides value set by LengthFromEdges()
05411     #  Only for algoType == NETGEN_FULL
05412     #  @ingroup l3_hypos_netgen
05413     def MaxElementArea(self, area):
05414         self.Parameters(SIMPLE).SetMaxElementArea(area)
05415 
05416     ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
05417     #  Overrides value set by MaxElementArea()
05418     #  Only for algoType == NETGEN_FULL
05419     #  @ingroup l3_hypos_netgen
05420     def LengthFromEdges(self):
05421         self.Parameters(SIMPLE).LengthFromEdges()
05422 
05423     ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
05424     #  Overrides value set by MaxElementVolume()
05425     #  Only for algoType == NETGEN_FULL
05426     #  @ingroup l3_hypos_netgen
05427     def LengthFromFaces(self):
05428         self.Parameters(SIMPLE).LengthFromFaces()
05429 
05430     ## To mesh "holes" in a solid or not. Default is to mesh.
05431     #  @ingroup l3_hypos_ghs3dh
05432     def SetToMeshHoles(self, toMesh):
05433         #  Parameter of GHS3D
05434         self.Parameters().SetToMeshHoles(toMesh)
05435 
05436     ## Set Optimization level:
05437     #   None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
05438     #   Strong_Optimization.
05439     # Default is Standard_Optimization
05440     #  @ingroup l3_hypos_ghs3dh
05441     def SetOptimizationLevel(self, level):
05442         #  Parameter of GHS3D
05443         self.Parameters().SetOptimizationLevel(level)
05444 
05445     ## Maximal size of memory to be used by the algorithm (in Megabytes).
05446     #  @ingroup l3_hypos_ghs3dh
05447     def SetMaximumMemory(self, MB):
05448         #  Advanced parameter of GHS3D
05449         self.Parameters().SetMaximumMemory(MB)
05450 
05451     ## Initial size of memory to be used by the algorithm (in Megabytes) in
05452     #  automatic memory adjustment mode.
05453     #  @ingroup l3_hypos_ghs3dh
05454     def SetInitialMemory(self, MB):
05455         #  Advanced parameter of GHS3D
05456         self.Parameters().SetInitialMemory(MB)
05457 
05458     ## Path to working directory.
05459     #  @ingroup l3_hypos_ghs3dh
05460     def SetWorkingDirectory(self, path):
05461         #  Advanced parameter of GHS3D
05462         self.Parameters().SetWorkingDirectory(path)
05463 
05464     ## To keep working files or remove them. Log file remains in case of errors anyway.
05465     #  @ingroup l3_hypos_ghs3dh
05466     def SetKeepFiles(self, toKeep):
05467         #  Advanced parameter of GHS3D and GHS3DPRL
05468         self.Parameters().SetKeepFiles(toKeep)
05469 
05470     ## To set verbose level [0-10]. <ul>
05471     #<li> 0 - no standard output,
05472     #<li> 2 - prints the data, quality statistics of the skin and final meshes and
05473     #     indicates when the final mesh is being saved. In addition the software
05474     #     gives indication regarding the CPU time.
05475     #<li>10 - same as 2 plus the main steps in the computation, quality statistics
05476     #     histogram of the skin mesh, quality statistics histogram together with
05477     #     the characteristics of the final mesh.</ul>
05478     #  @ingroup l3_hypos_ghs3dh
05479     def SetVerboseLevel(self, level):
05480         #  Advanced parameter of GHS3D
05481         self.Parameters().SetVerboseLevel(level)
05482 
05483     ## To create new nodes.
05484     #  @ingroup l3_hypos_ghs3dh
05485     def SetToCreateNewNodes(self, toCreate):
05486         #  Advanced parameter of GHS3D
05487         self.Parameters().SetToCreateNewNodes(toCreate)
05488 
05489     ## To use boundary recovery version which tries to create mesh on a very poor
05490     #  quality surface mesh.
05491     #  @ingroup l3_hypos_ghs3dh
05492     def SetToUseBoundaryRecoveryVersion(self, toUse):
05493         #  Advanced parameter of GHS3D
05494         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
05495 
05496     ## Applies finite-element correction by replacing overconstrained elements where
05497     #  it is possible. The process is cutting first the overconstrained edges and
05498     #  second the overconstrained facets. This insure that no edges have two boundary
05499     #  vertices and that no facets have three boundary vertices.
05500     #  @ingroup l3_hypos_ghs3dh
05501     def SetFEMCorrection(self, toUseFem):
05502         #  Advanced parameter of GHS3D
05503         self.Parameters().SetFEMCorrection(toUseFem)
05504 
05505     ## To removes initial central point.
05506     #  @ingroup l3_hypos_ghs3dh
05507     def SetToRemoveCentralPoint(self, toRemove):
05508         #  Advanced parameter of GHS3D
05509         self.Parameters().SetToRemoveCentralPoint(toRemove)
05510 
05511     ## To set an enforced vertex.
05512     #  @ingroup l3_hypos_ghs3dh
05513     def SetEnforcedVertex(self, x, y, z, size):
05514         #  Advanced parameter of GHS3D
05515         return self.Parameters().SetEnforcedVertex(x, y, z, size)
05516 
05517     ## To set an enforced vertex and add it in the group "groupName".
05518     #  Only on meshes w/o geometry
05519     #  @ingroup l3_hypos_ghs3dh
05520     def SetEnforcedVertexWithGroup(self, x, y, z, size, groupName):
05521         #  Advanced parameter of GHS3D
05522         return self.Parameters().SetEnforcedVertex(x, y, z, size,groupName)
05523 
05524     ## To remove an enforced vertex.
05525     #  @ingroup l3_hypos_ghs3dh
05526     def RemoveEnforcedVertex(self, x, y, z):
05527         #  Advanced parameter of GHS3D
05528         return self.Parameters().RemoveEnforcedVertex(x, y, z)
05529 
05530     ## To set an enforced vertex given a GEOM vertex, group or compound.
05531     #  @ingroup l3_hypos_ghs3dh
05532     def SetEnforcedVertexGeom(self, theVertex, size):
05533         AssureGeomPublished( self.mesh, theVertex )
05534         #  Advanced parameter of GHS3D
05535         return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
05536 
05537     ## To set an enforced vertex given a GEOM vertex, group or compound
05538     #  and add it in the group "groupName".
05539     #  Only on meshes w/o geometry
05540     #  @ingroup l3_hypos_ghs3dh
05541     def SetEnforcedVertexGeomWithGroup(self, theVertex, size, groupName):
05542         AssureGeomPublished( self.mesh, theVertex )
05543         #  Advanced parameter of GHS3D
05544         return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size,groupName)
05545 
05546     ## To remove an enforced vertex given a GEOM vertex, group or compound.
05547     #  @ingroup l3_hypos_ghs3dh
05548     def RemoveEnforcedVertexGeom(self, theVertex):
05549         AssureGeomPublished( self.mesh, theVertex )
05550         #  Advanced parameter of GHS3D
05551         return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
05552 
05553     ## To set an enforced mesh.
05554     #  @ingroup l3_hypos_ghs3dh
05555     def SetEnforcedMesh(self, theSource, elementType):
05556         #  Advanced parameter of GHS3D
05557         return self.Parameters().SetEnforcedMesh(theSource, elementType)
05558 
05559     ## To set an enforced mesh and add the enforced elements in the group "groupName".
05560     #  @ingroup l3_hypos_ghs3dh
05561     def SetEnforcedMeshWithGroup(self, theSource, elementType, groupName):
05562         #  Advanced parameter of GHS3D
05563         return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
05564 
05565     ## To set an enforced mesh with given size.
05566     #  @ingroup l3_hypos_ghs3dh
05567     def SetEnforcedMeshSize(self, theSource, elementType, size):
05568         #  Advanced parameter of GHS3D
05569         return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
05570 
05571     ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
05572     #  @ingroup l3_hypos_ghs3dh
05573     def SetEnforcedMeshSizeWithGroup(self, theSource, elementType, size, groupName):
05574         #  Advanced parameter of GHS3D
05575         return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
05576 
05577     ## Sets command line option as text.
05578     #  @ingroup l3_hypos_ghs3dh
05579     def SetTextOption(self, option):
05580         #  Advanced parameter of GHS3D
05581         self.Parameters().SetTextOption(option)
05582 
05583     ## Sets MED files name and path.
05584     def SetMEDName(self, value):
05585         self.Parameters().SetMEDName(value)
05586 
05587     ## Sets the number of partition of the initial mesh
05588     def SetNbPart(self, value):
05589         self.Parameters().SetNbPart(value)
05590 
05591     ## When big mesh, start tepal in background
05592     def SetBackground(self, value):
05593         self.Parameters().SetBackground(value)
05594 
05595 # Public class: Mesh_Hexahedron
05596 # ------------------------------
05597 
05598 ## Defines a hexahedron 3D algorithm
05599 #
05600 #  @ingroup l3_algos_basic
05601 class Mesh_Hexahedron(Mesh_Algorithm):
05602 
05603     params = 0
05604     algoType = 0
05605 
05606     ## Private constructor.
05607     def __init__(self, mesh, algoType=Hexa, geom=0):
05608         Mesh_Algorithm.__init__(self)
05609 
05610         self.algoType = algoType
05611 
05612         if algoType == Hexa:
05613             self.Create(mesh, geom, "Hexa_3D")
05614             pass
05615 
05616         elif algoType == Hexotic:
05617             CheckPlugin(Hexotic)
05618             self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
05619             pass
05620 
05621     ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
05622     #  @ingroup l3_hypos_hexotic
05623     def MinMaxQuad(self, min=3, max=8, quad=True):
05624         self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
05625                                       UseExisting=0)
05626         self.params.SetHexesMinLevel(min)
05627         self.params.SetHexesMaxLevel(max)
05628         self.params.SetHexoticQuadrangles(quad)
05629         return self.params
05630 
05631 # Deprecated, only for compatibility!
05632 # Public class: Mesh_Netgen
05633 # ------------------------------
05634 
05635 ## Defines a NETGEN-based 2D or 3D algorithm
05636 #  that needs no discrete boundary (i.e. independent)
05637 #
05638 #  This class is deprecated, only for compatibility!
05639 #
05640 #  More details.
05641 #  @ingroup l3_algos_basic
05642 class Mesh_Netgen(Mesh_Algorithm):
05643 
05644     is3D = 0
05645 
05646     ## Private constructor.
05647     def __init__(self, mesh, is3D, geom=0):
05648         Mesh_Algorithm.__init__(self)
05649 
05650         CheckPlugin(NETGEN)
05651 
05652         self.is3D = is3D
05653         if is3D:
05654             self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
05655             pass
05656 
05657         else:
05658             self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
05659             pass
05660 
05661     ## Defines the hypothesis containing parameters of the algorithm
05662     def Parameters(self):
05663         if self.is3D:
05664             hyp = self.Hypothesis("NETGEN_Parameters", [],
05665                                   "libNETGENEngine.so", UseExisting=0)
05666         else:
05667             hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
05668                                   "libNETGENEngine.so", UseExisting=0)
05669         return hyp
05670 
05671 # Public class: Mesh_Projection1D
05672 # ------------------------------
05673 
05674 ## Defines a projection 1D algorithm
05675 #  @ingroup l3_algos_proj
05676 #
05677 class Mesh_Projection1D(Mesh_Algorithm):
05678 
05679     ## Private constructor.
05680     def __init__(self, mesh, geom=0):
05681         Mesh_Algorithm.__init__(self)
05682         self.Create(mesh, geom, "Projection_1D")
05683 
05684     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
05685     #  a mesh pattern is taken, and, optionally, the association of vertices
05686     #  between the source edge and a target edge (to which a hypothesis is assigned)
05687     #  @param edge from which nodes distribution is taken
05688     #  @param mesh from which nodes distribution is taken (optional)
05689     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
05690     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
05691     #  to associate with \a srcV (optional)
05692     #  @param UseExisting if ==true - searches for the existing hypothesis created with
05693     #                     the same parameters, else (default) - creates a new one
05694     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
05695         AssureGeomPublished( self.mesh, edge )
05696         AssureGeomPublished( self.mesh, srcV )
05697         AssureGeomPublished( self.mesh, tgtV )
05698         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
05699                               UseExisting=0)
05700                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
05701         hyp.SetSourceEdge( edge )
05702         if not mesh is None and isinstance(mesh, Mesh):
05703             mesh = mesh.GetMesh()
05704         hyp.SetSourceMesh( mesh )
05705         hyp.SetVertexAssociation( srcV, tgtV )
05706         return hyp
05707 
05708     ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
05709     #def CompareSourceEdge(self, hyp, args):
05710     #    # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
05711     #    return False
05712 
05713 
05714 # Public class: Mesh_Projection2D
05715 # ------------------------------
05716 
05717 ## Defines a projection 2D algorithm
05718 #  @ingroup l3_algos_proj
05719 #
05720 class Mesh_Projection2D(Mesh_Algorithm):
05721 
05722     ## Private constructor.
05723     def __init__(self, mesh, geom=0):
05724         Mesh_Algorithm.__init__(self)
05725         self.Create(mesh, geom, "Projection_2D")
05726 
05727     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
05728     #  a mesh pattern is taken, and, optionally, the association of vertices
05729     #  between the source face and the target face (to which a hypothesis is assigned)
05730     #  @param face from which the mesh pattern is taken
05731     #  @param mesh from which the mesh pattern is taken (optional)
05732     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
05733     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
05734     #               to associate with \a srcV1 (optional)
05735     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
05736     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
05737     #               to associate with \a srcV2 (optional)
05738     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
05739     #                     the same parameters, else (default) - forces the creation a new one
05740     #
05741     #  Note: all association vertices must belong to one edge of a face
05742     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
05743                    srcV2=None, tgtV2=None, UseExisting=0):
05744         for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
05745             AssureGeomPublished( self.mesh, geom )
05746         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
05747                               UseExisting=0)
05748                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
05749         hyp.SetSourceFace( face )
05750         if isinstance(mesh, Mesh):
05751             mesh = mesh.GetMesh()
05752         hyp.SetSourceMesh( mesh )
05753         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
05754         return hyp
05755 
05756     ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
05757     #def CompareSourceFace(self, hyp, args):
05758     #    # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
05759     #    return False
05760 
05761 # Public class: Mesh_Projection3D
05762 # ------------------------------
05763 
05764 ## Defines a projection 3D algorithm
05765 #  @ingroup l3_algos_proj
05766 #
05767 class Mesh_Projection3D(Mesh_Algorithm):
05768 
05769     ## Private constructor.
05770     def __init__(self, mesh, geom=0):
05771         Mesh_Algorithm.__init__(self)
05772         self.Create(mesh, geom, "Projection_3D")
05773 
05774     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
05775     #  the mesh pattern is taken, and, optionally, the  association of vertices
05776     #  between the source and the target solid  (to which a hipothesis is assigned)
05777     #  @param solid from where the mesh pattern is taken
05778     #  @param mesh from where the mesh pattern is taken (optional)
05779     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
05780     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
05781     #  to associate with \a srcV1 (optional)
05782     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
05783     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
05784     #  to associate with \a srcV2 (optional)
05785     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
05786     #                     the same parameters, else (default) - creates a new one
05787     #
05788     #  Note: association vertices must belong to one edge of a solid
05789     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
05790                       srcV2=0, tgtV2=0, UseExisting=0):
05791         for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
05792             AssureGeomPublished( self.mesh, geom )
05793         hyp = self.Hypothesis("ProjectionSource3D",
05794                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
05795                               UseExisting=0)
05796                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
05797         hyp.SetSource3DShape( solid )
05798         if not mesh is None and isinstance(mesh, Mesh):
05799             mesh = mesh.GetMesh()
05800         hyp.SetSourceMesh( mesh )
05801         if srcV1 and srcV2 and tgtV1 and tgtV2:
05802             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
05803         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
05804         return hyp
05805 
05806     ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
05807     #def CompareSourceShape3D(self, hyp, args):
05808     #    # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
05809     #    return False
05810 
05811 
05812 # Public class: Mesh_Prism
05813 # ------------------------
05814 
05815 ## Defines a 3D extrusion algorithm
05816 #  @ingroup l3_algos_3dextr
05817 #
05818 class Mesh_Prism3D(Mesh_Algorithm):
05819 
05820     ## Private constructor.
05821     def __init__(self, mesh, geom=0):
05822         Mesh_Algorithm.__init__(self)
05823         self.Create(mesh, geom, "Prism_3D")
05824 
05825 # Public class: Mesh_RadialPrism
05826 # -------------------------------
05827 
05828 ## Defines a Radial Prism 3D algorithm
05829 #  @ingroup l3_algos_radialp
05830 #
05831 class Mesh_RadialPrism3D(Mesh_Algorithm):
05832 
05833     ## Private constructor.
05834     def __init__(self, mesh, geom=0):
05835         Mesh_Algorithm.__init__(self)
05836         self.Create(mesh, geom, "RadialPrism_3D")
05837 
05838         self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
05839         self.nbLayers = None
05840 
05841     ## Return 3D hypothesis holding the 1D one
05842     def Get3DHypothesis(self):
05843         return self.distribHyp
05844 
05845     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
05846     #  hypothesis. Returns the created hypothesis
05847     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
05848         #print "OwnHypothesis",hypType
05849         if not self.nbLayers is None:
05850             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
05851             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
05852         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
05853         self.mesh.smeshpyD.SetCurrentStudy( None )
05854         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
05855         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
05856         self.distribHyp.SetLayerDistribution( hyp )
05857         return hyp
05858 
05859     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
05860     #  prisms to build between the inner and outer shells
05861     #  @param n number of layers
05862     #  @param UseExisting if ==true - searches for the existing hypothesis created with
05863     #                     the same parameters, else (default) - creates a new one
05864     def NumberOfLayers(self, n, UseExisting=0):
05865         self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
05866         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
05867                                         CompareMethod=self.CompareNumberOfLayers)
05868         self.nbLayers.SetNumberOfLayers( n )
05869         return self.nbLayers
05870 
05871     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
05872     def CompareNumberOfLayers(self, hyp, args):
05873         return IsEqual(hyp.GetNumberOfLayers(), args[0])
05874 
05875     ## Defines "LocalLength" hypothesis, specifying the segment length
05876     #  to build between the inner and the outer shells
05877     #  @param l the length of segments
05878     #  @param p the precision of rounding
05879     def LocalLength(self, l, p=1e-07):
05880         hyp = self.OwnHypothesis("LocalLength", [l,p])
05881         hyp.SetLength(l)
05882         hyp.SetPrecision(p)
05883         return hyp
05884 
05885     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
05886     #  prisms to build between the inner and the outer shells.
05887     #  @param n the number of layers
05888     #  @param s the scale factor (optional)
05889     def NumberOfSegments(self, n, s=[]):
05890         if s == []:
05891             hyp = self.OwnHypothesis("NumberOfSegments", [n])
05892         else:
05893             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
05894             hyp.SetDistrType( 1 )
05895             hyp.SetScaleFactor(s)
05896         hyp.SetNumberOfSegments(n)
05897         return hyp
05898 
05899     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
05900     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
05901     #  @param start  the length of the first segment
05902     #  @param end    the length of the last  segment
05903     def Arithmetic1D(self, start, end ):
05904         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
05905         hyp.SetLength(start, 1)
05906         hyp.SetLength(end  , 0)
05907         return hyp
05908 
05909     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
05910     #  to build between the inner and the outer shells as geometric length increasing
05911     #  @param start for the length of the first segment
05912     #  @param end   for the length of the last  segment
05913     def StartEndLength(self, start, end):
05914         hyp = self.OwnHypothesis("StartEndLength", [start, end])
05915         hyp.SetLength(start, 1)
05916         hyp.SetLength(end  , 0)
05917         return hyp
05918 
05919     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
05920     #  to build between the inner and outer shells
05921     #  @param fineness defines the quality of the mesh within the range [0-1]
05922     def AutomaticLength(self, fineness=0):
05923         hyp = self.OwnHypothesis("AutomaticLength")
05924         hyp.SetFineness( fineness )
05925         return hyp
05926 
05927 # Public class: Mesh_RadialQuadrangle1D2D
05928 # -------------------------------
05929 
05930 ## Defines a Radial Quadrangle 1D2D algorithm
05931 #  @ingroup l2_algos_radialq
05932 #
05933 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
05934 
05935     ## Private constructor.
05936     def __init__(self, mesh, geom=0):
05937         Mesh_Algorithm.__init__(self)
05938         self.Create(mesh, geom, "RadialQuadrangle_1D2D")
05939 
05940         self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
05941         self.nbLayers = None
05942 
05943     ## Return 2D hypothesis holding the 1D one
05944     def Get2DHypothesis(self):
05945         return self.distribHyp
05946 
05947     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
05948     #  hypothesis. Returns the created hypothesis
05949     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
05950         #print "OwnHypothesis",hypType
05951         if self.nbLayers:
05952             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
05953         if self.distribHyp is None:
05954             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
05955         else:
05956             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
05957         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
05958         self.mesh.smeshpyD.SetCurrentStudy( None )
05959         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
05960         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
05961         self.distribHyp.SetLayerDistribution( hyp )
05962         return hyp
05963 
05964     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
05965     #  @param n number of layers
05966     #  @param UseExisting if ==true - searches for the existing hypothesis created with
05967     #                     the same parameters, else (default) - creates a new one
05968     def NumberOfLayers(self, n, UseExisting=0):
05969         if self.distribHyp:
05970             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
05971         self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
05972                                         CompareMethod=self.CompareNumberOfLayers)
05973         self.nbLayers.SetNumberOfLayers( n )
05974         return self.nbLayers
05975 
05976     ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
05977     def CompareNumberOfLayers(self, hyp, args):
05978         return IsEqual(hyp.GetNumberOfLayers(), args[0])
05979 
05980     ## Defines "LocalLength" hypothesis, specifying the segment length
05981     #  @param l the length of segments
05982     #  @param p the precision of rounding
05983     def LocalLength(self, l, p=1e-07):
05984         hyp = self.OwnHypothesis("LocalLength", [l,p])
05985         hyp.SetLength(l)
05986         hyp.SetPrecision(p)
05987         return hyp
05988 
05989     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
05990     #  @param n the number of layers
05991     #  @param s the scale factor (optional)
05992     def NumberOfSegments(self, n, s=[]):
05993         if s == []:
05994             hyp = self.OwnHypothesis("NumberOfSegments", [n])
05995         else:
05996             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
05997             hyp.SetDistrType( 1 )
05998             hyp.SetScaleFactor(s)
05999         hyp.SetNumberOfSegments(n)
06000         return hyp
06001 
06002     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
06003     #  with a length that changes in arithmetic progression
06004     #  @param start  the length of the first segment
06005     #  @param end    the length of the last  segment
06006     def Arithmetic1D(self, start, end ):
06007         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
06008         hyp.SetLength(start, 1)
06009         hyp.SetLength(end  , 0)
06010         return hyp
06011 
06012     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
06013     #  as geometric length increasing
06014     #  @param start for the length of the first segment
06015     #  @param end   for the length of the last  segment
06016     def StartEndLength(self, start, end):
06017         hyp = self.OwnHypothesis("StartEndLength", [start, end])
06018         hyp.SetLength(start, 1)
06019         hyp.SetLength(end  , 0)
06020         return hyp
06021 
06022     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
06023     #  @param fineness defines the quality of the mesh within the range [0-1]
06024     def AutomaticLength(self, fineness=0):
06025         hyp = self.OwnHypothesis("AutomaticLength")
06026         hyp.SetFineness( fineness )
06027         return hyp
06028 
06029 
06030 # Public class: Mesh_UseExistingElements
06031 # --------------------------------------
06032 ## Defines a Radial Quadrangle 1D2D algorithm
06033 #  @ingroup l3_algos_basic
06034 #
06035 class Mesh_UseExistingElements(Mesh_Algorithm):
06036 
06037     def __init__(self, dim, mesh, geom=0):
06038         if dim == 1:
06039             self.Create(mesh, geom, "Import_1D")
06040         else:
06041             self.Create(mesh, geom, "Import_1D2D")
06042         return
06043 
06044     ## Defines "Source edges" hypothesis, specifying groups of edges to import
06045     #  @param groups list of groups of edges
06046     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
06047     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
06048     #  @param UseExisting if ==true - searches for the existing hypothesis created with
06049     #                     the same parameters, else (default) - creates a new one
06050     def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
06051         if self.algo.GetName() == "Import_2D":
06052             raise ValueError, "algoritm dimension mismatch"
06053         for group in groups:
06054             AssureGeomPublished( self.mesh, group )
06055         hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
06056                               UseExisting=UseExisting, CompareMethod=self._compareHyp)
06057         hyp.SetSourceEdges(groups)
06058         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
06059         return hyp
06060 
06061     ## Defines "Source faces" hypothesis, specifying groups of faces to import
06062     #  @param groups list of groups of faces
06063     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
06064     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
06065     #  @param UseExisting if ==true - searches for the existing hypothesis created with
06066     #                     the same parameters, else (default) - creates a new one
06067     def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
06068         if self.algo.GetName() == "Import_1D":
06069             raise ValueError, "algoritm dimension mismatch"
06070         for group in groups:
06071             AssureGeomPublished( self.mesh, group )
06072         hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
06073                               UseExisting=UseExisting, CompareMethod=self._compareHyp)
06074         hyp.SetSourceFaces(groups)
06075         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
06076         return hyp
06077 
06078     def _compareHyp(self,hyp,args):
06079         if hasattr( hyp, "GetSourceEdges"):
06080             entries = hyp.GetSourceEdges()
06081         else:
06082             entries = hyp.GetSourceFaces()
06083         groups = args[0]
06084         toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
06085         if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
06086             entries2 = []
06087             study = self.mesh.smeshpyD.GetCurrentStudy()
06088             if study:
06089                 for g in groups:
06090                     ior  = salome.orb.object_to_string(g)
06091                     sobj = study.FindObjectIOR(ior)
06092                     if sobj: entries2.append( sobj.GetID() )
06093                     pass
06094                 pass
06095             entries.sort()
06096             entries2.sort()
06097             return entries == entries2
06098         return False
06099 
06100 
06101 # Private class: Mesh_UseExisting
06102 # -------------------------------
06103 class Mesh_UseExisting(Mesh_Algorithm):
06104 
06105     def __init__(self, dim, mesh, geom=0):
06106         if dim == 1:
06107             self.Create(mesh, geom, "UseExisting_1D")
06108         else:
06109             self.Create(mesh, geom, "UseExisting_2D")
06110 
06111 
06112 import salome_notebook
06113 notebook = salome_notebook.notebook
06114 
06115 ##Return values of the notebook variables
06116 def ParseParameters(last, nbParams,nbParam, value):
06117     result = None
06118     strResult = ""
06119     counter = 0
06120     listSize = len(last)
06121     for n in range(0,nbParams):
06122         if n+1 != nbParam:
06123             if counter < listSize:
06124                 strResult = strResult + last[counter]
06125             else:
06126                 strResult = strResult + ""
06127         else:
06128             if isinstance(value, str):
06129                 if notebook.isVariable(value):
06130                     result = notebook.get(value)
06131                     strResult=strResult+value
06132                 else:
06133                     raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
06134             else:
06135                 strResult=strResult+str(value)
06136                 result = value
06137         if nbParams - 1 != counter:
06138             strResult=strResult+var_separator #":"
06139         counter = counter+1
06140     return result, strResult
06141 
06142 #Wrapper class for StdMeshers_LocalLength hypothesis
06143 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
06144 
06145     ## Set Length parameter value
06146     #  @param length numerical value or name of variable from notebook
06147     def SetLength(self, length):
06148         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
06149         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
06150         StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
06151 
06152    ## Set Precision parameter value
06153    #  @param precision numerical value or name of variable from notebook
06154     def SetPrecision(self, precision):
06155         precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
06156         StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
06157         StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
06158 
06159 #Registering the new proxy for LocalLength
06160 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
06161 
06162 
06163 #Wrapper class for StdMeshers_LayerDistribution hypothesis
06164 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
06165 
06166     def SetLayerDistribution(self, hypo):
06167         StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
06168         hypo.ClearParameters();
06169         StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
06170 
06171 #Registering the new proxy for LayerDistribution
06172 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
06173 
06174 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
06175 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
06176 
06177     ## Set Length parameter value
06178     #  @param length numerical value or name of variable from notebook
06179     def SetLength(self, length):
06180         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
06181         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
06182         StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
06183 
06184 #Registering the new proxy for SegmentLengthAroundVertex
06185 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
06186 
06187 
06188 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
06189 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
06190 
06191     ## Set Length parameter value
06192     #  @param length   numerical value or name of variable from notebook
06193     #  @param isStart  true is length is Start Length, otherwise false
06194     def SetLength(self, length, isStart):
06195         nb = 2
06196         if isStart:
06197             nb = 1
06198         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
06199         StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
06200         StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
06201 
06202 #Registering the new proxy for Arithmetic1D
06203 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
06204 
06205 #Wrapper class for StdMeshers_Deflection1D hypothesis
06206 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
06207 
06208     ## Set Deflection parameter value
06209     #  @param deflection numerical value or name of variable from notebook
06210     def SetDeflection(self, deflection):
06211         deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
06212         StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
06213         StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
06214 
06215 #Registering the new proxy for Deflection1D
06216 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
06217 
06218 #Wrapper class for StdMeshers_StartEndLength hypothesis
06219 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
06220 
06221     ## Set Length parameter value
06222     #  @param length  numerical value or name of variable from notebook
06223     #  @param isStart true is length is Start Length, otherwise false
06224     def SetLength(self, length, isStart):
06225         nb = 2
06226         if isStart:
06227             nb = 1
06228         length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
06229         StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
06230         StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
06231 
06232 #Registering the new proxy for StartEndLength
06233 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
06234 
06235 #Wrapper class for StdMeshers_MaxElementArea hypothesis
06236 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
06237 
06238     ## Set Max Element Area parameter value
06239     #  @param area  numerical value or name of variable from notebook
06240     def SetMaxElementArea(self, area):
06241         area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
06242         StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
06243         StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
06244 
06245 #Registering the new proxy for MaxElementArea
06246 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
06247 
06248 
06249 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
06250 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
06251 
06252     ## Set Max Element Volume parameter value
06253     #  @param volume numerical value or name of variable from notebook
06254     def SetMaxElementVolume(self, volume):
06255         volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
06256         StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
06257         StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
06258 
06259 #Registering the new proxy for MaxElementVolume
06260 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
06261 
06262 
06263 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
06264 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
06265 
06266     ## Set Number Of Layers parameter value
06267     #  @param nbLayers  numerical value or name of variable from notebook
06268     def SetNumberOfLayers(self, nbLayers):
06269         nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
06270         StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
06271         StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
06272 
06273 #Registering the new proxy for NumberOfLayers
06274 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
06275 
06276 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
06277 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
06278 
06279     ## Set Number Of Segments parameter value
06280     #  @param nbSeg numerical value or name of variable from notebook
06281     def SetNumberOfSegments(self, nbSeg):
06282         lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
06283         nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
06284         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
06285         StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
06286 
06287     ## Set Scale Factor parameter value
06288     #  @param factor numerical value or name of variable from notebook
06289     def SetScaleFactor(self, factor):
06290         factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
06291         StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
06292         StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
06293 
06294 #Registering the new proxy for NumberOfSegments
06295 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
06296 
06297 if not noNETGENPlugin:
06298     #Wrapper class for NETGENPlugin_Hypothesis hypothesis
06299     class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
06300 
06301         ## Set Max Size parameter value
06302         #  @param maxsize numerical value or name of variable from notebook
06303         def SetMaxSize(self, maxsize):
06304             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
06305             maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
06306             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
06307             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
06308 
06309         ## Set Growth Rate parameter value
06310         #  @param value  numerical value or name of variable from notebook
06311         def SetGrowthRate(self, value):
06312             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
06313             value, parameters = ParseParameters(lastParameters,4,2,value)
06314             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
06315             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
06316 
06317         ## Set Number of Segments per Edge parameter value
06318         #  @param value  numerical value or name of variable from notebook
06319         def SetNbSegPerEdge(self, value):
06320             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
06321             value, parameters = ParseParameters(lastParameters,4,3,value)
06322             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
06323             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
06324 
06325         ## Set Number of Segments per Radius parameter value
06326         #  @param value  numerical value or name of variable from notebook
06327         def SetNbSegPerRadius(self, value):
06328             lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
06329             value, parameters = ParseParameters(lastParameters,4,4,value)
06330             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
06331             NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
06332 
06333     #Registering the new proxy for NETGENPlugin_Hypothesis
06334     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
06335 
06336 
06337     #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
06338     class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
06339         pass
06340 
06341     #Registering the new proxy for NETGENPlugin_Hypothesis_2D
06342     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
06343 
06344     #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
06345     class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
06346 
06347         ## Set Number of Segments parameter value
06348         #  @param nbSeg numerical value or name of variable from notebook
06349         def SetNumberOfSegments(self, nbSeg):
06350             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
06351             nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
06352             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
06353             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
06354 
06355         ## Set Local Length parameter value
06356         #  @param length numerical value or name of variable from notebook
06357         def SetLocalLength(self, length):
06358             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
06359             length, parameters = ParseParameters(lastParameters,2,1,length)
06360             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
06361             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
06362 
06363         ## Set Max Element Area parameter value
06364         #  @param area numerical value or name of variable from notebook
06365         def SetMaxElementArea(self, area):
06366             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
06367             area, parameters = ParseParameters(lastParameters,2,2,area)
06368             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
06369             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
06370 
06371         def LengthFromEdges(self):
06372             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
06373             value = 0;
06374             value, parameters = ParseParameters(lastParameters,2,2,value)
06375             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
06376             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
06377 
06378     #Registering the new proxy for NETGEN_SimpleParameters_2D
06379     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
06380 
06381 
06382     #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
06383     class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
06384         ## Set Max Element Volume parameter value
06385         #  @param volume numerical value or name of variable from notebook
06386         def SetMaxElementVolume(self, volume):
06387             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
06388             volume, parameters = ParseParameters(lastParameters,3,3,volume)
06389             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
06390             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
06391 
06392         def LengthFromFaces(self):
06393             lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
06394             value = 0;
06395             value, parameters = ParseParameters(lastParameters,3,3,value)
06396             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
06397             NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
06398 
06399     #Registering the new proxy for NETGEN_SimpleParameters_3D
06400     omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
06401 
06402     pass # if not noNETGENPlugin:
06403 
06404 class Pattern(SMESH._objref_SMESH_Pattern):
06405 
06406     def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
06407         flag = False
06408         if isinstance(theNodeIndexOnKeyPoint1,str):
06409             flag = True
06410         theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
06411         if flag:
06412             theNodeIndexOnKeyPoint1 -= 1
06413         theMesh.SetParameters(Parameters)
06414         return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
06415 
06416     def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
06417         flag0 = False
06418         flag1 = False
06419         if isinstance(theNode000Index,str):
06420             flag0 = True
06421         if isinstance(theNode001Index,str):
06422             flag1 = True
06423         theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
06424         if flag0:
06425             theNode000Index -= 1
06426         if flag1:
06427             theNode001Index -= 1
06428         theMesh.SetParameters(Parameters)
06429         return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
06430 
06431 #Registering the new proxy for Pattern
06432 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS