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

A facade class that manages interactions with a particle system. More...

#include <itkPSMParticleSystem.h>

+ Inheritance diagram for itk::PSMParticleSystem< VDimension >:
+ Collaboration diagram for itk::PSMParticleSystem< VDimension >:

Public Types

typedef PSMParticleSystem Self
 
typedef DataObject Superclass
 
typedef SmartPointer< SelfPointer
 
typedef SmartPointer< const SelfConstPointer
 
typedef WeakPointer< const SelfConstWeakPointer
 
typedef PSMDomain< VDimension > DomainType
 
typedef Point< double, VDimension > PointType
 
typedef PSMNeighborhood< VDimension > NeighborhoodType
 
typedef PSMContainer< PointTypePointContainerType
 
typedef NeighborhoodType::PointVectorType PointVectorType
 
typedef vnl_matrix_fixed< double, VDimension+1, VDimension+1 > TransformType
 
typedef vnl_vector_fixed< double, VDimension > VectorType
 

Public Member Functions

 itkNewMacro (Self)
 
 itkTypeMacro (PSMParticleSystem, DataObject)
 
 itkStaticConstMacro (Dimension, unsigned int, VDimension)
 
void RegisterAttribute (PSMAttribute< VDimension > *)
 
void SynchronizePositions ()
 
unsigned long int GetNumberOfParticles (unsigned int d=0) const
 
const PointTypeAddPosition (const PointType &, unsigned int d=0, int threadId=0)
 
const PointTypeSetPosition (const PointType &, unsigned long int k, unsigned int d=0, int threadId=0)
 
void RemovePosition (unsigned long int k, unsigned int d=0, int threadId=0)
 
PointTypeGetPosition (unsigned long int k, unsigned int d=0)
 
const PointTypeGetPosition (unsigned long int k, unsigned int d=0) const
 
PointType GetTransformedPosition (unsigned long int k, unsigned int d=0) const
 
void SplitAllParticles (double epsilon, int threadId=0)
 
void SplitAllParticlesInDomain (const vnl_vector_fixed< double, VDimension > &, double epsilon, unsigned int d=0, int threadId=0)
 
void SplitParticle (double epsilon, unsigned int idx, unsigned int d=0, int threadId=0)
 
void SetNeighborhood (unsigned int, NeighborhoodType *, int threadId=0)
 
void SetNeighborhood (NeighborhoodType *n, int threadId=0)
 
NeighborhoodType::ConstPointer GetNeighborhood (unsigned int k) const
 
PointVectorType FindNeighborhoodPoints (const PointType &p, double r, unsigned int d=0) const
 
PointVectorType FindNeighborhoodPoints (const PointType &p, std::vector< double > &w, double r, unsigned int d=0) const
 
PointVectorType FindNeighborhoodPoints (unsigned int idx, double r, unsigned int d=0) const
 
PointVectorType FindNeighborhoodPoints (unsigned int idx, std::vector< double > &w, double r, unsigned int d=0) const
 
void AddDomain (DomainType *, int threadId=0)
 
std::vector< typename DomainType::Pointer >::const_iterator GetDomainsBegin () const
 
std::vector< typename DomainType::Pointer >::const_iterator GetDomainsEnd () const
 
DomainTypeGetDomain (unsigned int i)
 
DomainTypeGetDomain ()
 
const DomainTypeGetDomain (unsigned int i) const
 
const DomainTypeGetDomain () const
 
unsigned int GetNumberOfDomains () const
 
void SetTransform (unsigned int i, const TransformType &, int threadId=0)
 
void SetTransform (const TransformType &p, int threadId=0)
 
void SetPrefixTransform (unsigned int i, const TransformType &, int threadId=0)
 
void SetPrefixTransform (const TransformType &p, int threadId=0)
 
std::vector< TransformType >::const_iterator GetTransformsBegin () const
 
std::vector< TransformType >::const_iterator GetTransformsEnd () const
 
const TransformTypeGetTransform (unsigned int i) const
 
const TransformTypeGetTransform () const
 
TransformType GetTransform (unsigned int i)
 
TransformType GetTransform ()
 
const TransformTypeGetPrefixTransform (unsigned int i) const
 
const TransformTypeGetPrefixTransform () const
 
TransformType GetPrefixTransform (unsigned int i)
 
TransformType GetPrefixTransform ()
 
std::vector< TransformType >::const_iterator GetInverseTransformsBegin () const
 
std::vector< TransformType >::const_iterator GetInverseTransformsEnd () const
 
const TransformTypeGetInverseTransform (unsigned int i) const
 
const TransformTypeGetInverseTransform () const
 
const TransformTypeGetInversePrefixTransform (unsigned int i) const
 
const TransformTypeGetInversePrefixTransform () const
 
const std::vector< typename PointContainerType::Pointer > & GetPositions () const
 
const PointContainerType::Pointer & GetPositions (unsigned int d) const
 
void AddPositionList (const std::vector< PointType > &, unsigned int d, int threadId=0)
 
