openconfiguration/
attach_point.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{impl_visitable_noop, Quaternion, Vector3};
4
5#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
6#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
7/// The type of the point
8/// "Origin" - the origin of a product, matches to "Child"
9/// "Child" - a (virtual) child can be placed, matches to "Origin"
10/// "Left" - L-R neighborship, matches to "Right"
11/// "Right" - L-R neighborship, matches to "Left"
12/// "Top" - vertical neighborship, matches to "Bottom"
13/// "Bottom" - vertical neighborship, matches to "Top"
14/// "Front" - front/back neighborship, matches to "Back"
15/// "Back" - front/back neighborship, matches to "Front"
16/// "Alignment" - auxiliary point to support alignments
17/// "Maximum" - marks the maximum of the bbox
18/// "Minimum" - marks the minimum of the bbox
19pub enum AttachPointType {
20    Origin,
21    Child,
22    Left,
23    Right,
24    Top,
25    Bottom,
26    Front,
27    Back,
28    Alignment,
29    Maximum,
30    Minimum,
31}
32
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
34#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
35pub enum AttachPointRepresentation {
36    Standard,
37    Ghost,
38    Ghost2,
39}
40
41#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
42#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
43#[cfg_attr(feature = "schema", schemars(deny_unknown_fields))]
44#[serde(rename_all = "camelCase")]
45/// An attachment point for planning support and placement of children.
46/// All attributes are mandatory, except for Tags.
47///
48/// Two attachment points match:
49/// - if Key and Foreign match, if needed with wildcards in the Foreign key,
50/// - there's at least one matching Tag on both sides, in case at least one has tags,
51/// - the Types match to each other, such as L - R
52/// - both of them are enabled
53/// - the position offset in global space is less than 0.2 [m]
54/// - the rotation offset in global space is less than 45 deg
55///
56/// IGXC Compatibility: the Rotation is changed to Quaternion, in IGXC it
57/// was Euler-based.
58pub struct AttachPoint {
59    #[serde(rename = "type")]
60
61    /// The type of the point
62    pub kind: AttachPointType,
63
64    /// Own key of the point. Should match the counterpart's foreign key.
65    pub key: String,
66
67    /// Allowed keys of counterpart's points. May contain /// and ? characters.
68    pub foreign: String,
69
70    /// An optional list of ids or tags to be used for attach-point matching.
71    /// If one point defines tags, the other point matches--if it already
72    /// matches--and additionally provides at least one compatible tag.
73    /// Two tags are compatible if there case-normalized versions are equal.
74    pub tags: Option<Vec<String>>,
75
76    /// The position of the point, relative to the Product.
77    pub point: Vector3,
78
79    /// The orientation of the point, relative to the Product.
80    pub rotation: Quaternion,
81
82    /// Attribute controls if the point is enabled.
83    /// If disabled, it should be invisible too.
84    pub enabled: bool,
85
86    /// The visual representation of the attachment point.
87    pub representation: AttachPointRepresentation,
88}
89
90impl_visitable_noop!(AttachPoint);