diff --git a/slicer/src/main.rs b/slicer/src/main.rs index ec5d572..ee81096 100644 --- a/slicer/src/main.rs +++ b/slicer/src/main.rs @@ -24,6 +24,16 @@ struct Args { input_file: PathBuf, /// Path to the .goo file output_file: PathBuf, + + /// Rotate the model (in degrees, about the z axis) before slicing it + #[clap(long)] + rotate_xy: Option, + /// Rotate the model (in degrees, about the y axis) before slicing it + #[clap(long)] + rotate_xz: Option, + /// Rotate the model (in degrees, about the x axis) before slicing it + #[clap(long)] + rotate_yz: Option, } fn main() -> Result<()> { @@ -51,6 +61,19 @@ fn main() -> Result<()> { let file = File::open(args.input_file)?; let mut buf = BufReader::new(file); let mut mesh = load_mesh(&mut buf, "stl")?; + + let mut rotate = mesh.rotation(); + if let Some(r) = args.rotate_xy { + rotate.z += r.to_radians(); + } + if let Some(r) = args.rotate_xz { + rotate.y += r.to_radians(); + } + if let Some(r) = args.rotate_yz { + rotate.x += r.to_radians(); + } + mesh.set_rotation(rotate); + let (min, max) = mesh.bounds(); // Scale the model into printer-space (mm => px)