Scribus
Open source desktop publishing at your fingertips
d2-sbasis.h
1 #ifdef _2GEOM_D2 /*This is intentional: we don't actually want anyone to
2  include this, other than D2.h. If somone else tries, D2
3  won't be defined. If it is, this will already be included. */
4 #ifndef __2GEOM_SBASIS_CURVE_H
5 #define __2GEOM_SBASIS_CURVE_H
6 
7 #include "sbasis.h"
8 #include "sbasis-2d.h"
9 #include "piecewise.h"
10 #include "matrix.h"
11 
12 //TODO: implement intersect
13 
14 namespace Geom {
15 
16 inline D2<SBasis> compose(D2<SBasis> const & a, SBasis const & b) {
17  return D2<SBasis>(compose(a[X], b), compose(a[Y], b));
18 }
19 
20 SBasis L2(D2<SBasis> const & a, unsigned k);
21 double L2(D2<double> const & a);
22 
23 D2<SBasis> multiply(Linear const & a, D2<SBasis> const & b);
24 inline D2<SBasis> operator*(Linear const & a, D2<SBasis> const & b) { return multiply(a, b); }
25 D2<SBasis> multiply(SBasis const & a, D2<SBasis> const & b);
26 inline D2<SBasis> operator*(SBasis const & a, D2<SBasis> const & b) { return multiply(a, b); }
27 D2<SBasis> truncate(D2<SBasis> const & a, unsigned terms);
28 
29 unsigned sbasis_size(D2<SBasis> const & a);
30 double tail_error(D2<SBasis> const & a, unsigned tail);
31 
32 //Piecewise<D2<SBasis> > specific decls:
33 
34 Piecewise<D2<SBasis> > sectionize(D2<Piecewise<SBasis> > const &a);
35 D2<Piecewise<SBasis> > make_cuts_independant(Piecewise<D2<SBasis> > const &a);
36 Piecewise<D2<SBasis> > rot90(Piecewise<D2<SBasis> > const &a);
37 Piecewise<SBasis> dot(Piecewise<D2<SBasis> > const &a, Piecewise<D2<SBasis> > const &b);
38 Piecewise<SBasis> cross(Piecewise<D2<SBasis> > const &a, Piecewise<D2<SBasis> > const &b);
39 
40 Piecewise<D2<SBasis> > operator*(Piecewise<D2<SBasis> > const &a, Matrix const &m);
41 
42 Piecewise<D2<SBasis> > force_continuity(Piecewise<D2<SBasis> > const &f,
43  double tol=0,
44  bool closed=false);
45 
46 class CoordIterator
47 : public std::iterator<std::input_iterator_tag, SBasis const>
48 {
49 public:
50  CoordIterator(std::vector<D2<SBasis> >::const_iterator const &iter, unsigned d) : impl_(iter), ix_(d) {}
51 
52  inline bool operator==(CoordIterator const &other) { return other.impl_ == impl_; }
53  inline bool operator!=(CoordIterator const &other) { return other.impl_ != impl_; }
54 
55  inline SBasis operator*() const {
56  return (*impl_)[ix_];
57  }
58 
59  inline CoordIterator &operator++() {
60  ++impl_;
61  return *this;
62  }
63  inline CoordIterator operator++(int) {
64  CoordIterator old=*this;
65  ++(*this);
66  return old;
67  }
68 
69 private:
70  std::vector<D2<SBasis> >::const_iterator impl_;
71  unsigned ix_;
72 };
73 
74 inline CoordIterator iterateCoord(Piecewise<D2<SBasis> > const &a, unsigned d) {
75  return CoordIterator(a.segs.begin(), d);
76 }
77 
78 //bounds specializations with order
79 inline Rect bounds_fast(D2<SBasis> const & s, unsigned order=0) {
80  return Rect(bounds_fast(s[X], order),
81  bounds_fast(s[Y], order));
82 }
83 inline Rect bounds_local(D2<SBasis> const & s, Interval i, unsigned order=0) {
84  return Rect(bounds_local(s[X], i, order),
85  bounds_local(s[Y], i, order));
86 }
87 
88 }
89 
90 #endif
91 #endif
Definition: angle.h:38