Orfeo Toolbox  3.16
itkCacheableScalarFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkCacheableScalarFunction.h,v $
5  Language: C++
6  Date: $Date: 2009-05-12 17:19:41 $
7  Version: $Revision: 1.11 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkCacheableScalarFunction_h
18 #define __itkCacheableScalarFunction_h
19 
20 #include "itkArray.h"
21 #include "itkExceptionObject.h"
22 
23 namespace itk {
56 {
57 public:
60 
63 
65  typedef double MeasureType;
67 
70  long GetNumberOfSamples() { return m_NumberOfSamples; }
71 
73  bool IsCacheAvailable() { return m_CacheAvailable; }
74 
76  double GetCacheUpperBound() { return m_CacheUpperBound; }
77 
79  double GetCacheLowerBound() { return m_CacheLowerBound; }
80 
84  virtual MeasureType Evaluate(MeasureType x)
85  { return x; }
86 
88  double GetInterval()
89  { return m_TableInc; }
90 
96  inline MeasureType GetCachedValue(MeasureType x)
97  {
98  if (x > m_CacheUpperBound || x < m_CacheLowerBound)
99  {
100  throw ExceptionObject(__FILE__,__LINE__);
101  }
102  // access table
103  int index = (int) ((x - m_CacheLowerBound) / m_TableInc);
104  return m_CacheTable[index];
105  }
106 
107 protected:
110  void CreateCache(double lowerBound, double upperBound, long sampleSize);
111 
112 private:
116 
119 
122 
125 
127  double m_TableInc;
128 
131 
132 }; // end of class
133 } // end of namespace itk
134 #endif

Generated at Sat Feb 2 2013 23:31:07 for Orfeo Toolbox with doxygen 1.8.1.1