aimsalgo  5.0.5
Neuroimaging image processing
meshToVoxelsResampler.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef AIMS_RESAMPLING_MESHTOVOXELSRESAMPLER_H
36 #define AIMS_RESAMPLING_MESHTOVOXELSRESAMPLER_H
37 
38 #include <aims/data/data.h>
39 #include <aims/vector/vector.h>
40 #include <aims/mesh/surface.h>
41 #include <cartobase/type/types.h>
42 #include <aims/bucket/bucket.h>
43 
44 namespace aims
45 {
46 
50 template<typename O>
52 {
53 public:
54 
56  virtual ~MeshToVoxelsResampler() {};
57 
58 public:
64  O doit(const AimsSurfaceTriangle &surface, float spacing=1.,
65  unsigned int connexity=26);
66 
67 private:
68  O init_data(const AimsVector<float,3> &offset, float spacing,
69  unsigned int dimx, unsigned int dimy, unsigned int dimz) const;
70  void set(O &output, uint x2, uint y2, uint z2, uint ind) const;
71  void fill_header(PythonHeader &hdr, O &output,
72  const AimsVector<float,3> & offset, float spacing) const;
73 };
74 
75 
76 template<> inline
78 init_data(const AimsVector<float,3> &offset, float spacing,
79  unsigned int dimx, unsigned int dimy, unsigned int dimz) const
80 {
81  AimsData<unsigned int> ima(dimx, dimy, dimz);
82  ima = 0; //value of background
83  PythonHeader *hdr = dynamic_cast<aims::PythonHeader *>(ima.header());
85  ima, offset, spacing);
86  return ima;
87 }
88 
89 template<> inline void MeshToVoxelsResampler<AimsData<unsigned int> >::
90 set(AimsData<unsigned int> &output, uint x2, uint y2, uint z2, uint ind) const
91 {
92  output(x2, y2, z2) = ind;
93 }
94 
95 template<> inline
97 init_data(const AimsVector<float,3> &offset, float spacing,
98  unsigned int, unsigned int, unsigned int) const
99 {
100  aims::BucketMap<Void> bucketmap;
102  bucketmap.header(), bucketmap, offset, spacing);
103 
104  return bucketmap;
105 }
106 
107 template<> inline
109 set(aims::BucketMap<Void> &output, uint x2, uint y2, uint z2, uint) const
110 {
111  output.insert(Point3d(x2, y2, z2), Void());
112 }
113 
114 };
115 
116 #endif
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle
O doit(const AimsSurfaceTriangle &surface, float spacing=1., unsigned int connexity=26)
surface : input mesh spacing : voxel size (according to mesh metric) connexity : 6 or 26 ...
const aims::Header * header() const
void insert(const Point3d &pos, const T &item)
unsigned int uint
const aims::PythonHeader & header() const
3D rasterization (voxelization) of a mesh O : AimsData<unsigned int> or BucketMap<Void> ...