diff --git a/src/main.rs b/src/main.rs index 4ba409c..075f708 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,9 @@ mod bvh; mod halton; use std::mem; +use std::io; +use std::io::Read; +use std::fs::File; use docopt::Docopt; @@ -25,6 +28,7 @@ use ray::Ray; use camera::Camera; use renderer::Renderer; use surface::triangle_mesh::TriangleMesh; +use parse::DataTree; // ---------------------------------------------------------------- @@ -35,20 +39,21 @@ Psychopath Usage: psychopath [options] + psychopath [options] -i psychopath (-h | --help) psychopath --version Options: - -i Input .psy file - -s , --spp Number of samples per pixel [default: 16]. - -h, --help Show this screen. - --version Show version. + -i , --input Input .psy file + -s , --spp Number of samples per pixel [default: 16]. + -h, --help Show this screen. + --version Show version. "#; #[derive(Debug, RustcDecodable)] struct Args { arg_imgpath: String, - flag_input_file: Option, + flag_input: Option, flag_spp: Option, flag_version: bool, } @@ -68,6 +73,19 @@ fn main() { return; } + // ======================= + // Print tree from psy file if passed as an argument. + // TODO: remove this, because it's for debugging + if let Some(fp) = args.flag_input { + let mut f = io::BufReader::new(File::open(fp).unwrap()); + let mut s = String::new(); + let _ = f.read_to_string(&mut s); + let dt = DataTree::from_str(&s); + println!("{:#?}", dt); + return; + } + // ======================= + let samples_per_pixel = args.flag_spp.unwrap_or_else(|| 16); println!("Sample count: {}", samples_per_pixel);