MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMapEdge.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMapOrHashMap.h"
4#include "MRBuffer.h"
5
6namespace MR
7{
10
11
13[[nodiscard]] inline EdgeId mapEdge( const WholeEdgeMap & map, EdgeId src )
14{
15 EdgeId res = map[ src.undirected() ];
16 if ( res && src.odd() )
17 res = res.sym();
18 return res;
19}
20
22[[nodiscard]] inline UndirectedEdgeId mapEdge( const WholeEdgeMap & map, UndirectedEdgeId src )
23{
24 EdgeId eres = map[ src ];
25 return eres ? eres.undirected() : UndirectedEdgeId{};
26}
27
29[[nodiscard]] inline EdgeId mapEdge( const WholeEdgeHashMap & map, EdgeId src )
30{
31 EdgeId res;
32 auto it = map.find( src.undirected() );
33 if ( it != map.end() )
34 {
35 res = it->second;
36 if ( src.odd() )
37 res = res.sym();
38 }
39 return res;
40}
41
43[[nodiscard]] inline UndirectedEdgeId mapEdge( const WholeEdgeHashMap & map, UndirectedEdgeId src )
44{
45 auto it = map.find( src );
46 return it != map.end() ? it->second.undirected() : UndirectedEdgeId{};
47}
48
50[[nodiscard]] inline EdgeId mapEdge( const WholeEdgeMapOrHashMap & m, EdgeId src )
51{
52 return std::visit( overloaded{
53 [src]( const WholeEdgeMap& map ) { return mapEdge( map, src ); },
54 [src]( const WholeEdgeHashMap& hashMap ) { return mapEdge( hashMap, src ); }
55 }, m.var );
56}
57
59[[nodiscard]] inline UndirectedEdgeId mapEdge( const WholeEdgeMapOrHashMap & m, UndirectedEdgeId src )
60{
61 return std::visit( overloaded{
62 [src]( const WholeEdgeMap& map ) { return mapEdge( map, src ); },
63 [src]( const WholeEdgeHashMap& hashMap ) { return mapEdge( hashMap, src ); }
64 }, m.var );
65}
66
68[[nodiscard]] inline UndirectedEdgeId mapEdge( const UndirectedEdgeBMap & map, UndirectedEdgeId src )
69{
70 return getAt( map.b, src );
71}
72
74[[nodiscard]] MRMESH_API UndirectedEdgeBitSet mapEdges( const WholeEdgeMap & map, const UndirectedEdgeBitSet & src );
75
77[[nodiscard]] MRMESH_API UndirectedEdgeBitSet mapEdges( const WholeEdgeHashMap & map, const UndirectedEdgeBitSet & src );
78
80[[nodiscard]] MRMESH_API UndirectedEdgeBitSet mapEdges( const UndirectedEdgeBMap & map, const UndirectedEdgeBitSet & src );
81
82}
T getAt(const Buffer< T, I > &bmap MR_LIFETIMEBOUND_NESTED, I key, T def={})
given some buffer map and a key, returns the value associated with the key, or default value if key i...
Definition MRBuffer.h:123
MRMESH_API UndirectedEdgeBitSet mapEdges(const WholeEdgeMap &map, const UndirectedEdgeBitSet &src)
given input bit-set (src), converts each id corresponding to set bit using given map,...
EdgeId mapEdge(const WholeEdgeMap &map, EdgeId src)
given input edge (src), converts its id using given map
Definition MRMapEdge.h:13
only for bindings generation
Definition MRCameraOrientationPlugin.h:8