My Project
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 {
40 public:
43  T3DDatafield<T>(org),
44  CAttributedData(org)
45  {
46  }
47 
48 
49  T3DVectorfield(const C3DBounds& size):
50  T3DDatafield<T>(size) {};
51 
52  T3DVectorfield(const CAttributedData& data, const C3DBounds& size) __attribute__((deprecated)):
53  T3DDatafield<T>(size),
54  CAttributedData(data)
55  {
56  }
57 
58  T3DVectorfield(const C3DBounds& size, const CAttributedData& data):
59  T3DDatafield<T>(size),
60  CAttributedData(data)
61  {
62  }
63 
65  {
66  const PAttribute attr = get_attribute("voxel");
67 
68  if (!attr) {
69  cvinfo() << "T3DVectorfield<T>::get_voxel_size(): "
70  "voxel size not defined, default to <1,1,1>\n";
71  return C3DFVector(1, 1, 1);
72  }
73 
74  const CVoxelAttribute *vs = dynamic_cast<const CVoxelAttribute *>(attr.get());
75 
76  if (!vs) {
77  cvinfo() << "T3DImage<T>::get_voxel_size(): voxel size wrong type, "
78  "default to <1,1,1>\n";
79  return C3DFVector(1, 1, 1);
80  }
81 
82  return *vs;
83  }
84 
85  void set_voxel_size(const C3DFVector& voxel)
86  {
87  set_attribute("voxel", PAttribute(new CVoxelAttribute(voxel)));
88  }
89 
91  T get_interpol_val_at(const C3DFVector& p) const;
92 
93 
94 
95 };
96 
97 extern template class EXPORT_3D T3DVectorfield<C3DFVector>;
103 {
104 public:
105  static const char *data_descr;
106 
108 
119  void update_as_inverse_of(const C3DFVectorfield& other, float tol, int maxiter);
120 
126  void update_by_velocity(const C3DFVectorfield& velocity_field, float time_step);
127 
128 };
129 
130 
131 extern template class EXPORT_3D T3DVectorfield<C3DDVector>;
132 
133 
134 typedef std::shared_ptr<C3DFVectorfield > P3DFVectorfield;
135 
141 
151 
152 
153 struct C3DLinearVectorfieldInterpolatorImpl;
155 {
156 public:
159 
160  C3DFVector operator () (const C3DFVector& x) const;
161 private:
162  const C3DFVectorfield& m_field;
163  const size_t m_save_index_range;
164  const size_t m_field_size_m1;
165  C3DLinearVectorfieldInterpolatorImpl *impl;
166 };
167 
169 
170 #endif
T3DVector< float > C3DFVector
A float 3D Vector.
Definition: 3d/vector.hh:409
std::shared_ptr< C3DFVectorfield > P3DFVectorfield
std::shared_ptr< CAttribute > PAttribute
define the shared pointer wrapped attribute pointer
Definition: attributes.hh:102
a 3D field of floating point single accuracy 3D vectors
static const char * data_descr
void update_by_velocity(const C3DFVectorfield &velocity_field, float time_step)
void update_as_inverse_of(const C3DFVectorfield &other, float tol, int maxiter)
evaluate this vector field as the inverse of another
C3DLinearVectorfieldInterpolator(const C3DFVectorfield &field)
a 3D vector value used in attributes
A collection of attributes.
Definition: attributes.hh:260
void set_attribute(const std::string &key, PAttribute attr)
const PAttribute get_attribute(const std::string &key) const
A templated class of a 3D data field.
Definition: 3d/datafield.hh:83
a 3D vector field
T3DVectorfield(const CAttributedData &data, const C3DBounds &size) __attribute__((deprecated))
T3DVectorfield(const C3DBounds &size)
T3DVectorfield(const C3DBounds &size, const CAttributedData &data)
T3DVectorfield(const T3DVectorfield< T > &org)
C3DFVector get_voxel_size() const
T get_interpol_val_at(const C3DFVector &p) const
void set_voxel_size(const C3DFVector &voxel)
#define EXPORT_3D
Definition: defines3d.hh:45
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
T3DVectorfield< C3DDVector > C3DDVectorfield
a 3D field of floating point double accuracy 3D vectors
EXPORT_3D C3DFVectorfield & operator+=(C3DFVectorfield &lhs, const C3DFVectorfield &rhs)
C3DValueAttribute< float > CVoxelAttribute
a 3D floating point vector used for the voxel size attribute
vstream & cvinfo()
informal output that may be of interest to understand problems with a program and are of higher prior...
Definition: msgstream.hh:262