diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/csgtermtest.cc | 7 | ||||
-rw-r--r-- | tests/csgtestcore.cc | 38 |
2 files changed, 19 insertions, 26 deletions
diff --git a/tests/csgtermtest.cc b/tests/csgtermtest.cc index 2383126..aabbc05 100644 --- a/tests/csgtermtest.cc +++ b/tests/csgtermtest.cc @@ -116,11 +116,11 @@ int main(int argc, char **argv) // cout << tree.getString(*root_node) << "\n"; - std::vector<CSGTerm*> highlights; - std::vector<CSGTerm*> background; + std::vector<shared_ptr<CSGTerm> > highlights; + std::vector<shared_ptr<CSGTerm> > background; PolySetEvaluator psevaluator(tree); CSGTermEvaluator evaluator(tree, &psevaluator); - CSGTerm *root_term = evaluator.evaluateCSGTerm(*root_node, highlights, background); + shared_ptr<CSGTerm> root_term = evaluator.evaluateCSGTerm(*root_node, highlights, background); // cout << "Stored terms: " << evaluator.stored_term.size() << "\n"; // for (map<int, class CSGTerm*>::iterator iter = evaluator.stored_term.begin(); @@ -143,7 +143,6 @@ int main(int argc, char **argv) } outfile.close(); - if (root_term) root_term->unlink(); delete root_node; delete root_module; diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 49bd473..864d40e 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -39,21 +39,18 @@ class CsgInfo { public: CsgInfo(); - CSGTerm *root_norm_term; // Normalized CSG products + shared_ptr<CSGTerm> root_norm_term; // Normalized CSG products class CSGChain *root_chain; - std::vector<CSGTerm*> highlight_terms; + std::vector<shared_ptr<CSGTerm> > highlight_terms; CSGChain *highlights_chain; - std::vector<CSGTerm*> background_terms; + std::vector<shared_ptr<CSGTerm> > background_terms; CSGChain *background_chain; OffscreenView *glview; }; CsgInfo::CsgInfo() { - root_norm_term = NULL; root_chain = NULL; - highlight_terms = std::vector<CSGTerm*>(); highlights_chain = NULL; - background_terms = std::vector<CSGTerm*>(); background_chain = NULL; glview = NULL; } @@ -129,9 +126,9 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) CsgInfo csgInfo = CsgInfo(); CGALEvaluator cgalevaluator(tree); CSGTermEvaluator evaluator(tree, &cgalevaluator.psevaluator); - CSGTerm *root_raw_term = evaluator.evaluateCSGTerm(*root_node, - csgInfo.highlight_terms, - csgInfo.background_terms); + shared_ptr<CSGTerm> root_raw_term = evaluator.evaluateCSGTerm(*root_node, + csgInfo.highlight_terms, + csgInfo.background_terms); if (!root_raw_term) { cerr << "Error: CSG generation failed! (no top level object found)\n"; @@ -139,16 +136,17 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) } // CSG normalization - csgInfo.root_norm_term = root_raw_term->link(); + csgInfo.root_norm_term = root_raw_term; while (1) { - CSGTerm *n = csgInfo.root_norm_term->normalize(); - csgInfo.root_norm_term->unlink(); - if (csgInfo.root_norm_term == n) - break; + shared_ptr<CSGTerm> n = CSGTerm::normalize(csgInfo.root_norm_term); + if (csgInfo.root_norm_term == n) break; csgInfo.root_norm_term = n; } assert(csgInfo.root_norm_term); + if (csgInfo.root_norm_term.use_count() <= 1) { + fprintf(stderr, "XXX\n"); + } csgInfo.root_chain = new CSGChain(); csgInfo.root_chain->import(csgInfo.root_norm_term); @@ -160,10 +158,8 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) csgInfo.highlights_chain = new CSGChain(); for (unsigned int i = 0; i < csgInfo.highlight_terms.size(); i++) { while (1) { - CSGTerm *n = csgInfo.highlight_terms[i]->normalize(); - csgInfo.highlight_terms[i]->unlink(); - if (csgInfo.highlight_terms[i] == n) - break; + shared_ptr<CSGTerm> n = CSGTerm::normalize(csgInfo.highlight_terms[i]); + if (csgInfo.highlight_terms[i] == n) break; csgInfo.highlight_terms[i] = n; } csgInfo.highlights_chain->import(csgInfo.highlight_terms[i]); @@ -176,10 +172,8 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) csgInfo.background_chain = new CSGChain(); for (unsigned int i = 0; i < csgInfo.background_terms.size(); i++) { while (1) { - CSGTerm *n = csgInfo.background_terms[i]->normalize(); - csgInfo.background_terms[i]->unlink(); - if (csgInfo.background_terms[i] == n) - break; + shared_ptr<CSGTerm> n = CSGTerm::normalize(csgInfo.background_terms[i]); + if (csgInfo.background_terms[i] == n) break; csgInfo.background_terms[i] = n; } csgInfo.background_chain->import(csgInfo.background_terms[i]); |