aimsalgo 6.0.0
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 <cartodata/volume/volume.h>
39#include <aims/vector/vector.h>
40#include <aims/mesh/surface.h>
42#include <aims/bucket/bucket.h>
43
44namespace aims
45{
46
50template<typename O>
52{
53public:
54
57
58public:
64 O doit(const AimsSurfaceTriangle &surface, float spacing=1.,
65 unsigned int connexity=26);
66
67private:
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(carto::PropertySet &hdr, O &output,
72 const AimsVector<float,3> & offset, float spacing) const;
73 void setVoxelSize( O & output, float vx, float vy, float vz,
74 float vt ) const;
75};
76
77
78template<> inline
80MeshToVoxelsResampler<carto::rc_ptr<carto::Volume<unsigned int> > >::
81init_data(const AimsVector<float,3> &offset, float spacing,
82 unsigned int dimx, unsigned int dimy, unsigned int dimz) const
83{
84 carto::VolumeRef<unsigned int> ima(dimx, dimy, dimz);
85 ima = 0; //value of background
86 carto::PropertySet &hdr = ima.header();
87 fill_header( hdr, ima, offset, spacing );
88 return ima;
89}
90
92set( carto::rc_ptr<carto::Volume<unsigned int> > &output, uint x2, uint y2,
93 uint z2, uint ind ) const
94{
95 output->at(x2, y2, z2) = ind;
96}
97
98template<> inline
99aims::BucketMap<Void> MeshToVoxelsResampler<aims::BucketMap<Void> >::
100init_data(const AimsVector<float,3> &offset, float spacing,
101 unsigned int, unsigned int, unsigned int) const
102{
103 aims::BucketMap<Void> bucketmap;
105 bucketmap.header().value<carto::PropertySet>(), bucketmap, offset,
106 spacing);
107
108 return bucketmap;
109}
110
111template<> inline
113set(aims::BucketMap<Void> &output, uint x2, uint y2, uint z2, uint) const
114{
115 output.insert(Point3d(x2, y2, z2), Void());
116}
117
118template<> inline
119void
121setVoxelSize( carto::rc_ptr<carto::Volume<unsigned int> > & output, float vx,
122 float vy, float vz, float vt) const
123{
124 output->setVoxelSize( vx, vy, vz, vt );
125}
126
127template<> inline
128void
130setVoxelSize( aims::BucketMap<Void> & output, float vx,
131 float vy, float vz, float vt) const
132{
133 output.setSizeXYZT( vx, vy, vz, vt );
134}
135
136}
137
138#endif
void insert(const Point3d &pos, const T &item)
const aims::PythonHeader & header() const
void setSizeXYZT(float sizex, float sizey, float sizez, float sizet)
void setVoxelSize(float sizex, float sizey, float sizez, float sizet)
3D rasterization (voxelization) of a mesh O : VolumeRef<unsigned int> or BucketMap<Void>
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 T & value() const
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle
unsigned int uint
AimsVector< int16_t, 3 > Point3d