Changed the "tagrelease" and "tagstable" make targets to use subversion. Also increme...
[synfig.git] / synfig-studio / tags / stable / src / sinfgapp / blineconvert.h
1 /* === S I N F G =========================================================== */
2 /*!     \file blineconvert.h
3 **      \brief Template Header
4 **
5 **      $Id: blineconvert.h,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === S T A R T =========================================================== */
23
24 #ifndef __SINFG_BLINE_CONVERT_H
25 #define __SINFG_BLINE_CONVERT_H
26
27 /* === H E A D E R S ======================================================= */
28
29 #include <sinfg/general.h>
30 #include <sinfg/blinepoint.h>
31 #include <list>
32 #include <vector>
33
34 /* === M A C R O S ========================================================= */
35
36 /* === T Y P E D E F S ===================================================== */
37
38 /* === C L A S S E S & S T R U C T S ======================================= */
39
40 namespace sinfgapp {
41         
42 class BLineConverter
43 {
44 public:
45         struct cpindex
46         {
47                 int             curind;
48                 sinfg::Real     tangentscale;
49                 sinfg::Real     error;  //negative error will indicate invalid;
50                 
51                 cpindex(int ci, sinfg::Real s=0, sinfg::Real e=-1) 
52                 :curind(ci), tangentscale(s), error(e) 
53                 {}
54                 
55                 cpindex(const cpindex & o)
56                 :curind(o.curind), tangentscale(o.tangentscale), error(o.error) 
57                 {}
58                 
59                 const cpindex & operator = (const cpindex & rhs)
60                 {
61                         curind = rhs.curind;
62                         tangentscale = rhs.tangentscale;
63                         error = rhs.error;
64                         return *this;
65                 }
66                 
67                 bool operator < (const cpindex &rhs) const
68                 {
69                         return curind < rhs.curind;             
70                 }
71                 
72                 //point is obviously in[curind]
73                 //tangent scale will get reset to the smallest (or something else depending on experimentation)
74         };
75
76 private:
77         //cached data
78         std::vector<sinfg::Point>       f;      //the preprocessed input cache
79         std::vector<sinfg::Real>        f_w;
80
81         //temporary point storage for vector calc
82         std::vector<sinfg::Point>       ftemp;
83         
84         std::vector<sinfg::Vector>      df; //the derivative cache      
85         std::vector<sinfg::Real>        cvt; //the curvature cache
86         
87         std::vector<int>                        brk; //the break point cache
88         
89         std::vector<sinfg::Real>        di,     //cumulative distance
90                                                                 d_i; //distance between adjacent segments
91         
92         std::vector<sinfg::Point>       work; //the working point cache for the entire curve
93         std::vector<cpindex>            curind;
94         
95         //function parameters
96         void clear();
97
98 public:
99         sinfg::Real width;
100
101         //Converter properties
102         sinfg::Real pixelwidth;
103         sinfg::Real smoothness; //actual error will be smoothness*pixelwidth (for global set pixelwidth = 1)
104
105         BLineConverter();
106
107         static void EnforceMinWidth(std::list<sinfg::BLinePoint> &bline, sinfg::Real min_pressure);
108         void operator ()(std::list<sinfg::BLinePoint> &out, const std::list<sinfg::Point> &in,const std::list<sinfg::Real> &in_w);
109 };
110         
111 }; // END of namespace sinfgapp
112
113 /* === E N D =============================================================== */
114
115 #endif