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, Copy, 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 Axis {
208 axis: Point3d<f64>,
210 point: Point3d<LengthUnit>,
212 },
213 Plane {
216 id: Uuid,
218 },
219}
220
221#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
223#[serde(rename_all = "snake_case")]
224#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
225#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
226#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
227#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
228pub enum CutTypeV2 {
229 Fillet {
231 radius: LengthUnit,
233 second_length: Option<LengthUnit>,
236 },
237 Chamfer {
239 distance: LengthUnit,
241 second_distance: Option<LengthUnit>,
243 angle: Option<Angle>,
245 swap: bool,
247 },
248 Custom {
250 path: Uuid,
252 },
253}
254
255#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
257#[serde(rename_all = "snake_case")]
258#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
259#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
260#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
261#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
262pub struct Rotation {
263 pub axis: Point3d<f64>,
266 pub angle: Angle,
269 pub origin: OriginType,
271}
272
273impl Default for Rotation {
274 fn default() -> Self {
276 Self {
277 axis: z_axis(),
278 angle: Angle::default(),
279 origin: OriginType::Local,
280 }
281 }
282}
283
284#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
286#[serde(rename_all = "snake_case")]
287#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
288#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
289#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
290#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
291pub struct Transform {
292 #[serde(default)]
295 #[builder(default)]
296 pub translate: Point3d<LengthUnit>,
297 #[serde(default = "same_scale")]
300 #[builder(default = same_scale())]
301 pub scale: Point3d<f64>,
302 #[serde(default)]
305 #[builder(default)]
306 pub rotation: Rotation,
307 #[serde(default = "bool_true")]
309 #[builder(default = bool_true())]
310 pub replicate: bool,
311}
312
313impl Default for Transform {
314 fn default() -> Self {
315 Self {
316 scale: same_scale(),
317 replicate: true,
318 translate: Default::default(),
319 rotation: Rotation::default(),
320 }
321 }
322}
323
324#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
326#[serde(rename_all = "snake_case")]
327#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
328#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
329#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
330#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
331pub struct AnnotationOptions {
332 pub text: Option<AnnotationTextOptions>,
334 pub line_ends: Option<AnnotationLineEndOptions>,
336 pub line_width: Option<f32>,
338 pub color: Option<Color>,
340 pub position: Option<Point3d<f32>>,
342 #[serde(default, skip_serializing_if = "Option::is_none")]
344 pub units: Option<units::UnitLength>,
345 pub dimension: Option<AnnotationBasicDimension>,
347 pub feature_control: Option<AnnotationFeatureControl>,
349 pub feature_tag: Option<AnnotationFeatureTag>,
351}
352
353#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
355#[serde(rename_all = "snake_case")]
356#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
357#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
358#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
359#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
360pub struct AnnotationLineEndOptions {
361 pub start: AnnotationLineEnd,
363 pub end: AnnotationLineEnd,
365}
366
367#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
369#[serde(rename_all = "snake_case")]
370#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
371#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
372#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
373#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
374pub struct AnnotationTextOptions {
375 pub x: AnnotationTextAlignmentX,
377 pub y: AnnotationTextAlignmentY,
379 pub text: String,
381 pub point_size: u32,
383}
384
385#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
387#[serde(rename_all = "snake_case")]
388#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
389#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
390#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
391#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
392pub struct AnnotationMbdControlFrame {
393 pub symbol: MbdSymbol,
395 pub diameter_symbol: Option<MbdSymbol>,
397 pub tolerance: f64,
399 pub modifier: Option<MbdSymbol>,
401 pub primary_datum: Option<char>,
403 pub secondary_datum: Option<char>,
405 pub tertiary_datum: Option<char>,
407}
408
409#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
411#[serde(rename_all = "snake_case")]
412#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
413#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
414#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
415#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
416pub struct AnnotationMbdBasicDimension {
417 pub symbol: Option<MbdSymbol>,
419 pub dimension: Option<f64>,
421 pub tolerance: f64,
423}
424
425#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
427#[serde(rename_all = "snake_case")]
428#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
429#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
430#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
431#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
432pub struct AnnotationBasicDimension {
433 #[serde(default, skip_serializing_if = "Option::is_none")]
435 pub from_entity_id: Option<Uuid>,
436
437 #[serde(default, skip_serializing_if = "Option::is_none")]
440 pub from_edge_reference: Option<EdgeSpecifier>,
441
442 pub from_entity_pos: Point2d<f64>,
444
445 #[serde(default, skip_serializing_if = "Option::is_none")]
447 pub to_entity_id: Option<Uuid>,
448
449 #[serde(default, skip_serializing_if = "Option::is_none")]
452 pub to_edge_reference: Option<EdgeSpecifier>,
453
454 pub to_entity_pos: Point2d<f64>,
456
457 pub dimension: AnnotationMbdBasicDimension,
459
460 pub plane_id: Uuid,
462
463 pub offset: Point2d<f64>,
465
466 pub precision: u32,
468
469 pub font_scale: f32,
471
472 pub font_point_size: u32,
474
475 #[serde(default = "one")]
477 pub arrow_scale: f32,
478}
479
480#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
482#[serde(rename_all = "snake_case")]
483#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
484#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
485#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
486#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
487pub struct AnnotationFeatureControl {
488 #[serde(default, skip_serializing_if = "Option::is_none")]
490 pub entity_id: Option<Uuid>,
491
492 #[serde(default, skip_serializing_if = "Option::is_none")]
495 pub edge_reference: Option<EdgeSpecifier>,
496
497 pub entity_pos: Point2d<f64>,
499
500 pub leader_type: AnnotationLineEnd,
502
503 pub dimension: Option<AnnotationMbdBasicDimension>,
505
506 pub control_frame: Option<AnnotationMbdControlFrame>,
508
509 pub defined_datum: Option<char>,
511
512 pub prefix: Option<String>,
514
515 pub suffix: Option<String>,
517
518 pub plane_id: Uuid,
520
521 pub offset: Point2d<f64>,
523
524 pub precision: u32,
526
527 pub font_scale: f32,
529
530 pub font_point_size: u32,
532
533 #[serde(default = "one")]
535 pub leader_scale: f32,
536}
537
538#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
540#[serde(rename_all = "snake_case")]
541#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
542#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
543#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
544#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
545pub struct AnnotationFeatureTag {
546 #[serde(default, skip_serializing_if = "Option::is_none")]
548 pub entity_id: Option<Uuid>,
549
550 #[serde(default, skip_serializing_if = "Option::is_none")]
553 pub edge_reference: Option<EdgeSpecifier>,
554
555 pub entity_pos: Point2d<f64>,
557
558 pub leader_type: AnnotationLineEnd,
560
561 pub key: String,
563
564 pub value: String,
566
567 pub show_key: bool,
569
570 pub plane_id: Uuid,
572
573 pub offset: Point2d<f64>,
575
576 pub font_scale: f32,
578
579 pub font_point_size: u32,
581
582 #[serde(default = "one")]
584 pub leader_scale: f32,
585}
586
587#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
591#[serde(rename_all = "snake_case", tag = "type")]
592#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
593#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
594#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
595#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
596pub enum DistanceType {
597 Euclidean {},
599 OnAxis {
601 axis: GlobalAxis,
603 },
604}
605
606#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
608#[serde(rename_all = "snake_case", tag = "type")]
609#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
610#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
611#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
612#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
613pub enum OriginType {
614 #[default]
616 Local,
617 Global,
619 Custom {
621 origin: Point3d<f64>,
623 },
624}
625
626#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
628#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
629#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
630#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
631#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
632pub struct Color {
633 pub r: f32,
635 pub g: f32,
637 pub b: f32,
639 pub a: f32,
641}
642
643impl Color {
644 pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
646 Self { r, g, b, a }
647 }
648}
649
650#[allow(missing_docs)]
652#[derive(
653 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
654)]
655#[serde(rename_all = "lowercase")]
656#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
657#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
658#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
659#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
660pub enum AnnotationTextAlignmentX {
661 Left,
662 Center,
663 Right,
664}
665
666#[allow(missing_docs)]
668#[derive(
669 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
670)]
671#[serde(rename_all = "lowercase")]
672#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
673#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
674#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
675#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
676pub enum AnnotationTextAlignmentY {
677 Bottom,
678 Center,
679 Top,
680}
681
682#[allow(missing_docs)]
684#[derive(
685 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
686)]
687#[serde(rename_all = "lowercase")]
688#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
689#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
690#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
691#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
692pub enum AnnotationLineEnd {
693 None,
694 Arrow,
695 Dot,
696}
697
698#[derive(
700 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
701)]
702#[serde(rename_all = "lowercase")]
703#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
704#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
705#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
706#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
707pub enum AnnotationType {
708 T2D,
710 T3D,
712}
713
714#[derive(
716 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
717)]
718#[serde(rename_all = "lowercase")]
719#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
720#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
721#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
722#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
723pub enum MbdStandard {
724 AsmeY14_5,
726}
727
728#[allow(missing_docs)]
731#[derive(
732 Default,
733 Display,
734 FromStr,
735 Copy,
736 Eq,
737 PartialEq,
738 Debug,
739 JsonSchema,
740 Deserialize,
741 Serialize,
742 Sequence,
743 Clone,
744 Ord,
745 PartialOrd,
746)]
747#[serde(rename_all = "lowercase")]
748#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
749#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
750#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
751#[repr(u16)]
752#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
753pub enum MbdSymbol {
754 #[default]
755 None = 0,
756 ArcLength = 174,
757 Between = 175,
758 Degrees = 176,
759 PlusMinus = 177,
760 Angularity = 178,
761 Cylindricity = 179,
762 Roundness = 180,
763 Concentricity = 181,
764 Straightness = 182,
765 Parallelism = 183,
766 Flatness = 184,
767 ProfileOfLine = 185,
768 SurfaceProfile = 186,
769 Symmetry = 187,
770 Perpendicularity = 188,
771 Runout = 189,
772 TotalRunout = 190,
773 Position = 191,
774 CenterLine = 192,
775 PartingLine = 193,
776 IsoEnvelope = 195,
777 IsoEnvelopeNonY145M = 196,
778 FreeState = 197,
779 StatisticalTolerance = 198,
780 ContinuousFeature = 199,
781 Independency = 200,
782 Depth = 201,
783 Start = 202,
784 LeastCondition = 203,
785 MaxCondition = 204,
786 ConicalTaper = 205,
787 Projected = 206,
788 Slope = 207,
789 Micro = 208,
790 TangentPlane = 210,
791 Unilateral = 211,
792 SquareFeature = 212,
793 Countersink = 213,
794 SpotFace = 214,
795 Target = 215,
796 Diameter = 216,
797 Radius = 217,
798 SphericalRadius = 218,
799 SphericalDiameter = 219,
800 ControlledRadius = 220,
801 BoxStart = 123,
802 BoxBar = 162,
803 BoxBarBetween = 124,
804 LetterBackwardUnderline = 95,
805 PunctuationBackwardUnderline = 92,
806 ModifierBackwardUnderline = 126,
807 NumericBackwardUnderline = 96,
808 BoxEnd = 125,
809 DatumUp = 166,
810 DatumLeft = 168,
811 DatumRight = 167,
812 DatumDown = 165,
813 DatumTriangle = 295,
814 HalfSpace = 236,
815 QuarterSpace = 237,
816 EighthSpace = 238,
817 ModifierSpace = 239,
818}
819
820#[derive(
822 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
823)]
824#[serde(rename_all = "lowercase")]
825#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
826#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
827#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
828#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
829pub enum CameraDragInteractionType {
830 Pan,
832 Rotate,
834 RotateTrackball,
836 Zoom,
838}
839
840#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
843#[serde(rename_all = "snake_case", tag = "type")]
844#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
845#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
846#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
847#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
848pub enum PathSegment {
849 Line {
852 end: Point3d<LengthUnit>,
854 relative: bool,
856 },
857 Arc {
860 center: Point2d<LengthUnit>,
862 radius: LengthUnit,
864 start: Angle,
866 end: Angle,
868 relative: bool,
870 },
871 Bezier {
875 control1: Point3d<LengthUnit>,
877 control2: Point3d<LengthUnit>,
879 end: Point3d<LengthUnit>,
881 relative: bool,
883 },
884 TangentialArc {
886 radius: LengthUnit,
889 offset: Angle,
891 },
892 TangentialArcTo {
895 to: Point3d<LengthUnit>,
899 angle_snap_increment: Option<Angle>,
901 },
902 ArcTo {
904 interior: Point3d<LengthUnit>,
906 end: Point3d<LengthUnit>,
908 relative: bool,
910 },
911 CircularInvolute {
914 start_radius: LengthUnit,
917 end_radius: LengthUnit,
920 angle: Angle,
923 reverse: bool,
926 },
927 Ellipse {
929 center: Point2d<LengthUnit>,
931 major_axis: Point2d<LengthUnit>,
933 minor_radius: LengthUnit,
935 start_angle: Angle,
937 end_angle: Angle,
939 },
940 ConicTo {
943 interior: Point2d<LengthUnit>,
945 end: Point2d<LengthUnit>,
947 start_tangent: Point2d<LengthUnit>,
949 end_tangent: Point2d<LengthUnit>,
951 relative: bool,
953 },
954}
955
956#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
958#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
959#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
960#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
961#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
962pub struct Angle {
963 pub unit: UnitAngle,
965 pub value: f64,
967}
968
969impl Angle {
970 pub fn to_degrees(self) -> f64 {
972 match self.unit {
973 UnitAngle::Degrees => self.value,
974 UnitAngle::Radians => self.value.to_degrees(),
975 }
976 }
977 pub fn to_radians(self) -> f64 {
979 match self.unit {
980 UnitAngle::Degrees => self.value.to_radians(),
981 UnitAngle::Radians => self.value,
982 }
983 }
984 pub const fn from_degrees(value: f64) -> Self {
986 Self {
987 unit: UnitAngle::Degrees,
988 value,
989 }
990 }
991 pub const fn from_radians(value: f64) -> Self {
993 Self {
994 unit: UnitAngle::Radians,
995 value,
996 }
997 }
998 pub const fn turn() -> Self {
1000 Self::from_degrees(360.0)
1001 }
1002 pub const fn half_circle() -> Self {
1004 Self::from_degrees(180.0)
1005 }
1006 pub const fn quarter_circle() -> Self {
1008 Self::from_degrees(90.0)
1009 }
1010 pub const fn zero() -> Self {
1012 Self::from_degrees(0.0)
1013 }
1014}
1015
1016impl Default for Angle {
1018 fn default() -> Self {
1020 Self::zero()
1021 }
1022}
1023
1024impl PartialOrd for Angle {
1025 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
1026 match (self.unit, other.unit) {
1027 (UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
1029 (UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
1030 _ => self.to_degrees().partial_cmp(&other.to_degrees()),
1031 }
1032 }
1033}
1034
1035impl std::ops::Add for Angle {
1036 type Output = Self;
1037
1038 fn add(self, rhs: Self) -> Self::Output {
1039 Self {
1040 unit: UnitAngle::Degrees,
1041 value: self.to_degrees() + rhs.to_degrees(),
1042 }
1043 }
1044}
1045
1046impl std::ops::AddAssign for Angle {
1047 fn add_assign(&mut self, rhs: Self) {
1048 match self.unit {
1049 UnitAngle::Degrees => {
1050 self.value += rhs.to_degrees();
1051 }
1052 UnitAngle::Radians => {
1053 self.value += rhs.to_radians();
1054 }
1055 }
1056 }
1057}
1058
1059#[derive(
1061 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1062)]
1063#[serde(rename_all = "lowercase")]
1064#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1065#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1066#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1067#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1068pub enum SceneSelectionType {
1069 Replace,
1071 Add,
1073 Remove,
1075}
1076
1077#[allow(missing_docs)]
1079#[derive(
1080 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1081)]
1082#[serde(rename_all = "snake_case")]
1083#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1084#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1085#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1086#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1087pub enum SceneToolType {
1088 CameraRevolve,
1089 Select,
1090 Move,
1091 SketchLine,
1092 SketchTangentialArc,
1093 SketchCurve,
1094 SketchCurveMod,
1095}
1096
1097#[allow(missing_docs)]
1099#[derive(
1100 Display,
1101 FromStr,
1102 Copy,
1103 Eq,
1104 PartialEq,
1105 Debug,
1106 JsonSchema,
1107 Deserialize,
1108 Serialize,
1109 Sequence,
1110 Clone,
1111 Ord,
1112 PartialOrd,
1113 Default,
1114)]
1115#[serde(rename_all = "snake_case")]
1116#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1117#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1118#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1119#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1120pub enum PathComponentConstraintBound {
1121 #[default]
1122 Unconstrained,
1123 PartiallyConstrained,
1124 FullyConstrained,
1125}
1126
1127#[allow(missing_docs)]
1129#[derive(
1130 Display,
1131 FromStr,
1132 Copy,
1133 Eq,
1134 PartialEq,
1135 Debug,
1136 JsonSchema,
1137 Deserialize,
1138 Serialize,
1139 Sequence,
1140 Clone,
1141 Ord,
1142 PartialOrd,
1143 Default,
1144)]
1145#[serde(rename_all = "snake_case")]
1146#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1147#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1148#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1149#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1150pub enum PathComponentConstraintType {
1151 #[default]
1152 Unconstrained,
1153 Vertical,
1154 Horizontal,
1155 EqualLength,
1156 Parallel,
1157 AngleBetween,
1158}
1159
1160#[allow(missing_docs)]
1162#[derive(
1163 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1164)]
1165#[serde(rename_all = "snake_case")]
1166#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1167#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1168#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1169#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1170pub enum PathCommand {
1171 MoveTo,
1172 LineTo,
1173 BezCurveTo,
1174 NurbsCurveTo,
1175 AddArc,
1176}
1177
1178#[allow(missing_docs)]
1180#[derive(
1181 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1182)]
1183#[serde(rename_all = "lowercase")]
1184#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1185#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1186#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1187#[repr(u8)]
1188#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1189pub enum EntityType {
1190 Entity,
1191 Object,
1192 Path,
1193 Segment,
1194 Curve,
1195 Solid2D,
1196 Solid3D,
1197 Edge,
1198 Face,
1199 Plane,
1200 Vertex,
1201 Region,
1202}
1203
1204#[allow(missing_docs)]
1206#[derive(
1207 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1208)]
1209#[serde(rename_all = "snake_case")]
1210#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1211#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1212#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1213#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1214pub enum CurveType {
1215 Line,
1216 Arc,
1217 Nurbs,
1218}
1219
1220#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1222#[cfg_attr(
1223 feature = "python",
1224 pyo3::pyclass(from_py_object),
1225 pyo3_stub_gen::derive::gen_stub_pyclass
1226)]
1227#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1228pub struct ExportFile {
1229 pub name: String,
1231 pub contents: crate::base64::Base64Data,
1233}
1234
1235#[cfg(feature = "python")]
1236#[pyo3_stub_gen::derive::gen_stub_pymethods]
1237#[pyo3::pymethods]
1238impl ExportFile {
1239 #[getter]
1240 fn contents(&self) -> Vec<u8> {
1241 self.contents.0.clone()
1242 }
1243
1244 #[getter]
1245 fn name(&self) -> String {
1246 self.name.clone()
1247 }
1248}
1249
1250#[derive(
1252 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1253)]
1254#[serde(rename_all = "lowercase")]
1255#[display(style = "lowercase")]
1256#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1257#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1258#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1259#[cfg_attr(
1260 feature = "python",
1261 pyo3::pyclass(from_py_object),
1262 pyo3_stub_gen::derive::gen_stub_pyclass_enum
1263)]
1264#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1265pub enum FileExportFormat {
1266 Fbx,
1268 Glb,
1275 Gltf,
1286 Obj,
1290 Ply,
1292 Step,
1294 Stl,
1296}
1297
1298#[derive(
1300 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1301)]
1302#[serde(rename_all = "lowercase")]
1303#[display(style = "lowercase")]
1304#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1305#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1306#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1307#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1308pub enum FileExportFormat2d {
1309 Dxf,
1311}
1312
1313#[derive(
1315 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1316)]
1317#[serde(rename_all = "lowercase")]
1318#[display(style = "lowercase")]
1319#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1320#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1321#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1322#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1323pub enum FileImportFormat {
1324 Acis,
1326 Catia,
1328 Creo,
1330 Fbx,
1332 Gltf,
1334 Inventor,
1336 Nx,
1338 Obj,
1342 Parasolid,
1344 Ply,
1346 Sldprt,
1348 Step,
1350 Stl,
1352}
1353
1354#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
1356#[serde(rename_all = "snake_case")]
1357#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1358#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1359#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1360#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1361pub enum EngineErrorCode {
1362 BadRequest = 1,
1366 InternalEngine,
1368}
1369
1370impl From<EngineErrorCode> for http::StatusCode {
1371 fn from(e: EngineErrorCode) -> Self {
1372 match e {
1373 EngineErrorCode::BadRequest => Self::BAD_REQUEST,
1374 EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
1375 }
1376 }
1377}
1378
1379#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1381#[serde(rename_all = "snake_case")]
1382#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1383#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1384#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1385pub enum BlendType {
1386 #[default]
1388 Tangent,
1389}
1390
1391#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1393#[serde(rename_all = "snake_case")]
1394#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1395#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1396#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1397#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1398pub enum BodyType {
1399 #[default]
1401 Solid,
1402 Surface,
1404}
1405
1406#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1409#[serde(rename_all = "snake_case")]
1410#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1411#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1412#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1413#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1414pub enum ExtrudeMethod {
1415 New,
1418 #[default]
1421 Merge,
1422}
1423
1424#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1426#[serde(rename_all = "snake_case")]
1427#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1428#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1429#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1430#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1431pub enum ExtrudeReference {
1432 EntityReference {
1435 #[serde(default, skip_serializing_if = "Option::is_none")]
1437 entity_id: Option<Uuid>,
1438 #[serde(default, skip_serializing_if = "Option::is_none")]
1440 entity_reference: Option<EntityReference>,
1441 },
1442 Axis {
1444 axis: Point3d<f64>,
1446 #[serde(default)]
1449 point: Point3d<LengthUnit>,
1450 },
1451 Point {
1453 point: Point3d<LengthUnit>,
1455 },
1456}
1457
1458#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1460#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1461#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1462#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1463#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1464pub struct ExtrudedFaceInfo {
1465 pub bottom: Option<Uuid>,
1470 pub top: Uuid,
1472 pub sides: Vec<SideFace>,
1474}
1475
1476#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1478#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1479#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1480#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1481#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1482pub struct SideFace {
1483 pub path_id: Uuid,
1485 pub face_id: Uuid,
1487}
1488
1489#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1491#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1492#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1493#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1494#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1495pub struct CameraSettings {
1496 pub pos: Point3d,
1498
1499 pub center: Point3d,
1501
1502 pub up: Point3d,
1504
1505 pub orientation: Quaternion,
1507
1508 pub fov_y: Option<f32>,
1510
1511 pub ortho_scale: Option<f32>,
1513
1514 pub ortho: bool,
1516}
1517
1518#[allow(missing_docs)]
1519#[repr(u8)]
1520#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1521#[serde(rename_all = "snake_case")]
1522#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1523#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1524#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1525#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1526pub enum WorldCoordinateSystem {
1527 #[default]
1528 RightHandedUpZ,
1529 RightHandedUpY,
1530}
1531
1532#[allow(missing_docs)]
1533#[repr(C)]
1534#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1535#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1536#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1537#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1538#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1539pub struct CameraViewState {
1540 pub pivot_rotation: Quaternion,
1541 pub pivot_position: Point3d,
1542 pub eye_offset: f32,
1543 pub fov_y: f32,
1544 pub ortho_scale_factor: f32,
1545 pub is_ortho: bool,
1546 pub ortho_scale_enabled: bool,
1547 pub world_coord_system: WorldCoordinateSystem,
1548}
1549
1550impl Default for CameraViewState {
1551 fn default() -> Self {
1552 CameraViewState {
1553 pivot_rotation: Default::default(),
1554 pivot_position: Default::default(),
1555 eye_offset: 10.0,
1556 fov_y: 45.0,
1557 ortho_scale_factor: 1.6,
1558 is_ortho: false,
1559 ortho_scale_enabled: true,
1560 world_coord_system: Default::default(),
1561 }
1562 }
1563}
1564
1565#[cfg(feature = "cxx")]
1566impl_extern_type! {
1567 [Trivial]
1568 CameraViewState = "Endpoints::CameraViewState"
1569}
1570
1571impl From<CameraSettings> for crate::output::DefaultCameraZoom {
1572 fn from(settings: CameraSettings) -> Self {
1573 Self { settings }
1574 }
1575}
1576impl From<CameraSettings> for crate::output::CameraDragMove {
1577 fn from(settings: CameraSettings) -> Self {
1578 Self { settings }
1579 }
1580}
1581impl From<CameraSettings> for crate::output::CameraDragEnd {
1582 fn from(settings: CameraSettings) -> Self {
1583 Self { settings }
1584 }
1585}
1586impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
1587 fn from(settings: CameraSettings) -> Self {
1588 Self { settings }
1589 }
1590}
1591impl From<CameraSettings> for crate::output::ZoomToFit {
1592 fn from(settings: CameraSettings) -> Self {
1593 Self { settings }
1594 }
1595}
1596impl From<CameraSettings> for crate::output::OrientToFace {
1597 fn from(settings: CameraSettings) -> Self {
1598 Self { settings }
1599 }
1600}
1601impl From<CameraSettings> for crate::output::ViewIsometric {
1602 fn from(settings: CameraSettings) -> Self {
1603 Self { settings }
1604 }
1605}
1606
1607#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default, Builder)]
1609#[serde(rename_all = "snake_case")]
1610#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1611#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1612#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1613#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1614pub struct PerspectiveCameraParameters {
1615 pub fov_y: Option<f32>,
1617 pub z_near: Option<f32>,
1619 pub z_far: Option<f32>,
1621}
1622
1623#[derive(
1625 Default,
1626 Display,
1627 FromStr,
1628 Copy,
1629 Eq,
1630 PartialEq,
1631 Debug,
1632 JsonSchema,
1633 Deserialize,
1634 Serialize,
1635 Sequence,
1636 Clone,
1637 Ord,
1638 PartialOrd,
1639)]
1640#[serde(rename_all = "snake_case")]
1641#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1642#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1643#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1644#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1645pub enum CameraMovement {
1646 #[default]
1648 Vantage,
1649 None,
1651}
1652
1653#[derive(
1655 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1656)]
1657#[serde(rename_all = "lowercase")]
1658#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1659#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1660#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1661#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1662pub enum GlobalAxis {
1663 X,
1665 Y,
1667 Z,
1669}
1670
1671#[derive(
1673 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1674)]
1675#[serde(rename_all = "snake_case")]
1676#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1677#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1678#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1679#[repr(u8)]
1680#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1681pub enum ExtrusionFaceCapType {
1682 None,
1684 Top,
1686 Bottom,
1688 Both,
1690}
1691
1692#[allow(missing_docs)]
1694#[derive(
1695 Display,
1696 FromStr,
1697 Copy,
1698 Eq,
1699 PartialEq,
1700 Debug,
1701 JsonSchema,
1702 Deserialize,
1703 Serialize,
1704 Sequence,
1705 Clone,
1706 Ord,
1707 PartialOrd,
1708 Default,
1709)]
1710#[serde(rename_all = "lowercase")]
1711#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1712#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1713#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1714#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1715pub enum PostEffectType {
1716 Phosphor,
1717 Ssao,
1718 #[default]
1719 NoEffect,
1720}
1721
1722#[cfg(feature = "cxx")]
1725impl_extern_type! {
1726 [Trivial]
1727 FileImportFormat = "Enums::_FileImportFormat"
1729 FileExportFormat = "Enums::_FileExportFormat"
1730 CameraDragInteractionType = "Enums::_CameraDragInteractionType"
1732 SceneSelectionType = "Enums::_SceneSelectionType"
1734 SceneToolType = "Enums::_SceneToolType"
1735 BlendType = "Enums::_BlendType"
1736 BodyType = "Enums::_BodyType"
1737 EntityType = "Enums::_EntityType"
1738 AnnotationType = "Enums::_AnnotationType"
1739 AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
1740 AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
1741 AnnotationLineEnd = "Enums::_AnnotationLineEnd"
1742 MbdStandard = "Enums::_MBDStandard"
1743 MbdSymbol = "Enums::_MBDSymbol"
1744
1745 CurveType = "Enums::_CurveType"
1746 PathCommand = "Enums::_PathCommand"
1747 PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
1748 PathComponentConstraintType = "Enums::_PathComponentConstraintType"
1749 ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
1750
1751 EngineErrorCode = "Enums::_ErrorCode"
1753 GlobalAxis = "Enums::_GlobalAxis"
1754 OriginType = "Enums::_OriginType"
1755
1756 PostEffectType = "Enums::_PostEffectType"
1758}
1759
1760fn bool_true() -> bool {
1761 true
1762}
1763fn same_scale() -> Point3d<f64> {
1764 Point3d::uniform(1.0)
1765}
1766
1767fn z_axis() -> Point3d<f64> {
1768 Point3d { x: 0.0, y: 0.0, z: 1.0 }
1769}
1770
1771impl ExtrudedFaceInfo {
1772 pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
1775 let mut face_infos: Vec<_> = self
1776 .sides
1777 .into_iter()
1778 .map(|side| ExtrusionFaceInfo {
1779 curve_id: Some(side.path_id),
1780 face_id: Some(side.face_id),
1781 cap: ExtrusionFaceCapType::None,
1782 })
1783 .collect();
1784 face_infos.push(ExtrusionFaceInfo {
1785 curve_id: None,
1786 face_id: Some(self.top),
1787 cap: ExtrusionFaceCapType::Top,
1788 });
1789 if let Some(bottom) = self.bottom {
1790 face_infos.push(ExtrusionFaceInfo {
1791 curve_id: None,
1792 face_id: Some(bottom),
1793 cap: ExtrusionFaceCapType::Bottom,
1794 });
1795 }
1796 face_infos
1797 }
1798}
1799
1800#[cfg(test)]
1801mod tests {
1802 use super::*;
1803
1804 #[test]
1805 fn test_angle_comparison() {
1806 let a = Angle::from_degrees(90.0);
1807 assert!(a < Angle::from_degrees(91.0));
1808 assert!(a > Angle::from_degrees(89.0));
1809 assert!(a <= Angle::from_degrees(90.0));
1810 assert!(a >= Angle::from_degrees(90.0));
1811 let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
1812 assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
1813 assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
1814 assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1815 assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
1816 assert!(a > b);
1818 assert!(a >= b);
1819 assert!(b < a);
1820 assert!(b <= a);
1821 let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
1822 assert!(a < c);
1823 assert!(a <= c);
1824 assert!(c > a);
1825 assert!(c >= a);
1826 }
1827}
1828
1829#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, JsonSchema, Builder)]
1831#[schemars(rename = "TransformByFor{T}")]
1832#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1833#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1834#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1835#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1836pub struct TransformBy<T> {
1837 pub property: T,
1839 pub set: bool,
1844 #[serde(default)]
1846 #[builder(default)]
1847 pub origin: OriginType,
1848}
1849
1850impl<T> TransformBy<T> {
1851 pub fn get_origin(&self) -> OriginType {
1855 self.origin
1856 }
1857}
1858
1859#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, Default, Builder)]
1862#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1863#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1864#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1865#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1866pub struct ComponentTransform {
1867 pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
1869 pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
1872 pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
1876 pub scale: Option<TransformBy<Point3d<f64>>>,
1878}
1879
1880#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
1883#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1884#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1885#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1886#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1887pub enum Opposite<T> {
1888 #[default]
1890 None,
1891 Symmetric,
1893 Other(T),
1895}
1896
1897impl<T: JsonSchema> JsonSchema for Opposite<T> {
1898 fn schema_name() -> String {
1899 format!("OppositeFor{}", T::schema_name())
1900 }
1901
1902 fn schema_id() -> std::borrow::Cow<'static, str> {
1903 std::borrow::Cow::Owned(format!("{}::Opposite<{}>", module_path!(), T::schema_id()))
1904 }
1905
1906 fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1907 SchemaObject {
1908 instance_type: Some(schemars::schema::InstanceType::String.into()),
1909 ..Default::default()
1910 }
1911 .into()
1912 }
1913}
1914
1915#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1918#[serde(rename_all = "snake_case")]
1919#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1920#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1921#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1922#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1923pub enum CutStrategy {
1924 Basic,
1927 Csg,
1930 #[default]
1932 Automatic,
1933}
1934
1935#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1937#[serde(rename_all = "snake_case")]
1938#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1939#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1940#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1941#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1942pub enum RelativeTo {
1943 #[default]
1945 SketchPlane,
1946 TrajectoryCurve,
1948}
1949
1950#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1952#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1953#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1954#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1955pub struct SelectedRegion {
1956 pub segment: Uuid,
1958 pub intersection_segment: Uuid,
1961 #[serde(default = "negative_one")]
1965 pub intersection_index: i32,
1966 #[serde(default)]
1969 pub curve_clockwise: bool,
1970}
1971
1972impl Default for SelectedRegion {
1973 fn default() -> Self {
1974 Self {
1975 segment: Default::default(),
1976 intersection_segment: Default::default(),
1977 intersection_index: -1,
1978 curve_clockwise: Default::default(),
1979 }
1980 }
1981}
1982
1983#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1985#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1986#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1987#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1988#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1989pub struct FractionOfEdge {
1990 #[serde(default, skip_serializing_if = "Option::is_none")]
1992 pub edge_id: Option<Uuid>,
1993 #[serde(default, skip_serializing_if = "Option::is_none")]
1995 pub edge_specifier: Option<EdgeSpecifier>,
1996 #[serde(default)]
2000 #[builder(default)]
2001 #[schemars(range(min = 0, max = 1))]
2002 pub lower_bound: f32,
2003 #[serde(default = "one")]
2007 #[builder(default = one())]
2008 #[schemars(range(min = 0, max = 1))]
2009 pub upper_bound: f32,
2010}
2011
2012#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2014#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2015#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2016#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2017#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2018pub struct SurfaceEdgeReference {
2019 pub object_id: Uuid,
2021 pub edges: Vec<FractionOfEdge>,
2023}
2024
2025#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2027#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2028#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2029#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2030#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2031pub struct BodiesCreated {
2032 pub bodies: Vec<BodyCreated>,
2034}
2035
2036impl BodiesCreated {
2037 pub fn is_empty(&self) -> bool {
2039 self.bodies.is_empty()
2040 }
2041}
2042
2043#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2045#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2046#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2047#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2048#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2049pub struct BodiesUpdated {
2050 pub bodies: Vec<BodyUpdated>,
2052}
2053
2054impl BodiesUpdated {
2055 pub fn is_empty(&self) -> bool {
2057 self.bodies.is_empty()
2058 }
2059}
2060
2061#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2063#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2064#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2065#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2066#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2067pub struct BodyCreated {
2068 pub id: Uuid,
2070 pub surfaces: Vec<SurfaceCreated>,
2072}
2073
2074#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2076#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2077#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2078#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2079#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2080pub struct BodyUpdated {
2081 pub id: Uuid,
2083 pub surfaces: Vec<SurfaceCreated>,
2085}
2086
2087#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2089#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2090#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2091#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2092#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2093pub struct SurfaceCreated {
2094 pub id: Uuid,
2096 pub primitive_face_index: u32,
2098 pub from_segments: Vec<Uuid>,
2100}
2101
2102#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2104#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2105#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2106#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2107#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2108pub enum RegionVersion {
2109 #[default]
2112 V0,
2113 V1,
2116}
2117
2118#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Copy)]
2120#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2121#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2122#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2123#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2124#[serde(rename_all = "snake_case")]
2125pub enum EdgeCutVersion {
2126 V0,
2128 V1,
2132 V2,
2136}
2137
2138const DEFAULT_EDGE_CUT_VERSION: EdgeCutVersion = EdgeCutVersion::V1;
2139
2140impl EdgeCutVersion {
2141 pub fn is_default(&self) -> bool {
2143 self == &DEFAULT_EDGE_CUT_VERSION
2144 }
2145}
2146
2147impl Default for EdgeCutVersion {
2148 fn default() -> Self {
2149 DEFAULT_EDGE_CUT_VERSION
2150 }
2151}
2152
2153impl TryFrom<u32> for EdgeCutVersion {
2155 type Error = ();
2156
2157 fn try_from(version: u32) -> Result<Self, Self::Error> {
2158 match version {
2159 0 => Ok(Self::V0),
2160 1 => Ok(Self::V1),
2161 2 => Ok(Self::V2),
2162 _ => Err(()),
2163 }
2164 }
2165}
2166
2167impl RegionVersion {
2168 pub fn is_zero(&self) -> bool {
2170 matches!(self, Self::V0)
2171 }
2172}
2173
2174impl From<BodyCreated> for BodyUpdated {
2175 fn from(body: BodyCreated) -> Self {
2176 Self {
2177 id: body.id,
2178 surfaces: body.surfaces,
2179 }
2180 }
2181}
2182
2183impl From<BodyUpdated> for BodyCreated {
2184 fn from(body: BodyUpdated) -> Self {
2185 Self {
2186 id: body.id,
2187 surfaces: body.surfaces,
2188 }
2189 }
2190}
2191
2192impl From<BodiesCreated> for BodiesUpdated {
2193 fn from(bodies: BodiesCreated) -> Self {
2194 Self {
2195 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2196 }
2197 }
2198}
2199
2200impl From<BodiesUpdated> for BodiesCreated {
2201 fn from(bodies: BodiesUpdated) -> Self {
2202 Self {
2203 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2204 }
2205 }
2206}
2207
2208fn one() -> f32 {
2209 1.0
2210}
2211
2212#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema, Builder)]
2214pub struct CurveDebug {
2215 pub start: Option<Point2d<f64>>,
2217 pub end: Option<Point2d<f64>>,
2219 pub center: Option<Point2d<f64>>,
2221 pub mid: Option<Point2d<f64>>,
2223 pub segment_type: CurveTypeDebug,
2225 pub id: ModelingCmdId,
2227}
2228
2229#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
2231pub enum CurveTypeDebug {
2232 Line,
2234 ThreePointArc,
2236 Circle,
2238}