draco_core/
geometry_indices.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
3pub struct AttributeValueIndex(pub u32);
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
7pub struct PointIndex(pub u32);
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
11pub struct VertexIndex(pub u32);
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct CornerIndex(pub u32);
16
17impl std::ops::Add<u32> for CornerIndex {
18 type Output = CornerIndex;
19 fn add(self, rhs: u32) -> CornerIndex {
20 CornerIndex(self.0 + rhs)
21 }
22}
23
24impl std::ops::Sub<u32> for CornerIndex {
25 type Output = CornerIndex;
26 fn sub(self, rhs: u32) -> CornerIndex {
27 CornerIndex(self.0 - rhs)
28 }
29}
30
31impl From<CornerIndex> for u32 {
32 fn from(ci: CornerIndex) -> u32 {
33 ci.0
34 }
35}
36
37#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
39pub struct FaceIndex(pub u32);
40
41pub const INVALID_ATTRIBUTE_VALUE_INDEX: AttributeValueIndex = AttributeValueIndex(u32::MAX);
43pub const INVALID_POINT_INDEX: PointIndex = PointIndex(u32::MAX);
45pub const INVALID_VERTEX_INDEX: VertexIndex = VertexIndex(u32::MAX);
47pub const INVALID_CORNER_INDEX: CornerIndex = CornerIndex(u32::MAX);
49pub const INVALID_FACE_INDEX: FaceIndex = FaceIndex(u32::MAX);
51
52impl From<u32> for AttributeValueIndex {
53 fn from(v: u32) -> Self {
54 Self(v)
55 }
56}
57
58impl From<AttributeValueIndex> for u32 {
59 fn from(v: AttributeValueIndex) -> Self {
60 v.0
61 }
62}
63
64impl From<u32> for PointIndex {
65 fn from(v: u32) -> Self {
66 Self(v)
67 }
68}
69
70impl From<PointIndex> for u32 {
71 fn from(v: PointIndex) -> Self {
72 v.0
73 }
74}
75
76impl From<usize> for PointIndex {
77 fn from(v: usize) -> Self {
78 Self(v as u32)
79 }
80}
81
82impl From<PointIndex> for usize {
83 fn from(v: PointIndex) -> Self {
84 v.0 as usize
85 }
86}