Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Protected Member Functions
itk::PSMImplicitSurfaceDomain< T, VDimension > Class Template Reference

#include <itkPSMImplicitSurfaceDomain.h>

+ Inheritance diagram for itk::PSMImplicitSurfaceDomain< T, VDimension >:
+ Collaboration diagram for itk::PSMImplicitSurfaceDomain< T, VDimension >:

Public Types

typedef PSMImplicitSurfaceDomain Self
 
typedef PSMImageDomainWithCurvature< T, VDimension > Superclass
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef WeakPointer< const SelfConstWeakPointer
 
typedef Superclass::ImageType ImageType
 
typedef Superclass::PointType PointType
 
typedef T PixelType
 
- Public Types inherited from itk::PSMImageDomainWithCurvature< T, VDimension >
typedef PSMImageDomainWithCurvature Self
 
typedef PSMImageDomainWithHessians< T, VDimension > Superclass
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef WeakPointer< const SelfConstWeakPointer
 
typedef Superclass::PointType PointType
 
typedef Superclass::ImageType ImageType
 
typedef Superclass::ScalarInterpolatorType ScalarInterpolatorType
 
typedef Superclass::VnlMatrixType VnlMatrixType
 
- Public Types inherited from itk::PSMImageDomainWithHessians< T, VDimension >
typedef PSMImageDomainWithHessians Self
 
typedef PSMImageDomainWithGradients< T, VDimension > Superclass
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef WeakPointer< const SelfConstWeakPointer
 
typedef Superclass::PointType PointType
 
typedef Superclass::ImageType ImageType
 
typedef Superclass::ScalarInterpolatorType ScalarInterpolatorType
 
typedef vnl_matrix_fixed< T, VDimension, VDimension > VnlMatrixType
 
- Public Types inherited from itk::PSMImageDomainWithGradients< T, VDimension >
typedef PSMImageDomainWithGradients Self
 
typedef PSMImageDomain< T, VDimension > Superclass
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef WeakPointer< const SelfConstWeakPointer
 
typedef Superclass::PointType PointType
 
typedef Superclass::ImageType ImageType
 
typedef Superclass::ScalarInterpolatorType ScalarInterpolatorType
 
typedef GradientImageFilter< ImageTypeGradientImageFilterType
 
typedef GradientImageFilterType::OutputImageType GradientImageType
 
typedef VectorLinearInterpolateImageFunction< GradientImageType, typename PointType::CoordRepType > GradientInterpolatorType
 
typedef FixedArray< T, VDimension > VectorType
 
typedef vnl_vector_fixed< T, VDimension > VnlVectorType
 
- Public Types inherited from itk::PSMImageDomain< T, VDimension >
typedef PSMImageDomain Self
 
typedef PSMRegionDomain< VDimension > Superclass
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef WeakPointer< const SelfConstWeakPointer
 
typedef Image< T, VDimension > ImageType
 
typedef Superclass::PointType PointType
 
typedef LinearInterpolateImageFunction< ImageType, typename PointType::CoordRepType > ScalarInterpolatorType
 
- Public Types inherited from itk::PSMRegionDomain< VDimension >
typedef PSMRegionDomain Self
 
typedef PSMDomain< VDimension > Superclass
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef WeakPointer< const SelfConstWeakPointer
 
typedef Point< double, VDimension > PointType
 
- Public Types inherited from itk::PSMDomain< VDimension >
typedef PSMDomain Self
 
typedef DataObject Superclass
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef WeakPointer< const SelfConstWeakPointer
 
typedef Point< double, VDimension > PointType
 

Public Member Functions

 itkNewMacro (Self)
 
 itkTypeMacro (PSMImplicitSurfaceDomain, ParticleClipByRegionDomain)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
 itkSetMacro (Tolerance, T)
 
 itkGetMacro (Tolerance, T)
 
virtual bool ApplyConstraints (PointType &p) const
 
virtual bool ApplyVectorConstraints (vnl_vector_fixed< double, VDimension > &gradE, const PointType &pos, double maxtimestep) const
 
virtual double Distance (const PointType &, const PointType &) const
 
void SetCuttingPlane (const vnl_vector< double > &a, const vnl_vector< double > &b, const vnl_vector< double > &c)
 
void RemoveCuttingPlane ()
 
bool IsCuttingPlaneDefined () const
 
const vnl_vector_fixed< double, VDimension > & GetCuttingPlanePoint () const
 
