diff options
Diffstat (limited to 'src')
-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 |
8 files changed, 63 insertions, 48 deletions
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: |