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
fb47e270
Commit
fb47e270
authored
Jul 11, 2018
by
Alexander Dielen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store 1d arrays as scalar properties
parent
b3189504
Pipeline
#7300
passed with stages
in 5 minutes and 51 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
src/MeshTypes.hh
src/MeshTypes.hh
+16
-13
No files found.
src/MeshTypes.hh
View file @
fb47e270
...
...
@@ -157,21 +157,24 @@ public:
throw
py
::
error_already_set
();
}
// reshape to (n, 1) if necessary
if
(
_arr
.
ndim
()
==
1
)
{
_arr
.
resize
({
n
,
size_t
(
1
)});
// special case: use scalar properties
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
Mesh
::
property
(
prop
,
Handle
(
i
))
=
py
::
float_
(
_arr
.
at
(
i
));
}
}
// copy one array at a time
const
size_t
size
=
_arr
.
strides
(
0
)
/
sizeof
(
double
);
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
double
*
data
=
new
double
[
size
];
std
::
copy
(
_arr
.
data
(
i
),
_arr
.
data
(
i
)
+
size
,
data
);
const
std
::
vector
<
size_t
>
shape
(
_arr
.
shape
()
+
1
,
_arr
.
shape
()
+
_arr
.
ndim
());
const
std
::
vector
<
size_t
>
strides
(
_arr
.
strides
()
+
1
,
_arr
.
strides
()
+
_arr
.
ndim
());
py
::
capsule
base
=
free_when_done
(
data
);
py
::
array_t
<
double
>
tmp
(
shape
,
strides
,
data
,
base
);
Mesh
::
property
(
prop
,
Handle
(
i
))
=
tmp
;
else
{
// copy one array at a time
const
size_t
size
=
_arr
.
strides
(
0
)
/
sizeof
(
double
);
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
double
*
data
=
new
double
[
size
];
std
::
copy
(
_arr
.
data
(
i
),
_arr
.
data
(
i
)
+
size
,
data
);
const
std
::
vector
<
size_t
>
shape
(
_arr
.
shape
()
+
1
,
_arr
.
shape
()
+
_arr
.
ndim
());
const
std
::
vector
<
size_t
>
strides
(
_arr
.
strides
()
+
1
,
_arr
.
strides
()
+
_arr
.
ndim
());
py
::
capsule
base
=
free_when_done
(
data
);
py
::
array_t
<
double
>
tmp
(
shape
,
strides
,
data
,
base
);
Mesh
::
property
(
prop
,
Handle
(
i
))
=
tmp
;
}
}
}
...
...
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