@@ -2132,20 +2132,20 @@ Object* OcdFileImport::importRectangleObject(const Ocd::OcdPoint32* ocd_points,
21322132void OcdFileImport::fillPathCoords (OcdImportedPathObject *object, bool is_area, quint32 num_points, const Ocd::OcdPoint32* ocd_points) const
21332133{
21342134 object->coords .resize (num_points);
2135+
2136+ auto const out_first = object->coords .begin ();
2137+ auto out_coord = out_first;
21352138 int ignore_flag_hole = 2 ;
2136- for (auto i = 0u ; i < num_points; i++)
2137- {
2138- const auto & ocd_point = ocd_points[i];
2139- object->coords [i] = convertOcdPoint (ocd_point);
2139+ std::for_each (ocd_points, ocd_points + num_points, [&](auto & ocd_point) {
2140+ *out_coord = convertOcdPoint (ocd_point);
21402141 if ((ocd_point.y & Ocd::OcdPoint32::FlagDash) || (ocd_point.y & Ocd::OcdPoint32::FlagCorner))
21412142 {
2142- object-> coords [i]. setDashPoint (true );
2143+ out_coord-> setDashPoint (true );
21432144 }
2144-
2145- if (ocd_point.x & Ocd::OcdPoint32::FlagCtl1 && i > 0 )
2145+ if ((ocd_point.x & Ocd::OcdPoint32::FlagCtl1) && out_coord != out_first)
21462146 {
21472147 // CurveStart needs to be applied to the start point
2148- object-> coords [i- 1 ]. setCurveStart (true );
2148+ (out_coord- 1 )-> setCurveStart (true );
21492149 ignore_flag_hole = 2 ; // 2nd control point + end point
21502150 }
21512151 else if (is_area)
@@ -2156,12 +2156,13 @@ void OcdFileImport::fillPathCoords(OcdImportedPathObject *object, bool is_area,
21562156 }
21572157 else if (ocd_point.y & Ocd::OcdPoint32::FlagHole)
21582158 {
2159- Q_ASSERT (i >= 2 ); // implied by initialization of ignore_hole_points
2159+ Q_ASSERT (std::distance (out_first, out_coord) >= 2 ); // implied by initialization of ignore_flag_hole
21602160 // HolePoint needs to be applied to the last point of a part
2161- object-> coords [i- 1 ]. setHolePoint (true );
2161+ (out_coord- 1 )-> setHolePoint (true );
21622162 }
21632163 }
2164- };
2164+ ++out_coord;
2165+ });
21652166
21662167 // For path objects, create closed parts where the position of the last point is equal to that of the first point
21672168 if (object->getType () == Object::Path)
0 commit comments