PointType TransformPoint (const PointType &, const TransformType &) const
 
VectorType TransformVector (const VectorType &, const TransformType &) const
 
TransformType InvertTransform (const TransformType &T) const
 
void FlagDomain (unsigned int i)
 
void UnflagDomain (unsigned int i)
 
bool GetDomainFlag (unsigned int i) const
 
const std::vector< bool > & GetDomainFlags () const
 
void SetDomainFlags ()
 
void ResetDomainFlags ()
 
void SetFixedParticleFlag (unsigned int i)
 
void ResetFixedParticleFlag (unsigned int i)
 
bool GetFixedParticleFlag (unsigned int i) const
 
void ResetFixedParticleFlags ()
 
template<>
PSMParticleSystem< 3 >::PointType TransformPoint (const PointType &p, const TransformType &T) const
 
template<>
PSMParticleSystem< 2 >::PointType TransformPoint (const PointType &p, const TransformType &T) const
 
template<>
PSMParticleSystem< 3 >::VectorType TransformVector (const VectorType &p, const TransformType &T) const
 
template<>
PSMParticleSystem< 2 >::VectorType TransformVector (const VectorType &p, const TransformType &T) const
 

Protected Member Functions

void PrintSelf (std::ostream &os, Indent indent) const
 
void SetNumberOfDomains (unsigned int)
 
std::vector< typename DomainType::Pointer >::iterator GetDomainsBegin ()
 
std::vector< typename DomainType::Pointer >::iterator GetDomainsEnd ()
 
std::vector< TransformType >::iterator GetTransformsBegin ()
 
std::vector< TransformType >::iterator GetTransformsEnd ()
 
std::vector< TransformType >::iterator GetInverseTransformsBegin ()
 
std::vector< TransformType >::iterator GetInverseTransformsEnd ()
 
TransformTypeGetInverseTransform (unsigned int i)
 
TransformTypeGetInverseTransform ()
 
TransformTypeGetInversePrefixTransform (unsigned int i)
 
TransformTypeGetInversePrefixTransform ()
 

Detailed Description

template<unsigned int VDimension>
class itk::PSMParticleSystem< VDimension >

A facade class that manages interactions with a particle system.

A particle system consists of a set of particle locations and domains in which those locations are defined. For example, a particle system may simply be a set of points in 3D Euclidean space that are constrained to a specified bounding box. A more complex example is a set of 3D points constrained to a given surface. The itkPSMParticleSystem class is also designed to manage multiple sets of points across multiple domains. For example, one may create a system of dozens of point sets that are each defined in different spaces. The itkPSMParticleSystem class can also maintain a set of transformations associated with each domain that map that particular domain into another coordinate frame, for example, a common coordinate frame.

All operations on the particle system must happen through the interface of the PSMParticleSystem class.

Author
Josh Cates

Definition at line 68 of file itkPSMParticleSystem.h.

Member Typedef Documentation

template<unsigned int VDimension>
typedef PSMDomain<VDimension> itk::PSMParticleSystem< VDimension >::DomainType

Define the base domain type.

Definition at line 88 of file itkPSMParticleSystem.h.

template<unsigned int VDimension>
typedef PSMNeighborhood<VDimension> itk::PSMParticleSystem< VDimension >::NeighborhoodType

Class used to compute neighborhoods of points. One is associated with each domain.

Definition at line 95 of file itkPSMParticleSystem.h.

template<unsigned int VDimension>
typedef PSMContainer<PointType> itk::PSMParticleSystem< VDimension >::PointContainerType

Point container type. One is associated with each domain.

Definition at line 98 of file itkPSMParticleSystem.h.

template<unsigned int VDimension>
typedef Point<double, VDimension> itk::PSMParticleSystem< VDimension >::PointType

Point type used to store particle locations.

Definition at line 91 of file itkPSMParticleSystem.h.

template<unsigned int VDimension>
typedef PSMParticleSystem itk::PSMParticleSystem< VDimension >::Self

Standard class typedefs

Definition at line 72 of file itkPSMParticleSystem.h.

template<unsigned int VDimension>
typedef vnl_matrix_fixed<double, VDimension +1, VDimension +1> itk::PSMParticleSystem< VDimension >::TransformType

Defines a transform class type. One is associated with each domain. Transforms are affine for simplicity.

Definition at line 104 of file itkPSMParticleSystem.h.

Member Function Documentation

template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::AddDomain ( DomainType input,
int  threadId = 0 
)

Add a domain to the particle system. This method also allocates space for a list of positions that are contained within the domain, and a default neighborhood calculator. The final, optional argument indicates the calling thread id.

Definition at line 55 of file itkPSMParticleSystem.hxx.

