45#ifndef _INCLUDED_Field3D_Curve_H_
46#define _INCLUDED_Field3D_Curve_H_
54#include <boost/lexical_cast.hpp>
58#include <OpenEXR/OpenEXRConfig.h>
59#define COMBINED_OPENEXR_VERSION ((10000*OPENEXR_VERSION_MAJOR) + \
60 (100*OPENEXR_VERSION_MINOR) + \
61 OPENEXR_VERSION_PATCH)
66#if COMBINED_OPENEXR_VERSION >= 20599
67# include <Imath/ImathFun.h>
68# include <Imath/ImathMatrix.h>
71# include <OpenEXR/ImathFun.h>
72# include <OpenEXR/ImathMatrix.h>
133 public std::unary_function<std::pair<float, T>, bool>
148 public std::unary_function<std::pair<float, T>, bool>
174 {
return Imath::lerp(lower.second, upper.second,
t); }
193 typename SampleVec::iterator
i =
195 if (
i != m_samples.end()) {
206 if (
i != m_samples.end()) {
220 if (m_samples.size() == 0) {
221 return defaultReturnValue();
225 typename SampleVec::const_iterator
i =
230 if (
i == m_samples.end()) {
231 return m_samples.back().second;
232 }
else if (
i == m_samples.begin()) {
233 return m_samples.front().second;
238 const float interpT = Imath::lerpfactor(
t, lower.first, upper.first);
239 return lerp(lower, upper,
interpT);
247inline Imath::Matrix44<float>
258inline Imath::Matrix44<double>
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.
Implements a simple function curve where samples of type T can be added along a 1D axis....
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...
std::pair< float, T > Sample
SampleVec m_samples
Stores the samples that define the curve. Sample insertion ensures that the samples are sorted accord...
void addSample(const float t, const T &value)
Adds a sample point to the curve.
size_t numSamples() const
Returns the number of samples in the curve.
const SampleVec & samples() const
Returns a const reference to the samples in the curve.
T defaultReturnValue() const
The default return value is used when no sample points are available. This defaults to zero,...
void clear()
Clears all samples in curve.
T linear(const float t) const
Linearly interpolates a value from the curve.
std::vector< Sample > SampleVec
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Used when finding values in the m_samples vector.
bool operator()(std::pair< float, T > test)
Used when finding values in the m_samples vector.
CheckTGreaterThan(float match)
bool operator()(std::pair< float, T > test)