[PY3] 2to3 results

This commit is contained in:
Nicolas Geimer 2017-03-20 13:27:30 +01:00
parent 84cf6c4911
commit 5260bd00bd
297 changed files with 1874 additions and 1879 deletions

View File

@ -30,7 +30,7 @@ def set_env(args):
python_version="python%d.%d" % sys.version_info[0:2]
if not os.environ.has_key("SALOME_StdMeshersResources"):
if "SALOME_StdMeshersResources" not in os.environ:
os.environ["SALOME_StdMeshersResources"] \
= os.path.join(os.environ["SMESH_ROOT_DIR"],"share",salome_subdir,"resources","smesh")
pass
@ -38,7 +38,7 @@ def set_env(args):
# find plugins
plugin_list = ["StdMeshers"]
resource_path_list = []
for env_var in os.environ.keys():
for env_var in list(os.environ.keys()):
value = os.environ[env_var]
if env_var[-9:] == "_ROOT_DIR" and value:
plugin_root = value
@ -61,7 +61,7 @@ def set_env(args):
# add paths of plugin
plugin_list.append(plugin)
if not os.environ.has_key("SALOME_"+plugin+"Resources"):
if "SALOME_"+plugin+"Resources" not in os.environ:
resource_path = os.path.join(plugin_root,"share",salome_subdir,"resources",plugin.lower())
os.environ["SALOME_"+plugin+"Resources"] = resource_path
resource_path_list.append( resource_path )

View File

@ -22,23 +22,23 @@ mesh = smesh.Mesh( sphere )
cartAlgo = mesh.BodyFitted()
# define a cartesian grid using Coordinates
coords = range(-100,100,10)
coords = list(range(-100,100,10))
cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000)
# compute the mesh
mesh.Compute()
print "nb hexahedra",mesh.NbHexas()
print "nb tetrahedra",mesh.NbTetras()
print "nb polyhedra",mesh.NbPolyhedrons()
print
print("nb hexahedra",mesh.NbHexas())
print("nb tetrahedra",mesh.NbTetras())
print("nb polyhedra",mesh.NbPolyhedrons())
print()
# define the grid by setting constant spacing
cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000)
mesh.Compute()
print "nb hexahedra",mesh.NbHexas()
print "nb tetrahedra",mesh.NbTetras()
print "nb polyhedra",mesh.NbPolyhedrons()
print("nb hexahedra",mesh.NbHexas())
print("nb tetrahedra",mesh.NbTetras())
print("nb polyhedra",mesh.NbPolyhedrons())
# define the grid by setting different spacing in 2 sub-ranges of geometry
@ -46,10 +46,10 @@ spaceFuns = ["5","10+10*t"]
cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 10 )
mesh.Compute()
print "nb hexahedra",mesh.NbHexas()
print "nb tetrahedra",mesh.NbTetras()
print "nb polyhedra",mesh.NbPolyhedrons()
print
print("nb hexahedra",mesh.NbHexas())
print("nb tetrahedra",mesh.NbTetras())
print("nb polyhedra",mesh.NbPolyhedrons())
print()
# Example of customization of dirtections of the grid axes
@ -67,23 +67,23 @@ mesh = smesh.Mesh( box, "custom axes")
algo = mesh.BodyFitted()
algo.SetGrid( spc, spc, spc, 10000 )
mesh.Compute()
print "Default axes"
print " nb hex:",mesh.NbHexas()
print("Default axes")
print(" nb hex:",mesh.NbHexas())
# set axes using edges of the box
algo.SetAxesDirs( xDir, [-0.1,1,0], zDir )
mesh.Compute()
print "Manual axes"
print " nb hex:",mesh.NbHexas()
print("Manual axes")
print(" nb hex:",mesh.NbHexas())
# set optimal orthogonal axes
algo.SetOptimalAxesDirs( isOrthogonal=True )
mesh.Compute()
print "Optimal orthogonal axes"
print " nb hex:",mesh.NbHexas()
print("Optimal orthogonal axes")
print(" nb hex:",mesh.NbHexas())
# set optimal non-orthogonal axes
algo.SetOptimalAxesDirs( isOrthogonal=False )
mesh.Compute()
print "Optimal non-orthogonal axes"
print " nb hex:",mesh.NbHexas()
print("Optimal non-orthogonal axes")
print(" nb hex:",mesh.NbHexas())

View File

@ -29,7 +29,7 @@ algo3D.MaxElementVolume(900.)
# compute the mesh
ret = tetra.Compute()
if ret == 0:
print "problem when computing the mesh"
print("problem when computing the mesh")
else:
print "mesh computed"
print("mesh computed")
pass

View File

@ -45,15 +45,15 @@ SubMesh_3 = MEFISTO_2D_3.GetSubMesh()
# check exisiting sub-mesh priority order
[ [ SubMesh_1, SubMesh_3, SubMesh_2 ] ] = Mesh_1.GetMeshOrder()
isDone = Mesh_1.Compute()
print "Nb elements at initial order of sub-meshes:", Mesh_1.NbElements()
print("Nb elements at initial order of sub-meshes:", Mesh_1.NbElements())
# set new sub-mesh order
isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_1, SubMesh_2, SubMesh_3 ] ])
# compute mesh
isDone = Mesh_1.Compute()
print "Nb elements at new order of sub-meshes:", Mesh_1.NbElements()
print("Nb elements at new order of sub-meshes:", Mesh_1.NbElements())
# compute with other sub-mesh order
isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_2, SubMesh_1, SubMesh_3 ] ])
isDone = Mesh_1.Compute()
print "Nb elements at another order of sub-meshes:", Mesh_1.NbElements()
print("Nb elements at another order of sub-meshes:", Mesh_1.NbElements())

View File

@ -12,11 +12,11 @@ smesh = smeshBuilder.New(salome.myStudy)
def PrintMeshInfo(theMesh):
aMesh = theMesh.GetMesh()
print "Information about mesh:"
print "Number of nodes : ", aMesh.NbNodes()
print "Number of edges : ", aMesh.NbEdges()
print "Number of faces : ", aMesh.NbFaces()
print "Number of volumes : ", aMesh.NbVolumes()
print("Information about mesh:")
print("Number of nodes : ", aMesh.NbNodes())
print("Number of edges : ", aMesh.NbEdges())
print("Number of faces : ", aMesh.NbFaces())
print("Number of volumes : ", aMesh.NbVolumes())
pass
# create a box

View File

@ -47,12 +47,12 @@ import MEDLoader, os
# on XOY plane, and autoDimension=True by default
mesh2D.ExportMED( medFile )
medMesh = MEDLoader.MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0)
print "autoDimension==True, exported mesh is in %sD"%medMesh.getSpaceDimension()
print("autoDimension==True, exported mesh is in %sD"%medMesh.getSpaceDimension())
# exported mesh is in 3D space, same as in Mesh module,
# thanks to autoDimension=False
mesh2D.ExportMED( medFile, autoDimension=False )
medMesh = MEDLoader.MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0)
print "autoDimension==False, exported mesh is in %sD"%medMesh.getSpaceDimension()
print("autoDimension==False, exported mesh is in %sD"%medMesh.getSpaceDimension())
os.remove( medFile )

View File

@ -32,6 +32,6 @@ algo3D.MaxElementVolume(200.)
# compute the mesh
ret = tetra.Compute()
if ret == 0:
print "problem when computing the mesh"
print("problem when computing the mesh")
else:
print "Computation succeeded"
print("Computation succeeded")

View File

@ -2,11 +2,11 @@
# create mesh
from SMESH_mechanic import *
print
print()
# create a group of all faces (quadrangles) generated on sub_face3
quads_on_face3 = mesh.MakeGroup("quads_on_face3", SMESH.FACE, SMESH.FT_BelongToGeom,'=',sub_face3)
print "There are %s quadrangles generated on '%s' and included in the group '%s'" % ( quads_on_face3.Size(), sub_face3.GetName(), quads_on_face3.GetName() )
print("There are %s quadrangles generated on '%s' and included in the group '%s'" % ( quads_on_face3.Size(), sub_face3.GetName(), quads_on_face3.GetName() ))
# create a group of all the rest quadrangles, generated on other faces by combining 2 criteria:
# - negated FT_BelongToMeshGroup to select elements not included in quads_on_face3
@ -15,5 +15,5 @@ not_on_face3 = smesh.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=',qu
quadrangles = smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_QUADRANGLE )
rest_quads = mesh.MakeGroupByCriteria("rest_quads", [ not_on_face3, quadrangles ])
print "'%s' group includes all the rest %s quadrangles" % ( rest_quads.GetName(), rest_quads.Size() )
print("'%s' group includes all the rest %s quadrangles" % ( rest_quads.GetName(), rest_quads.Size() ))

