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{
8
10[[nodiscard]] inline EdgeId mapEdge( const WholeEdgeMap & map, EdgeId src )
11{
12 EdgeId res = map[ src.undirected() ];
13 if ( res && src.odd() )
14 res = res.sym();
15 return res;
16}
17
19[[nodiscard]] inline EdgeId mapEdge( const WholeEdgeHashMap & map, EdgeId src )
20{
21 EdgeId res;
22 auto it = map.find( src.undirected() );
23 if ( it != map.end() )
24 {
25 res = it->second;
26 if ( src.odd() )
27 res = res.sym();
28 }
29 return res;
30}
31
33[[nodiscard]] inline EdgeId mapEdge( const WholeEdgeMapOrHashMap & m, EdgeId src )
34{
35 return std::visit( overloaded{
36 [src]( const WholeEdgeMap& map ) { return mapEdge( map, src ); },
37 [src]( const WholeEdgeHashMap& hashMap ) { return mapEdge( hashMap, src ); }
38 }, m.var );
39}
40
42[[nodiscard]] inline UndirectedEdgeId mapEdge( const UndirectedEdgeBMap & map, UndirectedEdgeId src )
43{
44 return getAt( map.b, src );
45}
46
48[[nodiscard]] MRMESH_API UndirectedEdgeBitSet mapEdges( const WholeEdgeMap & map, const UndirectedEdgeBitSet & src );
49
51[[nodiscard]] MRMESH_API UndirectedEdgeBitSet mapEdges( const WholeEdgeHashMap & map, const UndirectedEdgeBitSet & src );
52
54[[nodiscard]] MRMESH_API UndirectedEdgeBitSet mapEdges( const UndirectedEdgeBMap & map, const UndirectedEdgeBitSet & src );
55
56} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
Definition MRCameraOrientationPlugin.h:8
T getAt(const Buffer< T, I > &bmap, 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:119
HashMap< UndirectedEdgeId, EdgeId > WholeEdgeHashMap
mapping of whole edges: map[e]->f, map[e.sym()]->f.sym(), where only map[e] for even edges is stored
Definition MRMesh/MRMeshFwd.h:537
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:10
std::variant< Dense, Hash > var
Definition MRMapOrHashMap.h:19
Definition MRMesh/MRMeshFwd.h:710