diff --git a/slicer/README.md b/slicer/README.md index 5603267..6452beb 100644 --- a/slicer/README.md +++ b/slicer/README.md @@ -9,10 +9,9 @@ It also exposes a CLI for slicing models, open the dropdown below to see it's he ```plain mslicer command line interface -Usage: slicer [OPTIONS] |--rotation |--scale > +Usage: slicer [OPTIONS] <--mesh |--position |--rotation |--scale > Arguments: - Path to a .stl or .obj file File to save sliced result to. Currently only .goo files can be generated Options: @@ -42,12 +41,14 @@ Options: The speed to lift the platform after exposing each first layer, in mm/min [default: 65] --first-retract-speed The speed to retract (move down) the platform after exposing each first layer, in mm/min [default: 150] + --mesh + Path to a .stl or .obj file --position - Location of the bottom center of model bounding box. The origin is the center of the build plate [default: "0, 0, 0"] + Location of the bottom center of model bounding box. The origin is the center of the build plate --rotation - Rotation of the model in degrees, pitch, roll, yaw [default: "0, 0, 0"] + Rotation of the model in degrees, pitch, roll, yaw --scale - Scale of the model along the X, Y, and Z axes [default: "1, 1, 1"] + Scale of the model along the X, Y, and Z axes -h, --help Print help ``` diff --git a/slicer/bin/args.rs b/slicer/bin/args.rs index 56e8c0b..5226bcb 100644 --- a/slicer/bin/args.rs +++ b/slicer/bin/args.rs @@ -89,7 +89,7 @@ pub struct ModelArgs { pub scale: Vec>, } -#[derive(Default, Debug)] +#[derive(Debug)] pub struct CliMesh { pub path: PathBuf, pub position: Vector3, @@ -128,7 +128,7 @@ impl CliMesh { pub fn from_matches(matches: &ArgMatches) -> Vec { let mut meshes = matches .get_many::("mesh") - .unwrap() + .expect("No meshes defined") .zip(matches.indices_of("mesh").unwrap()) .map(|x| { ( @@ -152,7 +152,10 @@ impl CliMesh { }; for (instance, idx) in instances.zip(matches.indices_of(key).unwrap()) { - let mesh = meshes.iter_mut().rfind(|x| idx > x.0).unwrap(); + let mesh = meshes + .iter_mut() + .rfind(|x| idx > x.0) + .expect("Mesh parameter before mesh"); *value(&mut mesh.1) = instance.to_owned(); } } @@ -165,6 +168,17 @@ impl CliMesh { } } +impl Default for CliMesh { + fn default() -> Self { + Self { + path: PathBuf::default(), + position: Vector3::zeros(), + rotation: Vector3::zeros(), + scale: Vector3::repeat(1.0), + } + } +} + pub fn vector_value_parser( raw: &str, ) -> Result, U1, ArrayStorage>>