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, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
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"))]
21#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
22pub struct EdgeSpecifier {
23 pub side_faces: Vec<Uuid>,
25 #[serde(default, skip_serializing_if = "Vec::is_empty")]
27 #[builder(default)]
28 pub end_faces: Vec<Uuid>,
29 #[serde(skip_serializing_if = "Option::is_none")]
33 pub index: Option<u32>,
34}
35
36#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
52#[serde(rename_all = "snake_case")]
53#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
54#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
55#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
56pub struct PrimitiveTopologyFallback {
57 pub parent_id: Uuid,
59 pub primitive_index: u32,
61}
62
63#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
65#[serde(tag = "type", 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"))]
69pub enum EntityReference {
70 Plane {
72 plane_id: Uuid,
74 #[serde(default, skip_serializing_if = "Option::is_none")]
76 topology_fallback: Option<PrimitiveTopologyFallback>,
77 },
78 Face {
80 face_id: Uuid,
82 #[serde(default, skip_serializing_if = "Option::is_none")]
84 topology_fallback: Option<PrimitiveTopologyFallback>,
85 },
86 Edge {
88 #[serde(flatten)]
90 inner: EdgeSpecifier,
91 #[serde(default, skip_serializing_if = "Option::is_none")]
93 topology_fallback: Option<PrimitiveTopologyFallback>,
94 },
95 Vertex {
97 side_faces: Vec<Uuid>,
99 #[serde(skip_serializing_if = "Option::is_none")]
101 index: Option<u32>,
102 #[serde(default, skip_serializing_if = "Option::is_none")]
104 topology_fallback: Option<PrimitiveTopologyFallback>,
105 },
106 Solid2d {
108 solid2d_id: Uuid,
110 #[serde(default, skip_serializing_if = "Option::is_none")]
112 topology_fallback: Option<PrimitiveTopologyFallback>,
113 },
114 Solid3d {
116 solid3d_id: Uuid,
118 #[serde(default, skip_serializing_if = "Option::is_none")]
120 topology_fallback: Option<PrimitiveTopologyFallback>,
121 },
122 Solid2dEdge {
125 edge_id: Uuid,
127 #[serde(default, skip_serializing_if = "Option::is_none")]
129 topology_fallback: Option<PrimitiveTopologyFallback>,
130 },
131 Segment {
133 path_id: Uuid,
135 segment_id: Uuid,
137 #[serde(default, skip_serializing_if = "Option::is_none")]
139 topology_fallback: Option<PrimitiveTopologyFallback>,
140 },
141 Region {
143 region_id: Uuid,
145 #[serde(default, skip_serializing_if = "Option::is_none")]
147 topology_fallback: Option<PrimitiveTopologyFallback>,
148 },
149}
150
151#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
153#[serde(rename_all = "snake_case")]
154#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
155#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
156#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
157pub enum CutType {
158 #[default]
160 Fillet,
161 Chamfer,
163}
164
165#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
167#[serde(rename_all = "snake_case")]
168#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
169#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
170#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
171pub enum MirrorAcross {
172 Edge {
175 id: Uuid,
177 },
178 Axis {
181 axis: Point3d<f64>,
183 point: Point3d<LengthUnit>,
185 },
186 Plane {
189 id: Uuid,
191 },
192}
193
194#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
196#[serde(rename_all = "snake_case")]
197#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
198#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
199#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
200#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
201pub enum CutTypeV2 {
202 Fillet {
204 radius: LengthUnit,
206 second_length: Option<LengthUnit>,
209 },
210 Chamfer {
212 distance: LengthUnit,
214 second_distance: Option<LengthUnit>,
216 angle: Option<Angle>,
218 swap: bool,
220 },
221 Custom {
223 path: Uuid,
225 },
226}
227
228#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
230#[serde(rename_all = "snake_case")]
231#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
232#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
233#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
234#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
235pub struct Rotation {
236 pub axis: Point3d<f64>,
239 pub angle: Angle,
242 pub origin: OriginType,
244}
245
246impl Default for Rotation {
247 fn default() -> Self {
249 Self {
250 axis: z_axis(),
251 angle: Angle::default(),
252 origin: OriginType::Local,
253 }
254 }
255}
256
257#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
259#[serde(rename_all = "snake_case")]
260#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
261#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
262#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
263#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
264pub struct Transform {
265 #[serde(default)]
268 #[builder(default)]
269 pub translate: Point3d<LengthUnit>,
270 #[serde(default = "same_scale")]
273 #[builder(default = same_scale())]
274 pub scale: Point3d<f64>,
275 #[serde(default)]
278 #[builder(default)]
279 pub rotation: Rotation,
280 #[serde(default = "bool_true")]
282 #[builder(default = bool_true())]
283 pub replicate: bool,
284}
285
286impl Default for Transform {
287 fn default() -> Self {
288 Self {
289 scale: same_scale(),
290 replicate: true,
291 translate: Default::default(),
292 rotation: Rotation::default(),
293 }
294 }
295}
296
297#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
299#[serde(rename_all = "snake_case")]
300#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
301#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
302#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
303#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
304pub struct AnnotationOptions {
305 pub text: Option<AnnotationTextOptions>,
307 pub line_ends: Option<AnnotationLineEndOptions>,
309 pub line_width: Option<f32>,
311 pub color: Option<Color>,
313 pub position: Option<Point3d<f32>>,
315 pub dimension: Option<AnnotationBasicDimension>,
317 pub feature_control: Option<AnnotationFeatureControl>,
319 pub feature_tag: Option<AnnotationFeatureTag>,
321}
322
323#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
325#[serde(rename_all = "snake_case")]
326#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
327#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
328#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
329#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
330pub struct AnnotationLineEndOptions {
331 pub start: AnnotationLineEnd,
333 pub end: AnnotationLineEnd,
335}
336
337#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
339#[serde(rename_all = "snake_case")]
340#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
341#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
342#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
343#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
344pub struct AnnotationTextOptions {
345 pub x: AnnotationTextAlignmentX,
347 pub y: AnnotationTextAlignmentY,
349 pub text: String,
351 pub point_size: u32,
353}
354
355#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
357#[serde(rename_all = "snake_case")]
358#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
359#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
360#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
361#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
362pub struct AnnotationMbdControlFrame {
363 pub symbol: MbdSymbol,
365 pub diameter_symbol: Option<MbdSymbol>,
367 pub tolerance: f64,
369 pub modifier: Option<MbdSymbol>,
371 pub primary_datum: Option<char>,
373 pub secondary_datum: Option<char>,
375 pub tertiary_datum: Option<char>,
377}
378
379#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
381#[serde(rename_all = "snake_case")]
382#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
383#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
384#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
385#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
386pub struct AnnotationMbdBasicDimension {
387 pub symbol: Option<MbdSymbol>,
389 pub dimension: Option<f64>,
391 pub tolerance: f64,
393}
394
395#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
397#[serde(rename_all = "snake_case")]
398#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
399#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
400#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
401#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
402pub struct AnnotationBasicDimension {
403 pub from_entity_id: Uuid,
405
406 pub from_entity_pos: Point2d<f64>,
408
409 pub to_entity_id: Uuid,
411
412 pub to_entity_pos: Point2d<f64>,
414
415 pub dimension: AnnotationMbdBasicDimension,
417
418 pub plane_id: Uuid,
420
421 pub offset: Point2d<f64>,
423
424 pub precision: u32,
426
427 pub font_scale: f32,
429
430 pub font_point_size: u32,
432
433 #[serde(default = "one")]
435 pub arrow_scale: f32,
436}
437
438#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
440#[serde(rename_all = "snake_case")]
441#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
442#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
443#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
444#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
445pub struct AnnotationFeatureControl {
446 pub entity_id: Uuid,
448
449 pub entity_pos: Point2d<f64>,
451
452 pub leader_type: AnnotationLineEnd,
454
455 pub dimension: Option<AnnotationMbdBasicDimension>,
457
458 pub control_frame: Option<AnnotationMbdControlFrame>,
460
461 pub defined_datum: Option<char>,
463
464 pub prefix: Option<String>,
466
467 pub suffix: Option<String>,
469
470 pub plane_id: Uuid,
472
473 pub offset: Point2d<f64>,
475
476 pub precision: u32,
478
479 pub font_scale: f32,
481
482 pub font_point_size: u32,
484
485 #[serde(default = "one")]
487 pub leader_scale: f32,
488}
489
490#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
492#[serde(rename_all = "snake_case")]
493#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
494#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
495#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
496#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
497pub struct AnnotationFeatureTag {
498 pub entity_id: Uuid,
500
501 pub entity_pos: Point2d<f64>,
503
504 pub leader_type: AnnotationLineEnd,
506
507 pub key: String,
509
510 pub value: String,
512
513 pub show_key: bool,
515
516 pub plane_id: Uuid,
518
519 pub offset: Point2d<f64>,
521
522 pub font_scale: f32,
524
525 pub font_point_size: u32,
527
528 #[serde(default = "one")]
530 pub leader_scale: f32,
531}
532
533#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
537#[serde(rename_all = "snake_case", tag = "type")]
538#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
539#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
540#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
541#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
542pub enum DistanceType {
543 Euclidean {},
545 OnAxis {
547 axis: GlobalAxis,
549 },
550}
551
552#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
554#[serde(rename_all = "snake_case", tag = "type")]
555#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
556#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
557#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
558#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
559pub enum OriginType {
560 #[default]
562 Local,
563 Global,
565 Custom {
567 origin: Point3d<f64>,
569 },
570}
571
572#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
574#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
575#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
576#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
577#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
578pub struct Color {
579 pub r: f32,
581 pub g: f32,
583 pub b: f32,
585 pub a: f32,
587}
588
589impl Color {
590 pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
592 Self { r, g, b, a }
593 }
594}
595
596#[allow(missing_docs)]
598#[derive(
599 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
600)]
601#[serde(rename_all = "lowercase")]
602#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
603#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
604#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
605#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
606pub enum AnnotationTextAlignmentX {
607 Left,
608 Center,
609 Right,
610}
611
612#[allow(missing_docs)]
614#[derive(
615 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
616)]
617#[serde(rename_all = "lowercase")]
618#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
619#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
620#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
621#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
622pub enum AnnotationTextAlignmentY {
623 Bottom,
624 Center,
625 Top,
626}
627
628#[allow(missing_docs)]
630#[derive(
631 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
632)]
633#[serde(rename_all = "lowercase")]
634#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
635#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
636#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
637#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
638pub enum AnnotationLineEnd {
639 None,
640 Arrow,
641 Dot,
642}
643
644#[derive(
646 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
647)]
648#[serde(rename_all = "lowercase")]
649#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
650#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
651#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
652#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
653pub enum AnnotationType {
654 T2D,
656 T3D,
658}
659
660#[derive(
662 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
663)]
664#[serde(rename_all = "lowercase")]
665#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
666#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
667#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
668#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
669pub enum MbdStandard {
670 AsmeY14_5,
672}
673
674#[allow(missing_docs)]
677#[derive(
678 Default,
679 Display,
680 FromStr,
681 Copy,
682 Eq,
683 PartialEq,
684 Debug,
685 JsonSchema,
686 Deserialize,
687 Serialize,
688 Sequence,
689 Clone,
690 Ord,
691 PartialOrd,
692)]
693#[serde(rename_all = "lowercase")]
694#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
695#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
696#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
697#[repr(u16)]
698#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
699pub enum MbdSymbol {
700 #[default]
701 None = 0,
702 ArcLength = 174,
703 Between = 175,
704 Degrees = 176,
705 PlusMinus = 177,
706 Angularity = 178,
707 Cylindricity = 179,
708 Roundness = 180,
709 Concentricity = 181,
710 Straightness = 182,
711 Parallelism = 183,
712 Flatness = 184,
713 ProfileOfLine = 185,
714 SurfaceProfile = 186,
715 Symmetry = 187,
716 Perpendicularity = 188,
717 Runout = 189,
718 TotalRunout = 190,
719 Position = 191,
720 CenterLine = 192,
721 PartingLine = 193,
722 IsoEnvelope = 195,
723 IsoEnvelopeNonY145M = 196,
724 FreeState = 197,
725 StatisticalTolerance = 198,
726 ContinuousFeature = 199,
727 Independency = 200,
728 Depth = 201,
729 Start = 202,
730 LeastCondition = 203,
731 MaxCondition = 204,
732 ConicalTaper = 205,
733 Projected = 206,
734 Slope = 207,
735 Micro = 208,
736 TangentPlane = 210,
737 Unilateral = 211,
738 SquareFeature = 212,
739 Countersink = 213,
740 SpotFace = 214,
741 Target = 215,
742 Diameter = 216,
743 Radius = 217,
744 SphericalRadius = 218,
745 SphericalDiameter = 219,
746 ControlledRadius = 220,
747 BoxStart = 123,
748 BoxBar = 162,
749 BoxBarBetween = 124,
750 LetterBackwardUnderline = 95,
751 PunctuationBackwardUnderline = 92,
752 ModifierBackwardUnderline = 126,
753 NumericBackwardUnderline = 96,
754 BoxEnd = 125,
755 DatumUp = 166,
756 DatumLeft = 168,
757 DatumRight = 167,
758 DatumDown = 165,
759 DatumTriangle = 295,
760 HalfSpace = 236,
761 QuarterSpace = 237,
762 EighthSpace = 238,
763 ModifierSpace = 239,
764}
765
766#[derive(
768 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
769)]
770#[serde(rename_all = "lowercase")]
771#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
772#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
773#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
774#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
775pub enum CameraDragInteractionType {
776 Pan,
778 Rotate,
780 RotateTrackball,
782 Zoom,
784}
785
786#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
789#[serde(rename_all = "snake_case", tag = "type")]
790#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
791#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
792#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
793#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
794pub enum PathSegment {
795 Line {
798 end: Point3d<LengthUnit>,
800 relative: bool,
802 },
803 Arc {
806 center: Point2d<LengthUnit>,
808 radius: LengthUnit,
810 start: Angle,
812 end: Angle,
814 relative: bool,
816 },
817 Bezier {
821 control1: Point3d<LengthUnit>,
823 control2: Point3d<LengthUnit>,
825 end: Point3d<LengthUnit>,
827 relative: bool,
829 },
830 TangentialArc {
832 radius: LengthUnit,
835 offset: Angle,
837 },
838 TangentialArcTo {
841 to: Point3d<LengthUnit>,
845 angle_snap_increment: Option<Angle>,
847 },
848 ArcTo {
850 interior: Point3d<LengthUnit>,
852 end: Point3d<LengthUnit>,
854 relative: bool,
856 },
857 CircularInvolute {
860 start_radius: LengthUnit,
863 end_radius: LengthUnit,
866 angle: Angle,
869 reverse: bool,
872 },
873 Ellipse {
875 center: Point2d<LengthUnit>,
877 major_axis: Point2d<LengthUnit>,
879 minor_radius: LengthUnit,
881 start_angle: Angle,
883 end_angle: Angle,
885 },
886 ConicTo {
889 interior: Point2d<LengthUnit>,
891 end: Point2d<LengthUnit>,
893 start_tangent: Point2d<LengthUnit>,
895 end_tangent: Point2d<LengthUnit>,
897 relative: bool,
899 },
900}
901
902#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
904#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
905#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
906#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
907#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
908pub struct Angle {
909 pub unit: UnitAngle,
911 pub value: f64,
913}
914
915impl Angle {
916 pub fn to_degrees(self) -> f64 {
918 match self.unit {
919 UnitAngle::Degrees => self.value,
920 UnitAngle::Radians => self.value.to_degrees(),
921 }
922 }
923 pub fn to_radians(self) -> f64 {
925 match self.unit {
926 UnitAngle::Degrees => self.value.to_radians(),
927 UnitAngle::Radians => self.value,
928 }
929 }
930 pub const fn from_degrees(value: f64) -> Self {
932 Self {
933 unit: UnitAngle::Degrees,
934 value,
935 }
936 }
937 pub const fn from_radians(value: f64) -> Self {
939 Self {
940 unit: UnitAngle::Radians,
941 value,
942 }
943 }
944 pub const fn turn() -> Self {
946 Self::from_degrees(360.0)
947 }
948 pub const fn half_circle() -> Self {
950 Self::from_degrees(180.0)
951 }
952 pub const fn quarter_circle() -> Self {
954 Self::from_degrees(90.0)
955 }
956 pub const fn zero() -> Self {
958 Self::from_degrees(0.0)
959 }
960}
961
962impl Default for Angle {
964 fn default() -> Self {
966 Self::zero()
967 }
968}
969
970impl PartialOrd for Angle {
971 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
972 match (self.unit, other.unit) {
973 (UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
975 (UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
976 _ => self.to_degrees().partial_cmp(&other.to_degrees()),
977 }
978 }
979}
980
981impl std::ops::Add for Angle {
982 type Output = Self;
983
984 fn add(self, rhs: Self) -> Self::Output {
985 Self {
986 unit: UnitAngle::Degrees,
987 value: self.to_degrees() + rhs.to_degrees(),
988 }
989 }
990}
991
992impl std::ops::AddAssign for Angle {
993 fn add_assign(&mut self, rhs: Self) {
994 match self.unit {
995 UnitAngle::Degrees => {
996 self.value += rhs.to_degrees();
997 }
998 UnitAngle::Radians => {
999 self.value += rhs.to_radians();
1000 }
1001 }
1002 }
1003}
1004
1005#[derive(
1007 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1008)]
1009#[serde(rename_all = "lowercase")]
1010#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1011#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1012#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1013#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1014pub enum SceneSelectionType {
1015 Replace,
1017 Add,
1019 Remove,
1021}
1022
1023#[allow(missing_docs)]
1025#[derive(
1026 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1027)]
1028#[serde(rename_all = "snake_case")]
1029#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1030#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1031#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1032#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1033pub enum SceneToolType {
1034 CameraRevolve,
1035 Select,
1036 Move,
1037 SketchLine,
1038 SketchTangentialArc,
1039 SketchCurve,
1040 SketchCurveMod,
1041}
1042
1043#[allow(missing_docs)]
1045#[derive(
1046 Display,
1047 FromStr,
1048 Copy,
1049 Eq,
1050 PartialEq,
1051 Debug,
1052 JsonSchema,
1053 Deserialize,
1054 Serialize,
1055 Sequence,
1056 Clone,
1057 Ord,
1058 PartialOrd,
1059 Default,
1060)]
1061#[serde(rename_all = "snake_case")]
1062#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1063#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1064#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1065#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1066pub enum PathComponentConstraintBound {
1067 #[default]
1068 Unconstrained,
1069 PartiallyConstrained,
1070 FullyConstrained,
1071}
1072
1073#[allow(missing_docs)]
1075#[derive(
1076 Display,
1077 FromStr,
1078 Copy,
1079 Eq,
1080 PartialEq,
1081 Debug,
1082 JsonSchema,
1083 Deserialize,
1084 Serialize,
1085 Sequence,
1086 Clone,
1087 Ord,
1088 PartialOrd,
1089 Default,
1090)]
1091#[serde(rename_all = "snake_case")]
1092#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1093#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1094#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1095#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1096pub enum PathComponentConstraintType {
1097 #[default]
1098 Unconstrained,
1099 Vertical,
1100 Horizontal,
1101 EqualLength,
1102 Parallel,
1103 AngleBetween,
1104}
1105
1106#[allow(missing_docs)]
1108#[derive(
1109 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1110)]
1111#[serde(rename_all = "snake_case")]
1112#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1113#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1114#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1115#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1116pub enum PathCommand {
1117 MoveTo,
1118 LineTo,
1119 BezCurveTo,
1120 NurbsCurveTo,
1121 AddArc,
1122}
1123
1124#[allow(missing_docs)]
1126#[derive(
1127 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1128)]
1129#[serde(rename_all = "lowercase")]
1130#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1131#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1132#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1133#[repr(u8)]
1134#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1135pub enum EntityType {
1136 Entity,
1137 Object,
1138 Path,
1139 Segment,
1140 Curve,
1141 Solid2D,
1142 Solid3D,
1143 Edge,
1144 Face,
1145 Plane,
1146 Vertex,
1147 Region,
1148}
1149
1150#[allow(missing_docs)]
1152#[derive(
1153 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1154)]
1155#[serde(rename_all = "snake_case")]
1156#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1157#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1158#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1159#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1160pub enum CurveType {
1161 Line,
1162 Arc,
1163 Nurbs,
1164}
1165
1166#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1168#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
1169#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1170pub struct ExportFile {
1171 pub name: String,
1173 pub contents: crate::base64::Base64Data,
1175}
1176
1177#[cfg(feature = "python")]
1178#[pyo3_stub_gen::derive::gen_stub_pymethods]
1179#[pyo3::pymethods]
1180impl ExportFile {
1181 #[getter]
1182 fn contents(&self) -> Vec<u8> {
1183 self.contents.0.clone()
1184 }
1185
1186 #[getter]
1187 fn name(&self) -> String {
1188 self.name.clone()
1189 }
1190}
1191
1192#[derive(
1194 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1195)]
1196#[serde(rename_all = "lowercase")]
1197#[display(style = "lowercase")]
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(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
1202#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1203pub enum FileExportFormat {
1204 Fbx,
1206 Glb,
1213 Gltf,
1224 Obj,
1228 Ply,
1230 Step,
1232 Stl,
1234}
1235
1236#[derive(
1238 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1239)]
1240#[serde(rename_all = "lowercase")]
1241#[display(style = "lowercase")]
1242#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1243#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1244#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1245#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1246pub enum FileExportFormat2d {
1247 Dxf,
1249}
1250
1251#[derive(
1253 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1254)]
1255#[serde(rename_all = "lowercase")]
1256#[display(style = "lowercase")]
1257#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1258#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1259#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1260#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1261pub enum FileImportFormat {
1262 Fbx,
1264 Gltf,
1266 Obj,
1270 Ply,
1272 Sldprt,
1274 Step,
1276 Stl,
1278}
1279
1280#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
1282#[serde(rename_all = "snake_case")]
1283#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1284#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1285#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1286#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1287pub enum EngineErrorCode {
1288 BadRequest = 1,
1292 InternalEngine,
1294}
1295
1296impl From<EngineErrorCode> for http::StatusCode {
1297 fn from(e: EngineErrorCode) -> Self {
1298 match e {
1299 EngineErrorCode::BadRequest => Self::BAD_REQUEST,
1300 EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
1301 }
1302 }
1303}
1304
1305#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1307#[serde(rename_all = "snake_case")]
1308#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1309#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1310#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1311pub enum BlendType {
1312 #[default]
1314 Tangent,
1315}
1316
1317#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1319#[serde(rename_all = "snake_case")]
1320#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1321#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1322#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1323#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1324pub enum BodyType {
1325 #[default]
1327 Solid,
1328 Surface,
1330}
1331
1332#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1335#[serde(rename_all = "snake_case")]
1336#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1337#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1338#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1339#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1340pub enum ExtrudeMethod {
1341 New,
1344 #[default]
1347 Merge,
1348}
1349
1350#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1352#[serde(rename_all = "snake_case")]
1353#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1354#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1355#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1356#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1357pub enum ExtrudeReference {
1358 EntityReference {
1361 #[serde(default, skip_serializing_if = "Option::is_none")]
1363 entity_id: Option<Uuid>,
1364 #[serde(default, skip_serializing_if = "Option::is_none")]
1366 entity_reference: Option<EntityReference>,
1367 },
1368 Axis {
1370 axis: Point3d<f64>,
1372 #[serde(default)]
1375 point: Point3d<LengthUnit>,
1376 },
1377 Point {
1379 point: Point3d<LengthUnit>,
1381 },
1382}
1383
1384#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1386#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1387#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1388#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1389#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1390pub struct ExtrudedFaceInfo {
1391 pub bottom: Option<Uuid>,
1396 pub top: Uuid,
1398 pub sides: Vec<SideFace>,
1400}
1401
1402#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1404#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1405#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1406#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1407#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1408pub struct SideFace {
1409 pub path_id: Uuid,
1411 pub face_id: Uuid,
1413}
1414
1415#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1417#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1418#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1419#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1420#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1421pub struct CameraSettings {
1422 pub pos: Point3d,
1424
1425 pub center: Point3d,
1427
1428 pub up: Point3d,
1430
1431 pub orientation: Quaternion,
1433
1434 pub fov_y: Option<f32>,
1436
1437 pub ortho_scale: Option<f32>,
1439
1440 pub ortho: bool,
1442}
1443
1444#[allow(missing_docs)]
1445#[repr(u8)]
1446#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1447#[serde(rename_all = "snake_case")]
1448#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1449#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1450#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1451#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1452pub enum WorldCoordinateSystem {
1453 #[default]
1454 RightHandedUpZ,
1455 RightHandedUpY,
1456}
1457
1458#[allow(missing_docs)]
1459#[repr(C)]
1460#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1461#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1462#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1463#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1464#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1465pub struct CameraViewState {
1466 pub pivot_rotation: Quaternion,
1467 pub pivot_position: Point3d,
1468 pub eye_offset: f32,
1469 pub fov_y: f32,
1470 pub ortho_scale_factor: f32,
1471 pub is_ortho: bool,
1472 pub ortho_scale_enabled: bool,
1473 pub world_coord_system: WorldCoordinateSystem,
1474}
1475
1476impl Default for CameraViewState {
1477 fn default() -> Self {
1478 CameraViewState {
1479 pivot_rotation: Default::default(),
1480 pivot_position: Default::default(),
1481 eye_offset: 10.0,
1482 fov_y: 45.0,
1483 ortho_scale_factor: 1.6,
1484 is_ortho: false,
1485 ortho_scale_enabled: true,
1486 world_coord_system: Default::default(),
1487 }
1488 }
1489}
1490
1491#[cfg(feature = "cxx")]
1492impl_extern_type! {
1493 [Trivial]
1494 CameraViewState = "Endpoints::CameraViewState"
1495}
1496
1497impl From<CameraSettings> for crate::output::DefaultCameraZoom {
1498 fn from(settings: CameraSettings) -> Self {
1499 Self { settings }
1500 }
1501}
1502impl From<CameraSettings> for crate::output::CameraDragMove {
1503 fn from(settings: CameraSettings) -> Self {
1504 Self { settings }
1505 }
1506}
1507impl From<CameraSettings> for crate::output::CameraDragEnd {
1508 fn from(settings: CameraSettings) -> Self {
1509 Self { settings }
1510 }
1511}
1512impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
1513 fn from(settings: CameraSettings) -> Self {
1514 Self { settings }
1515 }
1516}
1517impl From<CameraSettings> for crate::output::ZoomToFit {
1518 fn from(settings: CameraSettings) -> Self {
1519 Self { settings }
1520 }
1521}
1522impl From<CameraSettings> for crate::output::OrientToFace {
1523 fn from(settings: CameraSettings) -> Self {
1524 Self { settings }
1525 }
1526}
1527impl From<CameraSettings> for crate::output::ViewIsometric {
1528 fn from(settings: CameraSettings) -> Self {
1529 Self { settings }
1530 }
1531}
1532
1533#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default, Builder)]
1535#[serde(rename_all = "snake_case")]
1536#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1537#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1538#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1539#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1540pub struct PerspectiveCameraParameters {
1541 pub fov_y: Option<f32>,
1543 pub z_near: Option<f32>,
1545 pub z_far: Option<f32>,
1547}
1548
1549#[derive(
1551 Default,
1552 Display,
1553 FromStr,
1554 Copy,
1555 Eq,
1556 PartialEq,
1557 Debug,
1558 JsonSchema,
1559 Deserialize,
1560 Serialize,
1561 Sequence,
1562 Clone,
1563 Ord,
1564 PartialOrd,
1565)]
1566#[serde(rename_all = "snake_case")]
1567#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1568#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1569#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1570#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1571pub enum CameraMovement {
1572 #[default]
1574 Vantage,
1575 None,
1577}
1578
1579#[derive(
1581 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1582)]
1583#[serde(rename_all = "lowercase")]
1584#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1585#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1586#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1587#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1588pub enum GlobalAxis {
1589 X,
1591 Y,
1593 Z,
1595}
1596
1597#[derive(
1599 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1600)]
1601#[serde(rename_all = "snake_case")]
1602#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1603#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1604#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1605#[repr(u8)]
1606#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1607pub enum ExtrusionFaceCapType {
1608 None,
1610 Top,
1612 Bottom,
1614 Both,
1616}
1617
1618#[allow(missing_docs)]
1620#[derive(
1621 Display,
1622 FromStr,
1623 Copy,
1624 Eq,
1625 PartialEq,
1626 Debug,
1627 JsonSchema,
1628 Deserialize,
1629 Serialize,
1630 Sequence,
1631 Clone,
1632 Ord,
1633 PartialOrd,
1634 Default,
1635)]
1636#[serde(rename_all = "lowercase")]
1637#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1638#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1639#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1640#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1641pub enum PostEffectType {
1642 Phosphor,
1643 Ssao,
1644 #[default]
1645 NoEffect,
1646}
1647
1648#[cfg(feature = "cxx")]
1651impl_extern_type! {
1652 [Trivial]
1653 FileImportFormat = "Enums::_FileImportFormat"
1655 FileExportFormat = "Enums::_FileExportFormat"
1656 CameraDragInteractionType = "Enums::_CameraDragInteractionType"
1658 SceneSelectionType = "Enums::_SceneSelectionType"
1660 SceneToolType = "Enums::_SceneToolType"
1661 BlendType = "Enums::_BlendType"
1662 BodyType = "Enums::_BodyType"
1663 EntityType = "Enums::_EntityType"
1664 AnnotationType = "Enums::_AnnotationType"
1665 AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
1666 AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
1667 AnnotationLineEnd = "Enums::_AnnotationLineEnd"
1668 MbdStandard = "Enums::_MBDStandard"
1669 MbdSymbol = "Enums::_MBDSymbol"
1670
1671 CurveType = "Enums::_CurveType"
1672 PathCommand = "Enums::_PathCommand"
1673 PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
1674 PathComponentConstraintType = "Enums::_PathComponentConstraintType"
1675 ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
1676
1677 EngineErrorCode = "Enums::_ErrorCode"
1679 GlobalAxis = "Enums::_GlobalAxis"
1680 OriginType = "Enums::_OriginType"
1681
1682 PostEffectType = "Enums::_PostEffectType"
1684}
1685
1686fn bool_true() -> bool {
1687 true
1688}
1689fn same_scale() -> Point3d<f64> {
1690 Point3d::uniform(1.0)
1691}
1692
1693fn z_axis() -> Point3d<f64> {
1694 Point3d { x: 0.0, y: 0.0, z: 1.0 }
1695}
1696
1697impl ExtrudedFaceInfo {
1698 pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
1701 let mut face_infos: Vec<_> = self
1702 .sides
1703 .into_iter()
1704 .map(|side| ExtrusionFaceInfo {
1705 curve_id: Some(side.path_id),
1706 face_id: Some(side.face_id),
1707 cap: ExtrusionFaceCapType::None,
1708 })
1709 .collect();
1710 face_infos.push(ExtrusionFaceInfo {
1711 curve_id: None,
1712 face_id: Some(self.top),
1713 cap: ExtrusionFaceCapType::Top,
1714 });
1715 if let Some(bottom) = self.bottom {
1716 face_infos.push(ExtrusionFaceInfo {
1717 curve_id: None,
1718 face_id: Some(bottom),
1719 cap: ExtrusionFaceCapType::Bottom,
1720 });
1721 }
1722 face_infos
1723 }
1724}
1725
1726#[cfg(test)]
1727mod tests {
1728 use super::*;
1729
1730 #[test]
1731 fn test_angle_comparison() {
1732 let a = Angle::from_degrees(90.0);
1733 assert!(a < Angle::from_degrees(91.0));
1734 assert!(a > Angle::from_degrees(89.0));
1735 assert!(a <= Angle::from_degrees(90.0));
1736 assert!(a >= Angle::from_degrees(90.0));
1737 let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
1738 assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
1739 assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
1740 assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1741 assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1742 assert!(a > b);
1744 assert!(a >= b);
1745 assert!(b < a);
1746 assert!(b <= a);
1747 let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
1748 assert!(a < c);
1749 assert!(a <= c);
1750 assert!(c > a);
1751 assert!(c >= a);
1752 }
1753}
1754
1755#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, JsonSchema, Builder)]
1757#[schemars(rename = "TransformByFor{T}")]
1758#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1759#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1760#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1761#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1762pub struct TransformBy<T> {
1763 pub property: T,
1765 pub set: bool,
1770 #[serde(default)]
1772 #[builder(default)]
1773 pub origin: OriginType,
1774}
1775
1776impl<T> TransformBy<T> {
1777 pub fn get_origin(&self) -> OriginType {
1781 self.origin
1782 }
1783}
1784
1785#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, Default, Builder)]
1788#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1789#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1790#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1791#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1792pub struct ComponentTransform {
1793 pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
1795 pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
1798 pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
1802 pub scale: Option<TransformBy<Point3d<f64>>>,
1804}
1805
1806#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
1809#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1810#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1811#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1812#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1813pub enum Opposite<T> {
1814 #[default]
1816 None,
1817 Symmetric,
1819 Other(T),
1821}
1822
1823impl<T: JsonSchema> JsonSchema for Opposite<T> {
1824 fn schema_name() -> String {
1825 format!("OppositeFor{}", T::schema_name())
1826 }
1827
1828 fn schema_id() -> std::borrow::Cow<'static, str> {
1829 std::borrow::Cow::Owned(format!("{}::Opposite<{}>", module_path!(), T::schema_id()))
1830 }
1831
1832 fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1833 SchemaObject {
1834 instance_type: Some(schemars::schema::InstanceType::String.into()),
1835 ..Default::default()
1836 }
1837 .into()
1838 }
1839}
1840
1841#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1844#[serde(rename_all = "snake_case")]
1845#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1846#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1847#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1848#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1849pub enum CutStrategy {
1850 Basic,
1853 Csg,
1856 #[default]
1858 Automatic,
1859}
1860
1861#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1863#[serde(rename_all = "snake_case")]
1864#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1865#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1866#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1867#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1868pub enum RelativeTo {
1869 #[default]
1871 SketchPlane,
1872 TrajectoryCurve,
1874}
1875
1876#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1878#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1879#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1880#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1881pub struct SelectedRegion {
1882 pub segment: Uuid,
1884 pub intersection_segment: Uuid,
1887 #[serde(default = "negative_one")]
1891 pub intersection_index: i32,
1892 #[serde(default)]
1895 pub curve_clockwise: bool,
1896}
1897
1898impl Default for SelectedRegion {
1899 fn default() -> Self {
1900 Self {
1901 segment: Default::default(),
1902 intersection_segment: Default::default(),
1903 intersection_index: -1,
1904 curve_clockwise: Default::default(),
1905 }
1906 }
1907}
1908
1909#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1911#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1912#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1913#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1914#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1915pub struct FractionOfEdge {
1916 #[serde(default, skip_serializing_if = "Option::is_none")]
1918 pub edge_id: Option<Uuid>,
1919 #[serde(default, skip_serializing_if = "Option::is_none")]
1921 pub edge_specifier: Option<EdgeSpecifier>,
1922 #[serde(default)]
1926 #[builder(default)]
1927 #[schemars(range(min = 0, max = 1))]
1928 pub lower_bound: f32,
1929 #[serde(default = "one")]
1933 #[builder(default = one())]
1934 #[schemars(range(min = 0, max = 1))]
1935 pub upper_bound: f32,
1936}
1937
1938#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1940#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1941#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1942#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1943#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1944pub struct SurfaceEdgeReference {
1945 pub object_id: Uuid,
1947 pub edges: Vec<FractionOfEdge>,
1949}
1950
1951#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1953#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1954#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1955#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1956#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1957pub struct BodiesCreated {
1958 pub bodies: Vec<BodyCreated>,
1960}
1961
1962impl BodiesCreated {
1963 pub fn is_empty(&self) -> bool {
1965 self.bodies.is_empty()
1966 }
1967}
1968
1969#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1971#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1972#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1973#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1974#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1975pub struct BodiesUpdated {
1976 pub bodies: Vec<BodyUpdated>,
1978}
1979
1980impl BodiesUpdated {
1981 pub fn is_empty(&self) -> bool {
1983 self.bodies.is_empty()
1984 }
1985}
1986
1987#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1989#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1990#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1991#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1992#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1993pub struct BodyCreated {
1994 pub id: Uuid,
1996 pub surfaces: Vec<SurfaceCreated>,
1998}
1999
2000#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2002#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2003#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2004#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2005#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2006pub struct BodyUpdated {
2007 pub id: Uuid,
2009 pub surfaces: Vec<SurfaceCreated>,
2011}
2012
2013#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2015#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2016#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2017#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2018#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2019pub struct SurfaceCreated {
2020 pub id: Uuid,
2022 pub primitive_face_index: u32,
2024 pub from_segments: Vec<Uuid>,
2026}
2027
2028#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2030#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2031#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2032#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2033#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2034pub enum RegionVersion {
2035 #[default]
2038 V0,
2039 V1,
2042}
2043
2044impl RegionVersion {
2045 pub fn is_zero(&self) -> bool {
2047 matches!(self, Self::V0)
2048 }
2049}
2050
2051impl From<BodyCreated> for BodyUpdated {
2052 fn from(body: BodyCreated) -> Self {
2053 Self {
2054 id: body.id,
2055 surfaces: body.surfaces,
2056 }
2057 }
2058}
2059
2060impl From<BodyUpdated> for BodyCreated {
2061 fn from(body: BodyUpdated) -> Self {
2062 Self {
2063 id: body.id,
2064 surfaces: body.surfaces,
2065 }
2066 }
2067}
2068
2069impl From<BodiesCreated> for BodiesUpdated {
2070 fn from(bodies: BodiesCreated) -> Self {
2071 Self {
2072 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2073 }
2074 }
2075}
2076
2077impl From<BodiesUpdated> for BodiesCreated {
2078 fn from(bodies: BodiesUpdated) -> Self {
2079 Self {
2080 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2081 }
2082 }
2083}
2084
2085fn one() -> f32 {
2086 1.0
2087}