16 #include <itkVector.h>
17 #include <vnl/vnl_vector.h>
18 #include <vnl/vnl_vector_fixed.h>
25 #include <nlohmann/json.hpp>
29 template <
class TCoordRep,
unsigned int NVectorDimension = 3>
30 class Vector :
public itk::Vector<TCoordRep, NVectorDimension>
41 :
itk::
Vector<TCoordRep, NVectorDimension>(r)
48 itk::Vector<TCoordRep, NVectorDimension>::operator=(r);
56 :
itk::
Vector<TCoordRep, NVectorDimension>(r)
66 :
itk::
Vector<TCoordRep, NVectorDimension>(r)
79 :
itk::
Vector<TCoordRep, NVectorDimension>()
81 if (vnlVector.size() != NVectorDimension)
82 mitkThrow() <<
"when constructing mitk::Vector from vnl_vector: sizes didn't match: mitk::Vector "
83 << NVectorDimension <<
"; vnl_vector " << vnlVector.size();
85 for (
unsigned int var = 0; (var < NVectorDimension) && (var < vnlVector.size()); ++var)
87 this->SetElement(var, vnlVector.get(var));
95 :
itk::
Vector<TCoordRep, NVectorDimension>()
97 for (
unsigned int var = 0; var < NVectorDimension; ++var)
99 this->SetElement(var, vnlVectorFixed[var]);
109 template <
typename ArrayType>
112 itk::FixedArray<TCoordRep, NVectorDimension> *thisP =
113 dynamic_cast<itk::FixedArray<TCoordRep, NVectorDimension> *
>(
this);
114 mitk::FillArray<ArrayType, TCoordRep, NVectorDimension>(*thisP, array);
122 template <
typename ArrayType>
125 mitk::ToArray<ArrayType, TCoordRep, NVectorDimension>(array, *
this);
133 operator vnl_vector<TCoordRep>()
const {
return this->GetVnlVector(); }
136 template <
class TCoordRep,
unsigned int NVectorDimension>
139 j = nlohmann::json::array();
141 for (
size_t i = 0; i < NVectorDimension; ++i)
145 template <
class TCoordRep,
unsigned int NVectorDimension>
148 for (
size_t i = 0; i < NVectorDimension; ++i)
149 j.at(i).get_to(v[i]);
172 template <
typename TCoordRep,
unsigned int NPo
intDimension>
173 inline bool Equal(
const itk::Vector<TCoordRep, NPointDimension> &vector1,
174 const itk::Vector<TCoordRep, NPointDimension> &vector2,
176 bool verbose =
false)
179 typename itk::Vector<TCoordRep, NPointDimension>::VectorType diff = vector1 - vector2;
180 for (
unsigned int i = 0; i < NPointDimension; i++)
206 bool verbose =
false)
210 for (
unsigned int i = 0; i < diff.size(); i++)
233 template <
typename TCoordRep,
unsigned int NPo
intDimension>
234 inline bool Equal(
const vnl_vector_fixed<TCoordRep, NPointDimension> &vector1,
235 const vnl_vector_fixed<TCoordRep, NPointDimension> &vector2,
237 bool verbose =
false)
239 vnl_vector_fixed<TCoordRep, NPointDimension> diff = vector1 - vector2;
241 for (
unsigned int i = 0; i < diff.size(); i++)