19 #include "itkPSMRegionNeighborhood.h" 20 #include "itkPSMRegionDomain.h" 25 int itkPSMRegionNeighborhoodTest(
int,
char* [])
28 std::string errstring =
"";
32 typedef itk::Point<double, 3> PointType;
36 itk::PSMRegionNeighborhood<3>::PointVectorType vec;
37 const unsigned int SZ = 100;
43 ptu[0] =
static_cast<double>(SZ);
44 ptu[1] =
static_cast<double>(SZ);
45 ptu[2] =
static_cast<double>(SZ);
51 for (
unsigned int i = 0; i < SZ; i++)
53 pt[0] =
static_cast<double>(i) + 0.1f;
54 pt[1] =
static_cast<double>(i) + 0.2f;
55 pt[2] =
static_cast<double>(i) + 0.3f;
65 errstring += std::string(
"AddPosition 3D method failed. ");
72 P->SetPosition(pt, SZ/2);
78 errstring += std::string(
"SetPosition 3D method failed. ");
86 errstring += std::string(
"FindNeighborhoodPoints 3D size failed . ");
88 else if ((vec[0].Index != 1 && vec[1].Index != 1) ||
89 (vec[0].Index != SZ/2 && vec[1].Index != SZ/2))
92 errstring += std::string(
"FindNeightborhoodPoints 3D index failed. ");
97 P->RemovePosition(SZ/2);
102 errstring += std::string(
"RemovePoints 3D method failed. ");
106 catch(itk::ExceptionObject &e)
108 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
109 + std::string(
"\n at location:") + std::string(e.GetLocation())
110 + std::string(
"\n in file:") + std::string(e.GetFile());
115 errstring =
"Unknown exception thrown";
122 typedef itk::Point<double, 2> PointType;
126 itk::PSMRegionNeighborhood<2>::PointVectorType vec;
127 const unsigned int SZ = 100;
132 ptu[0] =
static_cast<double>(SZ);
133 ptu[1] =
static_cast<double>(SZ);
139 for (
unsigned int i = 0; i < SZ; i++)
141 pt[0] =
static_cast<double>(i) + 0.1f;
142 pt[1] =
static_cast<double>(i) + 0.2f;
148 if (vec.size() != SZ)
151 errstring += std::string(
"AddPosition 2D method failed. ");
157 P->SetPosition(pt, SZ/2);
160 if (vec.size() != SZ)
163 errstring += std::string(
"SetPosition 2D method failed. ");
171 errstring += std::string(
"FindNeighborhoodPoints 2D size failed . ");
173 else if ((vec[0].Index != 1 && vec[1].Index != 1) ||
174 (vec[0].Index != SZ/2 && vec[1].Index != SZ/2))
177 errstring += std::string(
"FindNeightborhoodPoints 2D index failed. ");
182 P->RemovePosition(SZ/2);
187 errstring += std::string(
"RemovePoints 2D method failed. ");
191 catch(itk::ExceptionObject &e)
193 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
194 + std::string(
"\n at location:") + std::string(e.GetLocation())
195 + std::string(
"\n in file:") + std::string(e.GetFile());
200 errstring =
"Unknown exception thrown";
207 std::cout <<
"All tests passed" << std::endl;
212 std::cout <<
"Test failed with the following error:" << std::endl;
213 std::cout << errstring << std::endl;
void AddPosition(const PointType &p, unsigned int idx, int threadId=0)
virtual void SetDomain(DomainType *p)
virtual PointVectorType FindNeighborhoodPoints(const PointType &, double) const
void SetRegion(const PointType &l, const PointType &u)