3d/vectorfield.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef mia_3d_3dvectorfield_hh
22 #define mia_3d_3dvectorfield_hh
23 
25 #include <mia/3d/datafield.hh>
26 
28 
29 
37 template <typename T>
39 public:
42  T3DDatafield<T>(org),
43  CAttributedData(org)
44  {
45  }
46 
47 
48  T3DVectorfield(const C3DBounds& size):
49  T3DDatafield<T>(size) {};
50 
51  T3DVectorfield(const CAttributedData& data, const C3DBounds& size) __attribute__((deprecated)):
52  T3DDatafield<T>(size),
53  CAttributedData(data)
54  {
55  }
56 
57  T3DVectorfield(const C3DBounds& size, const CAttributedData& data):
58  T3DDatafield<T>(size),
59  CAttributedData(data)
60  {
61  }
62 
64  const PAttribute attr = get_attribute("voxel");
65  if (!attr) {
66  cvinfo() << "T3DVectorfield<T>::get_voxel_size(): "
67  "voxel size not defined, default to <1,1,1>\n";
68  return C3DFVector(1,1,1);
69  }
70 
71  const CVoxelAttribute * vs = dynamic_cast<const CVoxelAttribute *>(attr.get());
72  if (!vs){
73  cvinfo() << "T3DImage<T>::get_voxel_size(): voxel size wrong type, "
74  "default to <1,1,1>\n";
75  return C3DFVector(1,1,1);
76  }
77  return *vs;
78  }
79 
80  void set_voxel_size(const C3DFVector& voxel){
81  set_attribute("voxel", PAttribute(new CVoxelAttribute(voxel)));
82  }
83 
85  T get_interpol_val_at(const C3DFVector& p) const;
86 
87 
88 
89 };
90 
91 extern template class EXPORT_3D T3DVectorfield<C3DFVector>;
96 class EXPORT_3D C3DFVectorfield : public T3DVectorfield<C3DFVector> {
97 public:
98  static const char *data_descr;
99 
101 
112  void update_as_inverse_of(const C3DFVectorfield& other, float tol, int maxiter);
113 
119  void update_by_velocity(const C3DFVectorfield& velocity_field, float time_step);
120 
121 };
122 
123 
124 extern template class EXPORT_3D T3DVectorfield<C3DDVector>;
125 
126 
127 typedef std::shared_ptr<C3DFVectorfield > P3DFVectorfield;
128 
133 typedef T3DVectorfield<C3DDVector> C3DDVectorfield;
134 
144 
145 
146 struct C3DLinearVectorfieldInterpolatorImpl;
148 public:
151 
152  C3DFVector operator () (const C3DFVector& x) const;
153 private:
154  const C3DFVectorfield& m_field;
155  const size_t m_save_index_range;
156  const size_t m_field_size_m1;
157  C3DLinearVectorfieldInterpolatorImpl *impl;
158 };
159 
161 
162 #endif
vstream & cvinfo()
informal output that may be of interest to understand problems with a program and are of higher prior...
Definition: msgstream.hh:252
T3DVectorfield(const C3DBounds &size)
C3DFVector get_voxel_size() const
std::shared_ptr< C3DFVectorfield > P3DFVectorfield
a 3D field of floating point single accuracy 3D vectors
A templated class of a 3D data field.
Definition: 3d/datafield.hh:82
T3DVector< float > C3DFVector
A float 3D Vector.
Definition: 3d/vector.hh:346
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
A collection of attributes.
Definition: attributes.hh:255
a 3D vector field
#define EXPORT_3D
Definition: defines3d.hh:44
std::shared_ptr< CAttribute > PAttribute
define the shared pointer wrapped attribute pointer
Definition: attributes.hh:100
void set_attribute(const std::string &key, PAttribute attr)
T3DVectorfield(const C3DBounds &size, const CAttributedData &data)
value_type get_interpol_val_at(const T3DVector< float > &p) const __attribute__((deprecated))
C3DValueAttribute< float > CVoxelAttribute
a 3D floating point vector used for the voxel size attribute
T3DVectorfield< C3DDVector > C3DDVectorfield
a 3D field of floating point double accuracy 3D vectors
const_reference operator()(size_t x, size_t y, size_t z) const
void set_voxel_size(const C3DFVector &voxel)
T3DVectorfield(const T3DVectorfield< T > &org)
EXPORT_3D C3DFVectorfield & operator+=(C3DFVectorfield &lhs, const C3DFVectorfield &rhs)
static const char * data_descr
T3DVectorfield(const CAttributedData &data, const C3DBounds &size) __attribute__((deprecated))
const PAttribute get_attribute(const std::string &key) const
a 3D vector value used in attributes
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36