summaryrefslogtreecommitdiffstats
path: root/src/helper
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2019-01-02 09:41:30 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2019-01-02 09:41:30 +0000
commit169dff19d4da8d76e69b8e896aa25b0013639c03 (patch)
treea0c070fa95188b5cde708ac285e6a2db9df4a83f /src/helper
parentAvoid creating a new document before opening an old document. (diff)
downloadinkscape-169dff19d4da8d76e69b8e896aa25b0013639c03.tar.gz
inkscape-169dff19d4da8d76e69b8e896aa25b0013639c03.zip
modernize loops
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/geom-pathstroke.cpp8
-rw-r--r--src/helper/geom-pathvectorsatellites.cpp38
-rw-r--r--src/helper/geom.cpp38
3 files changed, 42 insertions, 42 deletions
diff --git a/src/helper/geom-pathstroke.cpp b/src/helper/geom-pathstroke.cpp
index d1ed7898d..a073db506 100644
--- a/src/helper/geom-pathstroke.cpp
+++ b/src/helper/geom-pathstroke.cpp
@@ -972,15 +972,15 @@ void offset_curve(Geom::Path& res, Geom::Curve const* current, double width, dou
}
default: {
Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(current->toSBasis(), tolerance);
- for (size_t i = 0; i < sbasis_path.size(); ++i)
- offset_curve(res, &sbasis_path[i], width, tolerance);
+ for (const auto & i : sbasis_path)
+ offset_curve(res, &i, width, tolerance);
break;
}
}
} else {
Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(current->toSBasis(), 0.1);
- for (size_t i = 0; i < sbasis_path.size(); ++i)
- offset_curve(res, &sbasis_path[i], width, tolerance);
+ for (const auto & i : sbasis_path)
+ offset_curve(res, &i, width, tolerance);
}
}
diff --git a/src/helper/geom-pathvectorsatellites.cpp b/src/helper/geom-pathvectorsatellites.cpp
index 2516181cb..92936813d 100644
--- a/src/helper/geom-pathvectorsatellites.cpp
+++ b/src/helper/geom-pathvectorsatellites.cpp
@@ -43,8 +43,8 @@ void PathVectorSatellites::setSatellites(Satellites satellites)
size_t PathVectorSatellites::getTotalSatellites()
{
size_t counter = 0;
- for (size_t i = 0; i < _satellites.size(); ++i) {
- for (size_t j = 0; j < _satellites[i].size(); ++j) {
+ for (auto & _satellite : _satellites) {
+ for (size_t j = 0; j < _satellite.size(); ++j) {
counter++;
}
}
@@ -68,12 +68,12 @@ std::pair<size_t, size_t> PathVectorSatellites::getIndexData(size_t index)
void PathVectorSatellites::setSelected(std::vector<size_t> selected)
{
size_t counter = 0;
- for (size_t i = 0; i < _satellites.size(); ++i) {
- for (size_t j = 0; j < _satellites[i].size(); ++j) {
+ for (auto & _satellite : _satellites) {
+ for (size_t j = 0; j < _satellite.size(); ++j) {
if (find (selected.begin(), selected.end(), counter) != selected.end()) {
- _satellites[i][j].setSelected(true);
+ _satellite[j].setSelected(true);
} else {
- _satellites[i][j].setSelected(false);
+ _satellite[j].setSelected(false);
}
counter++;
}
@@ -82,19 +82,19 @@ void PathVectorSatellites::setSelected(std::vector<size_t> selected)
void PathVectorSatellites::updateSteps(size_t steps, bool apply_no_radius, bool apply_with_radius, bool only_selected)
{
- for (size_t i = 0; i < _satellites.size(); ++i) {
- for (size_t j = 0; j < _satellites[i].size(); ++j) {
- if ((!apply_no_radius && _satellites[i][j].amount == 0) ||
- (!apply_with_radius && _satellites[i][j].amount != 0))
+ for (auto & _satellite : _satellites) {
+ for (size_t j = 0; j < _satellite.size(); ++j) {
+ if ((!apply_no_radius && _satellite[j].amount == 0) ||
+ (!apply_with_radius && _satellite[j].amount != 0))
{
continue;
}
if (only_selected) {
- if (_satellites[i][j].selected) {
- _satellites[i][j].steps = steps;
+ if (_satellite[j].selected) {
+ _satellite[j].steps = steps;
}
} else {
- _satellites[i][j].steps = steps;
+ _satellite[j].steps = steps;
}
}
}
@@ -205,13 +205,13 @@ void PathVectorSatellites::recalculateForNewPathVector(Geom::PathVector const pa
//TODO evaluate fix on nodes at same position
size_t number_nodes = pathv.nodes().size();
size_t previous_number_nodes = _pathvector.nodes().size();
- for (size_t i = 0; i < pathv.size(); i++) {
+ for (const auto & i : pathv) {
std::vector<Satellite> path_satellites;
- size_t count = pathv[i].size_default();
- if ( pathv[i].closed()) {
- const Geom::Curve &closingline = pathv[i].back_closed();
+ size_t count = i.size_default();
+ if ( i.closed()) {
+ const Geom::Curve &closingline = i.back_closed();
if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
- count = pathv[i].size_open();
+ count = i.size_open();
}
}
for (size_t j = 0; j < count; j++) {
@@ -225,7 +225,7 @@ void PathVectorSatellites::recalculateForNewPathVector(Geom::PathVector const pa
}
}
for (size_t l = 0; l < count2; l++) {
- if (Geom::are_near(_pathvector[k][l].initialPoint(), pathv[i][j].initialPoint()))
+ if (Geom::are_near(_pathvector[k][l].initialPoint(), i[j].initialPoint()))
{
path_satellites.push_back(_satellites[k][l]);
found = true;
diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp
index e1d48580c..801a9c6f1 100644
--- a/src/helper/geom.cpp
+++ b/src/helper/geom.cpp
@@ -154,11 +154,11 @@ bounds_exact_transformed(Geom::PathVector const & pv, Geom::Affine const & t)
Geom::Point initial = pv.front().initialPoint() * t;
Geom::Rect bbox(initial, initial); // obtain well defined bbox as starting point to unionWith
- for (Geom::PathVector::const_iterator it = pv.begin(); it != pv.end(); ++it) {
- bbox.expandTo(it->initialPoint() * t);
+ for (const auto & it : pv) {
+ bbox.expandTo(it.initialPoint() * t);
// don't loop including closing segment, since that segment can never increase the bbox
- for (Geom::Path::const_iterator cit = it->begin(); cit != it->end_open(); ++cit) {
+ for (Geom::Path::const_iterator cit = it.begin(); cit != it.end_open(); ++cit) {
Geom::Curve const &c = *cit;
unsigned order = 0;
@@ -395,8 +395,8 @@ geom_curve_bbox_wind_distance(Geom::Curve const & c, Geom::Affine const &m,
Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c.toSBasis(), 0.1);
//recurse to convert the new path resulting from the sbasis to svgd
- for (Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) {
- geom_curve_bbox_wind_distance(*iter, m, pt, bbox, wind, dist, tolerance, viewbox, p0);
+ for (const auto & iter : sbasis_path) {
+ geom_curve_bbox_wind_distance(iter, m, pt, bbox, wind, dist, tolerance, viewbox, p0);
}
}
}
@@ -423,13 +423,13 @@ pathv_matrix_point_bbox_wind_distance (Geom::PathVector const & pathv, Geom::Aff
Geom::Point p_start(0,0);
bool start_set = false;
- for (Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) {
+ for (const auto & it : pathv) {
if (start_set) { // this is a new subpath
if (wind && (p0 != p_start)) // for correct fill picking, each subpath must be closed
geom_line_wind_distance (p0[X], p0[Y], p_start[X], p_start[Y], pt, wind, dist);
}
- p0 = it->initialPoint() * m;
+ p0 = it.initialPoint() * m;
p_start = p0;
start_set = true;
if (bbox) {
@@ -437,7 +437,7 @@ pathv_matrix_point_bbox_wind_distance (Geom::PathVector const & pathv, Geom::Aff
}
// loop including closing segment if path is closed
- for (Geom::Path::const_iterator cit = it->begin(); cit != it->end_default(); ++cit) {
+ for (Geom::Path::const_iterator cit = it.begin(); cit != it.end_default(); ++cit) {
geom_curve_bbox_wind_distance(*cit, m, pt, bbox, wind, dist, tolerance, viewbox, p0);
}
}
@@ -459,12 +459,12 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv )
{
Geom::PathVector output;
- for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) {
+ for (const auto & pit : pathv) {
output.push_back( Geom::Path() );
output.back().setStitching(true);
- output.back().start( pit->initialPoint() );
+ output.back().start( pit.initialPoint() );
- for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) {
+ for (Geom::Path::const_iterator cit = pit.begin(); cit != pit.end_open(); ++cit) {
if (is_straight_curve(*cit)) {
Geom::LineSegment l(cit->initialPoint(), cit->finalPoint());
output.back().append(l);
@@ -482,7 +482,7 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv )
}
}
- output.back().close( pit->closed() );
+ output.back().close( pit.closed() );
}
return output;
@@ -557,19 +557,19 @@ pathv_to_cubicbezier( Geom::PathVector const &pathv)
{
Geom::PathVector output;
double cubicGap = 0.01;
- for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) {
+ for (const auto & pit : pathv) {
output.push_back( Geom::Path() );
- output.back().start( pit->initialPoint() );
- output.back().close( pit->closed() );
+ output.back().start( pit.initialPoint() );
+ output.back().close( pit.closed() );
bool end_open = false;
- if (pit->closed()) {
- const Geom::Curve &closingline = pit->back_closed();
+ if (pit.closed()) {
+ const Geom::Curve &closingline = pit.back_closed();
if (!are_near(closingline.initialPoint(), closingline.finalPoint())) {
end_open = true;
}
}
- Geom::Path pitCubic = (Geom::Path)(*pit);
- if(end_open && pit->closed()){
+ Geom::Path pitCubic = (Geom::Path)pit;
+ if(end_open && pit.closed()){
pitCubic.close(false);
pitCubic.appendNew<Geom::LineSegment>( pitCubic.initialPoint() );
pitCubic.close(true);