Commit 7a27451d authored by Alexander Dielen's avatar Alexander Dielen

updated tests to use numpy arrays

parent 45efc7b9
import unittest
import openmesh
import numpy as np
class AddFace(unittest.TestCase):
def test_add_triangles_to_trimesh(self):
......@@ -8,10 +10,10 @@ class AddFace(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 0, 0])))
# Add two faces
face_vhandles = []
......@@ -44,10 +46,10 @@ class AddFace(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 0, 0])))
# Add two faces
face_vhandles = []
......@@ -74,14 +76,14 @@ class AddFace(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, -1])))
# Add six faces to form a cube
face_vhandles = []
......@@ -203,13 +205,13 @@ class AddFace(unittest.TestCase):
# 3 4 5
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(2, 2, 2)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(3, 3, 3)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(4, 4, 4)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(5, 5, 5)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(6, 6, 6)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([2, 2, 2])))
self.vhandle.append(self.mesh.add_vertex(np.array([3, 3, 3])))
self.vhandle.append(self.mesh.add_vertex(np.array([4, 4, 4])))
self.vhandle.append(self.mesh.add_vertex(np.array([5, 5, 5])))
self.vhandle.append(self.mesh.add_vertex(np.array([6, 6, 6])))
self.mesh.add_face(self.vhandle[0], self.vhandle[1], self.vhandle[2])
self.mesh.add_face(self.vhandle[0], self.vhandle[3], self.vhandle[4])
......@@ -228,10 +230,10 @@ class AddFace(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 0, 0])))
# Add one face
face_vhandles = []
......@@ -258,14 +260,14 @@ class AddFace(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, -1])))
# Add six faces to form a cube
face_vhandles = []
......
import unittest
import openmesh
import numpy as np
class BoundaryTriangleMesh(unittest.TestCase):
def setUp(self):
......@@ -9,15 +11,15 @@ class BoundaryTriangleMesh(unittest.TestCase):
# Add some vertices
self.vhandle = []
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(2, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0,-1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(2,-1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(3, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([2, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0,-1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([2,-1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([3, 0, 0])))
# Single point
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0,-2, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0,-2, 0])))
# Add five faces
self.fhandle = []
......
import unittest
import openmesh
import numpy as np
class DeleteFaceTriangleMesh(unittest.TestCase):
def test_delete_half_triangle_mesh_cube_no_edge_status(self):
......@@ -8,14 +10,14 @@ class DeleteFaceTriangleMesh(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, -1])))
# Add six faces to form a cube
face_vhandles = []
......@@ -158,14 +160,14 @@ class DeleteFaceTriangleMesh(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, -1])))
# Add six faces to form a cube
face_vhandles = []
......@@ -308,14 +310,14 @@ class DeleteFaceTriangleMesh(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, -1])))
# Add six faces to form a cube
face_vhandles = []
......@@ -418,14 +420,14 @@ class DeleteFaceTriangleMesh(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, 1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, -1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d( 1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(-1, 1, -1)))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, 1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, -1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([ 1, 1, -1])))
self.vhandle.append(self.mesh.add_vertex(np.array([-1, 1, -1])))
# Add six faces to form a cube
face_vhandles = []
......
import unittest
import openmesh
import numpy as np
class Property(unittest.TestCase):
def setUp(self):
......@@ -9,10 +11,10 @@ class Property(unittest.TestCase):
def test_vertex_property_copy_properties_int(self):
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 0, 0])))
# Add two faces
face_vhandles = []
......@@ -131,10 +133,10 @@ class Property(unittest.TestCase):
self.mesh.request_edge_status()
# Define positions
p1 = openmesh.Vec3d(0, 0, 0)
p2 = openmesh.Vec3d(0, 1, 0)
p3 = openmesh.Vec3d(1, 1, 0)
p4 = openmesh.Vec3d(0, 0, 1)
p1 = np.array([0, 0, 0])
p2 = np.array([0, 1, 0])
p3 = np.array([1, 1, 0])
p4 = np.array([0, 0, 1])
# Add some vertices
vh1 = self.mesh.add_vertex(p1)
......@@ -160,10 +162,10 @@ class Property(unittest.TestCase):
def test_copy_all_properties_vertex_after_remove_of_property(self):
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 0, 0])))
# Add two faces
face_vhandles = []
......
import unittest
import openmesh
import numpy as np
class Python(unittest.TestCase):
def setUp(self):
......@@ -9,11 +11,11 @@ class Python(unittest.TestCase):
# Add some vertices
self.vhandle = []
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(2, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0,-1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(2,-1, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([2, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0,-1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([2,-1, 0])))
# Add four faces using Python lists
vertex_list = [self.vhandle[0], self.vhandle[1], self.vhandle[2]]
......@@ -55,8 +57,8 @@ class Python(unittest.TestCase):
self.assertTrue(propman.property_exists(self.mesh, "prop"))
# Check initial property values
for v in self.mesh.vertices():
self.assertEqual(propman[v], None)
# for v in self.mesh.vertices():
# self.assertEqual(propman[v], None)
# Set property values
propman.set_range(self.mesh.vertices(), 0.0)
......
import unittest
import openmesh
import os
import numpy as np
class ReadWriteOFF(unittest.TestCase):
def setUp(self):
self.mesh = openmesh.TriMesh()
if not os.path.exists('OutFiles'):
os.makedirs('OutFiles')
def test_load_simple_off_file(self):
ok = openmesh.read_mesh(self.mesh, "TestFiles/cube1.off")
......@@ -18,13 +24,13 @@ class ReadWriteOFF(unittest.TestCase):
def test_write_and_read_vertex_colors_to_and_from_off_file(self):
self.mesh.request_vertex_colors()
self.mesh.add_vertex(openmesh.Vec3d(0, 0, 1))
self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0))
self.mesh.add_vertex(openmesh.Vec3d(0, 1, 1))
self.mesh.add_vertex(openmesh.Vec3d(1, 0, 1))
self.mesh.add_vertex(np.array([0, 0, 1]))
self.mesh.add_vertex(np.array([0, 1, 0]))
self.mesh.add_vertex(np.array([0, 1, 1]))
self.mesh.add_vertex(np.array([1, 0, 1]))
# Using the default openmesh Python color type
testColor = openmesh.Vec4f(1.0, 0.5, 0.25, 1.0)
testColor = np.array([1.0, 0.5, 0.25, 1.0])
# Setting colors (different from black)
for v in self.mesh.vertices():
......@@ -43,8 +49,8 @@ class ReadWriteOFF(unittest.TestCase):
options += openmesh.Options.VertexColor
options += openmesh.Options.ColorFloat
openmesh.write_mesh(self.mesh, "TestFiles/temp.off", options)
openmesh.read_mesh(self.mesh, "TestFiles/temp.off", options)
openmesh.write_mesh(self.mesh, "OutFiles/temp.off", options)
openmesh.read_mesh(self.mesh, "OutFiles/temp.off", options)
# Check if vertices still have the same color
count = 0
......@@ -71,9 +77,9 @@ class ReadWriteOFF(unittest.TestCase):
options += openmesh.Options.ColorFloat
# Write the mesh
ok = openmesh.write_mesh(self.mesh, "TestFiles/cube_floating.off", options)
ok = openmesh.write_mesh(self.mesh, "OutFiles/cube_floating.off", options)
self.assertTrue(ok)
ok = openmesh.read_mesh(self.mesh, "TestFiles/cube_floating.off", options)
ok = openmesh.read_mesh(self.mesh, "OutFiles/cube_floating.off", options)
self.assertTrue(ok)
self.assertEqual(self.mesh.n_vertices(), 8)
......@@ -118,14 +124,14 @@ class ReadWriteOFF(unittest.TestCase):
options += openmesh.Options.ColorFloat
# Write the mesh
ok = openmesh.write_mesh(self.mesh, "TestFiles/cube_floating_binary.off", options)
ok = openmesh.write_mesh(self.mesh, "OutFiles/cube_floating_binary.off", options)
self.assertTrue(ok)
self.mesh.clear()
options.clear()
options += openmesh.Options.VertexColor
options += openmesh.Options.Binary
options += openmesh.Options.ColorFloat
ok = openmesh.read_mesh(self.mesh, "TestFiles/cube_floating_binary.off", options)
ok = openmesh.read_mesh(self.mesh, "OutFiles/cube_floating_binary.off", options)
self.assertTrue(ok)
self.assertEqual(self.mesh.n_vertices(), 8)
......
......@@ -2,10 +2,14 @@ import unittest
import openmesh
import os
import numpy as np
class ReadWriteOM(unittest.TestCase):
def setUp(self):
self.mesh = openmesh.TriMesh()
if not os.path.exists('OutFiles'):
os.makedirs('OutFiles')
def test_load_simple_om_force_vertex_colors_although_not_available(self):
self.mesh.request_vertex_colors()
......@@ -97,12 +101,12 @@ class ReadWriteOM(unittest.TestCase):
self.mesh.release_vertex_colors()
def test_write_triangle(self):
filename = "TestFiles/triangle-minimal.om";
filename = "OutFiles/triangle-minimal.om";
# Generate data
v1 = self.mesh.add_vertex(openmesh.Vec3d(1.0, 0.0, 0.0))
v2 = self.mesh.add_vertex(openmesh.Vec3d(0.0, 1.0, 0.0))
v3 = self.mesh.add_vertex(openmesh.Vec3d(0.0, 0.0, 1.0))
v1 = self.mesh.add_vertex(np.array([1.0, 0.0, 0.0]))
v2 = self.mesh.add_vertex(np.array([0.0, 1.0, 0.0]))
v3 = self.mesh.add_vertex(np.array([0.0, 0.0, 1.0]))
self.mesh.add_face(v1, v2, v3)
# Save
......@@ -121,9 +125,9 @@ class ReadWriteOM(unittest.TestCase):
self.assertEqual(self.mesh.n_edges(), 3)
self.assertEqual(self.mesh.n_faces(), 1)
self.assertEqual(self.mesh.point(v1), openmesh.Vec3d(1.0, 0.0, 0.0))
self.assertEqual(self.mesh.point(v2), openmesh.Vec3d(0.0, 1.0, 0.0))
self.assertEqual(self.mesh.point(v3), openmesh.Vec3d(0.0, 0.0, 1.0))
self.assertTrue(np.allclose(self.mesh.point(v1), np.array([1.0, 0.0, 0.0])))
self.assertTrue(np.allclose(self.mesh.point(v2), np.array([0.0, 1.0, 0.0])))
self.assertTrue(np.allclose(self.mesh.point(v3), np.array([0.0, 0.0, 1.0])))
# Cleanup
os.remove(filename)
......@@ -135,17 +139,17 @@ class ReadWriteOM(unittest.TestCase):
options += openmesh.Options.VertexColor
options += openmesh.Options.ColorFloat
filename = "TestFiles/triangle-minimal-ColorsPerVertex.om"
filename = "OutFiles/triangle-minimal-ColorsPerVertex.om"
# Generate data
v1 = self.mesh.add_vertex(openmesh.Vec3d(1.0, 0.0, 0.0))
v2 = self.mesh.add_vertex(openmesh.Vec3d(0.0, 1.0, 0.0))
v3 = self.mesh.add_vertex(openmesh.Vec3d(0.0, 0.0, 1.0))
v1 = self.mesh.add_vertex(np.array([1.0, 0.0, 0.0]))
v2 = self.mesh.add_vertex(np.array([0.0, 1.0, 0.0]))
v3 = self.mesh.add_vertex(np.array([0.0, 0.0, 1.0]))
self.mesh.add_face(v1, v2, v3)
c1 = openmesh.Vec4f(0.00, 0.00, 0.50, 1.00)
c2 = openmesh.Vec4f(0.25, 0.00, 0.00, 1.00)
c3 = openmesh.Vec4f(0.00, 0.75, 0.00, 1.00)
c1 = np.array([0.00, 0.00, 0.50, 1.00])
c2 = np.array([0.25, 0.00, 0.00, 1.00])
c3 = np.array([0.00, 0.75, 0.00, 1.00])
self.mesh.set_color(v1, c1)
self.mesh.set_color(v2, c2)
......@@ -170,9 +174,9 @@ class ReadWriteOM(unittest.TestCase):
self.assertEqual(self.mesh.n_edges(), 3)
self.assertEqual(self.mesh.n_faces(), 1)
self.assertEqual(cmpMesh.point(v1), openmesh.Vec3d(1.0, 0.0, 0.0))
self.assertEqual(cmpMesh.point(v2), openmesh.Vec3d(0.0, 1.0, 0.0))
self.assertEqual(cmpMesh.point(v3), openmesh.Vec3d(0.0, 0.0, 1.0))
self.assertTrue(np.allclose(cmpMesh.point(v1), np.array([1.0, 0.0, 0.0])))
self.assertTrue(np.allclose(cmpMesh.point(v2), np.array([0.0, 1.0, 0.0])))
self.assertTrue(np.allclose(cmpMesh.point(v3), np.array([0.0, 0.0, 1.0])))
self.assertAlmostEqual(cmpMesh.color(v1)[0], c1[0], 2)
self.assertAlmostEqual(cmpMesh.color(v1)[1], c1[1], 2)
......
import unittest
import openmesh
import os
class ReadWritePLY(unittest.TestCase):
def setUp(self):
self.mesh = openmesh.TriMesh()
if not os.path.exists('OutFiles'):
os.makedirs('OutFiles')
def test_load_simple_point_ply_file_with_bad_encoding(self):
ok = openmesh.read_mesh(self.mesh, "TestFiles/pointCloudBadEncoding.ply")
......@@ -140,12 +143,12 @@ class ReadWritePLY(unittest.TestCase):
options += openmesh.Options.Binary
ok = openmesh.write_mesh(self.mesh, "TestFiles/meshlab_binary.ply", options)
ok = openmesh.write_mesh(self.mesh, "OutFiles/meshlab_binary.ply", options)
self.assertTrue(ok)
self.mesh.clear
ok = openmesh.read_mesh(self.mesh, "TestFiles/meshlab_binary.ply", options)
ok = openmesh.read_mesh(self.mesh, "OutFiles/meshlab_binary.ply", options)
self.assertTrue(ok)
self.assertEqual(self.mesh.n_vertices(), 8)
......@@ -186,11 +189,11 @@ class ReadWritePLY(unittest.TestCase):
options += openmesh.Options.ColorFloat
ok = openmesh.write_mesh(self.mesh, "TestFiles/meshlab_float.ply", options)
ok = openmesh.write_mesh(self.mesh, "OutFiles/meshlab_float.ply", options)
self.assertTrue(ok)
self.mesh.clear
ok = openmesh.read_mesh(self.mesh, "TestFiles/meshlab_float.ply", options)
ok = openmesh.read_mesh(self.mesh, "OutFiles/meshlab_float.ply", options)
self.assertTrue(ok)
self.assertEqual(self.mesh.n_vertices(), 8)
......@@ -233,11 +236,11 @@ class ReadWritePLY(unittest.TestCase):
options += openmesh.Options.ColorFloat
options += openmesh.Options.Binary
ok = openmesh.write_mesh(self.mesh, "TestFiles/meshlab_binary_float.ply", options)
ok = openmesh.write_mesh(self.mesh, "OutFiles/meshlab_binary_float.ply", options)
self.assertTrue(ok)
self.mesh.clear
ok = openmesh.read_mesh(self.mesh, "TestFiles/meshlab_binary_float.ply", options)
ok = openmesh.read_mesh(self.mesh, "OutFiles/meshlab_binary_float.ply", options)
self.assertTrue(ok)
self.assertEqual(self.mesh.n_vertices(), 8)
......
import unittest
import openmesh
import numpy as np
class SplitCopy(unittest.TestCase):
def test_split_copy_triangle_mesh(self):
......@@ -8,10 +10,10 @@ class SplitCopy(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0.25, 0.25, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0.25, 0.25, 0])))
# Add one face
face_vhandles = []
......@@ -46,11 +48,11 @@ class SplitCopy(unittest.TestCase):
self.vhandle = []
# Add some vertices
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 1, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(1, 0, 0)))
self.vhandle.append(self.mesh.add_vertex(openmesh.Vec3d(0.5, 0.5, 0)))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 1, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([1, 0, 0])))
self.vhandle.append(self.mesh.add_vertex(np.array([0.5, 0.5, 0])))
# Add one face
face_vhandles = []
......