18 #ifndef __itkPSMParticleSystem_h 19 #define __itkPSMParticleSystem_h 21 #include "itkDataObject.h" 22 #include "itkObjectFactory.h" 24 #include "itkWeakPointer.h" 25 #include "itkPSMAttribute.h" 26 #include "itkPSMDomain.h" 27 #include "vnl/vnl_matrix_fixed.h" 28 #include "vnl/vnl_vector_fixed.h" 29 #include "itkPSMContainer.h" 30 #include "itkPSMEvents.h" 31 #include "itkCommand.h" 32 #include "itkEventObject.h" 33 #include "itkPSMNeighborhood.h" 34 #include "vnl/vnl_inverse.h" 35 #include "vnl/vnl_det.h" 67 template <
unsigned int VDimension>
73 typedef DataObject Superclass;
74 typedef SmartPointer<Self> Pointer;
75 typedef SmartPointer<const Self> ConstPointer;
76 typedef WeakPointer<const Self> ConstWeakPointer;
85 itkStaticConstMacro(Dimension,
unsigned int, VDimension);
104 typedef vnl_matrix_fixed<double, VDimension +1, VDimension +1>
TransformType;
105 typedef vnl_vector_fixed<double, VDimension> VectorType;
126 for (
unsigned int d = 0; d < this->GetNumberOfDomains(); d++)
128 for (
unsigned int p = 0; p < this->GetNumberOfParticles(d); p++)
130 this->SetPosition(this->GetPosition(p,d), p, d);
137 {
return m_Positions[d]->GetSize(); }
151 const PointType &AddPosition(
const PointType &,
unsigned int d=0,
int threadId=0);
152 const PointType &SetPosition(
const PointType &,
unsigned long int k,
unsigned int d=0,
int threadId=0);
160 void RemovePosition(
unsigned long int k,
unsigned int d=0,
int threadId=0);
170 {
return m_Positions[d]->operator[](k); }
171 const PointType &GetPosition(
unsigned long int k,
unsigned int d=0)
const 172 {
return m_Positions[d]->operator[](k); }
173 PointType GetTransformedPosition(
unsigned long int k,
unsigned int d=0)
const 174 {
return this->TransformPoint(m_Positions[d]->
operator[](k),
175 m_Transforms[d] * m_PrefixTransforms[d]); }
182 void SplitAllParticles(
double epsilon,
int threadId=0);
183 void SplitAllParticlesInDomain(
const vnl_vector_fixed<double, VDimension> &,
184 double epsilon,
unsigned int d=0,
int threadId=0);
185 void SplitParticle(
double epsilon,
unsigned int idx,
unsigned int d=0,
int threadId=0);
188 void SetNeighborhood(
unsigned int, NeighborhoodType *,
int threadId=0);
189 void SetNeighborhood(NeighborhoodType *n,
int threadId=0)
190 { this->SetNeighborhood(0, n, threadId); }
191 typename NeighborhoodType::ConstPointer GetNeighborhood(
unsigned int k)
const 192 {
return m_Neighborhoods[k]; }
201 double r,
unsigned int d = 0)
const 203 return m_Neighborhoods[d]->FindNeighborhoodPoints(p, r);
205 inline PointVectorType FindNeighborhoodPoints(
const PointType &p,
206 std::vector<double> &w,
207 double r,
unsigned int d = 0)
const 209 return m_Neighborhoods[d]->FindNeighborhoodPointsWithWeights(p,w,r);
211 inline PointVectorType FindNeighborhoodPoints(
unsigned int idx,
212 double r,
unsigned int d = 0)
const 214 return m_Neighborhoods[d]->FindNeighborhoodPoints(this->GetPosition(idx,d), r);
216 inline PointVectorType FindNeighborhoodPoints(
unsigned int idx,
217 std::vector<double> &w,
218 double r,
unsigned int d = 0)
const 220 return m_Neighborhoods[d]->FindNeighborhoodPointsWithWeights(this->GetPosition(idx,d),w, r);
241 void AddDomain( DomainType *,
int threadId =0);
245 typename std::vector< typename DomainType::Pointer >::const_iterator
GetDomainsBegin()
const 246 {
return m_Domains.begin(); }
250 typename std::vector< typename DomainType::Pointer >::const_iterator
GetDomainsEnd()
const 251 {
return m_Domains.end(); }
255 {
return m_Domains[i].GetPointer(); }
259 {
return m_Domains[0].GetPointer(); }
263 {
return m_Domains[i].GetPointer(); }
267 {
return m_Domains[0].GetPointer(); }
271 {
return m_Domains.size(); }
280 void SetTransform(
unsigned int i,
const TransformType &,
int threadId=0);
281 void SetTransform(
const TransformType &p,
int threadId=0)
282 { this->SetTransform(0, p, threadId); }
283 void SetPrefixTransform(
unsigned int i,
const TransformType &,
int threadId=0);
284 void SetPrefixTransform(
const TransformType &p,
int threadId=0)
285 { this->SetPrefixTransform(0, p, threadId); }
289 typename std::vector< TransformType >::const_iterator
294 typename std::vector< TransformType >::const_iterator
299 {
return m_Transforms[i]; }
303 {
return m_Transforms[0]; }
307 {
return m_Transforms[i]; }
311 {
return m_Transforms[0]; }
315 {
return m_PrefixTransforms[i]; }
319 {
return m_PrefixTransforms[0]; }
323 {
return m_PrefixTransforms[i]; }
327 {
return m_PrefixTransforms[0]; }
331 typename std::vector< TransformType >::const_iterator
333 {
return m_InverseTransforms.begin(); }
337 typename std::vector< TransformType >::const_iterator
339 {
return m_InverseTransforms.end(); }
343 {
return m_InverseTransforms[i]; }
347 {
return m_InverseTransforms[0]; }
351 {
return m_InversePrefixTransforms[i]; }
355 {
return m_InversePrefixTransforms[0]; }
358 const std::vector<typename PointContainerType::Pointer> &
GetPositions()
const 359 {
return m_Positions; }
360 const typename PointContainerType::Pointer & GetPositions(
unsigned int d)
const 361 {
return m_Positions[d]; }
365 void AddPositionList(
const std::vector<PointType> &,
unsigned int d,
int threadId = 0);
370 PointType TransformPoint(
const PointType &,
const TransformType &)
const;
374 VectorType TransformVector(
const VectorType &,
const TransformType &)
const;
379 double det = vnl_det(T);
384 TransformType identity;
385 identity.set_identity();
391 return vnl_inverse(T);
398 { m_DomainFlags[i] =
true; }
399 void UnflagDomain(
unsigned int i)
400 { m_DomainFlags[i] =
false; }
401 bool GetDomainFlag(
unsigned int i)
const 402 {
return m_DomainFlags[i]; }
405 const std::vector<bool> &GetDomainFlags()
const 406 {
return m_DomainFlags; }
407 void SetDomainFlags()
408 {
for (
unsigned int i = 0; i < m_DomainFlags.size(); i++) { m_DomainFlags[i] =
true; } }
409 void ResetDomainFlags()
410 {
for (
unsigned int i = 0; i < m_DomainFlags.size(); i++) { m_DomainFlags[i] =
false; } }
419 {
if (i < m_FixedParticleFlags.size()) m_FixedParticleFlags[i] =
true; }
420 void ResetFixedParticleFlag(
unsigned int i)
421 {
if (i < m_FixedParticleFlags.size()) m_FixedParticleFlags[i] =
false;}
422 bool GetFixedParticleFlag(
unsigned int i)
const 424 if (i < m_FixedParticleFlags.size())
return m_FixedParticleFlags[i];
427 void ResetFixedParticleFlags()
429 for (
unsigned int i = 0; i < m_FixedParticleFlags.size(); i++)
430 { m_FixedParticleFlags[i] =
false; }
435 void PrintSelf(std::ostream& os, Indent indent)
const;
440 void SetNumberOfDomains(
unsigned int );
445 {
return m_Domains.begin(); }
449 typename std::vector< typename DomainType::Pointer >::iterator
GetDomainsEnd()
450 {
return m_Domains.end(); }
455 {
return m_Transforms.begin(); }
460 {
return m_Transforms.end(); }
464 typename std::vector< TransformType >::iterator
466 {
return m_InverseTransforms.begin(); }
470 typename std::vector< TransformType >::iterator
472 {
return m_InverseTransforms.end(); }
476 {
return m_InverseTransforms[i]; }
480 {
return m_InverseTransforms[0]; }
484 {
return m_InversePrefixTransforms[i]; }
488 {
return m_InversePrefixTransforms[0]; }
492 void operator=(
const Self&);
496 std::vector<typename PointContainerType::Pointer> m_Positions;
499 std::vector< typename DomainType::Pointer > m_Domains;
502 std::vector< typename NeighborhoodType::Pointer > m_Neighborhoods;
505 std::vector< TransformType > m_Transforms;
508 std::vector< TransformType > m_InverseTransforms;
511 std::vector< TransformType > m_PrefixTransforms;
514 std::vector< TransformType > m_InversePrefixTransforms;
517 std::vector< unsigned long int> m_IndexCounters;
523 std::vector<bool> m_DomainFlags;
527 std::vector<bool> m_FixedParticleFlags;
532 #ifndef ITK_MANUAL_INSTANTIATION 533 #include "itkPSMParticleSystem.hxx" unsigned int GetNumberOfDomains() const
const TransformType & GetTransform() const
void SynchronizePositions()
TransformType InvertTransform(const TransformType &T) const
std::vector< typename DomainType::Pointer >::iterator GetDomainsBegin()
const TransformType & GetInverseTransform() const
const TransformType & GetInverseTransform(unsigned int i) const
std::vector< TransformType >::const_iterator GetTransformsBegin() const
TransformType & GetInversePrefixTransform(unsigned int i)
const TransformType & GetPrefixTransform() const
PSMNeighborhood< VDimension > NeighborhoodType
TransformType GetPrefixTransform()
const DomainType * GetDomain(unsigned int i) const
PointType & GetPosition(unsigned long int k, unsigned int d=0)
std::vector< TransformType >::const_iterator GetInverseTransformsBegin() const
TransformType GetTransform(unsigned int i)
TransformType & GetInverseTransform(unsigned int i)
TransformType GetTransform()
const DomainType * GetDomain() const
std::vector< TransformType >::const_iterator GetInverseTransformsEnd() const
void FlagDomain(unsigned int i)
std::vector< TransformType >::iterator GetInverseTransformsBegin()
unsigned long int GetNumberOfParticles(unsigned int d=0) const
Point< double, VDimension > PointType
TransformType & GetInverseTransform()
std::vector< typename DomainType::Pointer >::const_iterator GetDomainsEnd() const
std::vector< typename DomainType::Pointer >::iterator GetDomainsEnd()
std::vector< TransformType >::iterator GetTransformsBegin()
const TransformType & GetInversePrefixTransform(unsigned int i) const
A facade class that manages interactions with a particle system.
const TransformType & GetTransform(unsigned int i) const
const TransformType & GetPrefixTransform(unsigned int i) const
TransformType & GetInversePrefixTransform()
Base class for defining the domain in which a particle system exists.
DomainType * GetDomain(unsigned int i)
std::vector< typename DomainType::Pointer >::const_iterator GetDomainsBegin() const
Base class for PSMParticleSystem attribute classes.
std::vector< PSMPointIndexPair< VDimension > > PointVectorType
A container class that holds particle position information for the PSMParticleSystem class...
TransformType GetPrefixTransform(unsigned int i)
PointVectorType FindNeighborhoodPoints(const PointType &p, double r, unsigned int d=0) const
PSMDomain< VDimension > DomainType
std::vector< TransformType >::iterator GetInverseTransformsEnd()
void SetFixedParticleFlag(unsigned int i)
std::vector< TransformType >::const_iterator GetTransformsEnd() const
const TransformType & GetInversePrefixTransform() const
const std::vector< typename PointContainerType::Pointer > & GetPositions() const
PSMContainer< PointType > PointContainerType
std::vector< TransformType >::iterator GetTransformsEnd()
vnl_matrix_fixed< double, VDimension+1, VDimension+1 > TransformType