View File

@ -7,38 +7,38 @@ from SMESH_mechanic import *
# get faces with aspect ratio > 2.5
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 2.5)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with aspect ratio > 2.5:", len(ids)
print("Number of faces with aspect ratio > 2.5:", len(ids))
# get faces with aspect ratio > 1.5
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, '>', 1.5, mesh=mesh)
ids = filter.GetIDs()
print "Number of faces with aspect ratio > 1.5:", len(ids)
print("Number of faces with aspect ratio > 1.5:", len(ids))
# copy the faces with aspect ratio > 1.5 to another mesh;
# this demostrates that a filter can be used where usually a group or sub-mesh is acceptable
filter.SetMesh( mesh.GetMesh() ) # - actually non necessary as mesh is set at filter creation
mesh2 = smesh.CopyMesh( filter, "AR > 1.5" )
print "Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces()
print("Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces())
# create a group (Group on Filter) of faces with Aspect Ratio < 1.5
group = mesh.MakeGroup("AR < 1.5", SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5)
print "Number of faces with aspect ratio < 1.5:", group.Size()
print("Number of faces with aspect ratio < 1.5:", group.Size())
# combine several criteria to Create a Group of only Triangular faces with Aspect Ratio < 1.5;
# note that contents of a GroupOnFilter is dynamically updated as the mesh changes
crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5, BinaryOp=SMESH.FT_LogicalAND ),
smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) ]
triaGroup = mesh.MakeGroupByCriteria( "Tria AR < 1.5", crit )
print "Number of triangles with aspect ratio < 1.5:", triaGroup.Size()
print("Number of triangles with aspect ratio < 1.5:", triaGroup.Size())
# get range of values of Aspect Ratio of all faces in the mesh
aspects = mesh.GetMinMax( SMESH.FT_AspectRatio )
print "MESH: Min aspect = %s, Max aspect = %s" % ( aspects[0], aspects[1] )
print("MESH: Min aspect = %s, Max aspect = %s" % ( aspects[0], aspects[1] ))
# get max value of Aspect Ratio of faces in triaGroup
grAspects = mesh.GetMinMax( SMESH.FT_AspectRatio, triaGroup )
print "GROUP: Max aspect = %s" % grAspects[1]
print("GROUP: Max aspect = %s" % grAspects[1])
# get Aspect Ratio of an element
aspect = mesh.FunctorValue( SMESH.FT_AspectRatio, ids[0] )
print "Aspect ratio of the face %s = %s" % ( ids[0], aspect )
print("Aspect ratio of the face %s = %s" % ( ids[0], aspect ))

View File

@ -7,4 +7,4 @@ mesh.Compute()
# get volumes with aspect ratio < 2.0
filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_LessThan, 2.0)
ids = mesh.GetIdsFromFilter(filter)
print "Number of volumes with aspect ratio < 2.0:", len(ids)
print("Number of volumes with aspect ratio < 2.0:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get faces with warping angle = 2.0e-13 with tolerance 5.0e-14
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping, "=", 2.0e-13, Tolerance=5.0e-14)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids)
print("Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get faces with minimum angle > 75
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle,">", 75)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with minimum angle > 75:", len(ids)
print("Number of faces with minimum angle > 75:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get faces with taper < 1.e-15
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_LessThan, 1.e-15)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with taper < 1.e-15:", len(ids)
print("Number of faces with taper < 1.e-15:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get faces with skew > 50
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, 50)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with skew > 50:", len(ids)
print("Number of faces with skew > 50:", len(ids))

View File

@ -7,4 +7,4 @@ criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60
criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90)
filter = smesh.GetFilterFromCriteria([criterion1,criterion2], SMESH.FT_LogicalAND)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with area in range (60,90):", len(ids)
print("Number of faces with area in range (60,90):", len(ids))

View File

@ -7,4 +7,4 @@ mesh.Compute()
# get volumes faces with volume > 100
filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_MoreThan, 100)
ids = mesh.GetIdsFromFilter(filter)
print "Number of volumes with volume > 100:", len(ids)
print("Number of volumes with volume > 100:", len(ids))

View File

@ -18,4 +18,4 @@ mesh.Compute()
# get all free borders
filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
ids = mesh.GetIdsFromFilter(filter)
print "Number of edges on free borders:", len(ids)
print("Number of edges on free borders:", len(ids))

View File

@ -19,4 +19,4 @@ mesh.Compute()
# get all faces with free edges
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeEdges)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with free edges:", len(ids)
print("Number of faces with free edges:", len(ids))

View File

@ -7,4 +7,4 @@ mesh.AddNode(0,0,0)
# get all free nodes
filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes)
ids = mesh.GetIdsFromFilter(filter)
print "Number of free nodes:", len(ids)
print("Number of free nodes:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get all free faces
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces)
ids = mesh.GetIdsFromFilter(filter)
print "Number of free faces:", len(ids)
print("Number of free faces:", len(ids))

View File

@ -7,4 +7,4 @@ mesh.RemoveElements( mesh.GetElementsByType(SMESH.FACE)[0:5] )
# get all faces with bare borders
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BareBorderFace)
ids = mesh.GetIdsFromFilter(filter)
print "Faces with bare borders:", ids
print("Faces with bare borders:", ids)

View File

@ -6,4 +6,4 @@ faceID = mesh.GetElementsByType(SMESH.FACE)[0]
# get all faces co-planar to the first face with tolerance 5 degrees
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_CoplanarFaces,faceID,Tolerance=5.0)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces coplanar with the first one:", len(ids)
print("Number of faces coplanar with the first one:", len(ids))

View File

@ -4,4 +4,4 @@ from SMESH_mechanic import *
# get all over-constrained faces
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_OverConstrainedFace)
ids = mesh.GetIdsFromFilter(filter)
print "Over-constrained faces:", ids
print("Over-constrained faces:", ids)

View File

@ -27,6 +27,6 @@ equalEdgesFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_EqualEdges)
equalFacesFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_EqualFaces)
equalVolumesFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_EqualVolumes)
# get equal elements
print "Number of equal edges:", len( mesh.GetIdsFromFilter( equalEdgesFilter ))
print "Number of equal faces:", len( mesh.GetIdsFromFilter( equalFacesFilter ))
print "Number of equal volumes:", len( mesh.GetIdsFromFilter( equalVolumesFilter ))
print("Number of equal edges:", len( mesh.GetIdsFromFilter( equalEdgesFilter )))
print("Number of equal faces:", len( mesh.GetIdsFromFilter( equalFacesFilter )))
print("Number of equal volumes:", len( mesh.GetIdsFromFilter( equalVolumesFilter )))

View File

@ -20,4 +20,4 @@ mesh.TranslateObject( mesh, [10,0,0], Copy=True )
# create a filter to find nodes equal within tolerance of 1e-5
filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_EqualNodes, Tolerance=1e-5)
# get equal nodes
print "Number of equal nodes:", len( mesh.GetIdsFromFilter( filter ))
print("Number of equal nodes:", len( mesh.GetIdsFromFilter( filter )))

View File

@ -22,4 +22,4 @@ mesh.MergeNodes( mesh.FindCoincidentNodes( 1e-5 ))
# get mesh edges with number of connected elements (faces and volumes) == 3
filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, 3)
ids = mesh.GetIdsFromFilter(filter)
print "Number of border edges with 3 faces connected:", len(ids)
print("Number of border edges with 3 faces connected:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get faces which consist of edges belonging to 2 mesh elements
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, 2)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces consisting of edges belonging to 2 faces:", len(ids)
print("Number of faces consisting of edges belonging to 2 faces:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get edges with length > 14
filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, 14)
ids = mesh.GetIdsFromFilter(filter)
print "Number of edges with length > 14:", len(ids)
print("Number of edges with length > 14:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get all faces that have edges with length > 14
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, 14)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with maximum edge length > 14:", len(ids)
print("Number of faces with maximum edge length > 14:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get all faces that have elements with length > 10
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 10)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with maximum element length > 10:", len(ids)
print("Number of faces with maximum element length > 10:", len(ids))

