dd1a8e11cf875f2b03fa5bba880cbc2693df879d
1 /**
2 * \file
3 * \brief Do not include this file \todo brief description
4 *
5 * We don't actually want anyone to
6 * include this, other than D2.h. If somone else tries, D2
7 * won't be defined. If it is, this will already be included.
8 *
9 * Authors:
10 * ? <?@?.?>
11 *
12 * Copyright ?-? authors
13 *
14 * This library is free software; you can redistribute it and/or
15 * modify it either under the terms of the GNU Lesser General Public
16 * License version 2.1 as published by the Free Software Foundation
17 * (the "LGPL") or, at your option, under the terms of the Mozilla
18 * Public License Version 1.1 (the "MPL"). If you do not alter this
19 * notice, a recipient may use your version of this file under either
20 * the MPL or the LGPL.
21 *
22 * You should have received a copy of the LGPL along with this library
23 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * You should have received a copy of the MPL along with this library
26 * in the file COPYING-MPL-1.1
27 *
28 * The contents of this file are subject to the Mozilla Public License
29 * Version 1.1 (the "License"); you may not use this file except in
30 * compliance with the License. You may obtain a copy of the License at
31 * http://www.mozilla.org/MPL/
32 *
33 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
34 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
35 * the specific language governing rights and limitations.
36 *
37 */
39 #ifdef _2GEOM_D2 /*This is intentional: we don't actually want anyone to
40 include this, other than D2.h. If somone else tries, D2
41 won't be defined. If it is, this will already be included. */
42 #ifndef __2GEOM_SBASIS_CURVE_H
43 #define __2GEOM_SBASIS_CURVE_H
45 #include <2geom/sbasis.h>
46 #include <2geom/sbasis-2d.h>
47 #include <2geom/piecewise.h>
48 #include <2geom/matrix.h>
50 //TODO: implement intersect
52 namespace Geom {
54 inline D2<SBasis> compose(D2<SBasis> const & a, SBasis const & b) {
55 return D2<SBasis>(compose(a[X], b), compose(a[Y], b));
56 }
58 SBasis L2(D2<SBasis> const & a, unsigned k);
59 double L2(D2<double> const & a);
61 D2<SBasis> multiply(Linear const & a, D2<SBasis> const & b);
62 inline D2<SBasis> operator*(Linear const & a, D2<SBasis> const & b) { return multiply(a, b); }
63 D2<SBasis> multiply(SBasis const & a, D2<SBasis> const & b);
64 inline D2<SBasis> operator*(SBasis const & a, D2<SBasis> const & b) { return multiply(a, b); }
65 D2<SBasis> truncate(D2<SBasis> const & a, unsigned terms);
67 unsigned sbasis_size(D2<SBasis> const & a);
68 double tail_error(D2<SBasis> const & a, unsigned tail);
70 //Piecewise<D2<SBasis> > specific decls:
72 Piecewise<D2<SBasis> > sectionize(D2<Piecewise<SBasis> > const &a);
73 D2<Piecewise<SBasis> > make_cuts_independent(Piecewise<D2<SBasis> > const &a);
74 Piecewise<D2<SBasis> > rot90(Piecewise<D2<SBasis> > const &a);
75 Piecewise<SBasis> dot(Piecewise<D2<SBasis> > const &a, Piecewise<D2<SBasis> > const &b);
76 Piecewise<SBasis> cross(Piecewise<D2<SBasis> > const &a, Piecewise<D2<SBasis> > const &b);
78 Piecewise<D2<SBasis> > operator*(Piecewise<D2<SBasis> > const &a, Matrix const &m);
80 Piecewise<D2<SBasis> > force_continuity(Piecewise<D2<SBasis> > const &f, double tol=0, bool closed=false);
82 std::vector<Geom::Piecewise<Geom::D2<Geom::SBasis> > > split_at_discontinuities (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwsbin, double tol = .0001);
84 class CoordIterator
85 : public std::iterator<std::input_iterator_tag, SBasis const>
86 {
87 public:
88 CoordIterator(std::vector<D2<SBasis> >::const_iterator const &iter, unsigned d) : impl_(iter), ix_(d) {}
90 inline bool operator==(CoordIterator const &other) { return other.impl_ == impl_; }
91 inline bool operator!=(CoordIterator const &other) { return other.impl_ != impl_; }
93 inline SBasis operator*() const {
94 return (*impl_)[ix_];
95 }
97 inline CoordIterator &operator++() {
98 ++impl_;
99 return *this;
100 }
101 inline CoordIterator operator++(int) {
102 CoordIterator old=*this;
103 ++(*this);
104 return old;
105 }
107 private:
108 std::vector<D2<SBasis> >::const_iterator impl_;
109 unsigned ix_;
110 };
112 inline CoordIterator iterateCoord(Piecewise<D2<SBasis> > const &a, unsigned d) {
113 return CoordIterator(a.segs.begin(), d);
114 }
116 //bounds specializations with order
117 inline Rect bounds_fast(D2<SBasis> const & s, unsigned order=0) {
118 return Rect(bounds_fast(s[X], order),
119 bounds_fast(s[Y], order));
120 }
121 inline Rect bounds_local(D2<SBasis> const & s, Interval i, unsigned order=0) {
122 return Rect(bounds_local(s[X], i, order),
123 bounds_local(s[Y], i, order));
124 }
126 }
128 #endif
129 #endif
132 /*
133 Local Variables:
134 mode:c++
135 c-file-style:"stroustrup"
136 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
137 indent-tabs-mode:nil
138 fill-column:99
139 End:
140 */
141 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :