00001
00021
00022
00023
00024
00025 #ifndef __SYNFIG_BLINE_CONVERT_H
00026 #define __SYNFIG_BLINE_CONVERT_H
00027
00028
00029
00030 #include <synfig/general.h>
00031 #include <synfig/blinepoint.h>
00032 #include <list>
00033 #include <vector>
00034
00035
00036
00037
00038
00039
00040
00041 namespace synfigapp {
00042
00043 class BLineConverter
00044 {
00045 public:
00046 struct cpindex
00047 {
00048 int curind;
00049 synfig::Real tangentscale;
00050 synfig::Real error;
00051
00052 cpindex(int ci, synfig::Real s=0, synfig::Real e=-1)
00053 :curind(ci), tangentscale(s), error(e)
00054 {}
00055
00056 cpindex(const cpindex & o)
00057 :curind(o.curind), tangentscale(o.tangentscale), error(o.error)
00058 {}
00059
00060 const cpindex & operator=(const cpindex & rhs)
00061 {
00062 curind = rhs.curind;
00063 tangentscale = rhs.tangentscale;
00064 error = rhs.error;
00065 return *this;
00066 }
00067
00068 bool operator<(const cpindex &rhs) const
00069 {
00070 return curind < rhs.curind;
00071 }
00072
00073
00074
00075 };
00076
00077 private:
00078
00079 std::vector<synfig::Point> point_cache;
00080 std::vector<synfig::Real> width_cache;
00081
00082
00083 std::vector<synfig::Point> ftemp;
00084
00085 std::vector<synfig::Vector> deriv;
00086 std::vector<synfig::Real> curvature;
00087
00088 std::vector<int> break_tangents;
00089
00090 std::vector<synfig::Real> cum_dist,
00091 this_dist;
00092
00093 std::vector<synfig::Point> work;
00094 std::vector<cpindex> curind;
00095
00096
00097 void clear();
00098
00099 public:
00100 synfig::Real width;
00101
00102
00103 synfig::Real pixelwidth;
00104 synfig::Real smoothness;
00105
00106 BLineConverter();
00107
00108 static void EnforceMinWidth(std::list<synfig::BLinePoint> &bline, synfig::Real min_pressure);
00109 void operator()(std::list<synfig::BLinePoint> &out, const std::list<synfig::Point> &in,const std::list<synfig::Real> &in_w);
00110 };
00111
00112 };
00113
00114
00115
00116 #endif