18 #ifndef __itkPeakContainerHelper_h 19 #define __itkPeakContainerHelper_h 22 #include "itkVariableLengthVector.h" 51 static std::string
GetString(
const PeakType peakType)
54 return std::string(
"XYZV");
55 else if (peakType==
XYZ)
56 return std::string(
"XYZ");
57 else if (peakType==
NXYZV)
58 return std::string(
"NXYZV");
59 else if (peakType==
NXYZ)
60 return std::string(
"NXYZ");
73 else if (str==
"NXYZV")
87 else if (peakType==
XYZ || peakType==
NXYZ)
96 static int GetDimension(
const PeakType peakType,
const int numberOfPeaks)
99 if (peakType==
XYZ || peakType==
XYZV)
100 return d*numberOfPeaks;
101 else if (peakType==
NXYZ || peakType==
NXYZV)
102 return d*numberOfPeaks+1;
114 if (peakType==
XYZ || peakType==
XYZV)
116 else if (peakType==
NXYZ || peakType==
NXYZV)
124 return (dimension-off)/d;
127 template<
class ContainerType >
128 static int GetNumberOfPeaks(
const PeakType peakType,
const int dimension,
const ContainerType& vec)
132 for (
int i = 0; i < nn; i += 1 )
134 std::vector<double> p =
GetPeak(vec, i, peakType);
135 if (p[0]*p[0]+p[1]*p[1]+p[2]*p[2])
141 template<
class VectorType=std::vector<
double>,
class ContainerType >
142 static VectorType
GetPeak(
const ContainerType& vec,
const int index,
const PeakType peakType)
147 if (peakType==
XYZ || peakType==
XYZV)
149 else if (peakType==
NXYZ || peakType==
NXYZV)
154 peak[0]=vec[d*index+off+0];
155 peak[1]=vec[d*index+off+1];
156 peak[2]=vec[d*index+off+2];
160 template<
class VectorType,
class ContainerType >
161 static void SetPeak(
const VectorType& peak, ContainerType& vec,
const int index,
const PeakType peakType)
165 if (peakType==
XYZ || peakType==
XYZV)
167 else if (peakType==
NXYZ || peakType==
NXYZV)
172 vec[d*index+off+0]=peak[0];
173 vec[d*index+off+1]=peak[1];
174 vec[d*index+off+2]=peak[2];
177 template<
class ContainerType >
178 static double GetPeakValue(
const ContainerType& vec,
const int index,
const PeakType peakType)
185 else if (peakType==
NXYZV)
190 return vec[d*index+off+3];
193 template<
class ContainerType >
194 static void SetPeakValue(
const double peakValue, ContainerType& vec,
const int index,
const PeakType peakType)
201 else if (peakType==
NXYZV)
206 vec[d*index+off+3]=peakValue;
static double GetPeakValue(const ContainerType &vec, const int index, const PeakType peakType)
static int GetDimension(const PeakType peakType, const int numberOfPeaks)
#define utlException(cond, expout)
static PeakType GetPeakType(const std::string &str)
static std::string GetString(const PeakType peakType)
#define utlGlobalException(cond, expout)
bool IsInt(const std::string &input, const double epss=1e-10)
static int GetNumberOfPeaks(const PeakType peakType, const int dimension, const ContainerType &vec)
static VectorType GetPeak(const ContainerType &vec, const int index, const PeakType peakType)
static int GetNumberOfPeaks(const PeakType peakType, const int dimension)
#define utlSAException(expr)
static void SetPeakValue(const double peakValue, ContainerType &vec, const int index, const PeakType peakType)
static int GetDimensionPerPeak(const PeakType peakType)
a VariableLengthVector to contain peaks with different storing types
static void SetPeak(const VectorType &peak, ContainerType &vec, const int index, const PeakType peakType)