use bon::Builder;
use enum_iterator::Sequence;
use parse_display_derive::{Display, FromStr};
pub use point::{Point2d, Point3d, Point4d, Quaternion};
use schemars::{schema::SchemaObject, JsonSchema};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[cfg(feature = "cxx")]
use crate::impl_extern_type;
use crate::{def_enum::negative_one, length_unit::LengthUnit, output::ExtrusionFaceInfo, units::UnitAngle};
mod point;
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum CutType {
#[default]
Fillet,
Chamfer,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum MirrorAcross {
Edge {
id: Uuid,
},
Axis {
axis: Point3d<f64>,
point: Point3d<LengthUnit>,
},
Plane {
id: Uuid,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum CutTypeV2 {
Fillet {
radius: LengthUnit,
second_length: Option<LengthUnit>,
},
Chamfer {
distance: LengthUnit,
second_distance: Option<LengthUnit>,
angle: Option<Angle>,
swap: bool,
},
Custom {
path: Uuid,
},
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct Rotation {
pub axis: Point3d<f64>,
pub angle: Angle,
pub origin: OriginType,
}
impl Default for Rotation {
fn default() -> Self {
Self {
axis: z_axis(),
angle: Angle::default(),
origin: OriginType::Local,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct Transform {
#[serde(default)]
#[builder(default)]
pub translate: Point3d<LengthUnit>,
#[serde(default = "same_scale")]
#[builder(default = same_scale())]
pub scale: Point3d<f64>,
#[serde(default)]
#[builder(default)]
pub rotation: Rotation,
#[serde(default = "bool_true")]
#[builder(default = bool_true())]
pub replicate: bool,
}
impl Default for Transform {
fn default() -> Self {
Self {
scale: same_scale(),
replicate: true,
translate: Default::default(),
rotation: Rotation::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct AnnotationOptions {
pub text: Option<AnnotationTextOptions>,
pub line_ends: Option<AnnotationLineEndOptions>,
pub line_width: Option<f32>,
pub color: Option<Color>,
pub position: Option<Point3d<f32>>,
pub dimension: Option<AnnotationBasicDimension>,
pub feature_control: Option<AnnotationFeatureControl>,
pub feature_tag: Option<AnnotationFeatureTag>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct AnnotationLineEndOptions {
pub start: AnnotationLineEnd,
pub end: AnnotationLineEnd,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct AnnotationTextOptions {
pub x: AnnotationTextAlignmentX,
pub y: AnnotationTextAlignmentY,
pub text: String,
pub point_size: u32,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct AnnotationMbdControlFrame {
pub symbol: MbdSymbol,
pub diameter_symbol: Option<MbdSymbol>,
pub tolerance: f64,
pub modifier: Option<MbdSymbol>,
pub primary_datum: Option<char>,
pub secondary_datum: Option<char>,
pub tertiary_datum: Option<char>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct AnnotationMbdBasicDimension {
pub symbol: Option<MbdSymbol>,
pub dimension: Option<f64>,
pub tolerance: f64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct AnnotationBasicDimension {
pub from_entity_id: Uuid,
pub from_entity_pos: Point2d<f64>,
pub to_entity_id: Uuid,
pub to_entity_pos: Point2d<f64>,
pub dimension: AnnotationMbdBasicDimension,
pub plane_id: Uuid,
pub offset: Point2d<f64>,
pub precision: u32,
pub font_scale: f32,
pub font_point_size: u32,
#[serde(default = "one")]
pub arrow_scale: f32,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct AnnotationFeatureControl {
pub entity_id: Uuid,
pub entity_pos: Point2d<f64>,
pub leader_type: AnnotationLineEnd,
pub dimension: Option<AnnotationMbdBasicDimension>,
pub control_frame: Option<AnnotationMbdControlFrame>,
pub defined_datum: Option<char>,
pub prefix: Option<String>,
pub suffix: Option<String>,
pub plane_id: Uuid,
pub offset: Point2d<f64>,
pub precision: u32,
pub font_scale: f32,
pub font_point_size: u32,
#[serde(default = "one")]
pub leader_scale: f32,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct AnnotationFeatureTag {
pub entity_id: Uuid,
pub entity_pos: Point2d<f64>,
pub leader_type: AnnotationLineEnd,
pub key: String,
pub value: String,
pub show_key: bool,
pub plane_id: Uuid,
pub offset: Point2d<f64>,
pub font_scale: f32,
pub font_point_size: u32,
#[serde(default = "one")]
pub leader_scale: f32,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", tag = "type")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum DistanceType {
Euclidean {},
OnAxis {
axis: GlobalAxis,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "snake_case", tag = "type")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum OriginType {
#[default]
Local,
Global,
Custom {
origin: Point3d<f64>,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
impl Color {
pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
Self { r, g, b, a }
}
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum AnnotationTextAlignmentX {
Left,
Center,
Right,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum AnnotationTextAlignmentY {
Bottom,
Center,
Top,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum AnnotationLineEnd {
None,
Arrow,
Dot,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum AnnotationType {
T2D,
T3D,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum MbdStandard {
AsmeY14_5,
}
#[allow(missing_docs)]
#[derive(
Default,
Display,
FromStr,
Copy,
Eq,
PartialEq,
Debug,
JsonSchema,
Deserialize,
Serialize,
Sequence,
Clone,
Ord,
PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[repr(u16)]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum MbdSymbol {
#[default]
None = 0,
ArcLength = 174,
Between = 175,
Degrees = 176,
PlusMinus = 177,
Angularity = 178,
Cylindricity = 179,
Roundness = 180,
Concentricity = 181,
Straightness = 182,
Parallelism = 183,
Flatness = 184,
ProfileOfLine = 185,
SurfaceProfile = 186,
Symmetry = 187,
Perpendicularity = 188,
Runout = 189,
TotalRunout = 190,
Position = 191,
CenterLine = 192,
PartingLine = 193,
IsoEnvelope = 195,
IsoEnvelopeNonY145M = 196,
FreeState = 197,
StatisticalTolerance = 198,
ContinuousFeature = 199,
Independency = 200,
Depth = 201,
Start = 202,
LeastCondition = 203,
MaxCondition = 204,
ConicalTaper = 205,
Projected = 206,
Slope = 207,
Micro = 208,
TangentPlane = 210,
Unilateral = 211,
SquareFeature = 212,
Countersink = 213,
SpotFace = 214,
Target = 215,
Diameter = 216,
Radius = 217,
SphericalRadius = 218,
SphericalDiameter = 219,
ControlledRadius = 220,
BoxStart = 123,
BoxBar = 162,
BoxBarBetween = 124,
LetterBackwardUnderline = 95,
PunctuationBackwardUnderline = 92,
ModifierBackwardUnderline = 126,
NumericBackwardUnderline = 96,
BoxEnd = 125,
DatumUp = 166,
DatumLeft = 168,
DatumRight = 167,
DatumDown = 165,
DatumTriangle = 295,
HalfSpace = 236,
QuarterSpace = 237,
EighthSpace = 238,
ModifierSpace = 239,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum CameraDragInteractionType {
Pan,
Rotate,
RotateTrackball,
Zoom,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case", tag = "type")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum PathSegment {
Line {
end: Point3d<LengthUnit>,
relative: bool,
},
Arc {
center: Point2d<LengthUnit>,
radius: LengthUnit,
start: Angle,
end: Angle,
relative: bool,
},
Bezier {
control1: Point3d<LengthUnit>,
control2: Point3d<LengthUnit>,
end: Point3d<LengthUnit>,
relative: bool,
},
TangentialArc {
radius: LengthUnit,
offset: Angle,
},
TangentialArcTo {
to: Point3d<LengthUnit>,
angle_snap_increment: Option<Angle>,
},
ArcTo {
interior: Point3d<LengthUnit>,
end: Point3d<LengthUnit>,
relative: bool,
},
CircularInvolute {
start_radius: LengthUnit,
end_radius: LengthUnit,
angle: Angle,
reverse: bool,
},
Ellipse {
center: Point2d<LengthUnit>,
major_axis: Point2d<LengthUnit>,
minor_radius: LengthUnit,
start_angle: Angle,
end_angle: Angle,
},
ConicTo {
interior: Point2d<LengthUnit>,
end: Point2d<LengthUnit>,
start_tangent: Point2d<LengthUnit>,
end_tangent: Point2d<LengthUnit>,
relative: bool,
},
}
#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct Angle {
pub unit: UnitAngle,
pub value: f64,
}
impl Angle {
pub fn to_degrees(self) -> f64 {
match self.unit {
UnitAngle::Degrees => self.value,
UnitAngle::Radians => self.value.to_degrees(),
}
}
pub fn to_radians(self) -> f64 {
match self.unit {
UnitAngle::Degrees => self.value.to_radians(),
UnitAngle::Radians => self.value,
}
}
pub const fn from_degrees(value: f64) -> Self {
Self {
unit: UnitAngle::Degrees,
value,
}
}
pub const fn from_radians(value: f64) -> Self {
Self {
unit: UnitAngle::Radians,
value,
}
}
pub const fn turn() -> Self {
Self::from_degrees(360.0)
}
pub const fn half_circle() -> Self {
Self::from_degrees(180.0)
}
pub const fn quarter_circle() -> Self {
Self::from_degrees(90.0)
}
pub const fn zero() -> Self {
Self::from_degrees(0.0)
}
}
impl Default for Angle {
fn default() -> Self {
Self::zero()
}
}
impl PartialOrd for Angle {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
match (self.unit, other.unit) {
(UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
(UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
_ => self.to_degrees().partial_cmp(&other.to_degrees()),
}
}
}
impl std::ops::Add for Angle {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Self {
unit: UnitAngle::Degrees,
value: self.to_degrees() + rhs.to_degrees(),
}
}
}
impl std::ops::AddAssign for Angle {
fn add_assign(&mut self, rhs: Self) {
match self.unit {
UnitAngle::Degrees => {
self.value += rhs.to_degrees();
}
UnitAngle::Radians => {
self.value += rhs.to_radians();
}
}
}
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum SceneSelectionType {
Replace,
Add,
Remove,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum SceneToolType {
CameraRevolve,
Select,
Move,
SketchLine,
SketchTangentialArc,
SketchCurve,
SketchCurveMod,
}
#[allow(missing_docs)]
#[derive(
Display,
FromStr,
Copy,
Eq,
PartialEq,
Debug,
JsonSchema,
Deserialize,
Serialize,
Sequence,
Clone,
Ord,
PartialOrd,
Default,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum PathComponentConstraintBound {
#[default]
Unconstrained,
PartiallyConstrained,
FullyConstrained,
}
#[allow(missing_docs)]
#[derive(
Display,
FromStr,
Copy,
Eq,
PartialEq,
Debug,
JsonSchema,
Deserialize,
Serialize,
Sequence,
Clone,
Ord,
PartialOrd,
Default,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum PathComponentConstraintType {
#[default]
Unconstrained,
Vertical,
Horizontal,
EqualLength,
Parallel,
AngleBetween,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum PathCommand {
MoveTo,
LineTo,
BezCurveTo,
NurbsCurveTo,
AddArc,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[repr(u8)]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum EntityType {
Entity,
Object,
Path,
Curve,
Solid2D,
Solid3D,
Edge,
Face,
Plane,
Vertex,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum CurveType {
Line,
Arc,
Nurbs,
}
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct ExportFile {
pub name: String,
pub contents: crate::base64::Base64Data,
}
#[cfg(feature = "python")]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
#[pyo3::pymethods]
impl ExportFile {
#[getter]
fn contents(&self) -> Vec<u8> {
self.contents.0.clone()
}
#[getter]
fn name(&self) -> String {
self.name.clone()
}
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
)]
#[serde(rename_all = "lowercase")]
#[display(style = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum FileExportFormat {
Fbx,
Glb,
Gltf,
Obj,
Ply,
Step,
Stl,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
)]
#[serde(rename_all = "lowercase")]
#[display(style = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum FileExportFormat2d {
Dxf,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
)]
#[serde(rename_all = "lowercase")]
#[display(style = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum FileImportFormat {
Fbx,
Gltf,
Obj,
Ply,
Sldprt,
Step,
Stl,
}
#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum EngineErrorCode {
BadRequest = 1,
InternalEngine,
}
impl From<EngineErrorCode> for http::StatusCode {
fn from(e: EngineErrorCode) -> Self {
match e {
EngineErrorCode::BadRequest => Self::BAD_REQUEST,
EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
}
}
}
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum BlendType {
#[default]
Tangent,
}
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum BodyType {
#[default]
Solid,
Surface,
}
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum ExtrudeMethod {
New,
#[default]
Merge,
}
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum ExtrudeReference {
EntityReference {
entity_id: Uuid,
},
Axis {
axis: Point3d<f64>,
#[serde(default)]
point: Point3d<LengthUnit>,
},
Point {
point: Point3d<LengthUnit>,
},
}
#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct ExtrudedFaceInfo {
pub bottom: Option<Uuid>,
pub top: Uuid,
pub sides: Vec<SideFace>,
}
#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct SideFace {
pub path_id: Uuid,
pub face_id: Uuid,
}
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct CameraSettings {
pub pos: Point3d,
pub center: Point3d,
pub up: Point3d,
pub orientation: Quaternion,
pub fov_y: Option<f32>,
pub ortho_scale: Option<f32>,
pub ortho: bool,
}
#[allow(missing_docs)]
#[repr(u8)]
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum WorldCoordinateSystem {
#[default]
RightHandedUpZ,
RightHandedUpY,
}
#[allow(missing_docs)]
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct CameraViewState {
pub pivot_rotation: Quaternion,
pub pivot_position: Point3d,
pub eye_offset: f32,
pub fov_y: f32,
pub ortho_scale_factor: f32,
pub is_ortho: bool,
pub ortho_scale_enabled: bool,
pub world_coord_system: WorldCoordinateSystem,
}
impl Default for CameraViewState {
fn default() -> Self {
CameraViewState {
pivot_rotation: Default::default(),
pivot_position: Default::default(),
eye_offset: 10.0,
fov_y: 45.0,
ortho_scale_factor: 1.6,
is_ortho: false,
ortho_scale_enabled: true,
world_coord_system: Default::default(),
}
}
}
#[cfg(feature = "cxx")]
impl_extern_type! {
[Trivial]
CameraViewState = "Endpoints::CameraViewState"
}
impl From<CameraSettings> for crate::output::DefaultCameraZoom {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::CameraDragMove {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::CameraDragEnd {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::ZoomToFit {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::OrientToFace {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::ViewIsometric {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default, Builder)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct PerspectiveCameraParameters {
pub fov_y: Option<f32>,
pub z_near: Option<f32>,
pub z_far: Option<f32>,
}
#[derive(
Default,
Display,
FromStr,
Copy,
Eq,
PartialEq,
Debug,
JsonSchema,
Deserialize,
Serialize,
Sequence,
Clone,
Ord,
PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum CameraMovement {
#[default]
Vantage,
None,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum GlobalAxis {
X,
Y,
Z,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[repr(u8)]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum ExtrusionFaceCapType {
None,
Top,
Bottom,
Both,
}
#[allow(missing_docs)]
#[derive(
Display,
FromStr,
Copy,
Eq,
PartialEq,
Debug,
JsonSchema,
Deserialize,
Serialize,
Sequence,
Clone,
Ord,
PartialOrd,
Default,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum PostEffectType {
Phosphor,
Ssao,
#[default]
NoEffect,
}
#[cfg(feature = "cxx")]
impl_extern_type! {
[Trivial]
FileImportFormat = "Enums::_FileImportFormat"
FileExportFormat = "Enums::_FileExportFormat"
CameraDragInteractionType = "Enums::_CameraDragInteractionType"
SceneSelectionType = "Enums::_SceneSelectionType"
SceneToolType = "Enums::_SceneToolType"
BlendType = "Enums::_BlendType"
BodyType = "Enums::_BodyType"
EntityType = "Enums::_EntityType"
AnnotationType = "Enums::_AnnotationType"
AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
AnnotationLineEnd = "Enums::_AnnotationLineEnd"
MbdStandard = "Enums::_MBDStandard"
MbdSymbol = "Enums::_MBDSymbol"
CurveType = "Enums::_CurveType"
PathCommand = "Enums::_PathCommand"
PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
PathComponentConstraintType = "Enums::_PathComponentConstraintType"
ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
EngineErrorCode = "Enums::_ErrorCode"
GlobalAxis = "Enums::_GlobalAxis"
OriginType = "Enums::_OriginType"
PostEffectType = "Enums::_PostEffectType"
}
fn bool_true() -> bool {
true
}
fn same_scale() -> Point3d<f64> {
Point3d::uniform(1.0)
}
fn z_axis() -> Point3d<f64> {
Point3d { x: 0.0, y: 0.0, z: 1.0 }
}
impl ExtrudedFaceInfo {
pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
let mut face_infos: Vec<_> = self
.sides
.into_iter()
.map(|side| ExtrusionFaceInfo {
curve_id: Some(side.path_id),
face_id: Some(side.face_id),
cap: ExtrusionFaceCapType::None,
})
.collect();
face_infos.push(ExtrusionFaceInfo {
curve_id: None,
face_id: Some(self.top),
cap: ExtrusionFaceCapType::Top,
});
if let Some(bottom) = self.bottom {
face_infos.push(ExtrusionFaceInfo {
curve_id: None,
face_id: Some(bottom),
cap: ExtrusionFaceCapType::Bottom,
});
}
face_infos
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_angle_comparison() {
let a = Angle::from_degrees(90.0);
assert!(a < Angle::from_degrees(91.0));
assert!(a > Angle::from_degrees(89.0));
assert!(a <= Angle::from_degrees(90.0));
assert!(a >= Angle::from_degrees(90.0));
let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
assert!(a > b);
assert!(a >= b);
assert!(b < a);
assert!(b <= a);
let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
assert!(a < c);
assert!(a <= c);
assert!(c > a);
assert!(c >= a);
}
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, JsonSchema, Builder)]
#[schemars(rename = "TransformByFor{T}")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct TransformBy<T> {
pub property: T,
pub set: bool,
#[serde(default)]
#[builder(default)]
pub origin: OriginType,
}
impl<T> TransformBy<T> {
pub fn get_origin(&self) -> OriginType {
self.origin
}
}
#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, Default, Builder)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct ComponentTransform {
pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
pub scale: Option<TransformBy<Point3d<f64>>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum Opposite<T> {
#[default]
None,
Symmetric,
Other(T),
}
impl<T: JsonSchema> JsonSchema for Opposite<T> {
fn schema_name() -> String {
format!("OppositeFor{}", T::schema_name())
}
fn schema_id() -> std::borrow::Cow<'static, str> {
std::borrow::Cow::Owned(format!("{}::Opposite<{}>", module_path!(), T::schema_id()))
}
fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
SchemaObject {
instance_type: Some(schemars::schema::InstanceType::String.into()),
..Default::default()
}
.into()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum CutStrategy {
Basic,
Csg,
#[default]
Automatic,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum RelativeTo {
#[default]
SketchPlane,
TrajectoryCurve,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct SelectedRegion {
pub segment: Uuid,
pub intersection_segment: Uuid,
#[serde(default = "negative_one")]
pub intersection_index: i32,
#[serde(default)]
pub curve_clockwise: bool,
}
impl Default for SelectedRegion {
fn default() -> Self {
Self {
segment: Default::default(),
intersection_segment: Default::default(),
intersection_index: -1,
curve_clockwise: Default::default(),
}
}
}
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct FractionOfEdge {
pub edge_id: Uuid,
#[serde(default)]
#[builder(default)]
#[schemars(range(min = 0, max = 1))]
pub lower_bound: f32,
#[serde(default = "one")]
#[builder(default = one())]
#[schemars(range(min = 0, max = 1))]
pub upper_bound: f32,
}
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct SurfaceEdgeReference {
pub object_id: Uuid,
pub edges: Vec<FractionOfEdge>,
}
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct BodiesCreated {
pub bodies: Vec<BodyCreated>,
}
impl BodiesCreated {
pub fn is_empty(&self) -> bool {
self.bodies.is_empty()
}
}
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct BodiesUpdated {
pub bodies: Vec<BodyUpdated>,
}
impl BodiesUpdated {
pub fn is_empty(&self) -> bool {
self.bodies.is_empty()
}
}
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct BodyCreated {
pub id: Uuid,
pub surfaces: Vec<SurfaceCreated>,
}
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct BodyUpdated {
pub id: Uuid,
pub surfaces: Vec<SurfaceCreated>,
}
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct SurfaceCreated {
pub id: Uuid,
pub primitive_face_index: u32,
pub from_segments: Vec<Uuid>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub enum RegionVersion {
#[default]
V0,
V1,
}
impl From<BodyCreated> for BodyUpdated {
fn from(body: BodyCreated) -> Self {
Self {
id: body.id,
surfaces: body.surfaces,
}
}
}
impl From<BodyUpdated> for BodyCreated {
fn from(body: BodyUpdated) -> Self {
Self {
id: body.id,
surfaces: body.surfaces,
}
}
}
impl From<BodiesCreated> for BodiesUpdated {
fn from(bodies: BodiesCreated) -> Self {
Self {
bodies: bodies.bodies.into_iter().map(Into::into).collect(),
}
}
}
impl From<BodiesUpdated> for BodiesCreated {
fn from(bodies: BodiesUpdated) -> Self {
Self {
bodies: bodies.bodies.into_iter().map(Into::into).collect(),
}
}
}
fn one() -> f32 {
1.0
}