19 #include "itkPSMParticleSystem.h" 20 #include "itkPSMRegionNeighborhood.h" 21 #include "itkPSMRegionDomain.h" 25 int itkPSMParticleSystemTest(
int,
char* [] )
28 std::string errstring =
"";
32 typedef itk::Point<double, 3> PointType;
40 const unsigned int SZ = 100;
42 ptl[0] = 0.0f; ptl[1] = 0.0f; ptl[2] = 0.0f;
43 ptu[0] =
static_cast<double>(SZ); ptu[1] =
static_cast<double>(SZ); ptu[2] =
static_cast<double>(SZ);
55 errstring += std::string(
"AddDomain method failed. ");
65 for (
unsigned int i = 0; i < SZ; i++)
67 pt[0] =
static_cast<double>(i) + 0.1f;
68 pt[1] =
static_cast<double>(i) + 0.2f;
69 pt[2] =
static_cast<double>(i) + 0.3f;
76 errstring += std::string(
"AddPosition method failed. ");
85 errstring += std::string(
"SplitAllParticles method failed. ");
88 for (
unsigned int i = 0; i < 2; i++)
90 P->SplitParticle(0.1, 0, i);
94 errstring += std::string(
"SplitParticle method failed. ");
99 for (
unsigned int i = 0; i < 2; i++)
103 modPt[0] = originalPt[0] + 0.1;
104 modPt[1] = originalPt[1] + 0.2;
105 modPt[2] = originalPt[2] + 0.3;
106 P->SetPosition(modPt, 0, i);
110 errstring += std::string(
"Get/SetPosition methods failed. ");
115 for (
unsigned int i = 0; i < 2; i++)
117 P->RemovePosition(0, i);
121 errstring += std::string(
"RemovePosition method failed. ");
126 itk::PSMRegionNeighborhood<3>::PointVectorType vec;
127 for (
unsigned int i = 0; i < 2; i++)
136 errstring += std::string(
"FindNeighborhoodPoints method failed. ");
141 catch(itk::ExceptionObject &e)
143 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
144 + std::string(
"\n at location:") + std::string(e.GetLocation())
145 + std::string(
"\n in file:") + std::string(e.GetFile());
150 errstring =
"Unknown exception thrown";
156 std::cout <<
"All tests passed" << std::endl;
161 std::cout <<
"Test failed with the following error:" << std::endl;
162 std::cout << errstring << std::endl;
unsigned int GetNumberOfDomains() const
void AddDomain(DomainType *, int threadId=0)
void SetNeighborhood(unsigned int, NeighborhoodType *, int threadId=0)
PointType & GetPosition(unsigned long int k, unsigned int d=0)
const PointType & AddPosition(const PointType &, unsigned int d=0, int threadId=0)
unsigned long int GetNumberOfParticles(unsigned int d=0) const
A facade class that manages interactions with a particle system.
void SplitAllParticles(double epsilon, int threadId=0)
PointVectorType FindNeighborhoodPoints(const PointType &p, double r, unsigned int d=0) const
void SetRegion(const PointType &l, const PointType &u)