1use enum_iterator::Sequence;
2use parse_display_derive::{Display, FromStr};
3use schemars::{schema::SchemaObject, JsonSchema};
4use serde::{Deserialize, Serialize};
5use uuid::Uuid;
6
7#[cfg(feature = "cxx")]
8use crate::impl_extern_type;
9use crate::{length_unit::LengthUnit, output::ExtrusionFaceInfo, units::UnitAngle};
10
11pub use point::{Point2d, Point3d, Point4d, Quaternion};
12
13mod point;
14
15#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
17#[serde(rename_all = "snake_case")]
18#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
19#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
20pub enum CutType {
21 #[default]
23 Fillet,
24 Chamfer,
26}
27
28#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
30#[serde(rename_all = "snake_case")]
31#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
32#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
33pub struct Rotation {
34 pub axis: Point3d<f64>,
37 pub angle: Angle,
40 pub origin: OriginType,
42}
43
44impl Default for Rotation {
45 fn default() -> Self {
47 Self {
48 axis: z_axis(),
49 angle: Angle::default(),
50 origin: OriginType::Local,
51 }
52 }
53}
54
55#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
57#[serde(rename_all = "snake_case")]
58#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
59#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
60pub struct Transform {
61 #[serde(default)]
64 pub translate: Point3d<LengthUnit>,
65 #[serde(default = "same_scale")]
68 pub scale: Point3d<f64>,
69 #[serde(default)]
72 pub rotation: Rotation,
73 #[serde(default = "bool_true")]
75 pub replicate: bool,
76}
77
78impl Default for Transform {
79 fn default() -> Self {
80 Self {
81 scale: same_scale(),
82 replicate: true,
83 translate: Default::default(),
84 rotation: Rotation::default(),
85 }
86 }
87}
88
89#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
91#[serde(rename_all = "snake_case")]
92#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
93#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
94pub struct AnnotationOptions {
95 pub text: Option<AnnotationTextOptions>,
97 pub line_ends: Option<AnnotationLineEndOptions>,
99 pub line_width: Option<f32>,
101 pub color: Option<Color>,
103 pub position: Option<Point3d<f32>>,
105}
106
107#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
109#[serde(rename_all = "snake_case")]
110#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
111#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
112pub struct AnnotationLineEndOptions {
113 pub start: AnnotationLineEnd,
115 pub end: AnnotationLineEnd,
117}
118
119#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
121#[serde(rename_all = "snake_case")]
122#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
123#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
124pub struct AnnotationTextOptions {
125 pub x: AnnotationTextAlignmentX,
127 pub y: AnnotationTextAlignmentY,
129 pub text: String,
131 pub point_size: u32,
133}
134
135#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
139#[serde(rename_all = "snake_case", tag = "type")]
140#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
141#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
142pub enum DistanceType {
143 Euclidean {},
145 OnAxis {
147 axis: GlobalAxis,
149 },
150}
151
152#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
154#[serde(rename_all = "snake_case", tag = "type")]
155#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
156#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
157pub enum OriginType {
158 #[default]
160 Local,
161 Global,
163 Custom {
165 origin: Point3d<f64>,
167 },
168}
169
170#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
172#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
173#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
174pub struct Color {
175 pub r: f32,
177 pub g: f32,
179 pub b: f32,
181 pub a: f32,
183}
184
185#[allow(missing_docs)]
187#[derive(
188 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
189)]
190#[serde(rename_all = "lowercase")]
191#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
192#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
193pub enum AnnotationTextAlignmentX {
194 Left,
195 Center,
196 Right,
197}
198
199#[allow(missing_docs)]
201#[derive(
202 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
203)]
204#[serde(rename_all = "lowercase")]
205#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
206#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
207pub enum AnnotationTextAlignmentY {
208 Bottom,
209 Center,
210 Top,
211}
212
213#[allow(missing_docs)]
215#[derive(
216 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
217)]
218#[serde(rename_all = "lowercase")]
219#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
220#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
221pub enum AnnotationLineEnd {
222 None,
223 Arrow,
224}
225
226#[derive(
228 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
229)]
230#[serde(rename_all = "lowercase")]
231#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
232#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
233pub enum AnnotationType {
234 T2D,
236 T3D,
238}
239
240#[derive(
242 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
243)]
244#[serde(rename_all = "lowercase")]
245#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
246#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
247pub enum CameraDragInteractionType {
248 Pan,
250 Rotate,
252 RotateTrackball,
254 Zoom,
256}
257
258#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
261#[serde(rename_all = "snake_case", tag = "type")]
262#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
263#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
264pub enum PathSegment {
265 Line {
268 end: Point3d<LengthUnit>,
270 relative: bool,
272 },
273 Arc {
276 center: Point2d<LengthUnit>,
278 radius: LengthUnit,
280 start: Angle,
282 end: Angle,
284 relative: bool,
286 },
287 Bezier {
291 control1: Point3d<LengthUnit>,
293 control2: Point3d<LengthUnit>,
295 end: Point3d<LengthUnit>,
297 relative: bool,
299 },
300 TangentialArc {
302 radius: LengthUnit,
305 offset: Angle,
307 },
308 TangentialArcTo {
311 to: Point3d<LengthUnit>,
315 angle_snap_increment: Option<Angle>,
317 },
318 ArcTo {
320 interior: Point3d<LengthUnit>,
322 end: Point3d<LengthUnit>,
324 relative: bool,
326 },
327}
328
329#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
331#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
332#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
333pub struct Angle {
334 pub unit: UnitAngle,
336 pub value: f64,
338}
339
340impl Angle {
341 pub fn to_degrees(self) -> f64 {
343 match self.unit {
344 UnitAngle::Degrees => self.value,
345 UnitAngle::Radians => self.value.to_degrees(),
346 }
347 }
348 pub fn to_radians(self) -> f64 {
350 match self.unit {
351 UnitAngle::Degrees => self.value.to_radians(),
352 UnitAngle::Radians => self.value,
353 }
354 }
355 pub const fn from_degrees(value: f64) -> Self {
357 Self {
358 unit: UnitAngle::Degrees,
359 value,
360 }
361 }
362 pub const fn from_radians(value: f64) -> Self {
364 Self {
365 unit: UnitAngle::Radians,
366 value,
367 }
368 }
369 pub const fn turn() -> Self {
371 Self::from_degrees(360.0)
372 }
373 pub const fn half_circle() -> Self {
375 Self::from_degrees(180.0)
376 }
377 pub const fn quarter_circle() -> Self {
379 Self::from_degrees(90.0)
380 }
381 pub const fn zero() -> Self {
383 Self::from_degrees(0.0)
384 }
385}
386
387impl Default for Angle {
389 fn default() -> Self {
391 Self::zero()
392 }
393}
394
395impl PartialOrd for Angle {
396 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
397 match (self.unit, other.unit) {
398 (UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
400 (UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
401 _ => self.to_degrees().partial_cmp(&other.to_degrees()),
402 }
403 }
404}
405
406impl std::ops::Add for Angle {
407 type Output = Self;
408
409 fn add(self, rhs: Self) -> Self::Output {
410 Self {
411 unit: UnitAngle::Degrees,
412 value: self.to_degrees() + rhs.to_degrees(),
413 }
414 }
415}
416
417impl std::ops::AddAssign for Angle {
418 fn add_assign(&mut self, rhs: Self) {
419 match self.unit {
420 UnitAngle::Degrees => {
421 self.value += rhs.to_degrees();
422 }
423 UnitAngle::Radians => {
424 self.value += rhs.to_radians();
425 }
426 }
427 }
428}
429
430#[derive(
432 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
433)]
434#[serde(rename_all = "lowercase")]
435#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
436#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
437pub enum SceneSelectionType {
438 Replace,
440 Add,
442 Remove,
444}
445
446#[allow(missing_docs)]
448#[derive(
449 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
450)]
451#[serde(rename_all = "snake_case")]
452#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
453#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
454pub enum SceneToolType {
455 CameraRevolve,
456 Select,
457 Move,
458 SketchLine,
459 SketchTangentialArc,
460 SketchCurve,
461 SketchCurveMod,
462}
463
464#[allow(missing_docs)]
466#[derive(
467 Display,
468 FromStr,
469 Copy,
470 Eq,
471 PartialEq,
472 Debug,
473 JsonSchema,
474 Deserialize,
475 Serialize,
476 Sequence,
477 Clone,
478 Ord,
479 PartialOrd,
480 Default,
481)]
482#[serde(rename_all = "snake_case")]
483#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
484#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
485pub enum PathComponentConstraintBound {
486 #[default]
487 Unconstrained,
488 PartiallyConstrained,
489 FullyConstrained,
490}
491
492#[allow(missing_docs)]
494#[derive(
495 Display,
496 FromStr,
497 Copy,
498 Eq,
499 PartialEq,
500 Debug,
501 JsonSchema,
502 Deserialize,
503 Serialize,
504 Sequence,
505 Clone,
506 Ord,
507 PartialOrd,
508 Default,
509)]
510#[serde(rename_all = "snake_case")]
511#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
512#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
513pub enum PathComponentConstraintType {
514 #[default]
515 Unconstrained,
516 Vertical,
517 Horizontal,
518 EqualLength,
519 Parallel,
520 AngleBetween,
521}
522
523#[allow(missing_docs)]
525#[derive(
526 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
527)]
528#[serde(rename_all = "snake_case")]
529#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
530#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
531pub enum PathCommand {
532 MoveTo,
533 LineTo,
534 BezCurveTo,
535 NurbsCurveTo,
536 AddArc,
537}
538
539#[allow(missing_docs)]
541#[derive(
542 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
543)]
544#[serde(rename_all = "lowercase")]
545#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
546#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
547#[repr(u8)]
548pub enum EntityType {
549 Entity,
550 Object,
551 Path,
552 Curve,
553 Solid2D,
554 Solid3D,
555 Edge,
556 Face,
557 Plane,
558 Vertex,
559}
560
561#[allow(missing_docs)]
563#[derive(
564 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
565)]
566#[serde(rename_all = "snake_case")]
567#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
568#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
569pub enum CurveType {
570 Line,
571 Arc,
572 Nurbs,
573}
574
575#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
577pub struct ExportFile {
578 pub name: String,
580 pub contents: crate::base64::Base64Data,
582}
583
584#[derive(
586 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
587)]
588#[serde(rename_all = "lowercase")]
589#[display(style = "lowercase")]
590#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
591#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
592pub enum FileExportFormat {
593 Fbx,
595 Glb,
602 Gltf,
613 Obj,
617 Ply,
619 Step,
621 Stl,
623}
624
625#[derive(
627 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
628)]
629#[serde(rename_all = "lowercase")]
630#[display(style = "lowercase")]
631#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
632#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
633pub enum FileExportFormat2d {
634 Dxf,
636}
637
638#[derive(
640 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
641)]
642#[serde(rename_all = "lowercase")]
643#[display(style = "lowercase")]
644#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
645#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
646pub enum FileImportFormat {
647 Fbx,
649 Gltf,
651 Obj,
655 Ply,
657 Sldprt,
659 Step,
661 Stl,
663}
664
665#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
667#[serde(rename_all = "snake_case")]
668#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
669#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
670pub enum EngineErrorCode {
671 BadRequest = 1,
675 InternalEngine,
677}
678
679impl From<EngineErrorCode> for http::StatusCode {
680 fn from(e: EngineErrorCode) -> Self {
681 match e {
682 EngineErrorCode::BadRequest => Self::BAD_REQUEST,
683 EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
684 }
685 }
686}
687
688#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone)]
690#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
691#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
692pub struct ExtrudedFaceInfo {
693 pub bottom: Option<Uuid>,
698 pub top: Uuid,
700 pub sides: Vec<SideFace>,
702}
703
704#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone)]
706#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
707#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
708pub struct SideFace {
709 pub path_id: Uuid,
711 pub face_id: Uuid,
713}
714
715#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
717#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
718#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
719pub struct CameraSettings {
720 pub pos: Point3d,
722
723 pub center: Point3d,
725
726 pub up: Point3d,
728
729 pub orientation: Quaternion,
731
732 pub fov_y: Option<f32>,
734
735 pub ortho_scale: Option<f32>,
737
738 pub ortho: bool,
740}
741
742impl From<CameraSettings> for crate::output::DefaultCameraZoom {
743 fn from(settings: CameraSettings) -> Self {
744 Self { settings }
745 }
746}
747impl From<CameraSettings> for crate::output::CameraDragMove {
748 fn from(settings: CameraSettings) -> Self {
749 Self { settings }
750 }
751}
752impl From<CameraSettings> for crate::output::CameraDragEnd {
753 fn from(settings: CameraSettings) -> Self {
754 Self { settings }
755 }
756}
757impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
758 fn from(settings: CameraSettings) -> Self {
759 Self { settings }
760 }
761}
762impl From<CameraSettings> for crate::output::ZoomToFit {
763 fn from(settings: CameraSettings) -> Self {
764 Self { settings }
765 }
766}
767impl From<CameraSettings> for crate::output::OrientToFace {
768 fn from(settings: CameraSettings) -> Self {
769 Self { settings }
770 }
771}
772impl From<CameraSettings> for crate::output::ViewIsometric {
773 fn from(settings: CameraSettings) -> Self {
774 Self { settings }
775 }
776}
777
778#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default)]
780#[serde(rename_all = "snake_case")]
781#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
782#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
783pub struct PerspectiveCameraParameters {
784 pub fov_y: Option<f32>,
786 pub z_near: Option<f32>,
788 pub z_far: Option<f32>,
790}
791
792#[derive(
794 Default,
795 Display,
796 FromStr,
797 Copy,
798 Eq,
799 PartialEq,
800 Debug,
801 JsonSchema,
802 Deserialize,
803 Serialize,
804 Sequence,
805 Clone,
806 Ord,
807 PartialOrd,
808)]
809#[serde(rename_all = "snake_case")]
810#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
811#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
812pub enum CameraMovement {
813 #[default]
815 Vantage,
816 None,
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 = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
827pub enum GlobalAxis {
828 X,
830 Y,
832 Z,
834}
835
836#[derive(
838 Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
839)]
840#[serde(rename_all = "snake_case")]
841#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
842#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
843#[repr(u8)]
844pub enum ExtrusionFaceCapType {
845 None,
847 Top,
849 Bottom,
851 Both,
853}
854
855#[allow(missing_docs)]
857#[derive(
858 Display,
859 FromStr,
860 Copy,
861 Eq,
862 PartialEq,
863 Debug,
864 JsonSchema,
865 Deserialize,
866 Serialize,
867 Sequence,
868 Clone,
869 Ord,
870 PartialOrd,
871 Default,
872)]
873#[serde(rename_all = "lowercase")]
874#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
875#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
876pub enum PostEffectType {
877 Phosphor,
878 Ssao,
879 #[default]
880 NoEffect,
881}
882
883#[cfg(feature = "cxx")]
886impl_extern_type! {
887 [Trivial]
888 FileImportFormat = "Enums::_FileImportFormat"
890 FileExportFormat = "Enums::_FileExportFormat"
891 CameraDragInteractionType = "Enums::_CameraDragInteractionType"
893 SceneSelectionType = "Enums::_SceneSelectionType"
895 SceneToolType = "Enums::_SceneToolType"
896 EntityType = "Enums::_EntityType"
897 AnnotationType = "Enums::_AnnotationType"
898 AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
899 AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
900 AnnotationLineEnd = "Enums::_AnnotationLineEnd"
901
902 CurveType = "Enums::_CurveType"
903 PathCommand = "Enums::_PathCommand"
904 PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
905 PathComponentConstraintType = "Enums::_PathComponentConstraintType"
906 ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
907
908 EngineErrorCode = "Enums::_ErrorCode"
910 GlobalAxis = "Enums::_GlobalAxis"
911 OriginType = "Enums::_OriginType"
912
913 PostEffectType = "Enums::_PostEffectType"
915}
916
917fn bool_true() -> bool {
918 true
919}
920fn same_scale() -> Point3d<f64> {
921 Point3d::uniform(1.0)
922}
923
924fn z_axis() -> Point3d<f64> {
925 Point3d { x: 0.0, y: 0.0, z: 1.0 }
926}
927
928impl ExtrudedFaceInfo {
929 pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
932 let mut face_infos: Vec<_> = self
933 .sides
934 .into_iter()
935 .map(|side| ExtrusionFaceInfo {
936 curve_id: Some(side.path_id),
937 face_id: Some(side.face_id),
938 cap: ExtrusionFaceCapType::None,
939 })
940 .collect();
941 face_infos.push(ExtrusionFaceInfo {
942 curve_id: None,
943 face_id: Some(self.top),
944 cap: ExtrusionFaceCapType::Top,
945 });
946 if let Some(bottom) = self.bottom {
947 face_infos.push(ExtrusionFaceInfo {
948 curve_id: None,
949 face_id: Some(bottom),
950 cap: ExtrusionFaceCapType::Bottom,
951 });
952 }
953 face_infos
954 }
955}
956
957#[cfg(test)]
958mod tests {
959 use super::*;
960
961 #[test]
962 fn test_angle_comparison() {
963 let a = Angle::from_degrees(90.0);
964 assert!(a < Angle::from_degrees(91.0));
965 assert!(a > Angle::from_degrees(89.0));
966 assert!(a <= Angle::from_degrees(90.0));
967 assert!(a >= Angle::from_degrees(90.0));
968 let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
969 assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
970 assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
971 assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
972 assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
973 assert!(a > b);
975 assert!(a >= b);
976 assert!(b < a);
977 assert!(b <= a);
978 let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
979 assert!(a < c);
980 assert!(a <= c);
981 assert!(c > a);
982 assert!(c >= a);
983 }
984}
985
986#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
988#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
989#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
990pub struct TransformBy<T> {
991 pub property: T,
993 pub set: bool,
998 pub is_local: bool,
1001}
1002
1003impl<T: JsonSchema> JsonSchema for TransformBy<T> {
1004 fn schema_name() -> String {
1005 format!("TransformByFor{}", T::schema_name())
1006 }
1007
1008 fn schema_id() -> std::borrow::Cow<'static, str> {
1009 std::borrow::Cow::Owned(format!("{}::TransformBy<{}>", module_path!(), T::schema_id()))
1010 }
1011
1012 fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1013 SchemaObject {
1014 instance_type: Some(schemars::schema::InstanceType::String.into()),
1015 ..Default::default()
1016 }
1017 .into()
1018 }
1019}
1020
1021#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize)]
1023#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1024#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1025pub struct ComponentTransform {
1026 pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
1028 pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
1031 pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
1035 pub scale: Option<TransformBy<Point3d<f64>>>,
1037}