Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions modeling-cmds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ all-features = true
[features]
clap = ["dep:clap"]
default = []
derive-jsonschema-on-enums = []
derive-jsonschema-on-enums = ["json-schema"]
json-schema = ["dep:schemars"]
tabled = ["dep:tabled"]
ts-rs = ["dep:ts-rs", "kcl-api?/ts-rs", "kittycad-point/ts-rs"]
slog = ["dep:slog"]
Expand Down Expand Up @@ -51,7 +52,7 @@ parse-display = "0.11.0"
parse-display-derive = "0.11.0"
pyo3 = { version = "0.29.2", optional = true }
pyo3-stub-gen = { version = "0.23.0", optional = true, default-features = false, features = ["either", "numpy", "ordered-float"] }
schemars = { version = "0.8.22", features = ["bigdecimal04", "chrono", "url", "uuid1"] }
schemars = { version = "0.8.22", features = ["bigdecimal04", "chrono", "url", "uuid1"], optional = true }
serde = { version = "1.0.219", features = ["derive"] }
serde_bytes = "0.11.19"
serde_json = { version = "1.0.150", optional = true }
Expand Down
1 change: 1 addition & 0 deletions modeling-cmds/src/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl Serialize for Base64Data {
}
}

#[cfg(feature = "json-schema")]
impl schemars::JsonSchema for Base64Data {
fn schema_name() -> String {
"Base64Data".to_string()
Expand Down
13 changes: 8 additions & 5 deletions modeling-cmds/src/coord.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use parse_display::{Display, FromStr};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// Co-ordinate axis specifier.
///
/// See [cglearn.eu] for background reading.
///
/// [cglearn.eu]: https://cglearn.eu/pub/computer-graphics/introduction-to-geometry#material-coordinate-systems-1
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Display, FromStr)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "snake_case")]
#[display(style = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
Expand All @@ -26,7 +26,8 @@ pub enum Axis {
}

/// Specifies the sign of a co-ordinate axis.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Display, FromStr)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "snake_case")]
#[display(style = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
Expand Down Expand Up @@ -56,7 +57,8 @@ impl std::ops::Mul for Direction {
}

