1use crate::def_enum::negative_one;
2use bon::Builder;
3use enum_iterator::Sequence;
4use parse_display_derive::{Display, FromStr};
5pub use point::{Point2d, Point3d, Point4d, Quaternion};
6use schemars::{schema::SchemaObject, JsonSchema};
7use serde::{Deserialize, Serialize};
8use uuid::Uuid;
9
10#[cfg(feature = "cxx")]
11use crate::impl_extern_type;
12use crate::{length_unit::LengthUnit, output::ExtrusionFaceInfo, units::UnitAngle};
13
14mod point;
15
16#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
18#[serde(rename_all = "snake_case")]
19#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
20#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
21#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
22pub enum CutType {
23 #[default]
25 Fillet,
26 Chamfer,
28}
29
30#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
32#[serde(rename_all = "snake_case")]
33#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
34#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
35#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
36#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
37pub enum CutTypeV2 {
38 Fillet {
40 radius: LengthUnit,
42 second_length: Option<LengthUnit>,
45 },
46 Chamfer {
48 distance: LengthUnit,
50 second_distance: Option<LengthUnit>,
52 angle: Option<Angle>,
54 swap: bool,
56 },
57 Custom {
59 path: Uuid,
61 },
62}
63
64#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
66#[serde(rename_all = "snake_case")]
67#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
68#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
69#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
70#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
71pub struct Rotation {
72 pub axis: Point3d<f64>,
75 pub angle: Angle,
78 pub origin: OriginType,
80}
81
82impl Default for Rotation {
83 fn default() -> Self {
85 Self {
86 axis: z_axis(),
87 angle: Angle::default(),
88 origin: OriginType::Local,
89 }
90 }
91}
92
93#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
95#[serde(rename_all = "snake_case")]
96#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
97#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
98#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
99#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
100pub struct Transform {
101 #[serde(default)]
104 #[builder(default)]
105 pub translate: Point3d<LengthUnit>,
106 #[serde(default = "same_scale")]
109 #[builder(default = same_scale())]
110 pub scale: Point3d<f64>,
111 #[serde(default)]
114 #[builder(default)]
115 pub rotation: Rotation,
116 #[serde(default = "bool_true")]
118 #[builder(default = bool_true())]
119 pub replicate: bool,
120}
121
122impl Default for Transform {
123 fn default() -> Self {
124 Self {
125 scale: same_scale(),
126 replicate: true,
127 translate: Default::default(),
128 rotation: Rotation::default(),
129 }
130 }
131}
132
133#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
135#[serde(rename_all = "snake_case")]
136#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
137#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
138#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
139#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
140pub struct AnnotationOptions {
141 pub text: Option<AnnotationTextOptions>,
143 pub line_ends: Option<AnnotationLineEndOptions>,
145 pub line_width: Option<f32>,
147 pub color: Option<Color>,
149 pub position: Option<Point3d<f32>>,
151 pub dimension: Option<AnnotationBasicDimension>,
153 pub feature_control: Option<AnnotationFeatureControl>,
155 pub feature_tag: Option<AnnotationFeatureTag>,
157}
158
159#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
161#[serde(rename_all = "snake_case")]
162#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
163#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
164#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
165#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
166pub struct AnnotationLineEndOptions {
167 pub start: AnnotationLineEnd,
169 pub end: AnnotationLineEnd,
171}
172
173#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
175#[serde(rename_all = "snake_case")]
176#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
177#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
178#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
179#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
180pub struct AnnotationTextOptions {
181 pub x: AnnotationTextAlignmentX,
183 pub y: AnnotationTextAlignmentY,
185 pub text: String,
187 pub point_size: u32,
189}
190
191#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
193#[serde(rename_all = "snake_case")]
194#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
195#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
196#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
197#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
198pub struct AnnotationMbdControlFrame {
199 pub symbol: MbdSymbol,
201 pub diameter_symbol: Option<MbdSymbol>,
203 pub tolerance: f64,
205 pub modifier: Option<MbdSymbol>,
207 pub primary_datum: Option<char>,
209 pub secondary_datum: Option<char>,
211 pub tertiary_datum: Option<char>,
213}
214
215#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
217#[serde(rename_all = "snake_case")]
218#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
219#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
220#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
221#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
222pub struct AnnotationMbdBasicDimension {
223 pub symbol: Option<MbdSymbol>,
225 pub dimension: Option<f64>,
227 pub tolerance: f64,
229}
230
231#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
233#[serde(rename_all = "snake_case")]
234#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
235#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
236#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
237#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
238pub struct AnnotationBasicDimension {
239 pub from_entity_id: Uuid,
241
242 pub from_entity_pos: Point2d<f64>,
244
245 pub to_entity_id: Uuid,
247
248 pub to_entity_pos: Point2d<f64>,
250
251 pub dimension: AnnotationMbdBasicDimension,
253
254 pub plane_id: Uuid,
256
257 pub offset: Point2d<f64>,
259
260 pub precision: u32,
262
263 pub font_scale: f32,
265
266 pub font_point_size: u32,
268
269 #[serde(default = "one")]
271 pub arrow_scale: f32,
272}
273
274#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
276#[serde(rename_all = "snake_case")]
277#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
278#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
279#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
280#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
281pub struct AnnotationFeatureControl {
282 pub entity_id: Uuid,
284
285 pub entity_pos: Point2d<f64>,
287
288 pub leader_type: AnnotationLineEnd,
290
291 pub dimension: Option<AnnotationMbdBasicDimension>,
293
294 pub control_frame: Option<AnnotationMbdControlFrame>,
296
297 pub defined_datum: Option<char>,
299
300 pub prefix: Option<String>,
302
303 pub suffix: Option<String>,
305
306 pub plane_id: Uuid,
308
309 pub offset: Point2d<f64>,
311
312 pub precision: u32,
314
315 pub font_scale: f32,
317
318 pub font_point_size: u32,
320
321 #[serde(default = "one")]
323 pub leader_scale: f32,
324}
325
326#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
328#[serde(rename_all = "snake_case")]
329#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
330#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
331#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
332#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
333pub struct AnnotationFeatureTag {
334 pub entity_id: Uuid,
336
337 pub entity_pos: Point2d<f64>,
339
340 pub leader_type: AnnotationLineEnd,
342
343 pub key: String,
345
346 pub value: String,
348
349 pub show_key: bool,
351
352 pub plane_id: Uuid,
354
355 pub offset: Point2d<f64>,
357
358 pub font_scale: f32,
360
361 pub font_point_size: u32,
363
364 #[serde(default = "one")]
366 pub leader_scale: f32,
367}
368
369#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
373#[serde(rename_all = "snake_case", tag = "type")]
374#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
375#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
376#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
377#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
378pub enum DistanceType {
379 Euclidean {},
381 OnAxis {
383 axis: GlobalAxis,
385 },
386}
387
388#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
390#[serde(rename_all = "snake_case", tag = "type")]
391#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
392#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
393#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
394#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
395pub enum OriginType {
396 #[default]
398 Local,
399 Global,
401 Custom {
403 origin: Point3d<f64>,
405 },
406}
407
408#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
410#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
411#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
412#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
413#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
414pub struct Color {
415 pub r: f32,
417 pub g: f32,
419 pub b: f32,
421 pub a: f32,
423}
424
425impl Color {
426 pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
428 Self { r, g, b, a }
429 }
430}
431
432#[allow(missing_docs)]
434#[derive(
435 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
436)]
437#[serde(rename_all = "lowercase")]
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 enum AnnotationTextAlignmentX {
443 Left,
444 Center,
445 Right,
446}
447
448#[allow(missing_docs)]
450#[derive(
451 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
452)]
453#[serde(rename_all = "lowercase")]
454#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
455#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
456#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
457#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
458pub enum AnnotationTextAlignmentY {
459 Bottom,
460 Center,
461 Top,
462}
463
464#[allow(missing_docs)]
466#[derive(
467 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
468)]
469#[serde(rename_all = "lowercase")]
470#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
471#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
472#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
473#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
474pub enum AnnotationLineEnd {
475 None,
476 Arrow,
477 Dot,
478}
479
480#[derive(
482 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
483)]
484#[serde(rename_all = "lowercase")]
485#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
486#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
487#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
488#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
489pub enum AnnotationType {
490 T2D,
492 T3D,
494}
495
496#[derive(
498 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
499)]
500#[serde(rename_all = "lowercase")]
501#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
502#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
503#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
504#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
505pub enum MbdStandard {
506 AsmeY14_5,
508}
509
510#[allow(missing_docs)]
513#[derive(
514 Default,
515 Display,
516 FromStr,
517 Copy,
518 Eq,
519 PartialEq,
520 Debug,
521 JsonSchema,
522 Deserialize,
523 Serialize,
524 Sequence,
525 Clone,
526 Ord,
527 PartialOrd,
528)]
529#[serde(rename_all = "lowercase")]
530#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
531#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
532#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
533#[repr(u16)]
534#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
535pub enum MbdSymbol {
536 #[default]
537 None = 0,
538 ArcLength = 174,
539 Between = 175,
540 Degrees = 176,
541 PlusMinus = 177,
542 Angularity = 178,
543 Cylindricity = 179,
544 Roundness = 180,
545 Concentricity = 181,
546 Straightness = 182,
547 Parallelism = 183,
548 Flatness = 184,
549 ProfileOfLine = 185,
550 SurfaceProfile = 186,
551 Symmetry = 187,
552 Perpendicularity = 188,
553 Runout = 189,
554 TotalRunout = 190,
555 Position = 191,
556 CenterLine = 192,
557 PartingLine = 193,
558 IsoEnvelope = 195,
559 IsoEnvelopeNonY145M = 196,
560 FreeState = 197,
561 StatisticalTolerance = 198,
562 ContinuousFeature = 199,
563 Independency = 200,
564 Depth = 201,
565 Start = 202,
566 LeastCondition = 203,
567 MaxCondition = 204,
568 ConicalTaper = 205,
569 Projected = 206,
570 Slope = 207,
571 Micro = 208,
572 TangentPlane = 210,
573 Unilateral = 211,
574 SquareFeature = 212,
575 Countersink = 213,
576 SpotFace = 214,
577 Target = 215,
578 Diameter = 216,
579 Radius = 217,
580 SphericalRadius = 218,
581 SphericalDiameter = 219,
582 ControlledRadius = 220,
583 BoxStart = 123,
584 BoxBar = 162,
585 BoxBarBetween = 124,
586 LetterBackwardUnderline = 95,
587 PunctuationBackwardUnderline = 92,
588 ModifierBackwardUnderline = 126,
589 NumericBackwardUnderline = 96,
590 BoxEnd = 125,
591 DatumUp = 166,
592 DatumLeft = 168,
593 DatumRight = 167,
594 DatumDown = 165,
595 DatumTriangle = 295,
596 HalfSpace = 236,
597 QuarterSpace = 237,
598 EighthSpace = 238,
599 ModifierSpace = 239,
600}
601
602#[derive(
604 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
605)]
606#[serde(rename_all = "lowercase")]
607#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
608#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
609#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
610#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
611pub enum CameraDragInteractionType {
612 Pan,
614 Rotate,
616 RotateTrackball,
618 Zoom,
620}
621
622#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
625#[serde(rename_all = "snake_case", tag = "type")]
626#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
627#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
628#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
629#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
630pub enum PathSegment {
631 Line {
634 end: Point3d<LengthUnit>,
636 relative: bool,
638 },
639 Arc {
642 center: Point2d<LengthUnit>,
644 radius: LengthUnit,
646 start: Angle,
648 end: Angle,
650 relative: bool,
652 },
653 Bezier {
657 control1: Point3d<LengthUnit>,
659 control2: Point3d<LengthUnit>,
661 end: Point3d<LengthUnit>,
663 relative: bool,
665 },
666 TangentialArc {
668 radius: LengthUnit,
671 offset: Angle,
673 },
674 TangentialArcTo {
677 to: Point3d<LengthUnit>,
681 angle_snap_increment: Option<Angle>,
683 },
684 ArcTo {
686 interior: Point3d<LengthUnit>,
688 end: Point3d<LengthUnit>,
690 relative: bool,
692 },
693 CircularInvolute {
696 start_radius: LengthUnit,
699 end_radius: LengthUnit,
702 angle: Angle,
705 reverse: bool,
708 },
709 Ellipse {
711 center: Point2d<LengthUnit>,
713 major_axis: Point2d<LengthUnit>,
715 minor_radius: LengthUnit,
717 start_angle: Angle,
719 end_angle: Angle,
721 },
722 ConicTo {
725 interior: Point2d<LengthUnit>,
727 end: Point2d<LengthUnit>,
729 start_tangent: Point2d<LengthUnit>,
731 end_tangent: Point2d<LengthUnit>,
733 relative: bool,
735 },
736}
737
738#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
740#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
741#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
742#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
743#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
744pub struct Angle {
745 pub unit: UnitAngle,
747 pub value: f64,
749}
750
751impl Angle {
752 pub fn to_degrees(self) -> f64 {
754 match self.unit {
755 UnitAngle::Degrees => self.value,
756 UnitAngle::Radians => self.value.to_degrees(),
757 }
758 }
759 pub fn to_radians(self) -> f64 {
761 match self.unit {
762 UnitAngle::Degrees => self.value.to_radians(),
763 UnitAngle::Radians => self.value,
764 }
765 }
766 pub const fn from_degrees(value: f64) -> Self {
768 Self {
769 unit: UnitAngle::Degrees,
770 value,
771 }
772 }
773 pub const fn from_radians(value: f64) -> Self {
775 Self {
776 unit: UnitAngle::Radians,
777 value,
778 }
779 }
780 pub const fn turn() -> Self {
782 Self::from_degrees(360.0)
783 }
784 pub const fn half_circle() -> Self {
786 Self::from_degrees(180.0)
787 }
788 pub const fn quarter_circle() -> Self {
790 Self::from_degrees(90.0)
791 }
792 pub const fn zero() -> Self {
794 Self::from_degrees(0.0)
795 }
796}
797
798impl Default for Angle {
800 fn default() -> Self {
802 Self::zero()
803 }
804}
805
806impl PartialOrd for Angle {
807 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
808 match (self.unit, other.unit) {
809 (UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
811 (UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
812 _ => self.to_degrees().partial_cmp(&other.to_degrees()),
813 }
814 }
815}
816
817impl std::ops::Add for Angle {
818 type Output = Self;
819
820 fn add(self, rhs: Self) -> Self::Output {
821 Self {
822 unit: UnitAngle::Degrees,
823 value: self.to_degrees() + rhs.to_degrees(),
824 }
825 }
826}
827
828impl std::ops::AddAssign for Angle {
829 fn add_assign(&mut self, rhs: Self) {
830 match self.unit {
831 UnitAngle::Degrees => {
832 self.value += rhs.to_degrees();
833 }
834 UnitAngle::Radians => {
835 self.value += rhs.to_radians();
836 }
837 }
838 }
839}
840
841#[derive(
843 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
844)]
845#[serde(rename_all = "lowercase")]
846#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
847#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
848#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
849#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
850pub enum SceneSelectionType {
851 Replace,
853 Add,
855 Remove,
857}
858
859#[allow(missing_docs)]
861#[derive(
862 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
863)]
864#[serde(rename_all = "snake_case")]
865#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
866#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
867#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
868#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
869pub enum SceneToolType {
870 CameraRevolve,
871 Select,
872 Move,
873 SketchLine,
874 SketchTangentialArc,
875 SketchCurve,
876 SketchCurveMod,
877}
878
879#[allow(missing_docs)]
881#[derive(
882 Display,
883 FromStr,
884 Copy,
885 Eq,
886 PartialEq,
887 Debug,
888 JsonSchema,
889 Deserialize,
890 Serialize,
891 Sequence,
892 Clone,
893 Ord,
894 PartialOrd,
895 Default,
896)]
897#[serde(rename_all = "snake_case")]
898#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
899#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
900#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
901#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
902pub enum PathComponentConstraintBound {
903 #[default]
904 Unconstrained,
905 PartiallyConstrained,
906 FullyConstrained,
907}
908
909#[allow(missing_docs)]
911#[derive(
912 Display,
913 FromStr,
914 Copy,
915 Eq,
916 PartialEq,
917 Debug,
918 JsonSchema,
919 Deserialize,
920 Serialize,
921 Sequence,
922 Clone,
923 Ord,
924 PartialOrd,
925 Default,
926)]
927#[serde(rename_all = "snake_case")]
928#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
929#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
930#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
931#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
932pub enum PathComponentConstraintType {
933 #[default]
934 Unconstrained,
935 Vertical,
936 Horizontal,
937 EqualLength,
938 Parallel,
939 AngleBetween,
940}
941
942#[allow(missing_docs)]
944#[derive(
945 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
946)]
947#[serde(rename_all = "snake_case")]
948#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
949#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
950#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
951#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
952pub enum PathCommand {
953 MoveTo,
954 LineTo,
955 BezCurveTo,
956 NurbsCurveTo,
957 AddArc,
958}
959
960#[allow(missing_docs)]
962#[derive(
963 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
964)]
965#[serde(rename_all = "lowercase")]
966#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
967#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
968#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
969#[repr(u8)]
970#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
971pub enum EntityType {
972 Entity,
973 Object,
974 Path,
975 Curve,
976 Solid2D,
977 Solid3D,
978 Edge,
979 Face,
980 Plane,
981 Vertex,
982}
983
984#[allow(missing_docs)]
986#[derive(
987 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
988)]
989#[serde(rename_all = "snake_case")]
990#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
991#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
992#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
993#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
994pub enum CurveType {
995 Line,
996 Arc,
997 Nurbs,
998}
999
1000#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1002#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
1003#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1004pub struct ExportFile {
1005 pub name: String,
1007 pub contents: crate::base64::Base64Data,
1009}
1010
1011#[cfg(feature = "python")]
1012#[pyo3_stub_gen::derive::gen_stub_pymethods]
1013#[pyo3::pymethods]
1014impl ExportFile {
1015 #[getter]
1016 fn contents(&self) -> Vec<u8> {
1017 self.contents.0.clone()
1018 }
1019
1020 #[getter]
1021 fn name(&self) -> String {
1022 self.name.clone()
1023 }
1024}
1025
1026#[derive(
1028 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1029)]
1030#[serde(rename_all = "lowercase")]
1031#[display(style = "lowercase")]
1032#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1033#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1034#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1035#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
1036#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1037pub enum FileExportFormat {
1038 Fbx,
1040 Glb,
1047 Gltf,
1058 Obj,
1062 Ply,
1064 Step,
1066 Stl,
1068}
1069
1070#[derive(
1072 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1073)]
1074#[serde(rename_all = "lowercase")]
1075#[display(style = "lowercase")]
1076#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1077#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1078#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1079#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1080pub enum FileExportFormat2d {
1081 Dxf,
1083}
1084
1085#[derive(
1087 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1088)]
1089#[serde(rename_all = "lowercase")]
1090#[display(style = "lowercase")]
1091#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1092#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1093#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1094#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1095pub enum FileImportFormat {
1096 Fbx,
1098 Gltf,
1100 Obj,
1104 Ply,
1106 Sldprt,
1108 Step,
1110 Stl,
1112}
1113
1114#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
1116#[serde(rename_all = "snake_case")]
1117#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1118#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1119#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1120#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1121pub enum EngineErrorCode {
1122 BadRequest = 1,
1126 InternalEngine,
1128}
1129
1130impl From<EngineErrorCode> for http::StatusCode {
1131 fn from(e: EngineErrorCode) -> Self {
1132 match e {
1133 EngineErrorCode::BadRequest => Self::BAD_REQUEST,
1134 EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
1135 }
1136 }
1137}
1138
1139#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1141#[serde(rename_all = "snake_case")]
1142#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1143#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1144#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1145pub enum BlendType {
1146 #[default]
1148 Tangent,
1149}
1150
1151#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1153#[serde(rename_all = "snake_case")]
1154#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1155#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1156#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1157#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1158pub enum BodyType {
1159 #[default]
1161 Solid,
1162 Surface,
1164}
1165
1166#[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"))]
1173#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1174pub enum ExtrudeMethod {
1175 New,
1178 #[default]
1181 Merge,
1182}
1183
1184#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1186#[serde(rename_all = "snake_case")]
1187#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1188#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1189#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1190#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1191pub enum ExtrudeReference {
1192 EntityReference {
1195 entity_id: Uuid,
1197 },
1198 Axis {
1200 axis: Point3d<f64>,
1202 #[serde(default)]
1205 point: Point3d<LengthUnit>,
1206 },
1207 Point {
1209 point: Point3d<LengthUnit>,
1211 },
1212}
1213
1214#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1216#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1217#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1218#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1219#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1220pub struct ExtrudedFaceInfo {
1221 pub bottom: Option<Uuid>,
1226 pub top: Uuid,
1228 pub sides: Vec<SideFace>,
1230}
1231
1232#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1234#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1235#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1236#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1237#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1238pub struct SideFace {
1239 pub path_id: Uuid,
1241 pub face_id: Uuid,
1243}
1244
1245#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1247#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1248#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1249#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1250#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1251pub struct CameraSettings {
1252 pub pos: Point3d,
1254
1255 pub center: Point3d,
1257
1258 pub up: Point3d,
1260
1261 pub orientation: Quaternion,
1263
1264 pub fov_y: Option<f32>,
1266
1267 pub ortho_scale: Option<f32>,
1269
1270 pub ortho: bool,
1272}
1273
1274#[allow(missing_docs)]
1275#[repr(u8)]
1276#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1277#[serde(rename_all = "snake_case")]
1278#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1279#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1280#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1281#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1282pub enum WorldCoordinateSystem {
1283 #[default]
1284 RightHandedUpZ,
1285 RightHandedUpY,
1286}
1287
1288#[allow(missing_docs)]
1289#[repr(C)]
1290#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1291#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1292#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1293#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1294#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1295pub struct CameraViewState {
1296 pub pivot_rotation: Quaternion,
1297 pub pivot_position: Point3d,
1298 pub eye_offset: f32,
1299 pub fov_y: f32,
1300 pub ortho_scale_factor: f32,
1301 pub is_ortho: bool,
1302 pub ortho_scale_enabled: bool,
1303 pub world_coord_system: WorldCoordinateSystem,
1304}
1305
1306impl Default for CameraViewState {
1307 fn default() -> Self {
1308 CameraViewState {
1309 pivot_rotation: Default::default(),
1310 pivot_position: Default::default(),
1311 eye_offset: 10.0,
1312 fov_y: 45.0,
1313 ortho_scale_factor: 1.6,
1314 is_ortho: false,
1315 ortho_scale_enabled: true,
1316 world_coord_system: Default::default(),
1317 }
1318 }
1319}
1320
1321#[cfg(feature = "cxx")]
1322impl_extern_type! {
1323 [Trivial]
1324 CameraViewState = "Endpoints::CameraViewState"
1325}
1326
1327impl From<CameraSettings> for crate::output::DefaultCameraZoom {
1328 fn from(settings: CameraSettings) -> Self {
1329 Self { settings }
1330 }
1331}
1332impl From<CameraSettings> for crate::output::CameraDragMove {
1333 fn from(settings: CameraSettings) -> Self {
1334 Self { settings }
1335 }
1336}
1337impl From<CameraSettings> for crate::output::CameraDragEnd {
1338 fn from(settings: CameraSettings) -> Self {
1339 Self { settings }
1340 }
1341}
1342impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
1343 fn from(settings: CameraSettings) -> Self {
1344 Self { settings }
1345 }
1346}
1347impl From<CameraSettings> for crate::output::ZoomToFit {
1348 fn from(settings: CameraSettings) -> Self {
1349 Self { settings }
1350 }
1351}
1352impl From<CameraSettings> for crate::output::OrientToFace {
1353 fn from(settings: CameraSettings) -> Self {
1354 Self { settings }
1355 }
1356}
1357impl From<CameraSettings> for crate::output::ViewIsometric {
1358 fn from(settings: CameraSettings) -> Self {
1359 Self { settings }
1360 }
1361}
1362
1363#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default, Builder)]
1365#[serde(rename_all = "snake_case")]
1366#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1367#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1368#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1369#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1370pub struct PerspectiveCameraParameters {
1371 pub fov_y: Option<f32>,
1373 pub z_near: Option<f32>,
1375 pub z_far: Option<f32>,
1377}
1378
1379#[derive(
1381 Default,
1382 Display,
1383 FromStr,
1384 Copy,
1385 Eq,
1386 PartialEq,
1387 Debug,
1388 JsonSchema,
1389 Deserialize,
1390 Serialize,
1391 Sequence,
1392 Clone,
1393 Ord,
1394 PartialOrd,
1395)]
1396#[serde(rename_all = "snake_case")]
1397#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1398#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1399#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1400#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1401pub enum CameraMovement {
1402 #[default]
1404 Vantage,
1405 None,
1407}
1408
1409#[derive(
1411 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1412)]
1413#[serde(rename_all = "lowercase")]
1414#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1415#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1416#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1417#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1418pub enum GlobalAxis {
1419 X,
1421 Y,
1423 Z,
1425}
1426
1427#[derive(
1429 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1430)]
1431#[serde(rename_all = "snake_case")]
1432#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1433#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1434#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1435#[repr(u8)]
1436#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1437pub enum ExtrusionFaceCapType {
1438 None,
1440 Top,
1442 Bottom,
1444 Both,
1446}
1447
1448#[allow(missing_docs)]
1450#[derive(
1451 Display,
1452 FromStr,
1453 Copy,
1454 Eq,
1455 PartialEq,
1456 Debug,
1457 JsonSchema,
1458 Deserialize,
1459 Serialize,
1460 Sequence,
1461 Clone,
1462 Ord,
1463 PartialOrd,
1464 Default,
1465)]
1466#[serde(rename_all = "lowercase")]
1467#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1468#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1469#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1470#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1471pub enum PostEffectType {
1472 Phosphor,
1473 Ssao,
1474 #[default]
1475 NoEffect,
1476}
1477
1478#[cfg(feature = "cxx")]
1481impl_extern_type! {
1482 [Trivial]
1483 FileImportFormat = "Enums::_FileImportFormat"
1485 FileExportFormat = "Enums::_FileExportFormat"
1486 CameraDragInteractionType = "Enums::_CameraDragInteractionType"
1488 SceneSelectionType = "Enums::_SceneSelectionType"
1490 SceneToolType = "Enums::_SceneToolType"
1491 BlendType = "Enums::_BlendType"
1492 BodyType = "Enums::_BodyType"
1493 EntityType = "Enums::_EntityType"
1494 AnnotationType = "Enums::_AnnotationType"
1495 AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
1496 AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
1497 AnnotationLineEnd = "Enums::_AnnotationLineEnd"
1498 MbdStandard = "Enums::_MBDStandard"
1499 MbdSymbol = "Enums::_MBDSymbol"
1500
1501 CurveType = "Enums::_CurveType"
1502 PathCommand = "Enums::_PathCommand"
1503 PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
1504 PathComponentConstraintType = "Enums::_PathComponentConstraintType"
1505 ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
1506
1507 EngineErrorCode = "Enums::_ErrorCode"
1509 GlobalAxis = "Enums::_GlobalAxis"
1510 OriginType = "Enums::_OriginType"
1511
1512 PostEffectType = "Enums::_PostEffectType"
1514}
1515
1516fn bool_true() -> bool {
1517 true
1518}
1519fn same_scale() -> Point3d<f64> {
1520 Point3d::uniform(1.0)
1521}
1522
1523fn z_axis() -> Point3d<f64> {
1524 Point3d { x: 0.0, y: 0.0, z: 1.0 }
1525}
1526
1527impl ExtrudedFaceInfo {
1528 pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
1531 let mut face_infos: Vec<_> = self
1532 .sides
1533 .into_iter()
1534 .map(|side| ExtrusionFaceInfo {
1535 curve_id: Some(side.path_id),
1536 face_id: Some(side.face_id),
1537 cap: ExtrusionFaceCapType::None,
1538 })
1539 .collect();
1540 face_infos.push(ExtrusionFaceInfo {
1541 curve_id: None,
1542 face_id: Some(self.top),
1543 cap: ExtrusionFaceCapType::Top,
1544 });
1545 if let Some(bottom) = self.bottom {
1546 face_infos.push(ExtrusionFaceInfo {
1547 curve_id: None,
1548 face_id: Some(bottom),
1549 cap: ExtrusionFaceCapType::Bottom,
1550 });
1551 }
1552 face_infos
1553 }
1554}
1555
1556#[cfg(test)]
1557mod tests {
1558 use super::*;
1559
1560 #[test]
1561 fn test_angle_comparison() {
1562 let a = Angle::from_degrees(90.0);
1563 assert!(a < Angle::from_degrees(91.0));
1564 assert!(a > Angle::from_degrees(89.0));
1565 assert!(a <= Angle::from_degrees(90.0));
1566 assert!(a >= Angle::from_degrees(90.0));
1567 let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
1568 assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
1569 assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
1570 assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1571 assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1572 assert!(a > b);
1574 assert!(a >= b);
1575 assert!(b < a);
1576 assert!(b <= a);
1577 let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
1578 assert!(a < c);
1579 assert!(a <= c);
1580 assert!(c > a);
1581 assert!(c >= a);
1582 }
1583}
1584
1585#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, JsonSchema, Builder)]
1587#[schemars(rename = "TransformByFor{T}")]
1588#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1589#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1590#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1591#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1592pub struct TransformBy<T> {
1593 pub property: T,
1595 pub set: bool,
1600 #[serde(default)]
1602 #[builder(default)]
1603 pub origin: OriginType,
1604}
1605
1606impl<T> TransformBy<T> {
1607 pub fn get_origin(&self) -> OriginType {
1611 self.origin
1612 }
1613}
1614
1615#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, Default, Builder)]
1618#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1619#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1620#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1621#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1622pub struct ComponentTransform {
1623 pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
1625 pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
1628 pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
1632 pub scale: Option<TransformBy<Point3d<f64>>>,
1634}
1635
1636#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
1639#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1640#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1641#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1642#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1643pub enum Opposite<T> {
1644 #[default]
1646 None,
1647 Symmetric,
1649 Other(T),
1651}
1652
1653impl<T: JsonSchema> JsonSchema for Opposite<T> {
1654 fn schema_name() -> String {
1655 format!("OppositeFor{}", T::schema_name())
1656 }
1657
1658 fn schema_id() -> std::borrow::Cow<'static, str> {
1659 std::borrow::Cow::Owned(format!("{}::Opposite<{}>", module_path!(), T::schema_id()))
1660 }
1661
1662 fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1663 SchemaObject {
1664 instance_type: Some(schemars::schema::InstanceType::String.into()),
1665 ..Default::default()
1666 }
1667 .into()
1668 }
1669}
1670
1671#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1674#[serde(rename_all = "snake_case")]
1675#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1676#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1677#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1678#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1679pub enum CutStrategy {
1680 Basic,
1683 Csg,
1686 #[default]
1688 Automatic,
1689}
1690
1691#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1693#[serde(rename_all = "snake_case")]
1694#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1695#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1696#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1697#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1698pub enum RelativeTo {
1699 #[default]
1701 SketchPlane,
1702 TrajectoryCurve,
1704}
1705
1706#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1708#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1709#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1710#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1711pub struct SelectedRegion {
1712 pub segment: Uuid,
1714 pub intersection_segment: Uuid,
1717 #[serde(default = "negative_one")]
1721 pub intersection_index: i32,
1722 #[serde(default)]
1725 pub curve_clockwise: bool,
1726}
1727
1728impl Default for SelectedRegion {
1729 fn default() -> Self {
1730 Self {
1731 segment: Default::default(),
1732 intersection_segment: Default::default(),
1733 intersection_index: -1,
1734 curve_clockwise: Default::default(),
1735 }
1736 }
1737}
1738
1739#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1741#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1742#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1743#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1744#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1745pub struct FractionOfEdge {
1746 pub edge_id: Uuid,
1748 #[serde(default)]
1752 #[builder(default)]
1753 #[schemars(range(min = 0, max = 1))]
1754 pub lower_bound: f32,
1755 #[serde(default = "one")]
1759 #[builder(default = one())]
1760 #[schemars(range(min = 0, max = 1))]
1761 pub upper_bound: f32,
1762}
1763
1764#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1766#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1767#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1768#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1769#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1770pub struct SurfaceEdgeReference {
1771 pub object_id: Uuid,
1773 pub edges: Vec<FractionOfEdge>,
1775}
1776
1777fn one() -> f32 {
1778 1.0
1779}