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
564419a4
Commit
564419a4
authored
Jan 31, 2018
by
Alexander Dielen
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added a new test for the indices functions
parent
5ab16ee0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
tests/test_indices.py
tests/test_indices.py
+84
-0
No files found.
tests/test_indices.py
0 → 100644
View file @
564419a4
import
unittest
import
openmesh
import
numpy
as
np
class
Python
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
mesh
=
openmesh
.
TriMesh
()
openmesh
.
read_mesh
(
self
.
mesh
,
'TestFiles/cube-minimal.obj'
)
def
test_face_vertex_indices_trimesh
(
self
):
indices1
=
self
.
mesh
.
face_vertex_indices
()
indices2
=
self
.
mesh
.
fv_indices
()
for
fh
in
self
.
mesh
.
faces
():
fv_it
=
self
.
mesh
.
fv
(
fh
)
vh1
=
next
(
fv_it
)
vh2
=
next
(
fv_it
)
vh3
=
next
(
fv_it
)
self
.
assertEqual
(
indices1
[
fh
.
idx
(),
0
],
vh1
.
idx
())
self
.
assertEqual
(
indices1
[
fh
.
idx
(),
1
],
vh2
.
idx
())
self
.
assertEqual
(
indices1
[
fh
.
idx
(),
2
],
vh3
.
idx
())
self
.
assertEqual
(
indices2
[
fh
.
idx
(),
0
],
vh1
.
idx
())
self
.
assertEqual
(
indices2
[
fh
.
idx
(),
1
],
vh2
.
idx
())
self
.
assertEqual
(
indices2
[
fh
.
idx
(),
2
],
vh3
.
idx
())
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_faces
(),
3
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_faces
(),
3
))
def
test_face_vertex_indices_polymesh
(
self
):
self
.
mesh
=
openmesh
.
PolyMesh
()
vh1
=
self
.
mesh
.
add_vertex
(
np
.
array
([
0
,
0
,
0
]))
vh2
=
self
.
mesh
.
add_vertex
(
np
.
array
([
1
,
0
,
0
]))
vh3
=
self
.
mesh
.
add_vertex
(
np
.
array
([
1
,
1
,
0
]))
vh4
=
self
.
mesh
.
add_vertex
(
np
.
array
([
0
,
1
,
0
]))
vh5
=
self
.
mesh
.
add_vertex
(
np
.
array
([
2
,
0
,
0
]))
vh6
=
self
.
mesh
.
add_vertex
(
np
.
array
([
3
,
0
,
0
]))
vh7
=
self
.
mesh
.
add_vertex
(
np
.
array
([
3
,
1
,
0
]))
self
.
mesh
.
add_face
(
vh1
,
vh2
,
vh3
,
vh4
)
self
.
mesh
.
add_face
(
vh5
,
vh6
,
vh7
)
# Test setup:
# 3 === 2 6
# | | / |
# | | / |
# | | / |
# 0 === 1 4 === 5
indices1
=
self
.
mesh
.
face_vertex_indices
()
indices2
=
self
.
mesh
.
fv_indices
()
correct
=
np
.
array
([[
0
,
1
,
2
,
3
],
[
4
,
5
,
6
,
-
1
]])
self
.
assertTrue
(
np
.
array_equal
(
indices1
,
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
,
correct
))
def
test_edge_vertex_indices
(
self
):
indices1
=
self
.
mesh
.
edge_vertex_indices
()
indices2
=
self
.
mesh
.
ev_indices
()
for
eh
in
self
.
mesh
.
edges
():
heh
=
self
.
mesh
.
halfedge_handle
(
eh
,
0
)
vh1
=
self
.
mesh
.
from_vertex_handle
(
heh
)
vh2
=
self
.
mesh
.
to_vertex_handle
(
heh
)
self
.
assertEqual
(
indices1
[
eh
.
idx
(),
0
],
vh1
.
idx
())
self
.
assertEqual
(
indices1
[
eh
.
idx
(),
1
],
vh2
.
idx
())
self
.
assertEqual
(
indices2
[
eh
.
idx
(),
0
],
vh1
.
idx
())
self
.
assertEqual
(
indices2
[
eh
.
idx
(),
1
],
vh2
.
idx
())
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_edges
(),
2
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_edges
(),
2
))
def
test_halfedge_vertex_indices
(
self
):
indices1
=
self
.
mesh
.
halfedge_vertex_indices
()
indices2
=
self
.
mesh
.
hv_indices
()
for
heh
in
self
.
mesh
.
halfedges
():
vh1
=
self
.
mesh
.
from_vertex_handle
(
heh
)
vh2
=
self
.
mesh
.
to_vertex_handle
(
heh
)
self
.
assertEqual
(
indices1
[
heh
.
idx
(),
0
],
vh1
.
idx
())
self
.
assertEqual
(
indices1
[
heh
.
idx
(),
1
],
vh2
.
idx
())
self
.
assertEqual
(
indices2
[
heh
.
idx
(),
0
],
vh1
.
idx
())
self
.
assertEqual
(
indices2
[
heh
.
idx
(),
1
],
vh2
.
idx
())
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_halfedges
(),
2
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_halfedges
(),
2
))
if
__name__
==
'__main__'
:
suite
=
unittest
.
TestLoader
().
loadTestsFromTestCase
(
Python
)
unittest
.
TextTestRunner
(
verbosity
=
2
).
run
(
suite
)
Isaak Lim
@lim
mentioned in issue
#3 (closed)
·
Feb 01, 2018
mentioned in issue
#3 (closed)
mentioned in issue #3
Toggle commit list
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