honeycomb_core/cmap/components/
identifiers.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// ------ IMPORTS

// ------ CONTENT

macro_rules! impl_from_dartid {
    ($idty: ty) => {
        impl From<DartId> for $idty {
            fn from(dart_id: DartId) -> Self {
                Self(dart_id.0.into())
            }
        }
    };
}

macro_rules! impl_from_for_dartid {
    ($idty: ty) => {
        impl From<$idty> for DartId {
            fn from(id: $idty) -> Self {
                Self(id.0.into())
            }
        }
    };
}

// --- darts

/// Dart ID representation type.
pub type DartIdType = u32;

#[allow(unused)]
/// Strongly-typed dart ID.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct DartId(pub DartIdType);

/// Null dart ID value.
pub const NULL_DART_ID: DartIdType = 0; //: DartId = DartId(0);

impl_from_for_dartid!(VertexId);
impl_from_for_dartid!(EdgeId);
impl_from_for_dartid!(FaceId);
impl_from_for_dartid!(VolumeId);

// --- vertices

/// Vertex ID representation type.
pub type VertexIdType = u32;

#[allow(unused)]
/// Strongly-typed vertex ID.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct VertexId(pub VertexIdType);

/// Null vertex ID value.
pub const NULL_VERTEX_ID: VertexIdType = 0; //: VertexId = VertexId(0);

impl_from_dartid!(VertexId);

// --- edges

/// Edge ID representation type.
pub type EdgeIdType = u32;

#[allow(unused)]
/// Strongly-typed edge ID.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct EdgeId(pub EdgeIdType);

/// Null edge ID value.
pub const NULL_EDGE_ID: EdgeIdType = 0; //: EdgeId = EdgeId(0);

impl_from_dartid!(EdgeId);

// --- faces

/// Face ID representation type.
pub type FaceIdType = u32;

#[allow(unused)]
/// Strongly-typed face ID.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct FaceId(pub FaceIdType);

/// Null face ID value.
pub const NULL_FACE_ID: FaceIdType = 0; //: FaceId = FaceId(0);

impl_from_dartid!(FaceId);

// --- volumes

/// Volume ID representation type.
pub type VolumeIdType = u32;

#[allow(unused)]
/// Strongly-typed volume ID.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct VolumeId(pub VolumeIdType);

/// Null volume ID value.
pub const NULL_VOLUME_ID: VolumeIdType = 0; //: VolumeId = VolumeId(0);

impl_from_dartid!(VolumeId);