11 #ifndef __itkSHCoefficientsRotation_h 12 #define __itkSHCoefficientsRotation_h 14 #include "itkObject.h" 15 #include "itkObjectFactory.h" 34 template <
class T =
double >
63 if (m_MaxRank/2>m_SHMatrixInverse->size())
67 m_SHMatrixInverse = utl_shared_ptr<std::vector<MatrixType> >(
new std::vector<MatrixType>(m_MaxRank/2));
68 for (
int l = 2; l <= m_MaxRank; l += 2 )
92 utlSAException(m_SHMatrixInverse->size()==0).msg(
"need to use Initialize() first");
94 utlSAException(rankReal>m_MaxRank)(rankReal)(m_MaxRank).msg(
"rank is larger than m_MaxRank.");
95 MatrixType gradt3Rotated = (*m_Grad) * rotationMatrix;
97 VectorType shRotated(shInput);
100 for (
int l = 2; l <= rankReal; l += 2 )
103 tmp = shMatrixRotated->GetNColumns(colstart, 2*l+1);
104 VectorType sfValueRotatedL = tmp* shInput.GetSubVector(
utl::GetRange(colstart, colstart+2*l+1));
105 VectorType shRotatedL = (*m_SHMatrixInverse)[l/2-1]*sfValueRotatedL;
106 shRotated.SetSubVector(
utl::GetRange(colstart, colstart+shRotatedL.
Size()), shRotatedL);
114 m_Instance = Self::New();
121 m_Grad(new MatrixType()),
122 m_SHMatrixInverse(new
std::vector<MatrixType>())
131 Superclass::PrintSelf(os, indent);
132 PrintVar2(
true, m_MaxRank, m_TessOrder, os <<indent);
134 for (
int i = 0; i < m_SHMatrixInverse->size(); ++i )
137 utl::PrintUtlMatrix((*m_SHMatrixInverse)[i],
"(*m_SHMatrixInverse)[i]",
" ", os << indent);
143 typename LightObject::Pointer loPtr = Superclass::InternalClone();
144 typename Self::Pointer rval =
dynamic_cast<Self *
>(loPtr.GetPointer());
147 itkExceptionMacro(<<
"downcast to type " << this->GetNameOfClass()<<
" failed.");
149 rval->m_MaxRank = m_MaxRank;
150 rval->m_TessOrder = m_TessOrder;
151 rval->m_Grad = m_Grad;
152 rval->m_SHMatrixInverse = m_SHMatrixInverse;
168 void operator=(
const Self&);
179 SHRotationFilterType::Pointer shRotate = SHRotationFilterType::GetInstance();
180 shRotate->SetTessOrder(tess);
181 shRotate->SetMaxRank(rank);
182 shRotate->Initialize();
NDArray is a N-Dimensional array class (row-major, c version)
static MatrixPointer GetGrad(const int tessorder, const int NoSymmetricDuple=DIRECTION_NODUPLICATE, const int mode=CARTESIAN_TO_SPHERICAL, const int flipx=DIRECTION_NOFLIP, const int flipy=DIRECTION_NOFLIP, const int flipz=DIRECTION_NOFLIP, const bool need_normalize=true)
helper functions specifically used in dmritool
SHCoefficientsRotation Self
void PrintUtlMatrix(const NDArray< T, 2 > &mat, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout)
SmartPointer< Self > Pointer
void InitializeSHRotation(const int rank, const int tess)
int DimToRankSH(const int dimm)
utl::NDArray< double, 1 > VectorType
utl::NDArray< double, 2 > MatrixType
std::shared_ptr< NDArray< T, 2 > > ComputeSHMatrix(const unsigned int rank, const NDArray< T, 2 > &grad, const int mode)
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
static Pointer m_Instance
SmartPointer< const Self > ConstPointer
virtual ~SHCoefficientsRotation()
LightObject::Pointer InternalClone() const ITK_OVERRIDE
#define PrintVar(cond, os,...)
NDArray< T, 2 > PInverseMatrix(const NDArray< T, 2 > &mat, const double eps=1e-10)
#define utlSAException(expr)
static Pointer GetInstance()
VectorType GetRotatedSHCoefficients(const VectorType &shInput, const MatrixType &rotationMatrix) const
GetRotatedSHCoefficient rotate SH coefficient vector by a given rotation matrix.
rotate SH coefficient vector by a given rotation matrix.
int RankToDimSH(const int shRank)
#define itkSetGetMacro(name, type)
static void Initialize(const int tessorder)
utl_shared_ptr< MatrixType > MatrixPointer
utl_shared_ptr< std::vector< MatrixType > > m_SHMatrixInverse
std::vector< int > GetRange(const int start, const int end, const int space=1)
#define PrintVar2(cond, var1, var2, os)