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
2b8a59e2
Commit
2b8a59e2
authored
Nov 22, 2019
by
Max Lyon
Browse files
add method that converts smart range to set
parent
05c01593
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/OpenMesh/Core/Mesh/SmartRange.hh
View file @
2b8a59e2
...
...
@@ -45,6 +45,7 @@
#include
<utility>
#include
<array>
#include
<vector>
#include
<set>
//== NAMESPACES ===============================================================
...
...
@@ -189,6 +190,23 @@ struct SmartRangeT
return
res
;
}
/** @brief Convert range to set.
*
* Converts the range of elements into a set of objects returned by functor \p f.
*
* @param f Functor that is applied to all elements before putting them into the set. If no functor is provided
* the set will contain the handles.
*/
template
<
typename
Functor
=
Identity
>
auto
to_set
(
Functor
&&
f
=
{})
->
std
::
set
<
typename
std
::
remove_reference
<
decltype
(
f
(
std
::
declval
<
HandleT
>
()))
>::
type
>
{
auto
range
=
static_cast
<
const
RangeT
*>
(
this
);
std
::
set
<
typename
std
::
remove_reference
<
decltype
(
f
(
std
::
declval
<
HandleT
>
()))
>::
type
>
res
;
for
(
const
auto
&
e
:
*
range
)
res
.
insert
(
f
(
e
));
return
res
;
}
/** @brief Compute minimum.
*
* Computes the minimum of all objects returned by functor \p f.
...
...
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