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>
156 T
lerp(
const Sample &lower,
const Sample &upper,
const float t)
const 157 {
return Imath::lerp(lower.second, upper.second, t); }
171 template <
typename T>
176 typename SampleVec::iterator i =
190 m_samples.insert(i, make_pair(t, value));
192 m_samples.push_back(make_pair(t, value));
198 template <
typename T>
208 typename SampleVec::const_iterator i =
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 #define FIELD3D_NAMESPACE_HEADER_CLOSE
size_t numSamples() const
Returns the number of samples in the curve.
T defaultReturnValue() const
The default return value is used when no sample points are available. This defaults to zero...
std::pair< float, T > Sample
SampleVec m_samples
Stores the samples that define the curve. Sample insertion ensures that the samples are sorted accord...
bool operator()(std::pair< float, T > test)
CheckTGreaterThan(float match)
void addSample(const float t, const T &value)
Adds a sample point to the curve.
Used when finding values in the m_samples vector.
const SampleVec & samples() const
Returns a const reference to the samples in the curve.
T lerp(const Sample &lower, const Sample &upper, const float t) const
The default implementation for linear interpolation. Works for all classes for which Imath::lerp is i...
Implements a simple function curve where samples of type T can be added along a 1D axis...
bool match(const std::string &name, const std::string &attribute, const std::vector< std::string > &patterns, const MatchFlags flags=MatchEmptyPattern)
Matches a <name>:<attribute> string against a set of patterns.
T linear(const float t) const
Linearly interpolates a value from the curve.
std::vector< Sample > SampleVec
void clear()
Clears all samples in curve.
Used when finding values in the m_samples vector.
bool operator()(std::pair< float, T > test)