const vnl_vector_fixed< double, VDimension > & GetCuttingPlaneNormal () const
 
void AddSphere (const vnl_vector_fixed< double, VDimension > &v, double r)
 
double GetSphereRadius (unsigned int i) const
 
vnl_vector_fixed< double, VDimension > GetSphereCenter (unsigned int i) const
 
unsigned int GetNumberOfSpheres () const
 
- Public Member Functions inherited from itk::PSMImageDomainWithCurvature< T, VDimension >
 itkNewMacro (Self)
 
 itkTypeMacro (PSMImageDomainWithCurvature, PSMImageDomainWithHessians)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
void SetImage (ImageType *I)
 
double GetCurvature (const PointType &pos) const
 
ImageType::Pointer * GetCurvatureImage ()
 
- Public Member Functions inherited from itk::PSMImageDomainWithHessians< T, VDimension >
 itkNewMacro (Self)
 
 itkTypeMacro (PSMImageDomainWithHessians, PSMImageDomainWithGradients)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
void SetImage (ImageType *I)
 
VnlMatrixType SampleHessianVnl (const PointType &p) const
 
 itkSetMacro (Sigma, double)
 
 itkGetMacro (Sigma, double)
 
ScalarInterpolatorType::Pointer * GetInterpolators ()
 
ImageType::Pointer * GetPartialDerivatives ()
 
- Public Member Functions inherited from itk::PSMImageDomainWithGradients< T, VDimension >
 itkNewMacro (Self)
 
 itkTypeMacro (PSMImageDomainWithGradients, PSMImageDomain)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
void SetImage (ImageType *I)
 
 itkGetObjectMacro (GradientImage, GradientImageType)
 
VectorType SampleGradient (const PointType &p) const
 
VnlVectorType SampleGradientVnl (const PointType &p) const
 
VnlVectorType SampleNormalVnl (const PointType &p, T epsilon=1.0e-5) const
 
 itkGetObjectMacro (GradientInterpolator, GradientInterpolatorType)
 
- Public Member Functions inherited from itk::PSMImageDomain< T, VDimension >
 itkNewMacro (Self)
 
 itkTypeMacro (PSMImageDomain, PSMRegionDomain)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
void SetImage (ImageType *I)
 
 itkGetObjectMacro (Image, ImageType)
 
 itkGetConstObjectMacro (Image, ImageType)
 
Sample (const PointType &p) const
 
bool IsInsideBuffer (const PointType &p) const
 
 itkGetObjectMacro (ScalarInterpolator, ScalarInterpolatorType)
 
- Public Member Functions inherited from itk::PSMRegionDomain< VDimension >
 itkNewMacro (Self)
 
 itkTypeMacro (PSMRegionDomain, PSMDomain)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
 itkSetMacro (LowerBound, PointType)
 
 itkSetMacro (UpperBound, PointType)
 
virtual const PointTypeGetUpperBound () const
 
virtual const PointTypeGetLowerBound () const
 
void SetRegion (const PointType &l, const PointType &u)
 
- Public Member Functions inherited from itk::PSMDomain< VDimension >
 itkNewMacro (Self)
 
 itkTypeMacro (PSMDomain, DataObject)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
void DisableConstraints ()
 
void EnableConstraints ()
 
bool GetConstraintsEnabled () const
 
void SetConstraintsEnabled (bool g)
 

Protected Member Functions

void PrintSelf (std::ostream &os, Indent indent) const
 
- Protected Member Functions inherited from itk::PSMImageDomainWithCurvature< T, VDimension >
void PrintSelf (std::ostream &os, Indent indent) const
 
double MeanCurvature (const PointType &pos)
 
double vnl_trace (const VnlMatrixType &m) const
 
- Protected Member Functions inherited from itk::PSMImageDomainWithHessians< T, VDimension >
void PrintSelf (std::ostream &os, Indent indent) const
 
void DeletePartialDerivativeImages ()
 
- Protected Member Functions inherited from itk::PSMImageDomainWithGradients< T, VDimension >
void PrintSelf (std::ostream &os, Indent indent) const
 
- Protected Member Functions inherited from itk::PSMImageDomain< T, VDimension >
void PrintSelf (std::ostream &os, Indent indent) const
 
- Protected Member Functions inherited from itk::PSMRegionDomain< VDimension >
void PrintSelf (std::ostream &os, Indent indent) const
 
