From 3f7037b5242eed0175ca2c9780d7d02bd6943959 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 4 Feb 2013 12:29:00 -0500 Subject: bugfix: We didn't always print a warning when CSG normalization created too many elements diff --git a/src/csgtermnormalizer.cc b/src/csgtermnormalizer.cc index 81fab80..461e965 100644 --- a/src/csgtermnormalizer.cc +++ b/src/csgtermnormalizer.cc @@ -7,6 +7,7 @@ */ shared_ptr CSGTermNormalizer::normalize(const shared_ptr &root) { + this->aborted = false; shared_ptr temp = root; while (1) { this->rootnode = temp; @@ -49,14 +50,16 @@ shared_ptr CSGTermNormalizer::normalizePass(shared_ptr term) while (term && match_and_replace(term)) { } this->nodecount++; if (nodecount > this->limit) { + PRINTB("WARNING: Normalized tree is growing past %d elements. Aborting normalization.\n", this->limit); + this->aborted = true; return shared_ptr(); } if (!term || term->type == CSGTerm::TYPE_PRIMITIVE) return term; if (term->left) term->left = normalizePass(term->left); - } while (term->type != CSGTerm::TYPE_UNION && + } while (!this->aborted && term->type != CSGTerm::TYPE_UNION && ((term->right && term->right->type != CSGTerm::TYPE_PRIMITIVE) || (term->left && term->left->type == CSGTerm::TYPE_UNION))); - term->right = normalizePass(term->right); + if (!this->aborted) term->right = normalizePass(term->right); // FIXME: Do we need to take into account any transformation of item here? return collapse_null_terms(term); diff --git a/src/csgtermnormalizer.h b/src/csgtermnormalizer.h index c331f11..f7a444f 100644 --- a/src/csgtermnormalizer.h +++ b/src/csgtermnormalizer.h @@ -17,6 +17,7 @@ private: shared_ptr collapse_null_terms(const shared_ptr &term); unsigned int count(const shared_ptr &term) const; + bool aborted; size_t limit; size_t nodecount; shared_ptr rootnode; -- cgit v0.10.1