56 {
57  this->Modified();
58 
59  for (unsigned int idx = 0; idx < m_Domains.size(); ++idx)
60  {
61  if (!m_Domains[idx])
62  {
63  m_Domains[idx] = input;
64  m_Positions[idx] = PointContainerType::New();
65  m_IndexCounters[idx] = 0;
66  return;
67  }
68  }
69 
70  this->SetNumberOfDomains(static_cast<int>(m_Domains.size() + 1));
71  m_Domains[ static_cast<int>( m_Domains.size() ) - 1] = input;
72  m_Positions[static_cast<int>( m_Domains.size() ) - 1] = PointContainerType::New();
73  m_IndexCounters[static_cast<int>( m_Domains.size() -1)] = 0;
74  m_Neighborhoods[static_cast<int>( m_Domains.size() -1)] = NeighborhoodType::New();
75  m_Transforms[static_cast<int>( m_Domains.size() -1)].set_identity();
76  m_InverseTransforms[static_cast<int>( m_Domains.size() -1)].set_identity();
77  m_PrefixTransforms[static_cast<int>( m_Domains.size() -1)].set_identity();
78  m_InversePrefixTransforms[static_cast<int>( m_Domains.size() -1)].set_identity();
79  m_DomainFlags[static_cast<int>( m_Domains.size() -1)] = false;
80 
81  // Notify any observers.
82  ParticleDomainAddEvent e;
83  e.SetDomainIndex(m_Domains.size() - 1);
84  e.SetPositionIndex(0);
85  e.SetThreadID(threadId);
86  this->InvokeEvent(e);
87 }
void SetNumberOfDomains(unsigned int)
template<unsigned int VDimension>
const PSMParticleSystem< VDimension >::PointType & itk::PSMParticleSystem< VDimension >::AddPosition ( const PointType p,
unsigned int  d = 0,
int  threadId = 0 
)

Add/Set/Remove a single particle position. The actual position added or set will be returned. If, for example, the domain imposes any constraints on this location (e.g. out-of-bounds, projection onto a surface), then the method returns the location after constraints are applied. Both the Add and Set methods require a domain index. If unspecified, the domain index is zero. The Set method requires a specific particle index. If the given index does not exist, an exception is thrown. Set is intended to be used for moving particles. The SetTransformedPosition sets the position using a Point transformed by the m_Transform associated with the given domain.

Definition at line 145 of file itkPSMParticleSystem.hxx.

146 {
147  m_Positions[d]->operator[](m_IndexCounters[d]) = p;
148 
149  // Apply constraints to the given position. Note that the following
150  // operation potentially modifes that position.
151  m_Domains[d]->ApplyConstraints( m_Positions[d]->operator[](m_IndexCounters[d]));
152 
153  m_Neighborhoods[d]->AddPosition( m_Positions[d]->operator[](m_IndexCounters[d]),
154  m_IndexCounters[d], threadId);
155 
156  // Increase the FixedParticleFlag list size if necessary.
157  if (m_IndexCounters[0] >= m_FixedParticleFlags.size())
158  {
159  m_FixedParticleFlags.push_back(false);
160  }
161 
162  // Notify any observers.
163  ParticlePositionAddEvent e;
164  e.SetThreadID(threadId);
165  e.SetDomainIndex(d);
166  e.SetPositionIndex(m_IndexCounters[d]);
167  this->InvokeEvent(e);
168  m_IndexCounters[d]++;
169 
170  return m_Positions[d]->operator[](m_IndexCounters[d]-1);
171 }
template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::AddPositionList ( const std::vector< PointType > &  p,
unsigned int  d,
int  threadId = 0 
)

Adds a list of points to the specified domain. The arguments are the std::vector of points and the domain number.

Definition at line 221 of file itkPSMParticleSystem.hxx.

223 {
224  // Traverse the list and add each point to the domain.
225  for (typename std::vector<PointType>::const_iterator it= p.begin();
226  it != p.end(); it++)
227  {
228  this->AddPosition(*it, d, threadId);
229  }
230 }
const PointType & AddPosition(const PointType &, unsigned int d=0, int threadId=0)
template<unsigned int VDimension>
PointVectorType itk::PSMParticleSystem< VDimension >::FindNeighborhoodPoints ( const PointType p,
double  r,
unsigned int  d = 0 
) const
inline

Return the neighborhood of points with radius r around point p in domain k. This is just a convenience method to avoid exposing the underlying Neighborhood objects. FindTransformedNeighborhoodPoints returns the list with all points transformed by the transform associated with the given domain.

Definition at line 200 of file itkPSMParticleSystem.h.

202  {
203  return m_Neighborhoods[d]->FindNeighborhoodPoints(p, r);
204  }
template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::FlagDomain ( unsigned int  i)
inline

Flag/Unflag a domain. Flagging a domain has different meanings according to the application using this particle system.

Definition at line 397 of file itkPSMParticleSystem.h.

398  { m_DomainFlags[i] = true; }
template<unsigned int VDimension>
DomainType* itk::PSMParticleSystem< VDimension >::GetDomain ( unsigned int  i)
inline

Return the i'th domain object.

Definition at line 254 of file itkPSMParticleSystem.h.

