Skip to content

Commit

Permalink
Merge pull request openscad#1551 from openscad/c++11
Browse files Browse the repository at this point in the history
Require C++11
  • Loading branch information
kintel committed Jan 27, 2016
2 parents 87ae5b2 + c40cb9a commit 176a1e8
Show file tree
Hide file tree
Showing 108 changed files with 546 additions and 637 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ libraries from aptitude. If you're using Mac, or an older Linux/BSD, there
are build scripts that download and compile the libraries from source.
Follow the instructions for the platform you're compiling on below.

* [Qt4 (4.4 - 5.4)](http://www.qt.nokia.com/)
* [QScintilla2 (2.7 - 2.8)](http://www.riverbankcomputing.co.uk/software/qscintilla/)
* [CGAL (3.6 - 4.5)](http://www.cgal.org/)
* A C++ compiler supporting C++11
* [Qt4 (4.4 ->)](http://www.qt.nokia.com/)
* [QScintilla2 (2.7 ->)](http://www.riverbankcomputing.co.uk/software/qscintilla/)
* [CGAL (3.6 ->)](http://www.cgal.org/)
* [GMP (5.x)](http://www.gmplib.org/)
* [MPFR (3.x)](http://www.mpfr.org/)
* [cmake (2.8 - 3.0, required by CGAL and the test framework)](http://www.cmake.org/)
* [boost (1.35 - 1.57)](http://www.boost.org/)
* [cmake (2.8 ->, required by CGAL and the test framework)](http://www.cmake.org/)
* [boost (1.35 ->)](http://www.boost.org/)
* [OpenCSG (1.3.2 ->)](http://www.opencsg.org/)
* [GLEW (1.5.4 ->)](http://glew.sourceforge.net/)
* [Eigen (3.x)](http://eigen.tuxfamily.org/)
Expand Down Expand Up @@ -130,7 +131,7 @@ Prerequisites:
Install Dependencies:

Run the script that sets up the environment variables:
```source setenv_mac-qt5.sh```
```source setenv_mac.sh```

Then run the script to compile all the dependencies:
```./scripts/macosx-build-dependencies.sh```
Expand Down
16 changes: 15 additions & 1 deletion c++11.pri
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,22 @@ macx {
}

c++11 {
QMAKE_CXXFLAGS += -std=c++11
# -std=c++11 is only available in gcc>=4.7
*g++*: QMAKE_CXXFLAGS += -std=c++0x
else: QMAKE_CXXFLAGS += -std=c++11
message("Using C++11")

*clang*: {
# 3rd party libraries will probably violate this for a long time
CXX11_SUPPRESS_WARNINGS += -Wno-inconsistent-missing-override
# boost/algorithm/string.hpp does this
CXX11_SUPPRESS_WARNINGS += -Wno-unused-local-typedef
# CGAL
CXX11_SUPPRESS_WARNINGS += -Wno-deprecated-register

QMAKE_CXXFLAGS_WARN_ON += $$CXX11_SUPPRESS_WARNINGS
QMAKE_OBJECTIVE_CFLAGS_WARN_ON += $$CXX11_SUPPRESS_WARNINGS
}
}
else {
*clang* {
Expand Down
12 changes: 6 additions & 6 deletions openscad.pro
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ CONFIG(skip-version-check) {

# Application configuration
macx:CONFIG += mdi
#CONFIG += c++11
CONFIG += c++11
CONFIG += cgal
CONFIG += opencsg
CONFIG += glew
Expand Down Expand Up @@ -266,6 +266,7 @@ HEADERS += src/typedefs.h \
src/function.h \
src/exceptions.h \
src/grid.h \
src/hash.h \
src/highlighter.h \
src/localscope.h \
src/module.h \
Expand Down Expand Up @@ -304,10 +305,9 @@ HEADERS += src/typedefs.h \
src/GeometryCache.h \
src/GeometryEvaluator.h \
src/Tree.h \
src/DrawingCallback.h \
src/FreetypeRenderer.h \
src/FontCache.h \
src/mathc99.h \
src/DrawingCallback.h \
src/FreetypeRenderer.h \
src/FontCache.h \
src/memory.h \
src/linalg.h \
src/Camera.h \
Expand All @@ -334,7 +334,6 @@ src/FontCache.h \

SOURCES += src/version_check.cc \
src/ProgressWidget.cc \
src/mathc99.cc \
src/linalg.cc \
src/Camera.cc \
src/handle_dep.cc \
Expand Down Expand Up @@ -404,6 +403,7 @@ SOURCES += src/version_check.cc \
src/AutoUpdater.cc \
\
src/grid.cc \
src/hash.cc \
src/builtin.cc \
src/calc.cc \
src/export.cc \
Expand Down
11 changes: 11 additions & 0 deletions setenv_mac-c++11.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export OPENSCAD_LIBRARIES=$PWD/../libraries/install-c++11
export DYLD_LIBRARY_PATH=$OPENSCAD_LIBRARIES/lib
export DYLD_FRAMEWORK_PATH=$OPENSCAD_LIBRARIES/lib

# Our own Qt
export PATH=$OPENSCAD_LIBRARIES/bin:$PATH
unset QMAKESPEC

# ccache:
export PATH=/opt/local/libexec/ccache:$PATH
export CCACHE_BASEDIR=$PWD/..
File renamed without changes.
4 changes: 2 additions & 2 deletions src/AppleEvents.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <AppleEvents.h>
#include "AppleEvents.h"
#include <MacTypes.h>
#include <CoreServices/CoreServices.h>
#include <QApplication>
Expand All @@ -12,7 +12,7 @@ OSErr eventHandler(const AppleEvent *, AppleEvent *, SRefCon )
{
// FIXME: Ugly hack; just using the first MainWindow we can find
MainWindow *mainwin = NULL;
foreach (QWidget *w, QApplication::topLevelWidgets()) {
for (auto &w : QApplication::topLevelWidgets()) {
mainwin = qobject_cast<MainWindow*>(w);
if (mainwin) break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CGAL_Nef_polyhedron.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ PolySet *CGAL_Nef_polyhedron::convertToPolyset() const
}
#endif

void CGAL_Nef_polyhedron::resize(Vector3d newsize,
void CGAL_Nef_polyhedron::resize(const Vector3d &newsize,
const Eigen::Matrix<bool,3,1> &autosize)
{
// Based on resize() in Giles Bathgate's RapCAD (but not exactly)
Expand Down
2 changes: 1 addition & 1 deletion src/CGAL_Nef_polyhedron.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CGAL_Nef_polyhedron : public Geometry
// FIXME: Deprecated by CGALUtils::createPolySetFromNefPolyhedron3
// class PolySet *convertToPolyset() const;
void transform( const Transform3d &matrix );
void resize(Vector3d newsize, const Eigen::Matrix<bool,3,1> &autosize);
void resize(const Vector3d &newsize, const Eigen::Matrix<bool,3,1> &autosize);

shared_ptr<CGAL_Nef_polyhedron3> p3;
};
5 changes: 2 additions & 3 deletions src/CSGTreeEvaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <iostream>
#include <assert.h>
#include <cstddef>
#include <boost/foreach.hpp>

/*!
\class CSGTreeEvaluator
Expand Down Expand Up @@ -48,7 +47,7 @@ shared_ptr<CSGNode> CSGTreeEvaluator::buildCSGTree(const AbstractNode &node)

void CSGTreeEvaluator::applyBackgroundAndHighlight(State &state, const AbstractNode &node)
{
BOOST_FOREACH(const AbstractNode *chnode, this->visitedchildren[node.index()]) {
for(const auto &chnode : this->visitedchildren[node.index()]) {
shared_ptr<CSGNode> t(this->stored_term[chnode->index()]);
this->stored_term.erase(chnode->index());
if (t) {
Expand All @@ -62,7 +61,7 @@ void CSGTreeEvaluator::applyToChildren(State &state, const AbstractNode &node, O
{
shared_ptr<CSGNode> t1;
const ModuleInstantiation *t1_modinst;
BOOST_FOREACH(const AbstractNode *chnode, this->visitedchildren[node.index()]) {
for(const auto &chnode : this->visitedchildren[node.index()]) {
shared_ptr<CSGNode> t2(this->stored_term[chnode->index()]);
const ModuleInstantiation *t2_modinst = chnode->modinst;
this->stored_term.erase(chnode->index());
Expand Down
10 changes: 5 additions & 5 deletions src/CSGTreeEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class CSGTreeEvaluator : public Visitor
const shared_ptr<CSGNode> &getRootNode() const {
return this->rootNode;
}
const std::vector<shared_ptr<CSGNode> > &getHighlightNodes() const {
const std::vector<shared_ptr<CSGNode>> &getHighlightNodes() const {
return this->highlightNodes;
}
const std::vector<shared_ptr<CSGNode> > &getBackgroundNodes() const {
const std::vector<shared_ptr<CSGNode>> &getBackgroundNodes() const {
return this->backgroundNodes;
}

Expand All @@ -54,7 +54,7 @@ class CSGTreeEvaluator : public Visitor
const Tree &tree;
class GeometryEvaluator *geomevaluator;
shared_ptr<CSGNode> rootNode;
std::vector<shared_ptr<CSGNode> > highlightNodes;
std::vector<shared_ptr<CSGNode> > backgroundNodes;
std::map<int, shared_ptr<CSGNode> > stored_term; // The term evaluated from each node index
std::vector<shared_ptr<CSGNode>> highlightNodes;
std::vector<shared_ptr<CSGNode>> backgroundNodes;
std::map<int, shared_ptr<CSGNode>> stored_term; // The term evaluated from each node index
};
2 changes: 1 addition & 1 deletion src/CsgInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CsgInfo
const AbstractNode *root_node = tree.root();
GeometryEvaluator geomevaluator(tree);
CSGTreeEvaluator evaluator(tree, &geomevaluator);
boost::shared_ptr<CSGNode> csgRoot = evaluator.buildCSGTree(*root_node);
shared_ptr<CSGNode> csgRoot = evaluator.buildCSGTree(*root_node);
std::vector<shared_ptr<CSGNode> > highlightNodes = evaluator.getHighlightNodes();
std::vector<shared_ptr<CSGNode> > backgroundNodes = evaluator.getBackgroundNodes();

Expand Down
14 changes: 7 additions & 7 deletions src/DrawingCallback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "Polygon2d.h"
#include "DrawingCallback.h"

DrawingCallback::DrawingCallback(unsigned long fn) : fn(fn),
pen(Vector2d(0, 0)), offset(Vector2d(0, 0)), advance(Vector2d(0, 0))
DrawingCallback::DrawingCallback(unsigned long fn) :
pen(Vector2d(0, 0)), offset(Vector2d(0, 0)), advance(Vector2d(0, 0)), fn(fn)
{
}

Expand Down Expand Up @@ -74,12 +74,12 @@ void DrawingCallback::add_glyph_advance(double advance_x, double advance_y)
advance += Vector2d(advance_x, advance_y);
}

void DrawingCallback::add_vertex(Vector2d v)
void DrawingCallback::add_vertex(const Vector2d &v)
{
this->outline.vertices.push_back(v + offset + advance);
}

void DrawingCallback::move_to(Vector2d to)
void DrawingCallback::move_to(const Vector2d &to)
{
if (this->outline.vertices.size() > 0) {
this->polygon->addOutline(this->outline);
Expand All @@ -89,14 +89,14 @@ void DrawingCallback::move_to(Vector2d to)
pen = to;
}

void DrawingCallback::line_to(Vector2d to)
void DrawingCallback::line_to(const Vector2d &to)
{
add_vertex(to);
pen = to;
}

// Quadric Bezier curve
void DrawingCallback::curve_to(Vector2d c1, Vector2d to)
void DrawingCallback::curve_to(const Vector2d &c1, const Vector2d &to)
{
for (unsigned long idx = 1;idx <= fn;idx++) {
const double a = idx * (1.0 / (double)fn);
Expand All @@ -108,7 +108,7 @@ void DrawingCallback::curve_to(Vector2d c1, Vector2d to)
}

// Cubic Bezier curve
void DrawingCallback::curve_to(Vector2d c1, Vector2d c2, Vector2d to)
void DrawingCallback::curve_to(const Vector2d &c1, const Vector2d &c2, const Vector2d &to)
{
for (unsigned long idx = 1;idx <= fn;idx++) {
const double a = idx * (1.0 / (double)fn);
Expand Down
12 changes: 6 additions & 6 deletions src/DrawingCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ class DrawingCallback {
void add_glyph_advance(double advance_x, double advance_y);
std::vector<const Geometry *> get_result();

void move_to(Vector2d to);
void line_to(Vector2d to);
void curve_to(Vector2d c1, Vector2d to);
void curve_to(Vector2d c1, Vector2d c2, Vector2d to);
void move_to(const Vector2d &to);
void line_to(const Vector2d &to);
void curve_to(const Vector2d &c1, const Vector2d &to);
void curve_to(const Vector2d &c1, const Vector2d &c2, const Vector2d &to);
private:
unsigned long fn;
Vector2d pen;
Vector2d offset;
Vector2d advance;
unsigned long fn;

Outline2d outline;
class Polygon2d *polygon;
std::vector<const class Geometry *> polygons;

void add_vertex(Vector2d v);
void add_vertex(const Vector2d &v);
};
1 change: 0 additions & 1 deletion src/FontCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#include <iostream>

#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>

Expand Down
8 changes: 4 additions & 4 deletions src/GLView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "stdio.h"
#include "colormap.h"
#include "rendersettings.h"
#include "mathc99.h"
#include "printutils.h"
#include "renderer.h"
#include <cmath>

#ifdef _WIN32
#include <GL/wglew.h>
Expand Down Expand Up @@ -419,15 +419,15 @@ void GLView::showSmallaxes(const Color4f &col)

GLdouble xlabel_x, xlabel_y, xlabel_z;
gluProject(12*dpi, 0, 0, mat_model, mat_proj, viewport, &xlabel_x, &xlabel_y, &xlabel_z);
xlabel_x = round(xlabel_x); xlabel_y = round(xlabel_y);
xlabel_x = std::round(xlabel_x); xlabel_y = std::round(xlabel_y);

GLdouble ylabel_x, ylabel_y, ylabel_z;
gluProject(0, 12*dpi, 0, mat_model, mat_proj, viewport, &ylabel_x, &ylabel_y, &ylabel_z);
ylabel_x = round(ylabel_x); ylabel_y = round(ylabel_y);
ylabel_x = std::round(ylabel_x); ylabel_y = std::round(ylabel_y);

GLdouble zlabel_x, zlabel_y, zlabel_z;
gluProject(0, 0, 12*dpi, mat_model, mat_proj, viewport, &zlabel_x, &zlabel_y, &zlabel_z);
zlabel_x = round(zlabel_x); zlabel_y = round(zlabel_y);
zlabel_x = std::round(zlabel_x); zlabel_y = std::round(zlabel_y);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
Expand Down
3 changes: 0 additions & 3 deletions src/GLView.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ Some actions (showCrossHairs) only work properly on Gimbal Camera.
#include <Eigen/Core>
#include <Eigen/Geometry>
#include <string>
#ifndef _MSC_VER
#include <stdint.h>
#endif
#include "system-gl.h"
#include <iostream>
#include "Camera.h"
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Geometry
{
public:
typedef std::pair<const class AbstractNode *, shared_ptr<const Geometry> > GeometryItem;
typedef std::pair<const class AbstractNode *, shared_ptr<const Geometry>> GeometryItem;
typedef std::list<GeometryItem> Geometries;

Geometry() : convexity(1) {}
Expand Down
Loading

0 comments on commit 176a1e8

Please sign in to comment.