1use bon::Builder;
2use enum_iterator::Sequence;
3use parse_display_derive::{Display, FromStr};
4pub use point::{Point2d, Point3d, Point4d, Quaternion};
5use schemars::{schema::SchemaObject, JsonSchema};
6use serde::{Deserialize, Serialize};
7use uuid::Uuid;
8
9#[cfg(feature = "cxx")]
10use crate::impl_extern_type;
11use crate::{def_enum::negative_one, length_unit::LengthUnit, output::ExtrusionFaceInfo, units::UnitAngle};
12
13mod point;
14
15#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
17#[serde(rename_all = "snake_case")]
18#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
19#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
20#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
21pub enum CutType {
22 #[default]
24 Fillet,
25 Chamfer,
27}
28
29#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
31#[serde(rename_all = "snake_case")]
32#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
33#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
34#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
35pub enum MirrorAcross {
36 Edge {
39 id: Uuid,
41 },
42 Axis {
45 axis: Point3d<f64>,
47 point: Point3d<LengthUnit>,
49 },
50 Plane {
53 id: Uuid,
55 },
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
60#[serde(rename_all = "snake_case")]
61#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
62#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
63#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
64#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
65pub enum CutTypeV2 {
66 Fillet {
68 radius: LengthUnit,
70 second_length: Option<LengthUnit>,
73 },
74 Chamfer {
76 distance: LengthUnit,
78 second_distance: Option<LengthUnit>,
80 angle: Option<Angle>,
82 swap: bool,
84 },
85 Custom {
87 path: Uuid,
89 },
90}
91
92#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
94#[serde(rename_all = "snake_case")]
95#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
96#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
97#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
98#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
99pub struct Rotation {
100 pub axis: Point3d<f64>,
103 pub angle: Angle,
106 pub origin: OriginType,
108}
109
110impl Default for Rotation {
111 fn default() -> Self {
113 Self {
114 axis: z_axis(),
115 angle: Angle::default(),
116 origin: OriginType::Local,
117 }
118 }
119}
120
121#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
123#[serde(rename_all = "snake_case")]
124#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
125#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
126#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
127#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
128pub struct Transform {
129 #[serde(default)]
132 #[builder(default)]
133 pub translate: Point3d<LengthUnit>,
134 #[serde(default = "same_scale")]
137 #[builder(default = same_scale())]
138 pub scale: Point3d<f64>,
139 #[serde(default)]
142 #[builder(default)]
143 pub rotation: Rotation,
144 #[serde(default = "bool_true")]
146 #[builder(default = bool_true())]
147 pub replicate: bool,
148}
149
150impl Default for Transform {
151 fn default() -> Self {
152 Self {
153 scale: same_scale(),
154 replicate: true,
155 translate: Default::default(),
156 rotation: Rotation::default(),
157 }
158 }
159}
160
161#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
163#[serde(rename_all = "snake_case")]
164#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
165#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
166#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
167#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
168pub struct AnnotationOptions {
169 pub text: Option<AnnotationTextOptions>,
171 pub line_ends: Option<AnnotationLineEndOptions>,
173 pub line_width: Option<f32>,
175 pub color: Option<Color>,
177 pub position: Option<Point3d<f32>>,
179 pub dimension: Option<AnnotationBasicDimension>,
181 pub feature_control: Option<AnnotationFeatureControl>,
183 pub feature_tag: Option<AnnotationFeatureTag>,
185}
186
187#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
189#[serde(rename_all = "snake_case")]
190#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
191#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
192#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
193#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
194pub struct AnnotationLineEndOptions {
195 pub start: AnnotationLineEnd,
197 pub end: AnnotationLineEnd,
199}
200
201#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
203#[serde(rename_all = "snake_case")]
204#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
205#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
206#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
207#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
208pub struct AnnotationTextOptions {
209 pub x: AnnotationTextAlignmentX,
211 pub y: AnnotationTextAlignmentY,
213 pub text: String,
215 pub point_size: u32,
217}
218
219#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
221#[serde(rename_all = "snake_case")]
222#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
223#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
224#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
225#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
226pub struct AnnotationMbdControlFrame {
227 pub symbol: MbdSymbol,
229 pub diameter_symbol: Option<MbdSymbol>,
231 pub tolerance: f64,
233 pub modifier: Option<MbdSymbol>,
235 pub primary_datum: Option<char>,
237 pub secondary_datum: Option<char>,
239 pub tertiary_datum: Option<char>,
241}
242
243#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
245#[serde(rename_all = "snake_case")]
246#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
247#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
248#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
249#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
250pub struct AnnotationMbdBasicDimension {
251 pub symbol: Option<MbdSymbol>,
253 pub dimension: Option<f64>,
255 pub tolerance: f64,
257}
258
259#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
261#[serde(rename_all = "snake_case")]
262#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
263#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
264#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
265#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
266pub struct AnnotationBasicDimension {
267 pub from_entity_id: Uuid,
269
270 pub from_entity_pos: Point2d<f64>,
272
273 pub to_entity_id: Uuid,
275
276 pub to_entity_pos: Point2d<f64>,
278
279 pub dimension: AnnotationMbdBasicDimension,
281
282 pub plane_id: Uuid,
284
285 pub offset: Point2d<f64>,
287
288 pub precision: u32,
290
291 pub font_scale: f32,
293
294 pub font_point_size: u32,
296
297 #[serde(default = "one")]
299 pub arrow_scale: f32,
300}
301
302#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
304#[serde(rename_all = "snake_case")]
305#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
306#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
307#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
308#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
309pub struct AnnotationFeatureControl {
310 pub entity_id: Uuid,
312
313 pub entity_pos: Point2d<f64>,
315
316 pub leader_type: AnnotationLineEnd,
318
319 pub dimension: Option<AnnotationMbdBasicDimension>,
321
322 pub control_frame: Option<AnnotationMbdControlFrame>,
324
325 pub defined_datum: Option<char>,
327
328 pub prefix: Option<String>,
330
331 pub suffix: Option<String>,
333
334 pub plane_id: Uuid,
336
337 pub offset: Point2d<f64>,
339
340 pub precision: u32,
342
343 pub font_scale: f32,
345
346 pub font_point_size: u32,
348
349 #[serde(default = "one")]
351 pub leader_scale: f32,
352}
353
354#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
356#[serde(rename_all = "snake_case")]
357#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
358#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
359#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
360#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
361pub struct AnnotationFeatureTag {
362 pub entity_id: Uuid,
364
365 pub entity_pos: Point2d<f64>,
367
368 pub leader_type: AnnotationLineEnd,
370
371 pub key: String,
373
374 pub value: String,
376
377 pub show_key: bool,
379
380 pub plane_id: Uuid,
382
383 pub offset: Point2d<f64>,
385
386 pub font_scale: f32,
388
389 pub font_point_size: u32,
391
392 #[serde(default = "one")]
394 pub leader_scale: f32,
395}
396
397#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
401#[serde(rename_all = "snake_case", tag = "type")]
402#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
403#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
404#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
405#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
406pub enum DistanceType {
407 Euclidean {},
409 OnAxis {
411 axis: GlobalAxis,
413 },
414}
415
416#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
418#[serde(rename_all = "snake_case", tag = "type")]
419#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
420#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
421#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
422#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
423pub enum OriginType {
424 #[default]
426 Local,
427 Global,
429 Custom {
431 origin: Point3d<f64>,
433 },
434}
435
436#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
438#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
439#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
440#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
441#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
442pub struct Color {
443 pub r: f32,
445 pub g: f32,
447 pub b: f32,
449 pub a: f32,
451}
452
453impl Color {
454 pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
456 Self { r, g, b, a }
457 }
458}
459
460#[allow(missing_docs)]
462#[derive(
463 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
464)]
465#[serde(rename_all = "lowercase")]
466#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
467#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
468#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
469#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
470pub enum AnnotationTextAlignmentX {
471 Left,
472 Center,
473 Right,
474}
475
476#[allow(missing_docs)]
478#[derive(
479 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
480)]
481#[serde(rename_all = "lowercase")]
482#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
483#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
484#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
485#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
486pub enum AnnotationTextAlignmentY {
487 Bottom,
488 Center,
489 Top,
490}
491
492#[allow(missing_docs)]
494#[derive(
495 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
496)]
497#[serde(rename_all = "lowercase")]
498#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
499#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
500#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
501#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
502pub enum AnnotationLineEnd {
503 None,
504 Arrow,
505 Dot,
506}
507
508#[derive(
510 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
511)]
512#[serde(rename_all = "lowercase")]
513#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
514#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
515#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
516#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
517pub enum AnnotationType {
518 T2D,
520 T3D,
522}
523
524#[derive(
526 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
527)]
528#[serde(rename_all = "lowercase")]
529#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
530#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
531#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
532#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
533pub enum MbdStandard {
534 AsmeY14_5,
536}
537
538#[allow(missing_docs)]
541#[derive(
542 Default,
543 Display,
544 FromStr,
545 Copy,
546 Eq,
547 PartialEq,
548 Debug,
549 JsonSchema,
550 Deserialize,
551 Serialize,
552 Sequence,
553 Clone,
554 Ord,
555 PartialOrd,
556)]
557#[serde(rename_all = "lowercase")]
558#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
559#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
560#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
561#[repr(u16)]
562#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
563pub enum MbdSymbol {
564 #[default]
565 None = 0,
566 ArcLength = 174,
567 Between = 175,
568 Degrees = 176,
569 PlusMinus = 177,
570 Angularity = 178,
571 Cylindricity = 179,
572 Roundness = 180,
573 Concentricity = 181,
574 Straightness = 182,
575 Parallelism = 183,
576 Flatness = 184,
577 ProfileOfLine = 185,
578 SurfaceProfile = 186,
579 Symmetry = 187,
580 Perpendicularity = 188,
581 Runout = 189,
582 TotalRunout = 190,
583 Position = 191,
584 CenterLine = 192,
585 PartingLine = 193,
586 IsoEnvelope = 195,
587 IsoEnvelopeNonY145M = 196,
588 FreeState = 197,
589 StatisticalTolerance = 198,
590 ContinuousFeature = 199,
591 Independency = 200,
592 Depth = 201,
593 Start = 202,
594 LeastCondition = 203,
595 MaxCondition = 204,
596 ConicalTaper = 205,
597 Projected = 206,
598 Slope = 207,
599 Micro = 208,
600 TangentPlane = 210,
601 Unilateral = 211,
602 SquareFeature = 212,
603 Countersink = 213,
604 SpotFace = 214,
605 Target = 215,
606 Diameter = 216,
607 Radius = 217,
608 SphericalRadius = 218,
609 SphericalDiameter = 219,
610 ControlledRadius = 220,
611 BoxStart = 123,
612 BoxBar = 162,
613 BoxBarBetween = 124,
614 LetterBackwardUnderline = 95,
615 PunctuationBackwardUnderline = 92,
616 ModifierBackwardUnderline = 126,
617 NumericBackwardUnderline = 96,
618 BoxEnd = 125,
619 DatumUp = 166,
620 DatumLeft = 168,
621 DatumRight = 167,
622 DatumDown = 165,
623 DatumTriangle = 295,
624 HalfSpace = 236,
625 QuarterSpace = 237,
626 EighthSpace = 238,
627 ModifierSpace = 239,
628}
629
630#[derive(
632 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
633)]
634#[serde(rename_all = "lowercase")]
635#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
636#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
637#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
638#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
639pub enum CameraDragInteractionType {
640 Pan,
642 Rotate,
644 RotateTrackball,
646 Zoom,
648}
649
650#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
653#[serde(rename_all = "snake_case", tag = "type")]
654#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
655#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
656#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
657#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
658pub enum PathSegment {
659 Line {
662 end: Point3d<LengthUnit>,
664 relative: bool,
666 },
667 Arc {
670 center: Point2d<LengthUnit>,
672 radius: LengthUnit,
674 start: Angle,
676 end: Angle,
678 relative: bool,
680 },
681 Bezier {
685 control1: Point3d<LengthUnit>,
687 control2: Point3d<LengthUnit>,
689 end: Point3d<LengthUnit>,
691 relative: bool,
693 },
694 TangentialArc {
696 radius: LengthUnit,
699 offset: Angle,
701 },
702 TangentialArcTo {
705 to: Point3d<LengthUnit>,
709 angle_snap_increment: Option<Angle>,
711 },
712 ArcTo {
714 interior: Point3d<LengthUnit>,
716 end: Point3d<LengthUnit>,
718 relative: bool,
720 },
721 CircularInvolute {
724 start_radius: LengthUnit,
727 end_radius: LengthUnit,
730 angle: Angle,
733 reverse: bool,
736 },
737 Ellipse {
739 center: Point2d<LengthUnit>,
741 major_axis: Point2d<LengthUnit>,
743 minor_radius: LengthUnit,
745 start_angle: Angle,
747 end_angle: Angle,
749 },
750 ConicTo {
753 interior: Point2d<LengthUnit>,
755 end: Point2d<LengthUnit>,
757 start_tangent: Point2d<LengthUnit>,
759 end_tangent: Point2d<LengthUnit>,
761 relative: bool,
763 },
764}
765
766#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
768#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
769#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
770#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
771#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
772pub struct Angle {
773 pub unit: UnitAngle,
775 pub value: f64,
777}
778
779impl Angle {
780 pub fn to_degrees(self) -> f64 {
782 match self.unit {
783 UnitAngle::Degrees => self.value,
784 UnitAngle::Radians => self.value.to_degrees(),
785 }
786 }
787 pub fn to_radians(self) -> f64 {
789 match self.unit {
790 UnitAngle::Degrees => self.value.to_radians(),
791 UnitAngle::Radians => self.value,
792 }
793 }
794 pub const fn from_degrees(value: f64) -> Self {
796 Self {
797 unit: UnitAngle::Degrees,
798 value,
799 }
800 }
801 pub const fn from_radians(value: f64) -> Self {
803 Self {
804 unit: UnitAngle::Radians,
805 value,
806 }
807 }
808 pub const fn turn() -> Self {
810 Self::from_degrees(360.0)
811 }
812 pub const fn half_circle() -> Self {
814 Self::from_degrees(180.0)
815 }
816 pub const fn quarter_circle() -> Self {
818 Self::from_degrees(90.0)
819 }
820 pub const fn zero() -> Self {
822 Self::from_degrees(0.0)
823 }
824}
825
826impl Default for Angle {
828 fn default() -> Self {
830 Self::zero()
831 }
832}
833
834impl PartialOrd for Angle {
835 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
836 match (self.unit, other.unit) {
837 (UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
839 (UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
840 _ => self.to_degrees().partial_cmp(&other.to_degrees()),
841 }
842 }
843}
844
845impl std::ops::Add for Angle {
846 type Output = Self;
847
848 fn add(self, rhs: Self) -> Self::Output {
849 Self {
850 unit: UnitAngle::Degrees,
851 value: self.to_degrees() + rhs.to_degrees(),
852 }
853 }
854}
855
856impl std::ops::AddAssign for Angle {
857 fn add_assign(&mut self, rhs: Self) {
858 match self.unit {
859 UnitAngle::Degrees => {
860 self.value += rhs.to_degrees();
861 }
862 UnitAngle::Radians => {
863 self.value += rhs.to_radians();
864 }
865 }
866 }
867}
868
869#[derive(
871 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
872)]
873#[serde(rename_all = "lowercase")]
874#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
875#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
876#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
877#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
878pub enum SceneSelectionType {
879 Replace,
881 Add,
883 Remove,
885}
886
887#[allow(missing_docs)]
889#[derive(
890 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
891)]
892#[serde(rename_all = "snake_case")]
893#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
894#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
895#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
896#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
897pub enum SceneToolType {
898 CameraRevolve,
899 Select,
900 Move,
901 SketchLine,
902 SketchTangentialArc,
903 SketchCurve,
904 SketchCurveMod,
905}
906
907#[allow(missing_docs)]
909#[derive(
910 Display,
911 FromStr,
912 Copy,
913 Eq,
914 PartialEq,
915 Debug,
916 JsonSchema,
917 Deserialize,
918 Serialize,
919 Sequence,
920 Clone,
921 Ord,
922 PartialOrd,
923 Default,
924)]
925#[serde(rename_all = "snake_case")]
926#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
927#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
928#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
929#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
930pub enum PathComponentConstraintBound {
931 #[default]
932 Unconstrained,
933 PartiallyConstrained,
934 FullyConstrained,
935}
936
937#[allow(missing_docs)]
939#[derive(
940 Display,
941 FromStr,
942 Copy,
943 Eq,
944 PartialEq,
945 Debug,
946 JsonSchema,
947 Deserialize,
948 Serialize,
949 Sequence,
950 Clone,
951 Ord,
952 PartialOrd,
953 Default,
954)]
955#[serde(rename_all = "snake_case")]
956#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
957#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
958#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
959#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
960pub enum PathComponentConstraintType {
961 #[default]
962 Unconstrained,
963 Vertical,
964 Horizontal,
965 EqualLength,
966 Parallel,
967 AngleBetween,
968}
969
970#[allow(missing_docs)]
972#[derive(
973 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
974)]
975#[serde(rename_all = "snake_case")]
976#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
977#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
978#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
979#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
980pub enum PathCommand {
981 MoveTo,
982 LineTo,
983 BezCurveTo,
984 NurbsCurveTo,
985 AddArc,
986}
987
988#[allow(missing_docs)]
990#[derive(
991 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
992)]
993#[serde(rename_all = "lowercase")]
994#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
995#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
996#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
997#[repr(u8)]
998#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
999pub enum EntityType {
1000 Entity,
1001 Object,
1002 Path,
1003 Curve,
1004 Solid2D,
1005 Solid3D,
1006 Edge,
1007 Face,
1008 Plane,
1009 Vertex,
1010}
1011
1012#[allow(missing_docs)]
1014#[derive(
1015 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1016)]
1017#[serde(rename_all = "snake_case")]
1018#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1019#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1020#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1021#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1022pub enum CurveType {
1023 Line,
1024 Arc,
1025 Nurbs,
1026}
1027
1028#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1030#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
1031#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1032pub struct ExportFile {
1033 pub name: String,
1035 pub contents: crate::base64::Base64Data,
1037}
1038
1039#[cfg(feature = "python")]
1040#[pyo3_stub_gen::derive::gen_stub_pymethods]
1041#[pyo3::pymethods]
1042impl ExportFile {
1043 #[getter]
1044 fn contents(&self) -> Vec<u8> {
1045 self.contents.0.clone()
1046 }
1047
1048 #[getter]
1049 fn name(&self) -> String {
1050 self.name.clone()
1051 }
1052}
1053
1054#[derive(
1056 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1057)]
1058#[serde(rename_all = "lowercase")]
1059#[display(style = "lowercase")]
1060#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1061#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1062#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1063#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
1064#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1065pub enum FileExportFormat {
1066 Fbx,
1068 Glb,
1075 Gltf,
1086 Obj,
1090 Ply,
1092 Step,
1094 Stl,
1096}
1097
1098#[derive(
1100 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1101)]
1102#[serde(rename_all = "lowercase")]
1103#[display(style = "lowercase")]
1104#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1105#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1106#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1107#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1108pub enum FileExportFormat2d {
1109 Dxf,
1111}
1112
1113#[derive(
1115 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1116)]
1117#[serde(rename_all = "lowercase")]
1118#[display(style = "lowercase")]
1119#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1120#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1121#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1122#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1123pub enum FileImportFormat {
1124 Fbx,
1126 Gltf,
1128 Obj,
1132 Ply,
1134 Sldprt,
1136 Step,
1138 Stl,
1140}
1141
1142#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
1144#[serde(rename_all = "snake_case")]
1145#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1146#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1147#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1148#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1149pub enum EngineErrorCode {
1150 BadRequest = 1,
1154 InternalEngine,
1156}
1157
1158impl From<EngineErrorCode> for http::StatusCode {
1159 fn from(e: EngineErrorCode) -> Self {
1160 match e {
1161 EngineErrorCode::BadRequest => Self::BAD_REQUEST,
1162 EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
1163 }
1164 }
1165}
1166
1167#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1169#[serde(rename_all = "snake_case")]
1170#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1171#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1172#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1173pub enum BlendType {
1174 #[default]
1176 Tangent,
1177}
1178
1179#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1181#[serde(rename_all = "snake_case")]
1182#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1183#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1184#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1185#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1186pub enum BodyType {
1187 #[default]
1189 Solid,
1190 Surface,
1192}
1193
1194#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1197#[serde(rename_all = "snake_case")]
1198#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1199#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1200#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1201#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1202pub enum ExtrudeMethod {
1203 New,
1206 #[default]
1209 Merge,
1210}
1211
1212#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1214#[serde(rename_all = "snake_case")]
1215#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1216#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1217#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1218#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1219pub enum ExtrudeReference {
1220 EntityReference {
1223 entity_id: Uuid,
1225 },
1226 Axis {
1228 axis: Point3d<f64>,
1230 #[serde(default)]
1233 point: Point3d<LengthUnit>,
1234 },
1235 Point {
1237 point: Point3d<LengthUnit>,
1239 },
1240}
1241
1242#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1244#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1245#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1246#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1247#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1248pub struct ExtrudedFaceInfo {
1249 pub bottom: Option<Uuid>,
1254 pub top: Uuid,
1256 pub sides: Vec<SideFace>,
1258}
1259
1260#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1262#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1263#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1264#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1265#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1266pub struct SideFace {
1267 pub path_id: Uuid,
1269 pub face_id: Uuid,
1271}
1272
1273#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1275#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1276#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1277#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1278#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1279pub struct CameraSettings {
1280 pub pos: Point3d,
1282
1283 pub center: Point3d,
1285
1286 pub up: Point3d,
1288
1289 pub orientation: Quaternion,
1291
1292 pub fov_y: Option<f32>,
1294
1295 pub ortho_scale: Option<f32>,
1297
1298 pub ortho: bool,
1300}
1301
1302#[allow(missing_docs)]
1303#[repr(u8)]
1304#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1305#[serde(rename_all = "snake_case")]
1306#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1307#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1308#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1309#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1310pub enum WorldCoordinateSystem {
1311 #[default]
1312 RightHandedUpZ,
1313 RightHandedUpY,
1314}
1315
1316#[allow(missing_docs)]
1317#[repr(C)]
1318#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1319#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1320#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1321#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1322#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1323pub struct CameraViewState {
1324 pub pivot_rotation: Quaternion,
1325 pub pivot_position: Point3d,
1326 pub eye_offset: f32,
1327 pub fov_y: f32,
1328 pub ortho_scale_factor: f32,
1329 pub is_ortho: bool,
1330 pub ortho_scale_enabled: bool,
1331 pub world_coord_system: WorldCoordinateSystem,
1332}
1333
1334impl Default for CameraViewState {
1335 fn default() -> Self {
1336 CameraViewState {
1337 pivot_rotation: Default::default(),
1338 pivot_position: Default::default(),
1339 eye_offset: 10.0,
1340 fov_y: 45.0,
1341 ortho_scale_factor: 1.6,
1342 is_ortho: false,
1343 ortho_scale_enabled: true,
1344 world_coord_system: Default::default(),
1345 }
1346 }
1347}
1348
1349#[cfg(feature = "cxx")]
1350impl_extern_type! {
1351 [Trivial]
1352 CameraViewState = "Endpoints::CameraViewState"
1353}
1354
1355impl From<CameraSettings> for crate::output::DefaultCameraZoom {
1356 fn from(settings: CameraSettings) -> Self {
1357 Self { settings }
1358 }
1359}
1360impl From<CameraSettings> for crate::output::CameraDragMove {
1361 fn from(settings: CameraSettings) -> Self {
1362 Self { settings }
1363 }
1364}
1365impl From<CameraSettings> for crate::output::CameraDragEnd {
1366 fn from(settings: CameraSettings) -> Self {
1367 Self { settings }
1368 }
1369}
1370impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
1371 fn from(settings: CameraSettings) -> Self {
1372 Self { settings }
1373 }
1374}
1375impl From<CameraSettings> for crate::output::ZoomToFit {
1376 fn from(settings: CameraSettings) -> Self {
1377 Self { settings }
1378 }
1379}
1380impl From<CameraSettings> for crate::output::OrientToFace {
1381 fn from(settings: CameraSettings) -> Self {
1382 Self { settings }
1383 }
1384}
1385impl From<CameraSettings> for crate::output::ViewIsometric {
1386 fn from(settings: CameraSettings) -> Self {
1387 Self { settings }
1388 }
1389}
1390
1391#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default, Builder)]
1393#[serde(rename_all = "snake_case")]
1394#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1395#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1396#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1397#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1398pub struct PerspectiveCameraParameters {
1399 pub fov_y: Option<f32>,
1401 pub z_near: Option<f32>,
1403 pub z_far: Option<f32>,
1405}
1406
1407#[derive(
1409 Default,
1410 Display,
1411 FromStr,
1412 Copy,
1413 Eq,
1414 PartialEq,
1415 Debug,
1416 JsonSchema,
1417 Deserialize,
1418 Serialize,
1419 Sequence,
1420 Clone,
1421 Ord,
1422 PartialOrd,
1423)]
1424#[serde(rename_all = "snake_case")]
1425#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1426#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1427#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1428#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1429pub enum CameraMovement {
1430 #[default]
1432 Vantage,
1433 None,
1435}
1436
1437#[derive(
1439 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1440)]
1441#[serde(rename_all = "lowercase")]
1442#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1443#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1444#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1445#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1446pub enum GlobalAxis {
1447 X,
1449 Y,
1451 Z,
1453}
1454
1455#[derive(
1457 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1458)]
1459#[serde(rename_all = "snake_case")]
1460#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1461#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1462#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1463#[repr(u8)]
1464#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1465pub enum ExtrusionFaceCapType {
1466 None,
1468 Top,
1470 Bottom,
1472 Both,
1474}
1475
1476#[allow(missing_docs)]
1478#[derive(
1479 Display,
1480 FromStr,
1481 Copy,
1482 Eq,
1483 PartialEq,
1484 Debug,
1485 JsonSchema,
1486 Deserialize,
1487 Serialize,
1488 Sequence,
1489 Clone,
1490 Ord,
1491 PartialOrd,
1492 Default,
1493)]
1494#[serde(rename_all = "lowercase")]
1495#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1496#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1497#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1498#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1499pub enum PostEffectType {
1500 Phosphor,
1501 Ssao,
1502 #[default]
1503 NoEffect,
1504}
1505
1506#[cfg(feature = "cxx")]
1509impl_extern_type! {
1510 [Trivial]
1511 FileImportFormat = "Enums::_FileImportFormat"
1513 FileExportFormat = "Enums::_FileExportFormat"
1514 CameraDragInteractionType = "Enums::_CameraDragInteractionType"
1516 SceneSelectionType = "Enums::_SceneSelectionType"
1518 SceneToolType = "Enums::_SceneToolType"
1519 BlendType = "Enums::_BlendType"
1520 BodyType = "Enums::_BodyType"
1521 EntityType = "Enums::_EntityType"
1522 AnnotationType = "Enums::_AnnotationType"
1523 AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
1524 AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
1525 AnnotationLineEnd = "Enums::_AnnotationLineEnd"
1526 MbdStandard = "Enums::_MBDStandard"
1527 MbdSymbol = "Enums::_MBDSymbol"
1528
1529 CurveType = "Enums::_CurveType"
1530 PathCommand = "Enums::_PathCommand"
1531 PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
1532 PathComponentConstraintType = "Enums::_PathComponentConstraintType"
1533 ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
1534
1535 EngineErrorCode = "Enums::_ErrorCode"
1537 GlobalAxis = "Enums::_GlobalAxis"
1538 OriginType = "Enums::_OriginType"
1539
1540 PostEffectType = "Enums::_PostEffectType"
1542}
1543
1544fn bool_true() -> bool {
1545 true
1546}
1547fn same_scale() -> Point3d<f64> {
1548 Point3d::uniform(1.0)
1549}
1550
1551fn z_axis() -> Point3d<f64> {
1552 Point3d { x: 0.0, y: 0.0, z: 1.0 }
1553}
1554
1555impl ExtrudedFaceInfo {
1556 pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
1559 let mut face_infos: Vec<_> = self
1560 .sides
1561 .into_iter()
1562 .map(|side| ExtrusionFaceInfo {
1563 curve_id: Some(side.path_id),
1564 face_id: Some(side.face_id),
1565 cap: ExtrusionFaceCapType::None,
1566 })
1567 .collect();
1568 face_infos.push(ExtrusionFaceInfo {
1569 curve_id: None,
1570 face_id: Some(self.top),
1571 cap: ExtrusionFaceCapType::Top,
1572 });
1573 if let Some(bottom) = self.bottom {
1574 face_infos.push(ExtrusionFaceInfo {
1575 curve_id: None,
1576 face_id: Some(bottom),
1577 cap: ExtrusionFaceCapType::Bottom,
1578 });
1579 }
1580 face_infos
1581 }
1582}
1583
1584#[cfg(test)]
1585mod tests {
1586 use super::*;
1587
1588 #[test]
1589 fn test_angle_comparison() {
1590 let a = Angle::from_degrees(90.0);
1591 assert!(a < Angle::from_degrees(91.0));
1592 assert!(a > Angle::from_degrees(89.0));
1593 assert!(a <= Angle::from_degrees(90.0));
1594 assert!(a >= Angle::from_degrees(90.0));
1595 let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
1596 assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
1597 assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
1598 assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1599 assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1600 assert!(a > b);
1602 assert!(a >= b);
1603 assert!(b < a);
1604 assert!(b <= a);
1605 let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
1606 assert!(a < c);
1607 assert!(a <= c);
1608 assert!(c > a);
1609 assert!(c >= a);
1610 }
1611}
1612
1613#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, JsonSchema, Builder)]
1615#[schemars(rename = "TransformByFor{T}")]
1616#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1617#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1618#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1619#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1620pub struct TransformBy<T> {
1621 pub property: T,
1623 pub set: bool,
1628 #[serde(default)]
1630 #[builder(default)]
1631 pub origin: OriginType,
1632}
1633
1634impl<T> TransformBy<T> {
1635 pub fn get_origin(&self) -> OriginType {
1639 self.origin
1640 }
1641}
1642
1643#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, Default, Builder)]
1646#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1647#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1648#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1649#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1650pub struct ComponentTransform {
1651 pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
1653 pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
1656 pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
1660 pub scale: Option<TransformBy<Point3d<f64>>>,
1662}
1663
1664#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
1667#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1668#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1669#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1670#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1671pub enum Opposite<T> {
1672 #[default]
1674 None,
1675 Symmetric,
1677 Other(T),
1679}
1680
1681impl<T: JsonSchema> JsonSchema for Opposite<T> {
1682 fn schema_name() -> String {
1683 format!("OppositeFor{}", T::schema_name())
1684 }
1685
1686 fn schema_id() -> std::borrow::Cow<'static, str> {
1687 std::borrow::Cow::Owned(format!("{}::Opposite<{}>", module_path!(), T::schema_id()))
1688 }
1689
1690 fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1691 SchemaObject {
1692 instance_type: Some(schemars::schema::InstanceType::String.into()),
1693 ..Default::default()
1694 }
1695 .into()
1696 }
1697}
1698
1699#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1702#[serde(rename_all = "snake_case")]
1703#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1704#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1705#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1706#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1707pub enum CutStrategy {
1708 Basic,
1711 Csg,
1714 #[default]
1716 Automatic,
1717}
1718
1719#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1721#[serde(rename_all = "snake_case")]
1722#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1723#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1724#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1725#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1726pub enum RelativeTo {
1727 #[default]
1729 SketchPlane,
1730 TrajectoryCurve,
1732}
1733
1734#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1736#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1737#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1738#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1739pub struct SelectedRegion {
1740 pub segment: Uuid,
1742 pub intersection_segment: Uuid,
1745 #[serde(default = "negative_one")]
1749 pub intersection_index: i32,
1750 #[serde(default)]
1753 pub curve_clockwise: bool,
1754}
1755
1756impl Default for SelectedRegion {
1757 fn default() -> Self {
1758 Self {
1759 segment: Default::default(),
1760 intersection_segment: Default::default(),
1761 intersection_index: -1,
1762 curve_clockwise: Default::default(),
1763 }
1764 }
1765}
1766
1767#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1769#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1770#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1771#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1772#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1773pub struct FractionOfEdge {
1774 pub edge_id: Uuid,
1776 #[serde(default)]
1780 #[builder(default)]
1781 #[schemars(range(min = 0, max = 1))]
1782 pub lower_bound: f32,
1783 #[serde(default = "one")]
1787 #[builder(default = one())]
1788 #[schemars(range(min = 0, max = 1))]
1789 pub upper_bound: f32,
1790}
1791
1792#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1794#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1795#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1796#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1797#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1798pub struct SurfaceEdgeReference {
1799 pub object_id: Uuid,
1801 pub edges: Vec<FractionOfEdge>,
1803}
1804
1805#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1807#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1808#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1809#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1810#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1811pub struct BodiesCreated {
1812 pub bodies: Vec<BodyCreated>,
1814}
1815
1816impl BodiesCreated {
1817 pub fn is_empty(&self) -> bool {
1819 self.bodies.is_empty()
1820 }
1821}
1822
1823#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1825#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1826#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1827#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1828#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1829pub struct BodiesUpdated {
1830 pub bodies: Vec<BodyUpdated>,
1832}
1833
1834impl BodiesUpdated {
1835 pub fn is_empty(&self) -> bool {
1837 self.bodies.is_empty()
1838 }
1839}
1840
1841#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1843#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1844#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1845#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1846#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1847pub struct BodyCreated {
1848 pub id: Uuid,
1850 pub surfaces: Vec<SurfaceCreated>,
1852}
1853
1854#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1856#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1857#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1858#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1859#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1860pub struct BodyUpdated {
1861 pub id: Uuid,
1863 pub surfaces: Vec<SurfaceCreated>,
1865}
1866
1867#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1869#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1870#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1871#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1872#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1873pub struct SurfaceCreated {
1874 pub id: Uuid,
1876 pub primitive_face_index: u32,
1878 pub from_segments: Vec<Uuid>,
1880}
1881
1882#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1884#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1885#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1886#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1887#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1888pub enum RegionVersion {
1889 #[default]
1892 V0,
1893 V1,
1896}
1897
1898impl RegionVersion {
1899 pub fn is_zero(&self) -> bool {
1901 matches!(self, Self::V0)
1902 }
1903}
1904
1905impl From<BodyCreated> for BodyUpdated {
1906 fn from(body: BodyCreated) -> Self {
1907 Self {
1908 id: body.id,
1909 surfaces: body.surfaces,
1910 }
1911 }
1912}
1913
1914impl From<BodyUpdated> for BodyCreated {
1915 fn from(body: BodyUpdated) -> Self {
1916 Self {
1917 id: body.id,
1918 surfaces: body.surfaces,
1919 }
1920 }
1921}
1922
1923impl From<BodiesCreated> for BodiesUpdated {
1924 fn from(bodies: BodiesCreated) -> Self {
1925 Self {
1926 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
1927 }
1928 }
1929}
1930
1931impl From<BodiesUpdated> for BodiesCreated {
1932 fn from(bodies: BodiesUpdated) -> Self {
1933 Self {
1934 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
1935 }
1936 }
1937}
1938
1939fn one() -> f32 {
1940 1.0
1941}