C++11: Use range-based for instead of BOOST_FOREACH

This commit is contained in:
Marius Kintel 2016-01-10 16:10:17 -05:00
parent bf19e009ff
commit 34e7761a79
44 changed files with 172 additions and 229 deletions

View file

@ -43,7 +43,7 @@ shared_ptr<CSGTerm> CSGTermEvaluator::evaluateCSGTerm(const AbstractNode &node,
void CSGTermEvaluator::applyToChildren(const AbstractNode &node, CSGTermEvaluator::CsgOp op)
{
shared_ptr<CSGTerm> t1;
BOOST_FOREACH(const AbstractNode *chnode, this->visitedchildren[node.index()]) {
for(const auto &chnode : this->visitedchildren[node.index()]) {
shared_ptr<CSGTerm> t2(this->stored_term[chnode->index()]);
this->stored_term.erase(chnode->index());
if (t2 && !t1) {

View file

@ -80,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()) {
@ -124,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();
@ -153,9 +153,9 @@ Polygon2d *GeometryEvaluator::applyHull2D(const AbstractNode &node)
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]));
}
}
@ -167,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);
@ -203,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;
@ -276,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;
@ -502,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);
@ -618,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;
}
}
@ -635,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++) {
@ -696,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));
@ -816,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]);
@ -838,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());
}
}
@ -849,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());
}
}
@ -857,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());
@ -950,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

@ -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);
@ -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
@ -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>());
@ -451,8 +451,8 @@ bool GeometryUtils::tessellatePolygon(const Polygon &polygon, Polygons &triangle
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

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

@ -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,8 +62,8 @@ 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;
}
}

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

View file

@ -32,7 +32,6 @@
#include "system-gl.h"
#include <boost/unordered_map.hpp>
#include <boost/foreach.hpp>
ThrownTogetherRenderer::ThrownTogetherRenderer(CSGChain *root_chain,
CSGChain *highlights_chain,
@ -67,7 +66,7 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
PRINTD("Thrown renderCSGChain");
glDepthFunc(GL_LEQUAL);
boost::unordered_map<std::pair<const Geometry*,const Transform3d*>,int> geomVisitMark;
BOOST_FOREACH(const CSGChainObject &obj, chain->objects) {
for(const auto &obj : chain->objects) {
if (geomVisitMark[std::make_pair(obj.geom.get(), &obj.matrix)]++ > 0)
continue;
const Transform3d &m = obj.matrix;

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

View file

@ -32,7 +32,6 @@
#include <map>
#include <queue>
#include <boost/foreach.hpp>
#include <boost/unordered_set.hpp>
namespace CGALUtils {
@ -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]));
}
}

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 */ {
@ -48,10 +48,10 @@ namespace /* anonymous */ {
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) {
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);
}
@ -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

@ -32,7 +32,6 @@
#include <map>
#include <queue>
#include <boost/foreach.hpp>
#include <boost/unordered_set.hpp>

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

@ -32,7 +32,6 @@
#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));
}
}
@ -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,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

@ -24,7 +24,6 @@
*
*/
#include <boost/foreach.hpp>
#include "module.h"
#include "node.h"
#include "evalcontext.h"
@ -35,10 +34,6 @@
#include <sstream>
#include "mathc99.h"
#define foreach BOOST_FOREACH
class ControlModule : public AbstractModule
{
public: // types
@ -103,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));
}
@ -228,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

