Commit 3831af7a authored by Alexander Dielen's avatar Alexander Dielen

added a test for getMesh()

parent 98b22656
......@@ -10,6 +10,7 @@ if(BUILD_TESTING)
# ========================================================================
run_local_script_test_with_input_file("addMesh.ofp" "cube1.off")
run_local_script_test("getMesh.ofp")
run_local_script_test("properties.ofp")
endif()
......@@ -9,15 +9,36 @@ original_verts = original.points().copy()
original_noise = np.random.uniform(size=(original.n_vertices(), 10))
original.set_vertex_property_array("noise", original_noise)
om.addMesh(original, "mesh")
copy = om.getMesh("mesh")
id_ = om.addMesh(original, "mesh")
if not np.allclose(copy.points(), original_verts):
# get the mesh using its id
# ============================
copy1 = om.getMesh(id_)
if not np.allclose(copy1.points(), original_verts):
print("error: points()")
print("vertex coordinates changed as a result of addMesh() and getMesh()")
core.exitFailure()
if not np.allclose(copy1.vertex_property_array("noise"), original_noise):
print("error: vertex_property_array()")
print("vertex property changed as a result of addMesh() and getMesh()")
core.exitFailure()
# get the mesh using its name
# ============================
copy2 = om.getMesh("mesh")
if not np.allclose(copy2.points(), original_verts):
print("error: points()")
print("vertex coordinates changed as a result of addMesh() and getMesh()")
core.exitFailure()
if not np.allclose(copy.vertex_property_array("noise"), original_noise):
if not np.allclose(copy2.vertex_property_array("noise"), original_noise):
print("error: vertex_property_array()")
print("vertex property changed as a result of addMesh() and getMesh()")
core.exitFailure()
import OpenMeshPython as om
core.clearAll()
# add some primitives
# ============================
bspline = primitivesgenerator.addRandomBSplineSurface()
hexcube = primitivesgenerator.addHexahedralCube()
trimesh = primitivesgenerator.addIcosahedron()
polymesh = primitivesgenerator.addDodecahedron()
# get objects
# ============================
try:
mesh = om.getMesh(bspline)
except RuntimeError:
pass
else:
print("getMesh() was called with the id of a BSplineSurface but did not throw an exception")
core.exitFailure()
try:
mesh = om.getMesh(hexcube)
except RuntimeError:
pass
else:
print("getMesh() was called with the id of a HexahedralMesh but did not throw an exception")
core.exitFailure()
icosahedron = om.getMesh(trimesh)
if not icosahedron.n_vertices() == 12:
core.exitFailure()
if not icosahedron.n_edges() == 30:
core.exitFailure()
if not icosahedron.n_faces() == 20:
core.exitFailure()
dodecahedron = om.getMesh(polymesh)
if not dodecahedron.n_vertices() == 20:
core.exitFailure()
if not dodecahedron.n_edges() == 30:
core.exitFailure()
if not dodecahedron.n_faces() == 12:
core.exitFailure()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment