Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polymesh
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
Philip Trettner
polymesh
Commits
57b573b6
Commit
57b573b6
authored
4 years ago
by
Julius Nehring-Wirxel
Browse files
Options
Downloads
Patches
Plain Diff
Added dodecahedron object
parent
fb5a1bc7
Branches
Branches containing commit
No related tags found
1 merge request
!28
Added dodecahedron object
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/polymesh/objects/dodecahedron.cc
+54
-0
54 additions, 0 deletions
src/polymesh/objects/dodecahedron.cc
src/polymesh/objects/dodecahedron.hh
+43
-0
43 additions, 0 deletions
src/polymesh/objects/dodecahedron.hh
with
97 additions
and
0 deletions
src/polymesh/objects/dodecahedron.cc
0 → 100644
+
54
−
0
View file @
57b573b6
#include
"dodecahedron.hh"
#include
<cmath>
// std::sqrt
polymesh
::
unique_array
<
polymesh
::
detail
::
pos3f
>
polymesh
::
detail
::
add_unit_dodecahedron_impl
(
polymesh
::
Mesh
&
m
)
{
polymesh
::
unique_array
<
pos3f
>
position
(
20
);
auto
const
phi
=
(
1
+
std
::
sqrt
(
5.0
f
))
/
2.0
f
;
auto
const
phi_inv
=
1
/
phi
;
pm
::
vertex_handle
vs
[
20
];
for
(
size_t
i
=
0
;
i
<
20
;
++
i
)
vs
[
i
]
=
m
.
vertices
().
add
();
position
[
0
]
=
{
1
,
1
,
1
};
position
[
1
]
=
{
1
,
1
,
-
1
};
position
[
2
]
=
{
1
,
-
1
,
1
};
position
[
3
]
=
{
1
,
-
1
,
-
1
};
position
[
4
]
=
{
-
1
,
1
,
1
};
position
[
5
]
=
{
-
1
,
1
,
-
1
};
position
[
6
]
=
{
-
1
,
-
1
,
1
};
position
[
7
]
=
{
-
1
,
-
1
,
-
1
};
position
[
8
]
=
{
0
,
phi
,
phi_inv
};
position
[
9
]
=
{
0
,
phi
,
-
phi_inv
};
position
[
10
]
=
{
0
,
-
phi
,
phi_inv
};
position
[
11
]
=
{
0
,
-
phi
,
-
phi_inv
};
position
[
12
]
=
{
phi_inv
,
0
,
phi
};
position
[
13
]
=
{
phi_inv
,
0
,
-
phi
};
position
[
14
]
=
{
-
phi_inv
,
0
,
phi
};
position
[
15
]
=
{
-
phi_inv
,
0
,
-
phi
};
position
[
16
]
=
{
phi
,
phi_inv
,
0
};
position
[
17
]
=
{
phi
,
-
phi_inv
,
0
};
position
[
18
]
=
{
-
phi
,
phi_inv
,
0
};
position
[
19
]
=
{
-
phi
,
-
phi_inv
,
0
};
m
.
faces
().
add
({
vs
[
8
],
vs
[
9
],
vs
[
5
],
vs
[
18
],
vs
[
4
]});
m
.
faces
().
add
({
vs
[
9
],
vs
[
8
],
vs
[
0
],
vs
[
16
],
vs
[
1
]});
m
.
faces
().
add
({
vs
[
8
],
vs
[
4
],
vs
[
14
],
vs
[
12
],
vs
[
0
]});
m
.
faces
().
add
({
vs
[
9
],
vs
[
1
],
vs
[
13
],
vs
[
15
],
vs
[
5
]});
m
.
faces
().
add
({
vs
[
4
],
vs
[
18
],
vs
[
19
],
vs
[
6
],
vs
[
14
]});
m
.
faces
().
add
({
vs
[
5
],
vs
[
15
],
vs
[
7
],
vs
[
19
],
vs
[
18
]});
m
.
faces
().
add
({
vs
[
13
],
vs
[
3
],
vs
[
11
],
vs
[
7
],
vs
[
15
]});
m
.
faces
().
add
({
vs
[
16
],
vs
[
17
],
vs
[
3
],
vs
[
13
],
vs
[
1
]});
m
.
faces
().
add
({
vs
[
0
],
vs
[
12
],
vs
[
2
],
vs
[
17
],
vs
[
16
]});
m
.
faces
().
add
({
vs
[
14
],
vs
[
6
],
vs
[
10
],
vs
[
2
],
vs
[
12
]});
m
.
faces
().
add
({
vs
[
19
],
vs
[
7
],
vs
[
11
],
vs
[
10
],
vs
[
6
]});
m
.
faces
().
add
({
vs
[
17
],
vs
[
2
],
vs
[
10
],
vs
[
11
],
vs
[
3
]});
return
position
;
}
This diff is collapsed.
Click to expand it.
src/polymesh/objects/dodecahedron.hh
0 → 100644
+
43
−
0
View file @
57b573b6
#pragma once
#include
<polymesh/Mesh.hh>
#include
<polymesh/detail/math.hh>
#include
<polymesh/detail/unique_array.hh>
#include
<polymesh/fields.hh>
namespace
polymesh
::
detail
{
unique_array
<
pos3f
>
add_unit_dodecahedron_impl
(
Mesh
&
m
);
}
namespace
polymesh
::
objects
{
/// Adds a (subdivided) ico_sphere to the given mesh
/// sf is called with (v, x, y, z), with vertex handle v and coordinates (x,y,z) on the unit sphere
template
<
class
SphereF
>
vertex_handle
add_dodecahedron
(
Mesh
&
m
,
SphereF
&&
sf
);
/// same as add_cube but directly fills a position attribute
template
<
class
Pos3
>
vertex_handle
add_dodecahedron
(
Mesh
&
m
,
vertex_attribute
<
Pos3
>&
pos
);
// ======== IMPLEMENTATION ========
template
<
class
SphereF
>
vertex_handle
add_dodecahedron
(
Mesh
&
m
,
SphereF
&&
sf
)
{
auto
const
last_vertex_count
=
m
.
all_vertices
().
size
();
auto
const
positions
=
detail
::
add_unit_dodecahedron_impl
(
m
);
for
(
auto
i
=
0
;
i
<
20
;
++
i
)
{
sf
(
vertex_index
(
last_vertex_count
+
i
).
of
(
m
),
positions
[
i
].
x
,
positions
[
i
].
y
,
positions
[
i
].
z
);
}
return
vertex_index
(
last_vertex_count
).
of
(
m
);
}
template
<
class
Pos3
>
auto
add_dodecahedron
(
Mesh
&
m
,
vertex_attribute
<
Pos3
>&
pos
)
->
vertex_handle
{
return
add_dodecahedron
(
m
,
[
&
](
vertex_handle
v
,
float
x
,
float
y
,
float
z
)
{
pos
[
v
]
=
field3
<
Pos3
>::
make_pos
(
x
,
y
,
z
);
});
}
}
This diff is collapsed.
Click to expand it.
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