Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkCacheableScalarFunction.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkCacheableScalarFunction.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:36 $ 00007 Version: $Revision: 1.8 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkCacheableScalarFunction_h 00018 #define __itkCacheableScalarFunction_h 00019 00020 #include "itkArray.h" 00021 #include "itkExceptionObject.h" 00022 00023 namespace itk { 00055 class CacheableScalarFunction 00056 { 00057 public: 00059 CacheableScalarFunction() ; 00060 00062 virtual ~CacheableScalarFunction() {} 00063 00065 typedef double MeasureType ; 00066 typedef Array<MeasureType> MeasureArrayType; 00067 00070 long GetNumberOfSamples() { return m_NumberOfSamples ; } 00071 00073 bool IsCacheAvailable() { return m_CacheAvailable ; } 00074 00076 double GetCacheUpperBound() { return m_CacheUpperBound ; } 00077 00079 double GetCacheLowerBound() { return m_CacheLowerBound ; } 00080 00084 virtual MeasureType Evaluate(MeasureType x) 00085 { return x ; } 00086 00088 double GetInterval() 00089 { return m_TableInc ; } 00090 00096 inline MeasureType GetCachedValue(MeasureType x) 00097 { 00098 if (x > m_CacheUpperBound || x < m_CacheLowerBound) 00099 { 00100 throw ExceptionObject(__FILE__,__LINE__); 00101 } 00102 // access table 00103 int index = (int) ((x - m_CacheLowerBound) / m_TableInc) ; 00104 return m_CacheTable[index] ; 00105 } 00106 00107 protected: 00110 void CreateCache(double lowerBound, double upperBound, long sampleSize) ; 00111 00112 private: 00115 long m_NumberOfSamples ; 00116 00118 MeasureArrayType m_CacheTable; 00119 00121 double m_CacheUpperBound; 00122 00124 double m_CacheLowerBound ; 00125 00127 double m_TableInc ; 00128 00130 bool m_CacheAvailable ; 00131 00132 } ; // end of class 00133 } // end of namespace itk 00134 #endif

Generated at Sat Mar 31 02:15:24 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000