255  { return m_Domains[i].GetPointer(); }
template<unsigned int VDimension>
DomainType* itk::PSMParticleSystem< VDimension >::GetDomain ( )
inline

API for the single domain case.

Definition at line 258 of file itkPSMParticleSystem.h.

259  {return m_Domains[0].GetPointer(); }
template<unsigned int VDimension>
const DomainType* itk::PSMParticleSystem< VDimension >::GetDomain ( unsigned int  i) const
inline

Return the i'th domain object.

Definition at line 262 of file itkPSMParticleSystem.h.

263  { return m_Domains[i].GetPointer(); }
template<unsigned int VDimension>
const DomainType* itk::PSMParticleSystem< VDimension >::GetDomain ( ) const
inline

API for the single domain case.

Definition at line 266 of file itkPSMParticleSystem.h.

267  {return m_Domains[0].GetPointer(); }
template<unsigned int VDimension>
std::vector< typename DomainType::Pointer >::const_iterator itk::PSMParticleSystem< VDimension >::GetDomainsBegin ( ) const
inline

Return an iterator that points to the first element of the list of the domains.

Definition at line 245 of file itkPSMParticleSystem.h.

246  { return m_Domains.begin(); }
template<unsigned int VDimension>
std::vector< typename DomainType::Pointer >::iterator itk::PSMParticleSystem< VDimension >::GetDomainsBegin ( )
inlineprotected

Return an iterator that points to the first element of the list of the domains.

Definition at line 444 of file itkPSMParticleSystem.h.

445  { return m_Domains.begin(); }
template<unsigned int VDimension>
std::vector< typename DomainType::Pointer >::const_iterator itk::PSMParticleSystem< VDimension >::GetDomainsEnd ( ) const
inline

Return an iterator that points one position past the last element of the list of the domains.

Definition at line 250 of file itkPSMParticleSystem.h.

251  { return m_Domains.end(); }
template<unsigned int VDimension>
std::vector< typename DomainType::Pointer >::iterator itk::PSMParticleSystem< VDimension >::GetDomainsEnd ( )
inlineprotected

Return an iterator that points one position past the last element of the list of the domains.

Definition at line 449 of file itkPSMParticleSystem.h.

450  { return m_Domains.end(); }
template<unsigned int VDimension>
const TransformType& itk::PSMParticleSystem< VDimension >::GetInversePrefixTransform ( unsigned int  i) const
inline

Return the i'th transform object.

Definition at line 350 of file itkPSMParticleSystem.h.

351  { return m_InversePrefixTransforms[i]; }
template<unsigned int VDimension>
const TransformType& itk::PSMParticleSystem< VDimension >::GetInversePrefixTransform ( ) const
inline

API for the single transform case.

Definition at line 354 of file itkPSMParticleSystem.h.

355  {return m_InversePrefixTransforms[0]; }
template<unsigned int VDimension>
TransformType& itk::PSMParticleSystem< VDimension >::GetInversePrefixTransform ( unsigned int  i)
inlineprotected

Return the i'th transform object.

Definition at line 483 of file itkPSMParticleSystem.h.

484  { return m_InversePrefixTransforms[i]; }
template<unsigned int VDimension>
TransformType& itk::PSMParticleSystem< VDimension >::GetInversePrefixTransform ( )
inlineprotected

API for the single transform case.

Definition at line 487 of file itkPSMParticleSystem.h.

488  {return m_InversePrefixTransforms[0]; }
template<unsigned int VDimension>
const TransformType& itk::PSMParticleSystem< VDimension >::GetInverseTransform ( unsigned int  i) const
inline

Return the i'th transform object.

Definition at line 342 of file itkPSMParticleSystem.h.

343  { return m_InverseTransforms[i]; }
template<unsigned int VDimension>
const TransformType& itk::PSMParticleSystem< VDimension >::GetInverseTransform ( ) const
inline

API for the single transform case.

Definition at line 346 of file itkPSMParticleSystem.h.

347  {return m_InverseTransforms[0]; }
template<unsigned int VDimension>
TransformType& itk::PSMParticleSystem< VDimension >::GetInverseTransform ( unsigned int  i)
inlineprotected

Return the i'th transform object.

Definition at line 475 of file itkPSMParticleSystem.h.

476  { return m_InverseTransforms[i]; }
template<unsigned int VDimension>
TransformType& itk::PSMParticleSystem< VDimension >::GetInverseTransform ( )
inlineprotected

API for the single transform case.

Definition at line 479 of file itkPSMParticleSystem.h.

480  {return m_InverseTransforms[0]; }
template<unsigned int VDimension>
std::vector< TransformType >::const_iterator itk::PSMParticleSystem< VDimension >::GetInverseTransformsBegin ( ) const
inline

Return an iterator that points to the first element of the list of the inverse transforms.

Definition at line 332 of file itkPSMParticleSystem.h.

333  { return m_InverseTransforms.begin(); }
template<unsigned int VDimension>
std::vector< TransformType >::iterator itk::PSMParticleSystem< VDimension >::GetInverseTransformsBegin ( )
inlineprotected

