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::{
12 def_enum::negative_one,
13 id::ModelingCmdId,
14 length_unit::LengthUnit,
15 output::ExtrusionFaceInfo,
16 units::{self, UnitAngle},
17};
18
19mod point;
20pub mod safe_filepath;
21
22#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
24#[serde(rename_all = "snake_case")]
25#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
26#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
27#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
28#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
29pub struct EdgeSpecifier {
30 pub side_faces: Vec<Uuid>,
32 #[serde(default, skip_serializing_if = "Vec::is_empty")]
34 #[builder(default)]
35 pub end_faces: Vec<Uuid>,
36 #[serde(skip_serializing_if = "Option::is_none")]
40 pub index: Option<u32>,
41}
42
43#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
59#[serde(rename_all = "snake_case")]
60#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
61#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
62#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
63#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
64pub struct PrimitiveTopologyFallback {
65 pub parent_id: Uuid,
67 pub primitive_index: u32,
69}
70
71#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
73#[serde(tag = "type", rename_all = "snake_case")]
74#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
75#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
76#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
77pub enum EntityReference {
78 Plane {
80 plane_id: Uuid,
82 #[serde(default, skip_serializing_if = "Option::is_none")]
84 topology_fallback: Option<PrimitiveTopologyFallback>,
85 },
86 Face {
88 face_id: Uuid,
90 #[serde(default, skip_serializing_if = "Option::is_none")]
92 topology_fallback: Option<PrimitiveTopologyFallback>,
93 },
94 Edge {
96 #[serde(flatten)]
98 inner: EdgeSpecifier,
99 #[serde(default, skip_serializing_if = "Option::is_none")]
101 topology_fallback: Option<PrimitiveTopologyFallback>,
102 },
103 Vertex {
105 side_faces: Vec<Uuid>,
107 #[serde(skip_serializing_if = "Option::is_none")]
109 index: Option<u32>,
110 #[serde(default, skip_serializing_if = "Option::is_none")]
112 topology_fallback: Option<PrimitiveTopologyFallback>,
113 },
114 Solid2d {
116 solid2d_id: Uuid,
118 #[serde(default, skip_serializing_if = "Option::is_none")]
120 topology_fallback: Option<PrimitiveTopologyFallback>,
121 },
122 Solid3d {
124 solid3d_id: Uuid,
126 #[serde(default, skip_serializing_if = "Option::is_none")]
128 topology_fallback: Option<PrimitiveTopologyFallback>,
129 },
130 Solid2dEdge {
133 edge_id: Uuid,
135 #[serde(default, skip_serializing_if = "Option::is_none")]
137 topology_fallback: Option<PrimitiveTopologyFallback>,
138 },
139 Segment {
141 path_id: Uuid,
143 segment_id: Uuid,
145 #[serde(default, skip_serializing_if = "Option::is_none")]
147 topology_fallback: Option<PrimitiveTopologyFallback>,
148 },
149 Region {
151 region_id: Uuid,
153 #[serde(default, skip_serializing_if = "Option::is_none")]
155 topology_fallback: Option<PrimitiveTopologyFallback>,
156 },
157}
158
159#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
161#[serde(rename_all = "snake_case")]
162#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
163#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
164#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
165pub enum CutType {
166 #[default]
168 Fillet,
169 Chamfer,
171}
172
173#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
175#[serde(rename_all = "snake_case")]
176#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
177#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
178#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
179pub enum DirectionType {
180 Edge {
182 id: Uuid,
184 },
185 Axis {
187 direction: Point3d<f64>,
189 },
190}
191
192#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
194#[serde(rename_all = "snake_case")]
195#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
196#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
197#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
198pub enum MirrorAcross {
199 Edge {
202 id: Uuid,
204 },
205 EdgeReference {
208 reference: EdgeSpecifier,
210 },
211 Axis {
214 axis: Point3d<f64>,
216 point: Point3d<LengthUnit>,
218 },
219 Plane {
222 id: Uuid,
224 },
225}
226
227#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
229#[serde(rename_all = "snake_case")]
230#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
231#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
232#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
233#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
234pub enum CutTypeV2 {
235 Fillet {
237 radius: LengthUnit,
239 second_length: Option<LengthUnit>,
242 },
243 Chamfer {
245 distance: LengthUnit,
247 second_distance: Option<LengthUnit>,
249 angle: Option<Angle>,
251 swap: bool,
253 },
254 Custom {
256 path: Uuid,
258 },
259}
260
261#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
263#[serde(rename_all = "snake_case")]
264#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
265#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
266#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
267#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
268pub struct Rotation {
269 pub axis: Point3d<f64>,
272 pub angle: Angle,
275 pub origin: OriginType,
277}
278
279impl Default for Rotation {
280 fn default() -> Self {
282 Self {
283 axis: z_axis(),
284 angle: Angle::default(),
285 origin: OriginType::Local,
286 }
287 }
288}
289
290#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
292#[serde(rename_all = "snake_case")]
293#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
294#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
295#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
296#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
297pub struct Transform {
298 #[serde(default)]
301 #[builder(default)]
302 pub translate: Point3d<LengthUnit>,
303 #[serde(default = "same_scale")]
306 #[builder(default = same_scale())]
307 pub scale: Point3d<f64>,
308 #[serde(default)]
311 #[builder(default)]
312 pub rotation: Rotation,
313 #[serde(default = "bool_true")]
315 #[builder(default = bool_true())]
316 pub replicate: bool,
317}
318
319impl Default for Transform {
320 fn default() -> Self {
321 Self {
322 scale: same_scale(),
323 replicate: true,
324 translate: Default::default(),
325 rotation: Rotation::default(),
326 }
327 }
328}
329
330#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
332#[serde(rename_all = "snake_case")]
333#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
334#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
335#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
336#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
337pub struct AnnotationOptions {
338 pub text: Option<AnnotationTextOptions>,
340 pub line_ends: Option<AnnotationLineEndOptions>,
342 pub line_width: Option<f32>,
344 pub color: Option<Color>,
346 pub position: Option<Point3d<f32>>,
348 #[serde(default, skip_serializing_if = "Option::is_none")]
350 pub units: Option<units::UnitLength>,
351 pub dimension: Option<AnnotationBasicDimension>,
353 pub feature_control: Option<AnnotationFeatureControl>,
355 pub feature_tag: Option<AnnotationFeatureTag>,
357}
358
359#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
361#[serde(rename_all = "snake_case")]
362#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
363#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
364#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
365#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
366pub struct AnnotationLineEndOptions {
367 pub start: AnnotationLineEnd,
369 pub end: AnnotationLineEnd,
371}
372
373#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
375#[serde(rename_all = "snake_case")]
376#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
377#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
378#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
379#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
380pub struct AnnotationTextOptions {
381 pub x: AnnotationTextAlignmentX,
383 pub y: AnnotationTextAlignmentY,
385 pub text: String,
387 pub point_size: u32,
389}
390
391#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
393#[serde(rename_all = "snake_case")]
394#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
395#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
396#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
397#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
398pub struct AnnotationMbdControlFrame {
399 pub symbol: MbdSymbol,
401 pub diameter_symbol: Option<MbdSymbol>,
403 pub tolerance: f64,
405 pub modifier: Option<MbdSymbol>,
407 pub primary_datum: Option<char>,
409 pub secondary_datum: Option<char>,
411 pub tertiary_datum: Option<char>,
413}
414
415#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
417#[serde(rename_all = "snake_case")]
418#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
419#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
420#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
421#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
422pub struct AnnotationMbdBasicDimension {
423 pub symbol: Option<MbdSymbol>,
425 pub dimension: Option<f64>,
427 pub tolerance: f64,
429}
430
431#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
433#[serde(rename_all = "snake_case")]
434#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
435#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
436#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
437#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
438pub struct AnnotationBasicDimension {
439 #[serde(default, skip_serializing_if = "Option::is_none")]
441 pub from_entity_id: Option<Uuid>,
442
443 #[serde(default, skip_serializing_if = "Option::is_none")]
446 pub from_edge_reference: Option<EdgeSpecifier>,
447
448 pub from_entity_pos: Point2d<f64>,
450
451 #[serde(default, skip_serializing_if = "Option::is_none")]
453 pub to_entity_id: Option<Uuid>,
454
455 #[serde(default, skip_serializing_if = "Option::is_none")]
458 pub to_edge_reference: Option<EdgeSpecifier>,
459
460 pub to_entity_pos: Point2d<f64>,
462
463 pub dimension: AnnotationMbdBasicDimension,
465
466 pub plane_id: Uuid,
468
469 pub offset: Point2d<f64>,
471
472 pub precision: u32,
474
475 pub font_scale: f32,
477
478 pub font_point_size: u32,
480
481 #[serde(default = "one")]
483 pub arrow_scale: f32,
484}
485
486#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
488#[serde(rename_all = "snake_case")]
489#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
490#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
491#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
492#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
493pub struct AnnotationFeatureControl {
494 #[serde(default, skip_serializing_if = "Option::is_none")]
496 pub entity_id: Option<Uuid>,
497
498 #[serde(default, skip_serializing_if = "Option::is_none")]
501 pub edge_reference: Option<EdgeSpecifier>,
502
503 pub entity_pos: Point2d<f64>,
505
506 pub leader_type: AnnotationLineEnd,
508
509 pub dimension: Option<AnnotationMbdBasicDimension>,
511
512 pub control_frame: Option<AnnotationMbdControlFrame>,
514
515 pub defined_datum: Option<char>,
517
518 pub prefix: Option<String>,
520
521 pub suffix: Option<String>,
523
524 pub plane_id: Uuid,
526
527 pub offset: Point2d<f64>,
529
530 pub precision: u32,
532
533 pub font_scale: f32,
535
536 pub font_point_size: u32,
538
539 #[serde(default = "one")]
541 pub leader_scale: f32,
542}
543
544#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
546#[serde(rename_all = "snake_case")]
547#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
548#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
549#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
550#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
551pub struct AnnotationFeatureTag {
552 #[serde(default, skip_serializing_if = "Option::is_none")]
554 pub entity_id: Option<Uuid>,
555
556 #[serde(default, skip_serializing_if = "Option::is_none")]
559 pub edge_reference: Option<EdgeSpecifier>,
560
561 pub entity_pos: Point2d<f64>,
563
564 pub leader_type: AnnotationLineEnd,
566
567 pub key: String,
569
570 pub value: String,
572
573 pub show_key: bool,
575
576 pub plane_id: Uuid,
578
579 pub offset: Point2d<f64>,
581
582 pub font_scale: f32,
584
585 pub font_point_size: u32,
587
588 #[serde(default = "one")]
590 pub leader_scale: f32,
591}
592
593#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
597#[serde(rename_all = "snake_case", tag = "type")]
598#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
599#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
600#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
601#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
602pub enum DistanceType {
603 Euclidean {},
605 OnAxis {
607 axis: GlobalAxis,
609 },
610}
611
612#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
614#[serde(rename_all = "snake_case", tag = "type")]
615#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
616#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
617#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
618#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
619pub enum OriginType {
620 #[default]
622 Local,
623 Global,
625 Custom {
627 origin: Point3d<f64>,
629 },
630}
631
632#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
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 struct Color {
639 pub r: f32,
641 pub g: f32,
643 pub b: f32,
645 pub a: f32,
647}
648
649impl Color {
650 pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
652 Self { r, g, b, a }
653 }
654}
655
656#[allow(missing_docs)]
658#[derive(
659 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
660)]
661#[serde(rename_all = "lowercase")]
662#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
663#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
664#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
665#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
666pub enum AnnotationTextAlignmentX {
667 Left,
668 Center,
669 Right,
670}
671
672#[allow(missing_docs)]
674#[derive(
675 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
676)]
677#[serde(rename_all = "lowercase")]
678#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
679#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
680#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
681#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
682pub enum AnnotationTextAlignmentY {
683 Bottom,
684 Center,
685 Top,
686}
687
688#[allow(missing_docs)]
690#[derive(
691 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, 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#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
698pub enum AnnotationLineEnd {
699 None,
700 Arrow,
701 Dot,
702}
703
704#[derive(
706 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
707)]
708#[serde(rename_all = "lowercase")]
709#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
710#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
711#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
712#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
713pub enum AnnotationType {
714 T2D,
716 T3D,
718}
719
720#[derive(
722 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
723)]
724#[serde(rename_all = "lowercase")]
725#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
726#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
727#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
728#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
729pub enum MbdStandard {
730 AsmeY14_5,
732}
733
734#[allow(missing_docs)]
737#[derive(
738 Default,
739 Display,
740 FromStr,
741 Copy,
742 Eq,
743 PartialEq,
744 Debug,
745 JsonSchema,
746 Deserialize,
747 Serialize,
748 Sequence,
749 Clone,
750 Ord,
751 PartialOrd,
752)]
753#[serde(rename_all = "lowercase")]
754#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
755#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
756#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
757#[repr(u16)]
758#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
759pub enum MbdSymbol {
760 #[default]
761 None = 0,
762 ArcLength = 174,
763 Between = 175,
764 Degrees = 176,
765 PlusMinus = 177,
766 Angularity = 178,
767 Cylindricity = 179,
768 Roundness = 180,
769 Concentricity = 181,
770 Straightness = 182,
771 Parallelism = 183,
772 Flatness = 184,
773 ProfileOfLine = 185,
774 SurfaceProfile = 186,
775 Symmetry = 187,
776 Perpendicularity = 188,
777 Runout = 189,
778 TotalRunout = 190,
779 Position = 191,
780 CenterLine = 192,
781 PartingLine = 193,
782 IsoEnvelope = 195,
783 IsoEnvelopeNonY145M = 196,
784 FreeState = 197,
785 StatisticalTolerance = 198,
786 ContinuousFeature = 199,
787 Independency = 200,
788 Depth = 201,
789 Start = 202,
790 LeastCondition = 203,
791 MaxCondition = 204,
792 ConicalTaper = 205,
793 Projected = 206,
794 Slope = 207,
795 Micro = 208,
796 TangentPlane = 210,
797 Unilateral = 211,
798 SquareFeature = 212,
799 Countersink = 213,
800 SpotFace = 214,
801 Target = 215,
802 Diameter = 216,
803 Radius = 217,
804 SphericalRadius = 218,
805 SphericalDiameter = 219,
806 ControlledRadius = 220,
807 BoxStart = 123,
808 BoxBar = 162,
809 BoxBarBetween = 124,
810 LetterBackwardUnderline = 95,
811 PunctuationBackwardUnderline = 92,
812 ModifierBackwardUnderline = 126,
813 NumericBackwardUnderline = 96,
814 BoxEnd = 125,
815 DatumUp = 166,
816 DatumLeft = 168,
817 DatumRight = 167,
818 DatumDown = 165,
819 DatumTriangle = 295,
820 HalfSpace = 236,
821 QuarterSpace = 237,
822 EighthSpace = 238,
823 ModifierSpace = 239,
824}
825
826#[derive(
828 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
829)]
830#[serde(rename_all = "lowercase")]
831#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
832#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
833#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
834#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
835pub enum CameraDragInteractionType {
836 Pan,
838 Rotate,
840 RotateTrackball,
842 Zoom,
844}
845
846#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
849#[serde(rename_all = "snake_case", tag = "type")]
850#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
851#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
852#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
853#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
854pub enum PathSegment {
855 Line {
858 end: Point3d<LengthUnit>,
860 relative: bool,
862 },
863 Arc {
866 center: Point2d<LengthUnit>,
868 radius: LengthUnit,
870 start: Angle,
872 end: Angle,
874 relative: bool,
876 },
877 Bezier {
881 control1: Point3d<LengthUnit>,
883 control2: Point3d<LengthUnit>,
885 end: Point3d<LengthUnit>,
887 relative: bool,
889 },
890 TangentialArc {
892 radius: LengthUnit,
895 offset: Angle,
897 },
898 TangentialArcTo {
901 to: Point3d<LengthUnit>,
905 angle_snap_increment: Option<Angle>,
907 },
908 ArcTo {
910 interior: Point3d<LengthUnit>,
912 end: Point3d<LengthUnit>,
914 relative: bool,
916 },
917 CircularInvolute {
920 start_radius: LengthUnit,
923 end_radius: LengthUnit,
926 angle: Angle,
929 reverse: bool,
932 },
933 Ellipse {
935 center: Point2d<LengthUnit>,
937 major_axis: Point2d<LengthUnit>,
939 minor_radius: LengthUnit,
941 start_angle: Angle,
943 end_angle: Angle,
945 },
946 ConicTo {
949 interior: Point2d<LengthUnit>,
951 end: Point2d<LengthUnit>,
953 start_tangent: Point2d<LengthUnit>,
955 end_tangent: Point2d<LengthUnit>,
957 relative: bool,
959 },
960}
961
962#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
964#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
965#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
966#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
967#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
968pub struct Angle {
969 pub unit: UnitAngle,
971 pub value: f64,
973}
974
975impl Angle {
976 pub fn to_degrees(self) -> f64 {
978 match self.unit {
979 UnitAngle::Degrees => self.value,
980 UnitAngle::Radians => self.value.to_degrees(),
981 }
982 }
983 pub fn to_radians(self) -> f64 {
985 match self.unit {
986 UnitAngle::Degrees => self.value.to_radians(),
987 UnitAngle::Radians => self.value,
988 }
989 }
990 pub const fn from_degrees(value: f64) -> Self {
992 Self {
993 unit: UnitAngle::Degrees,
994 value,
995 }
996 }
997 pub const fn from_radians(value: f64) -> Self {
999 Self {
1000 unit: UnitAngle::Radians,
1001 value,
1002 }
1003 }
1004 pub const fn turn() -> Self {
1006 Self::from_degrees(360.0)
1007 }
1008 pub const fn half_circle() -> Self {
1010 Self::from_degrees(180.0)
1011 }
1012 pub const fn quarter_circle() -> Self {
1014 Self::from_degrees(90.0)
1015 }
1016 pub const fn zero() -> Self {
1018 Self::from_degrees(0.0)
1019 }
1020}
1021
1022impl Default for Angle {
1024 fn default() -> Self {
1026 Self::zero()
1027 }
1028}
1029
1030impl PartialOrd for Angle {
1031 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
1032 match (self.unit, other.unit) {
1033 (UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
1035 (UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
1036 _ => self.to_degrees().partial_cmp(&other.to_degrees()),
1037 }
1038 }
1039}
1040
1041impl std::ops::Add for Angle {
1042 type Output = Self;
1043
1044 fn add(self, rhs: Self) -> Self::Output {
1045 Self {
1046 unit: UnitAngle::Degrees,
1047 value: self.to_degrees() + rhs.to_degrees(),
1048 }
1049 }
1050}
1051
1052impl std::ops::AddAssign for Angle {
1053 fn add_assign(&mut self, rhs: Self) {
1054 match self.unit {
1055 UnitAngle::Degrees => {
1056 self.value += rhs.to_degrees();
1057 }
1058 UnitAngle::Radians => {
1059 self.value += rhs.to_radians();
1060 }
1061 }
1062 }
1063}
1064
1065#[derive(
1067 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1068)]
1069#[serde(rename_all = "lowercase")]
1070#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1071#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1072#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1073#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1074pub enum SceneSelectionType {
1075 Replace,
1077 Add,
1079 Remove,
1081}
1082
1083#[allow(missing_docs)]
1085#[derive(
1086 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1087)]
1088#[serde(rename_all = "snake_case")]
1089#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1090#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1091#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1092#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1093pub enum SceneToolType {
1094 CameraRevolve,
1095 Select,
1096 Move,
1097 SketchLine,
1098 SketchTangentialArc,
1099 SketchCurve,
1100 SketchCurveMod,
1101}
1102
1103#[allow(missing_docs)]
1105#[derive(
1106 Display,
1107 FromStr,
1108 Copy,
1109 Eq,
1110 PartialEq,
1111 Debug,
1112 JsonSchema,
1113 Deserialize,
1114 Serialize,
1115 Sequence,
1116 Clone,
1117 Ord,
1118 PartialOrd,
1119 Default,
1120)]
1121#[serde(rename_all = "snake_case")]
1122#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1123#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1124#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1125#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1126pub enum PathComponentConstraintBound {
1127 #[default]
1128 Unconstrained,
1129 PartiallyConstrained,
1130 FullyConstrained,
1131}
1132
1133#[allow(missing_docs)]
1135#[derive(
1136 Display,
1137 FromStr,
1138 Copy,
1139 Eq,
1140 PartialEq,
1141 Debug,
1142 JsonSchema,
1143 Deserialize,
1144 Serialize,
1145 Sequence,
1146 Clone,
1147 Ord,
1148 PartialOrd,
1149 Default,
1150)]
1151#[serde(rename_all = "snake_case")]
1152#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1153#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1154#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1155#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1156pub enum PathComponentConstraintType {
1157 #[default]
1158 Unconstrained,
1159 Vertical,
1160 Horizontal,
1161 EqualLength,
1162 Parallel,
1163 AngleBetween,
1164}
1165
1166#[allow(missing_docs)]
1168#[derive(
1169 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1170)]
1171#[serde(rename_all = "snake_case")]
1172#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1173#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1174#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1175#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1176pub enum PathCommand {
1177 MoveTo,
1178 LineTo,
1179 BezCurveTo,
1180 NurbsCurveTo,
1181 AddArc,
1182}
1183
1184#[allow(missing_docs)]
1186#[derive(
1187 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1188)]
1189#[serde(rename_all = "lowercase")]
1190#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1191#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1192#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1193#[repr(u8)]
1194#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1195pub enum EntityType {
1196 Entity,
1197 Object,
1198 Path,
1199 Segment,
1200 Curve,
1201 Solid2D,
1202 Solid3D,
1203 Edge,
1204 Face,
1205 Plane,
1206 Vertex,
1207 Region,
1208}
1209
1210#[allow(missing_docs)]
1212#[derive(
1213 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1214)]
1215#[serde(rename_all = "snake_case")]
1216#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1217#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1218#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1219#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1220pub enum CurveType {
1221 Line,
1222 Arc,
1223 Nurbs,
1224}
1225
1226#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1228#[cfg_attr(
1229 feature = "python",
1230 pyo3::pyclass(from_py_object),
1231 pyo3_stub_gen::derive::gen_stub_pyclass
1232)]
1233#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1234pub struct ExportFile {
1235 pub name: String,
1237 pub contents: crate::base64::Base64Data,
1239}
1240
1241#[cfg(feature = "python")]
1242#[pyo3_stub_gen::derive::gen_stub_pymethods]
1243#[pyo3::pymethods]
1244impl ExportFile {
1245 #[getter]
1246 fn contents(&self) -> Vec<u8> {
1247 self.contents.0.clone()
1248 }
1249
1250 #[getter]
1251 fn name(&self) -> String {
1252 self.name.clone()
1253 }
1254}
1255
1256#[derive(
1258 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1259)]
1260#[serde(rename_all = "lowercase")]
1261#[display(style = "lowercase")]
1262#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1263#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1264#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1265#[cfg_attr(
1266 feature = "python",
1267 pyo3::pyclass(from_py_object),
1268 pyo3_stub_gen::derive::gen_stub_pyclass_enum
1269)]
1270#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1271pub enum FileExportFormat {
1272 Fbx,
1274 Glb,
1281 Gltf,
1292 Obj,
1296 Ply,
1298 Step,
1300 Stl,
1302}
1303
1304#[derive(
1306 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1307)]
1308#[serde(rename_all = "lowercase")]
1309#[display(style = "lowercase")]
1310#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1311#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1312#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1313#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1314pub enum FileExportFormat2d {
1315 Dxf,
1317}
1318
1319#[derive(
1321 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1322)]
1323#[serde(rename_all = "lowercase")]
1324#[display(style = "lowercase")]
1325#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1326#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1327#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1328#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1329pub enum FileImportFormat {
1330 Acis,
1332 Catia,
1334 Creo,
1336 Fbx,
1338 Gltf,
1340 Inventor,
1342 Nx,
1344 Obj,
1348 Parasolid,
1350 Ply,
1352 Sldprt,
1354 Step,
1356 Stl,
1358}
1359
1360#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
1362#[serde(rename_all = "snake_case")]
1363#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1364#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1365#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1366#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1367pub enum EngineErrorCode {
1368 BadRequest = 1,
1372 InternalEngine,
1374}
1375
1376impl From<EngineErrorCode> for http::StatusCode {
1377 fn from(e: EngineErrorCode) -> Self {
1378 match e {
1379 EngineErrorCode::BadRequest => Self::BAD_REQUEST,
1380 EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
1381 }
1382 }
1383}
1384
1385#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1387#[serde(rename_all = "snake_case")]
1388#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1389#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1390#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1391pub enum BlendType {
1392 #[default]
1394 Tangent,
1395}
1396
1397#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1399#[serde(rename_all = "snake_case")]
1400#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1401#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1402#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1403#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1404pub enum BodyType {
1405 #[default]
1407 Solid,
1408 Surface,
1410}
1411
1412#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1415#[serde(rename_all = "snake_case")]
1416#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1417#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1418#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1419#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1420pub enum ExtrudeMethod {
1421 New,
1424 #[default]
1427 Merge,
1428}
1429
1430#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1432#[serde(rename_all = "snake_case")]
1433#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1434#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1435#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1436#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1437pub enum ExtrudeReference {
1438 EntityReference {
1441 #[serde(default, skip_serializing_if = "Option::is_none")]
1443 entity_id: Option<Uuid>,
1444 #[serde(default, skip_serializing_if = "Option::is_none")]
1446 entity_reference: Option<EntityReference>,
1447 },
1448 Axis {
1450 axis: Point3d<f64>,
1452 #[serde(default)]
1455 point: Point3d<LengthUnit>,
1456 },
1457 Point {
1459 point: Point3d<LengthUnit>,
1461 },
1462}
1463
1464#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1466#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1467#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1468#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1469#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1470pub struct ExtrudedFaceInfo {
1471 pub bottom: Option<Uuid>,
1476 pub top: Uuid,
1478 pub sides: Vec<SideFace>,
1480}
1481
1482#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1484#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1485#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1486#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1487#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1488pub struct SideFace {
1489 pub path_id: Uuid,
1491 pub face_id: Uuid,
1493}
1494
1495#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1497#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1498#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1499#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1500#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1501pub struct CameraSettings {
1502 pub pos: Point3d,
1504
1505 pub center: Point3d,
1507
1508 pub up: Point3d,
1510
1511 pub orientation: Quaternion,
1513
1514 pub fov_y: Option<f32>,
1516
1517 pub ortho_scale: Option<f32>,
1519
1520 pub ortho: bool,
1522}
1523
1524#[allow(missing_docs)]
1525#[repr(u8)]
1526#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1527#[serde(rename_all = "snake_case")]
1528#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1529#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1530#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1531#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1532pub enum WorldCoordinateSystem {
1533 #[default]
1534 RightHandedUpZ,
1535 RightHandedUpY,
1536}
1537
1538#[allow(missing_docs)]
1539#[repr(C)]
1540#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1541#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1542#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1543#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1544#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1545pub struct CameraViewState {
1546 pub pivot_rotation: Quaternion,
1547 pub pivot_position: Point3d,
1548 pub eye_offset: f32,
1549 pub fov_y: f32,
1550 pub ortho_scale_factor: f32,
1551 pub is_ortho: bool,
1552 pub ortho_scale_enabled: bool,
1553 pub world_coord_system: WorldCoordinateSystem,
1554}
1555
1556impl Default for CameraViewState {
1557 fn default() -> Self {
1558 CameraViewState {
1559 pivot_rotation: Default::default(),
1560 pivot_position: Default::default(),
1561 eye_offset: 10.0,
1562 fov_y: 45.0,
1563 ortho_scale_factor: 1.6,
1564 is_ortho: false,
1565 ortho_scale_enabled: true,
1566 world_coord_system: Default::default(),
1567 }
1568 }
1569}
1570
1571#[cfg(feature = "cxx")]
1572impl_extern_type! {
1573 [Trivial]
1574 CameraViewState = "Endpoints::CameraViewState"
1575}
1576
1577impl From<CameraSettings> for crate::output::DefaultCameraZoom {
1578 fn from(settings: CameraSettings) -> Self {
1579 Self { settings }
1580 }
1581}
1582impl From<CameraSettings> for crate::output::CameraDragMove {
1583 fn from(settings: CameraSettings) -> Self {
1584 Self { settings }
1585 }
1586}
1587impl From<CameraSettings> for crate::output::CameraDragEnd {
1588 fn from(settings: CameraSettings) -> Self {
1589 Self { settings }
1590 }
1591}
1592impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
1593 fn from(settings: CameraSettings) -> Self {
1594 Self { settings }
1595 }
1596}
1597impl From<CameraSettings> for crate::output::ZoomToFit {
1598 fn from(settings: CameraSettings) -> Self {
1599 Self { settings }
1600 }
1601}
1602impl From<CameraSettings> for crate::output::OrientToFace {
1603 fn from(settings: CameraSettings) -> Self {
1604 Self { settings }
1605 }
1606}
1607impl From<CameraSettings> for crate::output::ViewIsometric {
1608 fn from(settings: CameraSettings) -> Self {
1609 Self { settings }
1610 }
1611}
1612
1613#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default, Builder)]
1615#[serde(rename_all = "snake_case")]
1616#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1617#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1618#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1619#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1620pub struct PerspectiveCameraParameters {
1621 pub fov_y: Option<f32>,
1623 pub z_near: Option<f32>,
1625 pub z_far: Option<f32>,
1627}
1628
1629#[derive(
1631 Default,
1632 Display,
1633 FromStr,
1634 Copy,
1635 Eq,
1636 PartialEq,
1637 Debug,
1638 JsonSchema,
1639 Deserialize,
1640 Serialize,
1641 Sequence,
1642 Clone,
1643 Ord,
1644 PartialOrd,
1645)]
1646#[serde(rename_all = "snake_case")]
1647#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1648#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1649#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1650#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1651pub enum CameraMovement {
1652 #[default]
1654 Vantage,
1655 None,
1657}
1658
1659#[derive(
1661 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1662)]
1663#[serde(rename_all = "lowercase")]
1664#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1665#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1666#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1667#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1668pub enum GlobalAxis {
1669 X,
1671 Y,
1673 Z,
1675}
1676
1677#[derive(
1679 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1680)]
1681#[serde(rename_all = "snake_case")]
1682#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1683#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1684#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1685#[repr(u8)]
1686#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1687pub enum ExtrusionFaceCapType {
1688 None,
1690 Top,
1692 Bottom,
1694 Both,
1696}
1697
1698#[allow(missing_docs)]
1700#[derive(
1701 Display,
1702 FromStr,
1703 Copy,
1704 Eq,
1705 PartialEq,
1706 Debug,
1707 JsonSchema,
1708 Deserialize,
1709 Serialize,
1710 Sequence,
1711 Clone,
1712 Ord,
1713 PartialOrd,
1714 Default,
1715)]
1716#[serde(rename_all = "lowercase")]
1717#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1718#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1719#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1720#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1721pub enum PostEffectType {
1722 Phosphor,
1723 Ssao,
1724 #[default]
1725 NoEffect,
1726}
1727
1728#[cfg(feature = "cxx")]
1731impl_extern_type! {
1732 [Trivial]
1733 FileImportFormat = "Enums::_FileImportFormat"
1735 FileExportFormat = "Enums::_FileExportFormat"
1736 CameraDragInteractionType = "Enums::_CameraDragInteractionType"
1738 SceneSelectionType = "Enums::_SceneSelectionType"
1740 SceneToolType = "Enums::_SceneToolType"
1741 BlendType = "Enums::_BlendType"
1742 BodyType = "Enums::_BodyType"
1743 EntityType = "Enums::_EntityType"
1744 AnnotationType = "Enums::_AnnotationType"
1745 AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
1746 AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
1747 AnnotationLineEnd = "Enums::_AnnotationLineEnd"
1748 MbdStandard = "Enums::_MBDStandard"
1749 MbdSymbol = "Enums::_MBDSymbol"
1750
1751 CurveType = "Enums::_CurveType"
1752 PathCommand = "Enums::_PathCommand"
1753 PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
1754 PathComponentConstraintType = "Enums::_PathComponentConstraintType"
1755 ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
1756
1757 EngineErrorCode = "Enums::_ErrorCode"
1759 GlobalAxis = "Enums::_GlobalAxis"
1760 OriginType = "Enums::_OriginType"
1761
1762 PostEffectType = "Enums::_PostEffectType"
1764}
1765
1766fn bool_true() -> bool {
1767 true
1768}
1769fn same_scale() -> Point3d<f64> {
1770 Point3d::uniform(1.0)
1771}
1772
1773fn z_axis() -> Point3d<f64> {
1774 Point3d { x: 0.0, y: 0.0, z: 1.0 }
1775}
1776
1777impl ExtrudedFaceInfo {
1778 pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
1781 let mut face_infos: Vec<_> = self
1782 .sides
1783 .into_iter()
1784 .map(|side| ExtrusionFaceInfo {
1785 curve_id: Some(side.path_id),
1786 face_id: Some(side.face_id),
1787 cap: ExtrusionFaceCapType::None,
1788 })
1789 .collect();
1790 face_infos.push(ExtrusionFaceInfo {
1791 curve_id: None,
1792 face_id: Some(self.top),
1793 cap: ExtrusionFaceCapType::Top,
1794 });
1795 if let Some(bottom) = self.bottom {
1796 face_infos.push(ExtrusionFaceInfo {
1797 curve_id: None,
1798 face_id: Some(bottom),
1799 cap: ExtrusionFaceCapType::Bottom,
1800 });
1801 }
1802 face_infos
1803 }
1804}
1805
1806#[cfg(test)]
1807mod tests {
1808 use super::*;
1809
1810 #[test]
1811 fn test_angle_comparison() {
1812 let a = Angle::from_degrees(90.0);
1813 assert!(a < Angle::from_degrees(91.0));
1814 assert!(a > Angle::from_degrees(89.0));
1815 assert!(a <= Angle::from_degrees(90.0));
1816 assert!(a >= Angle::from_degrees(90.0));
1817 let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
1818 assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
1819 assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
1820 assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1821 assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1822 assert!(a > b);
1824 assert!(a >= b);
1825 assert!(b < a);
1826 assert!(b <= a);
1827 let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
1828 assert!(a < c);
1829 assert!(a <= c);
1830 assert!(c > a);
1831 assert!(c >= a);
1832 }
1833}
1834
1835#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, JsonSchema, Builder)]
1837#[schemars(rename = "TransformByFor{T}")]
1838#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1839#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1840#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1841#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1842pub struct TransformBy<T> {
1843 pub property: T,
1845 pub set: bool,
1850 #[serde(default)]
1852 #[builder(default)]
1853 pub origin: OriginType,
1854}
1855
1856impl<T> TransformBy<T> {
1857 pub fn get_origin(&self) -> OriginType {
1861 self.origin
1862 }
1863}
1864
1865#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, Default, Builder)]
1868#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1869#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1870#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1871#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1872pub struct ComponentTransform {
1873 pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
1875 pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
1878 pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
1882 pub scale: Option<TransformBy<Point3d<f64>>>,
1884}
1885
1886#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
1889#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1890#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1891#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1892#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1893pub enum Opposite<T> {
1894 #[default]
1896 None,
1897 Symmetric,
1899 Other(T),
1901}
1902
1903impl<T: JsonSchema> JsonSchema for Opposite<T> {
1904 fn schema_name() -> String {
1905 format!("OppositeFor{}", T::schema_name())
1906 }
1907
1908 fn schema_id() -> std::borrow::Cow<'static, str> {
1909 std::borrow::Cow::Owned(format!("{}::Opposite<{}>", module_path!(), T::schema_id()))
1910 }
1911
1912 fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1913 SchemaObject {
1914 instance_type: Some(schemars::schema::InstanceType::String.into()),
1915 ..Default::default()
1916 }
1917 .into()
1918 }
1919}
1920
1921#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1924#[serde(rename_all = "snake_case")]
1925#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1926#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1927#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1928#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1929pub enum CutStrategy {
1930 Basic,
1933 Csg,
1936 #[default]
1938 Automatic,
1939}
1940
1941#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1943#[serde(rename_all = "snake_case")]
1944#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1945#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1946#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1947#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1948pub enum RelativeTo {
1949 #[default]
1951 SketchPlane,
1952 TrajectoryCurve,
1954}
1955
1956#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1958#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1959#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1960#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1961pub struct SelectedRegion {
1962 pub segment: Uuid,
1964 pub intersection_segment: Uuid,
1967 #[serde(default = "negative_one")]
1971 pub intersection_index: i32,
1972 #[serde(default)]
1975 pub curve_clockwise: bool,
1976}
1977
1978impl Default for SelectedRegion {
1979 fn default() -> Self {
1980 Self {
1981 segment: Default::default(),
1982 intersection_segment: Default::default(),
1983 intersection_index: -1,
1984 curve_clockwise: Default::default(),
1985 }
1986 }
1987}
1988
1989#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
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 FractionOfEdge {
1996 #[serde(default, skip_serializing_if = "Option::is_none")]
1998 pub edge_id: Option<Uuid>,
1999 #[serde(default, skip_serializing_if = "Option::is_none")]
2001 pub edge_specifier: Option<EdgeSpecifier>,
2002 #[serde(default)]
2006 #[builder(default)]
2007 #[schemars(range(min = 0, max = 1))]
2008 pub lower_bound: f32,
2009 #[serde(default = "one")]
2013 #[builder(default = one())]
2014 #[schemars(range(min = 0, max = 1))]
2015 pub upper_bound: f32,
2016}
2017
2018#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2020#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2021#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2022#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2023#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2024pub struct SurfaceEdgeReference {
2025 pub object_id: Uuid,
2027 pub edges: Vec<FractionOfEdge>,
2029}
2030
2031#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2033#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2034#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2035#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2036#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2037pub struct BodiesCreated {
2038 pub bodies: Vec<BodyCreated>,
2040}
2041
2042impl BodiesCreated {
2043 pub fn is_empty(&self) -> bool {
2045 self.bodies.is_empty()
2046 }
2047}
2048
2049#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2051#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2052#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2053#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2054#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2055pub struct BodiesUpdated {
2056 pub bodies: Vec<BodyUpdated>,
2058}
2059
2060impl BodiesUpdated {
2061 pub fn is_empty(&self) -> bool {
2063 self.bodies.is_empty()
2064 }
2065}
2066
2067#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2069#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2070#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2071#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2072#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2073pub struct BodyCreated {
2074 pub id: Uuid,
2076 pub surfaces: Vec<SurfaceCreated>,
2078}
2079
2080#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2082#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2083#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2084#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2085#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2086pub struct BodyUpdated {
2087 pub id: Uuid,
2089 pub surfaces: Vec<SurfaceCreated>,
2091}
2092
2093#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2095#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2096#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2097#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2098#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2099pub struct SurfaceCreated {
2100 pub id: Uuid,
2102 pub primitive_face_index: u32,
2104 pub from_segments: Vec<Uuid>,
2106}
2107
2108#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2110#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2111#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2112#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2113#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2114pub enum RegionVersion {
2115 #[default]
2118 V0,
2119 V1,
2122}
2123
2124#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Copy)]
2126#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2127#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2128#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2129#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2130#[serde(rename_all = "snake_case")]
2131pub enum EdgeCutVersion {
2132 V0,
2134 V1,
2138 V2,
2142}
2143
2144const DEFAULT_EDGE_CUT_VERSION: EdgeCutVersion = EdgeCutVersion::V1;
2145
2146impl EdgeCutVersion {
2147 pub fn is_default(&self) -> bool {
2149 self == &DEFAULT_EDGE_CUT_VERSION
2150 }
2151}
2152
2153impl Default for EdgeCutVersion {
2154 fn default() -> Self {
2155 DEFAULT_EDGE_CUT_VERSION
2156 }
2157}
2158
2159impl TryFrom<u32> for EdgeCutVersion {
2161 type Error = ();
2162
2163 fn try_from(version: u32) -> Result<Self, Self::Error> {
2164 match version {
2165 0 => Ok(Self::V0),
2166 1 => Ok(Self::V1),
2167 2 => Ok(Self::V2),
2168 _ => Err(()),
2169 }
2170 }
2171}
2172
2173impl RegionVersion {
2174 pub fn is_zero(&self) -> bool {
2176 matches!(self, Self::V0)
2177 }
2178}
2179
2180impl From<BodyCreated> for BodyUpdated {
2181 fn from(body: BodyCreated) -> Self {
2182 Self {
2183 id: body.id,
2184 surfaces: body.surfaces,
2185 }
2186 }
2187}
2188
2189impl From<BodyUpdated> for BodyCreated {
2190 fn from(body: BodyUpdated) -> Self {
2191 Self {
2192 id: body.id,
2193 surfaces: body.surfaces,
2194 }
2195 }
2196}
2197
2198impl From<BodiesCreated> for BodiesUpdated {
2199 fn from(bodies: BodiesCreated) -> Self {
2200 Self {
2201 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2202 }
2203 }
2204}
2205
2206impl From<BodiesUpdated> for BodiesCreated {
2207 fn from(bodies: BodiesUpdated) -> Self {
2208 Self {
2209 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2210 }
2211 }
2212}
2213
2214fn one() -> f32 {
2215 1.0
2216}
2217
2218#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema, Builder)]
2220pub struct CurveDebug {
2221 pub start: Option<Point2d<f64>>,
2223 pub end: Option<Point2d<f64>>,
2225 pub center: Option<Point2d<f64>>,
2227 pub mid: Option<Point2d<f64>>,
2229 pub segment_type: CurveTypeDebug,
2231 pub id: ModelingCmdId,
2233}
2234
2235#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
2237pub enum CurveTypeDebug {
2238 Line,
2240 ThreePointArc,
2242 Circle,
2244}