19 #include "itkPSMContainerArrayAttribute.h" 20 #include "itkPSMParticleSystem.h" 21 #include "itkPSMRegionNeighborhood.h" 22 #include "itkPSMRegionDomain.h" 27 template<
class T,
unsigned int VDimension>
35 typedef SmartPointer<Self> Pointer;
36 typedef SmartPointer<const Self> ConstPointer;
37 typedef WeakPointer<const Self> ConstWeakPointer;
51 this->resize( this->size() +1);
56 virtual void PositionAddEventCallback(Object *,
const EventObject &e)
58 const itk::ParticlePositionAddEvent &
event 59 =
dynamic_cast<const itk::ParticlePositionAddEvent &
>(e);
60 this->operator[](event.GetDomainIndex())->
operator[](event.GetPositionIndex()) = 0.0;
64 unsigned int GetNumberOfPositions() {
return m_AddPositionCount; }
65 unsigned int GetNumberOfDomains() {
return m_AddDomainCount; }
74 unsigned int m_AddPositionCount;
75 unsigned int m_AddDomainCount;
81 int itkPSMContainerArrayAttributeTest(
int,
char* [] )
84 std::string errstring =
"";
88 typedef itk::Point<double, 3> PointType;
101 const unsigned int SZ = 100;
103 ptl[0] = 0.0f; ptl[1] = 0.0f; ptl[2] = 0.0f;
104 ptu[0] =
static_cast<double>(SZ); ptu[1] =
static_cast<double>(SZ); ptu[2] =
static_cast<double>(SZ);
116 for (
unsigned int i = 0; i < SZ; i++)
118 pt[0] =
static_cast<double>(i) + 0.1f;
119 pt[1] =
static_cast<double>(i) + 0.2f;
120 pt[2] =
static_cast<double>(i) + 0.3f;
126 if (P->GetNumberOfPositions() != 2*SZ)
129 errstring += std::string(
"PositionAddEventCallback method error. ");
131 if (P->GetNumberOfDomains() != 2)
134 errstring += std::string(
"DomainAddEventCallback method error. ");
137 catch(itk::ExceptionObject &e)
139 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
140 + std::string(
"\n at location:") + std::string(e.GetLocation())
141 + std::string(
"\n in file:") + std::string(e.GetFile());
146 errstring =
"Unknown exception thrown";
152 std::cout <<
"All tests passed" << std::endl;
157 std::cout <<
"Test failed with the following error:" << std::endl;
158 std::cout << errstring << std::endl;
itkTypeMacro(TestContainerArrayAttribute, PSMContainerArrayAttribute)
void AddDomain(DomainType *, int threadId=0)
void SetNeighborhood(unsigned int, NeighborhoodType *, int threadId=0)
void RegisterAttribute(PSMAttribute< VDimension > *)
const PointType & AddPosition(const PointType &, unsigned int d=0, int threadId=0)
A facade class that manages interactions with a particle system.
Base class for PSMParticleSystem attribute classes.
A container class that holds particle position information for the PSMParticleSystem class...
virtual void DomainAddEventCallback(Object *, const EventObject &)
void SetRegion(const PointType &l, const PointType &u)