<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta name="robots" content="noindex"> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>ITK: itkCacheableScalarFunction.h Source File</title> <link href="DoxygenStyle.css" rel="stylesheet" type="text/css"> </head><body bgcolor="#ffffff"> <!-- Section customized for INSIGHT : Tue Jul 17 01:02:45 2001 --> <center> <a href="index.html" class="qindex">Main Page</a> <a href="modules.html" class="qindex">Groups</a> <a href="namespaces.html" class="qindex">Namespace List</a> <a href="hierarchy.html" class="qindex">Class Hierarchy</a> <a href="classes.html" class="qindex">Alphabetical List</a> <a href="annotated.html" class="qindex">Compound List</a> <a href="files.html" class="qindex">File List</a> <a href="namespacemembers.html" class="qindex">Namespace Members</a> <a href="functions.html" class="qindex">Compound Members</a> <a href="globals.html" class="qindex">File Members</a> <a href="pages.html" class="qindex">Concepts</a></center> <!-- Generated by Doxygen 1.5.9 --> <div class="navpath"><a class="el" href="dir_02e23d841c198393a6e961e9a0678fff.html">Code</a> » <a class="el" href="dir_2c33022d19e8077162952ea9ed57656d.html">Numerics</a> </div> <div class="contents"> <h1>itkCacheableScalarFunction.h</h1><a href="itkCacheableScalarFunction_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*=========================================================================</span> <a name="l00002"></a>00002 <span class="comment"></span> <a name="l00003"></a>00003 <span class="comment"> Program: Insight Segmentation & Registration Toolkit</span> <a name="l00004"></a>00004 <span class="comment"> Module: $RCSfile: itkCacheableScalarFunction.h,v $</span> <a name="l00005"></a>00005 <span class="comment"> Language: C++</span> <a name="l00006"></a>00006 <span class="comment"> Date: $Date: 2007-03-29 19:37:00 $</span> <a name="l00007"></a>00007 <span class="comment"> Version: $Revision: 1.10 $</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> Copyright (c) Insight Software Consortium. All rights reserved.</span> <a name="l00010"></a>00010 <span class="comment"> See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.</span> <a name="l00011"></a>00011 <span class="comment"></span> <a name="l00012"></a>00012 <span class="comment"> This software is distributed WITHOUT ANY WARRANTY; without even </span> <a name="l00013"></a>00013 <span class="comment"> the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR </span> <a name="l00014"></a>00014 <span class="comment"> PURPOSE. See the above copyright notices for more information.</span> <a name="l00015"></a>00015 <span class="comment"></span> <a name="l00016"></a>00016 <span class="comment">=========================================================================*/</span> <a name="l00017"></a>00017 <span class="preprocessor">#ifndef __itkCacheableScalarFunction_h</span> <a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define __itkCacheableScalarFunction_h</span> <a name="l00019"></a>00019 <span class="preprocessor"></span> <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="itkArray_8h.html">itkArray.h</a>"</span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="itkExceptionObject_8h.html">itkExceptionObject.h</a>"</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="keyword">namespace </span>itk { <a name="l00055"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html">00055</a> <span class="keyword">class </span><a class="code" href="classitk_1_1CacheableScalarFunction.html" title="function cache implementation">CacheableScalarFunction</a> <a name="l00056"></a>00056 { <a name="l00057"></a>00057 <span class="keyword">public</span>: <a name="l00059"></a>00059 <a class="code" href="classitk_1_1CacheableScalarFunction.html#7945e436c1d88335776109b3163b61d3">CacheableScalarFunction</a>(); <a name="l00060"></a>00060 <a name="l00062"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#13c7f7d6d855f6d8354150bafc6ca48e">00062</a> <span class="keyword">virtual</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#13c7f7d6d855f6d8354150bafc6ca48e">~CacheableScalarFunction</a>() {} <a name="l00063"></a>00063 <a name="l00065"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#3e6333600aacf7275e6e0311cbedbdb6">00065</a> <span class="keyword">typedef</span> <span class="keywordtype">double</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#3e6333600aacf7275e6e0311cbedbdb6">MeasureType</a>; <a name="l00066"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#e47e01c4f9242afa828ae8459fdbee15">00066</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Array.html">Array<MeasureType></a> <a class="code" href="classitk_1_1Array.html">MeasureArrayType</a>; <a name="l00067"></a>00067 <a name="l00070"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#dea9e0cfb540c895c7ae02f09bdcae0b">00070</a> <span class="keywordtype">long</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#dea9e0cfb540c895c7ae02f09bdcae0b">GetNumberOfSamples</a>() { <span class="keywordflow">return</span> m_NumberOfSamples; } <a name="l00071"></a>00071 <a name="l00073"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#6d08a844aad2210ad812989586ec3d5b">00073</a> <span class="keywordtype">bool</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#6d08a844aad2210ad812989586ec3d5b">IsCacheAvailable</a>() { <span class="keywordflow">return</span> m_CacheAvailable; } <a name="l00074"></a>00074 <a name="l00076"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#6d1670fee265e1cc6673e7b2c6915838">00076</a> <span class="keywordtype">double</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#6d1670fee265e1cc6673e7b2c6915838">GetCacheUpperBound</a>() { <span class="keywordflow">return</span> m_CacheUpperBound; } <a name="l00077"></a>00077 <a name="l00079"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#fc91ba796ec07c4a8318106acbc00b5f">00079</a> <span class="keywordtype">double</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#fc91ba796ec07c4a8318106acbc00b5f">GetCacheLowerBound</a>() { <span class="keywordflow">return</span> m_CacheLowerBound; } <a name="l00080"></a>00080 <a name="l00084"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#75e1d4a0b20464a80d73df54e4c33d1c">00084</a> <span class="keyword">virtual</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#3e6333600aacf7275e6e0311cbedbdb6">MeasureType</a> <a class="code" href="classitk_1_1CacheableScalarFunction.html#75e1d4a0b20464a80d73df54e4c33d1c">Evaluate</a>(<a class="code" href="classitk_1_1CacheableScalarFunction.html#3e6333600aacf7275e6e0311cbedbdb6">MeasureType</a> x) <a name="l00085"></a>00085 { <span class="keywordflow">return</span> x; } <a name="l00086"></a>00086 <a name="l00088"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#b9afe43734dd5521d0e8e382528c7615">00088</a> <span class="keywordtype">double</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#b9afe43734dd5521d0e8e382528c7615">GetInterval</a>() <a name="l00089"></a>00089 { <span class="keywordflow">return</span> m_TableInc; } <a name="l00090"></a>00090 <a name="l00096"></a><a class="code" href="classitk_1_1CacheableScalarFunction.html#4ae0a32e403ff42f78565fd1f38a4de3">00096</a> <span class="keyword">inline</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#3e6333600aacf7275e6e0311cbedbdb6">MeasureType</a> <a class="code" href="classitk_1_1CacheableScalarFunction.html#4ae0a32e403ff42f78565fd1f38a4de3">GetCachedValue</a>(<a class="code" href="classitk_1_1CacheableScalarFunction.html#3e6333600aacf7275e6e0311cbedbdb6">MeasureType</a> x) <a name="l00097"></a>00097 { <a name="l00098"></a>00098 <span class="keywordflow">if</span> (x > m_CacheUpperBound || x < m_CacheLowerBound) <a name="l00099"></a>00099 { <a name="l00100"></a>00100 <span class="keywordflow">throw</span> ExceptionObject(__FILE__,__LINE__); <a name="l00101"></a>00101 } <a name="l00102"></a>00102 <span class="comment">// access table</span> <a name="l00103"></a>00103 <span class="keywordtype">int</span> index = (int) ((x - m_CacheLowerBound) / m_TableInc); <a name="l00104"></a>00104 <span class="keywordflow">return</span> m_CacheTable[index]; <a name="l00105"></a>00105 } <a name="l00107"></a>00107 <a name="l00108"></a>00108 <span class="keyword">protected</span>: <a name="l00111"></a>00111 <span class="keywordtype">void</span> <a class="code" href="classitk_1_1CacheableScalarFunction.html#56633055451c4c5718e668043df845da">CreateCache</a>(<span class="keywordtype">double</span> lowerBound, <span class="keywordtype">double</span> upperBound, <span class="keywordtype">long</span> sampleSize); <a name="l00112"></a>00112 <a name="l00113"></a>00113 <span class="keyword">private</span>: <a name="l00116"></a>00116 <span class="keywordtype">long</span> m_NumberOfSamples; <a name="l00117"></a>00117 <a name="l00119"></a>00119 <a class="code" href="classitk_1_1CacheableScalarFunction.html#e47e01c4f9242afa828ae8459fdbee15">MeasureArrayType</a> m_CacheTable; <a name="l00120"></a>00120 <a name="l00122"></a>00122 <span class="keywordtype">double</span> m_CacheUpperBound; <a name="l00123"></a>00123 <a name="l00125"></a>00125 <span class="keywordtype">double</span> m_CacheLowerBound; <a name="l00126"></a>00126 <a name="l00128"></a>00128 <span class="keywordtype">double</span> m_TableInc; <a name="l00129"></a>00129 <a name="l00131"></a>00131 <span class="keywordtype">bool</span> m_CacheAvailable; <a name="l00132"></a>00132 <a name="l00133"></a>00133 }; <span class="comment">// end of class</span> <a name="l00134"></a>00134 } <span class="comment">// end of namespace itk</span> <a name="l00135"></a>00135 <span class="preprocessor">#endif</span> <a name="l00136"></a>00136 <span class="preprocessor"></span> </pre></div></div> <hr><address><small> Generated at Thu May 7 22:21:05 2009 for ITK by <a href="http://www.stack.nl/~dimitri/doxygen/index.html"> <img src="http://www.stack.nl/~dimitri/doxygen/doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53> </a> 1.5.9 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2000</small></address> </body> </html>