20 #include "itkPSMGradientDescentOptimizer.h" 21 #include "itkPSMShapeEntropyFunction.h" 22 #include "itkPSMRegionNeighborhood.h" 23 #include "itkPSMRegionDomain.h" 26 int itkPSMGradientDescentOptimizerTest(
int,
char* [] )
29 std::string errstring =
"";
33 itk::PSMGradientDescentOptimizer<float, 3>::Pointer P
36 typedef itk::Point<double, 3> PointType;
38 itk::PSMShapeEntropyFunction<3>::Pointer cf
40 itk::PSMShapeMatrixAttribute<double, 3>::Pointer sm =
56 const unsigned int SZ = 100;
58 ptl[0] = 0.0f; ptl[1] = 0.0f; ptl[2] = 0.0f;
59 ptu[0] =
static_cast<double>(SZ); ptu[1] =
static_cast<double>(SZ); ptu[2] =
static_cast<double>(SZ);
71 for (
unsigned int i = 0; i < SZ; i++)
73 pt[0] =
static_cast<double>(i) + 0.1f;
74 pt[1] =
static_cast<double>(i) + 0.2f;
75 pt[2] =
static_cast<double>(i) + 0.3f;
81 P->SetCostFunction(cf);
82 P->SetParticleSystem(ps);
88 catch(itk::ExceptionObject &e)
90 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
91 + std::string(
"\n at location:") + std::string(e.GetLocation())
92 + std::string(
"\n in file:") + std::string(e.GetFile());
97 errstring =
"Unknown exception thrown";
103 std::cout <<
"All tests passed" << std::endl;
108 std::cout <<
"Test failed with the following error:" << std::endl;
109 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.
void SetRegion(const PointType &l, const PointType &u)
void SetDomainsPerShape(int i)