Return an iterator that points to the first element of the list of the inverse transforms.

Definition at line 465 of file itkPSMParticleSystem.h.

466  { return m_InverseTransforms.begin(); }
template<unsigned int VDimension>
std::vector< TransformType >::const_iterator itk::PSMParticleSystem< VDimension >::GetInverseTransformsEnd ( ) const
inline

Return an iterator that points one position past the last element of the list of the transforms.

Definition at line 338 of file itkPSMParticleSystem.h.

339  { return m_InverseTransforms.end(); }
template<unsigned int VDimension>
std::vector< TransformType >::iterator itk::PSMParticleSystem< VDimension >::GetInverseTransformsEnd ( )
inlineprotected

Return an iterator that points one position past the last element of the list of the transforms.

Definition at line 471 of file itkPSMParticleSystem.h.

472  { return m_InverseTransforms.end(); }
template<unsigned int VDimension>
unsigned int itk::PSMParticleSystem< VDimension >::GetNumberOfDomains ( ) const
inline

Returns the number of domains contained in the particle system.

Definition at line 270 of file itkPSMParticleSystem.h.

271  { return m_Domains.size(); }
template<unsigned int VDimension>
unsigned long int itk::PSMParticleSystem< VDimension >::GetNumberOfParticles ( unsigned int  d = 0) const
inline

Returns the number of particles in domain k.

Definition at line 136 of file itkPSMParticleSystem.h.

137  { return m_Positions[d]->GetSize(); }
template<unsigned int VDimension>
PointType& itk::PSMParticleSystem< VDimension >::GetPosition ( unsigned long int  k,
unsigned int  d = 0 
)
inline

Return a position with index k from domain d. Note the order in which the 2 integers must be specified! The domain number is specified second and the position index within the domain is specified first. Note that the domain index may be omitted if the particle system only contains a single domain. GetTransformedPosition returns the position premultiplied by the transform matrix for the given domain.

Definition at line 169 of file itkPSMParticleSystem.h.

170  { return m_Positions[d]->operator[](k); }
template<unsigned int VDimension>
const std::vector<typename PointContainerType::Pointer>& itk::PSMParticleSystem< VDimension >::GetPositions ( ) const
inline

Return the array of particle positions.

Definition at line 358 of file itkPSMParticleSystem.h.

359  { return m_Positions; }
template<unsigned int VDimension>
const TransformType& itk::PSMParticleSystem< VDimension >::GetPrefixTransform ( unsigned int  i) const
inline

Return the i'th transform object.

Definition at line 314 of file itkPSMParticleSystem.h.

315  { return m_PrefixTransforms[i]; }
template<unsigned int VDimension>
const TransformType& itk::PSMParticleSystem< VDimension >::GetPrefixTransform ( ) const
inline

API for the single transform case.

Definition at line 318 of file itkPSMParticleSystem.h.

319  {return m_PrefixTransforms[0]; }
template<unsigned int VDimension>
TransformType itk::PSMParticleSystem< VDimension >::GetPrefixTransform ( unsigned int  i)
inline

Return the i'th transform object.

Definition at line 322 of file itkPSMParticleSystem.h.

323  { return m_PrefixTransforms[i]; }
template<unsigned int VDimension>
TransformType itk::PSMParticleSystem< VDimension >::GetPrefixTransform ( )
inline

API for the single transform case.

Definition at line 326 of file itkPSMParticleSystem.h.

327  {return m_PrefixTransforms[0]; }
template<unsigned int VDimension>
const TransformType& itk::PSMParticleSystem< VDimension >::GetTransform ( unsigned int  i) const
inline

Return the i'th transform object.

Definition at line 298 of file itkPSMParticleSystem.h.

299  { return m_Transforms[i]; }
template<unsigned int VDimension>
const TransformType& itk::PSMParticleSystem< VDimension >::GetTransform ( ) const
inline

API for the single transform case.

Definition at line 302 of file itkPSMParticleSystem.h.

303  {return m_Transforms[0]; }
template<unsigned int VDimension>
TransformType itk::PSMParticleSystem< VDimension >::GetTransform ( unsigned int  i)
inline

Return the i'th transform object.

Definition at line 306 of file itkPSMParticleSystem.h.

307  { return m_Transforms[i]; }
template<unsigned int VDimension>
TransformType itk::PSMParticleSystem< VDimension >::GetTransform ( )
inline

API for the single transform case.

Definition at line 310 of file itkPSMParticleSystem.h.

311  {return m_Transforms[0]; }
template<unsigned int VDimension>
std::vector< TransformType >::const_iterator itk::PSMParticleSystem< VDimension >::GetTransformsBegin ( ) const
inline

Return an iterator that points to the first element of the list of the transforms.

Definition at line 290 of file itkPSMParticleSystem.h.

