ICF 3.1.1.10
Technical documentation of ICF Libraries
CSampledFunction2d.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef imath_CSampledFunction2d_included
7#define imath_CSampledFunction2d_included
8
9
10#include <istd/TArray.h>
11#include <istd/CIndex2d.h>
12
14
15
16namespace imath
17{
18
19
24{
25public:
28 explicit CSampledFunction2d(const imath::ISampledFunction2d& function2d);
29 explicit CSampledFunction2d(const istd::CIndex2d& size, double defaultValue = 0);
30
31 void Reset();
32 bool CreateGrid2d(const istd::CIndex2d& size, double defaultValue = 0);
34 double GetSampleValue(const istd::CIndex2d& index) const;
35 void SetSampleValue(const istd::CIndex2d& index, double value);
36
37 // reimplemented (imath::ISampledFunction2d)
38 virtual bool CreateFunction(double* dataPtr, const ArgumentType& sizes);
39 virtual int GetTotalSamplesCount() const;
40 virtual int GetGridSize(int dimensionIndex) const;
41 virtual istd::CRange GetLogicalRange(int dimensionIndex) const;
42 virtual istd::CRange GetResultValueRange(int dimensionIndex, int resultDimension = -1) const;
43
44 // reimplemented (imath::TIMathFunction)
45 virtual bool GetValueAt(const ArgumentType& argument, ResultType& result) const;
46 virtual ResultType GetValueAt(const ArgumentType& argument) const;
47
48private:
50
51 SamplesContainer m_samplesContainer;
52};
53
54
55// public inline methods
56
58{
59 return m_samplesContainer.GetSizes();
60}
61
62
63inline double CSampledFunction2d::GetSampleValue(const istd::CIndex2d& index) const
64{
65 Q_ASSERT(index.IsInside(m_samplesContainer.GetSizes()));
66
67 return m_samplesContainer.GetAt(index);
68}
69
70
71inline void CSampledFunction2d::SetSampleValue(const istd::CIndex2d& index, double value)
72{
73 Q_ASSERT(index.IsInside(m_samplesContainer.GetSizes()));
74
75 m_samplesContainer.SetAt(index, value);
76}
77
78
79} // namespace imath
80
81
82#endif // !imath_CSampledFunction2d_included
83
84
Implementation of the resampled 2D-function.
virtual bool GetValueAt(const ArgumentType &argument, ResultType &result) const
istd::CIndex2d GetGridSize2d() const
bool CreateGrid2d(const istd::CIndex2d &size, double defaultValue=0)
CSampledFunction2d(const imath::ISampledFunction2d &function2d)
virtual istd::CRange GetResultValueRange(int dimensionIndex, int resultDimension=-1) const
Get range of result value for the given axis.
CSampledFunction2d(const CSampledFunction2d &function2d)
virtual istd::CRange GetLogicalRange(int dimensionIndex) const
Get logical grid position range for specified dimension.
CSampledFunction2d(const istd::CIndex2d &size, double defaultValue=0)
virtual ResultType GetValueAt(const ArgumentType &argument) const
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.
virtual int GetGridSize(int dimensionIndex) const
Get number of samples for specified dimension.
void SetSampleValue(const istd::CIndex2d &index, double value)
double GetSampleValue(const istd::CIndex2d &index) const
Interface for a resampled function with a regular grid design.
BaseClass::ArgumentType ArgumentType
Implementation of fixed-size mathematical vector with specified type of elements.
Definition TVector.h:32
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:25
Multidimensional array with fixed number of dimensions.
Definition TArray.h:28
const Element & GetAt(const IndexType &index) const
Get element stored at specified index.
Definition TArray.h:235
void SetAt(const IndexType &index, const Element &value)
Set element at specified index.
Definition TArray.h:259
const SizesType & GetSizes() const
Get list of all sizes.
Definition TArray.h:218
bool IsInside(const TIndex &boundaries) const
Check if index is inside boundaries.
Definition TIndex.h:460
Package with mathematical functions and algebraical primitives.

© Witold Gantzke and Kirill Lepskiy