Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenMesh
openmesh-python
Commits
dbcca72f
Commit
dbcca72f
authored
Jan 30, 2018
by
Alexander Dielen
Browse files
make sure arrays are dense and c style
parent
bdf547ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Mesh.hh
View file @
dbcca72f
...
...
@@ -1361,16 +1361,16 @@ void expose_mesh(py::module& m, const char *_name) {
// set_property_array
//======================================================================
.
def
(
"set_property_array"
,
[]
(
Mesh
&
_self
,
OM
::
VPropHandleT
<
py
::
none
>
_ph
,
py
::
array_t
<
double
>
_arr
)
{
.
def
(
"set_property_array"
,
[]
(
Mesh
&
_self
,
OM
::
VPropHandleT
<
py
::
none
>
_ph
,
py
::
array_t
<
double
,
py
::
array
::
c_style
|
py
::
array
::
forcecast
>
_arr
)
{
return
set_property_array
<
Mesh
,
OM
::
VPropHandleT
<
py
::
none
>
,
OM
::
VertexHandle
>
(
_self
,
_ph
,
_arr
,
_self
.
n_vertices
());
})
.
def
(
"set_property_array"
,
[]
(
Mesh
&
_self
,
OM
::
HPropHandleT
<
py
::
none
>
_ph
,
py
::
array_t
<
double
>
_arr
)
{
.
def
(
"set_property_array"
,
[]
(
Mesh
&
_self
,
OM
::
HPropHandleT
<
py
::
none
>
_ph
,
py
::
array_t
<
double
,
py
::
array
::
c_style
|
py
::
array
::
forcecast
>
_arr
)
{
return
set_property_array
<
Mesh
,
OM
::
HPropHandleT
<
py
::
none
>
,
OM
::
HalfedgeHandle
>
(
_self
,
_ph
,
_arr
,
_self
.
n_halfedges
());
})
.
def
(
"set_property_array"
,
[]
(
Mesh
&
_self
,
OM
::
EPropHandleT
<
py
::
none
>
_ph
,
py
::
array_t
<
double
>
_arr
)
{
.
def
(
"set_property_array"
,
[]
(
Mesh
&
_self
,
OM
::
EPropHandleT
<
py
::
none
>
_ph
,
py
::
array_t
<
double
,
py
::
array
::
c_style
|
py
::
array
::
forcecast
>
_arr
)
{
return
set_property_array
<
Mesh
,
OM
::
EPropHandleT
<
py
::
none
>
,
OM
::
EdgeHandle
>
(
_self
,
_ph
,
_arr
,
_self
.
n_edges
());
})
.
def
(
"set_property_array"
,
[]
(
Mesh
&
_self
,
OM
::
FPropHandleT
<
py
::
none
>
_ph
,
py
::
array_t
<
double
>
_arr
)
{
.
def
(
"set_property_array"
,
[]
(
Mesh
&
_self
,
OM
::
FPropHandleT
<
py
::
none
>
_ph
,
py
::
array_t
<
double
,
py
::
array
::
c_style
|
py
::
array
::
forcecast
>
_arr
)
{
return
set_property_array
<
Mesh
,
OM
::
FPropHandleT
<
py
::
none
>
,
OM
::
FaceHandle
>
(
_self
,
_ph
,
_arr
,
_self
.
n_faces
());
})
;
...
...
tests/test_property_array.py
View file @
dbcca72f
...
...
@@ -12,34 +12,82 @@ class Python(unittest.TestCase):
def
test_vertex_property_array
(
self
):
prop
=
openmesh
.
VPropHandle
()
self
.
mesh
.
add_property
(
prop
)
# c_contiguous
arr1
=
np
.
random
.
rand
(
self
.
mesh
.
n_vertices
(),
10
)
self
.
mesh
.
set_property_array
(
prop
,
arr1
)
arr2
=
self
.
mesh
.
property_array
(
prop
)
self
.
assertTrue
(
np
.
allclose
(
arr1
,
arr2
))
for
vh
in
self
.
mesh
.
vertices
():
arr3
=
self
.
mesh
.
property
(
prop
,
vh
)
self
.
assertTrue
(
np
.
allclose
(
arr1
[
vh
.
idx
()],
arr3
))
# f_contiguous
arr1
=
np
.
random
.
rand
(
10
,
self
.
mesh
.
n_vertices
())
self
.
mesh
.
set_property_array
(
prop
,
arr1
.
T
)
arr2
=
self
.
mesh
.
property_array
(
prop
)
self
.
assertTrue
(
np
.
allclose
(
arr1
.
T
,
arr2
))
for
vh
in
self
.
mesh
.
vertices
():
arr3
=
self
.
mesh
.
property
(
prop
,
vh
)
self
.
assertTrue
(
np
.
allclose
(
arr1
.
T
[
vh
.
idx
()],
arr3
))
def
test_halfedge_property_array
(
self
):
prop
=
openmesh
.
HPropHandle
()
self
.
mesh
.
add_property
(
prop
)
# c_contiguous
arr1
=
np
.
random
.
rand
(
self
.
mesh
.
n_halfedges
(),
10
)
self
.
mesh
.
set_property_array
(
prop
,
arr1
)
arr2
=
self
.
mesh
.
property_array
(
prop
)
self
.
assertTrue
(
np
.
allclose
(
arr1
,
arr2
))
for
hh
in
self
.
mesh
.
halfedges
():
arr3
=
self
.
mesh
.
property
(
prop
,
hh
)
self
.
assertTrue
(
np
.
allclose
(
arr1
[
hh
.
idx
()],
arr3
))
# f_contiguous
arr1
=
np
.
random
.
rand
(
10
,
self
.
mesh
.
n_halfedges
())
self
.
mesh
.
set_property_array
(
prop
,
arr1
.
T
)
arr2
=
self
.
mesh
.
property_array
(
prop
)
self
.
assertTrue
(
np
.
allclose
(
arr1
.
T
,
arr2
))
for
hh
in
self
.
mesh
.
halfedges
():
arr3
=
self
.
mesh
.
property
(
prop
,
hh
)
self
.
assertTrue
(
np
.
allclose
(
arr1
.
T
[
hh
.
idx
()],
arr3
))
def
test_edge_property_array
(
self
):
prop
=
openmesh
.
EPropHandle
()
self
.
mesh
.
add_property
(
prop
)
# c_contiguous
arr1
=
np
.
random
.
rand
(
self
.
mesh
.
n_edges
(),
10
)
self
.
mesh
.
set_property_array
(
prop
,
arr1
)
arr2
=
self
.
mesh
.
property_array
(
prop
)
self
.
assertTrue
(
np
.
allclose
(
arr1
,
arr2
))
for
eh
in
self
.
mesh
.
edges
():
arr3
=
self
.
mesh
.
property
(
prop
,
eh
)
self
.
assertTrue
(
np
.
allclose
(
arr1
[
eh
.
idx
()],
arr3
))
# f_contiguous
arr1
=
np
.
random
.
rand
(
10
,
self
.
mesh
.
n_edges
())
self
.
mesh
.
set_property_array
(
prop
,
arr1
.
T
)
arr2
=
self
.
mesh
.
property_array
(
prop
)
self
.
assertTrue
(
np
.
allclose
(
arr1
.
T
,
arr2
))
for
eh
in
self
.
mesh
.
edges
():
arr3
=
self
.
mesh
.
property
(
prop
,
eh
)
self
.
assertTrue
(
np
.
allclose
(
arr1
.
T
[
eh
.
idx
()],
arr3
))
def
test_face_property_array
(
self
):
prop
=
openmesh
.
FPropHandle
()
self
.
mesh
.
add_property
(
prop
)
# c_contiguous
arr1
=
np
.
random
.
rand
(
self
.
mesh
.
n_faces
(),
10
)
self
.
mesh
.
set_property_array
(
prop
,
arr1
)
arr2
=
self
.
mesh
.
property_array
(
prop
)
self
.
assertTrue
(
np
.
allclose
(
arr1
,
arr2
))
for
fh
in
self
.
mesh
.
faces
():
arr3
=
self
.
mesh
.
property
(
prop
,
fh
)
self
.
assertTrue
(
np
.
allclose
(
arr1
[
fh
.
idx
()],
arr3
))
# f_contiguous
arr1
=
np
.
random
.
rand
(
10
,
self
.
mesh
.
n_faces
())
self
.
mesh
.
set_property_array
(
prop
,
arr1
.
T
)
arr2
=
self
.
mesh
.
property_array
(
prop
)
self
.
assertTrue
(
np
.
allclose
(
arr1
.
T
,
arr2
))
for
fh
in
self
.
mesh
.
faces
():
arr3
=
self
.
mesh
.
property
(
prop
,
fh
)
self
.
assertTrue
(
np
.
allclose
(
arr1
.
T
[
fh
.
idx
()],
arr3
))
if
__name__
==
'__main__'
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment