bind.hh 1.09 KB
Newer Older
Philip Trettner's avatar
Philip Trettner committed
1
2
3
4
5
6
7
8
9
10
11
#pragma once

#include "cursors.hh"

/// Bindings for property-based functions
/// Example usage:
/// auto areas = m.faces().map(fbind(face_area<glm::vec3>, pos));

namespace polymesh
{
template <class FuncT, class... Args>
Philip Trettner's avatar
Philip Trettner committed
12
auto fbind(FuncT&& f, Args... args) -> decltype(f(std::declval<face_handle>(), std::forward<Args>(args)...))
Philip Trettner's avatar
Philip Trettner committed
13
14
15
16
17
{
    return [&](face_handle h) { return f(h, std::forward<Args>(args)...); };
}

template <class FuncT, class... Args>
Philip Trettner's avatar
Philip Trettner committed
18
auto vbind(FuncT&& f, Args... args) -> decltype(f(std::declval<vertex_handle>(), std::forward<Args>(args)...))
Philip Trettner's avatar
Philip Trettner committed
19
20
21
22
23
{
    return [&](vertex_handle h) { return f(h, std::forward<Args>(args)...); };
}

template <class FuncT, class... Args>
Philip Trettner's avatar
Philip Trettner committed
24
auto ebind(FuncT&& f, Args... args) -> decltype(f(std::declval<edge_handle>(), std::forward<Args>(args)...))
Philip Trettner's avatar
Philip Trettner committed
25
26
27
28
29
{
    return [&](edge_handle h) { return f(h, std::forward<Args>(args)...); };
}

template <class FuncT, class... Args>
Philip Trettner's avatar
Philip Trettner committed
30
auto hbind(FuncT&& f, Args... args) -> decltype(f(std::declval<halfedge_handle>(), std::forward<Args>(args)...))
Philip Trettner's avatar
Philip Trettner committed
31
32
33
34
{
    return [&](halfedge_handle h) { return f(h, std::forward<Args>(args)...); };
}
}