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
use serde::{Deserialize, Serialize};
use crate::{Quaternion, Vector3};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
/// The type of the point
/// "Origin" - the origin of a product, matches to "Child"
/// "Child" - a (virtual) child can be placed, matches to "Origin"
/// "Left" - L-R neighborship, matches to "Right"
/// "Right" - L-R neighborship, matches to "Left"
/// "Top" - vertical neighborship, matches to "Bottom"
/// "Bottom" - vertical neighborship, matches to "Top"
/// "Front" - front/back neighborship, matches to "Back"
/// "Back" - front/back neighborship, matches to "Front"
/// "Alignment" - auxiliary point to support alignments
/// "Maximum" - marks the maximum of the bbox
/// "Minimum" - marks the minimum of the bbox
pub enum AttachPointType {
Origin,
Child,
Left,
Right,
Top,
Bottom,
Front,
Back,
Alignment,
Maximum,
Minimum,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum AttachPointRepresentation {
Standard,
Ghost,
Ghost2,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "schema", schemars(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
/// An attachment point for planning support and placement of children.
/// All attributes are mandatory, except for Tags.
///
/// Two attachment points match:
/// - if Key and Foreign match, if needed with wildcards in the Foreign key,
/// - there's at least one matching Tag on both sides, in case at least one has tags,
/// - the Types match to each other, such as L - R
/// - both of them are enabled
/// - the position offset in global space is less than 0.2 [m]
/// - the rotation offset in global space is less than 45 deg
///
/// IGXC Compatibility: the Rotation is changed to Quaternion, in IGXC it
/// was Euler-based.
pub struct AttachPoint {
#[serde(rename = "type")]
/// The type of the point
pub kind: AttachPointType,
/// Own key of the point. Should match the counterpart's foreign key.
pub key: String,
/// Allowed keys of counterpart's points. May contain /// and ? characters.
pub foreign: String,
/// An optional list of ids or tags to be used for attach-point matching.
/// If one point defines tags, the other point matches--if it already
/// matches--and additionally provides at least one compatible tag.
/// Two tags are compatible if there case-normalized versions are equal.
pub tags: Option<Vec<String>>,
/// The position of the point, relative to the Product.
pub point: Vector3,
/// The orientation of the point, relative to the Product.
pub rotation: Quaternion,
/// Attribute controls if the point is enabled.
/// If disabled, it should be invisible too.
pub enabled: bool,
/// The visual representation of the attachment point.
pub representation: AttachPointRepresentation,
}