Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
polymesh-samples
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Philip Trettner
polymesh-samples
Commits
cdc7b65f
Commit
cdc7b65f
authored
Oct 02, 2020
by
Philip Trettner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed attribute views
parent
4bad9193
Pipeline
#15267
passed with stage
in 4 minutes and 45 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
extern/polymesh
extern/polymesh
+1
-1
tests/attributes/attribute-view-test.cc
tests/attributes/attribute-view-test.cc
+46
-0
No files found.
polymesh
@
2ee20575
Compare
85dc7a41
...
2ee20575
Subproject commit
85dc7a4197ffeca4f4602fbfe735cd83a04d9819
Subproject commit
2ee20575b944d16d44528653aa4ae158099493c8
tests/attributes/attribute-view-test.cc
0 → 100644
View file @
cdc7b65f
#include <doctest.hh>
#include <polymesh/Mesh.hh>
#include <typed-geometry/tg-lean.hh>
TEST_CASE
(
"attribute views"
)
{
pm
::
Mesh
m
;
auto
pos
=
m
.
vertices
().
make_attribute
<
tg
::
pos3
>
();
auto
v
=
m
.
vertices
().
add
();
pos
[
v
]
=
{
1
,
2
,
3
};
auto
pos_v
=
pos
.
view
([](
tg
::
pos3
&
p
)
->
tg
::
vec3
&
{
return
reinterpret_cast
<
tg
::
vec3
&>
(
p
);
});
static_assert
(
std
::
is_same_v
<
decltype
(
pos_v
[
v
]),
tg
::
vec3
&>
);
CHECK
(
pos
.
size
()
==
pos_v
.
size
());
CHECK
(
pos
[
v
]
==
tg
::
pos3
(
1
,
2
,
3
));
CHECK
(
pos_v
[
v
]
==
tg
::
vec3
(
1
,
2
,
3
));
pos
[
v
]
=
{
2
,
3
,
4
};
CHECK
(
pos
[
v
]
==
tg
::
pos3
(
2
,
3
,
4
));
CHECK
(
pos_v
[
v
]
==
tg
::
vec3
(
2
,
3
,
4
));
pos_v
[
v
]
=
{
1
,
5
,
3
};
CHECK
(
pos
[
v
]
==
tg
::
pos3
(
1
,
5
,
3
));
CHECK
(
pos_v
[
v
]
==
tg
::
vec3
(
1
,
5
,
3
));
pos_v
[
v
].
y
=
7
;
CHECK
(
pos
[
v
]
==
tg
::
pos3
(
1
,
7
,
3
));
CHECK
(
pos_v
[
v
]
==
tg
::
vec3
(
1
,
7
,
3
));
auto
pos_vz
=
pos_v
.
map
([](
tg
::
vec3
&
v
)
->
float
&
{
return
v
.
z
;
});
static_assert
(
std
::
is_same_v
<
decltype
(
pos_vz
[
v
]),
float
&>
);
CHECK
(
pos_vz
[
v
]
==
3
);
pos_vz
[
v
]
=
9
;
CHECK
(
pos
[
v
]
==
tg
::
pos3
(
1
,
7
,
9
));
CHECK
(
pos_v
[
v
]
==
tg
::
vec3
(
1
,
7
,
9
));
}
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