| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkShapeSignedDistanceFunction.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:47 $ |
| 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 |
DEF |
#ifndef _itkShapeSignedDistanceFunction_h |
| 18 |
DEF |
#define _itkShapeSignedDistanceFunction_h |
| 19 |
|
|
| 20 |
|
#include "itkSpatialFunction.h" |
| 21 |
|
#include "itkArray.h" |
| 22 |
|
|
| 23 |
|
namespace itk |
| 24 |
|
{ |
| 25 |
|
|
| 26 |
|
/** \class ShapeSignedDistanceFunction |
| 27 |
|
* \brief Base class for functions which evaluates the signed distance |
| 28 |
|
* from a shape. |
| 29 |
|
* |
| 30 |
|
* ShapeSignedDistanceFunction is the base class for functions which |
| 31 |
|
* returns the signed distance from a shape at an arbitrary point. |
| 32 |
|
* A shape assumed to be defined by a set of shape and pose parameters. |
| 33 |
|
* |
| 34 |
|
* Note that Initialize() must be called before use. |
| 35 |
|
* This allows the class an opportunity to validate any inputs. |
| 36 |
|
* |
| 37 |
|
* This class is templated over the coordinate representation type |
| 38 |
|
* (e.g. float or double) and the space dimension. |
| 39 |
|
* |
| 40 |
|
* ShapeSignedDistanceFunction is used to encapsulate the shape prior |
| 41 |
|
* in ShapePriorSegmentationLevelSetFunctions. |
| 42 |
|
* |
| 43 |
|
* \sa SpatialFunction |
| 44 |
|
* \sa ShapePriorSegmentationLevelSetFunction |
| 45 |
|
* |
| 46 |
|
* \ingroup ImageFunctions |
| 47 |
|
* |
| 48 |
|
* */ |
| 49 |
|
template <typename TCoordRep, unsigned int VSpaceDimension> |
| 50 |
|
class ITK_EXPORT ShapeSignedDistanceFunction : |
| 51 |
LEN,IND |
**public SpatialFunction< double, VSpaceDimension, Point<TCoordRep,VSpaceDimension> > |
| 52 |
|
{ |
| 53 |
|
public: |
| 54 |
|
/** Standard class typedefs. */ |
| 55 |
|
typedef ShapeSignedDistanceFunction Self; |
| 56 |
|
typedef SpatialFunction< double, VSpaceDimension, |
| 57 |
LEN,TDA |
Point<TCoordRep,VSpaceDimension> > Superclass; |
| 58 |
TDA |
typedef SmartPointer<Self> Pointer; |
| 59 |
TDA |
typedef SmartPointer<const Self> ConstPointer; |
| 60 |
|
|
| 61 |
|
/** Run-time type information (and related methods). */ |
| 62 |
|
itkTypeMacro(ShapeSignedDistanceFunction, SpatialFunction); |
| 63 |
|
|
| 64 |
|
/** OutputType typedef support. */ |
| 65 |
|
typedef typename Superclass::OutputType OutputType; |
| 66 |
|
|
| 67 |
|
/** InputType typedef support. */ |
| 68 |
|
typedef typename Superclass::InputType InputType; |
| 69 |
|
|
| 70 |
|
/** Dimension underlying input image. */ |
| 71 |
|
itkStaticConstMacro(SpaceDimension, unsigned int, VSpaceDimension); |
| 72 |
|
|
| 73 |
|
/** CoordRep typedef support. */ |
| 74 |
|
typedef TCoordRep CoordRepType; |
| 75 |
|
|
| 76 |
|
/** Point typedef support. */ |
| 77 |
|
typedef InputType PointType; |
| 78 |
|
|
| 79 |
|
/** Type of the shape parameters. */ |
| 80 |
|
typedef Array<double> ParametersType; |
| 81 |
|
|
| 82 |
|
/** A shape is defined by a set of shape parameters. */ |
| 83 |
|
virtual void SetParameters( const ParametersType & ) = 0; |
| 84 |
|
virtual ParametersType& GetParameters(void) |
| 85 |
|
{ return m_Parameters; } |
| 86 |
|
virtual unsigned int GetNumberOfShapeParameters(void) const = 0; |
| 87 |
|
virtual unsigned int GetNumberOfPoseParameters(void) const = 0; |
| 88 |
|
virtual unsigned int GetNumberOfParameters(void) const |
| 89 |
LEN |
{ return this->GetNumberOfShapeParameters() + this->GetNumberOfPoseParameters(); } |
| 90 |
|
|
| 91 |
|
/** Evaluate the signed distance from a shape at a given position. */ |
| 92 |
|
virtual OutputType Evaluate( const PointType& point ) const = 0; |
| 93 |
|
|
| 94 |
|
/** Initialize must be called before the first call of SetParameters() or |
| 95 |
IND |
***Evaluate() to allow the class to validate any inputs. */ |
| 96 |
|
virtual void Initialize() throw ( ExceptionObject ) {}; |
| 97 |
|
|
| 98 |
|
protected: |
| 99 |
|
|
| 100 |
|
ShapeSignedDistanceFunction() {}; |
| 101 |
|
|
| 102 |
|
~ShapeSignedDistanceFunction(){}; |
| 103 |
|
|
| 104 |
|
void PrintSelf(std::ostream& os, Indent indent) const |
| 105 |
|
{ |
| 106 |
|
Superclass::PrintSelf( os, indent ); |
| 107 |
IND |
//FIX os << indent << "Parameters: " << m_Parameters << std::endl; |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
ParametersType m_Parameters; |
| 111 |
|
|
| 112 |
|
private: |
| 113 |
|
ShapeSignedDistanceFunction( const Self& ); //purposely not implemented |
| 114 |
|
void operator=( const Self& ); //purposely not implemented |
| 115 |
|
|
| 116 |
|
}; |
| 117 |
|
|
| 118 |
|
} // namespace itk |
| 119 |
|
|
| 120 |
|
#endif |
| 121 |
|
|