1use bon::Builder;
2use enum_iterator::Sequence;
3pub use kittycad_point::{Point2d, Point3d, Point4d, Quaternion};
4use parse_display_derive::{Display, FromStr};
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
19pub mod safe_filepath;
20
21pub use crate::kcl_project::{KclFile, KclFileBuilder, KclProject, KclProjectBuilder};
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
25#[serde(rename_all = "snake_case")]
26#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
27#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
28#[cfg_attr(feature = "ts-rs", ts(export_to = "Compression.ts"))]
29#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
30pub enum CompressionType {
31 Zstd,
33}
34
35#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
37#[serde(rename_all = "snake_case")]
38#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
39#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
40#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
41#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
42pub struct Tolerance {
43 pub point_point_2d_coincident: LengthUnit,
45}
46
47#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
49#[serde(rename_all = "snake_case")]
50#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
51#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
52#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
53#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
54pub struct EdgeSpecifier {
55 pub side_faces: Vec<Uuid>,
57 #[serde(default, skip_serializing_if = "Vec::is_empty")]
59 #[builder(default)]
60 pub end_faces: Vec<Uuid>,
61 #[serde(skip_serializing_if = "Option::is_none")]
65 pub index: Option<u32>,
66}
67
68#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
84#[serde(rename_all = "snake_case")]
85#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
86#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
87#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
88#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
89pub struct PrimitiveTopologyFallback {
90 pub parent_id: Uuid,
92 pub primitive_index: u32,
94}
95
96#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
98#[serde(tag = "type", rename_all = "snake_case")]
99#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
100#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
101#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
102pub enum EntityReference {
103 Annotation {
105 annotation_id: Uuid,
107 },
108 Plane {
110 plane_id: Uuid,
112 #[serde(default, skip_serializing_if = "Option::is_none")]
114 topology_fallback: Option<PrimitiveTopologyFallback>,
115 },
116 Face {
118 face_id: Uuid,
120 #[serde(default, skip_serializing_if = "Option::is_none")]
122 topology_fallback: Option<PrimitiveTopologyFallback>,
123 },
124 Edge {
126 #[serde(flatten)]
128 inner: EdgeSpecifier,
129 #[serde(default, skip_serializing_if = "Option::is_none")]
131 topology_fallback: Option<PrimitiveTopologyFallback>,
132 },
133 Vertex {
135 side_faces: Vec<Uuid>,
137 #[serde(skip_serializing_if = "Option::is_none")]
139 index: Option<u32>,
140 #[serde(default, skip_serializing_if = "Option::is_none")]
142 topology_fallback: Option<PrimitiveTopologyFallback>,
143 },
144 Solid2d {
146 solid2d_id: Uuid,
148 #[serde(default, skip_serializing_if = "Option::is_none")]
150 topology_fallback: Option<PrimitiveTopologyFallback>,
151 },
152 Solid3d {
154 solid3d_id: Uuid,
156 #[serde(default, skip_serializing_if = "Option::is_none")]
158 topology_fallback: Option<PrimitiveTopologyFallback>,
159 },
160 Helix {
162 helix_id: Uuid,
164 },
165 Solid2dEdge {
168 edge_id: Uuid,
170 #[serde(default, skip_serializing_if = "Option::is_none")]
172 topology_fallback: Option<PrimitiveTopologyFallback>,
173 },
174 Segment {
176 path_id: Uuid,
178 segment_id: Uuid,
180 #[serde(default, skip_serializing_if = "Option::is_none")]
182 topology_fallback: Option<PrimitiveTopologyFallback>,
183 },
184 Region {
186 region_id: Uuid,
188 #[serde(default, skip_serializing_if = "Option::is_none")]
190 topology_fallback: Option<PrimitiveTopologyFallback>,
191 },
192}
193
194#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
200#[serde(rename_all = "snake_case")]
201#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
202#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
203#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
204#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
205pub struct PlanarFrame {
206 pub origin: Point3d<LengthUnit>,
208 pub x_axis: Point3d<f64>,
210 pub y_axis: Point3d<f64>,
212}
213
214#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
216#[serde(rename_all = "snake_case")]
217#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
218#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
219#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
220#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
221pub enum ProjectionHiddenLineMode {
222 VisibleOnly,
224 #[default]
226 IncludeHidden,
227}
228
229#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
231#[serde(rename_all = "snake_case")]
232#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
233#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
234#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
235#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
236pub enum ProjectionCurveVisibility {
237 Visible,
239 Hidden,
241}
242
243#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
252#[serde(tag = "type", rename_all = "snake_case")]
253#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
254#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
255#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
256#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
257pub enum ProjectionCurveSource {
258 Edge {
260 #[serde(default, skip_serializing_if = "Option::is_none")]
262 edge_id: Option<Uuid>,
263 edge_index: u32,
265 section_index: u32,
267 },
268 Silhouette {
270 #[serde(default, skip_serializing_if = "Option::is_none")]
272 face_id: Option<Uuid>,
273 face_index: u32,
275 silhouette_index: u32,
277 },
278}
279
280#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
284#[serde(rename_all = "snake_case")]
285#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
286#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
287#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
288#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
289pub struct LineSegment2d {
290 pub start: Point2d<f64>,
292 pub end: Point2d<f64>,
294}
295
296#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
298#[serde(rename_all = "snake_case")]
299#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
300#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
301#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
302#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
303pub enum Winding {
304 #[default]
306 Counterclockwise,
307 Clockwise,
309}
310
311#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
315#[serde(rename_all = "snake_case")]
316#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
317#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
318#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
319#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
320pub struct CircularArc2d {
321 pub origin: Point2d<f64>,
323 pub radius: f64,
325 pub start_angle: f64,
327 pub end_angle: f64,
329 #[serde(default)]
332 #[builder(default)]
333 pub winding: Winding,
334}
335
336#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
340#[serde(rename_all = "snake_case")]
341#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
342#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
343#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
344#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
345pub struct Nurbs2d {
346 pub control_points: Vec<Point2d<f64>>,
348 #[serde(default, skip_serializing_if = "Vec::is_empty")]
350 pub weights: Vec<f64>,
351 pub knot_vector: Vec<f64>,
354 pub order: u32,
356}
357
358#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
360#[serde(tag = "type", rename_all = "snake_case")]
361#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
362#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
363#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
364#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
365pub enum ProjectionCurveGeometry {
366 Line {
368 #[serde(flatten)]
370 data: LineSegment2d,
371 },
372 CircularArc {
374 #[serde(flatten)]
376 data: CircularArc2d,
377 },
378 Nurbs {
380 #[serde(flatten)]
382 data: Nurbs2d,
383 },
384}
385
386#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
388#[serde(rename_all = "snake_case")]
389#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
390#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
391#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
392#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
393pub struct ProjectionCurve {
394 pub segment_index: u32,
397 pub geometry: ProjectionCurveGeometry,
399 pub visibility: ProjectionCurveVisibility,
401 pub source: ProjectionCurveSource,
403}
404
405#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
407#[serde(rename_all = "snake_case")]
408#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
409#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
410#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
411pub enum CutType {
412 #[default]
414 Fillet,
415 Chamfer,
417}
418
419#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
421#[serde(rename_all = "snake_case")]
422#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
423#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
424#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
425pub enum DirectionType {
426 Edge {
428 id: Uuid,
430 },
431 Axis {
433 direction: Point3d<f64>,
435 },
436}
437
438#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
440#[serde(rename_all = "snake_case")]
441#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
442#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
443#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
444pub enum MirrorAcross {
445 Edge {
448 id: Uuid,
450 },
451 EdgeReference {
454 reference: EdgeSpecifier,
456 },
457 Axis {
460 axis: Point3d<f64>,
462 point: Point3d<LengthUnit>,
464 },
465 Plane {
468 id: Uuid,
470 },
471}
472
473#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
475#[serde(rename_all = "snake_case")]
476#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
477#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
478#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
479#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
480pub enum CutTypeV2 {
481 Fillet {
483 radius: LengthUnit,
485 second_length: Option<LengthUnit>,
488 },
489 Chamfer {
491 distance: LengthUnit,
493 second_distance: Option<LengthUnit>,
495 angle: Option<Angle>,
497 swap: bool,
499 },
500 Custom {
502 path: Uuid,
504 },
505}
506
507#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
509#[serde(rename_all = "snake_case")]
510#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
511#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
512#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
513#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
514pub struct Rotation {
515 pub axis: Point3d<f64>,
518 pub angle: Angle,
521 pub origin: OriginType,
523}
524
525impl Default for Rotation {
526 fn default() -> Self {
528 Self {
529 axis: z_axis(),
530 angle: Angle::default(),
531 origin: OriginType::Local,
532 }
533 }
534}
535
536#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
538#[serde(rename_all = "snake_case")]
539#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
540#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
541#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
542#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
543pub struct Transform {
544 #[serde(default)]
547 #[builder(default)]
548 pub translate: Point3d<LengthUnit>,
549 #[serde(default = "same_scale")]
552 #[builder(default = same_scale())]
553 pub scale: Point3d<f64>,
554 #[serde(default)]
557 #[builder(default)]
558 pub rotation: Rotation,
559 #[serde(default = "bool_true")]
561 #[builder(default = bool_true())]
562 pub replicate: bool,
563}
564
565impl Default for Transform {
566 fn default() -> Self {
567 Self {
568 scale: same_scale(),
569 replicate: true,
570 translate: Default::default(),
571 rotation: Rotation::default(),
572 }
573 }
574}
575
576#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
578#[serde(rename_all = "snake_case")]
579#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
580#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
581#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
582#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
583pub struct AnnotationOptions {
584 pub text: Option<AnnotationTextOptions>,
586 pub line_ends: Option<AnnotationLineEndOptions>,
588 pub line_width: Option<f32>,
590 pub color: Option<Color>,
592 pub position: Option<Point3d<f32>>,
594 #[serde(default, skip_serializing_if = "Option::is_none")]
596 pub units: Option<units::UnitLength>,
597 pub dimension: Option<AnnotationBasicDimension>,
599 pub feature_control: Option<AnnotationFeatureControl>,
601 pub feature_tag: Option<AnnotationFeatureTag>,
603 #[serde(default, skip_serializing_if = "Option::is_none")]
608 pub name: Option<String>,
609}
610
611#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
613#[serde(rename_all = "snake_case")]
614#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
615#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
616#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
617#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
618pub struct AnnotationLineEndOptions {
619 pub start: AnnotationLineEnd,
621 pub end: AnnotationLineEnd,
623}
624
625#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
627#[serde(rename_all = "snake_case")]
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 AnnotationTextOptions {
633 pub x: AnnotationTextAlignmentX,
635 pub y: AnnotationTextAlignmentY,
637 pub text: String,
639 pub point_size: u32,
641}
642
643#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
645#[serde(rename_all = "snake_case")]
646#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
647#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
648#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
649#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
650pub enum AnnotationMbdLeaderPosition {
651 NormalizedPos {
653 pos: Point2d<f64>,
655 },
656
657 Centroid {},
659
660 StepFrom {},
664
665 Auto {},
672}
673
674#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
676#[serde(rename_all = "snake_case")]
677#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
678#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
679#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
680#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
681pub struct AnnotationMbdControlFrame {
682 pub symbol: MbdSymbol,
684 pub diameter_symbol: Option<MbdSymbol>,
686 pub tolerance: f64,
689 pub modifier: Option<MbdSymbol>,
691 pub primary_datum: Option<char>,
693 pub secondary_datum: Option<char>,
695 pub tertiary_datum: Option<char>,
697}
698
699#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
701#[serde(rename_all = "snake_case")]
702#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
703#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
704#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
705#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
706pub struct AnnotationMbdBasicDimension {
707 pub symbol: Option<MbdSymbol>,
709 pub dimension: Option<f64>,
712 #[serde(default, skip_serializing_if = "Option::is_none")]
714 pub tolerance: Option<f64>,
715}
716
717#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
719#[serde(rename_all = "snake_case")]
720#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
721#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
722#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
723#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
724pub struct AnnotationBasicDimension {
725 #[serde(default, skip_serializing_if = "Option::is_none")]
727 pub from_entity_id: Option<Uuid>,
728
729 #[serde(default, skip_serializing_if = "Option::is_none")]
732 pub from_edge_reference: Option<EdgeSpecifier>,
733
734 #[serde(default, skip_serializing_if = "Option::is_none")]
736 pub from_entity_leader_pos: Option<AnnotationMbdLeaderPosition>,
737
738 #[serde(default, skip_serializing_if = "Option::is_none")]
741 pub from_entity_pos: Option<Point2d<f64>>,
742
743 #[serde(default, skip_serializing_if = "Option::is_none")]
745 pub to_entity_id: Option<Uuid>,
746
747 #[serde(default, skip_serializing_if = "Option::is_none")]
751 pub to_edge_reference: Option<EdgeSpecifier>,
752
753 #[serde(default, skip_serializing_if = "Option::is_none")]
755 pub to_entity_leader_pos: Option<AnnotationMbdLeaderPosition>,
756
757 #[serde(default, skip_serializing_if = "Option::is_none")]
760 pub to_entity_pos: Option<Point2d<f64>>,
761
762 pub dimension: AnnotationMbdBasicDimension,
764
765 pub plane_id: Uuid,
767
768 pub offset: Point2d<f64>,
770
771 pub precision: u32,
773
774 pub font_scale: f32,
776
777 pub font_point_size: u32,
779
780 #[serde(default = "one")]
782 pub arrow_scale: f32,
783}
784
785#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
787#[serde(rename_all = "snake_case")]
788#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
789#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
790#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
791#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
792pub struct AnnotationFeatureControl {
793 #[serde(default, skip_serializing_if = "Option::is_none")]
795 pub entity_id: Option<Uuid>,
796
797 #[serde(default, skip_serializing_if = "Option::is_none")]
800 pub edge_reference: Option<EdgeSpecifier>,
801
802 #[serde(default, skip_serializing_if = "Option::is_none")]
804 pub entity_leader_pos: Option<AnnotationMbdLeaderPosition>,
805
806 #[serde(default, skip_serializing_if = "Option::is_none")]
809 pub entity_pos: Option<Point2d<f64>>,
810
811 pub leader_type: AnnotationLineEnd,
813
814 pub dimension: Option<AnnotationMbdBasicDimension>,
816
817 pub control_frame: Option<AnnotationMbdControlFrame>,
819
820 pub defined_datum: Option<char>,
822
823 pub prefix: Option<String>,
825
826 pub suffix: Option<String>,
828
829 pub plane_id: Uuid,
831
832 pub offset: Point2d<f64>,
834
835 pub precision: u32,
837
838 pub font_scale: f32,
840
841 pub font_point_size: u32,
843
844 #[serde(default = "one")]
846 pub leader_scale: f32,
847}
848
849#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
851#[serde(rename_all = "snake_case")]
852#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
853#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
854#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
855#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
856pub struct AnnotationFeatureTag {
857 #[serde(default, skip_serializing_if = "Option::is_none")]
859 pub entity_id: Option<Uuid>,
860
861 #[serde(default, skip_serializing_if = "Option::is_none")]
864 pub edge_reference: Option<EdgeSpecifier>,
865
866 #[serde(default, skip_serializing_if = "Option::is_none")]
868 pub entity_leader_pos: Option<AnnotationMbdLeaderPosition>,
869
870 #[serde(default, skip_serializing_if = "Option::is_none")]
873 pub entity_pos: Option<Point2d<f64>>,
874
875 pub leader_type: AnnotationLineEnd,
877
878 pub key: String,
880
881 pub value: String,
883
884 pub show_key: bool,
886
887 pub plane_id: Uuid,
889
890 pub offset: Point2d<f64>,
892
893 pub font_scale: f32,
895
896 pub font_point_size: u32,
898
899 #[serde(default = "one")]
901 pub leader_scale: f32,
902}
903
904#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
908#[serde(rename_all = "snake_case", tag = "type")]
909#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
910#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
911#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
912#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
913pub enum DistanceType {
914 Euclidean {},
916 OnAxis {
918 axis: GlobalAxis,
920 },
921}
922
923#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
925#[serde(rename_all = "snake_case", tag = "type")]
926#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
927#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
928#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
929#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
930pub enum OriginType {
931 #[default]
933 Local,
934 Global,
936 Custom {
938 origin: Point3d<f64>,
940 },
941}
942
943#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
945#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
946#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
947#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
948#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
949pub struct Color {
950 pub r: f32,
952 pub g: f32,
954 pub b: f32,
956 pub a: f32,
958}
959
960impl Color {
961 pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
963 Self { r, g, b, a }
964 }
965}
966
967#[allow(missing_docs)]
969#[derive(
970 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
971)]
972#[serde(rename_all = "lowercase")]
973#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
974#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
975#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
976#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
977pub enum AnnotationTextAlignmentX {
978 Left,
979 Center,
980 Right,
981}
982
983#[allow(missing_docs)]
985#[derive(
986 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
987)]
988#[serde(rename_all = "lowercase")]
989#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
990#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
991#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
992#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
993pub enum AnnotationTextAlignmentY {
994 Bottom,
995 Center,
996 Top,
997}
998
999#[allow(missing_docs)]
1001#[derive(
1002 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1003)]
1004#[serde(rename_all = "lowercase")]
1005#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1006#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1007#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1008#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1009pub enum AnnotationLineEnd {
1010 None,
1011 Arrow,
1012 Dot,
1013}
1014
1015#[derive(
1017 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1018)]
1019#[serde(rename_all = "lowercase")]
1020#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1021#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1022#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1023#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1024pub enum AnnotationType {
1025 T2D,
1027 T3D,
1029}
1030
1031#[derive(
1033 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1034)]
1035#[serde(rename_all = "lowercase")]
1036#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1037#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1038#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1039#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1040pub enum MbdStandard {
1041 AsmeY14_5,
1043}
1044
1045#[allow(missing_docs)]
1048#[derive(
1049 Default,
1050 Display,
1051 FromStr,
1052 Copy,
1053 Eq,
1054 PartialEq,
1055 Debug,
1056 JsonSchema,
1057 Deserialize,
1058 Serialize,
1059 Sequence,
1060 Clone,
1061 Ord,
1062 PartialOrd,
1063)]
1064#[serde(rename_all = "lowercase")]
1065#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1066#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1067#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1068#[repr(u16)]
1069#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1070pub enum MbdSymbol {
1071 #[default]
1072 None = 0,
1073 ArcLength = 174,
1074 Between = 175,
1075 Degrees = 176,
1076 PlusMinus = 177,
1077 Angularity = 178,
1078 Cylindricity = 179,
1079 Roundness = 180,
1080 Concentricity = 181,
1081 Straightness = 182,
1082 Parallelism = 183,
1083 Flatness = 184,
1084 ProfileOfLine = 185,
1085 SurfaceProfile = 186,
1086 Symmetry = 187,
1087 Perpendicularity = 188,
1088 Runout = 189,
1089 TotalRunout = 190,
1090 Position = 191,
1091 CenterLine = 192,
1092 PartingLine = 193,
1093 IsoEnvelope = 195,
1094 IsoEnvelopeNonY145M = 196,
1095 FreeState = 197,
1096 StatisticalTolerance = 198,
1097 ContinuousFeature = 199,
1098 Independency = 200,
1099 Depth = 201,
1100 Start = 202,
1101 LeastCondition = 203,
1102 MaxCondition = 204,
1103 ConicalTaper = 205,
1104 Projected = 206,
1105 Slope = 207,
1106 Micro = 208,
1107 TangentPlane = 210,
1108 Unilateral = 211,
1109 SquareFeature = 212,
1110 Countersink = 213,
1111 SpotFace = 214,
1112 Target = 215,
1113 Diameter = 216,
1114 Radius = 217,
1115 SphericalRadius = 218,
1116 SphericalDiameter = 219,
1117 ControlledRadius = 220,
1118 BoxStart = 123,
1119 BoxBar = 162,
1120 BoxBarBetween = 124,
1121 LetterBackwardUnderline = 95,
1122 PunctuationBackwardUnderline = 92,
1123 ModifierBackwardUnderline = 126,
1124 NumericBackwardUnderline = 96,
1125 BoxEnd = 125,
1126 DatumUp = 166,
1127 DatumLeft = 168,
1128 DatumRight = 167,
1129 DatumDown = 165,
1130 DatumTriangle = 295,
1131 HalfSpace = 236,
1132 QuarterSpace = 237,
1133 EighthSpace = 238,
1134 ModifierSpace = 239,
1135}
1136
1137#[derive(
1139 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1140)]
1141#[serde(rename_all = "lowercase")]
1142#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1143#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1144#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1145#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1146pub enum CameraDragInteractionType {
1147 Pan,
1149 Rotate,
1151 RotateTrackball,
1153 Zoom,
1155}
1156
1157#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
1160#[serde(rename_all = "snake_case", tag = "type")]
1161#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1162#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1163#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1164#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1165pub enum PathSegment {
1166 Line {
1169 end: Point3d<LengthUnit>,
1171 relative: bool,
1173 },
1174 Arc {
1177 center: Point2d<LengthUnit>,
1179 radius: LengthUnit,
1181 start: Angle,
1183 end: Angle,
1185 relative: bool,
1187 },
1188 Bezier {
1192 control1: Point3d<LengthUnit>,
1194 control2: Point3d<LengthUnit>,
1196 end: Point3d<LengthUnit>,
1198 relative: bool,
1200 },
1201 TangentialArc {
1203 radius: LengthUnit,
1206 offset: Angle,
1208 },
1209 TangentialArcTo {
1212 to: Point3d<LengthUnit>,
1216 angle_snap_increment: Option<Angle>,
1218 },
1219 ArcTo {
1221 interior: Point3d<LengthUnit>,
1223 end: Point3d<LengthUnit>,
1225 relative: bool,
1227 },
1228 CircularInvolute {
1231 start_radius: LengthUnit,
1234 end_radius: LengthUnit,
1237 angle: Angle,
1240 reverse: bool,
1243 },
1244 Ellipse {
1246 center: Point2d<LengthUnit>,
1248 major_axis: Point2d<LengthUnit>,
1250 minor_radius: LengthUnit,
1252 start_angle: Angle,
1254 end_angle: Angle,
1256 },
1257 ConicTo {
1260 interior: Point2d<LengthUnit>,
1262 end: Point2d<LengthUnit>,
1264 start_tangent: Point2d<LengthUnit>,
1266 end_tangent: Point2d<LengthUnit>,
1268 relative: bool,
1270 },
1271}
1272
1273#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
1275#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1276#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1277#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1278#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1279pub struct Angle {
1280 pub unit: UnitAngle,
1282 pub value: f64,
1284}
1285
1286impl Angle {
1287 pub fn to_degrees(self) -> f64 {
1289 match self.unit {
1290 UnitAngle::Degrees => self.value,
1291 UnitAngle::Radians => self.value.to_degrees(),
1292 }
1293 }
1294 pub fn to_radians(self) -> f64 {
1296 match self.unit {
1297 UnitAngle::Degrees => self.value.to_radians(),
1298 UnitAngle::Radians => self.value,
1299 }
1300 }
1301 pub const fn from_degrees(value: f64) -> Self {
1303 Self {
1304 unit: UnitAngle::Degrees,
1305 value,
1306 }
1307 }
1308 pub const fn from_radians(value: f64) -> Self {
1310 Self {
1311 unit: UnitAngle::Radians,
1312 value,
1313 }
1314 }
1315 pub const fn turn() -> Self {
1317 Self::from_degrees(360.0)
1318 }
1319 pub const fn half_circle() -> Self {
1321 Self::from_degrees(180.0)
1322 }
1323 pub const fn quarter_circle() -> Self {
1325 Self::from_degrees(90.0)
1326 }
1327 pub const fn zero() -> Self {
1329 Self::from_degrees(0.0)
1330 }
1331}
1332
1333impl Default for Angle {
1335 fn default() -> Self {
1337 Self::zero()
1338 }
1339}
1340
1341impl PartialOrd for Angle {
1342 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
1343 match (self.unit, other.unit) {
1344 (UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
1346 (UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
1347 _ => self.to_degrees().partial_cmp(&other.to_degrees()),
1348 }
1349 }
1350}
1351
1352impl std::ops::Add for Angle {
1353 type Output = Self;
1354
1355 fn add(self, rhs: Self) -> Self::Output {
1356 Self {
1357 unit: UnitAngle::Degrees,
1358 value: self.to_degrees() + rhs.to_degrees(),
1359 }
1360 }
1361}
1362
1363impl std::ops::AddAssign for Angle {
1364 fn add_assign(&mut self, rhs: Self) {
1365 match self.unit {
1366 UnitAngle::Degrees => {
1367 self.value += rhs.to_degrees();
1368 }
1369 UnitAngle::Radians => {
1370 self.value += rhs.to_radians();
1371 }
1372 }
1373 }
1374}
1375
1376#[derive(
1378 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1379)]
1380#[serde(rename_all = "lowercase")]
1381#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1382#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1383#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1384#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1385pub enum SceneSelectionType {
1386 Replace,
1388 Add,
1390 Remove,
1392}
1393
1394#[allow(missing_docs)]
1396#[derive(
1397 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1398)]
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 SceneToolType {
1405 CameraRevolve,
1406 Select,
1407 Move,
1408 SketchLine,
1409 SketchTangentialArc,
1410 SketchCurve,
1411 SketchCurveMod,
1412}
1413
1414#[allow(missing_docs)]
1416#[derive(
1417 Display,
1418 FromStr,
1419 Copy,
1420 Eq,
1421 PartialEq,
1422 Debug,
1423 JsonSchema,
1424 Deserialize,
1425 Serialize,
1426 Sequence,
1427 Clone,
1428 Ord,
1429 PartialOrd,
1430 Default,
1431)]
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 PathComponentConstraintBound {
1438 #[default]
1439 Unconstrained,
1440 PartiallyConstrained,
1441 FullyConstrained,
1442}
1443
1444#[allow(missing_docs)]
1446#[derive(
1447 Display,
1448 FromStr,
1449 Copy,
1450 Eq,
1451 PartialEq,
1452 Debug,
1453 JsonSchema,
1454 Deserialize,
1455 Serialize,
1456 Sequence,
1457 Clone,
1458 Ord,
1459 PartialOrd,
1460 Default,
1461)]
1462#[serde(rename_all = "snake_case")]
1463#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1464#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1465#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1466#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1467pub enum PathComponentConstraintType {
1468 #[default]
1469 Unconstrained,
1470 Vertical,
1471 Horizontal,
1472 EqualLength,
1473 Parallel,
1474 AngleBetween,
1475}
1476
1477#[allow(missing_docs)]
1479#[derive(
1480 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1481)]
1482#[serde(rename_all = "snake_case")]
1483#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1484#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1485#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1486#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1487pub enum PathCommand {
1488 MoveTo,
1489 LineTo,
1490 BezCurveTo,
1491 NurbsCurveTo,
1492 AddArc,
1493}
1494
1495#[allow(missing_docs)]
1497#[derive(
1498 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1499)]
1500#[serde(rename_all = "lowercase")]
1501#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1502#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1503#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1504#[repr(u8)]
1505#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1506pub enum EntityType {
1507 Entity,
1508 Object,
1509 Path,
1510 Segment,
1511 Curve,
1512 Solid2D,
1513 Solid3D,
1514 Edge,
1515 Face,
1516 Plane,
1517 Vertex,
1518 Region,
1519 PatternGroup,
1520 Annotation,
1521}
1522
1523#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1525#[serde(rename_all = "snake_case")]
1526#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1527#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1528#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1529#[repr(u8)]
1530#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1531pub enum HiddenState {
1532 Hidden = 0,
1534 Visible = 1,
1536 NoSuchObject = 2,
1538}
1539
1540#[allow(missing_docs)]
1542#[derive(
1543 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1544)]
1545#[serde(rename_all = "snake_case")]
1546#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1547#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1548#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1549#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1550pub enum CurveType {
1551 Line,
1552 Arc,
1553 Nurbs,
1554}
1555
1556#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1558#[cfg_attr(
1559 feature = "python",
1560 pyo3::pyclass(from_py_object),
1561 pyo3_stub_gen::derive::gen_stub_pyclass
1562)]
1563#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1564pub struct ExportFile {
1565 pub name: String,
1567 pub contents: crate::base64::Base64Data,
1569}
1570
1571#[cfg(feature = "python")]
1572#[pyo3_stub_gen::derive::gen_stub_pymethods]
1573#[pyo3::pymethods]
1574impl ExportFile {
1575 #[getter]
1576 fn contents(&self) -> Vec<u8> {
1577 self.contents.0.clone()
1578 }
1579
1580 #[getter]
1581 fn name(&self) -> String {
1582 self.name.clone()
1583 }
1584}
1585
1586#[derive(
1588 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1589)]
1590#[serde(rename_all = "lowercase")]
1591#[display(style = "lowercase")]
1592#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1593#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1594#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1595#[cfg_attr(
1596 feature = "python",
1597 pyo3::pyclass(from_py_object),
1598 pyo3_stub_gen::derive::gen_stub_pyclass_enum
1599)]
1600#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1601pub enum FileExportFormat {
1602 Fbx,
1604 Glb,
1611 Gltf,
1622 Obj,
1626 Ply,
1628 Step,
1630 Stl,
1632 Rhino,
1634}
1635
1636#[derive(
1638 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1639)]
1640#[serde(rename_all = "lowercase")]
1641#[display(style = "lowercase")]
1642#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1643#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1644#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1645#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1646pub enum FileExportFormat2d {
1647 Dxf,
1649}
1650
1651#[derive(
1653 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
1654)]
1655#[serde(rename_all = "lowercase")]
1656#[display(style = "lowercase")]
1657#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1658#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1659#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1660#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1661pub enum FileImportFormat {
1662 Acis,
1664 Catia,
1666 Creo,
1668 Fbx,
1670 Gltf,
1672 Inventor,
1674 Nx,
1676 Obj,
1680 Parasolid,
1682 Ply,
1684 Sldprt,
1686 Step,
1688 Stl,
1690 Rhino,
1692}
1693
1694#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
1696#[serde(rename_all = "snake_case")]
1697#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1698#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1699#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1700#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1701pub enum EngineErrorCode {
1702 BadRequest = 1,
1706 InternalEngine,
1708}
1709
1710impl From<EngineErrorCode> for http::StatusCode {
1711 fn from(e: EngineErrorCode) -> Self {
1712 match e {
1713 EngineErrorCode::BadRequest => Self::BAD_REQUEST,
1714 EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
1715 }
1716 }
1717}
1718
1719#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1721#[serde(rename_all = "snake_case")]
1722#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1723#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1724#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1725pub enum BlendType {
1726 #[default]
1728 Tangent,
1729}
1730
1731#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1733#[serde(rename_all = "snake_case")]
1734#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1735#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1736#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1737#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1738pub enum BodyType {
1739 #[default]
1741 Solid,
1742 Surface,
1744}
1745
1746#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1749#[serde(rename_all = "snake_case")]
1750#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1751#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1752#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1753#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1754pub enum ExtrudeMethod {
1755 New,
1758 #[default]
1761 Merge,
1762}
1763
1764#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1766#[serde(rename_all = "snake_case")]
1767#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1768#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1769#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1770#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1771pub enum ExtrudeReference {
1772 EntityReference {
1775 #[serde(default, skip_serializing_if = "Option::is_none")]
1777 entity_id: Option<Uuid>,
1778 #[serde(default, skip_serializing_if = "Option::is_none")]
1780 entity_reference: Option<EntityReference>,
1781 },
1782 Axis {
1784 axis: Point3d<f64>,
1786 #[serde(default)]
1789 point: Point3d<LengthUnit>,
1790 },
1791 Point {
1793 point: Point3d<LengthUnit>,
1795 },
1796}
1797
1798#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1800#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1801#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1802#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1803#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1804pub struct ExtrudedFaceInfo {
1805 pub bottom: Option<Uuid>,
1810 pub top: Uuid,
1812 pub sides: Vec<SideFace>,
1814}
1815
1816#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, Builder)]
1818#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1819#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1820#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1821#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1822pub struct SideFace {
1823 pub path_id: Uuid,
1825 pub face_id: Uuid,
1827}
1828
1829#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Builder)]
1831#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1832#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1833#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1834#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1835pub struct CameraSettings {
1836 pub pos: Point3d,
1838
1839 pub center: Point3d,
1841
1842 pub up: Point3d,
1844
1845 pub orientation: Quaternion,
1847
1848 pub fov_y: Option<f32>,
1850
1851 pub ortho_scale: Option<f32>,
1853
1854 pub ortho: bool,
1856}
1857
1858#[allow(missing_docs)]
1859#[repr(u8)]
1860#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1861#[serde(rename_all = "snake_case")]
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 enum WorldCoordinateSystem {
1867 #[default]
1868 RightHandedUpZ,
1869 RightHandedUpY,
1870}
1871
1872#[allow(missing_docs)]
1873#[repr(C)]
1874#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
1875#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1876#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1877#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1878#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1879pub struct CameraViewState {
1880 pub pivot_rotation: Quaternion,
1881 pub pivot_position: Point3d,
1882 pub eye_offset: f32,
1883 pub fov_y: f32,
1884 pub ortho_scale_factor: f32,
1885 pub is_ortho: bool,
1886 pub ortho_scale_enabled: bool,
1887 pub world_coord_system: WorldCoordinateSystem,
1888}
1889
1890impl Default for CameraViewState {
1891 fn default() -> Self {
1892 CameraViewState {
1893 pivot_rotation: Default::default(),
1894 pivot_position: Default::default(),
1895 eye_offset: 10.0,
1896 fov_y: 45.0,
1897 ortho_scale_factor: 1.6,
1898 is_ortho: false,
1899 ortho_scale_enabled: true,
1900 world_coord_system: Default::default(),
1901 }
1902 }
1903}
1904
1905#[cfg(feature = "cxx")]
1906impl_extern_type! {
1907 [Trivial]
1908 CameraViewState = "Endpoints::CameraViewState"
1909}
1910
1911impl From<CameraSettings> for crate::output::DefaultCameraZoom {
1912 fn from(settings: CameraSettings) -> Self {
1913 Self { settings }
1914 }
1915}
1916impl From<CameraSettings> for crate::output::CameraDragMove {
1917 fn from(settings: CameraSettings) -> Self {
1918 Self { settings }
1919 }
1920}
1921impl From<CameraSettings> for crate::output::CameraDragEnd {
1922 fn from(settings: CameraSettings) -> Self {
1923 Self { settings }
1924 }
1925}
1926impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
1927 fn from(settings: CameraSettings) -> Self {
1928 Self { settings }
1929 }
1930}
1931impl From<CameraSettings> for crate::output::ZoomToFit {
1932 fn from(settings: CameraSettings) -> Self {
1933 Self { settings }
1934 }
1935}
1936impl From<CameraSettings> for crate::output::OrientToFace {
1937 fn from(settings: CameraSettings) -> Self {
1938 Self { settings }
1939 }
1940}
1941impl From<CameraSettings> for crate::output::ViewIsometric {
1942 fn from(settings: CameraSettings) -> Self {
1943 Self { settings }
1944 }
1945}
1946
1947#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default, Builder)]
1949#[serde(rename_all = "snake_case")]
1950#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1951#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1952#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1953#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1954pub struct PerspectiveCameraParameters {
1955 pub fov_y: Option<f32>,
1957 pub z_near: Option<f32>,
1959 pub z_far: Option<f32>,
1961}
1962
1963#[derive(
1965 Default,
1966 Display,
1967 FromStr,
1968 Copy,
1969 Eq,
1970 PartialEq,
1971 Debug,
1972 JsonSchema,
1973 Deserialize,
1974 Serialize,
1975 Sequence,
1976 Clone,
1977 Ord,
1978 PartialOrd,
1979)]
1980#[serde(rename_all = "snake_case")]
1981#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1982#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1983#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1984#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1985pub enum CameraMovement {
1986 #[default]
1988 Vantage,
1989 None,
1991}
1992
1993#[derive(
1995 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
1996)]
1997#[serde(rename_all = "lowercase")]
1998#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1999#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2000#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2001#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2002pub enum GlobalAxis {
2003 X,
2005 Y,
2007 Z,
2009}
2010
2011#[derive(
2013 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
2014)]
2015#[serde(rename_all = "snake_case")]
2016#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2017#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2018#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2019#[repr(u8)]
2020#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2021pub enum ExtrusionFaceCapType {
2022 None,
2024 Top,
2026 Bottom,
2028 Both,
2030}
2031
2032#[allow(missing_docs)]
2034#[derive(
2035 Display,
2036 FromStr,
2037 Copy,
2038 Eq,
2039 PartialEq,
2040 Debug,
2041 JsonSchema,
2042 Deserialize,
2043 Serialize,
2044 Sequence,
2045 Clone,
2046 Ord,
2047 PartialOrd,
2048 Default,
2049)]
2050#[serde(rename_all = "lowercase")]
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 enum PostEffectType {
2056 Phosphor,
2057 Ssao,
2058 RetroCad,
2059 #[default]
2060 NoEffect,
2061}
2062
2063#[cfg(feature = "cxx")]
2066impl_extern_type! {
2067 [Trivial]
2068 FileImportFormat = "Enums::_FileImportFormat"
2070 FileExportFormat = "Enums::_FileExportFormat"
2071 CameraDragInteractionType = "Enums::_CameraDragInteractionType"
2073 SceneSelectionType = "Enums::_SceneSelectionType"
2075 SceneToolType = "Enums::_SceneToolType"
2076 BlendType = "Enums::_BlendType"
2077 BodyType = "Enums::_BodyType"
2078 EntityType = "Enums::_EntityType"
2079 HiddenState = "Enums::_HiddenState"
2080 AnnotationType = "Enums::_AnnotationType"
2081 AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
2082 AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
2083 AnnotationLineEnd = "Enums::_AnnotationLineEnd"
2084 MbdStandard = "Enums::_MBDStandard"
2085 MbdSymbol = "Enums::_MBDSymbol"
2086
2087 CurveType = "Enums::_CurveType"
2088 PathCommand = "Enums::_PathCommand"
2089 PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
2090 PathComponentConstraintType = "Enums::_PathComponentConstraintType"
2091 ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
2092
2093 EngineErrorCode = "Enums::_ErrorCode"
2095 GlobalAxis = "Enums::_GlobalAxis"
2096 OriginType = "Enums::_OriginType"
2097
2098 PostEffectType = "Enums::_PostEffectType"
2100}
2101
2102fn bool_true() -> bool {
2103 true
2104}
2105fn same_scale() -> Point3d<f64> {
2106 Point3d::uniform(1.0)
2107}
2108
2109fn z_axis() -> Point3d<f64> {
2110 Point3d { x: 0.0, y: 0.0, z: 1.0 }
2111}
2112
2113impl ExtrudedFaceInfo {
2114 pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
2117 let mut face_infos: Vec<_> = self
2118 .sides
2119 .into_iter()
2120 .map(|side| ExtrusionFaceInfo {
2121 curve_id: Some(side.path_id),
2122 face_id: Some(side.face_id),
2123 cap: ExtrusionFaceCapType::None,
2124 })
2125 .collect();
2126 face_infos.push(ExtrusionFaceInfo {
2127 curve_id: None,
2128 face_id: Some(self.top),
2129 cap: ExtrusionFaceCapType::Top,
2130 });
2131 if let Some(bottom) = self.bottom {
2132 face_infos.push(ExtrusionFaceInfo {
2133 curve_id: None,
2134 face_id: Some(bottom),
2135 cap: ExtrusionFaceCapType::Bottom,
2136 });
2137 }
2138 face_infos
2139 }
2140}
2141
2142#[cfg(test)]
2143mod tests {
2144 use super::*;
2145 use serde_json::json;
2146
2147 #[test]
2148 fn circular_arc_winding_defaults_to_counterclockwise() {
2149 let wire = json!({"origin": {"x": 0.0, "y": 0.0}, "radius": 5.0,
2150 "start_angle": 0.0, "end_angle": std::f64::consts::FRAC_PI_2});
2151 let arc: CircularArc2d = serde_json::from_value(wire).unwrap();
2152 assert_eq!(arc.winding, Winding::Counterclockwise);
2153
2154 let built = CircularArc2d::builder()
2155 .origin(arc.origin)
2156 .radius(arc.radius)
2157 .start_angle(arc.start_angle)
2158 .end_angle(arc.end_angle)
2159 .build();
2160 assert_eq!(built.winding, Winding::Counterclockwise);
2161 assert_eq!(serde_json::to_value(built).unwrap()["winding"], "counterclockwise");
2162 }
2163
2164 #[test]
2165 fn orthographic_projection_non_rational_nurbs_omits_weights() {
2166 let wire = json!({"type": "nurbs", "control_points": [{"x": 0.0, "y": 0.0}, {"x": 1.0, "y": 0.0}],
2167 "knot_vector": [0.0, 0.0, 1.0, 1.0], "order": 2});
2168 let parsed: crate::shared::ProjectionCurveGeometry = serde_json::from_value(wire.clone()).unwrap();
2169 assert_eq!(serde_json::to_value(parsed).unwrap(), wire);
2170 }
2171
2172 #[test]
2173 fn orthographic_projection_source_requires_topology_and_component_identity() {
2174 for source in [
2175 json!({"type": "edge", "section_index": 0}),
2176 json!({"type": "edge", "edge_index": 2}),
2177 json!({"type": "silhouette", "face_index": 2}),
2178 json!({"type": "silhouette", "edge_index": 2, "silhouette_index": 0}),
2179 ] {
2180 assert!(serde_json::from_value::<ProjectionCurveSource>(source).is_err());
2181 }
2182 }
2183
2184 #[test]
2185 fn test_angle_comparison() {
2186 let a = Angle::from_degrees(90.0);
2187 assert!(a < Angle::from_degrees(91.0));
2188 assert!(a > Angle::from_degrees(89.0));
2189 assert!(a <= Angle::from_degrees(90.0));
2190 assert!(a >= Angle::from_degrees(90.0));
2191 let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
2192 assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
2193 assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
2194 assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
2195 assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
2196 assert!(a > b);
2198 assert!(a >= b);
2199 assert!(b < a);
2200 assert!(b <= a);
2201 let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
2202 assert!(a < c);
2203 assert!(a <= c);
2204 assert!(c > a);
2205 assert!(c >= a);
2206 }
2207}
2208
2209#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, JsonSchema, Builder)]
2211#[schemars(rename = "TransformByFor{T}")]
2212#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2213#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2214#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2215#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2216pub struct TransformBy<T> {
2217 pub property: T,
2219 pub set: bool,
2224 #[serde(default)]
2226 #[builder(default)]
2227 pub origin: OriginType,
2228}
2229
2230impl<T> TransformBy<T> {
2231 pub fn get_origin(&self) -> OriginType {
2234 self.origin
2235 }
2236}
2237
2238#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, Default, Builder)]
2241#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2242#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2243#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2244#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2245pub struct ComponentTransform {
2246 pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
2248 pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
2251 pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
2255 pub scale: Option<TransformBy<Point3d<f64>>>,
2257}
2258
2259#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
2262#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2263#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2264#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2265#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2266pub enum Opposite<T> {
2267 #[default]
2269 None,
2270 Symmetric,
2272 Other(T),
2274}
2275
2276impl<T: JsonSchema> JsonSchema for Opposite<T> {
2277 fn schema_name() -> String {
2278 format!("OppositeFor{}", T::schema_name())
2279 }
2280
2281 fn schema_id() -> std::borrow::Cow<'static, str> {
2282 std::borrow::Cow::Owned(format!("{}::Opposite<{}>", module_path!(), T::schema_id()))
2283 }
2284
2285 fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
2286 SchemaObject {
2287 instance_type: Some(schemars::schema::InstanceType::String.into()),
2288 ..Default::default()
2289 }
2290 .into()
2291 }
2292}
2293
2294#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2297#[serde(rename_all = "snake_case")]
2298#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2299#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2300#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2301#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2302pub enum CutStrategy {
2303 Basic,
2306 Csg,
2309 #[default]
2311 Automatic,
2312}
2313
2314#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2316#[serde(rename_all = "snake_case")]
2317#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2318#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2319#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2320#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2321pub enum RelativeTo {
2322 #[default]
2324 SketchPlane,
2325 TrajectoryCurve,
2327}
2328
2329#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
2331#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2332#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2333#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2334pub struct SelectedRegion {
2335 pub segment: Uuid,
2337 pub intersection_segment: Uuid,
2340 #[serde(default = "negative_one")]
2344 pub intersection_index: i32,
2345 #[serde(default)]
2348 pub curve_clockwise: bool,
2349}
2350
2351impl Default for SelectedRegion {
2352 fn default() -> Self {
2353 Self {
2354 segment: Default::default(),
2355 intersection_segment: Default::default(),
2356 intersection_index: -1,
2357 curve_clockwise: Default::default(),
2358 }
2359 }
2360}
2361
2362#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2364#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2365#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2366#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2367#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2368pub struct FractionOfEdge {
2369 #[serde(default, skip_serializing_if = "Option::is_none")]
2371 pub edge_id: Option<Uuid>,
2372 #[serde(default, skip_serializing_if = "Option::is_none")]
2374 pub edge_specifier: Option<EdgeSpecifier>,
2375 #[serde(default)]
2379 #[builder(default)]
2380 #[schemars(range(min = 0, max = 1))]
2381 pub lower_bound: f32,
2382 #[serde(default = "one")]
2386 #[builder(default = one())]
2387 #[schemars(range(min = 0, max = 1))]
2388 pub upper_bound: f32,
2389}
2390
2391#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2393#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2394#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2395#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2396#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2397pub struct SurfaceEdgeReference {
2398 pub object_id: Uuid,
2400 pub edges: Vec<FractionOfEdge>,
2402}
2403
2404#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2406#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2407#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2408#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2409#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2410pub struct BodiesCreated {
2411 pub bodies: Vec<BodyCreated>,
2413}
2414
2415impl BodiesCreated {
2416 pub fn is_empty(&self) -> bool {
2418 self.bodies.is_empty()
2419 }
2420}
2421
2422#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2424#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2425#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2426#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2427#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2428pub struct BodiesUpdated {
2429 pub bodies: Vec<BodyUpdated>,
2431}
2432
2433impl BodiesUpdated {
2434 pub fn is_empty(&self) -> bool {
2436 self.bodies.is_empty()
2437 }
2438}
2439
2440#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2442#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2443#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2444#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2445#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2446pub struct BodyCreated {
2447 pub id: Uuid,
2449 pub surfaces: Vec<SurfaceCreated>,
2451}
2452
2453#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2455#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2456#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2457#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2458#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2459pub struct BodyUpdated {
2460 pub id: Uuid,
2462 pub surfaces: Vec<SurfaceCreated>,
2464}
2465
2466#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2468#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2469#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2470#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2471#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2472pub struct SurfaceCreated {
2473 pub id: Uuid,
2475 pub primitive_face_index: u32,
2477 pub from_segments: Vec<Uuid>,
2479}
2480
2481#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
2483#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2484#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2485#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2486#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2487pub enum RegionVersion {
2488 #[default]
2491 V0,
2492 V1,
2495}
2496
2497#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Copy)]
2499#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2500#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2501#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
2502#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
2503#[serde(rename_all = "snake_case")]
2504pub enum EdgeCutVersion {
2505 V0,
2507 V1,
2511 V2,
2515}
2516
2517const DEFAULT_EDGE_CUT_VERSION: EdgeCutVersion = EdgeCutVersion::V1;
2518
2519impl EdgeCutVersion {
2520 pub fn is_default(&self) -> bool {
2522 self == &DEFAULT_EDGE_CUT_VERSION
2523 }
2524}
2525
2526impl Default for EdgeCutVersion {
2527 fn default() -> Self {
2528 DEFAULT_EDGE_CUT_VERSION
2529 }
2530}
2531
2532impl TryFrom<u32> for EdgeCutVersion {
2534 type Error = ();
2535
2536 fn try_from(version: u32) -> Result<Self, Self::Error> {
2537 match version {
2538 0 => Ok(Self::V0),
2539 1 => Ok(Self::V1),
2540 2 => Ok(Self::V2),
2541 _ => Err(()),
2542 }
2543 }
2544}
2545
2546impl RegionVersion {
2547 pub fn is_zero(&self) -> bool {
2549 matches!(self, Self::V0)
2550 }
2551}
2552
2553impl From<BodyCreated> for BodyUpdated {
2554 fn from(body: BodyCreated) -> Self {
2555 Self {
2556 id: body.id,
2557 surfaces: body.surfaces,
2558 }
2559 }
2560}
2561
2562impl From<BodyUpdated> for BodyCreated {
2563 fn from(body: BodyUpdated) -> Self {
2564 Self {
2565 id: body.id,
2566 surfaces: body.surfaces,
2567 }
2568 }
2569}
2570
2571impl From<BodiesCreated> for BodiesUpdated {
2572 fn from(bodies: BodiesCreated) -> Self {
2573 Self {
2574 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2575 }
2576 }
2577}
2578
2579impl From<BodiesUpdated> for BodiesCreated {
2580 fn from(bodies: BodiesUpdated) -> Self {
2581 Self {
2582 bodies: bodies.bodies.into_iter().map(Into::into).collect(),
2583 }
2584 }
2585}
2586
2587fn one() -> f32 {
2588 1.0
2589}
2590
2591#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema, Builder)]
2593pub struct CurveDebug {
2594 pub start: Option<Point2d<f64>>,
2596 pub end: Option<Point2d<f64>>,
2598 pub center: Option<Point2d<f64>>,
2600 pub mid: Option<Point2d<f64>>,
2602 pub segment_type: CurveTypeDebug,
2604 pub id: ModelingCmdId,
2606}
2607
2608#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
2610#[serde(rename_all = "snake_case")]
2611pub enum CurveTypeDebug {
2612 Line,
2614 ThreePointArc,
2616 Circle,
2618}