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"))]
35#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
36pub enum CutTypeV2 {
37 Fillet {
39 radius: LengthUnit,
41 second_length: Option<LengthUnit>,
44 },
45 Chamfer {
47 distance: LengthUnit,
49 second_distance: Option<LengthUnit>,
51 angle: Option<Angle>,
53 swap: bool,
55 },
56 Custom {
58 path: Uuid,
60 },
61}
62
63#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
65#[serde(rename_all = "snake_case")]
66#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
67#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
68#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
69#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
70pub struct Rotation {
71 pub axis: Point3d<f64>,
74 pub angle: Angle,
77 pub origin: OriginType,
79}
80
81impl Default for Rotation {
82 fn default() -> Self {
84 Self {
85 axis: z_axis(),
86 angle: Angle::default(),
87 origin: OriginType::Local,
88 }
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 Transform {
100 #[serde(default)]
103 #[builder(default)]
104 pub translate: Point3d<LengthUnit>,
105 #[serde(default = "same_scale")]
108 #[builder(default = same_scale())]
109 pub scale: Point3d<f64>,
110 #[serde(default)]
113 #[builder(default)]
114 pub rotation: Rotation,
115 #[serde(default = "bool_true")]
117 #[builder(default = bool_true())]
118 pub replicate: bool,
119}
120
121impl Default for Transform {
122 fn default() -> Self {
123 Self {
124 scale: same_scale(),
125 replicate: true,
126 translate: Default::default(),
127 rotation: Rotation::default(),
128 }
129 }
130}
131
132#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
134#[serde(rename_all = "snake_case")]
135#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
136#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
137#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
138#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
139pub struct AnnotationOptions {
140 pub text: Option<AnnotationTextOptions>,
142 pub line_ends: Option<AnnotationLineEndOptions>,
144 pub line_width: Option<f32>,
146 pub color: Option<Color>,
148 pub position: Option<Point3d<f32>>,
150 pub dimension: Option<AnnotationBasicDimension>,
152 pub feature_control: Option<AnnotationFeatureControl>,
154 pub feature_tag: Option<AnnotationFeatureTag>,
156}
157
158#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
160#[serde(rename_all = "snake_case")]
161#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
162#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
163#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
164#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
165pub struct AnnotationLineEndOptions {
166 pub start: AnnotationLineEnd,
168 pub end: AnnotationLineEnd,
170}
171
172#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
174#[serde(rename_all = "snake_case")]
175#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
176#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
177#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
178#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
179pub struct AnnotationTextOptions {
180 pub x: AnnotationTextAlignmentX,
182 pub y: AnnotationTextAlignmentY,
184 pub text: String,
186 pub point_size: u32,
188}
189
190#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
192#[serde(rename_all = "snake_case")]
193#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
194#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
195#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
196#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
197pub struct AnnotationMbdControlFrame {
198 pub symbol: MbdSymbol,
200 pub diameter_symbol: Option<MbdSymbol>,
202 pub tolerance: f64,
204 pub modifier: Option<MbdSymbol>,
206 pub primary_datum: Option<char>,
208 pub secondary_datum: Option<char>,
210 pub tertiary_datum: Option<char>,
212}
213
214#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
216#[serde(rename_all = "snake_case")]
217#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
218#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
219#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
220#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
221pub struct AnnotationMbdBasicDimension {
222 pub symbol: Option<MbdSymbol>,
224 pub dimension: Option<f64>,
226 pub tolerance: f64,
228}
229
230#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
232#[serde(rename_all = "snake_case")]
233#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
234#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
235#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
236#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
237pub struct AnnotationBasicDimension {
238 pub from_entity_id: Uuid,
240
241 pub from_entity_pos: Point2d<f64>,
243
244 pub to_entity_id: Uuid,
246
247 pub to_entity_pos: Point2d<f64>,
249
250 pub dimension: AnnotationMbdBasicDimension,
252
253 pub plane_id: Uuid,
255
256 pub offset: Point2d<f64>,
258
259 pub precision: u32,
261
262 pub font_scale: f32,
264
265 pub font_point_size: u32,
267
268 #[serde(default = "one")]
270 pub arrow_scale: f32,
271}
272
273#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
275#[serde(rename_all = "snake_case")]
276#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
277#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
278#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
279#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
280pub struct AnnotationFeatureControl {
281 pub entity_id: Uuid,
283
284 pub entity_pos: Point2d<f64>,
286
287 pub leader_type: AnnotationLineEnd,
289
290 pub dimension: Option<AnnotationMbdBasicDimension>,
292
293 pub control_frame: Option<AnnotationMbdControlFrame>,
295
296 pub defined_datum: Option<char>,
298
299 pub prefix: Option<String>,
301
302 pub suffix: Option<String>,
304
305 pub plane_id: Uuid,
307
308 pub offset: Point2d<f64>,
310
311 pub precision: u32,
313
314 pub font_scale: f32,
316
317 pub font_point_size: u32,
319
320 #[serde(default = "one")]
322 pub leader_scale: f32,
323}
324
325#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
327#[serde(rename_all = "snake_case")]
328#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
329#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
330#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
331#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
332pub struct AnnotationFeatureTag {
333 pub entity_id: Uuid,
335
336 pub entity_pos: Point2d<f64>,
338
339 pub leader_type: AnnotationLineEnd,
341
342 pub key: String,
344
345 pub value: String,
347
348 pub show_key: bool,
350
351 pub plane_id: Uuid,
353
354 pub offset: Point2d<f64>,
356
357 pub font_scale: f32,
359
360 pub font_point_size: u32,
362
363 #[serde(default = "one")]
365 pub leader_scale: f32,
366}
367
368#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
372#[serde(rename_all = "snake_case", tag = "type")]
373#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
374#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
375#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
376#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
377pub enum DistanceType {
378 Euclidean {},
380 OnAxis {
382 axis: GlobalAxis,
384 },
385}
386
387#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
389#[serde(rename_all = "snake_case", tag = "type")]
390#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
391#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
392#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
393#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
394pub enum OriginType {
395 #[default]
397 Local,
398 Global,
400 Custom {
402 origin: Point3d<f64>,
404 },
405}
406
407#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
409#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
410#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
411#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
412#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
413pub struct Color {
414 pub r: f32,
416 pub g: f32,
418 pub b: f32,
420 pub a: f32,
422}
423
424impl Color {
425 pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
427 Self { r, g, b, a }
428 }
429}
430
431#[allow(missing_docs)]
433#[derive(
434 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
435)]
436#[serde(rename_all = "lowercase")]
437#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
438#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
439#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
440#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
441pub enum AnnotationTextAlignmentX {
442 Left,
443 Center,
444 Right,
445}
446
447#[allow(missing_docs)]
449#[derive(
450 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
451)]
452#[serde(rename_all = "lowercase")]
453#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
454#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
455#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
456#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
457pub enum AnnotationTextAlignmentY {
458 Bottom,
459 Center,
460 Top,
461}
462
463#[allow(missing_docs)]
465#[derive(
466 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
467)]
468#[serde(rename_all = "lowercase")]
469#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
470#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
471#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
472#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
473pub enum AnnotationLineEnd {
474 None,
475 Arrow,
476 Dot,
477}
478
479#[derive(
481 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
482)]
483#[serde(rename_all = "lowercase")]
484#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
485#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
486#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
487#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
488pub enum AnnotationType {
489 T2D,
491 T3D,
493}
494
495#[derive(
497 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
498)]
499#[serde(rename_all = "lowercase")]
500#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
501#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
502#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
503#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
504pub enum MbdStandard {
505 AsmeY14_5,
507}
508
509#[allow(missing_docs)]
512#[derive(
513 Default,
514 Display,
515 FromStr,
516 Copy,
517 Eq,
518 PartialEq,
519 Debug,
520 JsonSchema,
521 Deserialize,
522 Serialize,
523 Sequence,
524 Clone,
525 Ord,
526 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#[repr(u16)]
533#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
534pub enum MbdSymbol {
535 #[default]
536 None = 0,
537 ArcLength = 174,
538 Between = 175,
539 Degrees = 176,
540 PlusMinus = 177,
541 Angularity = 178,
542 Cylindricity = 179,
543 Roundness = 180,
544 Concentricity = 181,
545 Straightness = 182,
546 Parallelism = 183,
547 Flatness = 184,
548 ProfileOfLine = 185,
549 SurfaceProfile = 186,
550 Symmetry = 187,
551 Perpendicularity = 188,
552 Runout = 189,
553 TotalRunout = 190,
554 Position = 191,
555 CenterLine = 192,
556 PartingLine = 193,
557 IsoEnvelope = 195,
558 IsoEnvelopeNonY145M = 196,
559 FreeState = 197,
560 StatisticalTolerance = 198,
561 ContinuousFeature = 199,
562 Independency = 200,
563 Depth = 201,
564 Start = 202,
565 LeastCondition = 203,
566 MaxCondition = 204,
567 ConicalTaper = 205,
568 Projected = 206,
569 Slope = 207,
570 Micro = 208,
571 TangentPlane = 210,
572 Unilateral = 211,
573 SquareFeature = 212,
574 Countersink = 213,
575 SpotFace = 214,
576 Target = 215,
577 Diameter = 216,
578 Radius = 217,
579 SphericalRadius = 218,
580 SphericalDiameter = 219,
581 ControlledRadius = 220,
582 BoxStart = 123,
583 BoxBar = 162,
584 BoxBarBetween = 124,
585 LetterBackwardUnderline = 95,
586 PunctuationBackwardUnderline = 92,
587 ModifierBackwardUnderline = 126,
588 NumericBackwardUnderline = 96,
589 BoxEnd = 125,
590 DatumUp = 166,
591 DatumLeft = 168,
592 DatumRight = 167,
593 DatumDown = 165,
594 DatumTriangle = 295,
595 HalfSpace = 236,
596 QuarterSpace = 237,
597 EighthSpace = 238,
598 ModifierSpace = 239,
599}
600
601#[derive(
603 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
604)]
605#[serde(rename_all = "lowercase")]
606#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
607#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
608#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
609#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
610pub enum CameraDragInteractionType {
611 Pan,
613 Rotate,
615 RotateTrackball,
617 Zoom,
619}
620
621#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
624#[serde(rename_all = "snake_case", tag = "type")]
625#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
626#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
627#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
628#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
629pub enum PathSegment {
630 Line {
633 end: Point3d<LengthUnit>,
635 relative: bool,
637 },
638 Arc {
641 center: Point2d<LengthUnit>,
643 radius: LengthUnit,
645 start: Angle,
647 end: Angle,
649 relative: bool,
651 },
652 Bezier {
656 control1: Point3d<LengthUnit>,
658 control2: Point3d<LengthUnit>,
660 end: Point3d<LengthUnit>,
662 relative: bool,
664 },
665 TangentialArc {
667 radius: LengthUnit,
670 offset: Angle,
672 },
673 TangentialArcTo {
676 to: Point3d<LengthUnit>,
680 angle_snap_increment: Option<Angle>,
682 },
683 ArcTo {
685 interior: Point3d<LengthUnit>,
687 end: Point3d<LengthUnit>,
689 relative: bool,
691 },
692 CircularInvolute {
695 start_radius: LengthUnit,
698 end_radius: LengthUnit,
701 angle: Angle,
704 reverse: bool,
707 },
708 Ellipse {
710 center: Point2d<LengthUnit>,
712 major_axis: Point2d<LengthUnit>,
714 minor_radius: LengthUnit,
716 start_angle: Angle,
718 end_angle: Angle,
720 },
721 ConicTo {
724 interior: Point2d<LengthUnit>,
726 end: Point2d<LengthUnit>,
728 start_tangent: Point2d<LengthUnit>,
730 end_tangent: Point2d<LengthUnit>,
732 relative: bool,
734 },
735}
736
737#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
739#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
740#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
741#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
742#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
743pub struct Angle {
744 pub unit: UnitAngle,
746 pub value: f64,
748}
749
750impl Angle {
751 pub fn to_degrees(self) -> f64 {
753 match self.unit {
754 UnitAngle::Degrees => self.value,
755 UnitAngle::Radians => self.value.to_degrees(),
756 }
757 }
758 pub fn to_radians(self) -> f64 {
760 match self.unit {
761 UnitAngle::Degrees => self.value.to_radians(),
762 UnitAngle::Radians => self.value,
763 }
764 }
765 pub const fn from_degrees(value: f64) -> Self {
767 Self {
768 unit: UnitAngle::Degrees,
769 value,
770 }
771 }
772 pub const fn from_radians(value: f64) -> Self {
774 Self {
775 unit: UnitAngle::Radians,
776 value,
777 }
778 }
779 pub const fn turn() -> Self {
781 Self::from_degrees(360.0)
782 }
783 pub const fn half_circle() -> Self {
785 Self::from_degrees(180.0)
786 }
787 pub const fn quarter_circle() -> Self {
789 Self::from_degrees(90.0)
790 }
791 pub const fn zero() -> Self {
793 Self::from_degrees(0.0)
794 }
795}
796
797impl Default for Angle {
799 fn default() -> Self {
801 Self::zero()
802 }
803}
804
805impl PartialOrd for Angle {
806 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
807 match (self.unit, other.unit) {
808 (UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
810 (UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
811 _ => self.to_degrees().partial_cmp(&other.to_degrees()),
812 }
813 }
814}
815
816impl std::ops::Add for Angle {
817 type Output = Self;
818
819 fn add(self, rhs: Self) -> Self::Output {
820 Self {
821 unit: UnitAngle::Degrees,
822 value: self.to_degrees() + rhs.to_degrees(),
823 }
824 }
825}
826
827impl std::ops::AddAssign for Angle {
828 fn add_assign(&mut self, rhs: Self) {
829 match self.unit {
830 UnitAngle::Degrees => {
831 self.value += rhs.to_degrees();
832 }
833 UnitAngle::Radians => {
834 self.value += rhs.to_radians();
835 }
836 }
837 }
838}
839
840#[derive(
842 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
843)]
844#[serde(rename_all = "lowercase")]
845#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
846#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
847#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
848#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
849pub enum SceneSelectionType {
850 Replace,
852 Add,
854 Remove,
856}
857
858#[allow(missing_docs)]
860#[derive(
861 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
862)]
863#[serde(rename_all = "snake_case")]
864#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
865#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
866#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
867#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
868pub enum SceneToolType {
869 CameraRevolve,
870 Select,
871 Move,
872 SketchLine,
873 SketchTangentialArc,
874 SketchCurve,
875 SketchCurveMod,
876}
877
878#[allow(missing_docs)]
880#[derive(
881 Display,
882 FromStr,
883 Copy,
884 Eq,
885 PartialEq,
886 Debug,
887 JsonSchema,
888 Deserialize,
889 Serialize,
890 Sequence,
891 Clone,
892 Ord,
893 PartialOrd,
894 Default,
895)]
896#[serde(rename_all = "snake_case")]
897#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
898#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
899#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
900#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
901pub enum PathComponentConstraintBound {
902 #[default]
903 Unconstrained,
904 PartiallyConstrained,
905 FullyConstrained,
906}
907
908#[allow(missing_docs)]
910#[derive(
911 Display,
912 FromStr,
913 Copy,
914 Eq,
915 PartialEq,
916 Debug,
917 JsonSchema,
918 Deserialize,
919 Serialize,
920 Sequence,
921 Clone,
922 Ord,
923 PartialOrd,
924 Default,
925)]
926#[serde(rename_all = "snake_case")]
927#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
928#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
929#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
930#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
931pub enum PathComponentConstraintType {
932 #[default]
933 Unconstrained,
934 Vertical,
935 Horizontal,
936 EqualLength,
937 Parallel,
938 AngleBetween,
939}
940
941#[allow(missing_docs)]
943#[derive(
944 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
945)]
946#[serde(rename_all = "snake_case")]
947#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
948#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
949#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
950#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
951pub enum PathCommand {
952 MoveTo,
953 LineTo,
954 BezCurveTo,
955 NurbsCurveTo,
956 AddArc,
957}
958
959#[allow(missing_docs)]
961#[derive(
962 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
963)]
964#[serde(rename_all = "lowercase")]
965#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
966#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
967#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
968#[repr(u8)]
969#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
970pub enum EntityType {
971 Entity,
972 Object,
973 Path,
974 Curve,
975 Solid2D,
976 Solid3D,
977 Edge,
978 Face,
979 Plane,
980 Vertex,
981}
982
983#[allow(missing_docs)]
985#[derive(
986 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
987)]
988#[serde(rename_all = "snake_case")]
989#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
990#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
991#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
992#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
993pub enum CurveType {
994 Line,
995 Arc,
996 Nurbs,
997}
998
999#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1001#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
1002#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1003pub struct ExportFile {
1004 pub name: String,
1006 pub contents: crate::base64::Base64Data,
1008}
1009
1010#[cfg(feature = "python")]
1011#[pyo3_stub_gen::derive::gen_stub_pymethods]
1012#[pyo3::pymethods]
1013impl ExportFile {
1014 #[getter]
1015 fn contents(&self) -> Vec<u8> {
1016 self.contents.0.clone()
1017 }
1018
1019 #[getter]
1020 fn name(&self) -> String {
1021 self.name.clone()
1022 }
1023}
1024
1025#[derive(
1027 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1028)]
1029#[serde(rename_all = "lowercase")]
1030#[display(style = "lowercase")]
1031#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1032#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1033#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1034#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
1035#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1036pub enum FileExportFormat {
1037 Fbx,
1039 Glb,
1046 Gltf,
1057 Obj,
1061 Ply,
1063 Step,
1065 Stl,
1067}
1068
1069#[derive(
1071 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1072)]
1073#[serde(rename_all = "lowercase")]
1074#[display(style = "lowercase")]
1075#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1076#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1077#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1078#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1079pub enum FileExportFormat2d {
1080 Dxf,
1082}
1083
1084#[derive(
1086 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1087)]
1088#[serde(rename_all = "lowercase")]
1089#[display(style = "lowercase")]
1090#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1091#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1092#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1093#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1094pub enum FileImportFormat {
1095 Fbx,
1097 Gltf,
1099 Obj,
1103 Ply,
1105 Sldprt,
1107 Step,
1109 Stl,
1111}
1112
1113#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
1115#[serde(rename_all = "snake_case")]
1116#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1117#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1118#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1119#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1120pub enum EngineErrorCode {
1121 BadRequest = 1,
1125 InternalEngine,
1127}
1128
1129impl From<EngineErrorCode> for http::StatusCode {
1130 fn from(e: EngineErrorCode) -> Self {
1131 match e {
1132 EngineErrorCode::BadRequest => Self::BAD_REQUEST,
1133 EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
1134 }
1135 }
1136}
1137
1138#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1140#[serde(rename_all = "snake_case")]
1141#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1142#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1143#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1144pub enum BlendType {
1145 #[default]
1147 Tangent,
1148}
1149
1150#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1152#[serde(rename_all = "snake_case")]
1153#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1154#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1155#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1156#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1157pub enum BodyType {
1158 #[default]
1160 Solid,
1161 Surface,
1163}
1164
1165#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1168#[serde(rename_all = "snake_case")]
1169#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1170#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1171#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1172#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1173pub enum ExtrudeMethod {
1174 New,
1177 #[default]
1180 Merge,
1181}
1182
1183#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1185#[serde(rename_all = "snake_case")]
1186#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1187#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1188#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1189#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1190pub enum ExtrudeReference {
1191 EntityReference {
1194 entity_id: Uuid,
1196 },
1197 Axis {
1199 axis: Point3d<f64>,
1201 #[serde(default)]
1204 point: Point3d<LengthUnit>,
1205 },
1206 Point {
1208 point: Point3d<LengthUnit>,
1210 },
1211}
1212
1213#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
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 struct ExtrudedFaceInfo {
1220 pub bottom: Option<Uuid>,
1225 pub top: Uuid,
1227 pub sides: Vec<SideFace>,
1229}
1230
1231#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1233#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1234#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1235#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1236#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1237pub struct SideFace {
1238 pub path_id: Uuid,
1240 pub face_id: Uuid,
1242}
1243
1244#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1246#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1247#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1248#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1249#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1250pub struct CameraSettings {
1251 pub pos: Point3d,
1253
1254 pub center: Point3d,
1256
1257 pub up: Point3d,
1259
1260 pub orientation: Quaternion,
1262
1263 pub fov_y: Option<f32>,
1265
1266 pub ortho_scale: Option<f32>,
1268
1269 pub ortho: bool,
1271}
1272
1273#[allow(missing_docs)]
1274#[repr(u8)]
1275#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1276#[serde(rename_all = "snake_case")]
1277#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1278#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1279#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1280#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1281pub enum WorldCoordinateSystem {
1282 #[default]
1283 RightHandedUpZ,
1284 RightHandedUpY,
1285}
1286
1287#[allow(missing_docs)]
1288#[repr(C)]
1289#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1290#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1291#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1292#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1293#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1294pub struct CameraViewState {
1295 pub pivot_rotation: Quaternion,
1296 pub pivot_position: Point3d,
1297 pub eye_offset: f32,
1298 pub fov_y: f32,
1299 pub ortho_scale_factor: f32,
1300 pub is_ortho: bool,
1301 pub ortho_scale_enabled: bool,
1302 pub world_coord_system: WorldCoordinateSystem,
1303}
1304
1305impl Default for CameraViewState {
1306 fn default() -> Self {
1307 CameraViewState {
1308 pivot_rotation: Default::default(),
1309 pivot_position: Default::default(),
1310 eye_offset: 10.0,
1311 fov_y: 45.0,
1312 ortho_scale_factor: 1.6,
1313 is_ortho: false,
1314 ortho_scale_enabled: true,
1315 world_coord_system: Default::default(),
1316 }
1317 }
1318}
1319
1320#[cfg(feature = "cxx")]
1321impl_extern_type! {
1322 [Trivial]
1323 CameraViewState = "Endpoints::CameraViewState"
1324}
1325
1326impl From<CameraSettings> for crate::output::DefaultCameraZoom {
1327 fn from(settings: CameraSettings) -> Self {
1328 Self { settings }
1329 }
1330}
1331impl From<CameraSettings> for crate::output::CameraDragMove {
1332 fn from(settings: CameraSettings) -> Self {
1333 Self { settings }
1334 }
1335}
1336impl From<CameraSettings> for crate::output::CameraDragEnd {
1337 fn from(settings: CameraSettings) -> Self {
1338 Self { settings }
1339 }
1340}
1341impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
1342 fn from(settings: CameraSettings) -> Self {
1343 Self { settings }
1344 }
1345}
1346impl From<CameraSettings> for crate::output::ZoomToFit {
1347 fn from(settings: CameraSettings) -> Self {
1348 Self { settings }
1349 }
1350}
1351impl From<CameraSettings> for crate::output::OrientToFace {
1352 fn from(settings: CameraSettings) -> Self {
1353 Self { settings }
1354 }
1355}
1356impl From<CameraSettings> for crate::output::ViewIsometric {
1357 fn from(settings: CameraSettings) -> Self {
1358 Self { settings }
1359 }
1360}
1361
1362#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default, Builder)]
1364#[serde(rename_all = "snake_case")]
1365#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1366#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1367#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1368#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1369pub struct PerspectiveCameraParameters {
1370 pub fov_y: Option<f32>,
1372 pub z_near: Option<f32>,
1374 pub z_far: Option<f32>,
1376}
1377
1378#[derive(
1380 Default,
1381 Display,
1382 FromStr,
1383 Copy,
1384 Eq,
1385 PartialEq,
1386 Debug,
1387 JsonSchema,
1388 Deserialize,
1389 Serialize,
1390 Sequence,
1391 Clone,
1392 Ord,
1393 PartialOrd,
1394)]
1395#[serde(rename_all = "snake_case")]
1396#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1397#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1398#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1399#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1400pub enum CameraMovement {
1401 #[default]
1403 Vantage,
1404 None,
1406}
1407
1408#[derive(
1410 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1411)]
1412#[serde(rename_all = "lowercase")]
1413#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1414#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1415#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1416#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1417pub enum GlobalAxis {
1418 X,
1420 Y,
1422 Z,
1424}
1425
1426#[derive(
1428 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1429)]
1430#[serde(rename_all = "snake_case")]
1431#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1432#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1433#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1434#[repr(u8)]
1435#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1436pub enum ExtrusionFaceCapType {
1437 None,
1439 Top,
1441 Bottom,
1443 Both,
1445}
1446
1447#[allow(missing_docs)]
1449#[derive(
1450 Display,
1451 FromStr,
1452 Copy,
1453 Eq,
1454 PartialEq,
1455 Debug,
1456 JsonSchema,
1457 Deserialize,
1458 Serialize,
1459 Sequence,
1460 Clone,
1461 Ord,
1462 PartialOrd,
1463 Default,
1464)]
1465#[serde(rename_all = "lowercase")]
1466#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1467#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1468#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1469#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1470pub enum PostEffectType {
1471 Phosphor,
1472 Ssao,
1473 #[default]
1474 NoEffect,
1475}
1476
1477#[cfg(feature = "cxx")]
1480impl_extern_type! {
1481 [Trivial]
1482 FileImportFormat = "Enums::_FileImportFormat"
1484 FileExportFormat = "Enums::_FileExportFormat"
1485 CameraDragInteractionType = "Enums::_CameraDragInteractionType"
1487 SceneSelectionType = "Enums::_SceneSelectionType"
1489 SceneToolType = "Enums::_SceneToolType"
1490 BlendType = "Enums::_BlendType"
1491 BodyType = "Enums::_BodyType"
1492 EntityType = "Enums::_EntityType"
1493 AnnotationType = "Enums::_AnnotationType"
1494 AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
1495 AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
1496 AnnotationLineEnd = "Enums::_AnnotationLineEnd"
1497 MbdStandard = "Enums::_MBDStandard"
1498 MbdSymbol = "Enums::_MBDSymbol"
1499
1500 CurveType = "Enums::_CurveType"
1501 PathCommand = "Enums::_PathCommand"
1502 PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
1503 PathComponentConstraintType = "Enums::_PathComponentConstraintType"
1504 ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
1505
1506 EngineErrorCode = "Enums::_ErrorCode"
1508 GlobalAxis = "Enums::_GlobalAxis"
1509 OriginType = "Enums::_OriginType"
1510
1511 PostEffectType = "Enums::_PostEffectType"
1513}
1514
1515fn bool_true() -> bool {
1516 true
1517}
1518fn same_scale() -> Point3d<f64> {
1519 Point3d::uniform(1.0)
1520}
1521
1522fn z_axis() -> Point3d<f64> {
1523 Point3d { x: 0.0, y: 0.0, z: 1.0 }
1524}
1525
1526impl ExtrudedFaceInfo {
1527 pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
1530 let mut face_infos: Vec<_> = self
1531 .sides
1532 .into_iter()
1533 .map(|side| ExtrusionFaceInfo {
1534 curve_id: Some(side.path_id),
1535 face_id: Some(side.face_id),
1536 cap: ExtrusionFaceCapType::None,
1537 })
1538 .collect();
1539 face_infos.push(ExtrusionFaceInfo {
1540 curve_id: None,
1541 face_id: Some(self.top),
1542 cap: ExtrusionFaceCapType::Top,
1543 });
1544 if let Some(bottom) = self.bottom {
1545 face_infos.push(ExtrusionFaceInfo {
1546 curve_id: None,
1547 face_id: Some(bottom),
1548 cap: ExtrusionFaceCapType::Bottom,
1549 });
1550 }
1551 face_infos
1552 }
1553}
1554
1555#[cfg(test)]
1556mod tests {
1557 use super::*;
1558
1559 #[test]
1560 fn test_angle_comparison() {
1561 let a = Angle::from_degrees(90.0);
1562 assert!(a < Angle::from_degrees(91.0));
1563 assert!(a > Angle::from_degrees(89.0));
1564 assert!(a <= Angle::from_degrees(90.0));
1565 assert!(a >= Angle::from_degrees(90.0));
1566 let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
1567 assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
1568 assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
1569 assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1570 assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1571 assert!(a > b);
1573 assert!(a >= b);
1574 assert!(b < a);
1575 assert!(b <= a);
1576 let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
1577 assert!(a < c);
1578 assert!(a <= c);
1579 assert!(c > a);
1580 assert!(c >= a);
1581 }
1582}
1583
1584#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, JsonSchema, Builder)]
1586#[schemars(rename = "TransformByFor{T}")]
1587#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1588#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1589#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1590#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1591pub struct TransformBy<T> {
1592 pub property: T,
1594 pub set: bool,
1599 #[serde(default)]
1601 #[builder(default)]
1602 pub origin: OriginType,
1603}
1604
1605impl<T> TransformBy<T> {
1606 pub fn get_origin(&self) -> OriginType {
1610 self.origin
1611 }
1612}
1613
1614#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, Default, Builder)]
1617#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1618#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1619#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1620#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1621pub struct ComponentTransform {
1622 pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
1624 pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
1627 pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
1631 pub scale: Option<TransformBy<Point3d<f64>>>,
1633}
1634
1635#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
1638#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1639#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1640#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1641#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1642pub enum Opposite<T> {
1643 #[default]
1645 None,
1646 Symmetric,
1648 Other(T),
1650}
1651
1652impl<T: JsonSchema> JsonSchema for Opposite<T> {
1653 fn schema_name() -> String {
1654 format!("OppositeFor{}", T::schema_name())
1655 }
1656
1657 fn schema_id() -> std::borrow::Cow<'static, str> {
1658 std::borrow::Cow::Owned(format!("{}::Opposite<{}>", module_path!(), T::schema_id()))
1659 }
1660
1661 fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1662 SchemaObject {
1663 instance_type: Some(schemars::schema::InstanceType::String.into()),
1664 ..Default::default()
1665 }
1666 .into()
1667 }
1668}
1669
1670#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1673#[serde(rename_all = "snake_case")]
1674#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1675#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1676#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1677#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1678pub enum CutStrategy {
1679 Basic,
1682 Csg,
1685 #[default]
1687 Automatic,
1688}
1689
1690#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1692#[serde(rename_all = "snake_case")]
1693#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1694#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1695#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1696#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1697pub enum RelativeTo {
1698 #[default]
1700 SketchPlane,
1701 TrajectoryCurve,
1703}
1704
1705#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1707#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1708#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1709#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1710pub struct SelectedRegion {
1711 pub segment: Uuid,
1713 pub intersection_segment: Uuid,
1716 #[serde(default = "negative_one")]
1720 pub intersection_index: i32,
1721 #[serde(default)]
1724 pub curve_clockwise: bool,
1725}
1726
1727impl Default for SelectedRegion {
1728 fn default() -> Self {
1729 Self {
1730 segment: Default::default(),
1731 intersection_segment: Default::default(),
1732 intersection_index: -1,
1733 curve_clockwise: Default::default(),
1734 }
1735 }
1736}
1737
1738#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1740#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1741#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1742#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1743#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1744pub struct FractionOfEdge {
1745 pub edge_id: Uuid,
1747 #[serde(default)]
1751 #[builder(default)]
1752 #[schemars(range(min = 0, max = 1))]
1753 pub lower_bound: f32,
1754 #[serde(default = "one")]
1758 #[builder(default = one())]
1759 #[schemars(range(min = 0, max = 1))]
1760 pub upper_bound: f32,
1761}
1762
1763#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1765#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1766#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1767#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1768#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1769pub struct SurfaceEdgeReference {
1770 pub object_id: Uuid,
1772 pub edges: Vec<FractionOfEdge>,
1774}
1775
1776fn one() -> f32 {
1777 1.0
1778}