CSampledFunction2d.h
Go to the documentation of this file.
1 #ifndef imath_CSampledFunction2d_included
2 #define imath_CSampledFunction2d_included
3 
4 
5 #include <istd/TArray.h>
6 #include <istd/CIndex2d.h>
7 
9 
10 
11 namespace imath
12 {
13 
14 
19 {
20 public:
22  CSampledFunction2d(const CSampledFunction2d& function2d);
23  explicit CSampledFunction2d(const imath::ISampledFunction2d& function2d);
24  explicit CSampledFunction2d(const istd::CIndex2d& size, double defaultValue = 0);
25 
26  void Reset();
27  bool CreateGrid2d(const istd::CIndex2d& size, double defaultValue = 0);
29  double GetSampleValue(const istd::CIndex2d& index) const;
30  void SetSampleValue(const istd::CIndex2d& index, double value);
31 
32  // reimplemented (imath::ISampledFunction2d)
33  virtual bool CreateFunction(double* dataPtr, const ArgumentType& sizes);
34  virtual int GetTotalSamplesCount() const;
35  virtual int GetGridSize(int dimensionIndex) const;
36  virtual istd::CRange GetLogicalRange(int dimensionIndex) const;
37  virtual istd::CRange GetResultValueRange(int dimensionIndex, int resultDimension = -1) const;
38 
39  // reimplemented (imath::TIMathFunction)
40  virtual bool GetValueAt(const ArgumentType& argument, ResultType& result) const;
41  virtual ResultType GetValueAt(const ArgumentType& argument) const;
42 
43 private:
45 
46  SamplesContainer m_samplesContainer;
47 };
48 
49 
50 // public inline methods
51 
53 {
54  return m_samplesContainer.GetSizes();
55 }
56 
57 
58 inline double CSampledFunction2d::GetSampleValue(const istd::CIndex2d& index) const
59 {
60  Q_ASSERT(index.IsInside(m_samplesContainer.GetSizes()));
61 
62  return m_samplesContainer.GetAt(index);
63 }
64 
65 
66 inline void CSampledFunction2d::SetSampleValue(const istd::CIndex2d& index, double value)
67 {
68  Q_ASSERT(index.IsInside(m_samplesContainer.GetSizes()));
69 
70  m_samplesContainer.SetAt(index, value);
71 }
72 
73 
74 } // namespace imath
75 
76 
77 #endif // !imath_CSampledFunction2d_included
78 
79 
double GetSampleValue(const istd::CIndex2d &index) const
virtual istd::CRange GetLogicalRange(int dimensionIndex) const
Get logical grid position range for specified dimension.
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
void SetAt(const IndexType &index, const Element &value)
Set element at specified index.
Definition: TArray.h:251
virtual int GetGridSize(int dimensionIndex) const
Get number of samples for specified dimension.
const Element & GetAt(const IndexType &index) const
Get element stored at specified index.
Definition: TArray.h:227
virtual istd::CRange GetResultValueRange(int dimensionIndex, int resultDimension=-1) const
Get range of result value for the given axis.
bool CreateGrid2d(const istd::CIndex2d &size, double defaultValue=0)
Interface for a resampled function with a regular grid design.
Implementation of fixed-size mathematical vector with specified type of elements. ...
Definition: TVector.h:27
Implementation of the resampled 2D-function.
virtual bool CreateFunction(double *dataPtr, const ArgumentType &sizes)
Create function from input data.
virtual int GetTotalSamplesCount() const
Get number of samples stored in this container.
void SetSampleValue(const istd::CIndex2d &index, double value)
const SizesType & GetSizes() const
Get list of all sizes.
Definition: TArray.h:210
bool IsInside(const TIndex &boundaries) const
Check if index is inside boundaries.
Definition: TIndex.h:456
virtual bool GetValueAt(const ArgumentType &argument, ResultType &result) const
istd::CIndex2d GetGridSize2d() const
BaseClass::ArgumentType ArgumentType

© 2007-2017 Witold Gantzke and Kirill Lepskiy