kittycad_modeling_cmds/format/obj.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
use parse_display::{Display, FromStr};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{coord, units::UnitLength};
/// Import models in OBJ format.
pub mod import {
use super::*;
/// Options for importing OBJ.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
#[display("coords: {coords}, units: {units}")]
#[serde(rename = "ObjImportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct Options {
/// Co-ordinate system of input data.
///
/// Defaults to the [KittyCAD co-ordinate system].
///
/// [KittyCAD co-ordinate system]: ../coord/constant.KITTYCAD.html
pub coords: coord::System,
/// The units of the input data.
///
/// This is very important for correct scaling and when calculating physics properties like
/// mass, etc.
///
/// Defaults to millimeters.
pub units: UnitLength,
}
impl Default for Options {
fn default() -> Self {
Self {
coords: *coord::KITTYCAD,
units: UnitLength::Millimeters,
}
}
}
}
/// Export models in OBJ format.
pub mod export {
use super::*;
/// Options for exporting OBJ.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
#[display("coords: {coords}, units: {units}")]
#[serde(rename = "ObjExportOptions")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct Options {
/// Co-ordinate system of output data.
///
/// Defaults to the [KittyCAD co-ordinate system].
///
/// [KittyCAD co-ordinate system]: ../coord/constant.KITTYCAD.html
pub coords: coord::System,
/// Export length unit.
///
/// Defaults to millimeters.
pub units: UnitLength,
}
impl Default for Options {
fn default() -> Self {
Self {
coords: *coord::KITTYCAD,
units: UnitLength::Millimeters,
}
}
}
}