Rev 15347 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
15347 | fschmid | 1 | #ifdef _2GEOM_D2 /*This is intentional: we don't actually want anyone to |
12065 | fschmid | 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" |
||
15347 | fschmid | 10 | #include "matrix.h" |
12065 | fschmid | 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); |
||
15347 | fschmid | 35 | D2<Piecewise<SBasis> > make_cuts_independant(Piecewise<D2<SBasis> > const &a); |
12065 | fschmid | 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 | |||
15347 | fschmid | 40 | Piecewise<D2<SBasis> > operator*(Piecewise<D2<SBasis> > const &a, Matrix const &m); |
12065 | fschmid | 41 | |
15347 | fschmid | 42 | Piecewise<D2<SBasis> > force_continuity(Piecewise<D2<SBasis> > const &f, |
43 | double tol=0, |
||
44 | bool closed=false); |
||
12065 | fschmid | 45 | |
46 | class CoordIterator |
||
47 | { |
||
48 | public: |
||
49 | CoordIterator(std::vector<D2<SBasis> >::const_iterator const &iter, unsigned d) : impl_(iter), ix_(d) {} |
||
50 | |||
25149 | jghali | 51 | using iterator_category = std::input_iterator_tag; |
52 | using value_type = SBasis const; |
||
53 | using difference_type = ptrdiff_t; |
||
54 | using pointer = SBasis const*; |
||
55 | using reference = SBasis const&; |
||
56 | |||
12065 | fschmid | 57 | inline bool operator==(CoordIterator const &other) { return other.impl_ == impl_; } |
58 | inline bool operator!=(CoordIterator const &other) { return other.impl_ != impl_; } |
||
59 | |||
60 | inline SBasis operator*() const { |
||
61 | return (*impl_)[ix_]; |
||
62 | } |
||
63 | |||
64 | inline CoordIterator &operator++() { |
||
65 | ++impl_; |
||
66 | return *this; |
||
67 | } |
||
68 | inline CoordIterator operator++(int) { |
||
69 | CoordIterator old=*this; |
||
70 | ++(*this); |
||
71 | return old; |
||
72 | } |
||
73 | |||
74 | private: |
||
75 | std::vector<D2<SBasis> >::const_iterator impl_; |
||
76 | unsigned ix_; |
||
77 | }; |
||
78 | |||
79 | inline CoordIterator iterateCoord(Piecewise<D2<SBasis> > const &a, unsigned d) { |
||
80 | return CoordIterator(a.segs.begin(), d); |
||
81 | } |
||
82 | |||
83 | //bounds specializations with order |
||
15347 | fschmid | 84 | inline Rect bounds_fast(D2<SBasis> const & s, unsigned order=0) { |
85 | return Rect(bounds_fast(s[X], order), |
||
86 | bounds_fast(s[Y], order)); |
||
12065 | fschmid | 87 | } |
15347 | fschmid | 88 | inline Rect bounds_local(D2<SBasis> const & s, Interval i, unsigned order=0) { |
89 | return Rect(bounds_local(s[X], i, order), |
||
90 | bounds_local(s[Y], i, order)); |
||
12065 | fschmid | 91 | } |
92 | |||
93 | } |
||
94 | |||
95 | #endif |
||
96 | #endif |