summaryrefslogtreecommitdiffstats
path: root/src/2geom
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2015-04-28 23:02:19 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2015-04-28 23:02:19 +0000
commitcfa7054c950050095e596edd18fedad53e7ed636 (patch)
tree2142ac03239c40a4af6b367754ddf3421e337577 /src/2geom
parent2Geom sync - initial commit (diff)
downloadinkscape-cfa7054c950050095e596edd18fedad53e7ed636.tar.gz
inkscape-cfa7054c950050095e596edd18fedad53e7ed636.zip
Fix calls to Geom::cross() - sign change.
(bzr r14059.2.2)
Diffstat (limited to 'src/2geom')
-rw-r--r--src/2geom/path.cpp10
-rw-r--r--src/2geom/path.h4
-rw-r--r--src/2geom/pathvector.cpp9
-rw-r--r--src/2geom/pathvector.h2
4 files changed, 24 insertions, 1 deletions
diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp
index cf8b15d60..8eb5c7fcb 100644
--- a/src/2geom/path.cpp
+++ b/src/2geom/path.cpp
@@ -760,6 +760,16 @@ void Path::replace(iterator first, iterator last, Path const &path)
replace(first, last, path.begin(), path.end());
}
+void Path::snapEnds(Coord precision)
+{
+ if (!_closed) return;
+ if (_curves->size() > 1 && are_near(_closing_seg->length(precision), 0, precision)) {
+ _unshare();
+ _closing_seg->setInitial(_closing_seg->finalPoint());
+ (_curves->end() - 1)->setFinal(_closing_seg->finalPoint());
+ }
+}
+
// replace curves between first and last with contents of source,
//
void Path::do_update(Sequence::iterator first, Sequence::iterator last, Sequence &source)
diff --git a/src/2geom/path.h b/src/2geom/path.h
index 1940aa580..8d585cd57 100644
--- a/src/2geom/path.h
+++ b/src/2geom/path.h
@@ -749,6 +749,10 @@ public:
do_append(new CurveType(finalPoint(), a, b, c, d, e, f, g, h, i));
}
+ /** @brief Reduce the closing segment to a point if it's shorter than precision.
+ * Do this by moving the final point. */
+ void snapEnds(Coord precision = EPSILON);
+
/// Append a stitching segment ending at the specified point.
void stitchTo(Point const &p);
diff --git a/src/2geom/pathvector.cpp b/src/2geom/pathvector.cpp
index 36364de9b..d2dc468c6 100644
--- a/src/2geom/pathvector.cpp
+++ b/src/2geom/pathvector.cpp
@@ -126,13 +126,20 @@ OptRect PathVector::boundsExact() const
return bound;
}
+void PathVector::snapEnds(Coord precision)
+{
+ for (std::size_t i = 0; i < size(); ++i) {
+ (*this)[i].snapEnds(precision);
+ }
+}
+
std::vector<PVIntersection> PathVector::intersect(PathVector const &other, Coord precision) const
{
typedef PathVectorPosition PVPos;
std::vector<PVIntersection> result;
for (std::size_t i = 0; i < size(); ++i) {
for (std::size_t j = 0; j < other.size(); ++j) {
- std::vector<PathIntersection> xs = (*this)[i].intersect(other[j]);
+ std::vector<PathIntersection> xs = (*this)[i].intersect(other[j], precision);
for (std::size_t k = 0; k < xs.size(); ++k) {
PVIntersection pvx(PVPos(i, xs[k].first), PVPos(j, xs[k].second), xs[k].point());
result.push_back(pvx);
diff --git a/src/2geom/pathvector.h b/src/2geom/pathvector.h
index 6765d6bc0..9140e3872 100644
--- a/src/2geom/pathvector.h
+++ b/src/2geom/pathvector.h
@@ -257,6 +257,8 @@ public:
return boost::range::equal(_data, other._data);
}
+ void snapEnds(Coord precision = EPSILON);
+
std::vector<PVIntersection> intersect(PathVector const &other, Coord precision = EPSILON) const;
/** @brief Determine the winding number at the specified point.