2013-08-08 21:17:00 +06:00
|
|
|
# Basic Properties
|
|
|
|
|
|
|
|
import salome
|
2021-08-12 14:38:10 +05:00
|
|
|
salome.salome_init_without_session()
|
2013-08-08 21:17:00 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
from salome.geom import geomBuilder
|
2013-08-08 21:17:00 +06:00
|
|
|
from salome.smesh import smeshBuilder
|
2022-04-11 18:28:01 +05:00
|
|
|
|
|
|
|
geom_builder = geomBuilder.New()
|
|
|
|
smesh_builder = smeshBuilder.New()
|
2013-08-08 21:17:00 +06:00
|
|
|
|
2013-08-20 20:25:57 +06:00
|
|
|
# create a box
|
2022-04-11 18:28:01 +05:00
|
|
|
box = geom_builder.MakeBoxDXDYDZ(100,100,100)
|
|
|
|
face = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType['FACE'])[0]
|
2013-08-08 21:17:00 +06:00
|
|
|
|
2013-08-20 20:25:57 +06:00
|
|
|
# mesh a box
|
2022-04-11 18:28:01 +05:00
|
|
|
mesh = smesh_builder.Mesh(box)
|
2013-08-20 20:25:57 +06:00
|
|
|
submesh_1d = mesh.Segment().NumberOfSegments(5)
|
|
|
|
submesh_2d = mesh.Quadrangle()
|
|
|
|
submesh_3d = mesh.Hexahedron()
|
|
|
|
submesh_2d_face = mesh.Triangle(face)
|
2023-02-21 18:59:44 +05:00
|
|
|
if not mesh.Compute(): raise Exception("Error when computing Mesh")
|
2013-08-08 21:17:00 +06:00
|
|
|
|
2013-08-20 20:25:57 +06:00
|
|
|
# create a group
|
2013-08-08 21:17:00 +06:00
|
|
|
|
2013-08-20 20:25:57 +06:00
|
|
|
group_2d = mesh.Group(face)
|
2013-08-08 21:17:00 +06:00
|
|
|
|
2013-08-20 20:25:57 +06:00
|
|
|
# compute basic properties
|
2013-08-08 21:17:00 +06:00
|
|
|
|
2017-03-20 17:27:30 +05:00
|
|
|
print("Get basic properties: approach 1 (via measurements tool) ----")
|
2013-08-20 20:25:57 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
measure = smesh_builder.CreateMeasurements()
|
2013-08-20 20:25:57 +06:00
|
|
|
|
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))
|
2013-08-20 20:25:57 +06:00
|
|
|
|
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))
|
2013-08-20 20:25:57 +06:00
|
|
|
|
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()))
|
2013-08-20 20:25:57 +06:00
|
|
|
|
|
|
|
measure.UnRegister()
|
|
|
|
|
2017-03-20 17:27:30 +05:00
|
|
|
print("Get basic properties: approach 2 (via smeshBuilder) ----")
|
2013-08-20 20:25:57 +06:00
|
|
|
|
2017-03-20 17:27:30 +05:00
|
|
|
print("* for mesh:")
|
2022-04-11 18:28:01 +05:00
|
|
|
print(" length:", smesh_builder.GetLength(mesh))
|
|
|
|
print(" area:", smesh_builder.GetArea(mesh))
|
|
|
|
print(" volume:", smesh_builder.GetVolume(mesh))
|
2013-08-20 20:25:57 +06:00
|
|
|
|
2017-03-20 17:27:30 +05:00
|
|
|
print("* for group (2d):")
|
2022-04-11 18:28:01 +05:00
|
|
|
print(" length:", smesh_builder.GetLength(group_2d))
|
|
|
|
print(" area:", smesh_builder.GetArea(group_2d))
|
|
|
|
print(" volume:", smesh_builder.GetVolume(group_2d))
|
2013-08-20 20:25:57 +06:00
|
|
|
|
2017-03-20 17:27:30 +05:00
|
|
|
print("* for submesh (2d):")
|
2022-04-11 18:28:01 +05:00
|
|
|
print(" length:", smesh_builder.GetLength(submesh_2d_face))
|
|
|
|
print(" area:", smesh_builder.GetArea(submesh_2d_face))
|
|
|
|
print(" volume:", smesh_builder.GetVolume(submesh_2d_face))
|
2013-08-20 20:25:57 +06:00
|
|
|
|
2017-03-20 17:27:30 +05:00
|
|
|
print("Get basic properties: approach 3 (via smeshBuilder.Mesh) ----")
|
2013-08-20 20:25:57 +06:00
|
|
|
|
2017-03-20 17:27:30 +05:00
|
|
|
print("* for mesh:")
|
|
|
|
print(" length:", mesh.GetLength())
|
|
|
|
print(" area:", mesh.GetArea())
|
|
|
|
print(" volume:", mesh.GetVolume())
|
2013-08-20 20:25:57 +06:00
|
|
|
|
2017-03-20 17:27:30 +05:00
|
|
|
print("* for group (2d): unsupported")
|
2013-08-20 20:25:57 +06:00
|
|
|
|
2017-03-20 17:27:30 +05:00
|
|
|
print("* for submesh (2d): unsupported")
|