1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkCacheableScalarFunction.cxx,v $
Language: C++
Date: $Date: 2007-03-22 14:29:13 $
Version: $Revision: 1.7 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkCacheableScalarFunction.h"
namespace itk {
CacheableScalarFunction
::CacheableScalarFunction()
{
m_CacheAvailable = false;
}
void
CacheableScalarFunction
::CreateCache(double lowerBound, double upperBound, long sampleSize)
{
m_NumberOfSamples = sampleSize;
m_CacheLowerBound = lowerBound;
m_CacheUpperBound = upperBound;
long i;
MeasureType d;
m_CacheTable = MeasureArrayType(m_NumberOfSamples);
m_TableInc =
static_cast<MeasureType>( (m_CacheUpperBound - m_CacheLowerBound) /
double(m_NumberOfSamples - 1) );
d = static_cast<MeasureType>( m_CacheLowerBound );
for (i = 0; i < m_NumberOfSamples; i++)
{
m_CacheTable[i] = Evaluate(d);
d += m_TableInc;
}
m_CacheAvailable = true;
}
} // end of namespace itk
|