/usr/include/miaviewit-1.0/viewit/voxelmover.hh is in libmiaviewit-dev 1.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | /* -*- mia-c++ -*-
*
* This file is part of viewitgui - a library and program for the
* visualization of 3D data sets.
*
* Copyright (c) Leipzig, Madrid 1999-2013 Mirco Hellmann, Gert Wollny
*
* viewitgui is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* viewitgui is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with viewitgui; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MOVER_HH
#define MOVER_HH
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <ctime>
#include <cstdlib>
#include <mia/3d/vector.hh>
namespace mia {
template <class Deformation, class voxel>
class TVoxelMover {
const Deformation& _M_deform;
protected:
typedef typename Deformation::const_iterator::value_type deform_type;
public:
/** Constructor initialized the mover with
\param __deform a deformation (interpreted as velocity field)
*/
TVoxelMover(const Deformation& __deform):
_M_deform(__deform)
{}
/// this destructor is virtual
virtual ~TVoxelMover(){}
/**
The forward movement function moves a voxel in the direction of the deformation
\param __v the voxel to be moved
\param __time_step a time step parameter
\retval __v the voxel with the new position
\returns the square of the Euclidian norm of the move applied
*/
virtual float forward(voxel *__v, float __time_step)const {
auto shift = _M_deform(*__v) * __time_step;
*__v += shift;
return shift.norm2();
}
/**
The backward movement function moves a voxel against the direction of the deformation
\param __v the voxel to be moved
\param __time_step a time step parameter
\retval __v the voxel with the new position
\returns the square of the Euclidian norm of the move applied
*/
virtual float backward(voxel *__v, float __time_step)const {
auto shift = _M_deform(*__v) * __time_step;
*__v -= shift;
return shift.norm2();
}
float operator()(const voxel& v)const {
return _M_deform(v).norm2();
}
protected:
/**
Get the deformation at a certain location
\param __v the location;
\returns deformation vector
*/
deform_type get_deform(const deform_type& __v)const {
return _M_deform(__v);
}
};
/** This is a class to move pixels around according to a deformation added
with brownian random movement.
*/
template <class Deformation, class voxel>
class TBrownVoxelMover: public TVoxelMover<Deformation,voxel> {
float _M_brown_weight;
protected:
typedef typename Deformation::const_iterator::value_type deform_type;
public:
/** Constructor initialized the mover with
\param __deform a deformation (interpreted as velocity field)
\param __brown_weight a weighting of brownian movement
*/
TBrownVoxelMover(const Deformation& __deform, float __brown_weight):
TVoxelMover<Deformation,voxel>(__deform),
_M_brown_weight(__brown_weight)
{
srand48(time(NULL));
}
/**
The forward movement function moves a voxel in the direction of the deformation
\param __v the location to be moved
\param __time_step a time step parameter
\retval __v the new location
\returns the square of the Euclidian norm of the move applied
*/
virtual float forward(voxel *__v, float __time_step)const {
deform_type brown(drand48() - 0.5, drand48() - 0.5, drand48() - 0.5);
deform_type shift = __time_step * (this->get_deform(*__v) + _M_brown_weight * brown );
*__v += shift;
return shift.norm2();
}
/**
The backward movement function moves a voxel against the direction of the deformation
\param __v the location to be moved
\param __time_step a time step parameter
\retval __v the new location
\returns the square of the Euclidian norm of the move applied
*/
virtual float backward(voxel *__v, float __time_step)const {
deform_type brown(drand48() - 0.5, drand48() - 0.5, drand48() - 0.5);
deform_type shift = __time_step * (this->get_deform(*__v) + _M_brown_weight * brown );
*__v -= shift;
return shift.norm2();
}
};
template <class vector3d>
class T3DVectorSource {
C3DBounds _M_size;
public:
T3DVectorSource(const C3DBounds& __size):
_M_size(__size)
{
_M_size.x--;
_M_size.y--;
_M_size.z--;
srand48(time(NULL));
}
vector3d operator() () const
{
return vector3d(_M_size.x * drand48(),
_M_size.y * drand48(),
_M_size.z * drand48());
}
bool inside(const vector3d& __v) {
C3DBounds b(__v);
return b.x < _M_size.x && b.y < _M_size.y && b.z < _M_size.z;
}
};
} // end namespace
#endif
/* CVS LOG
$Log$
Revision 1.4 2005/06/29 13:22:23 wollny
switch to version 0.7
Revision 1.1.1.1 2005/03/17 13:44:22 gerddie
initial import
Revision 1.3 2005/01/05 14:42:35 jaenicke
Corrected some doxygen warnings.
Revision 1.2 2004/08/25 09:08:32 wollny
added an emacs style comment to all source files
Revision 1.1 2004/07/09 14:54:19 tittge
making pthreads default
Revision 1.4 2004/06/03 09:57:32 wollny
Changed (hopefully) all instancable class names to Cxxxxx
Revision 1.3 2004/05/18 08:47:19 tittge
adjust documentation
Revision 1.2 2004/05/04 15:56:16 wollny
make viewitgui compile and link
Revision 1.1 2004/05/04 15:14:55 wollny
make libviewit compile
Revision 1.4 2004/04/05 15:24:33 gerddie
change filter allocation
Revision 1.3 2002/07/15 07:15:16 gerddie
make it compile with g++ 3.1
Revision 1.2 2002/06/20 09:59:48 gerddie
added cvs-log entry
*/
|