- Protected Member Functions inherited from itk::PSMDomain< VDimension >
void PrintSelf (std::ostream &os, Indent indent) const
 

Additional Inherited Members

- Protected Attributes inherited from itk::PSMDomain< VDimension >
bool m_ConstraintsEnabled
 

Detailed Description

template<class T, unsigned int VDimension>
class itk::PSMImplicitSurfaceDomain< T, VDimension >

A 3D cartesian domain that constrains points so that they always lie an implicit surface. The implicit surface is defined as the zero isosurface of the given image. Constraints are applied using a Newton-Raphson iteration, and this class assumes it has a distance transform as an image.

Definition at line 35 of file itkPSMImplicitSurfaceDomain.h.

Member Typedef Documentation

template<class T, unsigned int VDimension>
typedef PSMImplicitSurfaceDomain itk::PSMImplicitSurfaceDomain< T, VDimension >::Self

Standard class typedefs

Definition at line 40 of file itkPSMImplicitSurfaceDomain.h.

Member Function Documentation

template<class T, unsigned int VDimension>
void itk::PSMImplicitSurfaceDomain< T, VDimension >::AddSphere ( const vnl_vector_fixed< double, VDimension > &  v,
double  r 
)
inline

Maintain a list of spheres within the domain. These are used as soft constraints by some particle forcing functions.

Definition at line 104 of file itkPSMImplicitSurfaceDomain.h.

105  {
106  if (r > 0)
107  {
108  m_SphereCenterList.push_back(v);
109  m_SphereRadiusList.push_back(r);
110  }
111  }
template<class T , unsigned int VDimension>
bool itk::PSMImplicitSurfaceDomain< T, VDimension >::ApplyConstraints ( PointType p) const
virtual

Apply any constraints to the given point location. This method constrains points to lie within the given domain and on a given implicit surface. If the point is not already on the surface, it is projected back to the surface using a Newton-Raphson iteration. IMPORTANT: This method returns the true/false value of its superclass, and does not indicate changes only due to projection. This is done for speed: we typically will only want to know if a point tried to move outside of the bounding box domain, since movement off the surface will be very common. Consider subclassing this method to add a check for significant differences in the input and output points.

Reimplemented from itk::PSMRegionDomain< VDimension >.

Definition at line 89 of file itkPSMImplicitSurfaceDomain.hxx.

90 {
91  // First apply and constraints imposed by superclasses. This will
92  // guarantee the point starts in the correct image domain.
93  bool flag = Superclass::ApplyConstraints(p);
94 
95  if (this->m_ConstraintsEnabled == true)
96  {
97 
98  unsigned int k = 0;
99  double mult = 1.0;
100 
101  const T epsilon = m_Tolerance * 0.001;
102  T f = this->Sample(p);
103 
104  T gradmag = 1.0;
105  while ( fabs(f) > (m_Tolerance * mult) || gradmag < epsilon)
106  // while ( fabs(f) > m_Tolerance || gradmag < epsilon)
107  {
108  vnl_vector_fixed<T, VDimension> grad = this->SampleGradientVnl(p);
109 
110  gradmag = grad.magnitude();
111  vnl_vector_fixed<T, VDimension> vec = grad * ( f / (gradmag + epsilon) );
112  for (unsigned int i = 0; i < VDimension; i++)
113  {
114  p[i] -= vec[i];
115  }
116 
117  f = this->Sample(p);
118 
119  // Raise the tolerance if we have done too many iterations.
120  k++;
121  if (k > 10000)
122  {
123  mult *= 2.0;
124  k = 0;
125  }
126  } // end while
127  } // end if m_ConstraintsEnabled == true
128 
129  return flag;
130 }
T Sample(const PointType &p) const
virtual bool ApplyConstraints(PointType &p) const
template<class T , unsigned int VDimension>
bool itk::PSMImplicitSurfaceDomain< T, VDimension >::ApplyVectorConstraints ( vnl_vector_fixed< double, VDimension > &  gradE,
const PointType pos,
double  maxtimestep 
) const
virtual

Optionally add a repulsion from a planar boundar specified in m_CuttingPlane

Reimplemented from itk::PSMImageDomainWithGradients< T, VDimension >.

Definition at line 50 of file itkPSMImplicitSurfaceDomain.hxx.

