- Main Page
- Related Pages
- Namespaces
- Classes
- Files

# blineconvert.h

Go to the documentation of this file.

    00001 /* === S Y N F I G ========================================================= */
    00021 /* ========================================================================= */
    00022
    00023 /* === S T A R T =========================================================== */
    00024
    00025 #ifndef __SYNFIG_BLINE_CONVERT_H
    00026 #define __SYNFIG_BLINE_CONVERT_H
    00027
    00028 /* === H E A D E R S ======================================================= */
    00029
    00030 #include <synfig/general.h>
    00031 #include <synfig/blinepoint.h>
    00032 #include <list>
    00033 #include <vector>
    00034
    00035 /* === M A C R O S ========================================================= */
    00036
    00037 /* === T Y P E D E F S ===================================================== */
    00038
    00039 /* === C L A S S E S & S T R U C T S ======================================= */
    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;  //negative error will indicate invalid;
    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         //point is obviously in[curind]
    00074         //tangent scale will get reset to the smallest (or something else depending on experimentation)
    00075     };
    00076
    00077 private:
    00078     //cached data
    00079     std::vector<synfig::Point>  point_cache;    //the preprocessed input cache
    00080     std::vector<synfig::Real>   width_cache;
    00081
    00082     //temporary point storage for vector calc
    00083     std::vector<synfig::Point>  ftemp;
    00084
    00085     std::vector<synfig::Vector> deriv; //the derivative cache
    00086     std::vector<synfig::Real>   curvature; //the curvature cache
    00087
    00088     std::vector<int>            break_tangents; //the break point cache
    00089
    00090     std::vector<synfig::Real>   cum_dist,   //cumulative distance
    00091                                 this_dist; //distance between adjacent segments
    00092
    00093     std::vector<synfig::Point>  work; //the working point cache for the entire curve
    00094     std::vector<cpindex>        curind;
    00095
    00096     //function parameters
    00097     void clear();
    00098
    00099 public:
    00100     synfig::Real width;
    00101
    00102     //Converter properties
    00103     synfig::Real pixelwidth;
    00104     synfig::Real smoothness; //actual error will be smoothness*pixelwidth (for global set pixelwidth = 1)
    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 }; // END of namespace synfigapp
    00113
    00114 /* === E N D =============================================================== */
    00115
    00116 #endif