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 UndirectedEdgeId mapEdge( const WholeEdgeMap & map, UndirectedEdgeId src )
20{
21 EdgeId eres = map[ src ];
22 return eres ? eres.undirected() : UndirectedEdgeId{};
23}
24
26[[nodiscard]] inline EdgeId mapEdge( const WholeEdgeHashMap & map, EdgeId src )
27{
28 EdgeId res;
29 auto it = map.find( src.undirected() );
30 if ( it != map.end() )
31 {
32 res = it->second;
33 if ( src.odd() )
34 res = res.sym();
35 }
36 return res;
37}
38
40[[nodiscard]] inline UndirectedEdgeId mapEdge( const WholeEdgeHashMap & map, UndirectedEdgeId src )
41{
42 auto it = map.find( src );
43 return it != map.end() ? it->second.undirected() : UndirectedEdgeId{};
44}
45
47[[nodiscard]] inline EdgeId mapEdge( const WholeEdgeMapOrHashMap & m, EdgeId src )
48{
49 return std::visit( overloaded{
50 [src]( const WholeEdgeMap& map ) { return mapEdge( map, src ); },
51 [src]( const WholeEdgeHashMap& hashMap ) { return mapEdge( hashMap, src ); }
52 }, m.var );
53}
54
56[[nodiscard]] inline UndirectedEdgeId mapEdge( const WholeEdgeMapOrHashMap & m, UndirectedEdgeId src )
57{
58 return std::visit( overloaded{
59 [src]( const WholeEdgeMap& map ) { return mapEdge( map, src ); },
60 [src]( const WholeEdgeHashMap& hashMap ) { return mapEdge( hashMap, src ); }
61 }, m.var );
62}
63
65[[nodiscard]] inline UndirectedEdgeId mapEdge( const UndirectedEdgeBMap & map, UndirectedEdgeId src )
66{
67 return getAt( map.b, src );
68}
69
71[[nodiscard]] MRMESH_API UndirectedEdgeBitSet mapEdges( const WholeEdgeMap & map, const UndirectedEdgeBitSet & src );
72
74[[nodiscard]] MRMESH_API UndirectedEdgeBitSet mapEdges( const WholeEdgeHashMap & map, const UndirectedEdgeBitSet & src );
75
77[[nodiscard]] MRMESH_API UndirectedEdgeBitSet mapEdges( const UndirectedEdgeBMap & map, const UndirectedEdgeBitSet & src );
78
79} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
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:601
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:776