View File

@ -7,4 +7,4 @@ mesh.Compute()
# get all volumes that have elements with length > 10
filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, 10)
ids = mesh.GetIdsFromFilter(filter)
print "Number of volumes with maximum element length > 10:", len(ids)
print("Number of volumes with maximum element length > 10:", len(ids))

View File

@ -9,4 +9,4 @@ mesh.RemoveElements( mesh.GetElementsByType(VOLUME)[0:5] )
# get all volumes with bare borders
filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BareBorderVolume)
ids = mesh.GetIdsFromFilter(filter)
print "Volumes with bare borders:", ids
print("Volumes with bare borders:", ids)

View File

@ -7,4 +7,4 @@ mesh.Compute()
# get all over-constrained volumes
filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_OverConstrainedVolume)
ids = mesh.GetIdsFromFilter(filter)
print "Over-constrained volumes:", ids
print("Over-constrained volumes:", ids)

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get all faces which nodes lie on the face sub_face3
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces which nodes lie on sub_face3:", len(ids)
print("Number of faces which nodes lie on sub_face3:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get all faces at least one node of each lies on the face sub_face3
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_LyingOnGeom, sub_face3)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces at least one node of each lies on sub_face3:", len(ids)
print("Number of faces at least one node of each lies on sub_face3:", len(ids))

View File

@ -8,4 +8,4 @@ geompy.addToStudy(plane_1, "plane_1")
# get all nodes which lie on the plane \a plane_1
filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_BelongToPlane, plane_1)
ids = mesh.GetIdsFromFilter(filter)
print "Number of nodes which lie on the plane plane_1:", len(ids)
print("Number of nodes which lie on the plane plane_1:", len(ids))

View File

@ -5,4 +5,4 @@ from SMESH_mechanic import *
# get all faces which lie on the cylindrical face \a sub_face1
filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToCylinder, sub_face1)
ids = mesh.GetIdsFromFilter(filter)
print "Number of faces which lie on the cylindrical surface sub_face1:", len(ids)
print("Number of faces which lie on the cylindrical surface sub_face1:", len(ids))

View File

@ -9,4 +9,4 @@ geompy.addToStudy(surface_1, "surface_1")
# get all nodes which lie on the surface \a surface_1
filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_BelongToGenSurface, surface_1)
ids = mesh.GetIdsFromFilter(filter)
print "Number of nodes which lie on the surface surface_1:", len(ids)
print("Number of nodes which lie on the surface surface_1:", len(ids))

View File

@ -9,4 +9,4 @@ criterion2 = smesh.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold="15-3
filter = smesh.CreateFilterManager().CreateFilter()
filter.SetCriteria([criterion1,criterion2])
ids = mesh.GetIdsFromFilter(filter)
print "Number of nodes in ranges [5-10] and [15-30]:", len(ids)
print("Number of nodes in ranges [5-10] and [15-30]:", len(ids))

View File

@ -7,4 +7,4 @@ mesh.Compute()
# get all badly oriented volumes
filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BadOrientedVolume)
ids = mesh.GetIdsFromFilter(filter)
print "Number of badly oriented volumes:", len(ids)
print("Number of badly oriented volumes:", len(ids))

View File

@ -8,13 +8,13 @@ filter_linear = smesh.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic)
filter_quadratic = smesh.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic, SMESH.FT_LogicalNOT)
ids_linear = mesh.GetIdsFromFilter(filter_linear)
ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic)
print("Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic))
# convert mesh to quadratic
print "Convert to quadratic..."
print("Convert to quadratic...")
mesh.ConvertToQuadratic()
# get linear and quadratic edges
ids_linear = mesh.GetIdsFromFilter(filter_linear)
ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic)
print("Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic))

View File

@ -11,4 +11,4 @@ grp.SetColor(c)
# get number of the edges not belonging to the group with the given color
filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_GroupColor, c, SMESH.FT_LogicalNOT)
ids = mesh.GetIdsFromFilter(filter)
print "Number of edges not beloging to the group with color (0.1, 0.5, 1.0):", len(ids)
print("Number of edges not beloging to the group with color (0.1, 0.5, 1.0):", len(ids))

View File

@ -13,7 +13,7 @@ ids_tri = mesh.GetIdsFromFilter(filter_tri)
ids_qua = mesh.GetIdsFromFilter(filter_qua)
ids_tet = mesh.GetIdsFromFilter(filter_tet)
ids_pyr = mesh.GetIdsFromFilter(filter_pyr)
print "Number of triangles:", len(ids_tri)
print "Number of quadrangles:", len(ids_qua)
print "Number of tetrahedrons:", len(ids_tet)
print "Number of pyramids:", len(ids_pyr)
print("Number of triangles:", len(ids_tri))
print("Number of quadrangles:", len(ids_qua))
print("Number of tetrahedrons:", len(ids_tet))
print("Number of pyramids:", len(ids_pyr))

View File

@ -12,4 +12,4 @@ for face in SubFaceL[: len(SubFaceL)/2]:
# get triangles with 7 nodes
filter_tri = smesh.GetFilter(SMESH.FACE, SMESH.FT_EntityType,'=', SMESH.Entity_BiQuad_Triangle )
ids_tri = mesh.GetIdsFromFilter(filter_tri)
print "Number of bi-quadratic triangles:", len(ids_tri)
print("Number of bi-quadratic triangles:", len(ids_tri))

View File

@ -12,4 +12,4 @@ for i in range(1,10):
# get balls with diameter > 5.
diam_filter = smesh.GetFilter(SMESH.BALL, SMESH.FT_BallDiameter,'>', 5. )
ids = mesh.GetIdsFromFilter( diam_filter )
print "Number of balls with diameter > 5:", len(ids)
print("Number of balls with diameter > 5:", len(ids))

View File

@ -29,17 +29,17 @@ mesh.Compute()
# using point coordinates in box_1
nodeFilter = smesh.GetFilter( SMESH.NODE, SMESH.FT_ConnectedElements, "=", "1.,2,10", mesh=mesh )
print "Nb. nodes in box_1:", len( nodeFilter.GetIDs())
print("Nb. nodes in box_1:", len( nodeFilter.GetIDs()))
# using point coordinates in box_2
edgeFilter = smesh.GetFilter( SMESH.EDGE, SMESH.FT_ConnectedElements, "=", [202,1,1 ], mesh=mesh )
print "Nb. segments in box_2:", len( edgeFilter.GetIDs())
print("Nb. segments in box_2:", len( edgeFilter.GetIDs()))
# using a geom vertex of box_1
faceFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_ConnectedElements, "=", vertex, mesh=mesh )
print "Nb. faces in box_1:", len( edgeFilter.GetIDs())
print("Nb. faces in box_1:", len( edgeFilter.GetIDs()))
# using node ID in box_2
voluFilter = smesh.GetFilter( SMESH.VOLUME, SMESH.FT_ConnectedElements, "=", 10, mesh=mesh )
print "Nb. volumes in box_2:", len( voluFilter.GetIDs())
print("Nb. volumes in box_2:", len( voluFilter.GetIDs()))

View File

@ -6,4 +6,4 @@ from SMESH_mechanic import *
# get nodes connected to more than 6 tetrahedra
conn_nb_filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_NodeConnectivityNumber,'>', 6 )
ids = mesh.GetIdsFromFilter( conn_nb_filter )
print "Number of nodes connected to more than 6 tetrahedra:", len(ids)
print("Number of nodes connected to more than 6 tetrahedra:", len(ids))

View File

