Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenMesh
OpenMesh
Commits
14dffb83
Commit
14dffb83
authored
Nov 19, 2015
by
Hans-Christian Ebke
Browse files
C++11: Made VectorT's constructor from array more general.
parent
c8b5dea2
Changes
2
Show whitespace changes
Inline
Side-by-side
src/OpenMesh/Core/Geometry/Vector11T.hh
View file @
14dffb83
...
...
@@ -81,6 +81,9 @@ namespace OpenMesh {
template
<
typename
Scalar
,
int
DIM
>
class
VectorT
{
static_assert
(
DIM
>=
1
,
"VectorT requires positive dimensionality."
);
private:
std
::
array
<
Scalar
,
DIM
>
values_
;
...
...
@@ -154,9 +157,10 @@ class VectorT {
1
);
}
/// construct from a value array (explicit)
explicit
inline
VectorT
(
const
Scalar
_values
[
DIM
])
{
std
::
copy
(
_values
,
_values
+
DIM
,
values_
.
begin
());
/// construct from a value array or any other iterator
template
<
typename
Iterator
>
explicit
inline
VectorT
(
Iterator
it
)
{
std
::
copy_n
(
it
,
DIM
,
values_
.
begin
());
}
/// copy & cast constructor (explicit)
...
...
src/Unittests/unittests_vector_type.cc
View file @
14dffb83
#include <gtest/gtest.h>
#include <Unittests/unittests_common.hh>
#include <iostream>
#include <list>
namespace
{
...
...
@@ -171,6 +172,15 @@ TEST_F(OpenMeshVectorTest, move_constructor_assignment) {
EXPECT_EQ
(
3
,
C
::
copy_con
);
}
TEST_F
(
OpenMeshVectorTest
,
iterator_init
)
{
std
::
list
<
float
>
a
;
a
.
push_back
(
1.0
);
a
.
push_back
(
2.0
);
a
.
push_back
(
3.0
);
OpenMesh
::
Vec3f
v
(
a
.
begin
());
EXPECT_EQ
(
OpenMesh
::
Vec3f
(
1.0
,
2.0
,
3.0
),
v
);
}
#endif // C++11
...
...
@@ -200,6 +210,12 @@ TEST_F(OpenMeshVectorTest, BasicLinearAlgebra) {
EXPECT_NEAR
(
14
,
OpenMesh
::
Vec3d
(
-
1
,
-
2
,
-
3
)
|
OpenMesh
::
Vec3d
(
-
1
,
-
2
,
-
3
),
1e-6
);
}
TEST_F
(
OpenMeshVectorTest
,
array_init
)
{
float
a
[
3
];
a
[
0
]
=
1.0
;
a
[
1
]
=
2.0
;
a
[
2
]
=
3.0
;
OpenMesh
::
Vec3f
v
(
a
);
EXPECT_EQ
(
OpenMesh
::
Vec3f
(
1.0
,
2.0
,
3.0
),
v
);
}
TEST_F
(
OpenMeshVectorTest
,
normalized_cond
)
{
OpenMesh
::
Vec3d
v1
(
1
,
-
2
,
3
),
v2
(
0
,
0
,
0
);
EXPECT_EQ
(
OpenMesh
::
Vec3d
(
0
,
0
,
0
),
v2
.
normalize_cond
());
...
...
Write
Preview
Supports
Markdown
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