290 { return m_Transforms.begin(); }
template<unsigned int VDimension>
std::vector< TransformType >::iterator itk::PSMParticleSystem< VDimension >::GetTransformsBegin ( )
inlineprotected

Return an iterator that points to the first element of the list of the transforms.

Definition at line 454 of file itkPSMParticleSystem.h.

455  { return m_Transforms.begin(); }
template<unsigned int VDimension>
std::vector< TransformType >::const_iterator itk::PSMParticleSystem< VDimension >::GetTransformsEnd ( ) const
inline

Return an iterator that points one position past the last element of the list of the transforms.

Definition at line 295 of file itkPSMParticleSystem.h.

295 { return m_Transforms.end(); }
template<unsigned int VDimension>
std::vector< TransformType >::iterator itk::PSMParticleSystem< VDimension >::GetTransformsEnd ( )
inlineprotected

Return an iterator that points one position past the last element of the list of the transforms.

Definition at line 459 of file itkPSMParticleSystem.h.

460  { return m_Transforms.end(); }
template<unsigned int VDimension>
TransformType itk::PSMParticleSystem< VDimension >::InvertTransform ( const TransformType T) const
inline

Returns the inverse of a transformation matrix.

Definition at line 377 of file itkPSMParticleSystem.h.

378  {
379  double det = vnl_det(T);
380  // Check if the inverse can be calculated. If not, set the inverse
381  // to identity.
382  if (det == 0)
383  {
384  TransformType identity;
385  identity.set_identity();
386  return identity;
387  }
388  else
389  {
390  // Note, vnl_inverse is optimized for small matrices 1x1 - 4x4
391  return vnl_inverse(T);
392  }
393  }
vnl_matrix_fixed< double, VDimension+1, VDimension+1 > TransformType
template<unsigned int VDimension>
itk::PSMParticleSystem< VDimension >::itkNewMacro ( Self  )

Method for creation through the object factory.

template<unsigned int VDimension>
itk::PSMParticleSystem< VDimension >::itkStaticConstMacro ( Dimension  ,
unsigned  int,
VDimension   
)

Dimensionality of the domain of the particle system.

template<unsigned int VDimension>
itk::PSMParticleSystem< VDimension >::itkTypeMacro ( PSMParticleSystem< VDimension >  ,
DataObject   
)

Run-time type information (and related methods).

template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::RegisterAttribute ( PSMAttribute< VDimension > *  attr)

Register an attribute object with this particle system. This action adds the attribute object as an observer for the particle system so that it will receive published updates. For example, a gradient attribute object may need to know when particle positions have changed so that it can update its internal state appropriately (e.g. precompute a gradient that corresponds to the new particle position). Internally, this method manages registering the appropriate itk::Command and itk::Object as an observer of this itk::Object (AddObserver). Relevant state information is passed to objects in particle events.

Definition at line 310 of file itkPSMParticleSystem.hxx.

