summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2015-07-05 01:47:36 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2015-07-05 01:47:36 +0000
commit009833c1d6be271d611c183aae781e41b71ca927 (patch)
tree52108612e2f130dc9a5da8a5cb7dd0398cc91708 /src
parentTranslation. Danish translation update. (diff)
downloadinkscape-009833c1d6be271d611c183aae781e41b71ca927.tar.gz
inkscape-009833c1d6be271d611c183aae781e41b71ca927.zip
Fix compilation failure in make check
(bzr r14228)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/!PLEASE DON'T MAKE CHANGES IN THESE FILES.README4
-rw-r--r--src/2geom/forward.h2
-rw-r--r--src/2geom/path.h1
-rw-r--r--src/display/curve-test.h71
-rw-r--r--src/display/curve.cpp18
-rw-r--r--src/svg/svg-path-geom-test.h121
6 files changed, 47 insertions, 170 deletions
diff --git a/src/2geom/!PLEASE DON'T MAKE CHANGES IN THESE FILES.README b/src/2geom/!PLEASE DON'T MAKE CHANGES IN THESE FILES.README
index 074921de2..e94a549f6 100644
--- a/src/2geom/!PLEASE DON'T MAKE CHANGES IN THESE FILES.README
+++ b/src/2geom/!PLEASE DON'T MAKE CHANGES IN THESE FILES.README
@@ -2,11 +2,11 @@ This is an in-tree copy of lib2geom, a 2D geometry library started
by Inkscape developers. If you want to change code in 2Geom, you should
commit it first to upstream repository and then execute this command:
-rsync -r --existing /path/to/lib2geom/src/2geom /path/to/inkscape/src/2geom
+rsync -r --existing --exclude CMakeLists.txt /path/to/lib2geom/src/2geom/ /path/to/inkscape/src/2geom/
The command above will only update existing files. If you add new files
to 2Geom, you'll need to copy the new files manually. Same if you remove
-some files.
+some files. Note that the trailing slashes are required!
2geom's BZR repo = lp:lib2geom
http://lib2geom.sourceforge.net
diff --git a/src/2geom/forward.h b/src/2geom/forward.h
index cf9c75988..27909242c 100644
--- a/src/2geom/forward.h
+++ b/src/2geom/forward.h
@@ -72,8 +72,6 @@ class ConvexHull;
class Curve;
class SBasisCurve;
class BezierCurve;
-class HLineSegment;
-class VLineSegment;
template <unsigned degree> class BezierCurveN;
typedef BezierCurveN<1> LineSegment;
typedef BezierCurveN<2> QuadraticBezier;
diff --git a/src/2geom/path.h b/src/2geom/path.h
index a2d1e751e..3ca43e0e5 100644
--- a/src/2geom/path.h
+++ b/src/2geom/path.h
@@ -389,6 +389,7 @@ public:
swap(other._curves, _curves);
swap(other._closing_seg, _closing_seg);
swap(other._closed, _closed);
+ swap(other._exception_on_stitch, _exception_on_stitch);
}
/** @brief Swap contents of two paths.
* @relates Path */
diff --git a/src/display/curve-test.h b/src/display/curve-test.h
index 34137f3c8..f921a5361 100644
--- a/src/display/curve-test.h
+++ b/src/display/curve-test.h
@@ -16,15 +16,16 @@ public:
CurveTest() : path4(Geom::Point(3,5)) // Just a moveto
{
// Closed path
- path1.append(Geom::HLineSegment(Geom::Point(0,0),1));
- path1.append(Geom::VLineSegment(Geom::Point(1,0),1));
+ path1.append(Geom::LineSegment(Geom::Point(0,0),Geom::Point(1,0)));
+ path1.append(Geom::LineSegment(Geom::Point(1,0),Geom::Point(1,1)));
path1.close();
// Closed path (ClosingSegment is zero length)
path2.append(Geom::LineSegment(Geom::Point(2,0),Geom::Point(3,0)));
- // TODO fix path2.append(Geom::BezierCurve<3>(Geom::Point(3,0),Geom::Point(2,1),Geom::Point(1,1),Geom::Point(2,0)));
+ path2.append(Geom::CubicBezier(Geom::Point(3,0),Geom::Point(2,1),Geom::Point(1,1),Geom::Point(2,0)));
path2.close();
// Open path
- path3.append(Geom::SVGEllipticalArc(Geom::Point(4,0),1,2,M_PI,false,false,Geom::Point(5,1)));
+ path3.setStitching(true);
+ path3.append(Geom::EllipticalArc(Geom::Point(4,0),1,2,M_PI,false,false,Geom::Point(5,1)));
path3.append(Geom::LineSegment(Geom::Point(5,1),Geom::Point(5,2)));
path3.append(Geom::LineSegment(Geom::Point(6,4),Geom::Point(2,4)));
}
@@ -49,17 +50,17 @@ public:
TS_ASSERT_EQUALS(curve.get_segment_count() , 0u);
}
{ // Individual paths
- Geom::PathVector pv(1, Geom::Path());
+ Geom::PathVector pv((Geom::Path()));
pv[0] = path1;
TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 3u);
pv[0] = path2;
- TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 3u);
+ TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 2u);
pv[0] = path3;
TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 4u);
pv[0] = path4;
TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 0u);
pv[0].close();
- TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 1u);
+ TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 0u);
}
{ // Combination
Geom::PathVector pv;
@@ -68,7 +69,7 @@ public:
pv.push_back(path3);
pv.push_back(path4);
SPCurve curve(pv);
- TS_ASSERT_EQUALS(curve.get_segment_count() , 10u);
+ TS_ASSERT_EQUALS(curve.get_segment_count() , 9u);
}
}
@@ -86,7 +87,7 @@ public:
TS_ASSERT_EQUALS(curve.nodes_in_path() , 1u);
}
{ // Individual paths
- Geom::PathVector pv(1, Geom::Path());
+ Geom::PathVector pv((Geom::Path()));
pv[0] = path1;
TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 3u);
pv[0] = path2;
@@ -112,28 +113,28 @@ public:
void testIsEmpty()
{
TS_ASSERT(SPCurve(Geom::PathVector()).is_empty());
- TS_ASSERT(!SPCurve(Geom::PathVector(1, path1)).is_empty());
- TS_ASSERT(!SPCurve(Geom::PathVector(1, path2)).is_empty());
- TS_ASSERT(!SPCurve(Geom::PathVector(1, path3)).is_empty());
- TS_ASSERT(!SPCurve(Geom::PathVector(1, path4)).is_empty());
+ TS_ASSERT(!SPCurve(path1).is_empty());
+ TS_ASSERT(!SPCurve(path2).is_empty());
+ TS_ASSERT(!SPCurve(path3).is_empty());
+ TS_ASSERT(!SPCurve(path4).is_empty());
}
void testIsClosed()
{
TS_ASSERT(!SPCurve(Geom::PathVector()).is_closed());
- Geom::PathVector pv(1, Geom::Path());
+ Geom::PathVector pv((Geom::Path()));
TS_ASSERT(!SPCurve(pv).is_closed());
pv[0].close();
TS_ASSERT(SPCurve(pv).is_closed());
- TS_ASSERT(SPCurve(Geom::PathVector(1, path1)).is_closed());
- TS_ASSERT(SPCurve(Geom::PathVector(1, path2)).is_closed());
- TS_ASSERT(!SPCurve(Geom::PathVector(1, path3)).is_closed());
- TS_ASSERT(!SPCurve(Geom::PathVector(1, path4)).is_closed());
+ TS_ASSERT(SPCurve(path1).is_closed());
+ TS_ASSERT(SPCurve(path2).is_closed());
+ TS_ASSERT(!SPCurve(path3).is_closed());
+ TS_ASSERT(!SPCurve(path4).is_closed());
}
void testLastFirstSegment()
{
- Geom::PathVector pv(1, path4);
+ Geom::PathVector pv(path4);
TS_ASSERT_EQUALS(SPCurve(pv).first_segment() , (void*)0);
TS_ASSERT_EQUALS(SPCurve(pv).last_segment() , (void*)0);
pv[0].close();
@@ -185,10 +186,10 @@ public:
void testFirstPoint()
{
- TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path1)).first_point()) , Geom::Point(0,0));
- TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path2)).first_point()) , Geom::Point(2,0));
- TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path3)).first_point()) , Geom::Point(4,0));
- TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path4)).first_point()) , Geom::Point(3,5));
+ TS_ASSERT_EQUALS(*(SPCurve(path1).first_point()) , Geom::Point(0,0));
+ TS_ASSERT_EQUALS(*(SPCurve(path2).first_point()) , Geom::Point(2,0));
+ TS_ASSERT_EQUALS(*(SPCurve(path3).first_point()) , Geom::Point(4,0));
+ TS_ASSERT_EQUALS(*(SPCurve(path4).first_point()) , Geom::Point(3,5));
Geom::PathVector pv;
TS_ASSERT(!SPCurve(pv).first_point());
pv.push_back(path1);
@@ -201,10 +202,10 @@ public:
void testLastPoint()
{
- TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path1)).last_point()) , Geom::Point(0,0));
- TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path2)).last_point()) , Geom::Point(2,0));
- TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path3)).last_point()) , Geom::Point(8,4));
- TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path4)).last_point()) , Geom::Point(3,5));
+ TS_ASSERT_EQUALS(*(SPCurve(path1).last_point()) , Geom::Point(0,0));
+ TS_ASSERT_EQUALS(*(SPCurve(path2).last_point()) , Geom::Point(2,0));
+ TS_ASSERT_EQUALS(*(SPCurve(path3).last_point()) , Geom::Point(8,4));
+ TS_ASSERT_EQUALS(*(SPCurve(path4).last_point()) , Geom::Point(3,5));
Geom::PathVector pv;
TS_ASSERT(!SPCurve(pv).last_point());
pv.push_back(path1);
@@ -217,10 +218,10 @@ public:
void testSecondPoint()
{
- TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(1, path1)).second_point()) , Geom::Point(1,0));
- TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(1, path2)).second_point()) , Geom::Point(3,0));
- TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(1, path3)).second_point()) , Geom::Point(5,1));
- TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(1, path4)).second_point()) , Geom::Point(3,5));
+ TS_ASSERT_EQUALS( *(SPCurve(path1).second_point()) , Geom::Point(1,0));
+ TS_ASSERT_EQUALS( *(SPCurve(path2).second_point()) , Geom::Point(3,0));
+ TS_ASSERT_EQUALS( *(SPCurve(path3).second_point()) , Geom::Point(5,1));
+ TS_ASSERT_EQUALS( *(SPCurve(path4).second_point()) , Geom::Point(3,5));
Geom::PathVector pv;
pv.push_back(path1);
pv.push_back(path2);
@@ -232,10 +233,10 @@ public:
void testPenultimatePoint()
{
- TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(1, path1)).penultimate_point()) , Geom::Point(1,1));
- TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(1, path2)).penultimate_point()) , Geom::Point(3,0));
- TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(1, path3)).penultimate_point()) , Geom::Point(6,4));
- TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(1, path4)).penultimate_point()) , Geom::Point(3,5));
+ TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(path1)).penultimate_point()) , Geom::Point(1,1));
+ TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(path2)).penultimate_point()) , Geom::Point(3,0));
+ TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(path3)).penultimate_point()) , Geom::Point(6,4));
+ TS_ASSERT_EQUALS( *(SPCurve(Geom::PathVector(path4)).penultimate_point()) , Geom::Point(3,5));
Geom::PathVector pv;
pv.push_back(path1);
pv.push_back(path2);
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index d236d81cf..2f422c151 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -627,20 +627,10 @@ SPCurve::nodes_in_path() const
{
size_t nr = 0;
for(Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) {
- nr += (*it).size();
-
- nr++; // count last node (this works also for closed paths because although they don't have a 'last node', they do have an extra segment
-
- // do not count closing knot double for zero-length closing line segments
- // however, if the path is only a moveto, and is closed, do not subtract 1 (otherwise the result will be zero nodes)
- if ( it->closed()
- && ((*it).size() != 0) )
- {
- Geom::Curve const &c = it->back_closed();
- if (are_near(c.initialPoint(), c.finalPoint())) {
- nr--;
- }
- }
+ // if the path does not have any segments, it is a naked moveto,
+ // and therefore any path has at least one valid node
+ size_t psize = std::max(1ul, it->size_closed());
+ nr += psize;
}
return nr;
diff --git a/src/svg/svg-path-geom-test.h b/src/svg/svg-path-geom-test.h
index 3558b4e55..c3972133d 100644
--- a/src/svg/svg-path-geom-test.h
+++ b/src/svg/svg-path-geom-test.h
@@ -453,38 +453,6 @@ private:
return false;
}
}
- else if(Geom::HLineSegment const *la = dynamic_cast<Geom::HLineSegment const*>(ca))
- {
- Geom::HLineSegment const *lb = dynamic_cast<Geom::HLineSegment const*>(cb);
- if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- }
- else if(Geom::VLineSegment const *la = dynamic_cast<Geom::VLineSegment const*>(ca))
- {
- Geom::VLineSegment const *lb = dynamic_cast<Geom::VLineSegment const*>(cb);
- if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- }
else if(Geom::CubicBezier const *la = dynamic_cast<Geom::CubicBezier const*>(ca))
{
Geom::CubicBezier const *lb = dynamic_cast<Geom::CubicBezier const*>(cb);
@@ -522,91 +490,10 @@ private:
}
else // not same type
{
- if(Geom::LineSegment const *la = dynamic_cast<Geom::LineSegment const*>(ca))
- {
- if (Geom::HLineSegment const *lb = dynamic_cast<Geom::HLineSegment const*>(cb)) {
- if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- char temp[200];
- sprintf(temp, "A LineSegment and an HLineSegment have been considered equal. Subpath: %u, segment: %u", static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_TRACE(temp);
- } else if (Geom::VLineSegment const *lb = dynamic_cast<Geom::VLineSegment const*>(cb)) {
- if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- char temp[200];
- sprintf(temp, "A LineSegment and a VLineSegment have been considered equal. Subpath: %u, segment: %u", static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_TRACE(temp);
- } else {
- char temp[200];
- sprintf(temp, "Different curve types: %s != %s, subpath: %u, segment: %u", typeid(*ca).name(), typeid(*cb).name(), static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- }
- }
- else if(Geom::LineSegment const *lb = dynamic_cast<Geom::LineSegment const*>(cb))
- {
- if (Geom::HLineSegment const *la = dynamic_cast<Geom::HLineSegment const*>(ca)) {
- if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- char temp[200];
- sprintf(temp, "An HLineSegment and a LineSegment have been considered equal. Subpath: %u, segment: %u", static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_TRACE(temp);
- } else if (Geom::VLineSegment const *la = dynamic_cast<Geom::VLineSegment const*>(ca)) {
- if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) {
- char temp[200];
- sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- char temp[200];
- sprintf(temp, "A VLineSegment and a LineSegment have been considered equal. Subpath: %u, segment: %u", static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_TRACE(temp);
- } else {
- char temp[200];
- sprintf(temp, "Different curve types: %s != %s, subpath: %u, segment: %u", typeid(*ca).name(), typeid(*cb).name(), static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- return false;
- }
- } else {
- char temp[200];
- sprintf(temp, "Different curve types: %s != %s, subpath: %u, segment: %u", typeid(*ca).name(), typeid(*cb).name(), static_cast<unsigned int>(i), static_cast<unsigned int>(j));
- TS_FAIL(temp);
- }
+ char temp[200];
+ sprintf(temp, "Different curve types: %s != %s, subpath: %u, segment: %u", typeid(*ca).name(), typeid(*cb).name(), static_cast<unsigned int>(i), static_cast<unsigned int>(j));
+ TS_FAIL(temp);
+ return false;
}
}
}