summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-05-18 14:09:46 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-05-18 14:09:46 +0000
commite37b51c1e3bc642a4f8618085b649f1cc013e6bb (patch)
treeb22a2a7ee09dc440f60a4083dae1162bac7c4aad /src
parentadd SVG Output preferences (diff)
downloadinkscape-e37b51c1e3bc642a4f8618085b649f1cc013e6bb.tar.gz
inkscape-e37b51c1e3bc642a4f8618085b649f1cc013e6bb.zip
update to latest 2geom
(bzr r5689)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/Makefile_insert3
-rw-r--r--src/2geom/forward.h98
-rw-r--r--src/2geom/isnan.h6
-rw-r--r--src/2geom/path.cpp10
-rw-r--r--src/2geom/path.h7
-rw-r--r--src/2geom/pathvector.cpp82
-rw-r--r--src/2geom/pathvector.h62
7 files changed, 265 insertions, 3 deletions
diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert
index ef82b7525..6f2a3e642 100644
--- a/src/2geom/Makefile_insert
+++ b/src/2geom/Makefile_insert
@@ -27,6 +27,7 @@
2geom/d2-sbasis.h \
2geom/d2.h \
2geom/exception.h \
+ 2geom/forward.h \
2geom/geom.cpp \
2geom/geom.h \
2geom/interval.h \
@@ -44,6 +45,8 @@
2geom/path-intersection.h \
2geom/path.cpp \
2geom/path.h \
+ 2geom/pathvector.cpp \
+ 2geom/pathvector.h \
2geom/piecewise.cpp \
2geom/piecewise.h \
2geom/point-l.h \
diff --git a/src/2geom/forward.h b/src/2geom/forward.h
new file mode 100644
index 000000000..a34384023
--- /dev/null
+++ b/src/2geom/forward.h
@@ -0,0 +1,98 @@
+/*
+ * forward - this file contains forward declarations of 2geom types
+ *
+ * Authors:
+ * Johan Engelen <goejendaagh@zonnet.nl>
+ *
+ * Copyright 2008 authors
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ */
+
+#ifndef SEEN_GEOM_FORWARD_H
+#define SEEN_GEOM_FORWARD_H
+
+#include <vector> // include this dependency so PathVector can be defined more explicitly
+
+namespace Geom {
+
+template <unsigned> class BezierCurve;
+template<> class BezierCurve<0>;
+typedef BezierCurve<2> QuadraticBezier;
+typedef BezierCurve<1> LineSegment;
+typedef BezierCurve<3> CubicBezier;
+
+typedef double Coord;
+class Point;
+
+class Exception;
+class LogicalError;
+class RangeError;
+class NotImplemented;
+class InvariantsViolation;
+class NotInvertible;
+class ContinuityError;
+
+class Interval;
+class Linear;
+class Hat;
+class Tri;
+
+class Matrix;
+class Translate;
+class Rotate;
+class Scale;
+
+class Curve;
+class Path;
+typedef std::vector<Path> PathVector;
+
+template <class> class D2;
+template <typename> class Piecewise;
+class SBasis;
+class SBasisCurve;
+
+typedef D2<Interval> Rect;
+
+class Shape;
+class Region;
+
+class SVGEllipticalArc;
+class SVGPathSink;
+template <typename> class SVGPathGenerator;
+
+}
+
+#endif // SEEN_GEOM_FORWARD_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/2geom/isnan.h b/src/2geom/isnan.h
index decebc7d2..96a70f6dc 100644
--- a/src/2geom/isnan.h
+++ b/src/2geom/isnan.h
@@ -1,5 +1,5 @@
-#ifndef __ISNAN_H__
-#define __ISNAN_H__
+#ifndef _2GEOM_ISNAN_H__
+#define _2GEOM_ISNAN_H__
/*
* Temporary fix for various misdefinitions of isnan().
@@ -58,7 +58,7 @@
*/
-#endif /* __ISNAN_H__ */
+#endif /* _2GEOM_ISNAN_H__ */
/*
Local Variables:
diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp
index fdfa77c79..3effa9374 100644
--- a/src/2geom/path.cpp
+++ b/src/2geom/path.cpp
@@ -339,6 +339,16 @@ void Path::append(D2<SBasis> const &curve) {
do_append(new SBasisCurve(curve));
}
+void Path::append(Path const &other)
+{
+ // Check that path stays continuous:
+ if ( !are_near( finalPoint(), other.initialPoint() ) ) {
+ THROW_CONTINUITYERROR();
+ }
+
+ insert(begin(), other.begin(), other.end());
+}
+
void Path::do_update(Sequence::iterator first_replaced,
Sequence::iterator last_replaced,
Sequence::iterator first,
diff --git a/src/2geom/path.h b/src/2geom/path.h
index ed15260fc..0493b4a59 100644
--- a/src/2geom/path.h
+++ b/src/2geom/path.h
@@ -714,6 +714,7 @@ public:
ret.append(*temp);
delete temp;
}
+ ret.closed_ = closed_;
return ret;
}
@@ -844,6 +845,11 @@ public:
do_update(first.impl_, last.impl_, curves_.begin(), curves_.begin());
}
+ // erase last segment of path
+ void erase_last() {
+ erase(curves_.end()-2);
+ }
+
void replace(iterator replaced, Curve const &curve) {
Sequence source(1, curve.duplicate());
try {
@@ -906,6 +912,7 @@ public:
void append(Curve const &curve);
void append(D2<SBasis> const &curve);
+ void append(Path const &other);
template <typename CurveType, typename A>
void appendNew(A a) {
diff --git a/src/2geom/pathvector.cpp b/src/2geom/pathvector.cpp
new file mode 100644
index 000000000..2e3de3f50
--- /dev/null
+++ b/src/2geom/pathvector.cpp
@@ -0,0 +1,82 @@
+/*
+ * PathVector - std::vector containing Geom::Path
+ * This file provides a set of operations that can be performed on PathVector,
+ * e.g. an affine transform.
+ *
+ * Authors:
+ * Johan Engelen <goejendaagh@zonnet.nl>
+ *
+ * Copyright 2008 authors
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ */
+
+#ifndef SEEN_GEOM_PATHVECTOR_CPP
+#define SEEN_GEOM_PATHVECTOR_CPP
+
+#include "pathvector.h"
+
+#include "path.h"
+#include "matrix.h"
+
+namespace Geom {
+
+// TODO: see which of these functions can be inlined for optimization
+
+PathVector operator* (PathVector const & path_in, Matrix const &m)
+{
+ PathVector path_out;
+ for(PathVector::const_iterator it = path_in.begin(); it != path_in.end(); ++it) {
+ path_out.push_back( (*it) * m );
+ }
+ return path_out;
+}
+
+/**
+ * Reverses all Paths and the order of paths in the vector as well
+ **/
+PathVector reverse_paths_and_order (PathVector const & path_in)
+{
+ PathVector path_out;
+ for (PathVector::const_reverse_iterator it = path_in.rbegin(); it != path_in.rend(); it++) {
+ path_out.push_back( (*it).reverse() );
+ }
+ return path_out;
+}
+
+
+} // namespace Geom
+
+#endif // SEEN_GEOM_PATHVECTOR_CPP
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/2geom/pathvector.h b/src/2geom/pathvector.h
new file mode 100644
index 000000000..97a0d19f1
--- /dev/null
+++ b/src/2geom/pathvector.h
@@ -0,0 +1,62 @@
+/*
+ * PathVector - std::vector containing Geom::Path
+ * This file provides a set of operations that can be performed on PathVector,
+ * e.g. an affine transform.
+ *
+ * Authors:
+ * Johan Engelen <goejendaagh@zonnet.nl>
+ *
+ * Copyright 2008 authors
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ */
+
+#ifndef SEEN_GEOM_PATHVECTOR_H
+#define SEEN_GEOM_PATHVECTOR_H
+
+#include "forward.h"
+
+namespace Geom {
+
+typedef std::vector<Geom::Path> PathVector;
+
+
+PathVector operator* (PathVector const & path_in, Matrix const &m);
+
+PathVector reverse_paths_and_order (PathVector const & path_in);
+
+}
+
+#endif // SEEN_GEOM_PATHVECTOR_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :