aimsalgo  5.0.5
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( AimsData< T >&, T, int d=(int)Moment< T >::mAdd );
61  virtual void doit( const aims::BucketMap<Void> &, int d=(int)Moment< T >::mAdd );
62  #pragma GCC diagnostic pop
63 
64 
65  private:
66 
67  MomentStrategy< T > *stgy;
68 };
69 
70 
71 template< class T > inline
73 {
74  stgy = 0;
75  setMomentType( type );
76 }
77 
78 
79 template< class T > inline
81 {
82  delete stgy;
83 
84  MomentFactory< T > factory;
85  stgy = factory.create( type );
86 }
87 
88 
89 template< class T > inline
90 void GeometricMoment< T >::update( double x, double y, double z, int dir )
91 {
92  stgy->update( (Moment< T > *)this, x, y, z, dir );
94 }
95 
96 
97 template< class T > inline
98 void GeometricMoment< T >::doit( AimsData< T >& d, T label, int dir )
99 {
100  int i;
101 
102  this->_cx = (double)d.sizeX();
103  this->_cy = (double)d.sizeY();
104  this->_cz = (double)d.sizeZ();
105  this->_ct = this->_cx * this->_cy * this->_cz;
106 
107  this->_sum = 0.0;
108  this->_m0 = 0.0;
109 
110  for ( i=0; i<3; i++ ) this->_m1[ i ] = 0.0;
111  for ( i=0; i<6; i++ ) this->_m2[ i ] = 0.0;
112  for ( i=0; i<10; i++ ) this->_m3[ i ] = 0.0;
113 
114  stgy->doit( (Moment< T > *)this, d, label, dir );
116 }
117 
118 
119 template <typename T> inline
121  int dir )
122 {
123  int i;
124 
125  this->_cx = (double)b.sizeX();
126  this->_cy = (double)b.sizeY();
127  this->_cz = (double)b.sizeZ();
128  this->_ct = this->_cx * this->_cy * this->_cz;
129 
130  this->_sum = 0.0;
131  this->_m0 = 0.0;
132 
133  for ( i=0; i<3; i++ ) this->_m1[ i ] = 0.0;
134  for ( i=0; i<6; i++ ) this->_m2[ i ] = 0.0;
135  for ( i=0; i<10; i++ ) this->_m3[ i ] = 0.0;
136 
137  stgy->doit( (Moment< T > *)this, b, dir );
139 }
140 
141 #endif
MomentStrategy< T > * create(MomentBase::MomentType)
Definition: momFactory.h:56
float sizeY() const
GeometricMoment(MomentType mType=Incremental)
Definition: geomMoment.h:72
double _ct
Definition: moment.h:145
double _m3[10]
Definition: moment.h:154
double _m2[6]
Definition: moment.h:153
float sizeZ() const
float sizeZ() const
double _cx
Definition: moment.h:142
void update(double, double, double, int dir=(int) Moment< T >::mAdd)
Definition: geomMoment.h:90
float sizeX() const
virtual void doit(AimsData< T > &, T, int d=(int) Moment< T >::mAdd)
Definition: geomMoment.h:98
Definition: moment.h:47
double _m1[3]
Definition: moment.h:152
float sizeX() const
double _sum
Definition: moment.h:149
double _cy
Definition: moment.h:143
double _m0
Definition: moment.h:150
virtual void orientation()
Definition: moment.h:244
void setMomentType(MomentType)
Definition: geomMoment.h:80
double _cz
Definition: moment.h:144
float sizeY() const