311 {
312  // Register any methods defined by the attribute as observers of this
313  // PSMParticleSystem with appropriate events.
314  if (attr->m_DefinedCallbacks.Event == true)
315  {
316  typename MemberCommand< PSMAttribute<VDimension> >::Pointer tmpcmd
317  = MemberCommand< PSMAttribute<VDimension> >::New();
318  tmpcmd->SetCallbackFunction(attr, &PSMAttribute<VDimension>::EventCallback);
319  this->AddObserver(ParticleEvent(), tmpcmd);
320  }
321  if (attr->m_DefinedCallbacks.EventWithIndex == true)
322  {
323  typename MemberCommand< PSMAttribute<VDimension> >::Pointer tmpcmd
324  = MemberCommand< PSMAttribute<VDimension> >::New();
325  tmpcmd->SetCallbackFunction(attr, &PSMAttribute<VDimension>::EventWithIndexCallback);
326  this->AddObserver(ParticleEventWithIndex(), tmpcmd);
327  }
328  if (attr->m_DefinedCallbacks.DomainAddEvent == true)
329  {
330  typename MemberCommand< PSMAttribute<VDimension> >::Pointer tmpcmd
331  = MemberCommand< PSMAttribute<VDimension> >::New();
332  tmpcmd->SetCallbackFunction(attr, &PSMAttribute<VDimension>::DomainAddEventCallback);
333  this->AddObserver(ParticleDomainAddEvent(), tmpcmd);
334  }
335  if (attr->m_DefinedCallbacks.TransformSetEvent == true)
336  {
337  typename MemberCommand< PSMAttribute<VDimension> >::Pointer tmpcmd
338  = MemberCommand< PSMAttribute<VDimension> >::New();
339  tmpcmd->SetCallbackFunction(attr, &PSMAttribute<VDimension>::TransformSetEventCallback);
340  this->AddObserver(ParticleTransformSetEvent(), tmpcmd);
341  }
342  if (attr->m_DefinedCallbacks.PrefixTransformSetEvent == true)
343  {
344  typename MemberCommand< PSMAttribute<VDimension> >::Pointer tmpcmd
345  = MemberCommand< PSMAttribute<VDimension> >::New();
346  tmpcmd->SetCallbackFunction(attr, &PSMAttribute<VDimension>::PrefixTransformSetEventCallback);
347  this->AddObserver(ParticlePrefixTransformSetEvent(), tmpcmd);
348  }
349  if (attr->m_DefinedCallbacks.NeighborhoodSetEvent == true)
350  {
351  typename MemberCommand< PSMAttribute<VDimension> >::Pointer tmpcmd
352  = MemberCommand< PSMAttribute<VDimension> >::New();
353  tmpcmd->SetCallbackFunction(attr, &PSMAttribute<VDimension>::NeighborhoodSetEventCallback);
354  this->AddObserver(ParticleNeighborhoodSetEvent(), tmpcmd);
355  }
356  if (attr->m_DefinedCallbacks.PositionSetEvent == true)
357  {
358  typename MemberCommand< PSMAttribute<VDimension> >::Pointer tmpcmd
359  = MemberCommand< PSMAttribute<VDimension> >::New();
360  tmpcmd->SetCallbackFunction(attr, &PSMAttribute<VDimension>::PositionSetEventCallback);
361  this->AddObserver(ParticlePositionSetEvent(), tmpcmd);
362  }
363  if (attr->m_DefinedCallbacks.PositionAddEvent == true)
364  {
365  typename MemberCommand< PSMAttribute<VDimension> >::Pointer tmpcmd
366  = MemberCommand< PSMAttribute<VDimension> >::New();
367  tmpcmd->SetCallbackFunction(attr, &PSMAttribute<VDimension>::PositionAddEventCallback);
368  this->AddObserver(ParticlePositionAddEvent(), tmpcmd);
369  }
370  if (attr->m_DefinedCallbacks.PositionRemoveEvent == true)
371  {
372  typename MemberCommand< PSMAttribute<VDimension> >::Pointer tmpcmd
373  = MemberCommand< PSMAttribute<VDimension> >::New();
374  tmpcmd->SetCallbackFunction(attr, &PSMAttribute<VDimension>::PositionRemoveEventCallback);
375  this->AddObserver(ParticlePositionRemoveEvent(), tmpcmd);
376  }
377 }
virtual void EventCallback(Object *, const EventObject &)
template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::SetFixedParticleFlag ( unsigned int  i)
inline

The following methods provide functionality for specifying particle indices that are fixed landmarks. SetPosition() calls to these particle indices will silently fail. For simplicity, only one list of indices is maintained for all dimensions. If particle index n is flagged, for example, then particle index n in all domains is fixed.

Definition at line 418 of file itkPSMParticleSystem.h.

419  { if (i < m_FixedParticleFlags.size()) m_FixedParticleFlags[i] = true; }
template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::SetNeighborhood ( unsigned int  i,
NeighborhoodType N,
int  threadId = 0 
)

Set/Get the neighborhood object associated with domain k.

Definition at line 130 of file itkPSMParticleSystem.hxx.

131 {
132  m_Neighborhoods[i] = N;
133  m_Neighborhoods[i]->SetDomain(m_Domains[i]);
134  m_Neighborhoods[i]->SetPointContainer(m_Positions[i]);
135 
136  // Notify any observers.
137  ParticleNeighborhoodSetEvent e;
138  e.SetThreadID(threadId);
139  e.SetDomainIndex(i);
140  this->InvokeEvent(e);
141 }
template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::SetNumberOfDomains ( unsigned int  num)
protected

Set the number of domains. This method modifies the size of the m_Domains, m_Positions, and m_Transform lists.

Definition at line 35 of file itkPSMParticleSystem.hxx.

36 {
37  // in case nothing has changed.
38  if (num == m_Domains.size())
39  {
40  return;
41  }
42  m_Domains.resize(num);
43  m_Transforms.resize(num);
44  m_InverseTransforms.resize(num);
45  m_PrefixTransforms.resize(num);
46  m_InversePrefixTransforms.resize(num);
47  m_Positions.resize(num);
48  m_IndexCounters.resize(num);
49  m_Neighborhoods.resize(num);
50  m_DomainFlags.resize(num);
51  this->Modified();
52 }
template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::SetTransform ( unsigned int  i,
const TransformType T,
int  threadId = 0 
)

Set the transform associated with domain i. This method will also compute and set the corresponding inverse transform if possible. If the inverse transform cannot be computed, the exception is quietly handled by this method and an identity transform is set in its place. The calling program is responsible for knowing when an inverse transform cannot be computed.

Definition at line 102 of file itkPSMParticleSystem.hxx.

103 {
104  m_Transforms[i] = T;
105  m_InverseTransforms[i] = this->InvertTransform(T);
106 
107  // Notify any observers.
108  ParticleTransformSetEvent e;
109  e.SetThreadID(threadId);
110  e.SetDomainIndex(i);
111  this->InvokeEvent(e);
112 }
TransformType InvertTransform(const TransformType &T) const
template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::SplitAllParticles ( double  epsilon,
int  threadId = 0 
)