@ -28,37 +28,37 @@ aGroup = mesh.CreateEmptyGroup(SMESH.NODE, "aGroup")
# set/get group name
aGroup.SetName( "new name" )
print "name", aGroup.GetName()
print("name", aGroup.GetName())
# get group type (type of entities in the group, SMESH.NODE in our case)
print "type", aGroup.GetType()
print("type", aGroup.GetType())
# get number of entities (nodes in our case) in the group
print "size", aGroup.Size()
print("size", aGroup.Size())
# check of emptiness
print "is empty", aGroup.IsEmpty()
print("is empty", aGroup.IsEmpty())
# check of presence of an entity in the group
aGroup.Add([1,2]) # Add() method is specific to the standalone group
print "contains node 2", aGroup.Contains(2)
print("contains node 2", aGroup.Contains(2))
# get an entity by index
print "1st node", aGroup.GetID(1)
print("1st node", aGroup.GetID(1))
# get all entities
print "all", aGroup.GetIDs()
print("all", aGroup.GetIDs())
# get number of nodes (actual for groups of elements)
print "nb nodes", aGroup.GetNumberOfNodes()
print("nb nodes", aGroup.GetNumberOfNodes())
# get underlying nodes (actual for groups of elements)
print "nodes", aGroup.GetNodeIDs()
print("nodes", aGroup.GetNodeIDs())
# set/get color
import SALOMEDS
aGroup.SetColor( SALOMEDS.Color(1.,1.,0.));
print "color", aGroup.GetColor()
print("color", aGroup.GetColor())
# ----------------------------------------------------------------------------
# methods specific to the standalone group and not present in GroupOnGeometry

View File

@ -28,22 +28,22 @@ critaria = [ \
]
filt = smesh.GetFilterFromCriteria( critaria )
filtGroup = mesh.GroupOnFilter( SMESH.FACE, "group on filter", filt )
print "Group on filter contains %s elemens" % filtGroup.Size()
print("Group on filter contains %s elemens" % filtGroup.Size())
# group on filter is updated if the mesh is modified
hyp1D.SetStartLength( 2.5 )
hyp1D.SetEndLength( 2.5 )
mesh.Compute()
print "After mesh change, group on filter contains %s elemens" % filtGroup.Size()
print("After mesh change, group on filter contains %s elemens" % filtGroup.Size())
# set a new filter defining the group
filt2 = smesh.GetFilter( SMESH.FACE, SMESH.FT_RangeOfIds, "1-50" )
filtGroup.SetFilter( filt2 )
print "With a new filter, group on filter contains %s elemens" % filtGroup.Size()
print("With a new filter, group on filter contains %s elemens" % filtGroup.Size())
# group is updated at modification of the filter
filt2.SetCriteria( [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )])
filtIDs3 = filtGroup.GetIDs()
print "After filter modification, group on filter contains %s elemens" % filtGroup.Size()
print("After filter modification, group on filter contains %s elemens" % filtGroup.Size())
salome.sg.updateObjBrowser(True)

View File

@ -12,7 +12,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 35.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area > 35, Nb = ", len(anIds)
print("Criterion: Area > 35, Nb = ", len(anIds))
# create a group by adding elements with area > 35
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Area > 35")
@ -23,7 +23,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 40.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area > 40, Nb = ", len(anIds)
print("Criterion: Area > 40, Nb = ", len(anIds))
# create a group of elements with area [35; 40] by removing elements with area > 40 from group aGroup
aGroup.Remove(anIds)
@ -32,14 +32,14 @@ aGroup.SetName("35 < Area < 40")
# print the result
aGroupElemIDs = aGroup.GetListOfID()
print "Criterion: 35 < Area < 40, Nb = ", len(aGroupElemIDs)
print("Criterion: 35 < Area < 40, Nb = ", len(aGroupElemIDs))
j = 1
for i in range(len(aGroupElemIDs)):
if j > 20: j = 1; print ""
print aGroupElemIDs[i],
if j > 20: j = 1; print("")
print(aGroupElemIDs[i], end=' ')
j = j + 1
pass
print ""
print("")
salome.sg.updateObjBrowser(True)

View File

@ -12,7 +12,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area > 20, Nb = ", len( anIds )
print("Criterion: Area > 20, Nb = ", len( anIds ))
# create a group by adding elements with area > 20
aGroup1 = mesh.CreateEmptyGroup(SMESH.FACE, "Area > 20")
@ -23,7 +23,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_EqualTo, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area = 20, Nb = ", len( anIds )
print("Criterion: Area = 20, Nb = ", len( anIds ))
# create a group by adding elements with area = 20
aGroup2 = mesh.CreateEmptyGroup( SMESH.FACE, "Area = 20" )
@ -33,7 +33,7 @@ aGroup2.Add(anIds)
# create union group : area >= 20
aGroup3 = mesh.UnionListOfGroups([aGroup1, aGroup2], "Area >= 20")
aGroup3.SetColor( SALOMEDS.Color(1.,1.,0.));
print "Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID())
print("Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID()))
# Please note that also there is UnionGroups() method which works with two groups only
# Criterion : AREA < 20
@ -41,7 +41,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area < 20, Nb = ", len(anIds)
print("Criterion: Area < 20, Nb = ", len(anIds))
# create a group by adding elements with area < 20
aGroup4 = mesh.CreateEmptyGroup(SMESH.FACE, "Area < 20")
@ -50,6 +50,6 @@ aGroup4.SetColor( SALOMEDS.Color(1.,0.,0.));
# create union group : area >= 20 and area < 20
aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area")
print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())
print("Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID()))
salome.sg.updateObjBrowser(True)

View File

@ -12,7 +12,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area > 20, Nb = ", len(anIds)
print("Criterion: Area > 20, Nb = ", len(anIds))
# create a group by adding elements with area > 20
aGroup1 = mesh.CreateEmptyGroup(SMESH.FACE, "Area > 20")
@ -23,7 +23,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area < 60, Nb = ", len(anIds)
print("Criterion: Area < 60, Nb = ", len(anIds))
# create a group by adding elements with area < 60
aGroup2 = mesh.CreateEmptyGroup(SMESH.FACE, "Area < 60")
@ -31,7 +31,7 @@ aGroup2.Add(anIds)
# create an intersection of groups : 20 < area < 60
aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60")
print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())
print("Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID()))
# Please note that also there is IntersectGroups() method which works with two groups only
salome.sg.updateObjBrowser(True)

View File

@ -12,7 +12,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area > 20, Nb = ", len(anIds)
print("Criterion: Area > 20, Nb = ", len(anIds))
# create a group by adding elements with area > 20
aGroupMain = mesh.MakeGroupByIds("Area > 20", SMESH.FACE, anIds)
@ -22,14 +22,14 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area < 60, Nb = ", len(anIds)
print("Criterion: Area < 60, Nb = ", len(anIds))
# create a group by adding elements with area < 60
aGroupTool = mesh.MakeGroupByIds("Area < 60", SMESH.FACE, anIds)
# create a cut of groups : area >= 60
aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())
print("Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID()))
# Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths
salome.sg.updateObjBrowser(True)

View File

@ -13,7 +13,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.)
# create a group by adding elements with area > 100
aSrcGroup1 = mesh.GroupOnFilter(SMESH.FACE, "Area > 100", aFilter)
aSrcGroup1.SetColor( SALOMEDS.Color(1.,1.,0.))
print "Criterion: Area > 100, Nb = ", aSrcGroup1.Size()
print("Criterion: Area > 100, Nb = ", aSrcGroup1.Size())
# Criterion : AREA < 30
aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 30.)
@ -21,7 +21,7 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 30.)
# create a group by adding elements with area < 30
aSrcGroup2 = mesh.GroupOnFilter(SMESH.FACE, "Area < 30", aFilter)
aSrcGroup2.SetColor( SALOMEDS.Color(1.,0.,0.))
print "Criterion: Area < 30, Nb = ", aSrcGroup2.Size()
print("Criterion: Area < 30, Nb = ", aSrcGroup2.Size())
# Create group of edges using source groups of faces

View File

