X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftags%2F0.61.08%2Fsrc%2Fsynfigapp%2Fblineconvert.h;fp=synfig-studio%2Ftags%2F0.61.08%2Fsrc%2Fsynfigapp%2Fblineconvert.h;h=2b27187fbf62a367ca750b4164a7c7887da89e62;hb=79fcd5b32f0accf9f1d13f9b6ded0d628e6f4b33;hp=0000000000000000000000000000000000000000;hpb=c1f365570ac471ede0668ad976fad345747aa8de;p=synfig.git diff --git a/synfig-studio/tags/0.61.08/src/synfigapp/blineconvert.h b/synfig-studio/tags/0.61.08/src/synfigapp/blineconvert.h new file mode 100644 index 0000000..2b27187 --- /dev/null +++ b/synfig-studio/tags/0.61.08/src/synfigapp/blineconvert.h @@ -0,0 +1,116 @@ +/* === S Y N F I G ========================================================= */ +/*! \file blineconvert.h +** \brief Template Header +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** \endlegal +*/ +/* ========================================================================= */ + +/* === S T A R T =========================================================== */ + +#ifndef __SYNFIG_BLINE_CONVERT_H +#define __SYNFIG_BLINE_CONVERT_H + +/* === H E A D E R S ======================================================= */ + +#include +#include +#include +#include + +/* === M A C R O S ========================================================= */ + +/* === T Y P E D E F S ===================================================== */ + +/* === C L A S S E S & S T R U C T S ======================================= */ + +namespace synfigapp { + +class BLineConverter +{ +public: + struct cpindex + { + int curind; + synfig::Real tangentscale; + synfig::Real error; //negative error will indicate invalid; + + cpindex(int ci, synfig::Real s=0, synfig::Real e=-1) + :curind(ci), tangentscale(s), error(e) + {} + + cpindex(const cpindex & o) + :curind(o.curind), tangentscale(o.tangentscale), error(o.error) + {} + + const cpindex & operator=(const cpindex & rhs) + { + curind = rhs.curind; + tangentscale = rhs.tangentscale; + error = rhs.error; + return *this; + } + + bool operator<(const cpindex &rhs) const + { + return curind < rhs.curind; + } + + //point is obviously in[curind] + //tangent scale will get reset to the smallest (or something else depending on experimentation) + }; + +private: + //cached data + std::vector point_cache; //the preprocessed input cache + std::vector width_cache; + + //temporary point storage for vector calc + std::vector ftemp; + + std::vector deriv; //the derivative cache + std::vector curvature; //the curvature cache + + std::vector break_tangents; //the break point cache + + std::vector cum_dist, //cumulative distance + this_dist; //distance between adjacent segments + + std::vector work; //the working point cache for the entire curve + std::vector curind; + + //function parameters + void clear(); + +public: + synfig::Real width; + + //Converter properties + synfig::Real pixelwidth; + synfig::Real smoothness; //actual error will be smoothness*pixelwidth (for global set pixelwidth = 1) + + BLineConverter(); + + static void EnforceMinWidth(std::list &bline, synfig::Real min_pressure); + void operator()(std::list &out, const std::list &in,const std::list &in_w); +}; + +}; // END of namespace synfigapp + +/* === E N D =============================================================== */ + +#endif