diff options
-rw-r--r-- | RELEASE_NOTES | 3 | ||||
-rw-r--r-- | doc/TODO.txt | 3 | ||||
-rw-r--r-- | openscad.pro | 1 | ||||
-rw-r--r-- | src/PolySetCGALEvaluator.cc | 7 | ||||
-rw-r--r-- | src/cgal.cc | 46 | ||||
-rw-r--r-- | src/cgal.h | 2 | ||||
-rw-r--r-- | src/export.cc | 36 | ||||
-rw-r--r-- | src/mainwin.cc | 15 | ||||
-rw-r--r-- | src/node.h | 1 | ||||
-rw-r--r-- | src/primitives.cc | 2 | ||||
-rw-r--r-- | src/state.h | 2 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 10 | ||||
-rw-r--r-- | tests/csgtermtest.cc | 4 |
13 files changed, 76 insertions, 56 deletions
diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 5364e0a..a95d588 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,6 +1,9 @@ OpenSCAD 20xx.yy ================ +Bugfixes: +o square() crashed if any of the dimensions were zero +o Flush Caches didn't flush cached USE'd modules OpenSCAD 2011.06 ================ diff --git a/doc/TODO.txt b/doc/TODO.txt index 74e1f3f..751b544 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -115,6 +115,8 @@ o Misc - Save: Ask for confirmation if file has been externally changed - Rename OpenCSG and CGAL to smth. not specific to the underlying libraries (e.g Preview, Render) +o Cmd-line + - Add verbose option (PRINT command from mainwin.cc and progress output) ENGINE ------ @@ -169,6 +171,7 @@ o Misc empty AbstractNode instead of being ignored? - Bug: Using the background operator (%) on the only object in a scene triggers a CSG error: No top level object found + - Dependency tracking of libraries (USE'd modules) isn't implemented. See Mail from nophead 20110823. o Grammar - dim->name -> dim->label - A random(seed) function diff --git a/openscad.pro b/openscad.pro index d89a074..deda4d0 100644 --- a/openscad.pro +++ b/openscad.pro @@ -170,6 +170,7 @@ HEADERS += src/renderer.h \ SOURCES += src/openscad.cc \ src/mainwin.cc \ src/cgalrenderer.cc \ + src/cgal.cc \ src/ThrownTogetherRenderer.cc \ src/glview.cc \ src/export.cc \ diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index c269045..a914a62 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -9,7 +9,6 @@ #include "module.h" #include "printutils.h" -#include "export.h" // void cgal_nef3_to_polyset() #include "openscad.h" // get_fragments_from_r() PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node, AbstractPolyNode::render_mode_e) @@ -74,8 +73,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node, Abstr goto cant_project_non_simple_polyhedron; } - PolySet *ps3 = new PolySet(); - cgal_nef3_to_polyset(ps3, &N); + PolySet *ps3 = N.convertToPolyset(); Grid2d<int> conversion_grid(GRID_COARSE); for (size_t i = 0; i < ps3->polygons.size(); i++) { for (size_t j = 0; j < ps3->polygons[i].size(); j++) { @@ -106,8 +104,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node, Abstr goto cant_project_non_simple_polyhedron; } - PolySet *ps3 = new PolySet(); - cgal_nef3_to_polyset(ps3, &N); + PolySet *ps3 = N.convertToPolyset(); CGAL_Nef_polyhedron np; np.dim = 2; for (size_t i = 0; i < ps3->polygons.size(); i++) diff --git a/src/cgal.cc b/src/cgal.cc new file mode 100644 index 0000000..190ebd0 --- /dev/null +++ b/src/cgal.cc @@ -0,0 +1,46 @@ +#include "cgal.h" +#include "polyset.h" + +/*! + Creates a new PolySet and initializes it with the data from this polyhedron + + This method is not const since convert_to_Polyhedron() wasn't const + in earlier versions of CGAL. +*/ +PolySet *CGAL_Nef_polyhedron::convertToPolyset() +{ + PolySet *ps = new PolySet(); + CGAL_Polyhedron P; + this->p3.convert_to_Polyhedron(P); + + typedef CGAL_Polyhedron::Vertex Vertex; + typedef CGAL_Polyhedron::Vertex_const_iterator VCI; + typedef CGAL_Polyhedron::Facet_const_iterator FCI; + typedef CGAL_Polyhedron::Halfedge_around_facet_const_circulator HFCC; + + for (FCI fi = P.facets_begin(); fi != P.facets_end(); ++fi) { + HFCC hc = fi->facet_begin(); + HFCC hc_end = hc; + Vertex v1, v2, v3; + v1 = *VCI((hc++)->vertex()); + v3 = *VCI((hc++)->vertex()); + do { + v2 = v3; + v3 = *VCI((hc++)->vertex()); + double x1 = CGAL::to_double(v1.point().x()); + double y1 = CGAL::to_double(v1.point().y()); + double z1 = CGAL::to_double(v1.point().z()); + double x2 = CGAL::to_double(v2.point().x()); + double y2 = CGAL::to_double(v2.point().y()); + double z2 = CGAL::to_double(v2.point().z()); + double x3 = CGAL::to_double(v3.point().x()); + double y3 = CGAL::to_double(v3.point().y()); + double z3 = CGAL::to_double(v3.point().z()); + ps->append_poly(); + ps->append_vertex(x1, y1, z1); + ps->append_vertex(x2, y2, z2); + ps->append_vertex(x3, y3, z3); + } while (hc != hc_end); + } + return ps; +} @@ -94,6 +94,8 @@ struct CGAL_Nef_polyhedron return p3.number_of_vertices(); return 0; } + + class PolySet *convertToPolyset(); }; #endif /* ENABLE_CGAL */ diff --git a/src/export.cc b/src/export.cc index c87e917..e46a14f 100644 --- a/src/export.cc +++ b/src/export.cc @@ -36,42 +36,6 @@ #ifdef ENABLE_CGAL #include "cgal.h" -void cgal_nef3_to_polyset(PolySet *ps, CGAL_Nef_polyhedron *root_N) -{ - CGAL_Polyhedron P; - root_N->p3.convert_to_Polyhedron(P); - - typedef CGAL_Polyhedron::Vertex Vertex; - typedef CGAL_Polyhedron::Vertex_const_iterator VCI; - typedef CGAL_Polyhedron::Facet_const_iterator FCI; - typedef CGAL_Polyhedron::Halfedge_around_facet_const_circulator HFCC; - - for (FCI fi = P.facets_begin(); fi != P.facets_end(); ++fi) { - HFCC hc = fi->facet_begin(); - HFCC hc_end = hc; - Vertex v1, v2, v3; - v1 = *VCI((hc++)->vertex()); - v3 = *VCI((hc++)->vertex()); - do { - v2 = v3; - v3 = *VCI((hc++)->vertex()); - double x1 = CGAL::to_double(v1.point().x()); - double y1 = CGAL::to_double(v1.point().y()); - double z1 = CGAL::to_double(v1.point().z()); - double x2 = CGAL::to_double(v2.point().x()); - double y2 = CGAL::to_double(v2.point().y()); - double z2 = CGAL::to_double(v2.point().z()); - double x3 = CGAL::to_double(v3.point().x()); - double y3 = CGAL::to_double(v3.point().y()); - double z3 = CGAL::to_double(v3.point().z()); - ps->append_poly(); - ps->append_vertex(x1, y1, z1); - ps->append_vertex(x2, y2, z2); - ps->append_vertex(x3, y3, z3); - } while (hc != hc_end); - } -} - /*! Saves the current 3D CGAL Nef polyhedron as STL to the given file. The file must be open. diff --git a/src/mainwin.cc b/src/mainwin.cc index 2cd16be..89d17c5 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1114,16 +1114,18 @@ void MainWindow::actionReloadCompile() compile(true); if (this->root_node) compileCSG(true); + // Go to non-CGAL view mode + if (viewActionThrownTogether->isChecked()) { + viewModeThrownTogether(); + } + else { #ifdef ENABLE_OPENCSG - if (!(viewActionOpenCSG->isVisible() && viewActionOpenCSG->isChecked()) && - !viewActionThrownTogether->isChecked()) { viewModeOpenCSG(); - } - else +#else + viewModeThrownTogether(); #endif - { - this->glview->updateGL(); } + clearCurrentOutput(); } @@ -1489,6 +1491,7 @@ void MainWindow::actionFlushCaches() #endif dxf_dim_cache.clear(); dxf_cross_cache.clear(); + Module::libs_cache.clear(); } void MainWindow::viewModeActionsUncheck() @@ -2,6 +2,7 @@ #define NODE_H_ #include <vector> +#include <string> #include "traverser.h" diff --git a/src/primitives.cc b/src/primitives.cc index 3f88c75..4210e15 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -474,7 +474,7 @@ sphere_next_r2: } } - if (this->type == SQUARE) + if (this->type == SQUARE && x > 0 && y > 0) { double x1, x2, y1, y2; if (this->center) { diff --git a/src/state.h b/src/state.h index ae25c0f..c81575a 100644 --- a/src/state.h +++ b/src/state.h @@ -1,6 +1,8 @@ #ifndef STATE_H_ #define STATE_H_ +#include <cstring> + class State { public: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 961267a..fb86448 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -139,7 +139,7 @@ include_directories(${CGAL_INCLUDE_DIRS}) # # cgaltest # -add_executable(cgaltest cgaltest.cc ../src/CSGTermEvaluator.cc ../src/CGALEvaluator.cc +add_executable(cgaltest cgaltest.cc ../src/cgal.cc ../src/CSGTermEvaluator.cc ../src/CGALEvaluator.cc ../src/PolySetCGALEvaluator.cc ../src/qhash.cc ../src/nef2dxf.cc ../src/cgaladv_minkowski2.cc ../src/cgaladv_minkowski3.cc ${COMMON_SOURCES}) set_target_properties(cgaltest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") @@ -149,7 +149,7 @@ target_link_libraries(cgaltest ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_ # opencsgtest # add_executable(opencsgtest opencsgtest.cc OffscreenView.cc OffscreenContext.mm - ../src/opencsgrenderer.cc ../src/throwntogetherrenderer.cc ../src/CSGTermEvaluator.cc ../src/CGALEvaluator.cc + ../src/opencsgrenderer.cc ../src/throwntogetherrenderer.cc ../src/CSGTermEvaluator.cc ../src/cgal.cc ../src/CGALEvaluator.cc ../src/PolySetCGALEvaluator.cc ../src/qhash.cc ../src/nef2dxf.cc ../src/cgaladv_minkowski2.cc ../src/cgaladv_minkowski3.cc ${COMMON_SOURCES}) @@ -184,11 +184,7 @@ add_cmdline_test(csgtexttest txt ${MINIMAL_FILES}) add_cmdline_test(csgtermtest txt ${MINIMAL_FILES}) # Add cgaltest tests to CTest -LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/cube.scad) -LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/sphere.scad) -LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/cylinder.scad) -LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/background-modifier.scad) -LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/highlight-modifier.scad) +LIST(APPEND CGALTEST_FILES ${FEATURES_FILES}) LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) add_cmdline_test(cgaltest stl ${CGALTEST_FILES}) diff --git a/tests/csgtermtest.cc b/tests/csgtermtest.cc index 1c2eb22..42d22a0 100644 --- a/tests/csgtermtest.cc +++ b/tests/csgtermtest.cc @@ -154,8 +154,10 @@ int main(int argc, char **argv) // cout << tree.getString(*root_node) << "\n"; + vector<CSGTerm*> highlights; + vector<CSGTerm*> background; CSGTermEvaluator evaluator(tree); - CSGTerm *root_term = evaluator.evaluateCSGTerm(*root_node, NULL, NULL); + 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(); |