@ -29,51 +29,51 @@ group_2d = mesh.Group(face)
# compute basic properties
print "Get basic properties: approach 1 (via measurements tool) ----"
print("Get basic properties: approach 1 (via measurements tool) ----")
measure = smesh.CreateMeasurements()
print "* for mesh:"
print " length:", measure.Length(mesh.mesh)
print " area:", measure.Area(mesh.mesh)
print " volume:", measure.Volume(mesh.mesh)
print("* for mesh:")
print(" length:", measure.Length(mesh.mesh))
print(" area:", measure.Area(mesh.mesh))
print(" volume:", measure.Volume(mesh.mesh))
print "* for group (2d):"
print " length:", measure.Length(group_2d)
print " area:", measure.Area(group_2d)
print " volume:", measure.Volume(group_2d)
print("* for group (2d):")
print(" length:", measure.Length(group_2d))
print(" area:", measure.Area(group_2d))
print(" volume:", measure.Volume(group_2d))
print "* for submesh (2d):"
print " length:", measure.Length(submesh_2d_face.GetSubMesh())
print " area:", measure.Area(submesh_2d_face.GetSubMesh())
print " volume:", measure.Volume(submesh_2d_face.GetSubMesh())
print("* for submesh (2d):")
print(" length:", measure.Length(submesh_2d_face.GetSubMesh()))
print(" area:", measure.Area(submesh_2d_face.GetSubMesh()))
print(" volume:", measure.Volume(submesh_2d_face.GetSubMesh()))
measure.UnRegister()
print "Get basic properties: approach 2 (via smeshBuilder) ----"
print("Get basic properties: approach 2 (via smeshBuilder) ----")
print "* for mesh:"
print " length:", smesh.GetLength(mesh)
print " area:", smesh.GetArea(mesh)
print " volume:", smesh.GetVolume(mesh)
print("* for mesh:")
print(" length:", smesh.GetLength(mesh))
print(" area:", smesh.GetArea(mesh))
print(" volume:", smesh.GetVolume(mesh))
print "* for group (2d):"
print " length:", smesh.GetLength(group_2d)
print " area:", smesh.GetArea(group_2d)
print " volume:", smesh.GetVolume(group_2d)
print("* for group (2d):")
print(" length:", smesh.GetLength(group_2d))
print(" area:", smesh.GetArea(group_2d))
print(" volume:", smesh.GetVolume(group_2d))
print "* for submesh (2d):"
print " length:", smesh.GetLength(submesh_2d_face)
print " area:", smesh.GetArea(submesh_2d_face)
print " volume:", smesh.GetVolume(submesh_2d_face)
print("* for submesh (2d):")
print(" length:", smesh.GetLength(submesh_2d_face))
print(" area:", smesh.GetArea(submesh_2d_face))
print(" volume:", smesh.GetVolume(submesh_2d_face))
print "Get basic properties: approach 3 (via smeshBuilder.Mesh) ----"
print("Get basic properties: approach 3 (via smeshBuilder.Mesh) ----")
print "* for mesh:"
print " length:", mesh.GetLength()
print " area:", mesh.GetArea()
print " volume:", mesh.GetVolume()
print("* for mesh:")
print(" length:", mesh.GetLength())
print(" area:", mesh.GetArea())
print(" volume:", mesh.GetVolume())
print "* for group (2d): unsupported"
print("* for group (2d): unsupported")
print "* for submesh (2d): unsupported"
print("* for submesh (2d): unsupported")

View File

@ -11,6 +11,6 @@ mesh = smesh.Mesh()
# add node
new_id = mesh.AddNode(50, 10, 0)
print ""
if new_id == 0: print "KO node addition."
else: print "New Node has been added with ID ", new_id
print("")
if new_id == 0: print("KO node addition.")
else: print("New Node has been added with ID ", new_id)

View File

@ -15,6 +15,6 @@ node_id = mesh.AddNode(50, 10, 0)
# add 0D Element
new_id = mesh.Add0DElement(node_id)
print ""
if new_id == 0: print "KO node addition."
else: print "New 0D Element has been added with ID ", new_id
print("")
if new_id == 0: print("KO node addition.")
else: print("New 0D Element has been added with ID ", new_id)

View File

@ -48,5 +48,5 @@ res = mesh.Add0DElementsToAllNodes( mesh.GetElementsId() )
mesh.RemoveElements( mesh.GetElementsByType( SMESH.ELEM0D ))
# create 0D elements on some nodes
nodes = range(1,10)
nodes = list(range(1,10))
res = mesh.Add0DElementsToAllNodes( mesh.GetIDSource( nodes, SMESH.NODE ))

View File

@ -3,13 +3,13 @@
import SMESH_mechanic
mesh = SMESH_mechanic.mesh
print ""
print("")
# add node
n1 = mesh.AddNode(50, 10, 0)
if n1 == 0: print "KO node addition."
if n1 == 0: print("KO node addition.")
# add edge
e1 = mesh.AddEdge([n1, 38])
if e1 == 0: print "KO edge addition."
else: print "New Edge has been added with ID ", e1
if e1 == 0: print("KO edge addition.")
else: print("New Edge has been added with ID ", e1)

View File

@ -3,13 +3,13 @@
import SMESH_mechanic
mesh = SMESH_mechanic.mesh
print ""
print("")
# add node
n1 = mesh.AddNode(50, 10, 0)
if n1 == 0: print "KO node addition."
if n1 == 0: print("KO node addition.")
# add triangle
t1 = mesh.AddFace([n1, 38, 39])
if t1 == 0: print "KO triangle addition."
else: print "New Triangle has been added with ID ", t1
if t1 == 0: print("KO triangle addition.")
else: print("New Triangle has been added with ID ", t1)

View File

@ -3,16 +3,16 @@
import SMESH_mechanic
mesh = SMESH_mechanic.mesh
print ""
print("")
# add node
n1 = mesh.AddNode(50, 10, 0)
if n1 == 0: print "KO node addition."
if n1 == 0: print("KO node addition.")
n2 = mesh.AddNode(40, 20, 0)
if n2 == 0: print "KO node addition."
if n2 == 0: print("KO node addition.")
# add quadrangle
q1 = mesh.AddFace([n2, n1, 38, 39])
if q1 == 0: print "KO quadrangle addition."
else: print "New Quadrangle has been added with ID ", q1
if q1 == 0: print("KO quadrangle addition.")
else: print("New Quadrangle has been added with ID ", q1)

View File

@ -3,13 +3,13 @@
import SMESH_mechanic
mesh = SMESH_mechanic.mesh
print ""
print("")
# add node
n1 = mesh.AddNode(50, 10, 0)
if n1 == 0: print "KO node addition."
if n1 == 0: print("KO node addition.")
# add tetrahedron
t1 = mesh.AddVolume([n1, 38, 39, 246])
if t1 == 0: print "KO tetrahedron addition."
else: print "New Tetrahedron has been added with ID ", t1
if t1 == 0: print("KO tetrahedron addition.")
else: print("New Tetrahedron has been added with ID ", t1)

View File

@ -3,7 +3,7 @@
import SMESH_mechanic
mesh = SMESH_mechanic.mesh
print ""
print("")
# add nodes
nId1 = mesh.AddNode(50, 10, 0)
@ -11,9 +11,9 @@ nId2 = mesh.AddNode(47, 12, 0)
nId3 = mesh.AddNode(50, 10, 10)
nId4 = mesh.AddNode(47, 12, 10)
if nId1 == 0 or nId2 == 0 or nId3 == 0 or nId4 == 0: print "KO node addition."
if nId1 == 0 or nId2 == 0 or nId3 == 0 or nId4 == 0: print("KO node addition.")
# add hexahedron
vId = mesh.AddVolume([nId2, nId1, 38, 39, nId4, nId3, 245, 246])
if vId == 0: print "KO Hexahedron addition."
else: print "New Hexahedron has been added with ID ", vId
if vId == 0: print("KO Hexahedron addition.")
else: print("New Hexahedron has been added with ID ", vId)

View File

@ -6,5 +6,5 @@ mesh = SMESH_mechanic.mesh
# remove nodes #246 and #255
res = mesh.RemoveNodes([246, 255])
if res == 1: print "Nodes removing is OK!"
else: print "KO nodes removing."
if res == 1: print("Nodes removing is OK!")
else: print("KO nodes removing.")

View File

@ -6,5 +6,5 @@ mesh = SMESH_mechanic.mesh
# remove three elements: #850, #859 and #814
res = mesh.RemoveElements([850, 859, 814])
if res == 1: print "Elements removing is OK!"
else: print "KO Elements removing."
if res == 1: print("Elements removing is OK!")
else: print("KO Elements removing.")

View File

@ -9,5 +9,5 @@ mesh.AddNode(0,0,0)
mesh.AddNode(1,1,1)
# remove just created orphan nodes
res = mesh.RemoveOrphanNodes()
if res == 1: print "Removed %d nodes!" % res
else: print "KO nodes removing."
if res == 1: print("Removed %d nodes!" % res)
else: print("KO nodes removing.")

View File

