aimsalgo  5.1.2
Neuroimaging image processing
geomMoment.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_MOMENT_GEOMMOMENT_H
36 #define AIMS_MOMENT_GEOMMOMENT_H
37 
38 #include <aims/vector/vector.h>
39 
40 #include <aims/moment/moment.h>
41 #include <aims/moment/momBase.h>
42 #include <aims/moment/momStgy.h>
43 #include <aims/moment/momFactory.h>
44 
45 
46 template< class T >
47 class GeometricMoment : public MomentBase, public Moment< T >
48 {
49  public:
50 
52 
53  void setMomentType( MomentType );
54 
55  void update( double, double, double, int dir=(int)Moment< T >::mAdd );
56 
57  // ignore this warning (the API is broken, see comment in Moment<T>)
58  #pragma GCC diagnostic push
59  #pragma GCC diagnostic ignored "-Woverloaded-virtual"
60  virtual void doit( carto::rc_ptr<carto::Volume< T > > &, T,
61  int d=(int)Moment< T >::mAdd );
62  virtual void doit( const aims::BucketMap<Void> &, int d=(int)Moment< T >::mAdd );
63  #pragma GCC diagnostic pop
64 
65 
66  private:
67 
68  MomentStrategy< T > *stgy;
69 };
70 
71 
72 template< class T > inline
74 {
75  stgy = 0;
76  setMomentType( type );
77 }
78 
79 
80 template< class T > inline
82 {
83  delete stgy;
84 
85  MomentFactory< T > factory;
86  stgy = factory.create( type );
87 }
88 
89 
90 template< class T > inline
91 void GeometricMoment< T >::update( double x, double y, double z, int dir )
92 {
93  stgy->update( (Moment< T > *)this, x, y, z, dir );
95 }
96 
97 
98 template< class T > inline
100  T label, int dir )
101 {
102  int i;
103 
104  this->_cx = (double)d->getVoxelSize()[0];
105  this->_cy = (double)d->getVoxelSize()[1];
106  this->_cz = (double)d->getVoxelSize()[2];
107  this->_ct = this->_cx * this->_cy * this->_cz;
108 
109  this->_sum = 0.0;
110  this->_m0 = 0.0;
111 
112  for ( i=0; i<3; i++ ) this->_m1[ i ] = 0.0;
113  for ( i=0; i<6; i++ ) this->_m2[ i ] = 0.0;
114  for ( i=0; i<10; i++ ) this->_m3[ i ] = 0.0;
115 
116  stgy->doit( (Moment< T > *)this, d, label, dir );
118 }
119 
120 
121 template <typename T> inline
123  int dir )
124 {
125  int i;
126 
127  this->_cx = (double)b.sizeX();
128  this->_cy = (double)b.sizeY();
129  this->_cz = (double)b.sizeZ();
130  this->_ct = this->_cx * this->_cy * this->_cz;
131 
132  this->_sum = 0.0;
133  this->_m0 = 0.0;
134 
135  for ( i=0; i<3; i++ ) this->_m1[ i ] = 0.0;
136  for ( i=0; i<6; i++ ) this->_m2[ i ] = 0.0;
137  for ( i=0; i<10; i++ ) this->_m3[ i ] = 0.0;
138 
139  stgy->doit( (Moment< T > *)this, b, dir );
141 }
142 
143 #endif
virtual void doit(carto::rc_ptr< carto::Volume< T > > &, T, int d=(int) Moment< T >::mAdd)
Definition: geomMoment.h:99
void setMomentType(MomentType)
Definition: geomMoment.h:81
GeometricMoment(MomentType mType=Incremental)
Definition: geomMoment.h:73
void update(double, double, double, int dir=(int) Moment< T >::mAdd)
Definition: geomMoment.h:91
@ Incremental
Definition: momBase.h:46
MomentStrategy< T > * create(MomentBase::MomentType)
Definition: momFactory.h:56
Definition: moment.h:56
virtual void orientation()
Definition: moment.h:246
float sizeZ() const
float sizeY() const
float sizeX() const