Commit 8b7fc743 authored by Alexander Dielen's avatar Alexander Dielen

added tests for getMesh(), addMesh() and vertex_property()

parent 6ec7a795
# Include Testing package
if(BUILD_TESTING)
include( ${CMAKE_SOURCE_DIR}/OpenFlipper/tests/testGenerators.cmake )
# ========================================================================
# ========================================================================
# Tests
# ========================================================================
# ========================================================================
run_local_script_test("addMesh.ofp")
run_local_script_test("properties.ofp")
endif()
import OpenMeshPython as om
import numpy as np
core.clearAll()
original = om.read_trimesh("OpenFlipper/cube1.off")
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")
if not np.allclose(copy.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):
print("error: vertex_property_array()")
print("vertex property changed as a result of addMesh() and getMesh()")
core.exitFailure()
import OpenMeshPython as om
import numpy as np
core.clearAll()
id = primitivesgenerator.addSphere()
mesh = om.getMesh(id)
if not mesh.has_vertex_property("v:points"):
core.exitFailure()
for vh in mesh.vertices():
if not np.allclose(mesh.vertex_property("v:points", vh), mesh.point(vh)):
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