/// An [`Axis`] paired with a [`Direction`].
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Display, FromStr)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[display("({axis}, {direction})")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand All @@ -81,7 +83,8 @@ pub struct AxisDirectionPair {
/// See [cglearn.eu] for background reading.
///
/// [cglearn.eu](https://cglearn.eu/pub/computer-graphics/introduction-to-geometry#material-coordinate-systems-1)
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Display, FromStr)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[display("forward: {forward}, up: {up}")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down
513 changes: 340 additions & 173 deletions modeling-cmds/src/def_enum.rs

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions modeling-cmds/src/exec_kcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use indexmap::IndexMap;
use kcl_api::ArtifactGraph;
use kcl_api::{kcl_value_view::KclValueView, DefaultPlanes};
use kcl_error::{CompilationIssue, KclError};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::shared::safe_filepath::SafeFilepath;

/// A KCL project that can be executed.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default, Builder)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
Expand All @@ -32,7 +32,8 @@ impl KclProject {
}

/// Region-creation algorithm version.
#[derive(Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default, Builder)]
#[derive(Clone, PartialEq, Serialize, Deserialize, Default, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
Expand Down Expand Up @@ -64,7 +65,8 @@ impl KclFile {
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
Expand All @@ -85,7 +87,8 @@ pub struct ExecKclProjectOk {
pub default_planes: Option<Box<DefaultPlanes>>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
Expand Down
7 changes: 4 additions & 3 deletions modeling-cmds/src/format/dxf.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/// Export sketches in DXF format.
pub mod export {
use bon::Builder;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// Export storage.
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, JsonSchema, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "DxfStorage", rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand All @@ -28,7 +28,8 @@ pub mod export {
}

/// Options for exporting DXF format.
#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, JsonSchema, PartialEq, Serialize, Builder)]
#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "DxfExportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down
12 changes: 6 additions & 6 deletions modeling-cmds/src/format/fbx.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use bon::Builder;
use parse_display::{Display, FromStr};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// Import models in FBX format.
pub mod import {
use super::*;
/// Options for importing FBX.
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "FbxImportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -37,7 +37,8 @@ pub mod export {
use super::*;

/// Options for exporting FBX.
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "FbxExportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -68,9 +69,8 @@ pub mod export {
}

/// Describes the storage format of an FBX file.
#[derive(
Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr,
)]
#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Display, FromStr)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[display(style = "snake_case")]
#[serde(rename = "FbxStorage", rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
Expand Down
17 changes: 8 additions & 9 deletions modeling-cmds/src/format/gltf.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use bon::Builder;
use parse_display::{Display, FromStr};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// Import models in KittyCAD's GLTF format.
pub mod import {
use super::*;

/// Options for importing glTF 2.0.
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "GltfImportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -37,7 +37,8 @@ pub mod import {
pub mod export {
use super::*;
/// Options for exporting glTF 2.0.
#[derive(Default, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Default, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "GltfExportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -73,9 +74,8 @@ pub mod export {
}

/// Describes the storage format of a glTF 2.0 scene.
#[derive(
Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr,
)]
#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Display, FromStr)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[display(style = "snake_case")]
#[serde(rename = "GltfStorage", rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
Expand Down Expand Up @@ -110,9 +110,8 @@ pub mod export {
}

/// Describes the presentation style of the glTF JSON.
#[derive(
Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr,
)]
#[derive(Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Display, FromStr)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[display(style = "snake_case")]
#[serde(rename = "GltfPresentation", rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
Expand Down
17 changes: 10 additions & 7 deletions modeling-cmds/src/format/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use bon::Builder;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::shared::{FileExportFormat, FileExportFormat2d, FileImportFormat};
Expand All @@ -23,7 +22,8 @@ pub mod step;
pub mod stl;

/// Output 2D format specifier.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(tag = "type", rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand All @@ -39,7 +39,8 @@ pub enum OutputFormat2d {
pub type OutputFormat = OutputFormat3d;

/// Output 3D format specifier.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(tag = "type", rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -68,7 +69,8 @@ pub enum OutputFormat3d {
pub type InputFormat = InputFormat3d;

/// Input format specifier.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(tag = "type", rename_all = "snake_case")]
#[cfg_attr(
feature = "python",
Expand Down Expand Up @@ -132,7 +134,8 @@ impl InputFormat3d {
}

/// Data item selection.
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, JsonSchema, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Deserialize, Serialize)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "snake_case", tag = "type")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -390,12 +393,12 @@ macro_rules! proprietary_brep_formats {
/// Import functionality
pub mod import {
use bon::Builder;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::coord;

#[doc = std::concat!("Options for importing ", $format_description, ".")]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(default, rename = $spec_name)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down
7 changes: 4 additions & 3 deletions modeling-cmds/src/format/obj.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use bon::Builder;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::{coord, units::UnitLength};
Expand All @@ -9,7 +8,8 @@ pub mod import {
use super::*;

/// Options for importing OBJ.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "ObjImportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -65,7 +65,8 @@ pub mod export {
use super::*;

/// Options for exporting OBJ.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "ObjExportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down
10 changes: 6 additions & 4 deletions modeling-cmds/src/format/ply.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use bon::Builder;
use parse_display::{Display, FromStr};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::{coord, format::Selection, units::UnitLength};
Expand All @@ -10,7 +9,8 @@ pub mod import {
use super::*;

/// Options for importing PLY.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "PlyImportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -67,7 +67,8 @@ pub mod export {
use super::*;

/// Options for exporting PLY.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Builder)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[serde(rename = "PlyExportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -125,7 +126,8 @@ pub mod export {
}

/// The storage for the output PLY file.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr, Default)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Display, FromStr, Default)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[display(style = "snake_case")]
#[serde(rename = "PlyStorage", rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
Expand Down
Loading
Loading