diff options
-rw-r--r-- | src/csgtermnormalizer.cc | 7 | ||||
-rw-r--r-- | src/csgtermnormalizer.h | 2 | ||||
-rw-r--r-- | src/mainwin.cc | 7 |
3 files changed, 9 insertions, 7 deletions
diff --git a/src/csgtermnormalizer.cc b/src/csgtermnormalizer.cc index a830422..c4caa8f 100644 --- a/src/csgtermnormalizer.cc +++ b/src/csgtermnormalizer.cc @@ -2,7 +2,8 @@ #include "csgterm.h" #include "printutils.h" -shared_ptr<CSGTerm> CSGTermNormalizer::normalize(const shared_ptr<CSGTerm> &root) +shared_ptr<CSGTerm> CSGTermNormalizer::normalize(const shared_ptr<CSGTerm> &root, + size_t limit) { shared_ptr<CSGTerm> temp = root; while (1) { @@ -14,8 +15,8 @@ shared_ptr<CSGTerm> CSGTermNormalizer::normalize(const shared_ptr<CSGTerm> &root #ifdef DEBUG PRINTF("Normalize count: %d\n", num); #endif - if (num > 5000) { - PRINTF("WARNING: Normalized tree is growing past 5000 elements. Aborting normalization.\n"); + if (num > limit) { + PRINTF("WARNING: Normalized tree is growing past %d elements. Aborting normalization.\n", limit); return root; } } diff --git a/src/csgtermnormalizer.h b/src/csgtermnormalizer.h index df37441..2aab3a4 100644 --- a/src/csgtermnormalizer.h +++ b/src/csgtermnormalizer.h @@ -9,7 +9,7 @@ public: CSGTermNormalizer() : counter(0) {} ~CSGTermNormalizer() {} - shared_ptr<class CSGTerm> normalize(const shared_ptr<CSGTerm> &term); + shared_ptr<class CSGTerm> normalize(const shared_ptr<CSGTerm> &term, size_t limit); private: shared_ptr<CSGTerm> normalizePass(shared_ptr<CSGTerm> term) ; diff --git a/src/mainwin.cc b/src/mainwin.cc index cbfa46a..4979970 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -779,7 +779,8 @@ void MainWindow::compileCSG(bool procevents) QApplication::processEvents(); CSGTermNormalizer normalizer; - this->root_norm_term = normalizer.normalize(this->root_raw_term); + size_t normalizelimit = 2 * Preferences::inst()->getValue("advanced/openCSGLimit").toUInt(); + this->root_norm_term = normalizer.normalize(this->root_raw_term, normalizelimit); assert(this->root_norm_term); root_chain = new CSGChain(); @@ -793,7 +794,7 @@ void MainWindow::compileCSG(bool procevents) highlights_chain = new CSGChain(); for (unsigned int i = 0; i < highlight_terms.size(); i++) { - highlight_terms[i] = normalizer.normalize(highlight_terms[i]); + highlight_terms[i] = normalizer.normalize(highlight_terms[i], normalizelimit); highlights_chain->import(highlight_terms[i]); } } @@ -806,7 +807,7 @@ void MainWindow::compileCSG(bool procevents) background_chain = new CSGChain(); for (unsigned int i = 0; i < background_terms.size(); i++) { - background_terms[i] = normalizer.normalize(background_terms[i]); + background_terms[i] = normalizer.normalize(background_terms[i], normalizelimit); background_chain->import(background_terms[i]); } } |