Commit ed435703 authored by Alexander Dielen's avatar Alexander Dielen

additional read/write tests

parent c500f1ec
Pipeline #7292 passed with stages
in 5 minutes and 40 seconds
solid
facet normal 0 -0 -1
outer loop
vertex 0 0 0
vertex 1 1 0
vertex 1 0 0
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0 0 0
vertex 0 1 0
vertex 1 1 0
endloop
endfacet
facet normal -1 0 -0
outer loop
vertex 0 0 0
vertex 0 1 1
vertex 0 1 0
endloop
endfacet
facet normal -1 0 0
outer loop
vertex 0 0 0
vertex 0 0 1
vertex 0 1 1
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 0 1 0
vertex 1 1 1
vertex 1 1 0
endloop
endfacet
facet normal -0 1 0
outer loop
vertex 0 1 0
vertex 0 1 1
vertex 1 1 1
endloop
endfacet
facet normal 1 0 -0
outer loop
vertex 1 0 0
vertex 1 1 0
vertex 1 1 1
endloop
endfacet
facet normal 1 0 0
outer loop
vertex 1 0 0
vertex 1 1 1
vertex 1 0 1
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex 0 0 0
vertex 1 0 0
vertex 1 0 1
endloop
endfacet
facet normal -0 -1 0
outer loop
vertex 0 0 0
vertex 1 0 1
vertex 0 0 1
endloop
endfacet
facet normal 0 -0 1
outer loop
vertex 0 0 1
vertex 1 0 1
vertex 1 1 1
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 0 0 1
vertex 1 1 1
vertex 0 1 1
endloop
endfacet
endsolid
import unittest
import openmesh
import os
import numpy as np
class ReadWriteOBJ(unittest.TestCase):
def setUp(self):
if not os.path.exists('OutFiles'):
os.makedirs('OutFiles')
def test_read_write_read(self):
mesh1 = openmesh.read_trimesh("TestFiles/cube-minimal.obj")
openmesh.write_mesh('OutFiles/test_read_write_read.obj', mesh1)
mesh2 = openmesh.read_trimesh('OutFiles/test_read_write_read.obj')
self.assertTrue(np.allclose(mesh1.points(), mesh2.points()))
self.assertTrue(np.array_equal(mesh1.face_vertex_indices(), mesh2.face_vertex_indices()))
def test_load_simple_obj(self):
self.mesh = openmesh.read_trimesh("TestFiles/cube-minimal.obj")
self.assertEqual(self.mesh.n_vertices(), 8)
......
......@@ -4,13 +4,19 @@ import os
import numpy as np
class ReadWriteOFF(unittest.TestCase):
def setUp(self):
if not os.path.exists('OutFiles'):
os.makedirs('OutFiles')
def test_read_write_read(self):
mesh1 = openmesh.read_trimesh("TestFiles/cube-minimal.obj")
openmesh.write_mesh('OutFiles/test_read_write_read.off', mesh1)
mesh2 = openmesh.read_trimesh('OutFiles/test_read_write_read.off')
self.assertTrue(np.allclose(mesh1.points(), mesh2.points()))
self.assertTrue(np.array_equal(mesh1.face_vertex_indices(), mesh2.face_vertex_indices()))
def test_load_simple_off_file(self):
self.mesh = openmesh.read_trimesh("TestFiles/cube1.off")
self.assertEqual(self.mesh.n_vertices(), 7526)
......
......@@ -10,6 +10,13 @@ class ReadWriteOM(unittest.TestCase):
if not os.path.exists('OutFiles'):
os.makedirs('OutFiles')
def test_read_write_read(self):
mesh1 = openmesh.read_trimesh("TestFiles/cube-minimal.obj")
openmesh.write_mesh('OutFiles/test_read_write_read.om', mesh1)
mesh2 = openmesh.read_trimesh('OutFiles/test_read_write_read.om')
self.assertTrue(np.allclose(mesh1.points(), mesh2.points()))
self.assertTrue(np.array_equal(mesh1.face_vertex_indices(), mesh2.face_vertex_indices()))
def test_load_simple_om_force_vertex_colors_although_not_available(self):
with self.assertRaises(RuntimeError):
openmesh.read_trimesh("TestFiles/cube-minimal.om", vertex_color=True)
......
......@@ -2,12 +2,21 @@ import unittest
import openmesh
import os
import numpy as np
class ReadWritePLY(unittest.TestCase):
def setUp(self):
if not os.path.exists('OutFiles'):
os.makedirs('OutFiles')
def test_read_write_read(self):
mesh1 = openmesh.read_trimesh("TestFiles/cube-minimal.obj")
openmesh.write_mesh('OutFiles/test_read_write_read.ply', mesh1)
mesh2 = openmesh.read_trimesh('OutFiles/test_read_write_read.ply')
self.assertTrue(np.allclose(mesh1.points(), mesh2.points()))
self.assertTrue(np.array_equal(mesh1.face_vertex_indices(), mesh2.face_vertex_indices()))
def test_load_simple_point_ply_file_with_bad_encoding(self):
self.mesh = openmesh.read_trimesh("TestFiles/pointCloudBadEncoding.ply")
self.assertEqual(self.mesh.n_vertices(), 10)
......
import unittest
import openmesh
import os
import numpy as np
class ReadWriteSTL(unittest.TestCase):
def setUp(self):
if not os.path.exists('OutFiles'):
os.makedirs('OutFiles')
def test_read_write_read(self):
mesh1 = openmesh.read_trimesh("TestFiles/cube-minimal.stl")
openmesh.write_mesh('OutFiles/test_read_write_read.stl', mesh1)
mesh2 = openmesh.read_trimesh('OutFiles/test_read_write_read.stl')
self.assertTrue(np.allclose(mesh1.points(), mesh2.points()))
self.assertTrue(np.array_equal(mesh1.face_vertex_indices(), mesh2.face_vertex_indices()))
def test_load_simple_stl_file(self):
self.mesh = openmesh.read_trimesh("TestFiles/cube1.stl")
self.assertEqual(self.mesh.n_vertices(), 7526)
......
import unittest
import openmesh
import os
import numpy as np
class ReadWriteVTK(unittest.TestCase):
def setUp(self):
if not os.path.exists('OutFiles'):
os.makedirs('OutFiles')
def test_read_write_read(self):
mesh1 = openmesh.read_trimesh("TestFiles/cube-minimal.obj")
openmesh.write_mesh('OutFiles/test_read_write_read.vtk', mesh1)
# since there is no vtk reader, all we can do is check that
# write_mesh() doesn't throw
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