smesh/doc/salome/examples/measurements_ex03.py

80 lines
2.1 KiB
Python
Raw Normal View History

# Basic Properties
import salome
salome.salome_init_without_session()
import GEOM
from salome.geom import geomBuilder
2017-06-13 15:01:10 +05:00
geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
2017-06-13 15:01:10 +05:00
smesh = smeshBuilder.New()
# create a box
box = geompy.MakeBoxDXDYDZ(100,100,100)
face = geompy.SubShapeAllSorted(box, geompy.ShapeType['FACE'])[0]
# mesh a box
mesh = smesh.Mesh(box)
submesh_1d = mesh.Segment().NumberOfSegments(5)
submesh_2d = mesh.Quadrangle()
submesh_3d = mesh.Hexahedron()
submesh_2d_face = mesh.Triangle(face)
mesh.Compute()
# create a group
group_2d = mesh.Group(face)
# compute basic properties
2017-03-20 17:27:30 +05:00
print("Get basic properties: approach 1 (via measurements tool) ----")
measure = smesh.CreateMeasurements()
2017-03-20 17:27:30 +05:00
print("* for mesh:")
print(" length:", measure.Length(mesh.mesh))
print(" area:", measure.Area(mesh.mesh))
print(" volume:", measure.Volume(mesh.mesh))
2017-03-20 17:27:30 +05:00
print("* for group (2d):")
print(" length:", measure.Length(group_2d))
print(" area:", measure.Area(group_2d))
print(" volume:", measure.Volume(group_2d))
2017-03-20 17:27:30 +05:00
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()
2017-03-20 17:27:30 +05:00
print("Get basic properties: approach 2 (via smeshBuilder) ----")
2017-03-20 17:27:30 +05:00
print("* for mesh:")
print(" length:", smesh.GetLength(mesh))
print(" area:", smesh.GetArea(mesh))
print(" volume:", smesh.GetVolume(mesh))
2017-03-20 17:27:30 +05:00
print("* for group (2d):")
print(" length:", smesh.GetLength(group_2d))
print(" area:", smesh.GetArea(group_2d))
print(" volume:", smesh.GetVolume(group_2d))
2017-03-20 17:27:30 +05:00
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))
2017-03-20 17:27:30 +05:00
print("Get basic properties: approach 3 (via smeshBuilder.Mesh) ----")
2017-03-20 17:27:30 +05:00
print("* for mesh:")
print(" length:", mesh.GetLength())
print(" area:", mesh.GetArea())
print(" volume:", mesh.GetVolume())
2017-03-20 17:27:30 +05:00
print("* for group (2d): unsupported")
2017-03-20 17:27:30 +05:00
print("* for submesh (2d): unsupported")