19 #include "itkPSMShapeEntropyFunction.h" 20 #include "itkPSMParticleSystem.h" 21 #include "itkPSMRegionNeighborhood.h" 22 #include "itkPSMRegionDomain.h" 26 int itkPSMShapeEntropyFunctionTest(
int,
char* [] )
29 std::string errstring =
"";
33 typedef itk::Point<double, 3> PointType;
49 const unsigned int SZ = 100;
51 ptl[0] = 0.0f; ptl[1] = 0.0f; ptl[2] = 0.0f;
52 ptu[0] =
static_cast<double>(SZ); ptu[1] =
static_cast<double>(SZ); ptu[2] =
static_cast<double>(SZ);
64 for (
unsigned int i = 0; i < SZ; i++)
66 pt[0] =
static_cast<double>(i) + 0.1f;
67 pt[1] =
static_cast<double>(i) + 0.2f;
68 pt[2] =
static_cast<double>(i) + 0.3f;
75 double energy00 = p->Energy(0, 0, ps);
76 double energy10 = p->Energy(1, 0, ps);
77 double energy01 = p->Energy(0, 1, ps);
78 double energy11 = p->Energy(1, 1, ps);
79 if (energy00 != energy01 || energy10 != energy11)
82 errstring += std::string(
"Energy method failed. ");
85 catch(itk::ExceptionObject &e)
87 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
88 + std::string(
"\n at location:") + std::string(e.GetLocation())
89 + std::string(
"\n in file:") + std::string(e.GetFile());
94 errstring =
"Unknown exception thrown";
100 std::cout <<
"All tests passed" << std::endl;
105 std::cout <<
"Test failed with the following error:" << std::endl;
106 std::cout << errstring << std::endl;
Each column describes a shape. A shape may be composed of m_DomainsPerShape domains (default 1)...
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)
void SetShapeMatrix(ShapeMatrixType *s)
A facade class that manages interactions with a particle system.
virtual void BeforeIteration()
void SetRegion(const PointType &l, const PointType &u)
void SetDomainsPerShape(int i)