@ -28,7 +28,6 @@
#include "Geometry.h"
#include "linalg.h"
#include <sstream>
#include <boost/foreach.hpp>
/*!
\class CSGTerm
@ -185,7 +184,7 @@ std::string CSGChain::dump(bool full)
{
std::stringstream dump;
BOOST_FOREACH(const CSGChainObject &obj, this->objects) {
for(const auto &obj : this->objects) {
if (obj.type == CSGTerm::TYPE_UNION) {
if (&obj != &this->objects.front()) dump << "\n";
dump << "+";
@ -208,7 +207,7 @@ std::string CSGChain::dump(bool full)
BoundingBox CSGChain::getBoundingBox() const
{
BoundingBox bbox;
BOOST_FOREACH(const CSGChainObject &obj, this->objects) {
for(const auto &obj : this->objects) {
if (obj.type != CSGTerm::TYPE_DIFFERENCE) {
if (obj.geom) {
BoundingBox psbox = obj.geom->getBoundingBox();

View file

@ -34,7 +34,6 @@
#include "mathc99.h"
#include <assert.h>
#include <boost/unordered_map.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <algorithm>
@ -392,7 +391,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 +414,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

@ -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)
@ -58,7 +56,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();
}
}
@ -66,7 +64,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

@ -34,7 +34,6 @@
#include "stackcheck.h"
#include "exceptions.h"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
// unnamed namespace
namespace {
@ -408,7 +407,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);
vec.push_back(tmpval);
}

View file

@ -37,7 +37,6 @@
#include "printutils.h"
#include "stackcheck.h"
#include "exceptions.h"
#include <boost/foreach.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
using boost::math::isnan;
@ -636,7 +635,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 {

View file

@ -3,7 +3,6 @@
#include <sstream>
#include <stdlib.h> // for system()
#include <boost/unordered_set.hpp>
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
@ -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");

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();
@ -46,7 +44,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);
}
@ -63,7 +61,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

@ -107,7 +107,6 @@
#include <algorithm>
#include <boost/version.hpp>
#include <boost/foreach.hpp>
#include <sys/stat.h>
#ifdef ENABLE_CGAL

View file

@ -7,8 +7,6 @@
#include "builtin.h"
#include "ModuleCache.h"
#include <boost/foreach.hpp>
ModuleContext::ModuleContext(const Context *parent, const EvalContext *evalctx)
: Context(parent), functions_p(NULL), modules_p(NULL), evalctx(evalctx)
{
@ -24,7 +22,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);
@ -34,7 +32,7 @@ void ModuleContext::evaluateAssignments(const AssignmentList &assignments)
// to allow for initialization out of order
boost::unordered_map<std::string, Expression *> tmpass;
BOOST_FOREACH (const Assignment &ass, assignments) {
for(const auto &ass : assignments) {
tmpass[ass.first] = ass.second;
}
@ -69,7 +67,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 +85,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 +152,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 +199,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 +214,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

@ -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;
@ -294,7 +293,7 @@ bool FileModule::handleDependencies()
// 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

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

@ -62,7 +62,6 @@
#include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include "boosty.h"
#ifdef __APPLE__
@ -211,7 +210,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 &) {
@ -305,7 +304,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);
@ -741,7 +740,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());
}
}
@ -754,7 +753,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 {
@ -899,14 +898,14 @@ 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);
}
}

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.1);
}
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);
@ -57,7 +55,7 @@ namespace PolysetUtils {
Reindexer<Vector3f> allVertices;
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());

View file

@ -37,7 +37,6 @@
#include "mathc99.h"
#include <sstream>
#include <assert.h>
#include <boost/foreach.hpp>
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope
@ -585,9 +584,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

@ -37,7 +37,6 @@
#include <sstream>
#include <fstream>
#include <boost/foreach.hpp>
#include <boost/unordered_map.hpp>
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>
@ -192,7 +191,7 @@ img_data_t SurfaceNode::read_dat(std::string filename) const
int col = 0;
tokenizer tokens(line, sep);
try {
BOOST_FOREACH(const std::string &token, tokens) {
for(const auto &token : tokens) {
double v = boost::lexical_cast<double>(token);
data[std::make_pair(lines, col++)] = v;
if (col > columns) columns = col;

View file

@ -3,7 +3,6 @@
#include "node.h"
#include "state.h"
#include <algorithm>
#include <boost/foreach.hpp>
void Traverser::execute()
{
@ -26,7 +25,7 @@ Response Traverser::traverse(const AbstractNode &node, const State &state)
// Pruned traversals mean don't traverse children
if (response == ContinueTraversal) {
newstate.setParent(&node);
BOOST_FOREACH(const AbstractNode *chnode, node.getChildren()) {
for(const auto &chnode : node.getChildren()) {
response = this->traverse(*chnode, newstate);
if (response == AbortTraversal) return response; // Abort immediately
}

View file

@ -30,7 +30,6 @@
#include <math.h>
#include <assert.h>
#include <sstream>
#include <boost/foreach.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
@ -71,7 +70,7 @@ std::ostream &operator<<(std::ostream &stream, const Filename &filename)
std::ostream &operator<<(std::ostream &stream, const QuotedString &s)
{
stream << '"';
BOOST_FOREACH(char c, s) {
for(char c : s) {
switch (c) {
case '\t':
stream << "\\t";
@ -517,7 +516,7 @@ Value Value::multvecnum(const Value &vecval, const Value &numval)
{
// Vector * Number
VectorType dstv;
BOOST_FOREACH(const ValuePtr &val, vecval.toVector()) {
for(const auto &val : vecval.toVector()) {
dstv.push_back(ValuePtr(*val * numval));
}
return Value(dstv);
@ -601,7 +600,7 @@ Value Value::operator*(const Value &v) const
vec1[0]->toVector().size() == vec2.size()) {
// Matrix * Matrix
VectorType dstv;
BOOST_FOREACH(const ValuePtr &srcrow, vec1) {
for(const auto &srcrow : vec1) {
const VectorType &srcrowvec = srcrow->toVector();
if (srcrowvec.size() != vec2.size()) return Value::undefined;
dstv.push_back(ValuePtr(multvecmat(srcrowvec, vec2)));
@ -620,7 +619,7 @@ Value Value::operator/(const Value &v) const
else if (this->type() == VECTOR && v.type() == NUMBER) {
const VectorType &vec = this->toVector();
VectorType dstv;
BOOST_FOREACH(const ValuePtr &vecval, vec) {
for(const auto &vecval : vec) {
dstv.push_back(ValuePtr(*vecval / v));
}
return Value(dstv);
@ -628,7 +627,7 @@ Value Value::operator/(const Value &v) const
else if (this->type() == NUMBER && v.type() == VECTOR) {
const VectorType &vec = v.toVector();
VectorType dstv;
BOOST_FOREACH(const ValuePtr &vecval, vec) {
for(const auto &vecval : vec) {
dstv.push_back(ValuePtr(*this / *vecval));
}
return Value(dstv);
@ -652,7 +651,7 @@ Value Value::operator-() const
else if (this->type() == VECTOR) {
const VectorType &vec = this->toVector();
VectorType dstv;
BOOST_FOREACH(const ValuePtr &vecval, vec) {
for(const auto &vecval : vec) {
dstv.push_back(ValuePtr(-*vecval));
}
return Value(dstv);