45 #ifndef _INCLUDED_Field3D_Curve_H_
46 #define _INCLUDED_Field3D_Curve_H_
54 #include <boost/lexical_cast.hpp>
56 #include <OpenEXR/ImathFun.h>
57 #include <OpenEXR/ImathMatrix.h>
92 void addSample(
const float t,
const T &value);
96 T
linear(
const float t)
const;
116 public std::unary_function<std::pair<float, T>, bool>
131 public std::unary_function<std::pair<float, T>, bool>
157 {
return Imath::lerp(lower.second, upper.second, t); }
171 template <
typename T>
176 typename SampleVec::iterator i =
177 find_if(m_samples.begin(), m_samples.end(), CheckTEqual(t));
178 if (i != m_samples.end()) {
185 i = find_if(m_samples.begin(), m_samples.end(), CheckTGreaterThan(t));
189 if (i != m_samples.end()) {
190 m_samples.insert(i, make_pair(t, value));
192 m_samples.push_back(make_pair(t, value));
198 template <
typename T>
203 if (m_samples.size() == 0) {
204 return defaultReturnValue();
208 typename SampleVec::const_iterator i =
209 find_if(m_samples.begin(), m_samples.end(), CheckTGreaterThan(t));
213 if (i == m_samples.end()) {
214 return m_samples.back().second;
215 }
else if (i == m_samples.begin()) {
216 return m_samples.front().second;
220 const Sample &lower = *(--i);
221 const float interpT = Imath::lerpfactor(t, lower.first, upper.first);
222 return lerp(lower, upper, interpT);
230 inline Imath::Matrix44<float>
233 Imath::Matrix44<float> identity;
234 identity.makeIdentity();
241 inline Imath::Matrix44<double>
244 Imath::Matrix44<double> identity;
245 identity.makeIdentity();
255 #endif // Include guard