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(
1169 feature = "python",
1170 pyo3::pyclass(from_py_object),
1171 pyo3_stub_gen::derive::gen_stub_pyclass
1172)]
1173#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1174pub struct ExportFile {
1175 pub name: String,
1177 pub contents: crate::base64::Base64Data,
1179}
1180
1181#[cfg(feature = "python")]
1182#[pyo3_stub_gen::derive::gen_stub_pymethods]
1183#[pyo3::pymethods]
1184impl ExportFile {
1185 #[getter]
1186 fn contents(&self) -> Vec<u8> {
1187 self.contents.0.clone()
1188 }
1189
1190 #[getter]
1191 fn name(&self) -> String {
1192 self.name.clone()
1193 }
1194}
1195
1196#[derive(
1198 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1199)]
1200#[serde(rename_all = "lowercase")]
1201#[display(style = "lowercase")]
1202#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1203#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1204#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1205#[cfg_attr(
1206 feature = "python",
1207 pyo3::pyclass(from_py_object),
1208 pyo3_stub_gen::derive::gen_stub_pyclass_enum
1209)]
1210#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1211pub enum FileExportFormat {
1212 Fbx,
1214 Glb,
1221 Gltf,
1232 Obj,
1236 Ply,
1238 Step,
1240 Stl,
1242}
1243
1244#[derive(
1246 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1247)]
1248#[serde(rename_all = "lowercase")]
1249#[display(style = "lowercase")]
1250#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1251#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1252#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1253#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1254pub enum FileExportFormat2d {
1255 Dxf,
1257}
1258
1259#[derive(
1261 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1262)]
1263#[serde(rename_all = "lowercase")]
1264#[display(style = "lowercase")]
1265#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1266#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1267#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1268#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1269pub enum FileImportFormat {
1270 Acis,
1272 Catia,
1274 Creo,
1276 Fbx,
1278 Gltf,
1280 Inventor,
1282 Nx,
1284 Obj,
1288 Parasolid,
1290 Ply,
1292 Sldprt,
1294 Step,
1296 Stl,
1298}
1299
1300#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
1302#[serde(rename_all = "snake_case")]
1303#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1304#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1305#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1306#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1307pub enum EngineErrorCode {
1308 BadRequest = 1,
1312 InternalEngine,
1314}
1315
1316impl From<EngineErrorCode> for http::StatusCode {
1317 fn from(e: EngineErrorCode) -> Self {
1318 match e {
1319 EngineErrorCode::BadRequest => Self::BAD_REQUEST,
1320 EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
1321 }
1322 }
1323}
1324
1325#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1327#[serde(rename_all = "snake_case")]
1328#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1329#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1330#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1331pub enum BlendType {
1332 #[default]
1334 Tangent,
1335}
1336
1337#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1339#[serde(rename_all = "snake_case")]
1340#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1341#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1342#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1343#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1344pub enum BodyType {
1345 #[default]
1347 Solid,
1348 Surface,
1350}
1351
1352#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1355#[serde(rename_all = "snake_case")]
1356#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1357#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1358#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1359#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1360pub enum ExtrudeMethod {
1361 New,
1364 #[default]
1367 Merge,
1368}
1369
1370#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1372#[serde(rename_all = "snake_case")]
1373#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1374#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1375#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1376#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1377pub enum ExtrudeReference {
1378 EntityReference {
1381 #[serde(default, skip_serializing_if = "Option::is_none")]
1383 entity_id: Option<Uuid>,
1384 #[serde(default, skip_serializing_if = "Option::is_none")]
1386 entity_reference: Option<EntityReference>,
1387 },
1388 Axis {
1390 axis: Point3d<f64>,
1392 #[serde(default)]
1395 point: Point3d<LengthUnit>,
1396 },
1397 Point {
1399 point: Point3d<LengthUnit>,
1401 },
1402}
1403
1404#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1406#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1407#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1408#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1409#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1410pub struct ExtrudedFaceInfo {
1411 pub bottom: Option<Uuid>,
1416 pub top: Uuid,
1418 pub sides: Vec<SideFace>,
1420}
1421
1422#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1424#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1425#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1426#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1427#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1428pub struct SideFace {
1429 pub path_id: Uuid,
1431 pub face_id: Uuid,
1433}
1434
1435#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1437#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1438#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1439#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1440#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1441pub struct CameraSettings {
1442 pub pos: Point3d,
1444
1445 pub center: Point3d,
1447
1448 pub up: Point3d,
1450
1451 pub orientation: Quaternion,
1453
1454 pub fov_y: Option<f32>,
1456
1457 pub ortho_scale: Option<f32>,
1459
1460 pub ortho: bool,
1462}
1463
1464#[allow(missing_docs)]
1465#[repr(u8)]
1466#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1467#[serde(rename_all = "snake_case")]
1468#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1469#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1470#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1471#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1472pub enum WorldCoordinateSystem {
1473 #[default]
1474 RightHandedUpZ,
1475 RightHandedUpY,
1476}
1477
1478#[allow(missing_docs)]
1479#[repr(C)]
1480#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1481#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1482#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1483#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1484#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1485pub struct CameraViewState {
1486 pub pivot_rotation: Quaternion,
1487 pub pivot_position: Point3d,
1488 pub eye_offset: f32,
1489 pub fov_y: f32,
1490 pub ortho_scale_factor: f32,
1491 pub is_ortho: bool,
1492 pub ortho_scale_enabled: bool,
1493 pub world_coord_system: WorldCoordinateSystem,
1494}
1495
1496impl Default for CameraViewState {
1497 fn default() -> Self {
1498 CameraViewState {
1499 pivot_rotation: Default::default(),
1500 pivot_position: Default::default(),
1501 eye_offset: 10.0,
1502 fov_y: 45.0,
1503 ortho_scale_factor: 1.6,
1504 is_ortho: false,
1505 ortho_scale_enabled: true,
1506 world_coord_system: Default::default(),
1507 }
1508 }
1509}
1510
1511#[cfg(feature = "cxx")]
1512impl_extern_type! {
1513 [Trivial]
1514 CameraViewState = "Endpoints::CameraViewState"
1515}
1516
1517impl From<CameraSettings> for crate::output::DefaultCameraZoom {
1518 fn from(settings: CameraSettings) -> Self {
1519 Self { settings }
1520 }
1521}
1522impl From<CameraSettings> for crate::output::CameraDragMove {
1523 fn from(settings: CameraSettings) -> Self {
1524 Self { settings }
1525 }
1526}
1527impl From<CameraSettings> for crate::output::CameraDragEnd {
1528 fn from(settings: CameraSettings) -> Self {
1529 Self { settings }
1530 }
1531}
1532impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
1533 fn from(settings: CameraSettings) -> Self {
1534 Self { settings }
1535 }
1536}
1537impl From<CameraSettings> for crate::output::ZoomToFit {
1538 fn from(settings: CameraSettings) -> Self {
1539 Self { settings }
1540 }
1541}
1542impl From<CameraSettings> for crate::output::OrientToFace {
1543 fn from(settings: CameraSettings) -> Self {
1544 Self { settings }
1545 }
1546}
1547impl From<CameraSettings> for crate::output::ViewIsometric {
1548 fn from(settings: CameraSettings) -> Self {
1549 Self { settings }
1550 }
1551}
1552
1553#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default, Builder)]
1555#[serde(rename_all = "snake_case")]
1556#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1557#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1558#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1559#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1560pub struct PerspectiveCameraParameters {
1561 pub fov_y: Option<f32>,
1563 pub z_near: Option<f32>,
1565 pub z_far: Option<f32>,
1567}
1568
1569#[derive(
1571 Default,
1572 Display,
1573 FromStr,
1574 Copy,
1575 Eq,
1576 PartialEq,
1577 Debug,
1578 JsonSchema,
1579 Deserialize,
1580 Serialize,
1581 Sequence,
1582 Clone,
1583 Ord,
1584 PartialOrd,
1585)]
1586#[serde(rename_all = "snake_case")]
1587#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1588#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1589#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1590#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1591pub enum CameraMovement {
1592 #[default]
1594 Vantage,
1595 None,
1597}
1598
1599#[derive(
1601 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1602)]
1603#[serde(rename_all = "lowercase")]
1604#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1605#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1606#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1607#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1608pub enum GlobalAxis {
1609 X,
1611 Y,
1613 Z,
1615}
1616
1617#[derive(
1619 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1620)]
1621#[serde(rename_all = "snake_case")]
1622#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1623#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1624#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1625#[repr(u8)]
1626#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1627pub enum ExtrusionFaceCapType {
1628 None,
1630 Top,
1632 Bottom,
1634 Both,
1636}
1637
1638#[allow(missing_docs)]
1640#[derive(
1641 Display,
1642 FromStr,
1643 Copy,
1644 Eq,
1645 PartialEq,
1646 Debug,
1647 JsonSchema,
1648 Deserialize,
1649 Serialize,
1650 Sequence,
1651 Clone,
1652 Ord,
1653 PartialOrd,
1654 Default,
1655)]
1656#[serde(rename_all = "lowercase")]
1657#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1658#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1659#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1660#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1661pub enum PostEffectType {
1662 Phosphor,
1663 Ssao,
1664 #[default]
1665 NoEffect,
1666}
1667
1668#[cfg(feature = "cxx")]
1671impl_extern_type! {
1672 [Trivial]
1673 FileImportFormat = "Enums::_FileImportFormat"
1675 FileExportFormat = "Enums::_FileExportFormat"
1676 CameraDragInteractionType = "Enums::_CameraDragInteractionType"
1678 SceneSelectionType = "Enums::_SceneSelectionType"
1680 SceneToolType = "Enums::_SceneToolType"
1681 BlendType = "Enums::_BlendType"
1682 BodyType = "Enums::_BodyType"
1683 EntityType = "Enums::_EntityType"
1684 AnnotationType = "Enums::_AnnotationType"
1685 AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
1686 AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
1687 AnnotationLineEnd = "Enums::_AnnotationLineEnd"
1688 MbdStandard = "Enums::_MBDStandard"
1689 MbdSymbol = "Enums::_MBDSymbol"
1690
1691 CurveType = "Enums::_CurveType"
1692 PathCommand = "Enums::_PathCommand"
1693 PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
1694 PathComponentConstraintType = "Enums::_PathComponentConstraintType"
1695 ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
1696
1697 EngineErrorCode = "Enums::_ErrorCode"
1699 GlobalAxis = "Enums::_GlobalAxis"
1700 OriginType = "Enums::_OriginType"
1701
1702 PostEffectType = "Enums::_PostEffectType"
1704}
1705
1706fn bool_true() -> bool {
1707 true
1708}
1709fn same_scale() -> Point3d<f64> {
1710 Point3d::uniform(1.0)
1711}
1712
1713fn z_axis() -> Point3d<f64> {
1714 Point3d { x: 0.0, y: 0.0, z: 1.0 }
1715}
1716
1717impl ExtrudedFaceInfo {
1718 pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
1721 let mut face_infos: Vec<_> = self
1722 .sides
1723 .into_iter()
1724 .map(|side| ExtrusionFaceInfo {
1725 curve_id: Some(side.path_id),
1726 face_id: Some(side.face_id),
1727 cap: ExtrusionFaceCapType::None,
1728 })
1729 .collect();
1730 face_infos.push(ExtrusionFaceInfo {
1731 curve_id: None,
1732 face_id: Some(self.top),
1733 cap: ExtrusionFaceCapType::Top,
1734 });
1735 if let Some(bottom) = self.bottom {
1736 face_infos.push(ExtrusionFaceInfo {
1737 curve_id: None,
1738 face_id: Some(bottom),
1739 cap: ExtrusionFaceCapType::Bottom,
1740 });
1741 }
1742 face_infos
1743 }
1744}
1745
1746#[cfg(test)]
1747mod tests {
1748 use super::*;
1749
1750 #[test]
1751 fn test_angle_comparison() {
1752 let a = Angle::from_degrees(90.0);
1753 assert!(a < Angle::from_degrees(91.0));
1754 assert!(a > Angle::from_degrees(89.0));
1755 assert!(a <= Angle::from_degrees(90.0));
1756 assert!(a >= Angle::from_degrees(90.0));
1757 let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
1758 assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
1759 assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
1760 assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1761 assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1762 assert!(a > b);
1764 assert!(a >= b);
1765 assert!(b < a);
1766 assert!(b <= a);
1767 let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
1768 assert!(a < c);
1769 assert!(a <= c);
1770 assert!(c > a);
1771 assert!(c >= a);
1772 }
1773}
1774
1775#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, JsonSchema, Builder)]
1777#[schemars(rename = "TransformByFor{T}")]
1778#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1779#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1780#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1781#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1782pub struct TransformBy<T> {
1783 pub property: T,
1785 pub set: bool,
1790 #[serde(default)]
1792 #[builder(default)]
1793 pub origin: OriginType,
1794}
1795
1796impl<T> TransformBy<T> {
1797 pub fn get_origin(&self) -> OriginType {
1801 self.origin
1802 }
1803}
1804
1805#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, Default, Builder)]
1808#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1809#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1810#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1811#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1812pub struct ComponentTransform {
1813 pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
1815 pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
1818 pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
1822 pub scale: Option<TransformBy<Point3d<f64>>>,
1824}
1825
1826#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
1829#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1830#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1831#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1832#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1833pub enum Opposite<T> {
1834 #[default]
1836 None,
1837 Symmetric,
1839 Other(T),
1841}
1842
1843impl<T: JsonSchema> JsonSchema for Opposite<T> {
1844 fn schema_name() -> String {
1845 format!("OppositeFor{}", T::schema_name())
1846 }
1847
1848 fn schema_id() -> std::borrow::Cow<'static, str> {
1849 std::borrow::Cow::Owned(format!("{}::Opposite<{}>", module_path!(), T::schema_id()))
1850 }
1851
1852 fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1853 SchemaObject {
1854 instance_type: Some(schemars::schema::InstanceType::String.into()),
1855 ..Default::default()
1856 }
1857 .into()
1858 }
1859}
1860
1861#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1864#[serde(rename_all = "snake_case")]
1865#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1866#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1867#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1868#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1869pub enum CutStrategy {
1870 Basic,
1873 Csg,
1876 #[default]
1878 Automatic,
1879}
1880
1881#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1883#[serde(rename_all = "snake_case")]
1884#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1885#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1886#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1887#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1888pub enum RelativeTo {
1889 #[default]
1891 SketchPlane,
1892 TrajectoryCurve,
1894}
1895
1896#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1898#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1899#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1900#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1901pub struct SelectedRegion {
1902 pub segment: Uuid,
1904 pub intersection_segment: Uuid,
1907 #[serde(default = "negative_one")]
1911 pub intersection_index: i32,
1912 #[serde(default)]
1915 pub curve_clockwise: bool,
1916}
1917
1918impl Default for SelectedRegion {
1919 fn default() -> Self {
1920 Self {
1921 segment: Default::default(),
1922 intersection_segment: Default::default(),
1923 intersection_index: -1,
1924 curve_clockwise: Default::default(),
1925 }
1926 }
1927}
1928
1929#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1931#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1932#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1933#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1934#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1935pub struct FractionOfEdge {
1936 #[serde(default, skip_serializing_if = "Option::is_none")]
1938 pub edge_id: Option<Uuid>,
1939 #[serde(default, skip_serializing_if = "Option::is_none")]
1941 pub edge_specifier: Option<EdgeSpecifier>,
1942 #[serde(default)]
1946 #[builder(default)]
1947 #[schemars(range(min = 0, max = 1))]
1948 pub lower_bound: f32,
1949 #[serde(default = "one")]
1953 #[builder(default = one())]
1954 #[schemars(range(min = 0, max = 1))]
1955 pub upper_bound: f32,
1956}
1957
1958#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1960#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1961#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1962#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1963#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1964pub struct SurfaceEdgeReference {
1965 pub object_id: Uuid,
1967 pub edges: Vec<FractionOfEdge>,
1969}
1970
1971#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1973#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1974#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1975#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1976#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1977pub struct BodiesCreated {
1978 pub bodies: Vec<BodyCreated>,
1980}
1981
1982impl BodiesCreated {
1983 pub fn is_empty(&self) -> bool {
1985 self.bodies.is_empty()
1986 }
1987}
1988
1989#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1991#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1992#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1993#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1994#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1995pub struct BodiesUpdated {
1996 pub bodies: Vec<BodyUpdated>,
1998}
1999
2000impl BodiesUpdated {
2001 pub fn is_empty(&self) -> bool {
2003 self.bodies.is_empty()
2004 }
2005}
2006
2007#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2009#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2010#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2011#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2012#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2013pub struct BodyCreated {
2014 pub id: Uuid,
2016 pub surfaces: Vec<SurfaceCreated>,
2018}
2019
2020#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2022#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2023#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2024#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2025#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2026pub struct BodyUpdated {
2027 pub id: Uuid,
2029 pub surfaces: Vec<SurfaceCreated>,
2031}
2032
2033#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2035#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2036#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2037#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2038#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2039pub struct SurfaceCreated {
2040 pub id: Uuid,
2042 pub primitive_face_index: u32,
2044 pub from_segments: Vec<Uuid>,
2046}
2047
2048#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2050#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2051#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2052#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2053#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2054pub enum RegionVersion {
2055 #[default]
2058 V0,
2059 V1,
2062}
2063
2064impl RegionVersion {
2065 pub fn is_zero(&self) -> bool {
2067 matches!(self, Self::V0)
2068 }
2069}
2070
2071impl From<BodyCreated> for BodyUpdated {
2072 fn from(body: BodyCreated) -> Self {
2073 Self {
2074 id: body.id,
2075 surfaces: body.surfaces,
2076 }
2077 }
2078}
2079
2080impl From<BodyUpdated> for BodyCreated {
2081 fn from(body: BodyUpdated) -> Self {
2082 Self {
2083 id: body.id,
2084 surfaces: body.surfaces,
2085 }
2086 }
2087}
2088
2089impl From<BodiesCreated> for BodiesUpdated {
2090 fn from(bodies: BodiesCreated) -> Self {
2091 Self {
2092 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2093 }
2094 }
2095}
2096
2097impl From<BodiesUpdated> for BodiesCreated {
2098 fn from(bodies: BodiesUpdated) -> Self {
2099 Self {
2100 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2101 }
2102 }
2103}
2104
2105fn one() -> f32 {
2106 1.0
2107}