@ -38,15 +38,15 @@ if not node000:
# find node000 using a dedicated function
n = mesh.FindNodeClosestTo( -1,-1,-1 )
if not n == node000:
raise "FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 )
raise Exception("FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 ))
# move node000 to a new location
x,y,z = -10, -10, -10
n = mesh.MoveNode( n,x,y,z )
if not n:
raise "MoveNode() returns " + n
raise Exception("MoveNode() returns " + n)
# check the coordinates of the node000
xyz = mesh.GetNodeXYZ( node000 )
if not ( xyz[0] == x and xyz[1] == y and xyz[2] == z) :
raise "Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] )
raise Exception("Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] ))

View File

@ -46,9 +46,9 @@ ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
# inverse the diagonal bb[1] - tt[2]
print "\nDiagonal inversion ... ",
print("\nDiagonal inversion ... ", end=' ')
res = mesh.InverseDiag(bb[1], tt[2])
if not res: print "failed!"
else: print "done."
if not res: print("failed!")
else: print("done.")
salome.sg.updateObjBrowser(True)

View File

@ -46,9 +46,9 @@ ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
# delete the diagonal bb[1] - tt[2]
print "\nUnite two triangles ... ",
print("\nUnite two triangles ... ", end=' ')
res = mesh.DeleteDiag(bb[1], tt[2])
if not res: print "failed!"
else: print "done."
if not res: print("failed!")
else: print("done.")
salome.sg.updateObjBrowser(True)

View File

@ -46,9 +46,9 @@ ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
# unite a set of triangles
print "\nUnite a set of triangles ... ",
print("\nUnite a set of triangles ... ", end=' ')
res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], SMESH.FT_MinimumAngle, 60.)
if not res: print "failed!"
else: print "done."
if not res: print("failed!")
else: print("done.")
salome.sg.updateObjBrowser(True)

View File

@ -28,8 +28,8 @@ GroupSmooth = mesh.GroupOnGeom(face, "Group of faces (smooth)", SMESH.FACE)
# boolean SmoothObject(Object, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method)
res = mesh.SmoothObject(GroupSmooth, [], 20, 2., smesh.CENTROIDAL_SMOOTH)
print "\nSmoothing ... ",
if not res: print "failed!"
else: print "done."
print("\nSmoothing ... ", end=' ')
if not res: print("failed!")
else: print("done.")
salome.sg.updateObjBrowser(True)

View File

@ -19,7 +19,7 @@ iv = 1
vertices = []
for point in points:
vert = geompy.MakeVertex(point[0], point[1], 0)
geompy.addToStudy(vert, "Vertex_" + `iv`)
geompy.addToStudy(vert, "Vertex_" + repr(iv))
vertices.append(vert)
iv += 1
pass
@ -38,7 +38,7 @@ geompy.addToStudy(Edge_Circle , "Edge_Circle")
# 3. Explode wire on edges, as they will be used for mesh extrusion
Wire_polyline_edges = geompy.SubShapeAll(Wire_polyline, geompy.ShapeType["EDGE"])
for ii in range(len(Wire_polyline_edges)):
geompy.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii], "Edge_" + `ii + 1`)
geompy.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii], "Edge_" + repr(ii + 1))
pass
# Mesh
@ -49,7 +49,7 @@ def Mesh1D(shape1d, nbSeg, name):
algo = mesh1d_tool.Segment()
hyp = algo.NumberOfSegments(nbSeg)
isDone = mesh1d_tool.Compute()
if not isDone: print 'Mesh ', name, ': computation failed'
if not isDone: print('Mesh ', name, ': computation failed')
return mesh1d_tool
# Create a mesh with six nodes, seven edges and two quadrangle faces

View File

@ -29,7 +29,7 @@ algo1D.NumberOfSegments(3)
Mesh_1.Quadrangle()
isDone = Mesh_1.Compute()
if not isDone: print 'Mesh Mesh_1 : computation failed'
if not isDone: print('Mesh Mesh_1 : computation failed')
# build a triangle mesh on Face_2
Mesh_2 = smesh.Mesh(Face_2)
@ -40,20 +40,20 @@ algo2D = Mesh_2.Triangle()
algo2D.MaxElementArea(240)
isDone = Mesh_2.Compute()
if not isDone: print 'Mesh Mesh_2 : computation failed'
if not isDone: print('Mesh Mesh_2 : computation failed')
# create a 2d pattern
pattern = smesh.GetPattern()
isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)
if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode()
if (isDone != 1): print('LoadFromFace :', pattern.GetErrorCode())
# apply the pattern to a face of the first mesh
facesToSplit = Mesh_1.GetElementsByType(SMESH.FACE)
print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit))
print("Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit)))
pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0)
isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0)
if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode()
if (isDone != 1): print('MakeMesh :', pattern.GetErrorCode())
# create quadrangle mesh
Mesh_3 = smesh.Mesh(Box_1)
@ -61,7 +61,7 @@ Mesh_3.Segment().NumberOfSegments(1)
Mesh_3.Quadrangle()
Mesh_3.Hexahedron()
isDone = Mesh_3.Compute()
if not isDone: print 'Mesh Mesh_3 : computation failed'
if not isDone: print('Mesh Mesh_3 : computation failed')
# create a 3d pattern (hexahedrons)
pattern_hexa = smesh.GetPattern()
@ -93,10 +93,10 @@ pattern_hexa.LoadFromFile(smp_hexa)
# apply the pattern to a mesh
volsToSplit = Mesh_3.GetElementsByType(SMESH.VOLUME)
print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit))
print("Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit)))
pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3)
isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True)
if (isDone != 1): print 'MakeMesh :', pattern_hexa.GetErrorCode()
if (isDone != 1): print('MakeMesh :', pattern_hexa.GetErrorCode())
# create one more quadrangle mesh
Mesh_4 = smesh.Mesh(Box_1)
@ -104,7 +104,7 @@ Mesh_4.Segment().NumberOfSegments(1)
Mesh_4.Quadrangle()
Mesh_4.Hexahedron()
isDone = Mesh_4.Compute()
if not isDone: print 'Mesh Mesh_4 : computation failed'
if not isDone: print('Mesh Mesh_4 : computation failed')
# create another 3d pattern (pyramids)
pattern_pyra = smesh.GetPattern()
@ -132,7 +132,7 @@ pattern_pyra.LoadFromFile(smp_pyra)
# apply the pattern to a face mesh
volsToSplit = Mesh_4.GetElementsByType(SMESH.VOLUME)
print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit))
print("Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit)))
pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0)
isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True)
if (isDone != 1): print 'MakeMesh :', pattern_pyra.GetErrorCode()
if (isDone != 1): print('MakeMesh :', pattern_pyra.GetErrorCode())

View File

@ -31,14 +31,14 @@ aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Free borders Nb = ", len(anIds)
print("Criterion: Free borders Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Free borders")

View File

@ -33,14 +33,14 @@ aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, SMESH.FT_EqualTo
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Borders at multi-connections Nb = ", len(anIds)
print("Criterion: Borders at multi-connections Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Borders at multi-connections")

View File

@ -33,17 +33,17 @@ aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, length
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Edges length > ", length_margin, " Nb = ", len(anIds)
print("Criterion: Edges length > ", length_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`)
aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Edges with length > " + repr(length_margin))
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)

View File

@ -27,12 +27,12 @@ aGroupF = mesh.CreateEmptyGroup(SMESH.FACE, "Faces with free edges")
aGroupN = mesh.CreateEmptyGroup(SMESH.NODE, "Nodes on free edges")
# fill groups with elements, corresponding to the criterion
print ""
print "Criterion: Free edges Nb = ", len(aBorders)
print("")
print("Criterion: Free edges Nb = ", len(aBorders))
for i in range(len(aBorders)):
aBorder = aBorders[i]
print "Face # ", aBorder.myElemId, " : Edge between nodes (",
print aBorder.myPnt1, ", ", aBorder.myPnt2, ")"
print("Face # ", aBorder.myElemId, " : Edge between nodes (", end=' ')
print(aBorder.myPnt1, ", ", aBorder.myPnt2, ")")
aGroupF.Add([aBorder.myElemId])
aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2])

View File

@ -42,13 +42,13 @@ aGroup = mesh.CreateEmptyGroup(SMESH.NODE, "Free_nodes")
aGroup.Add(anNodeIds)
# print the result
print "Criterion: Free nodes Nb = ", len(anNodeIds)
print("Criterion: Free nodes Nb = ", len(anNodeIds))
j = 1
for i in range(len(anNodeIds)):
if j > 20: j = 1; print ""
print anNodeIds[i],
if j > 20: j = 1; print("")
print(anNodeIds[i], end=' ')
j = j + 1
pass
print ""
print("")
salome.sg.updateObjBrowser(True)

View File

@ -54,14 +54,14 @@ aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Free_faces")
aGroup.Add(aFaceIds)
# print the result
print "Criterion: Free faces Nb = ", len(aFaceIds)
print("Criterion: Free faces Nb = ", len(aFaceIds))
j = 1
for i in range(len(aFaceIds)):
if j > 20: j = 1; print ""
print aFaceIds[i],
if j > 20: j = 1; print("")
print(aFaceIds[i], end=' ')
j = j + 1
pass
print ""
print("")
#filter faces from plane 2
aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_2)

View File

@ -34,17 +34,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, leng
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds)
print("Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Faces with length 2D > " + `length_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Faces with length 2D > " + repr(length_margin))
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)

