Use C++11 initializers
This commit is contained in:
parent
a0d9273129
commit
02b21fe102
9 changed files with 28 additions and 29 deletions
|
|
@ -120,7 +120,7 @@ bool FileModule::handleDependencies()
|
|||
wasmissing = true;
|
||||
fs::path fullpath = find_valid_path(this->path, filename);
|
||||
if (!fullpath.empty()) {
|
||||
updates.push_back(std::make_pair(filename, fullpath.generic_string()));
|
||||
updates.push_back({filename, fullpath.generic_string()});
|
||||
filename = fullpath.generic_string();
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ void GeometryEvaluator::addToParent(const State &state,
|
|||
{
|
||||
this->visitedchildren.erase(node.index());
|
||||
if (state.parent()) {
|
||||
this->visitedchildren[state.parent()->index()].push_back(std::make_pair(&node, geom));
|
||||
this->visitedchildren[state.parent()->index()].push_back({&node, geom});
|
||||
}
|
||||
else {
|
||||
// Root node
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public:
|
|||
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()));
|
||||
this->map[val] = this->map.size();
|
||||
return this->map.size() - 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void ThrownTogetherRenderer::draw(bool /*showfaces*/, bool showedges) const
|
|||
void ThrownTogetherRenderer::renderChainObject(const CSGChainObject &csgobj, bool highlight_mode,
|
||||
bool background_mode, bool showedges, bool fberror, OpenSCADOperator type) const
|
||||
{
|
||||
if (this->geomVisitMark[std::make_pair(csgobj.leaf->geom.get(), &csgobj.leaf->matrix)]++ > 0) return;
|
||||
if (this->geomVisitMark[{csgobj.leaf->geom.get(), &csgobj.leaf->matrix}]++ > 0) return;
|
||||
const Color4f &c = csgobj.leaf->color;
|
||||
csgmode_e csgmode = csgmode_e(
|
||||
(highlight_mode ?
|
||||
|
|
|
|||
|
|
@ -379,8 +379,10 @@ namespace CGALUtils {
|
|||
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,
|
||||
shared_ptr<const Geometry>(createNefPolyhedronFromGeometry(ps))));
|
||||
fake_children.push_back({
|
||||
(const AbstractNode*)NULL,
|
||||
shared_ptr<const Geometry>(createNefPolyhedronFromGeometry(ps))
|
||||
});
|
||||
}
|
||||
CGAL_Nef_polyhedron *N = CGALUtils::applyOperator(fake_children, OPENSCAD_UNION);
|
||||
// FIXME: This hould really never throw.
|
||||
|
|
|
|||
|
|
@ -216,9 +216,6 @@ AbstractNode *ColorModule::instantiate(const Context *ctx, const ModuleInstantia
|
|||
{
|
||||
ColorNode *node = new ColorNode(inst);
|
||||
|
||||
node->color[0] = node->color[1] = node->color[2] = -1.0;
|
||||
node->color[3] = 1.0;
|
||||
|
||||
AssignmentList args;
|
||||
|
||||
args += Assignment("c"), Assignment("alpha");
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class ColorNode : public AbstractNode
|
|||
{
|
||||
public:
|
||||
VISITABLE();
|
||||
ColorNode(const ModuleInstantiation *mi) : AbstractNode(mi) { }
|
||||
ColorNode(const ModuleInstantiation *mi) : AbstractNode(mi), color(-1.0f, -1.0f, -1.0f, 1.0f) { }
|
||||
virtual std::string toString() const;
|
||||
virtual std::string name() const;
|
||||
|
||||
|
|
|
|||
10
src/grid.h
10
src/grid.h
|
|
@ -37,11 +37,11 @@ public:
|
|||
T &align(double &x, double &y) {
|
||||
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()) {
|
||||
if (db.find({ix, iy}) == db.end()) {
|
||||
int dist = 10;
|
||||
for (int64_t jx = ix - 1; jx <= ix + 1; jx++) {
|
||||
for (int64_t jy = iy - 1; jy <= iy + 1; jy++) {
|
||||
if (db.find(std::make_pair(jx, jy)) == db.end())
|
||||
if (db.find({jx, jy}) == db.end())
|
||||
continue;
|
||||
int d = abs(int(ix-jx)) + abs(int(iy-jy));
|
||||
if (d < dist) {
|
||||
|
|
@ -53,17 +53,17 @@ public:
|
|||
}
|
||||
}
|
||||
x = ix * res, y = iy * res;
|
||||
return db[std::make_pair(ix, iy)];
|
||||
return db[{ix, iy}];
|
||||
}
|
||||
|
||||
bool has(double x, double y) const {
|
||||
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())
|
||||
if (db.find({ix, iy}) != db.end())
|
||||
return true;
|
||||
for (int64_t jx = ix - 1; jx <= ix + 1; jx++)
|
||||
for (int64_t jy = iy - 1; jy <= iy + 1; jy++) {
|
||||
if (db.find(std::make_pair(jx, jy)) != db.end())
|
||||
if (db.find({jx, jy}) != db.end())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ void SurfaceNode::convert_image(img_data_t &data, std::vector<unsigned char> &im
|
|||
long idx = 4 * (y * width + x);
|
||||
double pixel = 0.2126 * img[idx] + 0.7152 * img[idx + 1] + 0.0722 * img[idx + 2];
|
||||
double z = 100.0/255 * (invert ? 1 - pixel : pixel);
|
||||
data[std::make_pair(height - 1 - y, x)] = z;
|
||||
data[{height - 1 - y, x}] = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ img_data_t SurfaceNode::read_dat(std::string filename) const
|
|||
try {
|
||||
for(const auto &token : tokens) {
|
||||
double v = boost::lexical_cast<double>(token);
|
||||
data[std::make_pair(lines, col++)] = v;
|
||||
data[{lines, col++}] = v;
|
||||
if (col > columns) columns = col;
|
||||
min_val = std::min(v-1, min_val);
|
||||
}
|
||||
|
|
@ -231,10 +231,10 @@ const Geometry *SurfaceNode::createGeometry() const
|
|||
for (int i = 1; i < lines; i++)
|
||||
for (int j = 1; j < columns; j++)
|
||||
{
|
||||
double v1 = data[std::make_pair(i-1, j-1)];
|
||||
double v2 = data[std::make_pair(i-1, j)];
|
||||
double v3 = data[std::make_pair(i, j-1)];
|
||||
double v4 = data[std::make_pair(i, j)];
|
||||
double v1 = data[{i-1, j-1}];
|
||||
double v2 = data[{i-1, j}];
|
||||
double v3 = data[{i, j-1}];
|
||||
double v4 = data[{i, j}];
|
||||
double vx = (v1 + v2 + v3 + v4) / 4;
|
||||
|
||||
p->append_poly();
|
||||
|
|
@ -262,14 +262,14 @@ const Geometry *SurfaceNode::createGeometry() const
|
|||
{
|
||||
p->append_poly();
|
||||
p->append_vertex(ox + 0, oy + i-1, min_val);
|
||||
p->append_vertex(ox + 0, oy + i-1, data[std::make_pair(i-1, 0)]);
|
||||
p->append_vertex(ox + 0, oy + i, data[std::make_pair(i, 0)]);
|
||||
p->append_vertex(ox + 0, oy + i-1, data[{i-1, 0}]);
|
||||
p->append_vertex(ox + 0, oy + i, data[{i, 0}]);
|
||||
p->append_vertex(ox + 0, oy + i, min_val);
|
||||
|
||||
p->append_poly();
|
||||
p->insert_vertex(ox + columns-1, oy + i-1, min_val);
|
||||
p->insert_vertex(ox + columns-1, oy + i-1, data[std::make_pair(i-1, columns-1)]);
|
||||
p->insert_vertex(ox + columns-1, oy + i, data[std::make_pair(i, columns-1)]);
|
||||
p->insert_vertex(ox + columns-1, oy + i-1, data[{i-1, columns-1}]);
|
||||
p->insert_vertex(ox + columns-1, oy + i, data[{i, columns-1}]);
|
||||
p->insert_vertex(ox + columns-1, oy + i, min_val);
|
||||
}
|
||||
|
||||
|
|
@ -277,14 +277,14 @@ const Geometry *SurfaceNode::createGeometry() const
|
|||
{
|
||||
p->append_poly();
|
||||
p->insert_vertex(ox + i-1, oy + 0, min_val);
|
||||
p->insert_vertex(ox + i-1, oy + 0, data[std::make_pair(0, i-1)]);
|
||||
p->insert_vertex(ox + i, oy + 0, data[std::make_pair(0, i)]);
|
||||
p->insert_vertex(ox + i-1, oy + 0, data[{0, i-1}]);
|
||||
p->insert_vertex(ox + i, oy + 0, data[{0, i}]);
|
||||
p->insert_vertex(ox + i, oy + 0, min_val);
|
||||
|
||||
p->append_poly();
|
||||
p->append_vertex(ox + i-1, oy + lines-1, min_val);
|
||||
p->append_vertex(ox + i-1, oy + lines-1, data[std::make_pair(lines-1, i-1)]);
|
||||
p->append_vertex(ox + i, oy + lines-1, data[std::make_pair(lines-1, i)]);
|
||||
p->append_vertex(ox + i-1, oy + lines-1, data[{lines-1, i-1}]);
|
||||
p->append_vertex(ox + i, oy + lines-1, data[{lines-1, i}]);
|
||||
p->append_vertex(ox + i, oy + lines-1, min_val);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue