From c7471af7bfacbb742973ab5fa143678bcec3d888 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 11 Sep 2019 10:01:34 -0500 Subject: [PATCH] Clenaing and comments. No longer need to address the special case of a complement at the back of the RPN. --- src/cell.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/cell.cpp b/src/cell.cpp index f33926b30..69d398fda 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -612,7 +612,7 @@ void CSGCell::apply_demorgan(std::vector::iterator start, std::vector::iterator CSGCell::find_left_parenthesis(std::vector::iterator start, const std::vector& rpn) { - + // start search at zero int level = 0; auto it = start; while (it != rpn.begin()) { @@ -643,12 +643,7 @@ CSGCell::find_left_parenthesis(std::vector::iterator start, } void CSGCell::remove_complements(std::vector& rpn) { - if (rpn.back() == OP_COMPLEMENT) { - apply_demorgan(rpn.begin(), rpn.end()); - rpn.pop_back(); - } - - std::vector::iterator it = std::find(rpn.begin(), rpn.end(), OP_COMPLEMENT); + auto it = std::find(rpn.begin(), rpn.end(), OP_COMPLEMENT); while (it != rpn.end()) { // find the opening parenthesis (if any) auto left = find_left_parenthesis(it, rpn); @@ -663,13 +658,15 @@ void CSGCell::remove_complements(std::vector& rpn) { } BoundingBox CSGCell::bounding_box_complex(std::vector rpn) { - + // remove complements by adjusting surface signs and operators remove_complements(rpn); + // use the first token to set the bounding box auto it = rpn.begin(); BoundingBox current = model::surfaces[abs(*it) - 1]->bounding_box(*it > 0); it++; + // loop over tokens while (it < rpn.end()) { // move through the rpn in twos int32_t one = *it; it++; @@ -713,7 +710,6 @@ BoundingBox CSGCell::bounding_box_complex(std::vector rpn) { } } } - return current; }