View File

@ -34,17 +34,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, SMESH.FT_Equal
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds)
print("Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Borders at multi-connection 2D = " + `nb_conn`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Borders at multi-connection 2D = " + repr(nb_conn))
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)

View File

@ -15,17 +15,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_mar
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Area > ", area_margin, " Nb = ", len(anIds)
print("Criterion: Area > ", area_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Area > " + `area_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Area > " + repr(area_margin))
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)

View File

@ -15,17 +15,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_MoreThan, taper_m
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds)
print("Criterion: Taper > ", taper_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Taper > " + `taper_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Taper > " + repr(taper_margin))
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)

View File

@ -15,17 +15,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, a
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds)
print("Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Aspect Ratio > " + `ar_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Aspect Ratio > " + repr(ar_margin))
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)

View File

@ -15,17 +15,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle, SMESH.FT_LessThan,
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Minimum Angle < ", min_angle, " Nb = ", len(anIds)
print("Criterion: Minimum Angle < ", min_angle, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Minimum Angle < " + `min_angle`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Minimum Angle < " + repr(min_angle))
aGroup.Add(anIds)

View File

@ -15,17 +15,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping, SMESH.FT_MoreThan, wa_ma
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Warp > ", wa_margin, " Nb = ", len(anIds)
print("Criterion: Warp > ", wa_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Warp > " + `wa_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Warp > " + repr(wa_margin))
aGroup.Add(anIds)

View File

@ -15,17 +15,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, skew_mar
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Skew > ", skew_margin, " Nb = ", len(anIds)
print("Criterion: Skew > ", skew_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Skew > " + `skew_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Skew > " + repr(skew_margin))
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)

View File

@ -15,17 +15,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_More
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Element Diameter 2D Ratio > ", mel_2d_margin, " Nb = ", len(anIds)
print("Criterion: Element Diameter 2D Ratio > ", mel_2d_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 2D > " + `mel_2d_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 2D > " + repr(mel_2d_margin))
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)

View File

@ -15,17 +15,17 @@ aFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_MoreTha
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Aspect Ratio 3D > ", ar_margin, " Nb = ", len(anIds)
print("Criterion: Aspect Ratio 3D > ", ar_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Aspect Ratio 3D > " + `ar_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Aspect Ratio 3D > " + repr(ar_margin))
aGroup.Add(anIds)

View File

@ -15,18 +15,18 @@ aFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_LessThan, vo
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print ""
print "Criterion: Volume < ", volume_margin, " Nb = ", len(anIds)
print("")
print("Criterion: Volume < ", volume_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Volume < " + `volume_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Volume < " + repr(volume_margin))
aGroup.Add(anIds)

View File

@ -15,17 +15,17 @@ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength3D, SMESH.FT_More
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
print "Criterion: Element Diameter 3D Ratio > ", mel_3d_margin, " Nb = ", len(anIds)
print("Criterion: Element Diameter 3D Ratio > ", mel_3d_margin, " Nb = ", len(anIds))
j = 1
for i in range(len(anIds)):
if j > 20: j = 1; print ""
print anIds[i],
if j > 20: j = 1; print("")
print(anIds[i], end=' ')
j = j + 1
pass
print ""
print("")
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 3D > " + `mel_3d_margin`)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 3D > " + repr(mel_3d_margin))
aGroup.Add(anIds)
salome.sg.updateObjBrowser(True)

View File

@ -54,27 +54,27 @@ trias.ExtrusionAlongPath([], circlemesh, circle,
1, 0, [], 0, SMESH.PointStruct(0, 0, 0))
# merge nodes
print "Number of nodes before MergeNodes:",
print("Number of nodes before MergeNodes:", end=' ')
trias.NbNodes()
tolerance = 0.001
array_of_nodes_groups = trias.FindCoincidentNodes(tolerance)
trias.MergeNodes(array_of_nodes_groups)
print "Number of nodes after MergeNodes:", trias.NbNodes()
print ""
print "Number of elements before MergeEqualElements:"
print "Edges : ", trias.NbEdges()
print "Triangles : ", trias.NbTriangles()
print "Quadrangles: ", trias.NbQuadrangles()
print "Volumes : ", trias.NbVolumes()
print("Number of nodes after MergeNodes:", trias.NbNodes())
print("")
print("Number of elements before MergeEqualElements:")
print("Edges : ", trias.NbEdges())
print("Triangles : ", trias.NbTriangles())
print("Quadrangles: ", trias.NbQuadrangles())
print("Volumes : ", trias.NbVolumes())
# merge elements
trias.MergeEqualElements()
print "Number of elements after MergeEqualElements:"
print "Edges : ", trias.NbEdges()
print "Triangles : ", trias.NbTriangles()
print "Quadrangles: ", trias.NbQuadrangles()
print "Volumes : ", trias.NbVolumes()
print("Number of elements after MergeEqualElements:")
print("Edges : ", trias.NbEdges())
print("Triangles : ", trias.NbTriangles())
print("Quadrangles: ", trias.NbQuadrangles())
print("Volumes : ", trias.NbVolumes())
salome.sg.updateObjBrowser(True)

View File

@ -45,6 +45,6 @@ CreatePolyedrs = False
res = mesh.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
FirstNodeID2, SecondNodeID2, LastNodeID2,
CreatePolygons, CreatePolyedrs )
print res
print "nb polygons:", mesh.NbPolygons()
print(res)
print("nb polygons:", mesh.NbPolygons())

View File

@ -37,27 +37,27 @@ mesh.Compute()
# find elements to sew
face1 = geompy.GetFaceNearPoint( aComp, geompy.MakeVertex( 5, 10, 5 ))
IDsOfSide1Elements = mesh.GetSubMeshElementsId( face1 )
print "side faces 1:",IDsOfSide1Elements
print("side faces 1:",IDsOfSide1Elements)
face1Translated = geompy.MakeTranslation( face1, 0,5,0 )
faceFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_BelongToGeom,'=', face1Translated )
IDsOfSide2Elements = mesh.GetIdsFromFilter( faceFilter )
print "side faces 2:",IDsOfSide2Elements
print("side faces 2:",IDsOfSide2Elements)
# find corresponding nodes on sides
edge1 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 10, 5 ))
segs1 = mesh.GetSubMeshElementsId( edge1 ) # mesh segments generated on edge1
NodeID1OfSide1ToMerge = mesh.GetElemNode( segs1[0], 0 )
NodeID2OfSide1ToMerge = mesh.GetElemNode( segs1[0], 1 )
print "nodes of side1:", [NodeID1OfSide1ToMerge,NodeID2OfSide1ToMerge]
print("nodes of side1:", [NodeID1OfSide1ToMerge,NodeID2OfSide1ToMerge])
edge2 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 15, 5 ))
segs2 = mesh.GetSubMeshElementsId( edge2 ) # mesh segments generated on edge2
NodeID1OfSide2ToMerge = mesh.GetElemNode( segs2[0], 0 )
NodeID2OfSide2ToMerge = mesh.GetElemNode( segs2[0], 1 )
print "nodes of side2:", [NodeID1OfSide2ToMerge,NodeID2OfSide2ToMerge]
print("nodes of side2:", [NodeID1OfSide2ToMerge,NodeID2OfSide2ToMerge])
res = mesh.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
print res
print(res)

