kittycad_modeling_cmds/format/
ply.rs1use parse_display::{Display, FromStr};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5use crate::{coord, format::Selection, units::UnitLength};
6
7pub mod import {
9 use super::*;
10
11 #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
13 #[display("coords: {coords}, units: {units}")]
14 #[serde(rename = "PlyImportOptions")]
15 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
16 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
17 #[cfg_attr(
18 feature = "python",
19 pyo3_stub_gen::derive::gen_stub_pyclass,
20 pyo3::pyclass(name = "PlyImportOptions")
21 )]
22 pub struct Options {
23 pub coords: coord::System,
29
30 pub units: UnitLength,
37 }
38
39 #[cfg(feature = "python")]
40 #[pyo3_stub_gen::derive::gen_stub_pymethods]
41 #[pyo3::pymethods]
42 impl Options {
43 #[new]
44 pub fn new() -> Self {
46 Default::default()
47 }
48 }
49
50 impl Default for Options {
51 fn default() -> Self {
52 Self {
53 coords: *coord::KITTYCAD,
54 units: UnitLength::Millimeters,
55 }
56 }
57 }
58}
59
60pub mod export {
62
63 use super::*;
64
65 #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
67 #[display("coords: {coords}, selection: {selection}, storage: {storage}, units: {units}")]
68 #[serde(rename = "PlyExportOptions")]
69 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
70 #[cfg_attr(
71 feature = "python",
72 pyo3_stub_gen::derive::gen_stub_pyclass,
73 pyo3::pyclass(name = "PlyExportOptions")
74 )]
75 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
76 pub struct Options {
77 pub coords: coord::System,
83
84 pub selection: Selection,
86
87 pub storage: Storage,
89
90 pub units: UnitLength,
94 }
95
96 #[cfg(feature = "python")]
97 #[pyo3_stub_gen::derive::gen_stub_pymethods]
98 #[pyo3::pymethods]
99 impl Options {
100 #[new]
101 pub fn new() -> Self {
103 Default::default()
104 }
105 }
106
107 impl Default for Options {
108 fn default() -> Self {
109 Self {
110 coords: *coord::KITTYCAD,
111 selection: Default::default(),
112 storage: Default::default(),
113 units: UnitLength::Millimeters,
114 }
115 }
116 }
117
118 #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr, Default)]
120 #[display(style = "snake_case")]
121 #[serde(rename = "PlyStorage", 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"))]
124 #[cfg_attr(
125 feature = "python",
126 pyo3_stub_gen::derive::gen_stub_pyclass_enum,
127 pyo3::pyclass(name = "PlyStorage")
128 )]
129 pub enum Storage {
130 #[default]
132 Ascii,
133 BinaryLittleEndian,
135 BinaryBigEndian,
137 }
138}