Merge pull request #1551 from openscad/c++11

Require C++11
This commit is contained in:
Marius Kintel 2016-01-27 11:29:33 -05:00
commit 176a1e8736
108 changed files with 546 additions and 637 deletions

View file

@ -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/)
@ -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```

View file

@ -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* {

View file

@ -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
@ -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 \
@ -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 \
@ -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 \
@ -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 \

11
setenv_mac-c++11.sh Normal file
View file

@ -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/..

View file

@ -1,4 +1,4 @@
#include <AppleEvents.h>
#include "AppleEvents.h"
#include <MacTypes.h>
#include <CoreServices/CoreServices.h>
#include <QApplication>
@ -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;
}

View file

@ -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)

View file

@ -30,7 +30,7 @@ public:
// 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;
};

View file

@ -20,7 +20,6 @@
#include <iostream>
#include <assert.h>
#include <cstddef>
#include <boost/foreach.hpp>
/*!
\class CSGTreeEvaluator
@ -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) {
@ -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());

View file

@ -30,10 +30,10 @@ public:
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;
}
@ -54,7 +54,7 @@ protected:
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
};

View file

@ -23,7 +23,7 @@ public:
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();

View file

@ -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)
{
}
@ -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);
@ -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);
@ -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);

View file

@ -41,19 +41,19 @@ public:
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);
};

View file

@ -26,7 +26,6 @@
#include <iostream>
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>

View file

@ -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>
@ -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();

View file

@ -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"

View file

@ -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) {}

View file

@ -28,7 +28,6 @@
#include "dxfdata.h"
#include <algorithm>
#include <boost/foreach.hpp>
#include <CGAL/convex_hull_2.h>
#include <CGAL/Point_2.h>
@ -81,7 +80,7 @@ shared_ptr<const Geometry> GeometryEvaluator::evaluateGeometry(const AbstractNod
GeometryEvaluator::ResultObject GeometryEvaluator::applyToChildren(const AbstractNode &node, OpenSCADOperator op)
{
unsigned int dim = 0;
BOOST_FOREACH(const Geometry::GeometryItem &item, this->visitedchildren[node.index()]) {
for(const auto &item : this->visitedchildren[node.index()]) {
if (!item.first->modinst->isBackground() && item.second) {
if (!dim) dim = item.second->getDimension();
else if (dim != item.second->getDimension()) {
@ -125,7 +124,7 @@ GeometryEvaluator::ResultObject GeometryEvaluator::applyToChildren3D(const Abstr
if (op == OPENSCAD_MINKOWSKI) {
Geometry::Geometries actualchildren;
BOOST_FOREACH(const Geometry::GeometryItem &item, children) {
for(const auto &item : children) {
if (!item.second->isEmpty()) actualchildren.push_back(item);
}
if (actualchildren.empty()) return ResultObject();
@ -151,12 +150,12 @@ Polygon2d *GeometryEvaluator::applyHull2D(const AbstractNode &node)
std::vector<const Polygon2d *> children = collectChildren2D(node);
Polygon2d *geometry = new Polygon2d();
typedef CGAL::Point_2<CGAL::Cartesian<double> > CGALPoint2;
typedef CGAL::Point_2<CGAL::Cartesian<double>> CGALPoint2;
// Collect point cloud
std::list<CGALPoint2> points;
BOOST_FOREACH(const Polygon2d *p, children) {
BOOST_FOREACH(const Outline2d &o, p->outlines()) {
BOOST_FOREACH(const Vector2d &v, o.vertices) {
for(const auto &p : children) {
for(const auto &o : p->outlines()) {
for(const auto &v : o.vertices) {
points.push_back(CGALPoint2(v[0], v[1]));
}
}
@ -168,7 +167,7 @@ Polygon2d *GeometryEvaluator::applyHull2D(const AbstractNode &node)
// Construct Polygon2d
Outline2d outline;
BOOST_FOREACH(const CGALPoint2 &p, result) {
for(const auto &p : result) {
outline.vertices.push_back(Vector2d(p[0], p[1]));
}
geometry->addOutline(outline);
@ -204,7 +203,7 @@ Polygon2d *GeometryEvaluator::applyMinkowski2D(const AbstractNode &node)
std::vector<const class Polygon2d *> GeometryEvaluator::collectChildren2D(const AbstractNode &node)
{
std::vector<const Polygon2d *> children;
BOOST_FOREACH(const Geometry::GeometryItem &item, this->visitedchildren[node.index()]) {
for(const auto &item : this->visitedchildren[node.index()]) {
const AbstractNode *chnode = item.first;
const shared_ptr<const Geometry> &chgeom = item.second;
if (chnode->modinst->isBackground()) continue;
@ -277,7 +276,7 @@ shared_ptr<const Geometry> GeometryEvaluator::smartCacheGet(const AbstractNode &
Geometry::Geometries GeometryEvaluator::collectChildren3D(const AbstractNode &node)
{
Geometry::Geometries children;
BOOST_FOREACH(const Geometry::GeometryItem &item, this->visitedchildren[node.index()]) {
for(const auto &item : this->visitedchildren[node.index()]) {
const AbstractNode *chnode = item.first;
const shared_ptr<const Geometry> &chgeom = item.second;
if (chnode->modinst->isBackground()) continue;
@ -503,7 +502,7 @@ Response GeometryEvaluator::visit(State &state, const TextNode &node)
if (!isSmartCached(node)) {
std::vector<const Geometry *> geometrylist = node.createGeometryList();
std::vector<const Polygon2d *> polygonlist;
BOOST_FOREACH(const Geometry *geometry, geometrylist) {
for(const auto &geometry : geometrylist) {
const Polygon2d *polygon = dynamic_cast<const Polygon2d*>(geometry);
assert(polygon);
polygonlist.push_back(polygon);
@ -619,8 +618,8 @@ Response GeometryEvaluator::visit(State &state, const TransformNode &node)
static void translate_PolySet(PolySet &ps, const Vector3d &translation)
{
BOOST_FOREACH(Polygon &p, ps.polygons) {
BOOST_FOREACH(Vector3d &v, p) {
for(auto &p : ps.polygons) {
for(auto &v : p) {
v += translation;
}
}
@ -636,7 +635,7 @@ static void add_slice(PolySet *ps, const Polygon2d &poly,
Eigen::Affine2d trans2(Eigen::Scaling(scale2) * Eigen::Rotation2D<double>(-rot2*M_PI/180));
bool splitfirst = sin((rot1 - rot2)*M_PI/180) > 0.0;
BOOST_FOREACH(const Outline2d &o, poly.outlines()) {
for(const auto &o : poly.outlines()) {
Vector2d prev1 = trans1 * o.vertices[0];
Vector2d prev2 = trans2 * o.vertices[0];
for (size_t i=1;i<=o.vertices.size();i++) {
@ -697,7 +696,7 @@ static Geometry *extrudePolygon(const LinearExtrudeNode &node, const Polygon2d &
PolySet *ps_bottom = poly.tessellate(); // bottom
// Flip vertex ordering for bottom polygon
BOOST_FOREACH(Polygon &p, ps_bottom->polygons) {
for(auto &p : ps_bottom->polygons) {
std::reverse(p.begin(), p.end());
}
translate_PolySet(*ps_bottom, Vector3d(0,0,h1));
@ -817,8 +816,8 @@ static Geometry *rotatePolygon(const RotateExtrudeNode &node, const Polygon2d &p
double min_x = 0;
double max_x = 0;
int fragments = 0;
BOOST_FOREACH(const Outline2d &o, poly.outlines()) {
BOOST_FOREACH(const Vector2d &v, o.vertices) {
for(const auto &o : poly.outlines()) {
for(const auto &v : o.vertices) {
min_x = fmin(min_x, v[0]);
max_x = fmax(max_x, v[0]);
@ -839,7 +838,7 @@ static Geometry *rotatePolygon(const RotateExtrudeNode &node, const Polygon2d &p
ps_start->transform(rot);
// Flip vertex ordering
if (!flip_faces) {
BOOST_FOREACH(Polygon &p, ps_start->polygons) {
for(auto &p : ps_start->polygons) {
std::reverse(p.begin(), p.end());
}
}
@ -850,7 +849,7 @@ static Geometry *rotatePolygon(const RotateExtrudeNode &node, const Polygon2d &p
Transform3d rot2(Eigen::AngleAxisd(node.angle*M_PI/180, Vector3d::UnitZ()) * Eigen::AngleAxisd(M_PI/2, Vector3d::UnitX()));
ps_end->transform(rot2);
if (flip_faces) {
BOOST_FOREACH(Polygon &p, ps_end->polygons) {
for(auto &p : ps_end->polygons) {
std::reverse(p.begin(), p.end());
}
}
@ -858,7 +857,7 @@ static Geometry *rotatePolygon(const RotateExtrudeNode &node, const Polygon2d &p
delete ps_end;
}
BOOST_FOREACH(const Outline2d &o, poly.outlines()) {
for(const auto &o : poly.outlines()) {
std::vector<Vector3d> rings[2];
rings[0].resize(o.vertices.size());
rings[1].resize(o.vertices.size());
@ -951,7 +950,7 @@ Response GeometryEvaluator::visit(State &state, const ProjectionNode &node)
if (!node.cut_mode) {
ClipperLib::Clipper sumclipper;
BOOST_FOREACH(const Geometry::GeometryItem &item, this->visitedchildren[node.index()]) {
for(const auto &item : this->visitedchildren[node.index()]) {
const AbstractNode *chnode = item.first;
const shared_ptr<const Geometry> &chgeom = item.second;
// FIXME: Don't use deep access to modinst members

View file

@ -2,11 +2,11 @@
#include "tesselator.h"
#include "printutils.h"
#include "Reindexer.h"
#include "grid.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/unordered_map.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <unordered_map>
#include <cmath>
#include <boost/functional/hash.hpp>
static void *stdAlloc(void* userData, unsigned int size) {
TESS_NOTUSED(userData);
@ -27,7 +27,7 @@ typedef std::pair<int,int> IndexedEdge;
class EdgeDict {
public:
// Counts occurrences of edges
typedef boost::unordered_map<IndexedEdge, int> IndexedEdgeDict;
typedef std::unordered_map<IndexedEdge, int, boost::hash<IndexedEdge>> IndexedEdgeDict;
EdgeDict() { }
@ -91,7 +91,7 @@ public:
size_t size() const { return this->edges.size(); }
void print() const {
BOOST_FOREACH(const IndexedEdgeDict::value_type &v, this->edges) {
for(const auto &v : this->edges) {
const IndexedEdge &e = v.first;
PRINTDB(" (%d,%d)%s", e.first % e.second % ((v.second > 1) ? boost::lexical_cast<std::string>(v.second).c_str() : ""));
}
@ -139,7 +139,7 @@ public:
// First, look for self-intersections in edges
v2e.clear();
v2e_reverse.clear();
BOOST_FOREACH(const IndexedEdgeDict::value_type &v, this->edges) {
for(const auto &v : this->edges) {
const IndexedEdge &e = v.first;
for (int i=0;i<v.second;i++) {
v2e[e.first].push_back(e.second);
@ -148,7 +148,7 @@ public:
}
while (!v2e.empty()) {
boost::unordered_map<int, std::list<int> >::iterator it;
std::unordered_map<int, std::list<int>>::iterator it;
for (it = v2e.begin();it != v2e.end();it++) {
if (it->second.size() == 1) { // First single vertex
int vidx = it->first;
@ -167,8 +167,8 @@ public:
}
IndexedEdgeDict edges;
boost::unordered_map<int, std::list<int> > v2e;
boost::unordered_map<int, std::list<int> > v2e_reverse;
std::unordered_map<int, std::list<int>> v2e;
std::unordered_map<int, std::list<int>> v2e_reverse;
};
@ -207,7 +207,7 @@ bool GeometryUtils::tessellatePolygonWithHoles(const Vector3f *vertices,
// Remove consecutive equal vertices, as well as null ears
std::vector<IndexedFace> cleanfaces = faces;
BOOST_FOREACH(IndexedFace &face, cleanfaces) {
for(auto &face : cleanfaces) {
size_t i=0;
while (face.size() >= 3 && i < face.size()) {
if (face[i] == face[(i+1)%face.size()]) { // Two consecutively equal indices
@ -223,7 +223,7 @@ bool GeometryUtils::tessellatePolygonWithHoles(const Vector3f *vertices,
const Vector3f &v = vertices[face[i]];
int k;
for (k=0;k<3;k++) {
if (boost::math::isnan(v[k]) || boost::math::isinf(v[k])) {
if (std::isnan(v[k]) || std::isinf(v[k])) {
face.erase(face.begin()+i);
break;
}
@ -253,7 +253,7 @@ bool GeometryUtils::tessellatePolygonWithHoles(const Vector3f *vertices,
// This contains all edges in the original polygon.
// To maintain connectivity, all these edges must exist in the output.
EdgeDict edges;
BOOST_FOREACH(IndexedFace &face, cleanfaces) {
for(const auto &face : cleanfaces) {
edges.add(face);
}
@ -281,9 +281,9 @@ bool GeometryUtils::tessellatePolygonWithHoles(const Vector3f *vertices,
// Since libtess2's indices is based on the running number of points added, we need to map back
// to our indices. allindices does the mapping.
std::vector<int> allindices;
BOOST_FOREACH(const IndexedFace &face, cleanfaces) {
for(const auto &face : cleanfaces) {
contour.clear();
BOOST_FOREACH(int idx, face) {
for(auto idx : face) {
const Vector3f &v = vertices[idx];
contour.push_back(v[0]);
contour.push_back(v[1]);
@ -428,7 +428,7 @@ bool GeometryUtils::tessellatePolygon(const Polygon &polygon, Polygons &triangle
std::vector<IndexedFace> indexedfaces;
indexedfaces.push_back(IndexedFace());
IndexedFace &currface = indexedfaces.back();
BOOST_FOREACH (const Vector3d &v, polygon) {
for(const auto &v : polygon) {
int idx = uniqueVertices.lookup(v.cast<float>());
if (currface.empty() || idx != currface.back()) currface.push_back(idx);
}
@ -437,7 +437,7 @@ bool GeometryUtils::tessellatePolygon(const Polygon &polygon, Polygons &triangle
const Vector3f *verts = uniqueVertices.getArray();
std::vector<IndexedTriangle> indexedtriangles;
err = tessellatePolygonWithHoles(verts, indexedfaces, indexedtriangles, normal);
BOOST_FOREACH(const IndexedTriangle &t, indexedtriangles) {
for(const auto &t : indexedtriangles) {
triangles.push_back(Polygon());
Polygon &p = triangles.back();
p.push_back(verts[t[0]].cast<double>());
@ -448,11 +448,11 @@ bool GeometryUtils::tessellatePolygon(const Polygon &polygon, Polygons &triangle
return err;
}
int GeometryUtils::findUnconnectedEdges(const std::vector<std::vector<IndexedFace> > &polygons)
int GeometryUtils::findUnconnectedEdges(const std::vector<std::vector<IndexedFace>> &polygons)
{
EdgeDict edges;
BOOST_FOREACH(const std::vector<IndexedFace> &faces, polygons) {
BOOST_FOREACH(const IndexedFace &face, faces) {
for(const auto &faces : polygons) {
for(const auto &face : faces) {
edges.add(face);
}
}
@ -468,7 +468,7 @@ int GeometryUtils::findUnconnectedEdges(const std::vector<std::vector<IndexedFac
int GeometryUtils::findUnconnectedEdges(const std::vector<IndexedTriangle> &triangles)
{
EdgeDict edges;
BOOST_FOREACH(const IndexedTriangle &t, triangles) {
for(const auto &t : triangles) {
edges.add(t);
}
#if 1 // for debugging

View file

@ -22,7 +22,7 @@ struct IndexedTriangleMesh {
// Indexed polygon mesh, where each polygon can have holes
struct IndexedPolyMesh {
std::vector<Vector3f> vertices;
std::vector<std::vector<IndexedFace> > polygons;
std::vector<std::vector<IndexedFace>> polygons;
};
namespace GeometryUtils {
@ -34,6 +34,6 @@ namespace GeometryUtils {
std::vector<IndexedTriangle> &triangles,
const Vector3f *normal = NULL);
int findUnconnectedEdges(const std::vector<std::vector<IndexedFace> > &polygons);
int findUnconnectedEdges(const std::vector<std::vector<IndexedFace>> &polygons);
int findUnconnectedEdges(const std::vector<IndexedTriangle> &triangles);
}

View file

@ -6,7 +6,6 @@
#include "boosty.h"
#include <boost/format.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <stdio.h>
#include <fstream>

View file

@ -1,7 +1,7 @@
#pragma once
#include <string>
#include <boost/unordered_map.hpp>
#include <unordered_map>
/*!
Caches FileModules based on their filenames
@ -26,5 +26,5 @@ private:
class FileModule *module;
std::string cache_id;
};
boost::unordered_map<std::string, cache_entry> entries;
std::unordered_map<std::string, cache_entry> entries;
};

View file

@ -7,7 +7,7 @@
#include <sstream>
#include "printutils.h"
OffscreenView::OffscreenView(size_t width, size_t height)
OffscreenView::OffscreenView(int width, int height)
{
this->ctx = create_offscreen_context(width, height);
if ( this->ctx == NULL ) throw -1;

View file

@ -4,9 +4,6 @@
#include <Eigen/Core>
#include <Eigen/Geometry>
#include <string>
#ifndef _MSC_VER
#include <stdint.h>
#endif
#include "system-gl.h"
#include <iostream>
#include "GLView.h"
@ -14,7 +11,7 @@
class OffscreenView : public GLView
{
public:
OffscreenView(size_t width, size_t height);
OffscreenView(int width, int height);
~OffscreenView();
bool save(std::ostream &output);
OffscreenContext *ctx;

View file

@ -29,7 +29,6 @@
#include "polyset.h"
#include "csgnode.h"
#include "stl-utils.h"
#include <boost/foreach.hpp>
#ifdef ENABLE_OPENCSG
# include <opencsg.h>
@ -95,12 +94,12 @@ void OpenCSGRenderer::renderCSGProducts(const CSGProducts &products, GLint *shad
bool highlight_mode, bool background_mode) const
{
#ifdef ENABLE_OPENCSG
BOOST_FOREACH(const CSGProduct &product, products.products) {
for(const auto &product : products.products) {
std::vector<OpenCSG::Primitive*> primitives;
BOOST_FOREACH(const CSGChainObject &csgobj, product.intersections) {
for(const auto &csgobj : product.intersections) {
if (csgobj.leaf->geom) primitives.push_back(createCSGPrimitive(csgobj, OpenCSG::Intersection, highlight_mode, background_mode, OPENSCAD_INTERSECTION));
}
BOOST_FOREACH(const CSGChainObject &csgobj, product.subtractions) {
for(const auto &csgobj : product.subtractions) {
if (csgobj.leaf->geom) primitives.push_back(createCSGPrimitive(csgobj, OpenCSG::Subtraction, highlight_mode, background_mode, OPENSCAD_DIFFERENCE));
}
if (primitives.size() > 1) {
@ -110,7 +109,7 @@ void OpenCSGRenderer::renderCSGProducts(const CSGProducts &products, GLint *shad
if (shaderinfo) glUseProgram(shaderinfo[0]);
const CSGChainObject &parent_obj = product.intersections[0];
BOOST_FOREACH(const CSGChainObject &csgobj, product.intersections) {
for(const auto &csgobj : product.intersections) {
const Color4f &c = csgobj.leaf->color;
csgmode_e csgmode = csgmode_e(
highlight_mode ?
@ -132,7 +131,7 @@ void OpenCSGRenderer::renderCSGProducts(const CSGProducts &products, GLint *shad
render_surface(csgobj.leaf->geom, csgmode, csgobj.leaf->matrix, shaderinfo);
glPopMatrix();
}
BOOST_FOREACH(const CSGChainObject &csgobj, product.subtractions) {
for(const auto &csgobj : product.subtractions) {
const Color4f &c = csgobj.leaf->color;
csgmode_e csgmode = csgmode_e(
(highlight_mode ?
@ -156,7 +155,7 @@ void OpenCSGRenderer::renderCSGProducts(const CSGProducts &products, GLint *shad
}
if (shaderinfo) glUseProgram(0);
BOOST_FOREACH(OpenCSG::Primitive *p, primitives) delete p;
for(auto &p : primitives) delete p;
glDepthFunc(GL_LEQUAL);
}
#endif

View file

@ -8,8 +8,6 @@
#include <CGAL/Polygon_2.h>
#include <iostream>
#include <boost/foreach.hpp>
namespace Polygon2DCGAL {
struct FaceInfo
@ -111,10 +109,10 @@ PolySet *Polygon2d::tessellate() const
Polygon2DCGAL::CDT cdt; // Uses a constrained Delaunay triangulator.
OPENSCAD_CGAL_ERROR_BEGIN;
// Adds all vertices, and add all contours as constraints.
BOOST_FOREACH(const Outline2d &outline, this->outlines()) {
for(const auto &outline : this->outlines()) {
// Start with last point
Polygon2DCGAL::CDT::Vertex_handle prev = cdt.insert(Polygon2DCGAL::Point(outline.vertices[outline.vertices.size()-1][0], outline.vertices[outline.vertices.size()-1][1]));
BOOST_FOREACH(const Vector2d &v, outline.vertices) {
for(const auto &v : outline.vertices) {
Polygon2DCGAL::CDT::Vertex_handle curr = cdt.insert(Polygon2DCGAL::Point(v[0], v[1]));
if (prev != curr) { // Ignore duplicate vertices
cdt.insert_constraint(prev, curr);

View file

@ -1,6 +1,5 @@
#include "Polygon2d.h"
#include "printutils.h"
#include <boost/foreach.hpp>
/*!
Class for holding 2D geometry.
@ -20,7 +19,7 @@
size_t Polygon2d::memsize() const
{
size_t mem = 0;
BOOST_FOREACH(const Outline2d &o, this->outlines()) {
for(const auto &o : this->outlines()) {
mem += o.vertices.size() * sizeof(Vector2d) + sizeof(Outline2d);
}
mem += sizeof(Polygon2d);
@ -30,8 +29,8 @@ size_t Polygon2d::memsize() const
BoundingBox Polygon2d::getBoundingBox() const
{
BoundingBox bbox;
BOOST_FOREACH(const Outline2d &o, this->outlines()) {
BOOST_FOREACH(const Vector2d &v, o.vertices) {
for(const auto &o : this->outlines()) {
for(const auto &v : o.vertices) {
bbox.extend(Vector3d(v[0], v[1], 0));
}
}
@ -41,9 +40,9 @@ BoundingBox Polygon2d::getBoundingBox() const
std::string Polygon2d::dump() const
{
std::stringstream out;
BOOST_FOREACH(const Outline2d &o, this->theoutlines) {
for(const auto &o : this->theoutlines) {
out << "contour:\n";
BOOST_FOREACH(const Vector2d &v, o.vertices) {
for(const auto &v : o.vertices) {
out << " " << v.transpose();
}
out << "\n";
@ -63,14 +62,14 @@ void Polygon2d::transform(const Transform2d &mat)
this->theoutlines.clear();
return;
}
BOOST_FOREACH(Outline2d &o, this->theoutlines) {
BOOST_FOREACH(Vector2d &v, o.vertices) {
for(auto &o : this->theoutlines) {
for(auto &v : o.vertices) {
v = mat * v;
}
}
}
void Polygon2d::resize(Vector2d newsize, const Eigen::Matrix<bool,2,1> &autosize)
void Polygon2d::resize(const Vector2d &newsize, const Eigen::Matrix<bool,2,1> &autosize)
{
BoundingBox bbox = this->getBoundingBox();

View file

@ -32,7 +32,7 @@ public:
const Outlines2d &outlines() const { return theoutlines; }
void transform(const Transform2d &mat);
void resize(Vector2d newsize, const Eigen::Matrix<bool,2,1> &autosize);
void resize(const Vector2d &newsize, const Eigen::Matrix<bool,2,1> &autosize);
bool isSanitized() const { return this->sanitized; }
void setSanitized(bool s) { this->sanitized = s; }

View file

@ -32,7 +32,6 @@
#include <QSettings>
#include <QStatusBar>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include "GeometryCache.h"
#include "AutoUpdater.h"
#include "feature.h"
@ -143,7 +142,7 @@ void Preferences::init() {
uint savedsize = getValue("editor/fontsize").toUInt();
QFontDatabase db;
foreach(uint size, db.standardSizes()) {
for(auto size : db.standardSizes()) {
this->fontSize->addItem(QString::number(size));
if (size == savedsize) {
this->fontSize->setCurrentIndex(this->fontSize->count()-1);
@ -691,7 +690,7 @@ void Preferences::initComboBox(QComboBox *comboBox, const Settings::SettingsEntr
{
comboBox->clear();
// Range is a vector of 2D vectors: [[name, value], ...]
BOOST_FOREACH(const ValuePtr &v, entry.range().toVector()) {
for(const auto &v : entry.range().toVector()) {
QString val = QString::fromStdString(v[0]->toString());
QString qtext = QString::fromStdString(gettext(v[1]->toString().c_str()));
comboBox->addItem(qtext, val);
@ -749,9 +748,7 @@ void Preferences::create(QStringList colorSchemes)
std::list<std::string> names = ColorMap::inst()->colorSchemeNames(true);
QStringList renderColorSchemes;
foreach (std::string name, names) {
renderColorSchemes << name.c_str();
}
for(const auto &name : names) renderColorSchemes << name.c_str();
instance = new Preferences();
instance->syntaxHighlight->clear();

View file

@ -43,7 +43,6 @@
#include <QErrorMessage>
#include "OpenCSGWarningDialog.h"
#include "mathc99.h"
#include <stdio.h>
#ifdef ENABLE_OPENCSG

View file

@ -1,9 +1,10 @@
#pragma once
#include <boost/unordered_map.hpp>
#include <boost/functional.hpp>
#include <unordered_map>
#include <functional>
#include <vector>
#include <algorithm>
#include "hash.h"
/*!
Reindexes a collection of elements of type T.
@ -20,7 +21,7 @@ public:
Looks up a value. Will insert the value if it doesn't already exist.
Returns the new index. */
int lookup(const T &val) {
typename boost::unordered_map<T, int>::const_iterator iter = this->map.find(val);
typename std::unordered_map<T, int>::const_iterator iter = this->map.find(val);
if (iter != this->map.end()) return iter->second;
else {
this->map.insert(std::make_pair(val, this->map.size()));
@ -40,7 +41,7 @@ public:
*/
const T *getArray() {
this->vec.resize(this->map.size());
typename boost::unordered_map<T, int>::const_iterator iter = this->map.begin();
typename std::unordered_map<T, int>::const_iterator iter = this->map.begin();
while (iter != this->map.end()) {
this->vec[iter->second] = iter->first;
iter++;
@ -57,6 +58,6 @@ public:
}
private:
boost::unordered_map<T, int> map;
std::unordered_map<T, int> map;
std::vector<T> vec;
};

View file

@ -30,8 +30,6 @@
#include "system-gl.h"
#include <boost/foreach.hpp>
ThrownTogetherRenderer::ThrownTogetherRenderer(shared_ptr<CSGProducts> root_products,
shared_ptr<CSGProducts> highlight_products,
shared_ptr<CSGProducts> background_products)
@ -123,11 +121,11 @@ void ThrownTogetherRenderer::renderCSGProducts(const CSGProducts &products, bool
glDepthFunc(GL_LEQUAL);
this->geomVisitMark.clear();
BOOST_FOREACH(const CSGProduct &product, products.products) {
BOOST_FOREACH(const CSGChainObject &csgobj, product.intersections) {
for(const auto &product : products.products) {
for(const auto &csgobj : product.intersections) {
renderChainObject(csgobj, highlight_mode, background_mode, showedges, fberror, OPENSCAD_INTERSECTION);
}
BOOST_FOREACH(const CSGChainObject &csgobj, product.subtractions) {
for(const auto &csgobj : product.subtractions) {
renderChainObject(csgobj, highlight_mode, background_mode, showedges, fberror, OPENSCAD_DIFFERENCE);
}
}

View file

@ -2,7 +2,8 @@
#include "renderer.h"
#include "csgnode.h"
#include <boost/unordered_map.hpp>
#include <unordered_map>
#include <boost/functional/hash.hpp>
class ThrownTogetherRenderer : public Renderer
{
@ -21,5 +22,7 @@ private:
shared_ptr<CSGProducts> root_products;
shared_ptr<CSGProducts> highlight_products;
shared_ptr<CSGProducts> background_products;
mutable boost::unordered_map<std::pair<const Geometry*,const Transform3d*>,int> geomVisitMark;
mutable std::unordered_map<std::pair<const Geometry*,const Transform3d*>,
int,
boost::hash<std::pair<const Geometry*,const Transform3d*>>> geomVisitMark;
};

View file

@ -38,7 +38,6 @@
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
QFileInfo UIUtils::openFile(QWidget *parent)
{
@ -108,7 +107,7 @@ QStringList UIUtils::exampleCategories()
QStringList categories;
ptree *pt = examplesTree();
if (pt) {
BOOST_FOREACH(const ptree::value_type &v, *pt) {
for(const auto &v : *pt) {
// v.first is the name of the child.
// v.second is the child tree.
categories << QString::fromStdString(v.first);
@ -124,7 +123,7 @@ QFileInfoList UIUtils::exampleFiles(const QString &category)
ptree *pt = examplesTree();
if (pt) {
fs::path examplesPath = PlatformUtils::resourcePath("examples") / category.toStdString();
BOOST_FOREACH(const ptree::value_type &v, pt->get_child(category.toStdString())) {
for(const auto &v : pt->get_child(category.toStdString())) {
examples << QFileInfo(QString::fromStdString((examplesPath / v.second.data()).string()));
}
}

View file

@ -2,7 +2,6 @@
#include "function.h"
#include "module.h"
#include "expression.h"
#include <boost/foreach.hpp>
Builtins *Builtins::instance(bool erase)
{
@ -95,19 +94,19 @@ std::string Builtins::isDeprecated(const std::string &name)
Builtins::Builtins()
{
this->globalscope.assignments.push_back(Assignment("$fn", boost::shared_ptr<Expression>(new ExpressionConst(ValuePtr(0.0)))));
this->globalscope.assignments.push_back(Assignment("$fs", boost::shared_ptr<Expression>(new ExpressionConst(ValuePtr(2.0)))));
this->globalscope.assignments.push_back(Assignment("$fa", boost::shared_ptr<Expression>(new ExpressionConst(ValuePtr(12.0)))));
this->globalscope.assignments.push_back(Assignment("$t", boost::shared_ptr<Expression>(new ExpressionConst(ValuePtr(0.0)))));
this->globalscope.assignments.push_back(Assignment("$fn", shared_ptr<Expression>(new ExpressionConst(ValuePtr(0.0)))));
this->globalscope.assignments.push_back(Assignment("$fs", shared_ptr<Expression>(new ExpressionConst(ValuePtr(2.0)))));
this->globalscope.assignments.push_back(Assignment("$fa", shared_ptr<Expression>(new ExpressionConst(ValuePtr(12.0)))));
this->globalscope.assignments.push_back(Assignment("$t", shared_ptr<Expression>(new ExpressionConst(ValuePtr(0.0)))));
Value::VectorType zero3;
zero3.push_back(ValuePtr(0.0));
zero3.push_back(ValuePtr(0.0));
zero3.push_back(ValuePtr(0.0));
ValuePtr zero3val(zero3);
this->globalscope.assignments.push_back(Assignment("$vpt", boost::shared_ptr<Expression>(new ExpressionConst(zero3val))));
this->globalscope.assignments.push_back(Assignment("$vpr", boost::shared_ptr<Expression>(new ExpressionConst(zero3val))));
this->globalscope.assignments.push_back(Assignment("$vpd", boost::shared_ptr<Expression>(new ExpressionConst(ValuePtr(500)))));
this->globalscope.assignments.push_back(Assignment("$vpt", shared_ptr<Expression>(new ExpressionConst(zero3val))));
this->globalscope.assignments.push_back(Assignment("$vpr", shared_ptr<Expression>(new ExpressionConst(zero3val))));
this->globalscope.assignments.push_back(Assignment("$vpd", shared_ptr<Expression>(new ExpressionConst(ValuePtr(500)))));
}
Builtins::~Builtins()

View file

@ -1,15 +1,15 @@
#pragma once
#include <string>
#include <boost/unordered_map.hpp>
#include <unordered_map>
#include "module.h"
#include "localscope.h"
class Builtins
{
public:
typedef boost::unordered_map<std::string, class AbstractFunction*> FunctionContainer;
typedef boost::unordered_map<std::string, class AbstractModule*> ModuleContainer;
typedef std::unordered_map<std::string, class AbstractFunction*> FunctionContainer;
typedef std::unordered_map<std::string, class AbstractModule*> ModuleContainer;
static Builtins *instance(bool erase = false);
static void init(const char *name, class AbstractModule *module);
@ -25,5 +25,5 @@ private:
LocalScope globalscope;
boost::unordered_map<std::string, std::string> deprecations;
std::unordered_map<std::string, std::string> deprecations;
};

View file

@ -44,7 +44,7 @@
#pragma once
#include <boost/unordered_map.hpp>
#include <unordered_map>
#include <boost/format.hpp>
#include "printutils.h"
@ -57,11 +57,11 @@ class Cache
: keyPtr(0), t(data), c(cost), p(0), n(0) {}
const Key *keyPtr; T *t; int c; Node *p,*n;
};
typedef typename boost::unordered_map<Key, Node> map_type;
typedef typename std::unordered_map<Key, Node> map_type;
typedef typename map_type::iterator iterator_type;
typedef typename map_type::value_type value_type;
boost::unordered_map<Key, Node> hash;
std::unordered_map<Key, Node> hash;
Node *f, *l;
void *unused;
int mx, total;

View file

@ -26,7 +26,7 @@
#include "calc.h"
#include "grid.h"
#include <boost/math/special_functions/fpclassify.hpp>
#include <cmath>
/*!
Returns the number of subdivision of a whole circle, given radius and
@ -36,7 +36,7 @@ int Calc::get_fragments_from_r(double r, double fn, double fs, double fa)
{
// FIXME: It would be better to refuse to create an object. Let's do more strict error handling
// in future versions of OpenSCAD
if (r < GRID_FINE || boost::math::isinf(fn) || boost::math::isnan(fn)) return 3;
if (r < GRID_FINE || std::isinf(fn) || std::isnan(fn)) return 3;
if (fn > 0.0) return (int)(fn >= 3 ? fn : 3);
return (int)ceil(fmax(fmin(360.0 / fa, r*2*M_PI / fs), 5));
}

View file

@ -2,14 +2,6 @@
#ifdef ENABLE_CGAL
#ifdef _MSC_VER
// see http://en.wikipedia.org/wiki/Stdint.h
// and http://www.mpfr.org/mpfr-2.4.2/#stdint
#include <boost/cstdint.hpp>
using boost::intmax_t;
using boost::uintmax_t;
#endif
// NDEBUG must be disabled when including CGAL headers, otherwise CGAL assertions
// will not be thrown, causing OpenSCAD's CGAL error checking to fail.
// To be on the safe side, this has to be done when including any CGAL header file.
@ -66,7 +58,7 @@ typedef std::vector<CGAL_Point_3> CGAL_Polygon_3;
// CGAL_Nef_polyhedron2::Explorer::Point which is different than
// CGAL_Kernel2::Point. Hence the suffix 'e'
typedef CGAL_Nef_polyhedron2::Explorer::Point CGAL_Point_2e;
typedef CGAL::Iso_rectangle_2<CGAL::Simple_cartesian<NT2> > CGAL_Iso_rectangle_2e;
typedef CGAL::Iso_rectangle_2<CGAL::Simple_cartesian<NT2>> CGAL_Iso_rectangle_2e;
#ifdef PREV_NDEBUG

View file

@ -32,8 +32,7 @@
#include <map>
#include <queue>
#include <boost/foreach.hpp>
#include <boost/unordered_set.hpp>
#include <unordered_set>
namespace CGALUtils {
@ -47,7 +46,7 @@ namespace CGALUtils {
}
}
// Also make sure that there is only one shell:
boost::unordered_set<typename Polyhedron::Facet_const_handle, typename CGAL::Handle_hash_function> visited;
std::unordered_set<typename Polyhedron::Facet_const_handle, typename CGAL::Handle_hash_function> visited;
// c++11
// visited.reserve(p.size_of_facets());
@ -86,7 +85,7 @@ namespace CGALUtils {
CGAL::Nef_nary_union_3<CGAL_Nef_polyhedron3> nary_union;
int nary_union_num_inserted = 0;
BOOST_FOREACH(const Geometry::GeometryItem &item, children) {
for(const auto &item : children) {
const shared_ptr<const Geometry> &chgeom = item.second;
shared_ptr<const CGAL_Nef_polyhedron> chN =
dynamic_pointer_cast<const CGAL_Nef_polyhedron>(chgeom);
@ -158,7 +157,7 @@ namespace CGALUtils {
// instead.
std::list<K::Point_3> points;
BOOST_FOREACH(const Geometry::GeometryItem &item, children) {
for(const auto &item : children) {
const shared_ptr<const Geometry> &chgeom = item.second;
const CGAL_Nef_polyhedron *N = dynamic_cast<const CGAL_Nef_polyhedron *>(chgeom.get());
if (N) {
@ -170,8 +169,8 @@ namespace CGALUtils {
} else {
const PolySet *ps = dynamic_cast<const PolySet *>(chgeom.get());
if (ps) {
BOOST_FOREACH(const Polygon &p, ps->polygons) {
BOOST_FOREACH(const Vector3d &v, p) {
for(const auto &p : ps->polygons) {
for(const auto &v : p) {
points.push_back(K::Point_3(v[0], v[1], v[2]));
}
}
@ -220,7 +219,7 @@ namespace CGALUtils {
typedef CGAL::Epick Hull_kernel;
std::list<CGAL_Polyhedron> P[2];
std::list<CGAL::Polyhedron_3<Hull_kernel> > result_parts;
std::list<CGAL::Polyhedron_3<Hull_kernel>> result_parts;
for (size_t i = 0; i < 2; i++) {
CGAL_Polyhedron poly;
@ -376,7 +375,7 @@ namespace CGALUtils {
t.start();
PRINTDB("Minkowski: Computing union of %d parts",result_parts.size());
Geometry::Geometries fake_children;
for (std::list<CGAL::Polyhedron_3<Hull_kernel> >::iterator i = result_parts.begin(); i != result_parts.end(); ++i) {
for (std::list<CGAL::Polyhedron_3<Hull_kernel>>::iterator i = result_parts.begin(); i != result_parts.end(); ++i) {
PolySet ps(3,true);
createPolySetFromPolyhedron(*i, ps);
fake_children.push_back(std::make_pair((const AbstractNode*)NULL,

View file

@ -9,7 +9,7 @@
#include "cgal.h"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <boost/foreach.hpp>
#include <boost/range/adaptor/reversed.hpp>
#undef GEN_SURFACE_DEBUG
namespace /* anonymous */ {
@ -45,13 +45,13 @@ namespace /* anonymous */ {
Grid3d<int> grid(GRID_FINE);
std::vector<CGALPoint> vertices;
std::vector<std::vector<size_t> > indices;
std::vector<std::vector<size_t>> indices;
// Align all vertices to grid and build vertex array in vertices
BOOST_FOREACH(const Polygon &p, ps.polygons) {
for(const auto &p : ps.polygons) {
indices.push_back(std::vector<size_t>());
indices.back().reserve(p.size());
BOOST_REVERSE_FOREACH(Vector3d v, p) {
indices.back().reserve(p.size());
for (auto v : boost::adaptors::reverse(p)) {
// align v to the grid; the CGALPoint will receive the aligned vertex
size_t idx = grid.align(v);
if (idx == vertices.size()) {
@ -67,10 +67,10 @@ namespace /* anonymous */ {
int pidx = 0;
#endif
B.begin_surface(vertices.size(), ps.polygons.size());
BOOST_FOREACH(const CGALPoint &p, vertices) {
for(const auto &p : vertices) {
B.add_vertex(p);
}
BOOST_FOREACH(std::vector<size_t> &pindices, indices) {
for(auto &pindices : indices) {
#ifdef GEN_SURFACE_DEBUG
if (pidx++ > 0) printf(",");
#endif
@ -87,7 +87,7 @@ namespace /* anonymous */ {
#ifdef GEN_SURFACE_DEBUG
printf("[");
int fidx = 0;
BOOST_REVERSE_FOREACH(size_t i, pindices) {
for (auto i : boost::adaptors::reverse(pindices)) {
if (fidx++ > 0) printf(",");
printf("%ld", i);
}
@ -121,12 +121,12 @@ namespace /* anonymous */ {
#ifdef GEN_SURFACE_DEBUG
printf("polyhedron(faces=[");
#endif
BOOST_FOREACH(const Polygon &p, ps.polygons) {
for(const auto &p : ps.polygons) {
#ifdef GEN_SURFACE_DEBUG
if (pidx++ > 0) printf(",");
#endif
indices.clear();
BOOST_REVERSE_FOREACH(const Vector3d &v, p) {
for (const auto &v, boost::adaptors::reverse(p)) {
size_t s = vertices.size();
size_t idx = vertices.lookup(v);
// If we added a vertex, also add it to the CGAL builder
@ -151,7 +151,7 @@ namespace /* anonymous */ {
#ifdef GEN_SURFACE_DEBUG
printf("[");
int fidx = 0;
BOOST_FOREACH(size_t i, indices) {
for(auto i : indices) {
if (fidx++ > 0) printf(",");
printf("%ld", i);
}
@ -289,7 +289,7 @@ namespace CGALUtils {
template bool createPolySetFromPolyhedron(const CGAL_Polyhedron &p, PolySet &ps);
template bool createPolySetFromPolyhedron(const CGAL::Polyhedron_3<CGAL::Epick> &p, PolySet &ps);
template bool createPolySetFromPolyhedron(const CGAL::Polyhedron_3<CGAL::Epeck> &p, PolySet &ps);
template bool createPolySetFromPolyhedron(const CGAL::Polyhedron_3<CGAL::Simple_cartesian<long> > &p, PolySet &ps);
template bool createPolySetFromPolyhedron(const CGAL::Polyhedron_3<CGAL::Simple_cartesian<long>> &p, PolySet &ps);
class Polyhedron_writer {
std::ostream *out;
@ -327,7 +327,7 @@ namespace CGALUtils {
}
void write_facet_end() {
bool firsti = true;
BOOST_REVERSE_FOREACH(int i, indices) {
for (auto i : boost::adaptors::reverse(indices)) {
*out << (firsti ? "" : ",") << i;
firsti = false;
}

View file

@ -27,14 +27,10 @@
#endif
#include "svg.h"
#include "Reindexer.h"
#include "GeometryUtils.h"
#include <map>
#include <queue>
#include <boost/foreach.hpp>
#include <boost/unordered_set.hpp>
static void add_outline_to_poly(CGAL_Nef_polyhedron2::Explorer &explorer,
CGAL_Nef_polyhedron2::Explorer::Halfedge_around_face_const_circulator circ,
@ -109,8 +105,8 @@ OGL_helper.h
class ZRemover {
public:
CGAL_Nef_polyhedron2::Boundary boundary;
boost::shared_ptr<CGAL_Nef_polyhedron2> tmpnef2d;
boost::shared_ptr<CGAL_Nef_polyhedron2> output_nefpoly2d;
shared_ptr<CGAL_Nef_polyhedron2> tmpnef2d;
shared_ptr<CGAL_Nef_polyhedron2> output_nefpoly2d;
CGAL::Direction_3<CGAL_Kernel3> up;
ZRemover()
{

View file

@ -340,7 +340,7 @@ namespace CGALUtils {
PRINTDB("plane %s",plane );
PRINTDB("proj: %i %i",goodproj.plane % goodproj.flip);
PRINTD("Inserting points and edges into Constrained Delaunay Triangulation");
std::vector< std::vector<CGAL_Point_2> > polygons2d;
std::vector< std::vector<CGAL_Point_2>> polygons2d;
for (size_t i=0;i<polygons.size();i++) {
std::vector<Vertex_handle> vhandles;
std::vector<CGAL_Point_2> polygon2d;
@ -459,7 +459,7 @@ namespace CGALUtils {
PRINTDB("plane %s",plane );
PRINTDB("proj: %i %i",goodproj.plane % goodproj.flip);
PRINTD("Inserting points and edges into Constrained Delaunay Triangulation");
std::vector< std::vector<CGAL_Point_2> > polygons2d;
std::vector< std::vector<CGAL_Point_2>> polygons2d;
for (size_t i=0;i<polygons.size();i++) {
std::vector<Vertex_handle> vhandles;
std::vector<CGAL_Point_2> polygon2d;

View file

@ -13,9 +13,6 @@
#define NDEBUG PREV_NDEBUG
#endif
#include <boost/foreach.hpp>
struct FaceInfo {
int nesting_level;
bool in_domain() { return nesting_level%2 == 1; }
@ -25,7 +22,7 @@ typedef CGAL::Triangulation_2_filtered_projection_traits_3<K> Projection;
typedef CGAL::Triangulation_face_base_with_info_2<FaceInfo, K> Fbb;
typedef CGAL::Triangulation_data_structure_2<
CGAL::Triangulation_vertex_base_2<Projection>,
CGAL::Constrained_triangulation_face_base_2<Projection, Fbb> > Tds;
CGAL::Constrained_triangulation_face_base_2<Projection, Fbb>> Tds;
typedef CGAL::Constrained_Delaunay_triangulation_2<
Projection, Tds, CGAL::Exact_predicates_tag> CDT;
@ -118,7 +115,7 @@ namespace CGALUtils {
// the Constrained Delaunay Triangulator.
Projection actualProjection(normalvec);
CDT cdt(actualProjection);
BOOST_FOREACH(const PolygonK &poly, polygons) {
for(const auto &poly : polygons) {
for (size_t i=0;i<poly.size(); i++) {
cdt.insert_constraint(poly[i], poly[(i+1)%poly.size()]);
}

View file

@ -28,12 +28,11 @@
#include "svg.h"
#include "Reindexer.h"
#include "hash.h"
#include "GeometryUtils.h"
#include <map>
#include <queue>
#include <boost/foreach.hpp>
#include <boost/unordered_set.hpp>
static CGAL_Nef_polyhedron *createNefPolyhedronFromPolySet(const PolySet &ps)
{
@ -53,8 +52,8 @@ static CGAL_Nef_polyhedron *createNefPolyhedronFromPolySet(const PolySet &ps)
// NB! CGAL's convex_hull_3() doesn't like std::set iterators, so we use a list
// instead.
std::list<K::Point_3> points;
BOOST_FOREACH(const Polygon &poly, psq.polygons) {
BOOST_FOREACH(const Vector3d &p, poly) {
for(const auto &poly : psq.polygons) {
for(const auto &p : poly) {
points.push_back(vector_convert<K::Point_3>(p));
}
}
@ -273,7 +272,7 @@ namespace CGALUtils {
// 1. Build Indexed PolyMesh
Reindexer<Vector3f> allVertices;
std::vector<std::vector<IndexedFace> > polygons;
std::vector<std::vector<IndexedFace>> polygons;
CGAL_Nef_polyhedron3::Halffacet_const_iterator hfaceti;
CGAL_forall_halffacets(hfaceti, N) {
@ -312,19 +311,19 @@ namespace CGALUtils {
// 3. Triangulate each face
const Vector3f *verts = allVertices.getArray();
std::vector<IndexedTriangle> allTriangles;
BOOST_FOREACH(const std::vector<IndexedFace> &faces, polygons) {
for(const auto &faces : polygons) {
#if 0 // For debugging
std::cerr << "---\n";
BOOST_FOREACH(const IndexedFace &poly, faces) {
BOOST_FOREACH(int i, poly) {
for(const auto &poly : faces) {
for(auto i : poly) {
std::cerr << i << " ";
}
std::cerr << "\n";
}
#if 0 // debug
std::cerr.precision(20);
BOOST_FOREACH(const IndexedFace &poly, faces) {
BOOST_FOREACH(int i, poly) {
for(const auto &poly : faces) {
for(auto i : poly) {
std::cerr << verts[i][0] << "," << verts[i][1] << "," << verts[i][2] << "\n";
}
std::cerr << "\n";
@ -354,7 +353,7 @@ namespace CGALUtils {
std::vector<IndexedTriangle> triangles;
bool err = GeometryUtils::tessellatePolygonWithHoles(verts, faces, triangles, NULL);
if (!err) {
BOOST_FOREACH(const IndexedTriangle &t, triangles) {
for(const auto &t : triangles) {
assert(t[0] >= 0 && t[0] < (int)allVertices.size());
assert(t[1] >= 0 && t[1] < (int)allVertices.size());
assert(t[2] >= 0 && t[2] < (int)allVertices.size());
@ -364,7 +363,7 @@ namespace CGALUtils {
}
#if 0 // For debugging
BOOST_FOREACH(const IndexedTriangle &t, allTriangles) {
for(const auto &t : allTriangles) {
std::cerr << t[0] << " " << t[1] << " " << t[2] << "\n";
}
#endif // debug
@ -374,7 +373,7 @@ namespace CGALUtils {
PRINTB("Error: Non-manifold triangle mesh created: %d unconnected edges", unconnected2);
}
BOOST_FOREACH(const IndexedTriangle &t, allTriangles) {
for(const auto &t : allTriangles) {
ps.append_poly();
ps.append_vertex(verts[t[0]]);
ps.append_vertex(verts[t[1]]);
@ -425,7 +424,7 @@ namespace CGALUtils {
std::vector<CGAL_Polygon_3> triangles;
bool err = CGALUtils::tessellate3DFaceWithHoles(polyholes, triangles, plane);
if (!err) {
BOOST_FOREACH(const CGAL_Polygon_3 &p, triangles) {
for(const auto &p : triangles) {
if (p.size() != 3) {
PRINT("WARNING: triangle doesn't have 3 points. skipping");
continue;
@ -474,7 +473,7 @@ namespace CGALUtils {
std::vector<Polygon> triangles;
bool err = CGALUtils::tessellate3DFaceWithHolesNew(polyholes, triangles, plane);
if (!err) {
BOOST_FOREACH(const Polygon &p, triangles) {
for(const auto &p : triangles) {
if (p.size() != 3) {
PRINT("WARNING: triangle doesn't have 3 points. skipping");
continue;
@ -539,7 +538,7 @@ namespace CGALUtils {
std::vector<Polygon> triangles;
bool err = CGALUtils::tessellatePolygonWithHolesNew(polyholes, triangles, NULL);
if (!err) {
BOOST_FOREACH(const Polygon &p, triangles) {
for(const auto &p : triangles) {
if (p.size() != 3) {
PRINT("WARNING: triangle doesn't have 3 points. skipping");
continue;
@ -578,8 +577,8 @@ namespace CGALUtils {
}
std::cout << "---\n";
BOOST_FOREACH(const PolygonK &poly, polyholes) {
BOOST_FOREACH(const Vertex3K &v, poly) {
for(const auto &poly : polyholes) {
for(const auto &v : poly) {
std::cout << v.x() << "," << v.y() << "," << v.z() << "\n";
}
std::cout << "\n";
@ -601,7 +600,7 @@ namespace CGALUtils {
std::vector<Polygon> triangles;
bool err = CGALUtils::tessellatePolygonWithHolesNew(polyholes, triangles, NULL);
if (!err) {
BOOST_FOREACH(const Polygon &p, triangles) {
for(const auto &p : triangles) {
if (p.size() != 3) {
PRINT("WARNING: triangle doesn't have 3 points. skipping");
continue;
@ -653,8 +652,8 @@ namespace CGALUtils {
#if 0 // For debugging
std::cerr << "---\n";
std::cerr.precision(20);
BOOST_FOREACH(const IndexedFace &poly, polyhole.faces) {
BOOST_FOREACH(int i, poly) {
for(const auto &poly : polyhole.faces) {
for(auto i : poly) {
std::cerr << polyhole.vertices[i][0] << "," << polyhole.vertices[i][1] << "," << polyhole.vertices[i][2] << "\n";
}
std::cerr << "\n";
@ -678,7 +677,7 @@ namespace CGALUtils {
bool err = GeometryUtils::tessellatePolygonWithHoles(polyhole, triangles, NULL);
const Vector3f *verts = &polyhole.vertices.front();
if (!err) {
BOOST_FOREACH(const Vector3i &t, triangles) {
for(const auto &t : triangles) {
ps.append_poly();
ps.append_vertex(verts[t[0]]);
ps.append_vertex(verts[t[1]]);

View file

@ -1,12 +1,11 @@
#include "clipper-utils.h"
#include "printutils.h"
#include <boost/foreach.hpp>
namespace ClipperUtils {
ClipperLib::Path fromOutline2d(const Outline2d &outline, bool keep_orientation) {
ClipperLib::Path p;
BOOST_FOREACH(const Vector2d &v, outline.vertices) {
for(const auto &v : outline.vertices) {
p.push_back(ClipperLib::IntPoint(v[0]*CLIPPER_SCALE, v[1]*CLIPPER_SCALE));
}
// Make sure all polygons point up, since we project also
@ -18,7 +17,7 @@ namespace ClipperUtils {
ClipperLib::Paths fromPolygon2d(const Polygon2d &poly) {
ClipperLib::Paths result;
BOOST_FOREACH(const Outline2d &outline, poly.outlines()) {
for(const auto &outline : poly.outlines()) {
result.push_back(fromOutline2d(outline, poly.isSanitized() ? true : false));
}
return result;
@ -66,7 +65,7 @@ namespace ClipperUtils {
// CleanPolygon can in some cases reduce the polygon down to no vertices
if (cleaned_path.size() >= 3) {
BOOST_FOREACH(const ClipperLib::IntPoint &ip, cleaned_path) {
for(const auto &ip : cleaned_path) {
Vector2d v(1.0*ip.X/CLIPPER_SCALE, 1.0*ip.Y/CLIPPER_SCALE);
outline.vertices.push_back(v);
}
@ -117,7 +116,7 @@ namespace ClipperUtils {
}
bool first = true;
BOOST_FOREACH(const ClipperLib::Paths &paths, pathsvector) {
for(const auto &paths : pathsvector) {
clipper.AddPaths(paths, first ? ClipperLib::ptSubject : ClipperLib::ptClip, true);
if (first) first = false;
}
@ -138,7 +137,7 @@ namespace ClipperUtils {
ClipperLib::ClipType clipType)
{
std::vector<ClipperLib::Paths> pathsvector;
BOOST_FOREACH(const Polygon2d *polygon, polygons) {
for(const auto &polygon : polygons) {
ClipperLib::Paths polypaths = fromPolygon2d(*polygon);
if (!polygon->isSanitized()) ClipperLib::PolyTreeToPaths(sanitize(polypaths), polypaths);
pathsvector.push_back(polypaths);
@ -202,13 +201,13 @@ namespace ClipperUtils {
static void fill_minkowski_insides(const ClipperLib::Paths &a,
const ClipperLib::Paths &b,
ClipperLib::Paths &target) {
BOOST_FOREACH(const ClipperLib::Path &b_path, b) {
for(const auto &b_path : b) {
// We only need to add for positive components of b
if (!b_path.empty() && ClipperLib::Orientation(b_path) == 1) {
const ClipperLib::IntPoint &delta = b_path[0]; // arbitrary point
BOOST_FOREACH(const ClipperLib::Path &path, a) {
for(const auto &path : a) {
target.push_back(path);
BOOST_FOREACH(ClipperLib::IntPoint &point, target.back()) {
for(auto &point : target.back()) {
point.X += delta.X;
point.Y += delta.Y;
}
@ -229,8 +228,8 @@ namespace ClipperUtils {
ClipperLib::Paths rhs = ClipperUtils::fromPolygon2d(*polygons[i]);
// First, convolve each outline of lhs with the outlines of rhs
BOOST_FOREACH(ClipperLib::Path const& rhs_path, rhs) {
BOOST_FOREACH(ClipperLib::Path const& lhs_path, lhs) {
for(auto const& rhs_path : rhs) {
for(auto const& lhs_path : lhs) {
ClipperLib::Paths result;
minkowski_outline(lhs_path, rhs_path, result, true, true);
minkowski_terms.insert(minkowski_terms.end(), result.begin(), result.end());

View file

@ -31,7 +31,7 @@
#include "printutils.h"
#include <sstream>
#include <assert.h>
#include <boost/unordered/unordered_map.hpp>
#include <unordered_map>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/assign/list_of.hpp>
@ -45,7 +45,7 @@ public:
virtual AbstractNode *instantiate(const Context *ctx, const ModuleInstantiation *inst, EvalContext *evalctx) const;
private:
boost::unordered_map<std::string, Color4f> webcolors;
std::unordered_map<std::string, Color4f> webcolors;
};
ColorModule::ColorModule()
@ -204,7 +204,7 @@ ColorModule::ColorModule()
// additional OpenSCAD specific entry
("transparent", Color4f(0, 0, 0, 0))
.convert_to_container<boost::unordered_map<std::string, Color4f> >();
.convert_to_container<std::unordered_map<std::string, Color4f>>();
}
ColorModule::~ColorModule()

View file

@ -280,7 +280,7 @@ void ColorMap::enumerateColorSchemesInPath(colorscheme_set_t &result_set, const
RenderColorScheme *colorScheme = new RenderColorScheme(path);
if (colorScheme->valid() && (findColorScheme(colorScheme->name()) == 0)) {
result_set.insert(colorscheme_set_t::value_type(colorScheme->index(), boost::shared_ptr<RenderColorScheme>(colorScheme)));
result_set.insert(colorscheme_set_t::value_type(colorScheme->index(), shared_ptr<RenderColorScheme>(colorScheme)));
PRINTDB("Found file '%s' with color scheme '%s' and index %d",
colorScheme->path() % colorScheme->name() % colorScheme->index());
} else {
@ -297,7 +297,7 @@ ColorMap::colorscheme_set_t ColorMap::enumerateColorSchemes()
RenderColorScheme *defaultColorScheme = new RenderColorScheme();
result_set.insert(colorscheme_set_t::value_type(defaultColorScheme->index(),
boost::shared_ptr<RenderColorScheme>(defaultColorScheme)));
shared_ptr<RenderColorScheme>(defaultColorScheme)));
enumerateColorSchemesInPath(result_set, PlatformUtils::resourceBasePath());
enumerateColorSchemesInPath(result_set, PlatformUtils::userConfigPath());

View file

@ -5,7 +5,7 @@
#include <list>
#include "linalg.h"
#include <boost/shared_ptr.hpp>
#include "memory.h"
#include <boost/filesystem.hpp>
#include <boost/property_tree/ptree.hpp>
@ -68,7 +68,7 @@ private:
class ColorMap
{
typedef std::multimap<int, boost::shared_ptr<RenderColorScheme>, std::less<int> > colorscheme_set_t;
typedef std::multimap<int, shared_ptr<RenderColorScheme>, std::less<int>> colorscheme_set_t;
public:
static ColorMap *inst(bool erase = false);

View file

@ -31,7 +31,6 @@
#include "module.h"
#include "builtin.h"
#include "printutils.h"
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#include "boosty.h"
@ -77,7 +76,7 @@ Context::~Context()
void Context::setVariables(const AssignmentList &args,
const EvalContext *evalctx)
{
BOOST_FOREACH(const Assignment &arg, args) {
for(const auto &arg : args) {
set_variable(arg.first, arg.second ? arg.second->evaluate(this->parent) : ValuePtr::undefined);
}
@ -215,20 +214,20 @@ std::string Context::dump(const AbstractModule *mod, const ModuleInstantiation *
const Module *m = dynamic_cast<const Module*>(mod);
if (m) {
s << " module args:";
BOOST_FOREACH(const Assignment &arg, m->definition_arguments) {
for(const auto &arg : m->definition_arguments) {
s << boost::format(" %s = %s") % arg.first % variables[arg.first];
}
}
}
typedef std::pair<std::string, ValuePtr> ValueMapType;
s << " vars:";
BOOST_FOREACH(const ValueMapType &v, constants) {
for(const auto &v : constants) {
s << boost::format(" %s = %s") % v.first % v.second;
}
BOOST_FOREACH(const ValueMapType &v, variables) {
for(const auto &v : variables) {
s << boost::format(" %s = %s") % v.first % v.second;
}
BOOST_FOREACH(const ValueMapType &v, config_variables) {
for(const auto &v : config_variables) {
s << boost::format(" %s = %s") % v.first % v.second;
}
return s.str();

View file

@ -2,7 +2,7 @@
#include <string>
#include <vector>
#include <boost/unordered_map.hpp>
#include <unordered_map>
#include "value.h"
#include "typedefs.h"
#include "memory.h"
@ -40,7 +40,7 @@ protected:
const Context *parent;
Stack *ctx_stack;
typedef boost::unordered_map<std::string, ValuePtr> ValueMap;
typedef std::unordered_map<std::string, ValuePtr> ValueMap;
ValueMap constants;
ValueMap variables;
ValueMap config_variables;

View file

@ -24,7 +24,6 @@
*
*/
#include <boost/foreach.hpp>
#include "module.h"
#include "node.h"
#include "evalcontext.h"
@ -33,11 +32,6 @@
#include "builtin.h"
#include "printutils.h"
#include <sstream>
#include "mathc99.h"
#define foreach BOOST_FOREACH
class ControlModule : public AbstractModule
{
@ -104,7 +98,7 @@ void ControlModule::for_eval(AbstractNode &node, const ModuleInstantiation &inst
// At this point, the for loop variables have been set and we can initialize
// the local scope (as they may depend on the for loop variables
Context c(ctx);
BOOST_FOREACH(const Assignment &ass, inst.scope.assignments) {
for(const auto &ass : inst.scope.assignments) {
c.set_variable(ass.first, ass.second->evaluate(&c));
}
@ -229,7 +223,7 @@ AbstractNode *ControlModule::instantiate(const Context* /*ctx*/, const ModuleIns
else if (value->type() == Value::VECTOR) {
AbstractNode* node = new GroupNode(inst);
const Value::VectorType& vect = value->toVector();
foreach (const ValuePtr &vectvalue, vect) {
for(const auto &vectvalue : vect) {
AbstractNode* childnode = getChild(vectvalue,modulectx);
if (childnode==NULL) continue; // error
node->children.push_back(childnode);

View file

@ -83,7 +83,7 @@ struct Default_polyhedron_for_Chull_3{
};
template <class K>
struct Default_polyhedron_for_Chull_3<Convex_hull_traits_3<K> >{
struct Default_polyhedron_for_Chull_3<Convex_hull_traits_3<K>>{
typedef typename Convex_hull_traits_3<K>::Polyhedron_3 type;
};
@ -704,8 +704,8 @@ ch_quickhull_polyhedron_3(std::list<typename Traits::Point_3>& points,
typedef typename std::list<Point_3>::iterator P3_iterator;
typedef Triangulation_data_structure_2<
Triangulation_vertex_base_with_info_2<int, GT3_for_CH3<Traits> >,
Convex_hull_face_base_2<int, Traits> > Tds;
Triangulation_vertex_base_with_info_2<int, GT3_for_CH3<Traits>>,
Convex_hull_face_base_2<int, Traits>> Tds;
typedef typename Tds::Vertex_handle Vertex_handle;
typedef typename Tds::Face_handle Face_handle;

View file

@ -28,7 +28,6 @@
#include "Geometry.h"
#include "linalg.h"
#include <sstream>
#include <boost/foreach.hpp>
#include <boost/range/iterator_range.hpp>
/*!
@ -194,12 +193,12 @@ std::string CSGProduct::dump() const
{
std::stringstream dump;
dump << this->intersections.front().leaf->label;
BOOST_FOREACH(const CSGChainObject &csgobj,
for(const auto &csgobj :
boost::make_iterator_range(this->intersections.begin() + 1,
this->intersections.end())) {
dump << " *" << csgobj.leaf->label;
}
BOOST_FOREACH(const CSGChainObject &csgobj, this->subtractions) {
for(const auto &csgobj : this->subtractions) {
dump << " -" << csgobj.leaf->label;
}
return dump.str();
@ -208,7 +207,7 @@ std::string CSGProduct::dump() const
BoundingBox CSGProduct::getBoundingBox() const
{
BoundingBox bbox;
BOOST_FOREACH(const CSGChainObject &csgobj, this->intersections) {
for(const auto &csgobj : this->intersections) {
if (csgobj.leaf->geom) {
BoundingBox psbox = csgobj.leaf->geom->getBoundingBox();
// FIXME: Should intersect rather than extend
@ -222,7 +221,7 @@ std::string CSGProducts::dump() const
{
std::stringstream dump;
BOOST_FOREACH(const CSGProduct &product, this->products) {
for(const auto &product : this->products) {
dump << "+" << product.dump() << "\n";
}
return dump.str();
@ -231,7 +230,7 @@ std::string CSGProducts::dump() const
BoundingBox CSGProducts::getBoundingBox() const
{
BoundingBox bbox;
BOOST_FOREACH(const CSGProduct &product, this->products) {
for(const auto &product : this->products) {
bbox.extend(product.getBoundingBox());
}
return bbox;
@ -240,7 +239,7 @@ BoundingBox CSGProducts::getBoundingBox() const
size_t CSGProducts::size() const
{
size_t count = 0;
BOOST_FOREACH(const CSGProduct &product, this->products) {
for(const auto &product : this->products) {
count += product.intersections.size() + product.subtractions.size();
}
return count;

View file

@ -31,10 +31,8 @@
#include "calc.h"
#include <fstream>
#include "mathc99.h"
#include <assert.h>
#include <boost/unordered_map.hpp>
#include <boost/foreach.hpp>
#include <unordered_map>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <algorithm>
@ -85,9 +83,9 @@ DxfData::DxfData(double fn, double fs, double fa,
return;
}
Grid2d< std::vector<int> > grid(GRID_COARSE);
Grid2d< std::vector<int>> grid(GRID_COARSE);
std::vector<Line> lines; // Global lines
boost::unordered_map< std::string, std::vector<Line> > blockdata; // Lines in blocks
std::unordered_map< std::string, std::vector<Line>> blockdata; // Lines in blocks
bool in_entities_section = false;
bool in_blocks_section = false;
@ -125,7 +123,7 @@ DxfData::DxfData(double fn, double fs, double fa,
for (int j = 0; j < 2; j++)
coords[i][j] = 0;
typedef boost::unordered_map<std::string, int> EntityList;
typedef std::unordered_map<std::string, int> EntityList;
EntityList unsupported_entities_list;
//
@ -392,7 +390,7 @@ DxfData::DxfData(double fn, double fs, double fa,
}
}
BOOST_FOREACH(const EntityList::value_type &i, unsupported_entities_list) {
for(const auto &i : unsupported_entities_list) {
if (layername.empty()) {
PRINTB("WARNING: Unsupported DXF Entity '%s' (%x) in %s.",
i.first % i.second % QuotedString(boosty::stringy(boostfs_uncomplete(filename, fs::current_path()))));
@ -415,7 +413,7 @@ DxfData::DxfData(double fn, double fs, double fa,
{
int current_line, current_point;
BOOST_FOREACH(const LineMap::value_type &l, enabled_lines) {
for(const auto &l : enabled_lines) {
int idx = l.second;
for (int j = 0; j < 2; j++) {
std::vector<int> *lv = &grid.data(this->points[lines[idx].idx[j]][0], this->points[lines[idx].idx[j]][1]);

View file

@ -33,14 +33,13 @@
#include "fileutils.h"
#include "evalcontext.h"
#include "mathc99.h"
#include <cmath>
#include <sstream>
#include <stdint.h>
#include <cstdint>
#include <boost/filesystem.hpp>
boost::unordered_map<std::string, ValuePtr> dxf_dim_cache;
boost::unordered_map<std::string, ValuePtr> dxf_cross_cache;
std::unordered_map<std::string, ValuePtr> dxf_dim_cache;
std::unordered_map<std::string, ValuePtr> dxf_cross_cache;
namespace fs = boost::filesystem;
ValuePtr builtin_dxf_dim(const Context *ctx, const EvalContext *evalctx)
@ -98,7 +97,7 @@ ValuePtr builtin_dxf_dim(const Context *ctx, const EvalContext *evalctx)
double x = d->coords[4][0] - d->coords[3][0];
double y = d->coords[4][1] - d->coords[3][1];
double angle = d->angle;
double distance_projected_on_line = fabs(x * cos(angle*M_PI/180) + y * sin(angle*M_PI/180));
double distance_projected_on_line = std::fabs(x * cos(angle*M_PI/180) + y * sin(angle*M_PI/180));
return dxf_dim_cache[key] = ValuePtr(distance_projected_on_line);
}
else if (type == 1) {
@ -111,7 +110,7 @@ ValuePtr builtin_dxf_dim(const Context *ctx, const EvalContext *evalctx)
// Angular
double a1 = atan2(d->coords[0][0] - d->coords[5][0], d->coords[0][1] - d->coords[5][1]);
double a2 = atan2(d->coords[4][0] - d->coords[3][0], d->coords[4][1] - d->coords[3][1]);
return dxf_dim_cache[key] = ValuePtr(fabs(a1 - a2) * 180 / M_PI);
return dxf_dim_cache[key] = ValuePtr(std::fabs(a1 - a2) * 180 / M_PI);
}
else if (type == 3 || type == 4) {
// Diameter or Radius

View file

@ -1,7 +1,7 @@
#pragma once
#include <boost/unordered_map.hpp>
#include <unordered_map>
#include "value.h"
extern boost::unordered_map<std::string, ValuePtr> dxf_dim_cache;
extern boost::unordered_map<std::string, ValuePtr> dxf_cross_cache;
extern std::unordered_map<std::string, ValuePtr> dxf_dim_cache;
extern std::unordered_map<std::string, ValuePtr> dxf_cross_cache;

View file

@ -7,8 +7,6 @@
#include "localscope.h"
#include "exceptions.h"
#include <boost/foreach.hpp>
EvalContext::EvalContext(const Context *parent,
const AssignmentList &args, const class LocalScope *const scope)
: Context(parent), eval_arguments(args), scope(scope)
@ -44,7 +42,7 @@ ModuleInstantiation *EvalContext::getChild(size_t i) const
void EvalContext::assignTo(Context &target) const
{
BOOST_FOREACH(const Assignment &assignment, this->eval_arguments) {
for(const auto &assignment : this->eval_arguments) {
ValuePtr v;
if (assignment.second) v = assignment.second->evaluate(&target);
if (target.has_local_variable(assignment.first)) {
@ -71,7 +69,7 @@ std::string EvalContext::dump(const AbstractModule *mod, const ModuleInstantiati
}
if (this->scope && this->scope->children.size() > 0) {
s << boost::format(" children:");
BOOST_FOREACH(const ModuleInstantiation *ch, this->scope->children) {
for(const auto &ch : this->scope->children) {
s << boost::format(" %s") % ch->name();
}
}
@ -79,7 +77,7 @@ std::string EvalContext::dump(const AbstractModule *mod, const ModuleInstantiati
const Module *m = dynamic_cast<const Module*>(mod);
if (m) {
s << boost::format(" module args:");
BOOST_FOREACH(const Assignment &arg, m->definition_arguments) {
for(const auto &arg : m->definition_arguments) {
s << boost::format(" %s = %s") % arg.first % *(variables[arg.first]);
}
}

View file

@ -29,8 +29,6 @@
#include "polyset-utils.h"
#include "dxfdata.h"
#include <boost/foreach.hpp>
#ifdef ENABLE_CGAL
#include "CGAL_Nef_polyhedron.h"
#include "cgal.h"

View file

@ -29,8 +29,6 @@
#include "polyset-utils.h"
#include "dxfdata.h"
#include <boost/foreach.hpp>
/*!
Saves the current Polygon2d as DXF to the given absolute filename.
*/
@ -49,7 +47,7 @@ void export_dxf(const Polygon2d &poly, std::ostream &output)
<< " 2\n"
<< "ENTITIES\n";
BOOST_FOREACH(const Outline2d &o, poly.outlines()) {
for(const auto &o : poly.outlines()) {
for (unsigned int i=0;i<o.vertices.size();i++) {
const Vector2d &p1 = o.vertices[i];
const Vector2d &p2 = o.vertices[(i+1)%o.vertices.size()];

View file

@ -29,8 +29,6 @@
#include "polyset-utils.h"
#include "dxfdata.h"
#include <boost/foreach.hpp>
#ifdef ENABLE_CGAL
#include "CGAL_Nef_polyhedron.h"
#include "cgal.h"
@ -50,8 +48,8 @@ struct IndexedMesh {
static void append_geometry(const PolySet &ps, IndexedMesh &mesh)
{
BOOST_FOREACH(const Polygon &p, ps.polygons) {
BOOST_FOREACH(const Vector3d &v, p) {
for(const auto &p : ps.polygons) {
for(const auto &v : p) {
mesh.indices.push_back(mesh.vertices.lookup(v));
}
mesh.numfaces++;

View file

@ -29,8 +29,6 @@
#include "polyset-utils.h"
#include "dxfdata.h"
#include <boost/foreach.hpp>
#ifdef ENABLE_CGAL
#include "CGAL_Nef_polyhedron.h"
#include "cgal.h"
@ -42,7 +40,7 @@ static void append_stl(const PolySet &ps, std::ostream &output)
PolysetUtils::tessellate_faces(ps, triangulated);
setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output
BOOST_FOREACH(const Polygon &p, triangulated.polygons) {
for(const auto &p : triangulated.polygons) {
assert(p.size() == 3); // STL only allows triangles
std::stringstream stream;
stream << p[0][0] << " " << p[0][1] << " " << p[0][2];
@ -70,7 +68,7 @@ static void append_stl(const PolySet &ps, std::ostream &output)
}
output << " outer loop\n";
BOOST_FOREACH(const Vector3d &v, p) {
for(const auto &v : p) {
output << " vertex " << v[0] << " " << v[1] << " " << v[2] << "\n";
}
output << " endloop\n";

View file

@ -28,12 +28,10 @@
#include "polyset.h"
#include "polyset-utils.h"
#include <boost/foreach.hpp>
static void append_svg(const Polygon2d &poly, std::ostream &output)
{
output << "<path d=\"\n";
BOOST_FOREACH(const Outline2d &o, poly.outlines()) {
for(const auto &o : poly.outlines()) {
if (o.vertices.empty()) {
continue;
}

View file

@ -35,7 +35,6 @@
#include "exceptions.h"
#include "feature.h"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
// unnamed namespace
namespace {
@ -399,7 +398,7 @@ ExpressionVector::ExpressionVector(Expression *expr) : Expression(expr)
ValuePtr ExpressionVector::evaluate(const Context *context) const
{
Value::VectorType vec;
BOOST_FOREACH(const Expression *e, this->children) {
for(const auto &e : this->children) {
ValuePtr tmpval = e->evaluate(context);
if (e->isListComprehension()) {
const Value::VectorType result = tmpval->toVector();

View file

@ -24,24 +24,24 @@
*
*/
#include "mathc99.h"
#define _USE_MATH_DEFINES // M_SQRT1_2
#include "math.h"
#include "function.h"
#include "expression.h"
#include "evalcontext.h"
#include "builtin.h"
#include <sstream>
#include <ctime>
#include <limits>
#include <algorithm>
#include "stl-utils.h"
#include "printutils.h"
#include "stackcheck.h"
#include "exceptions.h"
#include <boost/foreach.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
using boost::math::isnan;
using boost::math::isinf;
#include <cmath>
#include <sstream>
#include <ctime>
#include <cmath>
#include <limits>
#include <algorithm>
/*
Random numbers
@ -216,7 +216,7 @@ ValuePtr builtin_abs(const Context *, const EvalContext *evalctx)
if (evalctx->numArgs() == 1) {
ValuePtr v = evalctx->getArgValue(0);
if (v->type() == Value::NUMBER)
return ValuePtr(fabs(v->toDouble()));
return ValuePtr(std::fabs(v->toDouble()));
}
return ValuePtr::undefined;
}
@ -226,7 +226,7 @@ ValuePtr builtin_sign(const Context *, const EvalContext *evalctx)
if (evalctx->numArgs() == 1) {
ValuePtr v = evalctx->getArgValue(0);
if (v->type() == Value::NUMBER) {
register double x = v->toDouble();
double x = v->toDouble();
return ValuePtr((x<0) ? -1.0 : ((x>0) ? 1.0 : 0.0));
}
}
@ -241,7 +241,7 @@ ValuePtr builtin_rands(const Context *, const EvalContext *evalctx)
if (v0->type() != Value::NUMBER) goto quit;
double min = v0->toDouble();
if (boost::math::isinf(min)) {
if (std::isinf(min)) {
PRINT("WARNING: rands() range min cannot be infinite");
min = -std::numeric_limits<double>::max()/2;
PRINTB("WARNING: resetting to %f",min);
@ -249,18 +249,18 @@ ValuePtr builtin_rands(const Context *, const EvalContext *evalctx)
ValuePtr v1 = evalctx->getArgValue(1);
if (v1->type() != Value::NUMBER) goto quit;
double max = v1->toDouble();
if (boost::math::isinf(max)) {
if (std::isinf(max)) {
PRINT("WARNING: rands() range max cannot be infinite");
max = std::numeric_limits<double>::max()/2;
PRINTB("WARNING: resetting to %f",max);
}
if (max < min) {
register double tmp = min; min = max; max = tmp;
double tmp = min; min = max; max = tmp;
}
ValuePtr v2 = evalctx->getArgValue(2);
if (v2->type() != Value::NUMBER) goto quit;
double numresultsd = std::abs( v2->toDouble() );
if (boost::math::isinf(numresultsd)) {
if (std::isinf(numresultsd)) {
PRINT("WARNING: rands() cannot create an infinite number of results");
PRINT("WARNING: resetting number of results to 1");
numresultsd = 1;
@ -318,7 +318,7 @@ ValuePtr builtin_min(const Context *, const EvalContext *evalctx)
// 4/20/14 semantic change per discussion:
// break on any non-number
if (v->type() != Value::NUMBER) goto quit;
register double x = v->toDouble();
double x = v->toDouble();
if (x < val) val = x;
}
return ValuePtr(val);
@ -350,7 +350,7 @@ ValuePtr builtin_max(const Context *, const EvalContext *evalctx)
// 4/20/14 semantic change per discussion:
// break on any non-number
if (v->type() != Value::NUMBER) goto quit;
register double x = v->toDouble();
double x = v->toDouble();
if (x > val) val = x;
}
return ValuePtr(val);
@ -364,7 +364,7 @@ quit:
// comment/undefine it to disable domain check
#define TRIG_HUGE_VAL ((1L<<26)*360.0*(1L<<26))
double sin_degrees(register double x)
double sin_degrees(double x)
{
// use positive tests because of possible Inf/NaN
if (x < 360.0 && x >= 0.0) {
@ -374,7 +374,7 @@ double sin_degrees(register double x)
if (x < TRIG_HUGE_VAL && x > -TRIG_HUGE_VAL)
#endif
{
register double revolutions = floor(x/360.0);
double revolutions = floor(x/360.0);
x -= 360.0*revolutions;
}
#ifdef TRIG_HUGE_VAL
@ -384,7 +384,7 @@ double sin_degrees(register double x)
return std::numeric_limits<double>::quiet_NaN();
}
#endif
register bool oppose = x >= 180.0;
bool oppose = x >= 180.0;
if (oppose) x -= 180.0;
if (x > 90.0) x = 180.0 - x;
if (x < 45.0) {
@ -408,7 +408,7 @@ ValuePtr builtin_sin(const Context *, const EvalContext *evalctx)
return ValuePtr::undefined;
}
double cos_degrees(register double x)
double cos_degrees(double x)
{
// use positive tests because of possible Inf/NaN
if (x < 360.0 && x >= 0.0) {
@ -418,7 +418,7 @@ double cos_degrees(register double x)
if (x < TRIG_HUGE_VAL && x > -TRIG_HUGE_VAL)
#endif
{
register double revolutions = floor(x/360.0);
double revolutions = floor(x/360.0);
x -= 360.0*revolutions;
}
#ifdef TRIG_HUGE_VAL
@ -428,7 +428,7 @@ double cos_degrees(register double x)
return std::numeric_limits<double>::quiet_NaN();
}
#endif
register bool oppose = x >= 180.0;
bool oppose = x >= 180.0;
if (oppose) x -= 180.0;
if (x > 90.0) {
x = 180.0 - x;
@ -636,7 +636,7 @@ ValuePtr builtin_concat(const Context *, const EvalContext *evalctx)
for (size_t i = 0; i < evalctx->numArgs(); i++) {
ValuePtr val = evalctx->getArgValue(i);
if (val->type() == Value::VECTOR) {
BOOST_FOREACH(const ValuePtr &v, val->toVector()) {
for(const auto &v : val->toVector()) {
result.push_back(v);
}
} else {
@ -944,7 +944,7 @@ ValuePtr builtin_norm(const Context *, const EvalContext *evalctx)
for (size_t i = 0; i < n; i++)
if (v[i]->type() == Value::NUMBER) {
// sum += pow(v[i].toDouble(),2);
register double x = v[i]->toDouble();
double x = v[i]->toDouble();
sum += x*x;
} else {
PRINT("WARNING: Incorrect arguments to norm()");
@ -987,11 +987,11 @@ ValuePtr builtin_cross(const Context *, const EvalContext *evalctx)
}
double d0 = v0[a]->toDouble();
double d1 = v1[a]->toDouble();
if (boost::math::isnan(d0) || boost::math::isnan(d1)) {
if (std::isnan(d0) || std::isnan(d1)) {
PRINT("WARNING: Invalid value (NaN) in parameter vector for cross()");
return ValuePtr::undefined;
}
if (boost::math::isinf(d0) || boost::math::isinf(d1)) {
if (std::isinf(d0) || std::isinf(d1)) {
PRINT("WARNING: Invalid value (INF) in parameter vector for cross()");
return ValuePtr::undefined;
}

View file

@ -1,19 +0,0 @@
#include "grid.h"
namespace Eigen {
size_t hash_value(Vector3f const &v) {
size_t seed = 0;
for (int i=0;i<3;i++) boost::hash_combine(seed, v[i]);
return seed;
}
size_t hash_value(Vector3d const &v) {
size_t seed = 0;
for (int i=0;i<3;i++) boost::hash_combine(seed, v[i]);
return seed;
}
size_t hash_value(Eigen::Matrix<int64_t, 3, 1> const &v) {
size_t seed = 0;
for (int i=0;i<3;i++) boost::hash_combine(seed, v[i]);
return seed;
}
}

View file

@ -1,15 +1,12 @@
#pragma once
#include "mathc99.h"
#include "linalg.h"
#include "hash.h"
#include <boost/functional/hash.hpp>
#include <cmath>
#ifdef _WIN32
typedef __int64 int64_t;
#else
#include <stdint.h>
#endif
#include <stdlib.h>
#include <boost/unordered_map.hpp>
#include <cstdint> // int64_t
#include <unordered_map>
#include <utility>
//const double GRID_COARSE = 0.001;
@ -27,7 +24,7 @@ class Grid2d
{
public:
double res;
boost::unordered_map<std::pair<int64_t,int64_t>, T> db;
std::unordered_map<std::pair<int64_t,int64_t>, T, boost::hash<std::pair<int64_t,int64_t>>> db;
Grid2d(double resolution) {
res = resolution;
@ -38,8 +35,8 @@ public:
if not.
*/
T &align(double &x, double &y) {
int64_t ix = (int64_t)round(x / res);
int64_t iy = (int64_t)round(y / res);
int64_t ix = (int64_t)std::round(x / res);
int64_t iy = (int64_t)std::round(y / res);
if (db.find(std::make_pair(ix, iy)) == db.end()) {
int dist = 10;
for (int64_t jx = ix - 1; jx <= ix + 1; jx++) {
@ -60,8 +57,8 @@ public:
}
bool has(double x, double y) const {
int64_t ix = (int64_t)round(x / res);
int64_t iy = (int64_t)round(y / res);
int64_t ix = (int64_t)std::round(x / res);
int64_t iy = (int64_t)std::round(y / res);
if (db.find(std::make_pair(ix, iy)) != db.end())
return true;
for (int64_t jx = ix - 1; jx <= ix + 1; jx++)
@ -87,21 +84,13 @@ public:
}
};
typedef Eigen::Matrix<int64_t, 3, 1> Vector3l;
namespace Eigen {
size_t hash_value(Vector3f const &v);
size_t hash_value(Vector3d const &v);
size_t hash_value(Vector3l const &v);
}
template <typename T>
class Grid3d
{
public:
double res;
typedef Vector3l Key;
typedef boost::unordered_map<Key, T> GridContainer;
typedef std::unordered_map<Key, T> GridContainer;
GridContainer db;
Grid3d(double resolution) {

View file

@ -2,14 +2,13 @@
#include <string>
#include <sstream>
#include <stdlib.h> // for system()
#include <boost/unordered_set.hpp>
#include <boost/foreach.hpp>
#include <unordered_set>
#include <boost/regex.hpp>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#include "boosty.h"
boost::unordered_set<std::string> dependencies;
std::unordered_set<std::string> dependencies;
const char *make_command = NULL;
void handle_dep(const std::string &filename)
@ -36,7 +35,7 @@ bool write_deps(const std::string &filename, const std::string &output_file)
}
fprintf(fp, "%s:", output_file.c_str());
BOOST_FOREACH(const std::string &str, dependencies) {
for(const auto &str : dependencies) {
fprintf(fp, " \\\n\t%s", str.c_str());
}
fprintf(fp, "\n");

32
src/hash.cc Normal file
View file

@ -0,0 +1,32 @@
#include "hash.h"
#include <boost/functional/hash.hpp>
namespace std {
std::size_t hash<Vector3f>::operator()(const Vector3f &s) const {
return Eigen::hash_value(s);
}
std::size_t hash<Vector3d>::operator()(const Vector3d &s) const {
return Eigen::hash_value(s);
}
std::size_t hash<Vector3l>::operator()(const Vector3l &s) const {
return Eigen::hash_value(s);
}
}
namespace Eigen {
size_t hash_value(Vector3f const &v) {
size_t seed = 0;
for (int i=0;i<3;i++) boost::hash_combine(seed, v[i]);
return seed;
}
size_t hash_value(Vector3d const &v) {
size_t seed = 0;
for (int i=0;i<3;i++) boost::hash_combine(seed, v[i]);
return seed;
}
size_t hash_value(Eigen::Matrix<int64_t, 3, 1> const &v) {
size_t seed = 0;
for (int i=0;i<3;i++) boost::hash_combine(seed, v[i]);
return seed;
}
}

17
src/hash.h Normal file
View file

@ -0,0 +1,17 @@
#pragma once
#include "linalg.h"
typedef Eigen::Matrix<int64_t, 3, 1> Vector3l;
namespace std {
template<> struct hash<Vector3f> { std::size_t operator()(const Vector3f &s) const; };
template<> struct hash<Vector3d> { std::size_t operator()(const Vector3d &s) const; };
template<> struct hash<Vector3l> { std::size_t operator()(const Vector3l &s) const; };
}
namespace Eigen {
size_t hash_value(Vector3f const &v);
size_t hash_value(Vector3d const &v);
size_t hash_value(Vector3l const &v);
}

View file

@ -54,7 +54,7 @@ using namespace boost::assign; // bring 'operator+=()' into scope
#include "boosty.h"
#include <boost/detail/endian.hpp>
#include <boost/cstdint.hpp>
#include <cstdint>
class ImportModule : public AbstractModule
{

View file

@ -41,12 +41,12 @@ LaunchingScreen::LaunchingScreen(QWidget *parent) : QDialog(parent)
this->recentList->addItem(item);
}
foreach(const QString &category, UIUtils::exampleCategories())
for(const auto &category : UIUtils::exampleCategories())
{
QFileInfoList examples = UIUtils::exampleFiles(category);
QTreeWidgetItem *categoryItem = new QTreeWidgetItem(QStringList(gettext(category.toStdString().c_str())));
foreach(const QFileInfo &example, examples)
for(const auto &example : examples)
{
QTreeWidgetItem *exampleItem = new QTreeWidgetItem(QStringList(example.fileName()));
exampleItem->setData(0, Qt::UserRole, example.canonicalFilePath());

View file

@ -34,7 +34,6 @@
#include "parser_yacc.h"
#include "module.h"
#include <assert.h>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
@ -292,7 +291,7 @@ void includefile()
*/
void lexerdestroy()
{
BOOST_FOREACH (FILE *f, openfiles) fclose(f);
for (auto f : openfiles) fclose(f);
openfiles.clear();
openfilenames.clear();
path_stack.clear();

View file

@ -1,5 +1,5 @@
#include "linalg.h"
#include <boost/math/special_functions/fpclassify.hpp>
#include <cmath>
// FIXME: We can achieve better pruning by either:
// o Recalculate the box based on the transformed object
@ -31,7 +31,7 @@ bool matrix_contains_infinity( const Transform3d &m )
{
for (int i=0;i<m.matrix().rows();i++) {
for (int j=0;j<m.matrix().cols();j++) {
if ((boost::math::isinf)(m(i,j))) return true;
if ((std::isinf)(m(i,j))) return true;
}
}
return false;
@ -41,7 +41,7 @@ bool matrix_contains_nan( const Transform3d &m )
{
for (int i=0;i<m.matrix().rows();i++) {
for (int j=0;j<m.matrix().cols();j++) {
if ((boost::math::isnan)(m(i,j))) return true;
if ((std::isnan)(m(i,j))) return true;
}
}
return false;

View file

@ -3,16 +3,11 @@
#include <Eigen/Core>
#include <Eigen/Geometry>
#include <Eigen/Dense>
#include <Eigen/StdVector>
#include <boost/cstdint.hpp>
#include <cstdint>
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector2d)
using Eigen::Vector2d;
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3d)
using Eigen::Vector3d;
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3f)
using Eigen::Vector3f;
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3i)
using Eigen::Vector3i;
typedef Eigen::AlignedBox<double, 3> BoundingBox;

View file

@ -33,8 +33,8 @@
#include "builtin.h"
#include "calc.h"
#include "polyset.h"
#include "mathc99.h"
#include <cmath>
#include <sstream>
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope

View file

@ -5,17 +5,15 @@
#include "expression.h"
#include "function.h"
#include <boost/foreach.hpp>
LocalScope::LocalScope()
{
}
LocalScope::~LocalScope()
{
BOOST_FOREACH (ModuleInstantiation *v, children) delete v;
BOOST_FOREACH (FunctionContainer::value_type &f, functions) delete f.second;
BOOST_FOREACH (AbstractModuleContainer::value_type &m, modules) delete m.second;
for(auto &v : children) delete v;
for(auto &f : functions) delete f.second;
for(auto &m : modules) delete m.second;
}
void LocalScope::addChild(ModuleInstantiation *ch)
@ -27,16 +25,16 @@ void LocalScope::addChild(ModuleInstantiation *ch)
std::string LocalScope::dump(const std::string &indent) const
{
std::stringstream dump;
BOOST_FOREACH(const FunctionContainer::value_type &f, this->functions) {
for(const auto &f : this->functions) {
dump << f.second->dump(indent, f.first);
}
BOOST_FOREACH(const AbstractModuleContainer::value_type &m, this->modules) {
for(const auto &m : this->modules) {
dump << m.second->dump(indent, m.first);
}
BOOST_FOREACH(const Assignment &ass, this->assignments) {
for(const auto &ass : this->assignments) {
dump << indent << ass.first << " = " << *ass.second << ";\n";
}
BOOST_FOREACH(const ModuleInstantiation *inst, this->children) {
for(const auto &inst : this->children) {
dump << inst->dump(indent);
}
return dump.str();
@ -45,7 +43,7 @@ std::string LocalScope::dump(const std::string &indent) const
std::vector<AbstractNode*> LocalScope::instantiateChildren(const Context *evalctx) const
{
std::vector<AbstractNode*> childnodes;
BOOST_FOREACH (ModuleInstantiation *modinst, this->children) {
for(const auto &modinst : this->children) {
AbstractNode *node = modinst->evaluate(evalctx);
if (node) childnodes.push_back(node);
}
@ -62,7 +60,7 @@ std::vector<AbstractNode*> LocalScope::instantiateChildren(const Context *evalct
*/
void LocalScope::apply(Context &ctx) const
{
BOOST_FOREACH(const Assignment &ass, this->assignments) {
for(const auto &ass : this->assignments) {
ctx.set_variable(ass.first, ass.second->evaluate(&ctx));
}
}

View file

@ -1,7 +1,7 @@
#pragma once
#include "typedefs.h"
#include <boost/unordered_map.hpp>
#include <unordered_map>
class LocalScope
{
@ -17,8 +17,8 @@ public:
AssignmentList assignments;
ModuleInstantiationList children;
typedef boost::unordered_map<std::string, class AbstractFunction*> FunctionContainer;
typedef std::unordered_map<std::string, class AbstractFunction*> FunctionContainer;
FunctionContainer functions;
typedef boost::unordered_map<std::string, class AbstractModule*> AbstractModuleContainer;
typedef std::unordered_map<std::string, class AbstractModule*> AbstractModuleContainer;
AbstractModuleContainer modules;
};

View file

@ -107,7 +107,6 @@
#include <algorithm>
#include <boost/version.hpp>
#include <boost/foreach.hpp>
#include <sys/stat.h>
#ifdef ENABLE_CGAL
@ -585,20 +584,20 @@ void MainWindow::initActionIcon(QAction *action, const char *darkResource, const
void MainWindow::addKeyboardShortCut(const QList<QAction *> &actions)
{
foreach (QAction *action, actions) {
// prevent adding shortcut twice if action is added to multiple toolbars
if (action->toolTip().contains("&nbsp;")) {
for (auto &action : actions) {
// prevent adding shortcut twice if action is added to multiple toolbars
if (action->toolTip().contains("&nbsp;")) {
continue;
}
const QString shortCut(action->shortcut().toString(QKeySequence::NativeText));
if (shortCut.isEmpty()) {
}
const QString shortCut(action->shortcut().toString(QKeySequence::NativeText));
if (shortCut.isEmpty()) {
continue;
}
const QString toolTip("%1 &nbsp;<span style=\"color: gray; font-size: small; font-style: italic\">%2</span>");
action->setToolTip(toolTip.arg(action->toolTip(), shortCut));
}
const QString toolTip("%1 &nbsp;<span style=\"color: gray; font-size: small; font-style: italic\">%2</span>");
action->setToolTip(toolTip.arg(action->toolTip(), shortCut));
}
}
void MainWindow::loadViewSettings(){
@ -788,7 +787,7 @@ void MainWindow::updateRecentFiles()
while (files.size() > UIUtils::maxRecentFiles) files.removeLast();
settings.setValue("recentFileList", files);
foreach(QWidget *widget, QApplication::topLevelWidgets()) {
for(auto &widget : QApplication::topLevelWidgets()) {
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
if (mainWin) {
mainWin->updateRecentFileActions();
@ -1274,11 +1273,11 @@ void MainWindow::show_examples()
{
bool found_example = false;
foreach (const QString &cat, UIUtils::exampleCategories()) {
for (const auto &cat : UIUtils::exampleCategories()) {
QFileInfoList examples = UIUtils::exampleFiles(cat);
QMenu *menu = this->menuExamples->addMenu(gettext(cat.toStdString().c_str()));
foreach(const QFileInfo &ex, examples) {
for(const auto &ex : examples) {
QAction *openAct = new QAction(ex.fileName(), this);
connect(openAct, SIGNAL(triggered()), this, SLOT(actionOpenExample()));
menu->addAction(openAct);

View file

@ -1,22 +0,0 @@
#include "mathc99.h"
#ifdef WIN32
#include <algorithm>
double trunc(double a) {
return (a >= 0) ? floor(a) : ceil(a);
}
double round(double a) {
return a < 0 ? ceil(a - 0.5f) : floor(a + 0.5f);
}
float fmin(float a, float b) {
return std::min(a,b);
}
float fmax(float a, float b) {
return std::max(a,b);
}
#endif

View file

@ -1,19 +0,0 @@
#pragma once
#if defined(_MSC_VER)
// only for native windows builds, not MXE
#include <cmath>
//for native win32 builds we need to provide C99 math functions by ourselves
double trunc(double a);
double round(double a);
float fmin(float a, float b);
float fmax(float a, float b);
#else
#define _USE_MATH_DEFINES
#include <math.h>
#endif

View file

@ -1,8 +1,7 @@
#pragma once
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
using boost::shared_ptr;
using boost::make_shared;
using boost::dynamic_pointer_cast;
using boost::static_pointer_cast;
#include <memory>
using std::shared_ptr;
using std::make_shared;
using std::dynamic_pointer_cast;
using std::static_pointer_cast;

View file

@ -1,4 +1,6 @@
#include "mathc99.h"
#define _USE_MATH_DEFINES // M_PI
#include "math.h"
#include "modcontext.h"
#include "module.h"
#include "expression.h"
@ -6,8 +8,7 @@
#include "printutils.h"
#include "builtin.h"
#include "ModuleCache.h"
#include <boost/foreach.hpp>
#include <cmath>
ModuleContext::ModuleContext(const Context *parent, const EvalContext *evalctx)
: Context(parent), functions_p(NULL), modules_p(NULL), evalctx(evalctx)
@ -24,7 +25,7 @@ void ModuleContext::evaluateAssignments(const AssignmentList &assignments)
{
// First, assign all simple variables
std::list<std::string> undefined_vars;
BOOST_FOREACH(const Assignment &ass, assignments) {
for(const auto &ass : assignments) {
ValuePtr tmpval = ass.second->evaluate(this);
if (tmpval->isUndefined()) undefined_vars.push_back(ass.first);
else this->set_variable(ass.first, tmpval);
@ -33,8 +34,8 @@ void ModuleContext::evaluateAssignments(const AssignmentList &assignments)
// Variables which couldn't be evaluated in the first pass is attempted again,
// to allow for initialization out of order
boost::unordered_map<std::string, Expression *> tmpass;
BOOST_FOREACH (const Assignment &ass, assignments) {
std::unordered_map<std::string, Expression *> tmpass;
for(const auto &ass : assignments) {
tmpass[ass.first] = ass.second;
}
@ -44,7 +45,7 @@ void ModuleContext::evaluateAssignments(const AssignmentList &assignments)
std::list<std::string>::iterator iter = undefined_vars.begin();
while (iter != undefined_vars.end()) {
std::list<std::string>::iterator curr = iter++;
boost::unordered_map<std::string, Expression *>::iterator found = tmpass.find(*curr);
std::unordered_map<std::string, Expression *>::iterator found = tmpass.find(*curr);
if (found != tmpass.end()) {
const Expression *expr = found->second;
ValuePtr tmpval = expr->evaluate(this);
@ -69,7 +70,7 @@ void ModuleContext::initializeModule(const class Module &module)
// FIXME: Don't access module members directly
this->functions_p = &module.scope.functions;
this->modules_p = &module.scope.modules;
BOOST_FOREACH(const Assignment &ass, module.scope.assignments) {
for(const auto &ass : module.scope.assignments) {
this->set_variable(ass.first, ass.second->evaluate(this));
}
@ -87,7 +88,7 @@ void ModuleContext::registerBuiltin()
// FIXME: Don't access module members directly
this->functions_p = &scope.functions;
this->modules_p = &scope.modules;
BOOST_FOREACH(const Assignment &ass, scope.assignments) {
for(const auto &ass : scope.assignments) {
this->set_variable(ass.first, ass.second->evaluate(this));
}
@ -154,20 +155,20 @@ std::string ModuleContext::dump(const AbstractModule *mod, const ModuleInstantia
const Module *m = dynamic_cast<const Module*>(mod);
if (m) {
s << " module args:";
BOOST_FOREACH(const Assignment &arg, m->definition_arguments) {
for(const auto &arg : m->definition_arguments) {
s << boost::format(" %s = %s") % arg.first % variables[arg.first];
}
}
}
typedef std::pair<std::string, ValuePtr> ValueMapType;
s << " vars:";
BOOST_FOREACH(const ValueMapType &v, constants) {
for(const auto &v : constants) {
s << boost::format(" %s = %s") % v.first % v.second;
}
BOOST_FOREACH(const ValueMapType &v, variables) {
for(const auto &v : variables) {
s << boost::format(" %s = %s") % v.first % v.second;
}
BOOST_FOREACH(const ValueMapType &v, config_variables) {
for(const auto &v : config_variables) {
s << boost::format(" %s = %s") % v.first % v.second;
}
return s.str();
@ -201,7 +202,7 @@ ValuePtr FileContext::evaluate_function(const std::string &name,
const AbstractFunction *foundf = findLocalFunction(name);
if (foundf) return foundf->evaluate(this, evalctx);
BOOST_FOREACH(const FileModule::ModuleContainer::value_type &m, this->usedlibs) {
for(const auto &m : this->usedlibs) {
// usedmod is NULL if the library wasn't be compiled (error or file-not-found)
FileModule *usedmod = ModuleCache::instance()->lookup(m);
if (usedmod && usedmod->scope.functions.find(name) != usedmod->scope.functions.end())
@ -216,7 +217,7 @@ AbstractNode *FileContext::instantiate_module(const ModuleInstantiation &inst, E
const AbstractModule *foundm = this->findLocalModule(inst.name());
if (foundm) return foundm->instantiate(this, &inst, evalctx);
BOOST_FOREACH(const FileModule::ModuleContainer::value_type &m, this->usedlibs) {
for(const auto &m : this->usedlibs) {
FileModule *usedmod = ModuleCache::instance()->lookup(m);
// usedmod is NULL if the library wasn't be compiled (error or file-not-found)
if (usedmod &&

View file

@ -2,7 +2,6 @@
#include "context.h"
#include "module.h"
#include <boost/unordered_map.hpp>
/*!
This holds the context for a Module definition; keeps track of

View file

@ -41,7 +41,6 @@
namespace fs = boost::filesystem;
#include "boosty.h"
#include "FontCache.h"
#include <boost/foreach.hpp>
#include <sstream>
#include <sys/stat.h>
@ -259,7 +258,7 @@ void FileModule::registerInclude(const std::string &localpath,
bool FileModule::includesChanged() const
{
BOOST_FOREACH(const FileModule::IncludeContainer::value_type &item, this->includes) {
for(const auto &item : this->includes) {
if (include_modified(item.second)) return true;
}
return false;
@ -289,12 +288,12 @@ bool FileModule::handleDependencies()
this->is_handling_dependencies = true;
bool somethingchanged = false;
std::vector<std::pair<std::string,std::string> > updates;
std::vector<std::pair<std::string,std::string>> updates;
// If a lib in usedlibs was previously missing, we need to relocate it
// by searching the applicable paths. We can identify a previously missing module
// as it will have a relative path.
BOOST_FOREACH(std::string filename, this->usedlibs) {
for(auto filename : this->usedlibs) {
bool wasmissing = false;
bool found = true;
@ -332,7 +331,7 @@ bool FileModule::handleDependencies()
// Relative filenames which were located is reinserted as absolute filenames
typedef std::pair<std::string,std::string> stringpair;
BOOST_FOREACH(const stringpair &files, updates) {
for(const auto &files : updates) {
this->usedlibs.erase(files.first);
this->usedlibs.insert(files.second);
}

View file

@ -4,8 +4,8 @@
#include <vector>
#include <list>
#include <deque>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <sys/stat.h>
@ -121,7 +121,7 @@ public:
bool isHandlingDependencies() const { return this->is_handling_dependencies; }
ValuePtr lookup_variable(const std::string &name) const;
typedef boost::unordered_set<std::string> ModuleContainer;
typedef std::unordered_set<std::string> ModuleContainer;
ModuleContainer usedlibs;
private:
/** Reference to retain the context that was used in the last evaluation */
@ -134,7 +134,7 @@ private:
bool include_modified(const IncludeFile &inc) const;
typedef boost::unordered_map<std::string, struct IncludeFile> IncludeContainer;
typedef std::unordered_map<std::string, struct IncludeFile> IncludeContainer;
IncludeContainer includes;
bool is_handling_dependencies;
std::string path;

View file

@ -32,7 +32,6 @@
#include <iostream>
#include <algorithm>
#include <boost/foreach.hpp>
size_t AbstractNode::idx_counter;
@ -125,9 +124,9 @@ std::ostream &operator<<(std::ostream &stream, const AbstractNode &node)
// Do we have an explicit root node (! modifier)?
AbstractNode *find_root_tag(AbstractNode *n)
{
BOOST_FOREACH(AbstractNode *v, n->children) {
for(auto v : n->children) {
if (v->modinst->tag_root) return v;
if (AbstractNode *vroot = find_root_tag(v)) return vroot;
if (auto vroot = find_root_tag(v)) return vroot;
}
return NULL;
}

View file

@ -47,6 +47,6 @@ public:
}
private:
std::vector<shared_ptr<std::string> > cache;
std::vector<shared_ptr<std::string>> cache;
std::string nullvalue;
};

View file

@ -33,7 +33,6 @@
#include "builtin.h"
#include "calc.h"
#include "polyset.h"
#include "mathc99.h"
#include <sstream>
#include <boost/assign/std/vector.hpp>

View file

@ -63,7 +63,6 @@
#include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include "boosty.h"
#ifdef __APPLE__
@ -210,7 +209,7 @@ Camera get_camera(po::variables_map vm)
split(strs, vm["camera"].as<string>(), is_any_of(","));
if ( strs.size()==6 || strs.size()==7 ) {
try {
BOOST_FOREACH(string &s, strs) cam_parameters.push_back(lexical_cast<double>(s));
for(const auto &s : strs) cam_parameters.push_back(lexical_cast<double>(s));
camera.setup(cam_parameters);
}
catch (bad_lexical_cast &) {
@ -303,7 +302,7 @@ void set_render_color_scheme(const std::string color_scheme, const bool exit_if_
if (exit_if_not_found) {
PRINTB("Unknown color scheme '%s'. Valid schemes:", color_scheme);
BOOST_FOREACH (const std::string &name, ColorMap::inst()->colorSchemeNames()) {
for(const auto &name : ColorMap::inst()->colorSchemeNames()) {
PRINT(name);
}
exit(1);
@ -664,7 +663,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
#endif
// Other global settings
qRegisterMetaType<shared_ptr<const Geometry> >();
qRegisterMetaType<shared_ptr<const Geometry>>();
const QString &app_path = app.applicationDirPath();
PlatformUtils::registerApplicationPath(app_path.toLocal8Bit().constData());
@ -731,7 +730,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
// the "" dummy in inputFiles to open an empty MainWindow.
if (!files.empty()) {
inputFiles.clear();
BOOST_FOREACH(const QString &f, files) {
for(const auto &f : files) {
inputFiles.push_back(f.toStdString());
}
}
@ -744,7 +743,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
MainWindow *mainwin;
bool isMdi = settings.value("advanced/mdi", true).toBool();
if (isMdi) {
BOOST_FOREACH(const string &infile, inputFiles) {
for(const auto &infile : inputFiles) {
mainwin = new MainWindow(assemblePath(original_path, infile));
}
} else {
@ -753,9 +752,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
int rc = app.exec();
foreach (MainWindow *mainw, scadApp->windowManager.getWindows()) {
delete mainw;
}
for(auto &mainw : scadApp->windowManager.getWindows()) delete mainw;
return rc;
}
#else // OPENSCAD_QTGUI
@ -812,15 +809,15 @@ int main(int argc, char **argv)
("x,x", po::value<string>(), "dxf-file")
("d,d", po::value<string>(), "deps-file")
("m,m", po::value<string>(), "makefile")
("D,D", po::value<vector<string> >(), "var=val")
("D,D", po::value<vector<string>>(), "var=val")
#ifdef ENABLE_EXPERIMENTAL
("enable", po::value<vector<string> >(), "enable experimental features")
("enable", po::value<vector<string>>(), "enable experimental features")
#endif
;
po::options_description hidden("Hidden options");
hidden.add_options()
("input-file", po::value< vector<string> >(), "input file");
("input-file", po::value< vector<string>>(), "input file");
po::positional_options_description p;
p.add("input-file", -1);
@ -888,21 +885,21 @@ int main(int argc, char **argv)
}
if (vm.count("D")) {
BOOST_FOREACH(const string &cmd, vm["D"].as<vector<string> >()) {
for(const auto &cmd : vm["D"].as<vector<string>>()) {
commandline_commands += cmd;
commandline_commands += ";\n";
}
}
#ifdef ENABLE_EXPERIMENTAL
if (vm.count("enable")) {
BOOST_FOREACH(const string &feature, vm["enable"].as<vector<string> >()) {
for(const auto &feature : vm["enable"].as<vector<string>>()) {
Feature::enable_feature(feature);
}
}
#endif
vector<string> inputFiles;
if (vm.count("input-file")) {
inputFiles = vm["input-file"].as<vector<string> >();
inputFiles = vm["input-file"].as<vector<string>>();
}
if (vm.count("colorscheme")) {

View file

@ -40,12 +40,11 @@
#include "value.h"
#include "function.h"
#include "printutils.h"
#include "memory.h"
#include <sstream>
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#define foreach BOOST_FOREACH
#include "boosty.h"
@ -190,15 +189,15 @@ assignment:
TOK_ID '=' expr ';'
{
bool found = false;
foreach (Assignment& iter, scope_stack.top()->assignments) {
for (auto& iter : scope_stack.top()->assignments) {
if (iter.first == $1) {
iter.second = boost::shared_ptr<Expression>($3);
iter.second = shared_ptr<Expression>($3);
found = true;
break;
}
}
if (!found) {
scope_stack.top()->assignments.push_back(Assignment($1, boost::shared_ptr<Expression>($3)));
scope_stack.top()->assignments.push_back(Assignment($1, shared_ptr<Expression>($3)));
}
free($1);
}
@ -261,7 +260,7 @@ if_statement:
TOK_IF '(' expr ')'
{
$<ifelse>$ = new IfElseModuleInstantiation();
$<ifelse>$->arguments.push_back(Assignment("", boost::shared_ptr<Expression>($3)));
$<ifelse>$->arguments.push_back(Assignment("", shared_ptr<Expression>($3)));
$<ifelse>$->setPath(parser_source_path);
scope_stack.push(&$<ifelse>$->scope);
}
@ -546,7 +545,7 @@ argument_decl:
}
| TOK_ID '=' expr
{
$$ = new Assignment($1, boost::shared_ptr<Expression>($3));
$$ = new Assignment($1, shared_ptr<Expression>($3));
free($1);
}
;
@ -573,11 +572,11 @@ arguments_call:
argument_call:
expr
{
$$ = new Assignment("", boost::shared_ptr<Expression>($1));
$$ = new Assignment("", shared_ptr<Expression>($1));
}
| TOK_ID '=' expr
{
$$ = new Assignment($1, boost::shared_ptr<Expression>($3));
$$ = new Assignment($1, shared_ptr<Expression>($3));
free($1);
}
;

View file

@ -1,6 +1,5 @@
#include "parsersettings.h"
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include "boosty.h"
#include <boost/algorithm/string.hpp>
#include "PlatformUtils.h"
@ -20,7 +19,7 @@ static void add_librarydir(const std::string &libdir)
*/
fs::path search_libs(const fs::path &localpath)
{
BOOST_FOREACH(const std::string &dir, librarypath) {
for(const auto &dir : librarypath) {
fs::path usepath = fs::path(dir) / localpath;
if (fs::exists(usepath) && !fs::is_directory(usepath)) {
return usepath.string();
@ -53,7 +52,7 @@ static bool check_valid(const fs::path &p, const std::vector<std::string> *openf
std::string fullname = boosty::stringy(p);
// Detect circular includes
if (openfilenames) {
BOOST_FOREACH(const std::string &s, *openfilenames) {
for(const auto &s : *openfilenames) {
if (s == fullname) {
// PRINTB("WARNING: circular include file %s", fullname);
return false;

View file

@ -4,7 +4,6 @@
#include "printutils.h"
#include "grid.h"
#include <Eigen/LU>
#include <boost/foreach.hpp>
// all GL functions grouped together here
@ -130,7 +129,7 @@ void PolySet::render_surface(Renderer::csgmode_e csgmode, const Transform3d &m,
// Render sides
if (polygon.outlines().size() > 0) {
BOOST_FOREACH(const Outline2d &o, polygon.outlines()) {
for (const Outline2d &o : polygon.outlines()) {
for (size_t j = 1; j <= o.vertices.size(); j++) {
Vector3d p1(o.vertices[j-1][0], o.vertices[j-1][1], -zbase/2);
Vector3d p2(o.vertices[j-1][0], o.vertices[j-1][1], zbase/2);
@ -203,9 +202,9 @@ void PolySet::render_edges(Renderer::csgmode_e csgmode) const
if (this->dim == 2) {
if (csgmode == Renderer::CSGMODE_NONE) {
// Render only outlines
BOOST_FOREACH(const Outline2d &o, polygon.outlines()) {
for (const Outline2d &o : polygon.outlines()) {
glBegin(GL_LINE_LOOP);
BOOST_FOREACH(const Vector2d &v, o.vertices) {
for (const Vector2d &v : o.vertices) {
glVertex3d(v[0], v[1], 0);
}
glEnd();
@ -215,18 +214,18 @@ void PolySet::render_edges(Renderer::csgmode_e csgmode) const
// Render 2D objects 1mm thick, but differences slightly larger
double zbase = 1 + ((csgmode & CSGMODE_DIFFERENCE_FLAG) ? 0.1 : 0);
BOOST_FOREACH(const Outline2d &o, polygon.outlines()) {
for (const Outline2d &o : polygon.outlines()) {
// Render top+bottom outlines
for (double z = -zbase/2; z < zbase; z += zbase) {
glBegin(GL_LINE_LOOP);
BOOST_FOREACH(const Vector2d &v, o.vertices) {
for (const Vector2d &v : o.vertices) {
glVertex3d(v[0], v[1], z);
}
glEnd();
}
// Render sides
glBegin(GL_LINES);
BOOST_FOREACH(const Vector2d &v, o.vertices) {
for (const Vector2d &v : o.vertices) {
glVertex3d(v[0], v[1], -zbase/2);
glVertex3d(v[0], v[1], +zbase/2);
}

View file

@ -45,8 +45,6 @@ public:
Is_bad is_bad_object() const { return Is_bad(); }
};
#include <boost/foreach.hpp>
namespace PolysetUtils {
// Project all polygons (also back-facing) into a Polygon2d instance.
@ -55,9 +53,9 @@ namespace PolysetUtils {
Polygon2d *project(const PolySet &ps) {
Polygon2d *poly = new Polygon2d;
BOOST_FOREACH(const PolySet::Polygon &p, ps.polygons) {
for(const auto &p : ps.polygons) {
Outline2d outline;
BOOST_FOREACH(const Vector3d &v, p) {
for(const auto &v : p) {
outline.vertices.push_back(Vector2d(v[0], v[1]));
}
poly->addOutline(outline);

View file

@ -9,8 +9,6 @@
#include "cgalutils.h"
#endif
#include <boost/foreach.hpp>
namespace PolysetUtils {
// Project all polygons (also back-facing) into a Polygon2d instance.
@ -19,9 +17,9 @@ namespace PolysetUtils {
Polygon2d *project(const PolySet &ps) {
Polygon2d *poly = new Polygon2d;
BOOST_FOREACH(const Polygon &p, ps.polygons) {
for(const auto &p : ps.polygons) {
Outline2d outline;
BOOST_FOREACH(const Vector3d &v, p) {
for(const auto &v : p) {
outline.vertices.push_back(Vector2d(v[0], v[1]));
}
poly->addOutline(outline);
@ -55,9 +53,9 @@ namespace PolysetUtils {
// Build Indexed PolyMesh
Reindexer<Vector3f> allVertices;
std::vector<std::vector<IndexedFace> > polygons;
std::vector<std::vector<IndexedFace>> polygons;
BOOST_FOREACH(const Polygon &pgon, inps.polygons) {
for(const auto &pgon : inps.polygons) {
if (pgon.size() < 3) {
degeneratePolygons++;
continue;
@ -71,7 +69,7 @@ namespace PolysetUtils {
std::vector<IndexedFace> &faces = polygons.back();
faces.push_back(IndexedFace());
IndexedFace &currface = faces.back();
BOOST_FOREACH (const Vector3d &v, pgon) {
for(const auto &v : pgon) {
// Create vertex indices and remove consecutive duplicate vertices
int idx = allVertices.lookup(v.cast<float>());
if (currface.empty() || idx != currface.back()) currface.push_back(idx);
@ -86,7 +84,7 @@ namespace PolysetUtils {
// Tessellate indexed mesh
const Vector3f *verts = allVertices.getArray();
std::vector<IndexedTriangle> allTriangles;
BOOST_FOREACH(const std::vector<IndexedFace> &faces, polygons) {
for(const auto &faces : polygons) {
std::vector<IndexedTriangle> triangles;
if (faces[0].size() == 3) {
triangles.push_back(IndexedTriangle(faces[0][0], faces[0][1], faces[0][2]));
@ -94,7 +92,7 @@ namespace PolysetUtils {
else {
bool err = GeometryUtils::tessellatePolygonWithHoles(verts, faces, triangles, NULL);
if (!err) {
BOOST_FOREACH(const IndexedTriangle &t, triangles) {
for(const auto &t : triangles) {
outps.append_poly();
outps.append_vertex(verts[t[0]]);
outps.append_vertex(verts[t[1]]);

View file

@ -30,7 +30,6 @@
#include "printutils.h"
#include "grid.h"
#include <Eigen/LU>
#include <boost/foreach.hpp>
/*! /class PolySet
@ -128,8 +127,8 @@ BoundingBox PolySet::getBoundingBox() const
{
if (this->dirty) {
this->bbox.setNull();
BOOST_FOREACH(const Polygon &poly, polygons) {
BOOST_FOREACH(const Vector3d &p, poly) {
for(const auto &poly : polygons) {
for(const auto &p : poly) {
this->bbox.extend(p);
}
}
@ -141,7 +140,7 @@ BoundingBox PolySet::getBoundingBox() const
size_t PolySet::memsize() const
{
size_t mem = 0;
BOOST_FOREACH(const Polygon &p, this->polygons) mem += p.size() * sizeof(Vector3d);
for(const auto &p : this->polygons) mem += p.size() * sizeof(Vector3d);
mem += this->polygon.memsize() - sizeof(this->polygon);
mem += sizeof(PolySet);
return mem;
@ -160,8 +159,8 @@ void PolySet::transform(const Transform3d &mat)
// If mirroring transform, flip faces to avoid the object to end up being inside-out
bool mirrored = mat.matrix().determinant() < 0;
BOOST_FOREACH(Polygon &p, this->polygons){
BOOST_FOREACH(Vector3d &v, p) {
for(auto &p : this->polygons){
for(auto &v : p) {
v = mat * v;
}
if (mirrored) std::reverse(p.begin(), p.end());
@ -175,7 +174,7 @@ bool PolySet::is_convex() const {
return PolysetUtils::is_approximately_convex(*this);
}
void PolySet::resize(Vector3d newsize, const Eigen::Matrix<bool,3,1> &autosize)
void PolySet::resize(const Vector3d &newsize, const Eigen::Matrix<bool,3,1> &autosize)
{
BoundingBox bbox = this->getBoundingBox();

View file

@ -44,7 +44,7 @@ public:
void render_edges(Renderer::csgmode_e csgmode) const;
void transform(const Transform3d &mat);
void resize(Vector3d newsize, const Eigen::Matrix<bool,3,1> &autosize);
void resize(const Vector3d &newsize, const Eigen::Matrix<bool,3,1> &autosize);
bool is_convex() const;
boost::tribool convexValue() const { return this->convex; }

View file

@ -34,16 +34,12 @@
#include "visitor.h"
#include "context.h"
#include "calc.h"
#include "mathc99.h"
#include <sstream>
#include <assert.h>
#include <boost/foreach.hpp>
#include <cmath>
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope
#include <boost/math/special_functions/fpclassify.hpp>
#define isinf boost::math::isinf
#define F_MINIMUM 0.01
enum primitive_type_e {
@ -308,7 +304,7 @@ Geometry *PrimitiveNode::createGeometry() const
PolySet *p = new PolySet(3,true);
g = p;
if (this->x > 0 && this->y > 0 && this->z > 0 &&
!isinf(this->x) > 0 && !isinf(this->y) > 0 && !isinf(this->z) > 0) {
!std::isinf(this->x) > 0 && !std::isinf(this->y) > 0 && !std::isinf(this->z) > 0) {
double x1, x2, y1, y2, z1, z2;
if (this->center) {
x1 = -this->x/2;
@ -365,7 +361,7 @@ Geometry *PrimitiveNode::createGeometry() const
case SPHERE: {
PolySet *p = new PolySet(3,true);
g = p;
if (this->r1 > 0 && !isinf(this->r1)) {
if (this->r1 > 0 && !std::isinf(this->r1)) {
struct ring_s {
point2d *points;
double z;
@ -440,10 +436,10 @@ Geometry *PrimitiveNode::createGeometry() const
case CYLINDER: {
PolySet *p = new PolySet(3,true);
g = p;
if (this->h > 0 && !isinf(this->h) &&
if (this->h > 0 && !std::isinf(this->h) &&
this->r1 >=0 && this->r2 >= 0 && (this->r1 > 0 || this->r2 > 0) &&
!isinf(this->r1) && !isinf(this->r2)) {
int fragments = Calc::get_fragments_from_r(fmax(this->r1, this->r2), this->fn, this->fs, this->fa);
!std::isinf(this->r1) && !std::isinf(this->r2)) {
int fragments = Calc::get_fragments_from_r(std::fmax(this->r1, this->r2), this->fn, this->fs, this->fa);
double z1, z2;
if (this->center) {
@ -514,7 +510,7 @@ Geometry *PrimitiveNode::createGeometry() const
if (pt < this->points->toVector().size()) {
double px, py, pz;
if (!this->points->toVector()[pt]->getVec3(px, py, pz) ||
isinf(px) || isinf(py) || isinf(pz)) {
std::isinf(px) || std::isinf(py) || std::isinf(pz)) {
PRINTB("ERROR: Unable to convert point at index %d to a vec3 of numbers", j);
return p;
}
@ -528,7 +524,7 @@ Geometry *PrimitiveNode::createGeometry() const
Polygon2d *p = new Polygon2d();
g = p;
if (this->x > 0 && this->y > 0 &&
!isinf(this->x) && !isinf(this->y)) {
!std::isinf(this->x) && !std::isinf(this->y)) {
Vector2d v1(0, 0);
Vector2d v2(this->x, this->y);
if (this->center) {
@ -550,7 +546,7 @@ Geometry *PrimitiveNode::createGeometry() const
case CIRCLE: {
Polygon2d *p = new Polygon2d();
g = p;
if (this->r1 > 0 && !isinf(this->r1)) {
if (this->r1 > 0 && !std::isinf(this->r1)) {
int fragments = Calc::get_fragments_from_r(this->r1, this->fn, this->fs, this->fa);
Outline2d o;
@ -573,7 +569,7 @@ Geometry *PrimitiveNode::createGeometry() const
const Value::VectorType &vec = this->points->toVector();
for (unsigned int i=0;i<vec.size();i++) {
const Value &val = *vec[i];
if (!val.getVec2(x, y) || isinf(x) || isinf(y)) {
if (!val.getVec2(x, y) || std::isinf(x) || std::isinf(y)) {
PRINTB("ERROR: Unable to convert point %s at index %d to a vec2 of numbers",
val.toString() % i);
return p;
@ -585,9 +581,9 @@ Geometry *PrimitiveNode::createGeometry() const
p->addOutline(outline);
}
else {
BOOST_FOREACH(const ValuePtr &polygon, this->paths->toVector()) {
for(const auto &polygon : this->paths->toVector()) {
Outline2d curroutline;
BOOST_FOREACH(const ValuePtr &index, polygon->toVector()) {
for(const auto &index : polygon->toVector()) {
unsigned int idx = index->toDouble();
if (idx < outline.vertices.size()) {
curroutline.vertices.push_back(outline.vertices[idx]);

View file

@ -1,6 +1,6 @@
#pragma once
#include <qobject.h>
#include <QObject>
#include <Qsci/qsciglobal.h>
#include <Qsci/qscilexercpp.h>

View file

@ -377,7 +377,7 @@ void ScintillaEditor::enumerateColorSchemesInPath(ScintillaEditor::colorscheme_s
EditorColorScheme *colorScheme = new EditorColorScheme(path);
if (colorScheme->valid()) {
result_set.insert(colorscheme_set_t::value_type(colorScheme->index(), boost::shared_ptr<EditorColorScheme>(colorScheme)));
result_set.insert(colorscheme_set_t::value_type(colorScheme->index(), shared_ptr<EditorColorScheme>(colorScheme)));
} else {
delete colorScheme;
}

Some files were not shown because too many files have changed in this diff Show more