View File

@ -36,18 +36,18 @@ faces1 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces1' )
faces1.Add( [ 144, 151, 158 ] )
# Duplicate nodes
print "\nMesh before the first nodes duplication:"
print "Nodes : ", mesh.NbNodes()
print "Edges : ", mesh.NbEdges()
print "Quadrangles : ", mesh.NbQuadrangles()
print("\nMesh before the first nodes duplication:")
print("Nodes : ", mesh.NbNodes())
print("Edges : ", mesh.NbEdges())
print("Quadrangles : ", mesh.NbQuadrangles())
groupOfCreatedNodes = mesh.DoubleNodeGroup(nodes1, faces1, theMakeGroup=True)
print "New nodes:", groupOfCreatedNodes.GetIDs()
print("New nodes:", groupOfCreatedNodes.GetIDs())
print "\nMesh after the first nodes duplication:"
print "Nodes : ", mesh.NbNodes()
print "Edges : ", mesh.NbEdges()
print "Quadrangles : ", mesh.NbQuadrangles()
print("\nMesh after the first nodes duplication:")
print("Nodes : ", mesh.NbNodes())
print("Edges : ", mesh.NbEdges())
print("Quadrangles : ", mesh.NbQuadrangles())
# Duplicate nodes and border elements
@ -64,18 +64,18 @@ faces2 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces2' )
faces2.Add( [ 141, 148, 155 ] )
# Duplicate nodes
print "\nMesh before the second nodes duplication:"
print "Nodes : ", mesh.NbNodes()
print "Edges : ", mesh.NbEdges()
print "Quadrangles : ", mesh.NbQuadrangles()
print("\nMesh before the second nodes duplication:")
print("Nodes : ", mesh.NbNodes())
print("Edges : ", mesh.NbEdges())
print("Quadrangles : ", mesh.NbQuadrangles())
groupOfNewEdges = mesh.DoubleNodeElemGroup( edges, nodes2, faces2, theMakeGroup=True )
print "New edges:", groupOfNewEdges.GetIDs()
print("New edges:", groupOfNewEdges.GetIDs())
print "\nMesh after the second nodes duplication:"
print "Nodes : ", mesh.NbNodes()
print "Edges : ", mesh.NbEdges()
print "Quadrangles : ", mesh.NbQuadrangles()
print("\nMesh after the second nodes duplication:")
print("Nodes : ", mesh.NbNodes())
print("Edges : ", mesh.NbEdges())
print("Quadrangles : ", mesh.NbQuadrangles())
# Duplicate elements only

View File

@ -63,9 +63,9 @@ group1 = mesh3D.Group( faces[1] )
# pass group0 and ids of faces of group1 to inverse
nbRev = mesh3D.Reorient2DBy3D([ group0, group1.GetIDs() ], mesh3D, theOutsideNormal=False)
print "Nb reoriented faces:", nbRev
print("Nb reoriented faces:", nbRev)
# orient the reversed faces back
nbRev = mesh3D.Reorient2DBy3D( mesh3D, mesh3D, theOutsideNormal=True)
print "Nb re-reoriented faces:", nbRev
print("Nb re-reoriented faces:", nbRev)

View File

@ -44,40 +44,40 @@ group = tetra.CreateEmptyGroup( SMESH.FACE, 'Group' )
nbAdd = group.Add( [ 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76 ] )
# Print information about the mesh
print "Information about mesh:"
print "Number of nodes : ", tetra.NbNodes()
print "Number of edges : ", tetra.NbEdges()
print "Number of faces : ", tetra.NbFaces()
print " triangles : ", tetra.NbTriangles()
print " quadrangles : ", tetra.NbQuadrangles()
print " polygons : ", tetra.NbPolygons()
print "Number of volumes : ", tetra.NbVolumes()
print " tetrahedrons: ", tetra.NbTetras()
print " hexahedrons : ", tetra.NbHexas()
print " prisms : ", tetra.NbPrisms()
print " pyramids : ", tetra.NbPyramids()
print " polyhedrons : ", tetra.NbPolyhedrons()
print("Information about mesh:")
print("Number of nodes : ", tetra.NbNodes())
print("Number of edges : ", tetra.NbEdges())
print("Number of faces : ", tetra.NbFaces())
print(" triangles : ", tetra.NbTriangles())
print(" quadrangles : ", tetra.NbQuadrangles())
print(" polygons : ", tetra.NbPolygons())
print("Number of volumes : ", tetra.NbVolumes())
print(" tetrahedrons: ", tetra.NbTetras())
print(" hexahedrons : ", tetra.NbHexas())
print(" prisms : ", tetra.NbPrisms())
print(" pyramids : ", tetra.NbPyramids())
print(" polyhedrons : ", tetra.NbPolyhedrons())
# Get Information About Mesh by GetMeshInfo
print "\nInformation about mesh by GetMeshInfo:"
print("\nInformation about mesh by GetMeshInfo:")
info = smesh.GetMeshInfo(tetra)
keys = info.keys(); keys.sort()
keys = list(info.keys()); keys.sort()
for i in keys:
print " %s : %d" % ( i, info[i] )
print(" %s : %d" % ( i, info[i] ))
pass
# Get Information About Group by GetMeshInfo
print "\nInformation about group by GetMeshInfo:"
print("\nInformation about group by GetMeshInfo:")
info = smesh.GetMeshInfo(group)
keys = info.keys(); keys.sort()
keys = list(info.keys()); keys.sort()
for i in keys:
print " %s : %d" % ( i, info[i] )
print(" %s : %d" % ( i, info[i] ))
pass
# Get Information About SubMesh by GetMeshInfo
print "\nInformation about Submesh by GetMeshInfo:"
print("\nInformation about Submesh by GetMeshInfo:")
info = smesh.GetMeshInfo(submesh)
keys = info.keys(); keys.sort()
keys = list(info.keys()); keys.sort()
for i in keys:
print " %s : %d" % ( i, info[i] )
print(" %s : %d" % ( i, info[i] ))
pass

View File

@ -116,8 +116,8 @@ def main(plugin_name, dummymeshhelp = True, output_file = "smeshBuilder.py"):
f.close()
pass
pass
except Exception, e:
print e
except Exception as e:
print(e)
pass
pass

View File

@ -155,7 +155,7 @@ class SMeshStudyTools:
self.smeshGui = salome.ImportComponentGUI("SMESH")
if not helper.SalomeGUI.hasDesktop():
print "displayMeshObject: no desktop available"
print("displayMeshObject: no desktop available")
return
self.smeshGui.CreateAndDisplayActor(entry)

View File

@ -67,7 +67,7 @@ plane_mesh = salome.IDToObject( Id_face1)
mesh = smesh.Mesh(plane_mesh, "Mesh_1")
print"---------------------Hypothesis and Algorithms"
print("---------------------Hypothesis and Algorithms")
#---------------- NumberOfSegments
@ -75,12 +75,12 @@ numberOfSegment = 9
algoWireDes = mesh.Segment()
listHyp = algoWireDes.GetCompatibleHypothesis()
print algoWireDes.GetName()
print(algoWireDes.GetName())
algoWireDes.SetName("Ware descritisation")
hypNbSeg = algoWireDes.NumberOfSegments(numberOfSegment)
print hypNbSeg.GetName()
print hypNbSeg.GetNumberOfSegments()
print(hypNbSeg.GetName())
print(hypNbSeg.GetNumberOfSegments())
smesh.SetName(hypNbSeg, "Nb. Segments")
@ -89,19 +89,19 @@ maxElementArea = 200
algoMef = mesh.Triangle()
listHyp = algoMef.GetCompatibleHypothesis()
print algoMef.GetName()
print(algoMef.GetName())
algoMef.SetName("Triangle (Mefisto)")
hypArea200 = algoMef.MaxElementArea(maxElementArea)
print hypArea200.GetName()
print hypArea200.GetMaxElementArea()
print(hypArea200.GetName())
print(hypArea200.GetMaxElementArea())
smesh.SetName(hypArea200, "Max. Element Area")
print "---------------------Compute the mesh"
print("---------------------Compute the mesh")
ret = mesh.Compute()
print ret
print(ret)
salome.sg.updateObjBrowser(True)

Some files were not shown because too many files have changed in this diff Show More