#include <synfig/general.h>
#include <cassert>
-
+#include "general.h"
#endif
template < class T >
inline void FivePointdt(T &df, const T &f1, const T &f2, const T &f3, const T &f4, const T &f5, int bias)
{
- if(bias == 0)
- {
- //middle
+ if (bias == 0) // middle
df = (f1 - f2*8 + f4*8 - f5)*(1/12.0f);
- }else if(bias < 0)
- {
- //left
+ else if (bias < 0) // left
df = (-f1*25 + f2*48 - f3*36 + f4*16 - f5*3)*(1/12.0f);
- }else
- {
- //right
+ else // right
df = (f1*3 - f2*16 + f3*36 - f4*48 + f5*25)*(1/12.0f);
- }
}
template < class T >
inline void ThreePointdt(T &df, const T &f1, const T &f2, const T &f3, int bias)
{
- if(bias == 0)
- {
- //middle
+ if (bias == 0) // middle
df = (-f1 + f3)*(1/2.0f);
- }else if(bias < 0)
- {
- //left
+ else if (bias < 0) // left
df = (-f1*3 + f2*4 - f3)*(1/2.0f);
- }else
- {
- //right
+ else // right
df = (f1 - f2*4 + f3*3)*(1/2.0f);
- }
}
// template < class T >
if(right - left < 2)
return;
- else if(right - left < 3)
+ else if(right - left == 2)
{
synfig::Vector v = f[left+1] - f[left];
{
//left then middle then right
ThreePointdt(*(synfig::Vector*)out,f[left+0], f[left+1], f[left+2], -1);
- current += 1;
+ current++;
out += dfstride;
for(;current < right-1; current++, out += dfstride)
- {
ThreePointdt(*(synfig::Vector*)out,f[current-1], f[current], f[current+1], 0);
- }
ThreePointdt(*(synfig::Vector*)out,f[right-3], f[right-2], f[right-1], 1);
current++;
current += 2;
for(;current < right-2; current++, out += dfstride)
- {
FivePointdt(*(synfig::Vector*)out,f[current-2], f[current-1], f[current], f[current+1], f[current+2], 0);
- }
- FivePointdt(*(synfig::Vector*)out,f[right-5], f[right-4], f[right-3], f[right-2], f[right-1], 1);
- out += dfstride;
FivePointdt(*(synfig::Vector*)out,f[right-6], f[right-5], f[right-4], f[right-3], f[right-2], 2);
out += dfstride;
+ FivePointdt(*(synfig::Vector*)out,f[right-5], f[right-4], f[right-3], f[right-2], f[right-1], 1);
+ out += dfstride;
current += 2;
}
}
if(in.size() == in_w.size())
{
for(;i != end; ++i,++iw)
- {
- //eliminate duplicate points
- if(*i != c)
+ if(*i != c) // eliminate duplicate points
{
f.push_back(c = *i);
f_w.push_back(*iw);
}
- }
- }else
+ }
+ else
{
for(;i != end; ++i)
- {
- //eliminate duplicate points
- if(*i != c)
- {
+ if(*i != c) // eliminate duplicate points
f.push_back(c = *i);
- }
- }
}
}
//initialprocess = timer();
minc = cvt[i];
maxi = i;
}
- }else if(maxi >= 0)
+ }
+ else if(maxi >= 0)
{
if(maxi >= last + 8)
{
gaussian_blur_3(ftemp.begin(),ftemp.end(),false);
df.resize(size);
+
+ // Wondering whether the modification of the df vector
+ // using a char* pointer and pointer arithmetric was safe,
+ // I looked it up...
+ //
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2369.pdf tells me:
+ //
+ // 23.2.5 Class template vector [vector]
+ //
+ // [...] The elements of a vector are stored contiguously,
+ // meaning that if v is a vector<T,Allocator> where T is
+ // some type other than bool, then it obeys the identity
+ // &v[n] == &v[0] + n for all 0 <= n < v.size().
+ //
GetFirstDerivatives(ftemp,0,size,(char*)&df[0],sizeof(df[0]));
+
//GetSimpleDerivatives(ftemp,0,size,df,0,di);
//< don't have to worry about indexing stuff as it is all being taken care of right now
//preproceval += timer();
end = bline.end();
for(i = bline.begin(); i != end; ++i)
- {
if(i->get_width() < min_pressure)
- {
i->set_width(min_pressure);
- }
- }
}