Another project
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 2.3 kB View raw
1use bone_types::SketchEntityId; 2use serde::{Deserialize, Serialize}; 3 4#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] 5pub enum SketchRelation { 6 Coincident(SketchEntityId, SketchEntityId), 7 Horizontal(SketchEntityId), 8 Vertical(SketchEntityId), 9 Parallel(SketchEntityId, SketchEntityId), 10 Perpendicular(SketchEntityId, SketchEntityId), 11 Tangent(SketchEntityId, SketchEntityId), 12 Equal(SketchEntityId, SketchEntityId), 13 Concentric(SketchEntityId, SketchEntityId), 14 Midpoint { 15 point: SketchEntityId, 16 line: SketchEntityId, 17 }, 18 Symmetric { 19 a: SketchEntityId, 20 b: SketchEntityId, 21 axis: SketchEntityId, 22 }, 23 Fix(SketchEntityId), 24} 25 26impl SketchRelation { 27 #[must_use] 28 pub const fn references(&self) -> RelationRefs { 29 match *self { 30 Self::Coincident(a, b) 31 | Self::Parallel(a, b) 32 | Self::Perpendicular(a, b) 33 | Self::Tangent(a, b) 34 | Self::Equal(a, b) 35 | Self::Concentric(a, b) => RelationRefs([Some(a), Some(b), None]), 36 Self::Midpoint { point, line } => RelationRefs([Some(point), Some(line), None]), 37 Self::Symmetric { a, b, axis } => RelationRefs([Some(a), Some(b), Some(axis)]), 38 Self::Horizontal(a) | Self::Vertical(a) | Self::Fix(a) => { 39 RelationRefs([Some(a), None, None]) 40 } 41 } 42 } 43 44 #[must_use] 45 pub const fn pair(&self) -> Option<(SketchEntityId, SketchEntityId)> { 46 match *self { 47 Self::Coincident(a, b) 48 | Self::Parallel(a, b) 49 | Self::Perpendicular(a, b) 50 | Self::Tangent(a, b) 51 | Self::Equal(a, b) 52 | Self::Concentric(a, b) => Some((a, b)), 53 Self::Midpoint { point, line } => Some((point, line)), 54 Self::Symmetric { .. } | Self::Horizontal(_) | Self::Vertical(_) | Self::Fix(_) => None, 55 } 56 } 57} 58 59#[derive(Copy, Clone, Debug, PartialEq)] 60pub struct RelationRefs([Option<SketchEntityId>; 3]); 61 62impl IntoIterator for RelationRefs { 63 type Item = SketchEntityId; 64 type IntoIter = core::iter::Flatten<core::array::IntoIter<Option<SketchEntityId>, 3>>; 65 66 fn into_iter(self) -> Self::IntoIter { 67 self.0.into_iter().flatten() 68 } 69}