53 {
54  if (this->m_UseCuttingPlane == true)
55  {
56  // See http://mathworld.wolfram.com/Point-PlaneDistance.html, for example
57  vnl_vector_fixed<double, VDimension> x;
58  vnl_vector_fixed<T, VDimension> grad = this->SampleGradientVnl(pos);
59  for (unsigned int i = 0; i < VDimension; i++)
60  { x[i] = pos[i]; }
61  const double D = dot_product(m_CuttingPlaneNormal, x- m_CuttingPlanePoint);
62 
63  // x = m_CuttingPlaneNormal * fabs(1.0 / (D + 1.0e-3));
64  // x = m_CuttingPlaneNormal * lambda * exp(-lambda * fabs(D));
65 
66  // Gradient of simple force 1/D^2 to push away from cutting plane
67  vnl_vector_fixed<double, VDimension> df;
68  const double k = (-2.0 / (D * D * D));
69  df[0] = k * grad[0] * m_CuttingPlaneNormal[0];
70  df[1] = k * grad[1] * m_CuttingPlaneNormal[1];
71  df[2] = k * grad[2] * m_CuttingPlaneNormal[2];
72 
73  gradE = gradE + df;
74 
75  // Make sure force is not huge relative to other forces.
76  if (gradE.magnitude() > maxtimestep)
77  {
78  gradE.normalize();
79  gradE = gradE * maxtimestep;
80  }
81  }
82 
83 
84  return Superclass::ApplyVectorConstraints(gradE,pos,maxtimestep);
85 }
virtual bool ApplyVectorConstraints(vnl_vector_fixed< double, VDimension > &gradE, const PointType &pos, double) const
template<class T , unsigned int VDimension>
double itk::PSMImplicitSurfaceDomain< T, VDimension >::Distance ( const PointType a,
const PointType b 
) const
virtual

Define a distance measure on the surface. Note that this distance measure is NOT the geodesic distance, as one might expect, but is only a Euclidean distance which ignores points whose normals are not sufficiently aligned (method returns a negative number). The assumption here is that points are sufficiently close to one another on the surface that they may be considered to lie in a tangent plane.

Reimplemented from itk::PSMDomain< VDimension >.

Definition at line 134 of file itkPSMImplicitSurfaceDomain.hxx.

135 {
136  double sum = 0.0;
137  for (unsigned int i = 0; i < VDimension; i++)
138  { sum += (b[i]-a[i]) * (b[i]-a[i]); }
139  return sqrt(sum);
140 }
template<class T, unsigned int VDimension>
vnl_vector_fixed<double, VDimension> itk::PSMImplicitSurfaceDomain< T, VDimension >::GetSphereCenter ( unsigned int  i) const
inline

Returns the center point of sphere i. If sphere i does not exist, returns 0 vector.

Definition at line 122 of file itkPSMImplicitSurfaceDomain.h.

123  {
124  if (m_SphereRadiusList.size() > i) return m_SphereCenterList[i];
125  else
126  { return vnl_vector_fixed<double, VDimension>(0.0,0.0,0.0); }
127  }
template<class T, unsigned int VDimension>
double itk::PSMImplicitSurfaceDomain< T, VDimension >::GetSphereRadius ( unsigned int  i) const
inline

Returns the radius of sphere i, or 0.0 if sphere i does not exist

Definition at line 114 of file itkPSMImplicitSurfaceDomain.h.

115  {
116  if (m_SphereRadiusList.size() > i) return m_SphereRadiusList[i];
117  else return 0.0;
118  }
template<class T, unsigned int VDimension>
itk::PSMImplicitSurfaceDomain< T, VDimension >::itkNewMacro ( Self  )

Method for creation through the object factory.

template<class T, unsigned int VDimension>
itk::PSMImplicitSurfaceDomain< T, VDimension >::itkSetMacro ( Tolerance  ,
 
)

Set/Get the precision of the projection operation. The resulting projection will be within the specified tolerance.

template<class T, unsigned int VDimension>
itk::PSMImplicitSurfaceDomain< T, VDimension >::itkStaticConstMacro ( Dimension  ,
unsigned  int,
VDimension   
)

Dimensionality of the domain of the particle system.

template<class T, unsigned int VDimension>
itk::PSMImplicitSurfaceDomain< T, VDimension >::itkTypeMacro ( PSMImplicitSurfaceDomain< T, VDimension >  ,
ParticleClipByRegionDomain   
)

Run-time type information (and related methods).


The documentation for this class was generated from the following files: