diff options
-rw-r--r-- | src/csgterm.cc | 20 | ||||
-rw-r--r-- | src/csgterm.h | 1 | ||||
-rw-r--r-- | src/mainwin.cc | 13 | ||||
-rw-r--r-- | tests/OffscreenView.h | 2 | ||||
-rw-r--r-- | tests/opencsgtest.cc | 62 |
5 files changed, 66 insertions, 32 deletions
diff --git a/src/csgterm.cc b/src/csgterm.cc index 8306aaf..5bccff8 100644 --- a/src/csgterm.cc +++ b/src/csgterm.cc @@ -227,6 +227,26 @@ std::string CSGChain::dump() return dump.str(); } + +std::string CSGChain::fulldump() +{ + std::stringstream dump; + dump << "\nsizes: \n"; + dump << " polysets: " << polysets.size(); + dump << " matrices: " << matrices.size(); + dump << " colors: " << colors.size(); + dump << " types: " << types.size(); + dump << " labels: " << labels.size(); + dump << "\ndata: \n"; + for (size_t i = 0; i < polysets.size(); i++) dump << (*polysets[i]).polygons.size() << "\n"; + for (size_t i = 0; i < matrices.size(); i++) dump << *matrices[i] << "\n"; + for (size_t i = 0; i < colors.size(); i++) dump << *colors[i] << "\n"; + for (size_t i = 0; i < types.size(); i++) dump << types[i] << "\n"; + for (size_t i = 0; i < labels.size(); i++) dump << labels[i] << "\n"; + dump << "\n"; + return dump.str(); +} + BoundingBox CSGChain::getBoundingBox() const { BoundingBox bbox; diff --git a/src/csgterm.h b/src/csgterm.h index c12b7ae..c4e88a6 100644 --- a/src/csgterm.h +++ b/src/csgterm.h @@ -50,6 +50,7 @@ public: void add(const shared_ptr<PolySet> &polyset, double *m, double *color, CSGTerm::type_e type, std::string label); void import(CSGTerm *term, CSGTerm::type_e type = CSGTerm::TYPE_UNION); std::string dump(); + std::string fulldump(); BoundingBox getBoundingBox() const; }; diff --git a/src/mainwin.cc b/src/mainwin.cc index 56502f2..f3f53a1 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -95,6 +95,8 @@ using namespace boost::lambda; #endif // ENABLE_CGAL +using std::cerr; + // Global application state unsigned int GuiLocker::gui_locked = 0; @@ -876,6 +878,17 @@ void MainWindow::compileCSG(bool procevents) this->highlights_chain, this->background_chain); + fprintf(stderr, "Dump root chain\n"); + cerr << this->root_chain->fulldump(); + cerr << this->highlights_chain; + cerr << this->background_chain; +/* fprintf(stderr, "dump highlights\n"); + this->highlights_chain->dump(); + fprintf(stderr, "dump background\n"); + this->background_chain->dump();*/ + fprintf(stderr, "end dump\n"); + + PRINT("CSG generation finished."); int s = t.elapsed() / 1000; PRINTF("Total rendering time: %d hours, %d minutes, %d seconds", s / (60*60), (s / 60) % 60, s % 60); diff --git a/tests/OffscreenView.h b/tests/OffscreenView.h index 85c0144..dd52a81 100644 --- a/tests/OffscreenView.h +++ b/tests/OffscreenView.h @@ -1,8 +1,10 @@ #ifndef OFFSCREENVIEW_H_ #define OFFSCREENVIEW_H_ +#ifndef __APPLE__ // Eigen SIMD alignment #define EIGEN_DONT_VECTORIZE 1 #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT 1 +#endif #include "OffscreenContext.h" #include <Eigen/Core> diff --git a/tests/opencsgtest.cc b/tests/opencsgtest.cc index ff5d296..4043d4b 100644 --- a/tests/opencsgtest.cc +++ b/tests/opencsgtest.cc @@ -1,4 +1,4 @@ -//#include <GL/glew.h> +///#include <GL/glew.h> #include "openscad.h" #include "handle_dep.h" #include "builtin.h" @@ -32,8 +32,10 @@ QString librarydir; //#define DEBUG -struct CsgInfo +class CsgInfo { +public: + CsgInfo(); CSGTerm *root_norm_term; // Normalized CSG products class CSGChain *root_chain; std::vector<CSGTerm*> highlight_terms; @@ -43,6 +45,17 @@ struct CsgInfo OffscreenView *glview; }; +CsgInfo::CsgInfo() +{ + this->root_norm_term = NULL; + this->root_chain = NULL;; + this->highlight_terms = vector<CSGTerm*>(); + this->highlights_chain = NULL; + this->background_terms = vector<CSGTerm*>(); + this->background_chain = NULL; + this->glview = NULL; +} + AbstractNode *find_root_tag(AbstractNode *n) { foreach(AbstractNode *v, n->children) { @@ -141,12 +154,11 @@ int main(int argc, char *argv[]) Tree tree(root_node); - CsgInfo csgInfo; + 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); + 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"; @@ -203,45 +215,31 @@ int main(int argc, char *argv[]) QDir::setCurrent(original_path.absolutePath()); + /* + fprintf(stderr, "Dump root chain\n"); + cerr << csgInfo.root_chain->fulldump(); + cerr << csgInfo.highlights_chain; + cerr << csgInfo.background_chain; + fprintf(stderr, "end dump\n"); + */ - + ThrownTogetherRenderer thrownTogetherRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain); csgInfo.glview = new OffscreenView(512,512); - BoundingBox bbox = csgInfo.root_chain->getBoundingBox(); - Vector3d center = (bbox.min() + bbox.max()) / 2; - double radius = (bbox.max() - bbox.min()).norm() / 2; + BoundingBox bbox = csgInfo.root_chain->getBoundingBox(); + Vector3d center = (bbox.min() + bbox.max()) / 2; + double radius = (bbox.max() - bbox.min()).norm() / 2; Vector3d cameradir(1, 1, -0.5); Vector3d camerapos = center - radius*1.8*cameradir; csgInfo.glview->setCamera(camerapos, center); - //glewInit(); -#ifdef DEBUG - cout << "GLEW version " << glewGetString(GLEW_VERSION) << "\n"; - cout << (const char *)glGetString(GL_RENDERER) << "(" << (const char *)glGetString(GL_VENDOR) << ")\n" - << "OpenGL version " << (const char *)glGetString(GL_VERSION) << "\n"; - cout << "Extensions: " << (const char *)glGetString(GL_EXTENSIONS) << "\n"; - - - if (GLEW_ARB_framebuffer_object) { - cout << "ARB_FBO supported\n"; - } - if (GLEW_EXT_framebuffer_object) { - cout << "EXT_FBO supported\n"; - } - if (GLEW_EXT_packed_depth_stencil) { - cout << "EXT_packed_depth_stencil\n"; - } -#endif + csgInfo.glview->setRenderer(&thrownTogetherRenderer); //OpenCSGRenderer opencsgRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain, csgInfo.glview->shaderinfo); //csgInfo.glview->setRenderer(&opencsgRenderer); - ThrownTogetherRenderer thrownTogetherRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain); - csgInfo.glview->setRenderer(&thrownTogetherRenderer); - csgInfo.glview->paintGL(); - csgInfo.glview->save("/dev/stdout"); destroy_builtin_functions(); |