slicer: implement --rotate-{xy,xz,yz} CLI arguments
This commit is contained in:
@@ -24,6 +24,16 @@ struct Args {
|
|||||||
input_file: PathBuf,
|
input_file: PathBuf,
|
||||||
/// Path to the .goo file
|
/// Path to the .goo file
|
||||||
output_file: PathBuf,
|
output_file: PathBuf,
|
||||||
|
|
||||||
|
/// Rotate the model (in degrees, about the z axis) before slicing it
|
||||||
|
#[clap(long)]
|
||||||
|
rotate_xy: Option<f32>,
|
||||||
|
/// Rotate the model (in degrees, about the y axis) before slicing it
|
||||||
|
#[clap(long)]
|
||||||
|
rotate_xz: Option<f32>,
|
||||||
|
/// Rotate the model (in degrees, about the x axis) before slicing it
|
||||||
|
#[clap(long)]
|
||||||
|
rotate_yz: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
@@ -51,6 +61,19 @@ fn main() -> Result<()> {
|
|||||||
let file = File::open(args.input_file)?;
|
let file = File::open(args.input_file)?;
|
||||||
let mut buf = BufReader::new(file);
|
let mut buf = BufReader::new(file);
|
||||||
let mut mesh = load_mesh(&mut buf, "stl")?;
|
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();
|
let (min, max) = mesh.bounds();
|
||||||
|
|
||||||
// Scale the model into printer-space (mm => px)
|
// Scale the model into printer-space (mm => px)
|
||||||
|
Reference in New Issue
Block a user