Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openmesh-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenMesh
openmesh-python
Commits
0ef632d1
There was a problem fetching the pipeline summary.
Commit
0ef632d1
authored
7 years ago
by
Alexander Dielen
Browse files
Options
Downloads
Patches
Plain Diff
added tests for the new element index array methods
parent
f3e1fe2e
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_indices.py
+207
-23
207 additions, 23 deletions
tests/test_indices.py
with
207 additions
and
23 deletions
tests/test_indices.py
+
207
−
23
View file @
0ef632d1
...
...
@@ -6,10 +6,99 @@ import numpy as np
class
Python
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
mesh
=
openmesh
.
PolyMesh
()
vh0
=
self
.
mesh
.
add_vertex
(
np
.
array
([
0
,
0
,
0
]))
vh1
=
self
.
mesh
.
add_vertex
(
np
.
array
([
1
,
0
,
0
]))
vh2
=
self
.
mesh
.
add_vertex
(
np
.
array
([
1
,
1
,
0
]))
vh3
=
self
.
mesh
.
add_vertex
(
np
.
array
([
0
,
1
,
0
]))
vh4
=
self
.
mesh
.
add_vertex
(
np
.
array
([
2
,
0
,
0
]))
vh5
=
self
.
mesh
.
add_vertex
(
np
.
array
([
3
,
0
,
0
]))
vh6
=
self
.
mesh
.
add_vertex
(
np
.
array
([
3
,
1
,
0
]))
vh7
=
self
.
mesh
.
add_vertex
(
np
.
array
([
2
,
1
,
0
]))
vh8
=
self
.
mesh
.
add_vertex
(
np
.
array
([
4
,
0
,
0
]))
vh9
=
self
.
mesh
.
add_vertex
(
np
.
array
([
5
,
0
,
0
]))
vh10
=
self
.
mesh
.
add_vertex
(
np
.
array
([
5
,
1
,
0
]))
self
.
mesh
.
add_face
(
vh0
,
vh1
,
vh2
,
vh3
)
self
.
mesh
.
add_face
(
vh4
,
vh5
,
vh6
)
self
.
mesh
.
add_face
(
vh6
,
vh7
,
vh4
)
self
.
mesh
.
add_face
(
vh8
,
vh9
,
vh10
)
# Test setup:
# 3 === 2 7 === 6 10
# | | | / | / |
# | | | / | / |
# | | | / | / |
# 0 === 1 4 === 5 8 === 9
def
test_vertex_vertex_indices
(
self
):
indices1
=
self
.
mesh
.
vertex_vertex_indices
()
indices2
=
self
.
mesh
.
vv_indices
()
for
h1
in
self
.
mesh
.
vertices
():
correct
=
[
h2
.
idx
()
for
h2
in
self
.
mesh
.
vv
(
h1
)]
while
len
(
correct
)
<
3
:
correct
.
append
(
-
1
)
correct
=
np
.
array
(
correct
)
self
.
assertTrue
(
np
.
array_equal
(
indices1
[
h1
.
idx
()],
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
[
h1
.
idx
()],
correct
))
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_vertices
(),
3
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_vertices
(),
3
))
def
test_vertex_face_indices
(
self
):
indices1
=
self
.
mesh
.
vertex_face_indices
()
indices2
=
self
.
mesh
.
vf_indices
()
for
h1
in
self
.
mesh
.
vertices
():
correct
=
[
h2
.
idx
()
for
h2
in
self
.
mesh
.
vf
(
h1
)]
while
len
(
correct
)
<
2
:
correct
.
append
(
-
1
)
correct
=
np
.
array
(
correct
)
self
.
assertTrue
(
np
.
array_equal
(
indices1
[
h1
.
idx
()],
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
[
h1
.
idx
()],
correct
))
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_vertices
(),
2
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_vertices
(),
2
))
def
test_vertex_edge_indices
(
self
):
indices1
=
self
.
mesh
.
vertex_edge_indices
()
indices2
=
self
.
mesh
.
ve_indices
()
for
h1
in
self
.
mesh
.
vertices
():
correct
=
[
h2
.
idx
()
for
h2
in
self
.
mesh
.
ve
(
h1
)]
while
len
(
correct
)
<
3
:
correct
.
append
(
-
1
)
correct
=
np
.
array
(
correct
)
self
.
assertTrue
(
np
.
array_equal
(
indices1
[
h1
.
idx
()],
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
[
h1
.
idx
()],
correct
))
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_vertices
(),
3
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_vertices
(),
3
))
def
test_vertex_outgoing_halfedge_indices
(
self
):
indices1
=
self
.
mesh
.
vertex_outgoing_halfedge_indices
()
indices2
=
self
.
mesh
.
voh_indices
()
for
h1
in
self
.
mesh
.
vertices
():
correct
=
[
h2
.
idx
()
for
h2
in
self
.
mesh
.
voh
(
h1
)]
while
len
(
correct
)
<
3
:
correct
.
append
(
-
1
)
correct
=
np
.
array
(
correct
)
self
.
assertTrue
(
np
.
array_equal
(
indices1
[
h1
.
idx
()],
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
[
h1
.
idx
()],
correct
))
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_vertices
(),
3
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_vertices
(),
3
))
def
test_vertex_incoming_halfedge_indices
(
self
):
indices1
=
self
.
mesh
.
vertex_incoming_halfedge_indices
()
indices2
=
self
.
mesh
.
vih_indices
()
for
h1
in
self
.
mesh
.
vertices
():
correct
=
[
h2
.
idx
()
for
h2
in
self
.
mesh
.
vih
(
h1
)]
while
len
(
correct
)
<
3
:
correct
.
append
(
-
1
)
correct
=
np
.
array
(
correct
)
self
.
assertTrue
(
np
.
array_equal
(
indices1
[
h1
.
idx
()],
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
[
h1
.
idx
()],
correct
))
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_vertices
(),
3
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_vertices
(),
3
))
def
test_face_vertex_indices_trimesh
(
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
():
...
...
@@ -27,29 +116,56 @@ class Python(unittest.TestCase):
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
))
for
h1
in
self
.
mesh
.
faces
():
correct
=
[
h2
.
idx
()
for
h2
in
self
.
mesh
.
fv
(
h1
)]
while
len
(
correct
)
<
4
:
correct
.
append
(
-
1
)
correct
=
np
.
array
(
correct
)
self
.
assertTrue
(
np
.
array_equal
(
indices1
[
h1
.
idx
()],
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
[
h1
.
idx
()],
correct
))
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_faces
(),
4
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_faces
(),
4
))
def
test_face_face_indices
(
self
):
indices1
=
self
.
mesh
.
face_face_indices
()
indices2
=
self
.
mesh
.
ff_indices
()
for
h1
in
self
.
mesh
.
faces
():
correct
=
[
h2
.
idx
()
for
h2
in
self
.
mesh
.
ff
(
h1
)]
while
len
(
correct
)
<
1
:
correct
.
append
(
-
1
)
correct
=
np
.
array
(
correct
)
self
.
assertTrue
(
np
.
array_equal
(
indices1
[
h1
.
idx
()],
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
[
h1
.
idx
()],
correct
))
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_faces
(),
1
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_faces
(),
1
))
def
test_face_edge_indices
(
self
):
indices1
=
self
.
mesh
.
face_edge_indices
()
indices2
=
self
.
mesh
.
fe_indices
()
for
h1
in
self
.
mesh
.
faces
():
correct
=
[
h2
.
idx
()
for
h2
in
self
.
mesh
.
fe
(
h1
)]
while
len
(
correct
)
<
4
:
correct
.
append
(
-
1
)
correct
=
np
.
array
(
correct
)
self
.
assertTrue
(
np
.
array_equal
(
indices1
[
h1
.
idx
()],
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
[
h1
.
idx
()],
correct
))
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_faces
(),
4
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_faces
(),
4
))
def
test_face_halfedge_indices
(
self
):
indices1
=
self
.
mesh
.
face_halfedge_indices
()
indices2
=
self
.
mesh
.
fh_indices
()
for
h1
in
self
.
mesh
.
faces
():
correct
=
[
h2
.
idx
()
for
h2
in
self
.
mesh
.
fh
(
h1
)]
while
len
(
correct
)
<
4
:
correct
.
append
(
-
1
)
correct
=
np
.
array
(
correct
)
self
.
assertTrue
(
np
.
array_equal
(
indices1
[
h1
.
idx
()],
correct
))
self
.
assertTrue
(
np
.
array_equal
(
indices2
[
h1
.
idx
()],
correct
))
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_faces
(),
4
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_faces
(),
4
))
def
test_edge_vertex_indices
(
self
):
indices1
=
self
.
mesh
.
edge_vertex_indices
()
...
...
@@ -65,6 +181,34 @@ class Python(unittest.TestCase):
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_edges
(),
2
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_edges
(),
2
))
def
test_edge_face_indices
(
self
):
indices1
=
self
.
mesh
.
edge_face_indices
()
indices2
=
self
.
mesh
.
ef_indices
()
for
eh
in
self
.
mesh
.
edges
():
heh1
=
self
.
mesh
.
halfedge_handle
(
eh
,
0
)
heh2
=
self
.
mesh
.
halfedge_handle
(
eh
,
1
)
fh1
=
self
.
mesh
.
face_handle
(
heh1
)
fh2
=
self
.
mesh
.
face_handle
(
heh2
)
self
.
assertEqual
(
indices1
[
eh
.
idx
(),
0
],
fh1
.
idx
())
self
.
assertEqual
(
indices1
[
eh
.
idx
(),
1
],
fh2
.
idx
())
self
.
assertEqual
(
indices2
[
eh
.
idx
(),
0
],
fh1
.
idx
())
self
.
assertEqual
(
indices2
[
eh
.
idx
(),
1
],
fh2
.
idx
())
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_edges
(),
2
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_edges
(),
2
))
def
test_edge_halfedge_indices
(
self
):
indices1
=
self
.
mesh
.
edge_halfedge_indices
()
indices2
=
self
.
mesh
.
eh_indices
()
for
eh
in
self
.
mesh
.
edges
():
heh1
=
self
.
mesh
.
halfedge_handle
(
eh
,
0
)
heh2
=
self
.
mesh
.
halfedge_handle
(
eh
,
1
)
self
.
assertEqual
(
indices1
[
eh
.
idx
(),
0
],
heh1
.
idx
())
self
.
assertEqual
(
indices1
[
eh
.
idx
(),
1
],
heh2
.
idx
())
self
.
assertEqual
(
indices2
[
eh
.
idx
(),
0
],
heh1
.
idx
())
self
.
assertEqual
(
indices2
[
eh
.
idx
(),
1
],
heh2
.
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
()
...
...
@@ -78,6 +222,46 @@ class Python(unittest.TestCase):
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_halfedges
(),
2
))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_halfedges
(),
2
))
def
test_halfedge_to_vertex_indices
(
self
):
indices1
=
self
.
mesh
.
halfedge_to_vertex_indices
()
indices2
=
self
.
mesh
.
htv_indices
()
for
heh
in
self
.
mesh
.
halfedges
():
vh
=
self
.
mesh
.
to_vertex_handle
(
heh
)
self
.
assertEqual
(
indices1
[
heh
.
idx
()],
vh
.
idx
())
self
.
assertEqual
(
indices2
[
heh
.
idx
()],
vh
.
idx
())
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_halfedges
(),))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_halfedges
(),))
def
test_halfedge_from_vertex_indices
(
self
):
indices1
=
self
.
mesh
.
halfedge_from_vertex_indices
()
indices2
=
self
.
mesh
.
hfv_indices
()
for
heh
in
self
.
mesh
.
halfedges
():
vh
=
self
.
mesh
.
from_vertex_handle
(
heh
)
self
.
assertEqual
(
indices1
[
heh
.
idx
()],
vh
.
idx
())
self
.
assertEqual
(
indices2
[
heh
.
idx
()],
vh
.
idx
())
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_halfedges
(),))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_halfedges
(),))
def
test_halfedge_face_indices
(
self
):
indices1
=
self
.
mesh
.
halfedge_face_indices
()
indices2
=
self
.
mesh
.
hf_indices
()
for
heh
in
self
.
mesh
.
halfedges
():
fh
=
self
.
mesh
.
face_handle
(
heh
)
self
.
assertEqual
(
indices1
[
heh
.
idx
()],
fh
.
idx
())
self
.
assertEqual
(
indices2
[
heh
.
idx
()],
fh
.
idx
())
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_halfedges
(),))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_halfedges
(),))
def
test_halfedge_edge_indices
(
self
):
indices1
=
self
.
mesh
.
halfedge_edge_indices
()
indices2
=
self
.
mesh
.
he_indices
()
for
heh
in
self
.
mesh
.
halfedges
():
eh
=
self
.
mesh
.
edge_handle
(
heh
)
self
.
assertEqual
(
indices1
[
heh
.
idx
()],
eh
.
idx
())
self
.
assertEqual
(
indices2
[
heh
.
idx
()],
eh
.
idx
())
self
.
assertEqual
(
indices1
.
shape
,
(
self
.
mesh
.
n_halfedges
(),))
self
.
assertEqual
(
indices2
.
shape
,
(
self
.
mesh
.
n_halfedges
(),))
if
__name__
==
'
__main__
'
:
suite
=
unittest
.
TestLoader
().
loadTestsFromTestCase
(
Python
)
...
...
This diff is collapsed.
Click to expand it.
Alexander Dielen
@adielen
mentioned in issue
#9 (closed)
·
7 years ago
mentioned in issue
#9 (closed)
mentioned in issue #9
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment