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
75fd2fdd
Commit
75fd2fdd
authored
2 years ago
by
Philip Trettner
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/develop' into pt/cpp-20
parents
0996e0ee
b87495a6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/polymesh/algorithms/normal_estimation.hh
+28
-22
28 additions, 22 deletions
src/polymesh/algorithms/normal_estimation.hh
src/polymesh/attributes.hh
+76
-0
76 additions, 0 deletions
src/polymesh/attributes.hh
with
104 additions
and
22 deletions
src/polymesh/algorithms/normal_estimation.hh
+
28
−
22
View file @
75fd2fdd
...
@@ -19,35 +19,41 @@ template <class Vec3, class IsHardEdgeF>
...
@@ -19,35 +19,41 @@ template <class Vec3, class IsHardEdgeF>
auto
const
hard_edges
=
m
.
edges
().
map
([
&
](
edge_handle
e
)
{
return
e
.
is_boundary
()
?
true
:
is_hard_edge
(
e
);
});
auto
const
hard_edges
=
m
.
edges
().
map
([
&
](
edge_handle
e
)
{
return
e
.
is_boundary
()
?
true
:
is_hard_edge
(
e
);
});
return
m
.
halfedges
().
map
([
&
](
halfedge_handle
h
)
{
return
m
.
halfedges
().
map
(
Vec3
n
=
face_normals
[
h
.
face
()];
[
&
](
halfedge_handle
h
)
{
if
(
h
.
is_boundary
())
return
Vec3
{};
auto
h0
=
h
;
POLYMESH_ASSERT
(
h
.
face
().
is_valid
())
;
auto
h1
=
h
.
next
().
opposit
e
();
Vec3
n
=
face_normals
[
h
.
fac
e
()
]
;
// iterate over h0
auto
h0
=
h
;
auto
hh
=
h0
;
auto
h1
=
h
.
next
().
opposite
();
while
(
hh
!=
h1
&&
!
hard_edges
[
hh
])
{
hh
=
hh
.
opposite
().
prev
();
n
+=
face_normals
[
hh
.
face
()];
}
// iterate over h1 if not reached around
// iterate over h0
if
(
hh
!=
h1
)
auto
hh
=
h0
;
{
while
(
hh
!=
h1
&&
!
hard_edges
[
hh
])
hh
=
h1
;
while
(
hh
!=
h0
&&
!
hard_edges
[
hh
])
{
{
hh
=
hh
.
opposite
().
prev
();
n
+=
face_normals
[
hh
.
face
()];
n
+=
face_normals
[
hh
.
face
()];
hh
=
hh
.
next
().
opposite
();
}
}
}
// normalize
// iterate over h1 if not reached around
auto
l
=
std
::
sqrt
(
n
.
x
*
n
.
x
+
n
.
y
*
n
.
y
+
n
.
z
*
n
.
z
);
if
(
hh
!=
h1
)
return
n
/
(
l
+
1e-30
f
);
{
});
hh
=
h1
;
while
(
hh
!=
h0
&&
!
hard_edges
[
hh
])
{
n
+=
face_normals
[
hh
.
face
()];
hh
=
hh
.
next
().
opposite
();
}
}
// normalize
auto
l
=
std
::
sqrt
(
n
.
x
*
n
.
x
+
n
.
y
*
n
.
y
+
n
.
z
*
n
.
z
);
return
n
/
(
l
+
1e-30
f
);
});
}
}
/// same as normal_estimation(face_attribute<Vec3>, ...)
/// same as normal_estimation(face_attribute<Vec3>, ...)
...
...
This diff is collapsed.
Click to expand it.
src/polymesh/attributes.hh
+
76
−
0
View file @
75fd2fdd
...
@@ -247,4 +247,80 @@ auto attribute(Collection const& c, AttrT const& defaultValue = {}) -> decltype(
...
@@ -247,4 +247,80 @@ auto attribute(Collection const& c, AttrT const& defaultValue = {}) -> decltype(
return
c
.
make_attribute
(
defaultValue
);
return
c
.
make_attribute
(
defaultValue
);
}
}
namespace
detail
{
template
<
class
T
>
struct
is_mesh_attribute_t
:
std
::
false_type
{
};
template
<
class
T
>
struct
is_mesh_attribute_t
<
vertex_attribute
<
T
>>
:
std
::
true_type
{
};
template
<
class
T
>
struct
is_mesh_attribute_t
<
edge_attribute
<
T
>>
:
std
::
true_type
{
};
template
<
class
T
>
struct
is_mesh_attribute_t
<
halfedge_attribute
<
T
>>
:
std
::
true_type
{
};
template
<
class
T
>
struct
is_mesh_attribute_t
<
face_attribute
<
T
>>
:
std
::
true_type
{
};
template
<
class
tag
,
class
T
>
struct
is_mesh_attribute_t
<
primitive_attribute
<
tag
,
T
>>
:
std
::
true_type
{
};
template
<
class
T
>
struct
is_vertex_attribute_t
:
std
::
false_type
{
};
template
<
class
T
>
struct
is_vertex_attribute_t
<
vertex_attribute
<
T
>>
:
std
::
true_type
{
};
template
<
class
T
>
struct
is_face_attribute_t
:
std
::
false_type
{
};
template
<
class
T
>
struct
is_face_attribute_t
<
face_attribute
<
T
>>
:
std
::
true_type
{
};
template
<
class
T
>
struct
is_edge_attribute_t
:
std
::
false_type
{
};
template
<
class
T
>
struct
is_edge_attribute_t
<
edge_attribute
<
T
>>
:
std
::
true_type
{
};
template
<
class
T
>
struct
is_halfedge_attribute_t
:
std
::
false_type
{
};
template
<
class
T
>
struct
is_halfedge_attribute_t
<
halfedge_attribute
<
T
>>
:
std
::
true_type
{
};
}
/// true iff (decayed) T is vertex, face, edge, or halfedge attribute
template
<
class
T
>
constexpr
bool
is_mesh_attribute
=
detail
::
is_mesh_attribute_t
<
std
::
decay_t
<
T
>>::
value
;
template
<
class
T
>
constexpr
bool
is_vertex_attribute
=
detail
::
is_vertex_attribute_t
<
std
::
decay_t
<
T
>>::
value
;
template
<
class
T
>
constexpr
bool
is_face_attribute
=
detail
::
is_face_attribute_t
<
std
::
decay_t
<
T
>>::
value
;
template
<
class
T
>
constexpr
bool
is_edge_attribute
=
detail
::
is_edge_attribute_t
<
std
::
decay_t
<
T
>>::
value
;
template
<
class
T
>
constexpr
bool
is_halfedge_attribute
=
detail
::
is_halfedge_attribute_t
<
std
::
decay_t
<
T
>>::
value
;
}
// namespace polymesh
}
// namespace polymesh
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