From 2262afa92bda168aae155e4d0e8f2258e27edded Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 29 Sep 2011 12:51:29 +0200 Subject: Added test case for polyhedron intersection bug reported by Dan Zuras diff --git a/testdata/scad/features/intersection-tests.scad b/testdata/scad/features/intersection-tests.scad index e53f3c9..bc58233 100644 --- a/testdata/scad/features/intersection-tests.scad +++ b/testdata/scad/features/intersection-tests.scad @@ -39,3 +39,11 @@ translate([-12,12,0]) intersection() { cube([10,10,10], center=true); translate([0,-9.99,-9.99]) cube([10,10,10], center=true); } + +translate([-12,0,0]) intersection() { + scale(10/sqrt(2)) + polyhedron(points = [[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]], + triangles = [[0,2,4],[0,5,2],[0,4,3],[0,3,5],[1,4,2],[1,2,5],[1,3,4], [1,5,3]], + convexity = 1); + translate([0,0,10]) cube([20,20,20], center=true); +} diff --git a/tests/regression/cgalpngtest/intersection-tests-expected.png b/tests/regression/cgalpngtest/intersection-tests-expected.png index 6d004b0..1fd38e7 100644 Binary files a/tests/regression/cgalpngtest/intersection-tests-expected.png and b/tests/regression/cgalpngtest/intersection-tests-expected.png differ -- cgit v0.10.1 From 9e42bcc2fe08b839165b641d6357b96c66f37d43 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 29 Sep 2011 21:26:12 +0200 Subject: removed obsolete qtcolorbutton diff --git a/src/qtcolorbutton/README.txt b/src/qtcolorbutton/README.txt deleted file mode 100644 index 4b55f67..0000000 --- a/src/qtcolorbutton/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -The QtColorButton class is copied from the gradient editor in Qt's shared tool classes: -http://qt.gitorious.org/qt/qt/trees/master/tools/shared/qtgradienteditor diff --git a/src/qtcolorbutton/qtcolorbutton.cpp b/src/qtcolorbutton/qtcolorbutton.cpp deleted file mode 100644 index 21b9848..0000000 --- a/src/qtcolorbutton/qtcolorbutton.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtcolorbutton.h" -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QtColorButtonPrivate -{ - QtColorButton *q_ptr; - Q_DECLARE_PUBLIC(QtColorButton) -public: - QColor m_color; -#ifndef QT_NO_DRAGANDDROP - QColor m_dragColor; - QPoint m_dragStart; - bool m_dragging; -#endif - bool m_backgroundCheckered; - - void slotEditColor(); - QColor shownColor() const; - QPixmap generatePixmap() const; -}; - -void QtColorButtonPrivate::slotEditColor() -{ - bool ok; - const QRgb rgba = QColorDialog::getRgba(m_color.rgba(), &ok, q_ptr); - if (!ok) - return; - const QColor c = QColor::fromRgba(rgba); - if (c == q_ptr->color()) - return; - q_ptr->setColor(c); - emit q_ptr->colorChanged(m_color); -} - -QColor QtColorButtonPrivate::shownColor() const -{ -#ifndef QT_NO_DRAGANDDROP - if (m_dragging) - return m_dragColor; -#endif - return m_color; -} - -QPixmap QtColorButtonPrivate::generatePixmap() const -{ - QPixmap pix(24, 24); - - int pixSize = 20; - QBrush br(shownColor()); - - QPixmap pm(2 * pixSize, 2 * pixSize); - QPainter pmp(&pm); - pmp.fillRect(0, 0, pixSize, pixSize, Qt::lightGray); - pmp.fillRect(pixSize, pixSize, pixSize, pixSize, Qt::lightGray); - pmp.fillRect(0, pixSize, pixSize, pixSize, Qt::darkGray); - pmp.fillRect(pixSize, 0, pixSize, pixSize, Qt::darkGray); - pmp.fillRect(0, 0, 2 * pixSize, 2 * pixSize, shownColor()); - br = QBrush(pm); - - QPainter p(&pix); - int corr = 1; - QRect r = pix.rect().adjusted(corr, corr, -corr, -corr); - p.setBrushOrigin((r.width() % pixSize + pixSize) / 2 + corr, (r.height() % pixSize + pixSize) / 2 + corr); - p.fillRect(r, br); - - p.fillRect(r.width() / 4 + corr, r.height() / 4 + corr, - r.width() / 2, r.height() / 2, - QColor(shownColor().rgb())); - p.drawRect(pix.rect().adjusted(0, 0, -1, -1)); - - return pix; -} - -/////////////// - -QtColorButton::QtColorButton(QWidget *parent) - : QToolButton(parent) -{ - d_ptr = new QtColorButtonPrivate; - d_ptr->q_ptr = this; - d_ptr->m_dragging = false; - d_ptr->m_backgroundCheckered = true; - - setAcceptDrops(true); - - connect(this, SIGNAL(clicked()), this, SLOT(slotEditColor())); - setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); -} - -QtColorButton::~QtColorButton() -{ - delete d_ptr; -} - -void QtColorButton::setColor(const QColor &color) -{ - if (d_ptr->m_color == color) - return; - d_ptr->m_color = color; - update(); -} - -QColor QtColorButton::color() const -{ - return d_ptr->m_color; -} - -void QtColorButton::setBackgroundCheckered(bool checkered) -{ - if (d_ptr->m_backgroundCheckered == checkered) - return; - d_ptr->m_backgroundCheckered = checkered; - update(); -} - -bool QtColorButton::isBackgroundCheckered() const -{ - return d_ptr->m_backgroundCheckered; -} - -void QtColorButton::paintEvent(QPaintEvent *event) -{ - QToolButton::paintEvent(event); - if (!isEnabled()) - return; - - const int pixSize = 10; - QBrush br(d_ptr->shownColor()); - if (d_ptr->m_backgroundCheckered) { - QPixmap pm(2 * pixSize, 2 * pixSize); - QPainter pmp(&pm); - pmp.fillRect(0, 0, pixSize, pixSize, Qt::white); - pmp.fillRect(pixSize, pixSize, pixSize, pixSize, Qt::white); - pmp.fillRect(0, pixSize, pixSize, pixSize, Qt::black); - pmp.fillRect(pixSize, 0, pixSize, pixSize, Qt::black); - pmp.fillRect(0, 0, 2 * pixSize, 2 * pixSize, d_ptr->shownColor()); - br = QBrush(pm); - } - - QPainter p(this); - const int corr = 4; - QRect r = rect().adjusted(corr, corr, -corr, -corr); - p.setBrushOrigin((r.width() % pixSize + pixSize) / 2 + corr, (r.height() % pixSize + pixSize) / 2 + corr); - p.fillRect(r, br); - - //const int adjX = qRound(r.width() / 4.0); - //const int adjY = qRound(r.height() / 4.0); - //p.fillRect(r.adjusted(adjX, adjY, -adjX, -adjY), - // QColor(d_ptr->shownColor().rgb())); - /* - p.fillRect(r.adjusted(0, r.height() * 3 / 4, 0, 0), - QColor(d_ptr->shownColor().rgb())); - p.fillRect(r.adjusted(0, 0, 0, -r.height() * 3 / 4), - QColor(d_ptr->shownColor().rgb())); - */ - /* - const QColor frameColor0(0, 0, 0, qRound(0.2 * (0xFF - d_ptr->shownColor().alpha()))); - p.setPen(frameColor0); - p.drawRect(r.adjusted(adjX, adjY, -adjX - 1, -adjY - 1)); - */ - - const QColor frameColor1(0, 0, 0, 26); - p.setPen(frameColor1); - p.drawRect(r.adjusted(1, 1, -2, -2)); - const QColor frameColor2(0, 0, 0, 51); - p.setPen(frameColor2); - p.drawRect(r.adjusted(0, 0, -1, -1)); -} - -void QtColorButton::mousePressEvent(QMouseEvent *event) -{ -#ifndef QT_NO_DRAGANDDROP - if (event->button() == Qt::LeftButton) - d_ptr->m_dragStart = event->pos(); -#endif - QToolButton::mousePressEvent(event); -} - -void QtColorButton::mouseMoveEvent(QMouseEvent *event) -{ -#ifndef QT_NO_DRAGANDDROP - if (event->buttons() & Qt::LeftButton && - (d_ptr->m_dragStart - event->pos()).manhattanLength() > QApplication::startDragDistance()) { - QMimeData *mime = new QMimeData; - mime->setColorData(color()); - QDrag *drg = new QDrag(this); - drg->setMimeData(mime); - drg->setPixmap(d_ptr->generatePixmap()); - setDown(false); - event->accept(); - drg->start(); - return; - } -#endif - QToolButton::mouseMoveEvent(event); -} - -#ifndef QT_NO_DRAGANDDROP -void QtColorButton::dragEnterEvent(QDragEnterEvent *event) -{ - const QMimeData *mime = event->mimeData(); - if (!mime->hasColor()) - return; - - event->accept(); - d_ptr->m_dragColor = qvariant_cast(mime->colorData()); - d_ptr->m_dragging = true; - update(); -} - -void QtColorButton::dragLeaveEvent(QDragLeaveEvent *event) -{ - event->accept(); - d_ptr->m_dragging = false; - update(); -} - -void QtColorButton::dropEvent(QDropEvent *event) -{ - event->accept(); - d_ptr->m_dragging = false; - if (d_ptr->m_dragColor == color()) - return; - setColor(d_ptr->m_dragColor); - emit colorChanged(color()); -} -#endif - -QT_END_NAMESPACE - -#include "moc_qtcolorbutton.cpp" diff --git a/src/qtcolorbutton/qtcolorbutton.h b/src/qtcolorbutton/qtcolorbutton.h deleted file mode 100644 index 26bdde0..0000000 --- a/src/qtcolorbutton/qtcolorbutton.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTCOLORBUTTON_H -#define QTCOLORBUTTON_H - -#include - -QT_BEGIN_NAMESPACE - -class QtColorButton : public QToolButton -{ - Q_OBJECT - Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered) -public: - QtColorButton(QWidget *parent = 0); - ~QtColorButton(); - - bool isBackgroundCheckered() const; - void setBackgroundCheckered(bool checkered); - - QColor color() const; - -public slots: - - void setColor(const QColor &color); - -signals: - void colorChanged(const QColor &color); -protected: - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); -#ifndef QT_NO_DRAGANDDROP - void dragEnterEvent(QDragEnterEvent *event); - void dragLeaveEvent(QDragLeaveEvent *event); - void dropEvent(QDropEvent *event); -#endif -private: - class QtColorButtonPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtColorButton) - Q_DISABLE_COPY(QtColorButton) - Q_PRIVATE_SLOT(d_func(), void slotEditColor()) -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/qtcolorbutton/qtcolorbutton.pri b/src/qtcolorbutton/qtcolorbutton.pri deleted file mode 100644 index 0e41068..0000000 --- a/src/qtcolorbutton/qtcolorbutton.pri +++ /dev/null @@ -1,4 +0,0 @@ -INCLUDEPATH += $$PWD -DEPENDPATH += $$PWD -SOURCES += $$PWD/qtcolorbutton.cpp -HEADERS += $$PWD/qtcolorbutton.h -- cgit v0.10.1 From c1fa2f9675225df448a1c1f162ae7d93573401fa Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 29 Sep 2011 22:22:49 +0200 Subject: Upgrade to CGAL-3.9 diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 0ed375f..c8eb349 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -120,12 +120,13 @@ build_cgal() echo "Building CGAL" $version "..." cd $BASEDIR/src rm -rf CGAL* - curl -O https://gforge.inria.fr/frs/download.php/28500/CGAL-$version.tar.gz + curl -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz +# curl -O https://gforge.inria.fr/frs/download.php/28500/CGAL-$version.tar.gz # curl -O https://gforge.inria.fr/frs/download.php/27641/CGAL-$version.tar.gz tar xzf CGAL-$version.tar.gz cd CGAL-$version # We build a static lib. Not really necessary, but it's well tested. - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" -DBOOST_ROOT=$DEPLOYDIR + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.dylib -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmp.dylib -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.dylib -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" -DBOOST_ROOT=$DEPLOYDIR make -j4 make install } @@ -165,6 +166,6 @@ build_gmp 5.0.1 build_mpfr 3.0.1 build_boost 1.47.0 # NB! For CGAL, also update the actual download URL in the function -build_cgal 3.8 +build_cgal 3.9 build_glew 1.6.0 build_opencsg 1.3.0 -- cgit v0.10.1 From 1b31c32638faa0429ffb6af0751a2199b33c52a0 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 29 Sep 2011 23:13:22 +0200 Subject: Cleaned up the OGL_helper patches a bit diff --git a/patches/CGAL-OGL-Tess-Combine-Fix.patch b/patches/CGAL-OGL-Tess-Combine-Fix.patch deleted file mode 100644 index 2a4ad1a..0000000 --- a/patches/CGAL-OGL-Tess-Combine-Fix.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- CGAL-3.4/include/CGAL/Nef_3/OGL_helper.h -+++ CGAL-3.4/include/CGAL/Nef_3/OGL_helper.h -@@ -243,6 +243,23 @@ - glVertex3dv(pc); - } - -+ inline void CGAL_GLU_TESS_CALLBACK combineCallback(GLdouble coords[3], GLvoid *d[4], GLfloat w[4], GLvoid **dataOut) -+ { -+ static std::list pcache; -+ if (dataOut) { -+ GLdouble *n = new GLdouble[3]; -+ n[0] = coords[0]; -+ n[1] = coords[1]; -+ n[2] = coords[2]; -+ pcache.push_back(n); -+ *dataOut = n; -+ } else { -+ for (std::list::const_iterator i = pcache.begin(); i != pcache.end(); i++) -+ delete[] *i; -+ pcache.clear(); -+ } -+ } -+ - - enum { SNC_AXES}; - enum { SNC_BOUNDARY, SNC_SKELETON }; -@@ -376,6 +393,8 @@ - GLUtesselator* tess_ = gluNewTess(); - gluTessCallback(tess_, GLenum(GLU_TESS_VERTEX_DATA), - (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &vertexCallback); -+ gluTessCallback(tess_, GLenum(GLU_TESS_COMBINE), -+ (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &combineCallback); - gluTessCallback(tess_, GLenum(GLU_TESS_BEGIN), - (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &beginCallback); - gluTessCallback(tess_, GLenum(GLU_TESS_END), -@@ -410,6 +429,7 @@ - gluTessEndPolygon(tess_); - // CGAL_NEF_TRACEN("End Polygon"); - gluDeleteTess(tess_); -+ combineCallback(NULL, NULL, NULL, NULL); - } - - void construct_axes() const diff --git a/patches/CGAL-OGL_helper-colors.patch b/patches/CGAL-OGL_helper-colors.patch new file mode 100644 index 0000000..4c2f8c0 --- /dev/null +++ b/patches/CGAL-OGL_helper-colors.patch @@ -0,0 +1,80 @@ +--- OGL_helper.h 2011-09-29 23:02:04.000000000 +0200 ++++ ../src/OGL_helper.h 2011-09-29 23:01:27.000000000 +0200 +@@ -263,7 +263,7 @@ + enum { SNC_BOUNDARY, SNC_SKELETON }; + + class Polyhedron : public OGL_base_object { +- ++ protected: + std::list vertices_; + std::list edges_; + std::list halffacets_; +@@ -356,11 +356,17 @@ + Bbox_3 bbox() const { return bbox_; } + Bbox_3& bbox() { return bbox_; } + ++ virtual CGAL::Color getVertexColor(Vertex_iterator v) const ++ { ++ CGAL::Color cf(CGAL_NEF3_MARKED_VERTEX_COLOR), ++ ct(CGAL_NEF3_UNMARKED_VERTEX_COLOR); // more blue-ish ++ CGAL::Color c = v->mark() ? ct : cf; ++ return c; ++ } ++ + void draw(Vertex_iterator v) const { + // CGAL_NEF_TRACEN("drawing vertex "<<*v); +- CGAL::Color cf(CGAL_NEF3_MARKED_VERTEX_COLOR), +- ct(CGAL_NEF3_UNMARKED_VERTEX_COLOR); // more blue-ish +- CGAL::Color c = v->mark() ? ct : cf; ++ CGAL::Color c = getVertexColor(v); + glPointSize(10); + glColor3ub(c.red(), c.green(), c.blue()); + glBegin(GL_POINTS); +@@ -372,12 +378,18 @@ + glEnd(); + } + ++ virtual CGAL::Color getEdgeColor(Edge_iterator e) const ++ { ++ CGAL::Color cf(CGAL_NEF3_MARKED_EDGE_COLOR), ++ ct(CGAL_NEF3_UNMARKED_EDGE_COLOR); // more blue-ish ++ CGAL::Color c = e->mark() ? ct : cf; ++ return c; ++ } ++ + void draw(Edge_iterator e) const { + // CGAL_NEF_TRACEN("drawing edge "<<*e); + Double_point p = e->source(), q = e->target(); +- CGAL::Color cf(CGAL_NEF3_MARKED_EDGE_COLOR), +- ct(CGAL_NEF3_UNMARKED_EDGE_COLOR); // more blue-ish +- CGAL::Color c = e->mark() ? ct : cf; ++ CGAL::Color c = getEdgeColor(e); + glLineWidth(5); + glColor3ub(c.red(),c.green(),c.blue()); + glBegin(GL_LINE_STRIP); +@@ -386,6 +398,14 @@ + glEnd(); + } + ++ virtual CGAL::Color getFacetColor(Halffacet_iterator f) const ++ { ++ CGAL::Color cf(CGAL_NEF3_MARKED_FACET_COLOR), ++ ct(CGAL_NEF3_UNMARKED_FACET_COLOR); // more blue-ish ++ CGAL::Color c = (f->mark() ? ct : cf); ++ return c; ++ } ++ + void draw(Halffacet_iterator f) const { + // CGAL_NEF_TRACEN("drawing facet "<<(f->debug(),"")); + GLUtesselator* tess_ = gluNewTess(); +@@ -403,9 +423,7 @@ + GLU_TESS_WINDING_POSITIVE); + + DFacet::Coord_const_iterator cit; +- CGAL::Color cf(CGAL_NEF3_MARKED_FACET_COLOR), +- ct(CGAL_NEF3_UNMARKED_FACET_COLOR); // more blue-ish +- CGAL::Color c = (f->mark() ? ct : cf); ++ CGAL::Color c = getFacetColor(f); + glColor3ub(c.red(),c.green(),c.blue()); + gluTessBeginPolygon(tess_,f->normal()); + // CGAL_NEF_TRACEN(" "); diff --git a/patches/CGAL-OGL_helper-tesscombine.patch b/patches/CGAL-OGL_helper-tesscombine.patch new file mode 100644 index 0000000..792e1da --- /dev/null +++ b/patches/CGAL-OGL_helper-tesscombine.patch @@ -0,0 +1,34 @@ +--- ../../libraries/install/include/CGAL/Nef_3/OGL_helper.h 2010-06-09 21:00:52.000000000 +0200 ++++ OGL_helper.h 2011-09-29 23:09:47.000000000 +0200 +@@ -243,6 +243,22 @@ + glVertex3dv(pc); + } + ++ inline void CGAL_GLU_TESS_CALLBACK combineCallback(GLdouble coords[3], GLvoid *[4], GLfloat [4], GLvoid **dataOut) ++ { static std::list pcache; ++ if (dataOut) { ++ GLdouble *n = new GLdouble[3]; ++ n[0] = coords[0]; ++ n[1] = coords[1]; ++ n[2] = coords[2]; ++ pcache.push_back(n); ++ *dataOut = n; ++ } else { ++ for (std::list::const_iterator i = pcache.begin(); i != pcache.end(); i++) ++ delete[] *i; ++ pcache.clear(); ++ } ++ } ++ + + enum { SNC_AXES}; + enum { SNC_BOUNDARY, SNC_SKELETON }; +@@ -376,6 +392,8 @@ + GLUtesselator* tess_ = gluNewTess(); + gluTessCallback(tess_, GLenum(GLU_TESS_VERTEX_DATA), + (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &vertexCallback); ++ gluTessCallback(tess_, GLenum(GLU_TESS_COMBINE), ++ (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &combineCallback); + gluTessCallback(tess_, GLenum(GLU_TESS_BEGIN), + (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &beginCallback); + gluTessCallback(tess_, GLenum(GLU_TESS_END), diff --git a/src/OGL_helper.h b/src/OGL_helper.h index 2764561..40a3e35 100644 --- a/src/OGL_helper.h +++ b/src/OGL_helper.h @@ -11,7 +11,7 @@ // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // -// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.7-branch/Nef_3/include/CGAL/Nef_3/OGL_helper.h $ +// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/trunk/Nef_3/include/CGAL/Nef_3/OGL_helper.h $ // $Id: OGL_helper.h 56667 2010-06-09 07:37:13Z sloriot $ // // @@ -246,19 +246,20 @@ namespace OGL { inline void CGAL_GLU_TESS_CALLBACK combineCallback(GLdouble coords[3], GLvoid *[4], GLfloat [4], GLvoid **dataOut) { static std::list pcache; if (dataOut) { - GLdouble *n = new GLdouble[3]; - n[0] = coords[0]; - n[1] = coords[1]; - n[2] = coords[2]; - pcache.push_back(n); - *dataOut = n; + GLdouble *n = new GLdouble[3]; + n[0] = coords[0]; + n[1] = coords[1]; + n[2] = coords[2]; + pcache.push_back(n); + *dataOut = n; } else { - for (std::list::const_iterator i = pcache.begin(); i != pcache.end(); i++) - delete[] *i; - pcache.clear(); + for (std::list::const_iterator i = pcache.begin(); i != pcache.end(); i++) + delete[] *i; + pcache.clear(); } } + enum { SNC_AXES}; enum { SNC_BOUNDARY, SNC_SKELETON }; -- cgit v0.10.1 From 6b0cad7557454fe39635123eb85a95302a6d06d0 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 02:42:34 +0200 Subject: Implemented string comparison for >, >=, <, <= operators diff --git a/src/value.cc b/src/value.cc index 53fd6dc..685bf81 100644 --- a/src/value.cc +++ b/src/value.cc @@ -193,6 +193,9 @@ Value Value::operator < (const Value &v) const if (this->type == NUMBER && v.type == NUMBER) { return Value(this->num < v.num); } + else if (this->type == STRING && v.type == STRING) { + return Value(this->text < v.text); + } return Value(); } @@ -201,6 +204,9 @@ Value Value::operator <= (const Value &v) const if (this->type == NUMBER && v.type == NUMBER) { return Value(this->num <= v.num); } + else if (this->type == STRING && v.type == STRING) { + return Value(this->text <= v.text); + } return Value(); } @@ -240,6 +246,9 @@ Value Value::operator >= (const Value &v) const if (this->type == NUMBER && v.type == NUMBER) { return Value(this->num >= v.num); } + else if (this->type == STRING && v.type == STRING) { + return Value(this->text >= v.text); + } return Value(); } @@ -248,6 +257,9 @@ Value Value::operator > (const Value &v) const if (this->type == NUMBER && v.type == NUMBER) { return Value(this->num > v.num); } + else if (this->type == STRING && v.type == STRING) { + return Value(this->text > v.text); + } return Value(); } -- cgit v0.10.1 From 27a7d6c115b0f94bb51489c1e3acf8f680a8d1f2 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 02:43:09 +0200 Subject: Added version() function diff --git a/src/func.cc b/src/func.cc index 52f04dd..b58a1b7 100644 --- a/src/func.cc +++ b/src/func.cc @@ -349,6 +349,14 @@ Value builtin_lookup(const Context *, const std::vector&, const std return Value(high_v * f + low_v * (1-f)); } +#define QUOTE(x__) # x__ +#define QUOTED(x__) QUOTE(x__) + +Value builtin_version(const Context *, const std::vector&, const std::vector &) +{ + return Value(std::string(QUOTED(OPENSCAD_VERSION))); +} + void initialize_builtin_functions() { builtin_functions["abs"] = new BuiltinFunction(&builtin_abs); @@ -373,6 +381,7 @@ void initialize_builtin_functions() builtin_functions["ln"] = new BuiltinFunction(&builtin_ln); builtin_functions["str"] = new BuiltinFunction(&builtin_str); builtin_functions["lookup"] = new BuiltinFunction(&builtin_lookup); + builtin_functions["version"] = new BuiltinFunction(&builtin_version); initialize_builtin_dxf_dim(); } -- cgit v0.10.1 From c407d6bbd12b9de8df44050b041d0849e8ab9f33 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 02:43:49 +0200 Subject: gmp was specified twice diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index c8eb349..f524d43 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -126,7 +126,7 @@ build_cgal() tar xzf CGAL-$version.tar.gz cd CGAL-$version # We build a static lib. Not really necessary, but it's well tested. - cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.dylib -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmp.dylib -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.dylib -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" -DBOOST_ROOT=$DEPLOYDIR + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.dylib -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.dylib -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" -DBOOST_ROOT=$DEPLOYDIR make -j4 make install } -- cgit v0.10.1 From e22f92c4073bb14a25b86bacc28f604177b0bf25 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 02:49:00 +0200 Subject: Added version() to function tests diff --git a/testdata/scad/minimal/allfunctions.scad b/testdata/scad/minimal/allfunctions.scad index e58bd07..c33b43c 100644 --- a/testdata/scad/minimal/allfunctions.scad +++ b/testdata/scad/minimal/allfunctions.scad @@ -22,3 +22,4 @@ a = str(); a = lookup(); a = dxf_dim(); a = dxf_cross(); +a = version(); -- cgit v0.10.1 From 7c334fe02f4a55ae006de6d68d1530432faabc88 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 02:49:17 +0200 Subject: Updated with latest changes diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 97af740..299a24d 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -9,6 +9,8 @@ o New import() statement reads the correct file format based on the filename ext o The color() statement now supports an alpha parameter, e.g. color(c=[1,0,0], alpha=0.4) o The color() statement now supports specifying colors as strings, e.g. color("Red") o if() and else() can now take any value type as parameter. false, 0, empty string and empty vector or illegal value type will evaluate as false, everything else as true. +o Strings can now be lexographically compared using the <, <=, >, >= operators +o The version() function will return the OpenSCAD version as a string, e.g. "2011.10" Bugfixes: o square() crashed if any of the dimensions were zero -- cgit v0.10.1 From ff915961b6fac11c535742857b5923514ce18e09 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 02:51:15 +0200 Subject: Updated with latest changes diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 299a24d..f8a10f0 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -16,6 +16,8 @@ Bugfixes: o square() crashed if any of the dimensions were zero o Flush Caches didn't flush cached USE'd modules o STL export should be a bit more robust +o Dropping a file into the editor under Windows didn't work (double C:/C:/ problem) + Deprecations: o dxf_linear_extrude() and dxf_rotate_extrude() are now deprecated. -- cgit v0.10.1 From bf3fb9634c44bcd28a4e2faede72052daa1f966c Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 03:11:28 +0200 Subject: Renamed some files and classnames for clarification diff --git a/openscad.pro b/openscad.pro index 6e79b29..765ff6b 100644 --- a/openscad.pro +++ b/openscad.pro @@ -139,8 +139,8 @@ HEADERS += src/renderer.h \ src/module.h \ src/node.h \ src/csgnode.h \ - src/dxflinextrudenode.h \ - src/dxfrotextrudenode.h \ + src/linearextrudenode.h \ + src/rotateextrudenode.h \ src/projectionnode.h \ src/cgaladvnode.h \ src/importnode.h \ @@ -197,8 +197,8 @@ SOURCES += src/openscad.cc \ src/dxftess-glu.cc \ src/dxftess-cgal.cc \ src/dxfdim.cc \ - src/dxflinextrude.cc \ - src/dxfrotextrude.cc \ + src/linearextrude.cc \ + src/rotateextrude.cc \ src/highlighter.cc \ src/printutils.cc \ src/Preferences.cc \ diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index b019ad5..7f62d0a 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -4,8 +4,8 @@ #include "polyset.h" #include "CGALEvaluator.h" #include "projectionnode.h" -#include "dxflinextrudenode.h" -#include "dxfrotextrudenode.h" +#include "linearextrudenode.h" +#include "rotateextrudenode.h" #include "cgaladvnode.h" #include "rendernode.h" #include "dxfdata.h" @@ -251,7 +251,7 @@ static void add_slice(PolySet *ps, const DxfData &dxf, DxfData::Path &path, doub } } -PolySet *PolySetCGALEvaluator::evaluatePolySet(const DxfLinearExtrudeNode &node) +PolySet *PolySetCGALEvaluator::evaluatePolySet(const LinearExtrudeNode &node) { DxfData *dxf; @@ -283,7 +283,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const DxfLinearExtrudeNode &node) return ps; } -PolySet *PolySetCGALEvaluator::extrudeDxfData(const DxfLinearExtrudeNode &node, DxfData &dxf) +PolySet *PolySetCGALEvaluator::extrudeDxfData(const LinearExtrudeNode &node, DxfData &dxf) { PolySet *ps = new PolySet(); ps->convexity = node.convexity; @@ -349,7 +349,7 @@ PolySet *PolySetCGALEvaluator::extrudeDxfData(const DxfLinearExtrudeNode &node, return ps; } -PolySet *PolySetCGALEvaluator::evaluatePolySet(const DxfRotateExtrudeNode &node) +PolySet *PolySetCGALEvaluator::evaluatePolySet(const RotateExtrudeNode &node) { DxfData *dxf; @@ -398,7 +398,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const RenderNode &node) return ps; } -PolySet *PolySetCGALEvaluator::rotateDxfData(const DxfRotateExtrudeNode &node, DxfData &dxf) +PolySet *PolySetCGALEvaluator::rotateDxfData(const RotateExtrudeNode &node, DxfData &dxf) { PolySet *ps = new PolySet(); ps->convexity = node.convexity; diff --git a/src/PolySetCGALEvaluator.h b/src/PolySetCGALEvaluator.h index 2aa5b13..dddcfc5 100644 --- a/src/PolySetCGALEvaluator.h +++ b/src/PolySetCGALEvaluator.h @@ -13,14 +13,14 @@ public: PolySetCGALEvaluator(class CGALEvaluator &cgalevaluator); virtual ~PolySetCGALEvaluator() { } virtual PolySet *evaluatePolySet(const ProjectionNode &node); - virtual PolySet *evaluatePolySet(const DxfLinearExtrudeNode &node); - virtual PolySet *evaluatePolySet(const DxfRotateExtrudeNode &node); + virtual PolySet *evaluatePolySet(const LinearExtrudeNode &node); + virtual PolySet *evaluatePolySet(const RotateExtrudeNode &node); virtual PolySet *evaluatePolySet(const CgaladvNode &node); virtual PolySet *evaluatePolySet(const RenderNode &node); protected: - PolySet *extrudeDxfData(const DxfLinearExtrudeNode &node, class DxfData &dxf); - PolySet *rotateDxfData(const DxfRotateExtrudeNode &node, class DxfData &dxf); + PolySet *extrudeDxfData(const LinearExtrudeNode &node, class DxfData &dxf); + PolySet *rotateDxfData(const RotateExtrudeNode &node, class DxfData &dxf); CGALEvaluator &cgalevaluator; }; diff --git a/src/PolySetEvaluator.h b/src/PolySetEvaluator.h index 833b079..8d7d1a8 100644 --- a/src/PolySetEvaluator.h +++ b/src/PolySetEvaluator.h @@ -16,8 +16,8 @@ public: virtual shared_ptr getPolySet(const class AbstractNode &, bool cache); virtual PolySet *evaluatePolySet(const class ProjectionNode &) { return NULL; } - virtual PolySet *evaluatePolySet(const class DxfLinearExtrudeNode &) { return NULL; } - virtual PolySet *evaluatePolySet(const class DxfRotateExtrudeNode &) { return NULL; } + virtual PolySet *evaluatePolySet(const class LinearExtrudeNode &) { return NULL; } + virtual PolySet *evaluatePolySet(const class RotateExtrudeNode &) { return NULL; } virtual PolySet *evaluatePolySet(const class CgaladvNode &) { return NULL; } virtual PolySet *evaluatePolySet(const class RenderNode &) { return NULL; } diff --git a/src/dxflinextrude.cc b/src/dxflinextrude.cc deleted file mode 100644 index 8bb246f..0000000 --- a/src/dxflinextrude.cc +++ /dev/null @@ -1,167 +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 "dxflinextrudenode.h" - -#include "module.h" -#include "context.h" -#include "printutils.h" -#include "builtin.h" -#include "dxfdata.h" -#include "dxftess.h" -#include "polyset.h" -#include "progress.h" -#include "visitor.h" -#include "PolySetEvaluator.h" -#include "openscad.h" // get_fragments_from_r() - -#include -#include -using namespace boost::assign; // bring 'operator+=()' into scope - -#include - -class DxfLinearExtrudeModule : public AbstractModule -{ -public: - DxfLinearExtrudeModule() { } - virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; -}; - -AbstractNode *DxfLinearExtrudeModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const -{ - DxfLinearExtrudeNode *node = new DxfLinearExtrudeNode(inst); - - std::vector argnames; - argnames += "file", "layer", "height", "origin", "scale", "center", "twist", "slices"; - std::vector argexpr; - - Context c(ctx); - c.args(argnames, argexpr, inst->argnames, inst->argvalues); - - node->fn = c.lookup_variable("$fn").num; - node->fs = c.lookup_variable("$fs").num; - node->fa = c.lookup_variable("$fa").num; - - Value file = c.lookup_variable("file"); - Value layer = c.lookup_variable("layer", true); - Value height = c.lookup_variable("height", true); - Value convexity = c.lookup_variable("convexity", true); - Value origin = c.lookup_variable("origin", true); - Value scale = c.lookup_variable("scale", true); - Value center = c.lookup_variable("center", true); - Value twist = c.lookup_variable("twist", true); - Value slices = c.lookup_variable("slices", true); - - if (!file.text.empty()) { - PRINTF("DEPRECATED: Support for reading files in linear_extrude will be removed in future releases. Use a child import() instead."); - node->filename = c.getAbsolutePath(file.text); - } - - node->layername = layer.text; - node->height = height.num; - node->convexity = (int)convexity.num; - origin.getv2(node->origin_x, node->origin_y); - node->scale = scale.num; - - if (center.type == Value::BOOL) - node->center = center.b; - - if (node->height <= 0) - node->height = 100; - - if (node->convexity <= 0) - node->convexity = 1; - - if (node->scale <= 0) - node->scale = 1; - - if (twist.type == Value::NUMBER) { - node->twist = twist.num; - if (slices.type == Value::NUMBER) { - node->slices = (int)slices.num; - } else { - node->slices = (int)fmax(2, fabs(get_fragments_from_r(node->height, - node->fn, node->fs, node->fa) * node->twist / 360)); - } - node->has_twist = true; - } - - if (node->filename.empty()) { - std::vector evaluatednodes = inst->evaluateChildren(); - node->children.insert(node->children.end(), evaluatednodes.begin(), evaluatednodes.end()); - } - - return node; -} - -void register_builtin_dxf_linear_extrude() -{ - builtin_modules["dxf_linear_extrude"] = new DxfLinearExtrudeModule(); - builtin_modules["linear_extrude"] = new DxfLinearExtrudeModule(); -} - -PolySet *DxfLinearExtrudeNode::evaluate_polyset(PolySetEvaluator *evaluator) const -{ - if (!evaluator) { - PRINTF("WARNING: No suitable PolySetEvaluator found for %s module!", this->name().c_str()); - return NULL; - } - - print_messages_push(); - - PolySet *ps = evaluator->evaluatePolySet(*this); - - print_messages_pop(); - - return ps; -} - -std::string DxfLinearExtrudeNode::toString() const -{ - std::stringstream stream; - - stream << this->name() << "("; - if (!this->filename.empty()) { // Ignore deprecated parameters if empty - stream << - "file = \"" << this->filename << "\", " - "cache = \"" << QFileInfo(QString::fromStdString(this->filename)) << "\", " - "layer = \"" << this->layername << "\", " - "origin = [ " << this->origin_x << " " << this->origin_y << " ], " - "scale = " << this->scale << ", "; - } - stream << - "height = " << std::dec << this->height << ", " - "center = " << (this->center?"true":"false") << ", " - "convexity = " << this->convexity; - - if (this->has_twist) { - stream << ", twist = " << this->twist << ", slices = " << this->slices; - } - stream << ", $fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; - - return stream.str(); -} diff --git a/src/dxflinextrudenode.h b/src/dxflinextrudenode.h deleted file mode 100644 index 360fd28..0000000 --- a/src/dxflinextrudenode.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef DXFLINEXTRUDENODE_H_ -#define DXFLINEXTRUDENODE_H_ - -#include "node.h" -#include "visitor.h" - -class DxfLinearExtrudeNode : public AbstractPolyNode -{ -public: - DxfLinearExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { - convexity = slices = 0; - fn = fs = fa = height = twist = 0; - origin_x = origin_y = scale = 0; - center = has_twist = false; - } - virtual Response accept(class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - virtual std::string name() const { return "linear_extrude"; } - - int convexity, slices; - double fn, fs, fa, height, twist; - double origin_x, origin_y, scale; - bool center, has_twist; - std::string filename, layername; - virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const; -}; - -#endif diff --git a/src/dxfrotextrude.cc b/src/dxfrotextrude.cc deleted file mode 100644 index 646b643..0000000 --- a/src/dxfrotextrude.cc +++ /dev/null @@ -1,137 +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 "dxfrotextrudenode.h" -#include "module.h" -#include "context.h" -#include "printutils.h" -#include "builtin.h" -#include "polyset.h" -#include "dxfdata.h" -#include "progress.h" -#include "visitor.h" -#include "PolySetEvaluator.h" -#include "openscad.h" // get_fragments_from_r() - -#include -#include -using namespace boost::assign; // bring 'operator+=()' into scope - -#include - -class DxfRotateExtrudeModule : public AbstractModule -{ -public: - DxfRotateExtrudeModule() { } - virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; -}; - -AbstractNode *DxfRotateExtrudeModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const -{ - DxfRotateExtrudeNode *node = new DxfRotateExtrudeNode(inst); - - std::vector argnames; - argnames += "file", "layer", "origin", "scale"; - std::vector argexpr; - - Context c(ctx); - c.args(argnames, argexpr, inst->argnames, inst->argvalues); - - node->fn = c.lookup_variable("$fn").num; - node->fs = c.lookup_variable("$fs").num; - node->fa = c.lookup_variable("$fa").num; - - Value file = c.lookup_variable("file"); - Value layer = c.lookup_variable("layer", true); - Value convexity = c.lookup_variable("convexity", true); - Value origin = c.lookup_variable("origin", true); - Value scale = c.lookup_variable("scale", true); - - if (!file.text.empty()) { - PRINTF("DEPRECATED: Support for reading files in rotate_extrude will be removed in future releases. Use a child import() instead."); - node->filename = c.getAbsolutePath(file.text); - } - - node->layername = layer.text; - node->convexity = (int)convexity.num; - origin.getv2(node->origin_x, node->origin_y); - node->scale = scale.num; - - if (node->convexity <= 0) - node->convexity = 1; - - if (node->scale <= 0) - node->scale = 1; - - if (node->filename.empty()) { - std::vector evaluatednodes = inst->evaluateChildren(); - node->children.insert(node->children.end(), evaluatednodes.begin(), evaluatednodes.end()); - } - - return node; -} - -void register_builtin_dxf_rotate_extrude() -{ - builtin_modules["dxf_rotate_extrude"] = new DxfRotateExtrudeModule(); - builtin_modules["rotate_extrude"] = new DxfRotateExtrudeModule(); -} - -PolySet *DxfRotateExtrudeNode::evaluate_polyset(PolySetEvaluator *evaluator) const -{ - if (!evaluator) { - PRINTF("WARNING: No suitable PolySetEvaluator found for %s module!", this->name().c_str()); - return NULL; - } - - print_messages_push(); - - PolySet *ps = evaluator->evaluatePolySet(*this); - - print_messages_pop(); - - return ps; -} - -std::string DxfRotateExtrudeNode::toString() const -{ - std::stringstream stream; - - stream << this->name() << "("; - if (!this->filename.empty()) { // Ignore deprecated parameters if empty - stream << - "file = \"" << this->filename << "\", " - "cache = \"" << QFileInfo(QString::fromStdString(this->filename)) << "\", " - "layer = \"" << this->layername << "\", " - "origin = [ " << std::dec << this->origin_x << " " << this->origin_y << " ], " - "scale = " << this->scale << ", "; - } - stream << - "convexity = " << this->convexity << ", " - "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; - - return stream.str(); -} diff --git a/src/dxfrotextrudenode.h b/src/dxfrotextrudenode.h deleted file mode 100644 index e0ade82..0000000 --- a/src/dxfrotextrudenode.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef DXFROTEXTRUDENODE_H_ -#define DXFROTEXTRUDENODE_H_ - -#include "node.h" -#include "visitor.h" - -class DxfRotateExtrudeNode : public AbstractPolyNode -{ -public: - DxfRotateExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { - convexity = 0; - fn = fs = fa = 0; - origin_x = origin_y = scale = 0; - } - virtual Response accept(class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - virtual std::string name() const { return "rotate_extrude"; } - - int convexity; - double fn, fs, fa; - double origin_x, origin_y, scale; - std::string filename, layername; - virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const; -}; - -#endif diff --git a/src/linearextrude.cc b/src/linearextrude.cc new file mode 100644 index 0000000..4ce87db --- /dev/null +++ b/src/linearextrude.cc @@ -0,0 +1,167 @@ +/* + * 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 "linearextrudenode.h" + +#include "module.h" +#include "context.h" +#include "printutils.h" +#include "builtin.h" +#include "dxfdata.h" +#include "dxftess.h" +#include "polyset.h" +#include "progress.h" +#include "visitor.h" +#include "PolySetEvaluator.h" +#include "openscad.h" // get_fragments_from_r() + +#include +#include +using namespace boost::assign; // bring 'operator+=()' into scope + +#include + +class LinearExtrudeModule : public AbstractModule +{ +public: + LinearExtrudeModule() { } + virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; +}; + +AbstractNode *LinearExtrudeModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const +{ + LinearExtrudeNode *node = new LinearExtrudeNode(inst); + + std::vector argnames; + argnames += "file", "layer", "height", "origin", "scale", "center", "twist", "slices"; + std::vector argexpr; + + Context c(ctx); + c.args(argnames, argexpr, inst->argnames, inst->argvalues); + + node->fn = c.lookup_variable("$fn").num; + node->fs = c.lookup_variable("$fs").num; + node->fa = c.lookup_variable("$fa").num; + + Value file = c.lookup_variable("file"); + Value layer = c.lookup_variable("layer", true); + Value height = c.lookup_variable("height", true); + Value convexity = c.lookup_variable("convexity", true); + Value origin = c.lookup_variable("origin", true); + Value scale = c.lookup_variable("scale", true); + Value center = c.lookup_variable("center", true); + Value twist = c.lookup_variable("twist", true); + Value slices = c.lookup_variable("slices", true); + + if (!file.text.empty()) { + PRINTF("DEPRECATED: Support for reading files in linear_extrude will be removed in future releases. Use a child import() instead."); + node->filename = c.getAbsolutePath(file.text); + } + + node->layername = layer.text; + node->height = height.num; + node->convexity = (int)convexity.num; + origin.getv2(node->origin_x, node->origin_y); + node->scale = scale.num; + + if (center.type == Value::BOOL) + node->center = center.b; + + if (node->height <= 0) + node->height = 100; + + if (node->convexity <= 0) + node->convexity = 1; + + if (node->scale <= 0) + node->scale = 1; + + if (twist.type == Value::NUMBER) { + node->twist = twist.num; + if (slices.type == Value::NUMBER) { + node->slices = (int)slices.num; + } else { + node->slices = (int)fmax(2, fabs(get_fragments_from_r(node->height, + node->fn, node->fs, node->fa) * node->twist / 360)); + } + node->has_twist = true; + } + + if (node->filename.empty()) { + std::vector evaluatednodes = inst->evaluateChildren(); + node->children.insert(node->children.end(), evaluatednodes.begin(), evaluatednodes.end()); + } + + return node; +} + +void register_builtin_dxf_linear_extrude() +{ + builtin_modules["dxf_linear_extrude"] = new LinearExtrudeModule(); + builtin_modules["linear_extrude"] = new LinearExtrudeModule(); +} + +PolySet *LinearExtrudeNode::evaluate_polyset(PolySetEvaluator *evaluator) const +{ + if (!evaluator) { + PRINTF("WARNING: No suitable PolySetEvaluator found for %s module!", this->name().c_str()); + return NULL; + } + + print_messages_push(); + + PolySet *ps = evaluator->evaluatePolySet(*this); + + print_messages_pop(); + + return ps; +} + +std::string LinearExtrudeNode::toString() const +{ + std::stringstream stream; + + stream << this->name() << "("; + if (!this->filename.empty()) { // Ignore deprecated parameters if empty + stream << + "file = \"" << this->filename << "\", " + "cache = \"" << QFileInfo(QString::fromStdString(this->filename)) << "\", " + "layer = \"" << this->layername << "\", " + "origin = [ " << this->origin_x << " " << this->origin_y << " ], " + "scale = " << this->scale << ", "; + } + stream << + "height = " << std::dec << this->height << ", " + "center = " << (this->center?"true":"false") << ", " + "convexity = " << this->convexity; + + if (this->has_twist) { + stream << ", twist = " << this->twist << ", slices = " << this->slices; + } + stream << ", $fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; + + return stream.str(); +} diff --git a/src/linearextrudenode.h b/src/linearextrudenode.h new file mode 100644 index 0000000..503f1bd --- /dev/null +++ b/src/linearextrudenode.h @@ -0,0 +1,30 @@ +#ifndef LINEAREXTRUDENODE_H_ +#define LINEAREXTRUDENODE_H_ + +#include "node.h" +#include "visitor.h" + +class LinearExtrudeNode : public AbstractPolyNode +{ +public: + LinearExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { + convexity = slices = 0; + fn = fs = fa = height = twist = 0; + origin_x = origin_y = scale = 0; + center = has_twist = false; + } + virtual Response accept(class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + virtual std::string name() const { return "linear_extrude"; } + + int convexity, slices; + double fn, fs, fa, height, twist; + double origin_x, origin_y, scale; + bool center, has_twist; + std::string filename, layername; + virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const; +}; + +#endif diff --git a/src/rotateextrude.cc b/src/rotateextrude.cc new file mode 100644 index 0000000..3a6eb55 --- /dev/null +++ b/src/rotateextrude.cc @@ -0,0 +1,137 @@ +/* + * 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 "rotateextrudenode.h" +#include "module.h" +#include "context.h" +#include "printutils.h" +#include "builtin.h" +#include "polyset.h" +#include "dxfdata.h" +#include "progress.h" +#include "visitor.h" +#include "PolySetEvaluator.h" +#include "openscad.h" // get_fragments_from_r() + +#include +#include +using namespace boost::assign; // bring 'operator+=()' into scope + +#include + +class RotateExtrudeModule : public AbstractModule +{ +public: + RotateExtrudeModule() { } + virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; +}; + +AbstractNode *RotateExtrudeModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const +{ + RotateExtrudeNode *node = new RotateExtrudeNode(inst); + + std::vector argnames; + argnames += "file", "layer", "origin", "scale"; + std::vector argexpr; + + Context c(ctx); + c.args(argnames, argexpr, inst->argnames, inst->argvalues); + + node->fn = c.lookup_variable("$fn").num; + node->fs = c.lookup_variable("$fs").num; + node->fa = c.lookup_variable("$fa").num; + + Value file = c.lookup_variable("file"); + Value layer = c.lookup_variable("layer", true); + Value convexity = c.lookup_variable("convexity", true); + Value origin = c.lookup_variable("origin", true); + Value scale = c.lookup_variable("scale", true); + + if (!file.text.empty()) { + PRINTF("DEPRECATED: Support for reading files in rotate_extrude will be removed in future releases. Use a child import() instead."); + node->filename = c.getAbsolutePath(file.text); + } + + node->layername = layer.text; + node->convexity = (int)convexity.num; + origin.getv2(node->origin_x, node->origin_y); + node->scale = scale.num; + + if (node->convexity <= 0) + node->convexity = 1; + + if (node->scale <= 0) + node->scale = 1; + + if (node->filename.empty()) { + std::vector evaluatednodes = inst->evaluateChildren(); + node->children.insert(node->children.end(), evaluatednodes.begin(), evaluatednodes.end()); + } + + return node; +} + +void register_builtin_dxf_rotate_extrude() +{ + builtin_modules["dxf_rotate_extrude"] = new RotateExtrudeModule(); + builtin_modules["rotate_extrude"] = new RotateExtrudeModule(); +} + +PolySet *RotateExtrudeNode::evaluate_polyset(PolySetEvaluator *evaluator) const +{ + if (!evaluator) { + PRINTF("WARNING: No suitable PolySetEvaluator found for %s module!", this->name().c_str()); + return NULL; + } + + print_messages_push(); + + PolySet *ps = evaluator->evaluatePolySet(*this); + + print_messages_pop(); + + return ps; +} + +std::string RotateExtrudeNode::toString() const +{ + std::stringstream stream; + + stream << this->name() << "("; + if (!this->filename.empty()) { // Ignore deprecated parameters if empty + stream << + "file = \"" << this->filename << "\", " + "cache = \"" << QFileInfo(QString::fromStdString(this->filename)) << "\", " + "layer = \"" << this->layername << "\", " + "origin = [ " << std::dec << this->origin_x << " " << this->origin_y << " ], " + "scale = " << this->scale << ", "; + } + stream << + "convexity = " << this->convexity << ", " + "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; + + return stream.str(); +} diff --git a/src/rotateextrudenode.h b/src/rotateextrudenode.h new file mode 100644 index 0000000..613d44b --- /dev/null +++ b/src/rotateextrudenode.h @@ -0,0 +1,28 @@ +#ifndef ROTATEEXTRUDENODE_H_ +#define ROTATEEXTRUDENODE_H_ + +#include "node.h" +#include "visitor.h" + +class RotateExtrudeNode : public AbstractPolyNode +{ +public: + RotateExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { + convexity = 0; + fn = fs = fa = 0; + origin_x = origin_y = scale = 0; + } + virtual Response accept(class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + virtual std::string name() const { return "rotate_extrude"; } + + int convexity; + double fn, fs, fa; + double origin_x, origin_y, scale; + std::string filename, layername; + virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const; +}; + +#endif diff --git a/src/visitor.h b/src/visitor.h index f4846b8..fe350f8 100644 --- a/src/visitor.h +++ b/src/visitor.h @@ -22,10 +22,10 @@ public: virtual Response visit(class State &state, const class CsgNode &node) { return visit(state, (const class AbstractNode &)node); } - virtual Response visit(class State &state, const class DxfLinearExtrudeNode &node) { + virtual Response visit(class State &state, const class LinearExtrudeNode &node) { return visit(state, (const class AbstractPolyNode &)node); } - virtual Response visit(class State &state, const class DxfRotateExtrudeNode &node) { + virtual Response visit(class State &state, const class RotateExtrudeNode &node) { return visit(state, (const class AbstractPolyNode &)node); } virtual Response visit(class State &state, const class ImportNode &node) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b92ee22..4b6a9dd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -103,8 +103,8 @@ set(COMMON_SOURCES ../src/dxfdata.cc ../src/dxftess.cc ../src/dxfdim.cc - ../src/dxflinextrude.cc - ../src/dxfrotextrude.cc + ../src/linearextrude.cc + ../src/rotateextrude.cc ../src/printutils.cc ../src/progress.cc ../src/nodedumper.cc -- cgit v0.10.1 From e7001dd4592735e35779d26a77b4a7da69d547c0 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 03:24:49 +0200 Subject: Reverted intersection with inside-out polyhedron - test belongs in the polyehdron test diff --git a/testdata/scad/features/intersection-tests.scad b/testdata/scad/features/intersection-tests.scad index bc58233..e53f3c9 100644 --- a/testdata/scad/features/intersection-tests.scad +++ b/testdata/scad/features/intersection-tests.scad @@ -39,11 +39,3 @@ translate([-12,12,0]) intersection() { cube([10,10,10], center=true); translate([0,-9.99,-9.99]) cube([10,10,10], center=true); } - -translate([-12,0,0]) intersection() { - scale(10/sqrt(2)) - polyhedron(points = [[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]], - triangles = [[0,2,4],[0,5,2],[0,4,3],[0,3,5],[1,4,2],[1,2,5],[1,3,4], [1,5,3]], - convexity = 1); - translate([0,0,10]) cube([20,20,20], center=true); -} diff --git a/tests/regression/cgalpngtest/intersection-tests-expected.png b/tests/regression/cgalpngtest/intersection-tests-expected.png index 1fd38e7..6d004b0 100644 Binary files a/tests/regression/cgalpngtest/intersection-tests-expected.png and b/tests/regression/cgalpngtest/intersection-tests-expected.png differ -- cgit v0.10.1 From f3b3eaac687f0ba9a2a9b9382e7b605f106bf2b0 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 30 Sep 2011 03:25:42 +0200 Subject: Added polyhedron-tests diff --git a/testdata/scad/features/polyhedron-tests.scad b/testdata/scad/features/polyhedron-tests.scad new file mode 100644 index 0000000..690d962 --- /dev/null +++ b/testdata/scad/features/polyhedron-tests.scad @@ -0,0 +1,20 @@ +module polyhedrons() { + polyhedron(points = [[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]], + triangles = [[0,4,2],[0,2,5],[0,3,4],[0,5,3],[1,2,4],[1,5,2],[1,4,3], [1,3,5]]); + + // One face flipped + translate([2,0,0]) + polyhedron(points = [[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]], + triangles = [[0,4,2],[0,2,5],[0,3,4],[0,5,3],[1,2,4],[1,5,2],[1,3,4], [1,3,5]]); + + // All faces flipped + translate([4,0,0]) + polyhedron(points = [[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]], + triangles = [[0,2,4],[0,5,2],[0,4,3],[0,3,5],[1,4,2],[1,2,5],[1,3,4], [1,5,3]]); +} + +polyhedrons(); +translate([0,2,0]) difference() { + polyhedrons(); + translate([2,0,2]) cube([8,3,3], center=true); +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4b6a9dd..606878a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -213,6 +213,7 @@ LIST(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/cube-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/features/sphere-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/features/cylinder-tests.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/features/polyhedron-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/features/union-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/features/difference-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/features/intersection-tests.scad diff --git a/tests/regression/cgalpngtest/polyhedron-tests-expected.png b/tests/regression/cgalpngtest/polyhedron-tests-expected.png new file mode 100644 index 0000000..c80990f Binary files /dev/null and b/tests/regression/cgalpngtest/polyhedron-tests-expected.png differ diff --git a/tests/regression/opencsgtest/polyhedron-tests-expected.png b/tests/regression/opencsgtest/polyhedron-tests-expected.png new file mode 100644 index 0000000..0740f1a Binary files /dev/null and b/tests/regression/opencsgtest/polyhedron-tests-expected.png differ -- cgit v0.10.1