Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenMesh
openmesh-python
Commits
ed435703
Commit
ed435703
authored
Jul 09, 2018
by
Alexander Dielen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
additional read/write tests
parent
c500f1ec
Pipeline
#7292
passed with stages
in 5 minutes and 40 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
166 additions
and
1 deletion
+166
-1
tests/TestFiles/cube-minimal.stl
tests/TestFiles/cube-minimal.stl
+98
-0
tests/test_read_write_obj.py
tests/test_read_write_obj.py
+14
-0
tests/test_read_write_off.py
tests/test_read_write_off.py
+7
-1
tests/test_read_write_om.py
tests/test_read_write_om.py
+7
-0
tests/test_read_write_ply.py
tests/test_read_write_ply.py
+9
-0
tests/test_read_write_stl.py
tests/test_read_write_stl.py
+14
-0
tests/test_read_write_vtk.py
tests/test_read_write_vtk.py
+17
-0
No files found.
tests/TestFiles/cube-minimal.stl
0 → 100644
View file @
ed435703
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
tests/test_read_write_obj.py
View file @
ed435703
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
)
...
...
tests/test_read_write_off.py
View file @
ed435703
...
...
@@ -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
)
...
...
tests/test_read_write_om.py
View file @
ed435703
...
...
@@ -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
)
...
...
tests/test_read_write_ply.py
View file @
ed435703
...
...
@@ -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
)
...
...
tests/test_read_write_stl.py
View file @
ed435703
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
)
...
...
tests/test_read_write_vtk.py
0 → 100644
View file @
ed435703
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment