slicer: implement --rotate-{xy,xz,yz} CLI arguments
Some checks failed
Build / build (ubuntu-latest) (push) Has been cancelled
Build / build (windows-latest) (push) Has been cancelled
Build / build (macos-latest) (push) Has been cancelled

This commit is contained in:
2025-04-01 06:08:26 +00:00
parent b6b6620105
commit 70e7e2a35a

View File

@@ -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)