From 111933c30e8ed44cc466eee572a02058b4331ee3 Mon Sep 17 00:00:00 2001 From: Chris Hodapp Date: Fri, 6 Mar 2020 15:38:25 -0500 Subject: [PATCH] Some more notes and tried other examples with to_mesh_iter --- src/examples.rs | 8 ++++++++ src/rule.rs | 28 ++++++++-------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/examples.rs b/src/examples.rs index be3d22a..156a994 100644 --- a/src/examples.rs +++ b/src/examples.rs @@ -421,6 +421,7 @@ pub fn main() { mesh.write_stl_file(&fname).unwrap(); } + /* run_test(CubeThing::init(), Rule { eval: CubeThing::rec }, 3, "cube_thing"); // this can't work on its own because the resultant OpenMesh still // has parent references: @@ -428,6 +429,13 @@ pub fn main() { run_test(CurveHorn::init(), Rule { eval: CurveHorn::start }, 100, "curve_horn2"); run_test(RamHorn::init(), Rule { eval: RamHorn::start }, 200, "ram_horn"); run_test(Twist::init(), Rule { eval: Twist::start }, 200, "twist"); + */ + run_test_iter(CubeThing::init(), Rule { eval: CubeThing::rec }, 3, "cube_thing2"); run_test_iter(CurveHorn::init(), Rule { eval: CurveHorn::start }, 100, "curve_horn2_iter"); + run_test_iter(RamHorn::init(), Rule { eval: RamHorn::start }, 100, "ram_horn2"); + // TODO: If I increase the above from 100 to ~150, Blender reports + // that the very tips are non-manifold. I am wondering if this is + // some sort of numerical precision issue. + run_test_iter(Twist::init(), Rule { eval: Twist::start }, 200, "twist2"); } diff --git a/src/rule.rs b/src/rule.rs index 7595d4a..e980189 100644 --- a/src/rule.rs +++ b/src/rule.rs @@ -151,12 +151,9 @@ impl Rule { // s = the 'current' state: let s = &mut stack[n-1]; let depth = s.depth; - // TODO: remove - //println!("DEBUG: stack has len {}; depth={}", n, depth); - - let child = &s.rules[s.next]; // Evaluate the rule: + let child = &s.rules[s.next]; let mut eval = (child.rule.eval)(arg); eval_count += 1; @@ -169,10 +166,6 @@ impl Rule { // See if we can still recurse further: if depth <= 0 { - // TODO: remove - //println!("DEBUG: backtracing, depth={}, s.next = {}, s.rules.len() = {}", - // depth, s.next, s.rules.len()); - // As we're stopping recursion, we need to connect // final_geom with all else in order to actually close // geometry properly: @@ -205,21 +198,18 @@ impl Rule { continue; } - // TODO: remove - //println!("DEBUG: Connecting {} faces, vmap={:?}, faces={:?}", - // new_geom.verts.len(), child.vmap, new_geom.faces); let (g, offsets) = geom.connect(&vec![(new_geom, &child.vmap)]); geom = g; // 'new_geom' may itself be parent geometry for - // something in 'eval.children' (via Tag::Parent), - // and vmap is there to resolve those Tag::Parent - // references to the right vertices in 'new_geom'. + // 'eval.children' (via Tag::Parent), and vmap is there to + // resolve Tag::Parent references to the right vertices in + // 'new_geom'. // - // However, we connect() on the global geometry - // which we merged 'new_geom' into, not 'new_geom' - // directly. To account for this, we must shift - // vmap by the offset that 'geom.connect' gave us: + // However, we connect() on the global geometry which we + // merged 'new_geom' into, not 'new_geom' directly. To + // account for this, we must shift vmap by the offset that + // 'geom.connect' gave us: for (offset, child) in offsets.iter().zip(eval.children.iter_mut()) { child.vmap = child.vmap.iter().map(|n| { n + offset @@ -248,8 +238,6 @@ impl Rule { } } - // TODO: Handle final_geom - return (geom, eval_count); }