Doubles the number of particles of the system by splitting each particle into 2 particles. Each new particle position is added to the system at a random epsilon distance on the surface from the original particle. The new particles are added using the AddPosition method, so all appropriate callbacks are invoked.

Definition at line 288 of file itkPSMParticleSystem.hxx.

289 {
290  // Find a random direction.
291  vnl_vector_fixed<double, VDimension> random;
292 
293  for (unsigned int i = 0; i < VDimension; i++)
294  { random[i] = static_cast<double>(rand()); }
295  double norm = random.magnitude();
296 
297  // Normalize the random vector.
298  random /= norm;
299 
300  // Loop through all particle positions in the domain and add a new position
301  // at an epsilon distance and random direction.
302  for (unsigned i = 0; i < this->GetNumberOfDomains(); i++)
303  {
304  this->SplitAllParticlesInDomain(random, epsilon, i, threadId);
305  }
306 }
unsigned int GetNumberOfDomains() const
template<unsigned int VDimension>
void itk::PSMParticleSystem< VDimension >::SynchronizePositions ( )
inline

Invokes the set event on all particle positions, resetting them to their current value. This method may be called to synchronize positional information among various observers which may have gone out of sync.

Definition at line 124 of file itkPSMParticleSystem.h.

125  {
126  for (unsigned int d = 0; d < this->GetNumberOfDomains(); d++)
127  {
128  for (unsigned int p = 0; p < this->GetNumberOfParticles(d); p++)
129  {
130  this->SetPosition(this->GetPosition(p,d), p, d);
131  }
132  }
133  }
unsigned int GetNumberOfDomains() const
PointType & GetPosition(unsigned long int k, unsigned int d=0)
unsigned long int GetNumberOfParticles(unsigned int d=0) const
template<>
PSMParticleSystem< 3 >::PointType itk::PSMParticleSystem< 3 >::TransformPoint ( const PointType p,
const TransformType T 
) const

For efficiency, we specialize for 3D and 2D

Definition at line 26 of file itkPSMParticleSystem.cxx.

27 {
28  PointType ans;
29 
30  ans[0] = T[0][0] * p[0] + T[0][1] * p[1] + T[0][2] * p[2] + T[0][3];
31  ans[1] = T[1][0] * p[0] + T[1][1] * p[1] + T[1][2] * p[2] + T[1][3];
32  ans[2] = T[2][0] * p[0] + T[2][1] * p[1] + T[2][2] * p[2] + T[2][3];
33 
34  return ans;
35 }
Point< double, VDimension > PointType
template<>
PSMParticleSystem< 2 >::PointType itk::PSMParticleSystem< 2 >::TransformPoint ( const PointType p,
const TransformType T 
) const

For efficiency, we specialize for 3D and 2D

Definition at line 41 of file itkPSMParticleSystem.cxx.

42 {
43  PointType ans;
44 
45  ans[0] = T[0][0] * p[0] + T[0][1] * p[1] + T[0][2];
46  ans[1] = T[1][0] * p[0] + T[1][1] * p[1] + T[1][2];
47 
48  return ans;
49 }
Point< double, VDimension > PointType
template<unsigned int VDimension>
PointType itk::PSMParticleSystem< VDimension >::TransformPoint ( const PointType ,
const TransformType  
) const

Transforms a point using the given transform. NOTE: Scaling is not currently implemented. (This method may be converted to virtual and overridden if tranform type is generalized.)

template<>
PSMParticleSystem< 3 >::VectorType itk::PSMParticleSystem< 3 >::TransformVector ( const VectorType &  p,
const TransformType T 
) const

For efficiency, we specialize for 3D and 2D

Definition at line 56 of file itkPSMParticleSystem.cxx.

57 {
58  VectorType ans;
59 
60  ans[0] = T[0][0] * p[0] + T[0][1] * p[1] + T[0][2] * p[2];
61  ans[1] = T[1][0] * p[0] + T[1][1] * p[1] + T[1][2] * p[2];
62  ans[2] = T[2][0] * p[0] + T[2][1] * p[1] + T[2][2] * p[2];
63 
64  return ans;
65 }
template<>
PSMParticleSystem< 2 >::VectorType itk::PSMParticleSystem< 2 >::TransformVector ( const VectorType &  p,
const TransformType T 
) const

For efficiency, we specialize for 3D and 2D

Definition at line 71 of file itkPSMParticleSystem.cxx.

72 {
73  VectorType ans;
74 
75  ans[0] = T[0][0] * p[0] + T[0][1] * p[1];
76  ans[1] = T[1][0] * p[0] + T[1][1] * p[1];
77 
78  return ans;
79 }
template<unsigned int VDimension>
VectorType itk::PSMParticleSystem< VDimension >::TransformVector ( const VectorType &  ,
const TransformType  
) const

Transforms a vector using the given transform. Only the rotational part of the transform is applied. NOTE: Scaling is not currently supported.


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