From 781dab0493b62c368b948b0d7ce1be714c36f3a2 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 4 Sep 2011 01:57:26 +0200 Subject: Filename case fix diff --git a/openscad.pro b/openscad.pro index 8abadc9..d3923e5 100644 --- a/openscad.pro +++ b/openscad.pro @@ -214,12 +214,12 @@ HEADERS += src/cgal.h \ src/cgalfwd.h \ src/CGALEvaluator.h \ src/PolySetCGALEvaluator.h \ - src/cgalrenderer.h \ + src/CGALRenderer.h \ src/CGAL_Nef_polyhedron.h SOURCES += src/CGALEvaluator.cc \ src/PolySetCGALEvaluator.cc \ - src/cgalrenderer.cc \ + src/CGALRenderer.cc \ src/CGAL_Nef_polyhedron.cc \ src/CGAL_Nef_polyhedron_DxfData.cc \ src/cgaladv_convexhull2.cc \ diff --git a/src/CGALRenderer.cc b/src/CGALRenderer.cc new file mode 100644 index 0000000..da5d859 --- /dev/null +++ b/src/CGALRenderer.cc @@ -0,0 +1,134 @@ +/* + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * As a special exception, you have permission to link this program + * with the CGAL library and distribute executables, as long as you + * follow the requirements of the GNU GPL in regard to all of the + * software in the executable aside from CGAL. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "cgalrenderer.h" +#include "polyset.h" +#include "CGAL_renderer.h" +#include "dxfdata.h" +#include "dxftess.h" +#include "CGAL_Nef_polyhedron.h" +#include "cgal.h" + +//#include "Preferences.h" + +CGALRenderer::CGALRenderer(const CGAL_Nef_polyhedron &root) : root(root) +{ + if (root.dim == 2) { + DxfData *dd = root.convertToDxfData(); + this->polyhedron = NULL; + this->polyset = new PolySet(); + this->polyset->is2d = true; + dxf_tesselate(this->polyset, *dd, 0, true, false, 0); + delete dd; + } + else if (root.dim == 3) { + this->polyset = NULL; + this->polyhedron = new Polyhedron(); + // FIXME: Make independent of Preferences + // this->polyhedron->setColor(Polyhedron::CGAL_NEF3_MARKED_FACET_COLOR, + // Preferences::inst()->color(Preferences::CGAL_FACE_BACK_COLOR).red(), + // Preferences::inst()->color(Preferences::CGAL_FACE_BACK_COLOR).green(), + // Preferences::inst()->color(Preferences::CGAL_FACE_BACK_COLOR).blue()); + // this->polyhedron->setColor(Polyhedron::CGAL_NEF3_UNMARKED_FACET_COLOR, + // Preferences::inst()->color(Preferences::CGAL_FACE_FRONT_COLOR).red(), + // Preferences::inst()->color(Preferences::CGAL_FACE_FRONT_COLOR).green(), + // Preferences::inst()->color(Preferences::CGAL_FACE_FRONT_COLOR).blue()); + + CGAL::OGL::Nef3_Converter::convert_to_OGLPolyhedron(*this->root.p3, this->polyhedron); + this->polyhedron->init(); + } +} + +CGALRenderer::~CGALRenderer() +{ + if (this->polyset) this->polyset->unlink(); + delete this->polyhedron; +} + +void CGALRenderer::draw(bool showfaces, bool showedges) const +{ + if (this->root.dim == 2) { + // Draw 2D polygons + glDisable(GL_LIGHTING); +// FIXME: const QColor &col = Preferences::inst()->color(Preferences::CGAL_FACE_2D_COLOR); + const QColor &col = QColor(0x00, 0xbf, 0x99); + glColor3f(col.redF(), col.greenF(), col.blueF()); + + for (int i=0; i < this->polyset->polygons.size(); i++) { + glBegin(GL_POLYGON); + for (int j=0; j < this->polyset->polygons[i].size(); j++) { + const Vector3d &p = this->polyset->polygons[i][j]; + glVertex3d(p[0], p[1], -0.1); + } + glEnd(); + } + + typedef CGAL_Nef_polyhedron2::Explorer Explorer; + typedef Explorer::Face_const_iterator fci_t; + typedef Explorer::Halfedge_around_face_const_circulator heafcc_t; + typedef Explorer::Point Point; + Explorer E = this->root.p2->explorer(); + + // Draw 2D edges + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glLineWidth(2); +// FIXME: const QColor &col2 = Preferences::inst()->color(Preferences::CGAL_EDGE_2D_COLOR); + const QColor &col2 = QColor(0xff, 0x00, 0x00); + glColor3f(col2.redF(), col2.greenF(), col2.blueF()); + + // Extract the boundary, including inner boundaries of the polygons + for (fci_t fit = E.faces_begin(), facesend = E.faces_end(); fit != facesend; ++fit) { + bool fset = false; + double fx = 0.0, fy = 0.0; + heafcc_t fcirc(E.halfedge(fit)), fend(fcirc); + CGAL_For_all(fcirc, fend) { + if(E.is_standard(E.target(fcirc))) { + Point p = E.point(E.target(fcirc)); + double x = to_double(p.x()), y = to_double(p.y()); + if (!fset) { + glBegin(GL_LINE_STRIP); + fx = x, fy = y; + fset = true; + } + glVertex3d(x, y, -0.1); + } + } + if (fset) { + glVertex3d(fx, fy, -0.1); + glEnd(); + } + } + + glEnable(GL_DEPTH_TEST); + } + else if (this->root.dim == 3) { + if (showfaces) this->polyhedron->set_style(SNC_BOUNDARY); + else this->polyhedron->set_style(SNC_SKELETON); + + this->polyhedron->draw(showfaces && showedges); + } +} diff --git a/src/CGALRenderer.h b/src/CGALRenderer.h new file mode 100644 index 0000000..5f854ea --- /dev/null +++ b/src/CGALRenderer.h @@ -0,0 +1,20 @@ +#ifndef CGALRENDERER_H_ +#define CGALRENDERER_H_ + +#include "renderer.h" +#include "CGAL_Nef_polyhedron.h" + +class CGALRenderer : public Renderer +{ +public: + CGALRenderer(const CGAL_Nef_polyhedron &root); + ~CGALRenderer(); + void draw(bool showfaces, bool showedges) const; + +public: + const CGAL_Nef_polyhedron &root; + class Polyhedron *polyhedron; + class PolySet *polyset; +}; + +#endif diff --git a/src/cgalrenderer.cc b/src/cgalrenderer.cc deleted file mode 100644 index da5d859..0000000 --- a/src/cgalrenderer.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * OpenSCAD (www.openscad.org) - * Copyright (C) 2009-2011 Clifford Wolf and - * Marius Kintel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * As a special exception, you have permission to link this program - * with the CGAL library and distribute executables, as long as you - * follow the requirements of the GNU GPL in regard to all of the - * software in the executable aside from CGAL. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "cgalrenderer.h" -#include "polyset.h" -#include "CGAL_renderer.h" -#include "dxfdata.h" -#include "dxftess.h" -#include "CGAL_Nef_polyhedron.h" -#include "cgal.h" - -//#include "Preferences.h" - -CGALRenderer::CGALRenderer(const CGAL_Nef_polyhedron &root) : root(root) -{ - if (root.dim == 2) { - DxfData *dd = root.convertToDxfData(); - this->polyhedron = NULL; - this->polyset = new PolySet(); - this->polyset->is2d = true; - dxf_tesselate(this->polyset, *dd, 0, true, false, 0); - delete dd; - } - else if (root.dim == 3) { - this->polyset = NULL; - this->polyhedron = new Polyhedron(); - // FIXME: Make independent of Preferences - // this->polyhedron->setColor(Polyhedron::CGAL_NEF3_MARKED_FACET_COLOR, - // Preferences::inst()->color(Preferences::CGAL_FACE_BACK_COLOR).red(), - // Preferences::inst()->color(Preferences::CGAL_FACE_BACK_COLOR).green(), - // Preferences::inst()->color(Preferences::CGAL_FACE_BACK_COLOR).blue()); - // this->polyhedron->setColor(Polyhedron::CGAL_NEF3_UNMARKED_FACET_COLOR, - // Preferences::inst()->color(Preferences::CGAL_FACE_FRONT_COLOR).red(), - // Preferences::inst()->color(Preferences::CGAL_FACE_FRONT_COLOR).green(), - // Preferences::inst()->color(Preferences::CGAL_FACE_FRONT_COLOR).blue()); - - CGAL::OGL::Nef3_Converter::convert_to_OGLPolyhedron(*this->root.p3, this->polyhedron); - this->polyhedron->init(); - } -} - -CGALRenderer::~CGALRenderer() -{ - if (this->polyset) this->polyset->unlink(); - delete this->polyhedron; -} - -void CGALRenderer::draw(bool showfaces, bool showedges) const -{ - if (this->root.dim == 2) { - // Draw 2D polygons - glDisable(GL_LIGHTING); -// FIXME: const QColor &col = Preferences::inst()->color(Preferences::CGAL_FACE_2D_COLOR); - const QColor &col = QColor(0x00, 0xbf, 0x99); - glColor3f(col.redF(), col.greenF(), col.blueF()); - - for (int i=0; i < this->polyset->polygons.size(); i++) { - glBegin(GL_POLYGON); - for (int j=0; j < this->polyset->polygons[i].size(); j++) { - const Vector3d &p = this->polyset->polygons[i][j]; - glVertex3d(p[0], p[1], -0.1); - } - glEnd(); - } - - typedef CGAL_Nef_polyhedron2::Explorer Explorer; - typedef Explorer::Face_const_iterator fci_t; - typedef Explorer::Halfedge_around_face_const_circulator heafcc_t; - typedef Explorer::Point Point; - Explorer E = this->root.p2->explorer(); - - // Draw 2D edges - glDisable(GL_DEPTH_TEST); - glDisable(GL_LIGHTING); - glLineWidth(2); -// FIXME: const QColor &col2 = Preferences::inst()->color(Preferences::CGAL_EDGE_2D_COLOR); - const QColor &col2 = QColor(0xff, 0x00, 0x00); - glColor3f(col2.redF(), col2.greenF(), col2.blueF()); - - // Extract the boundary, including inner boundaries of the polygons - for (fci_t fit = E.faces_begin(), facesend = E.faces_end(); fit != facesend; ++fit) { - bool fset = false; - double fx = 0.0, fy = 0.0; - heafcc_t fcirc(E.halfedge(fit)), fend(fcirc); - CGAL_For_all(fcirc, fend) { - if(E.is_standard(E.target(fcirc))) { - Point p = E.point(E.target(fcirc)); - double x = to_double(p.x()), y = to_double(p.y()); - if (!fset) { - glBegin(GL_LINE_STRIP); - fx = x, fy = y; - fset = true; - } - glVertex3d(x, y, -0.1); - } - } - if (fset) { - glVertex3d(fx, fy, -0.1); - glEnd(); - } - } - - glEnable(GL_DEPTH_TEST); - } - else if (this->root.dim == 3) { - if (showfaces) this->polyhedron->set_style(SNC_BOUNDARY); - else this->polyhedron->set_style(SNC_SKELETON); - - this->polyhedron->draw(showfaces && showedges); - } -} diff --git a/src/cgalrenderer.h b/src/cgalrenderer.h deleted file mode 100644 index 5f854ea..0000000 --- a/src/cgalrenderer.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef CGALRENDERER_H_ -#define CGALRENDERER_H_ - -#include "renderer.h" -#include "CGAL_Nef_polyhedron.h" - -class CGALRenderer : public Renderer -{ -public: - CGALRenderer(const CGAL_Nef_polyhedron &root); - ~CGALRenderer(); - void draw(bool showfaces, bool showedges) const; - -public: - const CGAL_Nef_polyhedron &root; - class Polyhedron *polyhedron; - class PolySet *polyset; -}; - -#endif -- cgit v0.10.1