18 #ifndef __itkPSMShapeMatrixAttribute_hxx 19 #define __itkPSMShapeMatrixAttribute_hxx 20 #include "itkPSMShapeMatrixAttribute.h" 25 template <
class T,
unsigned int VDimension>
28 const ParticleDomainAddEvent &
event =
dynamic_cast<const ParticleDomainAddEvent &
>(e);
29 unsigned int d =
event.GetDomainIndex();
31 if ( d % m_DomainsPerShape == 0 )
33 this->ResizeMatrix(this->rows(), this->cols()+1);
37 template <
class T,
unsigned int VDimension>
40 vnl_matrix<T> tmp(*
this);
43 this->set_size(rs, cs);
46 for (
unsigned int c = 0; c < tmp.cols(); c++)
48 for (
unsigned int r = 0; r < tmp.rows(); r++)
50 this->operator()(r,c) = tmp(r,c);
55 template <
class T,
unsigned int VDimension>
58 const ParticlePositionAddEvent &
event =
dynamic_cast<const ParticlePositionAddEvent &
>(e);
60 const int d =
event.GetDomainIndex();
61 const unsigned int idx =
event.GetPositionIndex();
69 this->ResizeMatrix(PointsPerDomain * VDimension * m_DomainsPerShape, this->cols());
74 unsigned int k = ((d % m_DomainsPerShape) * PointsPerDomain * VDimension)
76 for (
unsigned int i = 0; i < VDimension; i++)
78 this->operator()(i+k, d / m_DomainsPerShape) = pos[i];
82 template <
class T,
unsigned int VDimension>
85 const ParticlePositionSetEvent &
event =
dynamic_cast<const ParticlePositionSetEvent &
>(e);
87 const int d =
event.GetDomainIndex();
88 const unsigned int idx =
event.GetPositionIndex();
94 unsigned int k = ((d % m_DomainsPerShape) * PointsPerDomain * VDimension)
96 for (
unsigned int i = 0; i < VDimension; i++)
98 this->operator()(i+k, d / m_DomainsPerShape) = pos[i];
virtual void PositionSetEventCallback(Object *o, const EventObject &e)
unsigned long int GetNumberOfParticles(unsigned int d=0) const
virtual void ResizeMatrix(int, int)
A facade class that manages interactions with a particle system.
virtual void DomainAddEventCallback(Object *, const EventObject &e)
virtual void PositionAddEventCallback(Object *o, const EventObject &e)