diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-07-24 23:31:44 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-07-24 23:31:44 +0000 |
| commit | fae4db6d2c975173a6768bd4984eb707265f4e43 (patch) | |
| tree | 5f2a213743a58ba45d47aeb5e49f67d3e0b78981 /src/2geom | |
| parent | astyle (diff) | |
| parent | 3D box tool: the shift key must not prevent snapping of the vanishing point. ... (diff) | |
| download | inkscape-fae4db6d2c975173a6768bd4984eb707265f4e43.tar.gz inkscape-fae4db6d2c975173a6768bd4984eb707265f4e43.zip | |
update to trunk
(bzr r13645.1.106)
Diffstat (limited to 'src/2geom')
| -rw-r--r-- | src/2geom/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | src/2geom/conicsec.cpp | 1 | ||||
| -rw-r--r-- | src/2geom/ellipse.cpp | 56 | ||||
| -rw-r--r-- | src/2geom/nearest-time.cpp | 2 | ||||
| -rw-r--r-- | src/2geom/path.cpp | 3 | ||||
| -rw-r--r-- | src/2geom/point.h | 4 | ||||
| -rw-r--r-- | src/2geom/sbasis.cpp | 8 | ||||
| -rwxr-xr-x | src/2geom/sync.sh | 31 |
8 files changed, 82 insertions, 31 deletions
diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index 5d3ca7a6c..2388390b9 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -70,8 +70,6 @@ set(2geom_SRC conic_section_clipper_cr.h conic_section_clipper_impl.h conicsec.h - conjugate_gradient.h - convex-cover.h coord.h crossing.h curve.h @@ -85,7 +83,6 @@ set(2geom_SRC generic-interval.h generic-rect.h geom.h - hvlinesegment.h int-interval.h int-point.h int-rect.h @@ -93,21 +90,17 @@ set(2geom_SRC line.h linear.h math-utils.h - nearest-point.h ord.h path-intersection.h path-sink.h path.h pathvector.h piecewise.h - point-ops.h point.h pointwise.h polynomial.h ray.h rect.h - region.h - satellite.h sbasis-2d.h sbasis-curve.h sbasis-geometric.h @@ -115,7 +108,6 @@ set(2geom_SRC sbasis-poly.h sbasis-to-bezier.h sbasis.h - shape.h solver.h svg-path-parser.h svg-path-writer.h diff --git a/src/2geom/conicsec.cpp b/src/2geom/conicsec.cpp index 3b36137be..089db71a4 100644 --- a/src/2geom/conicsec.cpp +++ b/src/2geom/conicsec.cpp @@ -1337,6 +1337,7 @@ bool xAx::decompose (Line& l1, Line& l2) const */ Rect xAx::arc_bound (const Point & P1, const Point & Q, const Point & P2) const { + using std::swap; //std::cout << "BOUND: P1 = " << P1 << std::endl; //std::cout << "BOUND: Q = " << Q << std::endl; //std::cout << "BOUND: P2 = " << P2 << std::endl; diff --git a/src/2geom/ellipse.cpp b/src/2geom/ellipse.cpp index 0264ab4ae..4b5ad9762 100644 --- a/src/2geom/ellipse.cpp +++ b/src/2geom/ellipse.cpp @@ -205,22 +205,50 @@ Ellipse::arc(Point const &ip, Point const &inner, Point const &fp) bool sweep_flag = false; // Determination of large arc flag: - // The arc is larger than half of the ellipse if the inner point - // is on the same side of the line going from the initial - // to the final point as the center of the ellipse - Point versor = fp - ip; - double sdist_c = cross(versor, _center - ip); - double sdist_inner = cross(versor, inner - ip); - - // if we have exactly half of an arc, do not set the large flag. - if (sdist_c != 0 && sgn(sdist_c) == sgn(sdist_inner)) { + // large_arc is false when the inner point is on the same side + // of the center---initial point line as the final point, AND + // is on the same side of the center---final point line as the + // initial point. + // Additionally, large_arc is always false when we have exactly + // 1/2 of an arc, i.e. the cross product of the center -> initial point + // and center -> final point vectors is zero. + // Negating the above leads to the condition for large_arc being true. + Point fv = fp - _center; + Point iv = ip - _center; + Point innerv = inner - _center; + double ifcp = cross(fv, iv); + + if (ifcp != 0 && (sgn(cross(fv, innerv)) != sgn(ifcp) || + sgn(cross(iv, innerv)) != sgn(-ifcp))) + { large_arc_flag = true; } + //cross(-iv, fv) && large_arc_flag + + // Determination of sweep flag: - // If the inner point is on the left side of the ip-fp line, - // we go in clockwise direction. - if (sdist_inner < 0) { + // For clarity, let's assume that Y grows up. Then the cross product + // is positive for points on the left side of a vector and negative + // on the right side of a vector. + // + // cross(?, v) > 0 + // o-------------------> + // cross(?, v) < 0 + // + // If the arc is small (large_arc_flag is false) and the final point + // is on the right side of the vector initial point -> center, + // we have to go in the direction of increasing angles + // (counter-clockwise) and the sweep flag is true. + // If the arc is large, the opposite is true, since we have to reach + // the final point going the long way - in the other direction. + // We can express this observation as: + // cross(_center - ip, fp - _center) < 0 xor large_arc flag + // This is equal to: + // cross(-iv, fv) < 0 xor large_arc flag + // But cross(-iv, fv) is equal to cross(fv, iv) due to antisymmetry + // of the cross product, so we end up with the condition below. + if ((ifcp < 0) ^ large_arc_flag) { sweep_flag = true; } @@ -499,7 +527,7 @@ std::vector<ShapeIntersection> Ellipse::intersect(Ellipse const &other) const Line lines[2]; if (aa != 0) { - bb /= aa; cc /= aa; dd /= aa; ee /= aa; ff /= aa; + bb /= aa; cc /= aa; dd /= aa; ee /= aa; /*ff /= aa;*/ Coord s = (ee + std::sqrt(ee*ee - 4*bb)) / 2; Coord q = ee - s; Coord alpha = (dd - cc*q) / (s - q); @@ -508,7 +536,7 @@ std::vector<ShapeIntersection> Ellipse::intersect(Ellipse const &other) const lines[0] = Line(1, q, alpha); lines[1] = Line(1, s, beta); } else if (bb != 0) { - cc /= bb; dd /= bb; ee /= bb; ff /= bb; + cc /= bb; /*dd /= bb;*/ ee /= bb; ff /= bb; Coord s = ee; Coord q = 0; Coord alpha = cc / ee; diff --git a/src/2geom/nearest-time.cpp b/src/2geom/nearest-time.cpp index 0b21e51a2..103921021 100644 --- a/src/2geom/nearest-time.cpp +++ b/src/2geom/nearest-time.cpp @@ -80,7 +80,7 @@ Coord nearest_time(Point const &p, D2<Bezier> const &input, Coord from, Coord to t = 0; } if (dfinal < mind) { - mind = dfinal; + //mind = dfinal; t = 1; } diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp index 836e65013..871441751 100644 --- a/src/2geom/path.cpp +++ b/src/2geom/path.cpp @@ -441,7 +441,6 @@ std::vector<PathTime> Path::roots(Coord v, Dim2 d) const // The class below implements sweepline optimization for curve intersection in paths. // Instead of O(N^2), this takes O(N + X), where X is the number of overlaps // between the bounding boxes of curves. -namespace { struct CurveSweepTraits { struct Bound { @@ -512,8 +511,6 @@ private: Coord _precision; }; -} // end anonymous namespace - std::vector<PathIntersection> Path::intersect(Path const &other, Coord precision) const { std::vector<PathIntersection> result; diff --git a/src/2geom/point.h b/src/2geom/point.h index f2659d351..a66e64647 100644 --- a/src/2geom/point.h +++ b/src/2geom/point.h @@ -386,7 +386,9 @@ inline Coord distanceSq (Point const &a, Point const &b) { /// Test whether two points are no further apart than some threshold. /// @relates Point inline bool are_near(Point const &a, Point const &b, double eps = EPSILON) { - return are_near(distance(a, b), 0, eps); + // do not use an unqualified calls to distance before the empty + // specialization of iterator_traits is defined - see end of file + return are_near((a - b).length(), 0, eps); } /// Test whether three points lie approximately on the same line. diff --git a/src/2geom/sbasis.cpp b/src/2geom/sbasis.cpp index 4f1df621e..42d92d7b8 100644 --- a/src/2geom/sbasis.cpp +++ b/src/2geom/sbasis.cpp @@ -328,9 +328,9 @@ SBasis derivative(SBasis const &a) { } int k = a.size()-1; double d = (2*k+1)*(a[k][1] - a[k][0]); - if(d == 0) + if (d == 0 && k > 0) { c.pop_back(); - else { + } else { c[k][0] = d; c[k][1] = d; } @@ -351,9 +351,9 @@ void SBasis::derive() { // in place version } int k = size()-1; double d = (2*k+1)*((*this)[k][1] - (*this)[k][0]); - if(d == 0) + if (d == 0 && k > 0) { pop_back(); - else { + } else { (*this)[k][0] = d; (*this)[k][1] = d; } diff --git a/src/2geom/sync.sh b/src/2geom/sync.sh new file mode 100755 index 000000000..a2c162903 --- /dev/null +++ b/src/2geom/sync.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +function usage { + echo "2Geom sync to upstream script" + echo "Usage: $0 path/to/2geom/checkout/dir" +} + +if [ "x$(which rsync)" = "x" ]; then + echo "rsync not found on your system, please install it" + exit 1 +fi + +if [ "x$1" = "x" ]; then + usage $0 + exit 64 +fi +if [ ! -d "$1" ]; then + usage $0 + exit 64 +fi +if [ ! -f "$1/src/2geom/path.h" ]; then + usage $0 + exit 64 +fi + +INK_2GEOM="$(dirname $0)/" +UPSTREAM_2GEOM="$1/src/2geom/" +rsync -r --existing \ + --exclude CMakeLists.txt --exclude sync.sh \ + "$UPSTREAM_2GEOM" "$INK_2GEOM" |
