summaryrefslogtreecommitdiff
path: root/src/csgtermnormalizer.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-03-06 04:27:12 (GMT)
committerMarius Kintel <marius@kintel.net>2013-03-06 04:27:12 (GMT)
commitf70578f362c8c2c78036c9de846c20802ac7aa81 (patch)
treef327de271f14382c0915677a87e53867785551f7 /src/csgtermnormalizer.cc
parent32469374cfe2985f936f017a204d4e9d7dcd3e2f (diff)
parent03be37d16b585e64de87118053206aaae06e7cf8 (diff)
Merge branch 'master' into epec-kernel
Diffstat (limited to 'src/csgtermnormalizer.cc')
-rw-r--r--src/csgtermnormalizer.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/csgtermnormalizer.cc b/src/csgtermnormalizer.cc
index e2474e9..461e965 100644
--- a/src/csgtermnormalizer.cc
+++ b/src/csgtermnormalizer.cc
@@ -7,6 +7,7 @@
*/
shared_ptr<CSGTerm> CSGTermNormalizer::normalize(const shared_ptr<CSGTerm> &root)
{
+ this->aborted = false;
shared_ptr<CSGTerm> temp = root;
while (1) {
this->rootnode = temp;
@@ -20,7 +21,7 @@ shared_ptr<CSGTerm> CSGTermNormalizer::normalize(const shared_ptr<CSGTerm> &root
PRINTB("WARNING: Normalized tree is growing past %d elements. Aborting normalization.\n", this->limit);
// Clean up any partially evaluated terms
shared_ptr<CSGTerm> newroot = root, tmproot;
- while (newroot != tmproot) {
+ while (newroot && newroot != tmproot) {
tmproot = newroot;
newroot = collapse_null_terms(tmproot);
}
@@ -49,14 +50,16 @@ shared_ptr<CSGTerm> CSGTermNormalizer::normalizePass(shared_ptr<CSGTerm> 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<CSGTerm>();
}
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);
contact: Jan Huwald // Impressum