diff options
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/PathClipper.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/src/PathClipper.cpp | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/PathClipper.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/PathClipper.cpp index bd7e3dd5ac3..7fa21855b23 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/PathClipper.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/PathClipper.cpp @@ -2,7 +2,7 @@ ** PathClipper.cpp ** ** ** ** This file is part of dvisvgm -- a fast DVI to SVG converter ** -** Copyright (C) 2005-2016 Martin Gieseking <martin.gieseking@uos.de> ** +** Copyright (C) 2005-2017 Martin Gieseking <martin.gieseking@uos.de> ** ** ** ** This program is free software; you can redistribute it and/or ** ** modify it under the terms of the GNU General Public License as ** @@ -19,9 +19,8 @@ *************************************************************************/ #include <config.h> -#include "Bezier.h" -#include "PathClipper.h" -#include "types.h" +#include "Bezier.hpp" +#include "PathClipper.hpp" using namespace std; using namespace ClipperLib; @@ -57,36 +56,36 @@ class FlattenActions : public CurvedPath::Actions { FlattenActions (vector<Bezier> &curves, Polygons &polygons, int &numLines) : _polygons(polygons), _curves(curves), _numLines(numLines) {} - void moveto (const CurvedPath::Point &p) { + void moveto (const CurvedPath::Point &p) override { if (p == _currentPoint && !_currentPoly.empty()) return; closepath(); - _currentPoly.push_back(IntPoint(to_cInt(p.x()), to_cInt(p.y()), 0)); + _currentPoly.emplace_back(IntPoint(to_cInt(p.x()), to_cInt(p.y()), 0)); _currentPoint = _startPoint = p; } - void lineto (const CurvedPath::Point &p) { + void lineto (const CurvedPath::Point &p) override { if (p == _currentPoint && !_currentPoly.empty()) return; if (_currentPoly.empty()) // this shouldn't happen but in case it does... - _currentPoly.push_back(IntPoint(0, 0, 0)); // ...add a start point first + _currentPoly.emplace_back(IntPoint(0, 0, 0)); // ...add a start point first _numLines--; _currentPoly.back().Z.label2 = _numLines; - _currentPoly.push_back(IntPoint(to_cInt(p.x()), to_cInt(p.y()), ZType(_numLines, 0))); + _currentPoly.emplace_back(IntPoint(to_cInt(p.x()), to_cInt(p.y()), ZType(_numLines, 0))); _currentPoint = p; } - void conicto (const CurvedPath::Point &p1, const CurvedPath::Point &p2) { + void conicto (const CurvedPath::Point &p1, const CurvedPath::Point &p2) override { Bezier bezier(_currentPoint, p1, p2); addCurvePoints(bezier); } - void cubicto (const CurvedPath::Point &p1, const CurvedPath::Point &p2, const CurvedPath::Point &p3) { + void cubicto (const CurvedPath::Point &p1, const CurvedPath::Point &p2, const CurvedPath::Point &p3) override { Bezier bezier(_currentPoint, p1, p2, p3); addCurvePoints(bezier); } - void closepath () { + void closepath () override { if (_currentPoly.empty()) return; _numLines--; @@ -96,14 +95,14 @@ class FlattenActions : public CurvedPath::Actions { _currentPoly.clear(); } - void finished () { + void finished () override { closepath(); } protected: void addCurvePoints (const Bezier &bezier) { if (_currentPoly.empty()) // this shouldn't happen but in case it does, ... - _currentPoly.push_back(IntPoint(0, 0, 0)); // ...add a start point first + _currentPoly.emplace_back(IntPoint(0, 0, 0)); // ...add a start point first vector<DPair> points; // points of flattened curve vector<double> t; // corresponding 'time' parameters bezier.approximate(0.01, points, &t); @@ -116,7 +115,7 @@ class FlattenActions : public CurvedPath::Actions { continue; _currentPoly.back().Z.label2 = ZLabel(_curves.size(), t[i-1]); ZLabel label(_curves.size(), t[i]); - _currentPoly.push_back(IntPoint(to_cInt(p.x()), to_cInt(p.y()), ZType(label, label))); + _currentPoly.emplace_back(IntPoint(to_cInt(p.x()), to_cInt(p.y()), ZType(label, label))); _currentPoint = p; } } @@ -177,10 +176,10 @@ void PathClipper::flatten (const CurvedPath &curvedPath, Polygons &polygons) { * edge belongs to. * @param[in] p1 first of two adjacent vertices * @param[in] p2 second of two adjacent vertices - * @param[out] t1 time paramater of p1 - * @param[out] t2 time paramater of p2 + * @param[out] t1 time parameter of p1 + * @param[out] t2 time parameter of p2 * @return id of edge between p1 and p2, or 0 if it's not possible to identify the segment */ -static Int32 segment_id (const IntPoint &p1, const IntPoint &p2, double &t1, double &t2) { +static int32_t segment_id (const IntPoint &p1, const IntPoint &p2, double &t1, double &t2) { const ZType &z1=p1.Z, &z2=p2.Z; if (z1 == z2 && z1.minLabel().id < 0) return z1.minLabel().id; if (z1.label1 == z2.label2) {t1=z1.label1.t; t2=z2.label2.t; return z1.label1.id;} @@ -193,13 +192,13 @@ static Int32 segment_id (const IntPoint &p1, const IntPoint &p2, double &t1, dou } -inline Int32 edge_id (const IntPoint &p1, const IntPoint &p2) { - double t; +inline int32_t edge_id (const IntPoint &p1, const IntPoint &p2) { + double t=0; return segment_id(p1, p2, t, t); } -/** This function expects 3 colinear points p1, p2, and q where q lies between p1 and p2, +/** This function expects 3 colinear points p1, p2, and q, where q lies between p1 and p2, * i.e. q divides the line \f$ \overline{p_1 p_2} \f$ somewhere. The function returns * the corresponding division ratio. */ static double division_ratio (const IntPoint &p1, const IntPoint &p2, const IntPoint &q) { @@ -217,7 +216,7 @@ static double division_ratio (const IntPoint &p1, const IntPoint &p2, const IntP inline ZLabel division_label (const IntPoint &p1, const IntPoint &p2, const IntPoint &q) { double t1, t2; double s=0; - Int32 id = segment_id(p1, p2, t1, t2); + int32_t id = segment_id(p1, p2, t1, t2); if (id > 0) s = t1+(t2-t1)*division_ratio(p1, p2, q); return ZLabel(id, s); @@ -251,9 +250,9 @@ static size_t find_segment_endpoint (const Polygon &polygon, size_t start, ZLabe const size_t num_points = polygon.size(); int i = start%num_points; - double t1, t2; // time parameters of start and endpoint of current edge - Int32 id1 = segment_id(polygon[i], polygon[(i+1)%num_points], t1, t2); - Int32 id2 = id1; + double t1=0, t2=0; // time parameters of start and endpoint of current edge + int32_t id1 = segment_id(polygon[i], polygon[(i+1)%num_points], t1, t2); + int32_t id2 = id1; double t = t2; // time parameter of resulting endpoint for (size_t j=1; id1 == id2 && j < num_points; j++) { t = t2; @@ -275,8 +274,8 @@ static size_t find_segment_endpoint (const Polygon &polygon, size_t start, ZLabe * @param[in] polygons set of polygons to reconstruct * @param[out] path the reconstructed curved path */ void PathClipper::reconstruct (const Polygons &polygons, CurvedPath &path) { - for (size_t i=0; i < polygons.size(); i++) - reconstruct(polygons[i], path); + for (const Polygon &polygon : polygons) + reconstruct(polygon, path); } @@ -315,11 +314,11 @@ void PathClipper::reconstruct (const Polygon &polygon, CurvedPath &path) { inline PolyFillType polyFillType (CurvedPath::WindingRule wr) { - return (wr == CurvedPath::WR_NON_ZERO) ? pftNonZero : pftEvenOdd; + return (wr == CurvedPath::WindingRule::NON_ZERO) ? pftNonZero : pftEvenOdd; } -/** Computes the intersection of to curved path. +/** Computes the intersection of to curved paths. * @param[in] p1 first curved path * @param[in] p2 second curved path * @param[out] result intersection of p1 and p2 */ |