#ifdef _2GEOM_D2 /*This is intentional: we don't actually want anyone to include this, other than D2.h. If somone else tries, D2 won't be defined. If it is, this will already be included. */ #ifndef __2GEOM_SBASIS_CURVE_H #define __2GEOM_SBASIS_CURVE_H #include "sbasis.h" #include "sbasis-2d.h" #include "piecewise.h" #include "matrix.h" //TODO: implement intersect namespace Geom { inline D2 compose(D2 const & a, SBasis const & b) { return D2(compose(a[X], b), compose(a[Y], b)); } SBasis L2(D2 const & a, unsigned k); double L2(D2 const & a); D2 multiply(Linear const & a, D2 const & b); inline D2 operator*(Linear const & a, D2 const & b) { return multiply(a, b); } D2 multiply(SBasis const & a, D2 const & b); inline D2 operator*(SBasis const & a, D2 const & b) { return multiply(a, b); } D2 truncate(D2 const & a, unsigned terms); unsigned sbasis_size(D2 const & a); double tail_error(D2 const & a, unsigned tail); //Piecewise > specific decls: Piecewise > sectionize(D2 > const &a); D2 > make_cuts_independant(Piecewise > const &a); Piecewise > rot90(Piecewise > const &a); Piecewise dot(Piecewise > const &a, Piecewise > const &b); Piecewise cross(Piecewise > const &a, Piecewise > const &b); Piecewise > operator*(Piecewise > const &a, Matrix const &m); Piecewise > force_continuity(Piecewise > const &f, double tol=0, bool closed=false); class CoordIterator : public std::iterator { public: CoordIterator(std::vector >::const_iterator const &iter, unsigned d) : impl_(iter), ix_(d) {} inline bool operator==(CoordIterator const &other) { return other.impl_ == impl_; } inline bool operator!=(CoordIterator const &other) { return other.impl_ != impl_; } inline SBasis operator*() const { return (*impl_)[ix_]; } inline CoordIterator &operator++() { ++impl_; return *this; } inline CoordIterator operator++(int) { CoordIterator old=*this; ++(*this); return old; } private: std::vector >::const_iterator impl_; unsigned ix_; }; inline CoordIterator iterateCoord(Piecewise > const &a, unsigned d) { return CoordIterator(a.segs.begin(), d); } //bounds specializations with order inline Rect bounds_fast(D2 const & s, unsigned order=0) { return Rect(bounds_fast(s[X], order), bounds_fast(s[Y], order)); } inline Rect bounds_local(D2 const & s, Interval i, unsigned order=0) { return Rect(bounds_local(s[X], i, order), bounds_local(s[Y], i, order)); } } #endif #endif