| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkTorusInteriorExteriorSpatialFunction.txx.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:48 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 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 __itkTorusInteriorExteriorSpatialFunction_txx |
| 18 |
|
#define __itkTorusInteriorExteriorSpatialFunction_txx |
| 19 |
|
|
| 20 |
|
#include "itkTorusInteriorExteriorSpatialFunction.h" |
| 21 |
|
|
| 22 |
|
namespace itk |
| 23 |
|
{ |
| 24 |
|
|
| 25 |
|
template <unsigned int VDimension, typename TInput> |
| 26 |
|
TorusInteriorExteriorSpatialFunction<VDimension, TInput> |
| 27 |
|
::TorusInteriorExteriorSpatialFunction() |
| 28 |
|
{ |
| 29 |
|
m_Origin.Fill(0.0); |
| 30 |
|
|
| 31 |
|
// These default values are not picked for any particular reason |
| 32 |
|
m_MajorRadius = 3; |
| 33 |
|
m_MinorRadius = 1; |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
template <unsigned int VDimension, typename TInput> |
| 37 |
|
TorusInteriorExteriorSpatialFunction<VDimension, TInput> |
| 38 |
|
::~TorusInteriorExteriorSpatialFunction() |
| 39 |
|
{ |
| 40 |
|
|
| 41 |
|
} |
| 42 |
|
|
| 43 |
|
template <unsigned int VDimension, typename TInput> |
| 44 |
|
typename TorusInteriorExteriorSpatialFunction<VDimension, TInput>::OutputType |
| 45 |
|
TorusInteriorExteriorSpatialFunction<VDimension, TInput> |
| 46 |
|
::Evaluate(const InputType& position) const |
| 47 |
|
{ |
| 48 |
|
double x = position[0] - m_Origin[0]; |
| 49 |
|
double y = position[1] - m_Origin[1]; |
| 50 |
|
double z = position[2] - m_Origin[2]; |
| 51 |
|
|
| 52 |
|
double k = pow(m_MajorRadius - sqrt(x*x + y*y), 2.0) + z*z; |
| 53 |
|
|
| 54 |
|
if( k <= (m_MinorRadius * m_MinorRadius) ) |
| 55 |
|
return true; |
| 56 |
|
else |
| 57 |
|
return false; |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
template <unsigned int VDimension, typename TInput> |
| 61 |
|
void |
| 62 |
|
TorusInteriorExteriorSpatialFunction<VDimension, TInput> |
| 63 |
|
::PrintSelf(std::ostream& os, Indent indent) const |
| 64 |
|
{ |
| 65 |
|
Superclass::PrintSelf(os,indent); |
| 66 |
|
|
| 67 |
|
unsigned int i; |
| 68 |
|
|
| 69 |
|
os << indent << "Origin: ["; |
| 70 |
|
for (i=0; i < VDimension - 1; i++) |
| 71 |
|
{ |
| 72 |
|
os << m_Origin[i] << ", "; |
| 73 |
|
} |
| 74 |
|
os << "]" << std::endl; |
| 75 |
|
|
| 76 |
|
os << indent << "Major radius: " << m_MajorRadius << std::endl; |
| 77 |
|
|
| 78 |
|
os << indent << "Minor radius: " << m_MinorRadius << std::endl; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
} // end namespace itk |
| 82 |
|
|
| 83 |
|
#endif |
| 84 |
|
|