From 147b22b861406ac5be425bb89ad12cebe2a6ff7e Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 6 Mar 2016 23:25:37 -0800 Subject: [PATCH] Added ability to print the debug data of a data tree file. This is purely for debug purposes, to make sure everything is working correctly. Should be removed in the future. --- src/main.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) 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);