aimsdata  5.0.5
Neuroimaging data handling
border.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  * Offset border class
36  */
37 #ifndef AIMS_BORDER_BORDER_H
38 #define AIMS_BORDER_BORDER_H
39 
40 #include <algorithm>
41 #include <vector>
43 
44 namespace aims {
45 
46 
50 { public:
53 
61  Border(int dimx,int dimy,int dimz,int width=0);
62 
75  Border(int dimx,int dimy,int dimz,
76  int bx1, int bx2,
77  int by1, int by2,
78  int bz1, int bz2);
79 
87  Border(int dimx,int dimy,int dimz,
88  const std::vector<int> & borders);
90  virtual ~Border();
92 
95  int borderWidth() const;
98  int oFirstPoint() const;
100  int oLastPoint() const;
102  int oLine() const;
104  int oPointBetweenLine() const;
106  int oSlice() const;
108  int oLineBetweenSlice() const;
110  int oVolume() const;
112  int oSliceBetweenVolume() const;
114  const std::vector<int> & borders() const;
116 
117  protected:
120 
122  std::vector<int> _borders;
128  int _oLine;
132  int _oSlice;
136  int _oVolume;
139 
141 
144  void _setBorder(int dimx,int dimy,int dimz,int width);
147 
149  void _setBorder(int dimx,int dimy,int dimz,
152  int bx1, int bx2,
153  int by1, int by2,
154  int bz1, int bz2);
156 
157 
159  void _setBorder(int dimx,int dimy,int dimz,
162  const std::vector<int> & borders);
164 };
165 
166 
167 inline
168 Border::Border(int dimx,int dimy,int dimz,int width):
169  _borders(6, 0)
170 {
171  _setBorder(dimx,dimy,dimz,width);
172 }
173 
174 inline
175 Border::Border(int dimx,int dimy,int dimz,
176  int bx1, int bx2,
177  int by1, int by2,
178  int bz1, int bz2):
179  _borders(6, 0)
180 {
181  _setBorder(dimx,dimy,dimz,
182  bx1,bx2,by1,by2,bz1,bz2);
183 }
184 
185 inline
186 Border::Border(int dimx,int dimy,int dimz,
187  const std::vector<int> & borders):
188  _borders(6, 0)
189 {
190  _setBorder(dimx,dimy,dimz,borders);
191 }
192 
193 inline
195 {
196 }
197 
198 
199 inline
201 {
202  int s = _borders.size();
203  if (s > 0) {
204  int width;
205  width = _borders[0];
206  for (int i = 1; i < s; ++i)
207  width = std::min(width, _borders[i]);
208  return width;
209  }
210  return 0;
211 }
212 
213 
214 inline
216 {
217  return _oFirstPoint;
218 }
219 
220 
221 inline
223 {
224  return _oLastPoint;
225 }
226 
227 
228 inline
229 int Border::oLine() const
230 {
231  return _oLine;
232 }
233 
234 
235 inline
237 {
238  return _oPointBetweenLine;
239 }
240 
241 
242 inline
243 int Border::oSlice() const
244 {
245  return _oSlice;
246 }
247 
248 
249 inline
251 {
252  return _oLineBetweenSlice;
253 }
254 
255 
256 inline
257 int Border::oVolume() const
258 {
259  return _oVolume;
260 }
261 
262 
263 inline
265 {
266  return _oSliceBetweenVolume;
267 }
268 
269 
270 }
271 
272 
273 #endif
int oLineBetweenSlice() const
Number of lines between 2 consecutive slices.
Definition: border.h:250
int _oLastPoint
Offset up to last point.
Definition: border.h:126
int _oSlice
Length of a slice.
Definition: border.h:132
int oPointBetweenLine() const
Offset between the end of a line and the start of the consecutive line.
Definition: border.h:236
int oLine() const
Offset between 2 consecutive lines.
Definition: border.h:229
void _setBorder(int dimx, int dimy, int dimz, int width)
Function that sets up all protected datas.
#define AIMSDATA_API
const std::vector< int > & borders() const
Sizes of the border.
The base class to manage borders on data containers.
Definition: border.h:49
The class for EcatSino data write operation.
Definition: border.h:44
int oSlice() const
Offset between 2 consecutive slices.
Definition: border.h:243
int _oPointBetweenLine
Offset between two consecutive lines.
Definition: border.h:130
int oLastPoint() const
Offset from the start of the allocated memory to the last point.
Definition: border.h:222
int _oSliceBetweenVolume
Offset between two consecutive volumes.
Definition: border.h:138
int oVolume() const
Offset between 2 consecutive volumes.
Definition: border.h:257
int _oFirstPoint
Offset up to first point.
Definition: border.h:124
int _oLineBetweenSlice
Offset between two consecutive slices.
Definition: border.h:134
Border(int dimx, int dimy, int dimz, int width=0)
The constructor precalculates offsets to speed-up access to data during loops.
Definition: border.h:168
int _oVolume
Length of a volume.
Definition: border.h:136
std::vector< int > _borders
Borders.
Definition: border.h:122
virtual ~Border()
Definition: border.h:194
int oSliceBetweenVolume() const
Number of slices between 2 consecutive volumes.
Definition: border.h:264
int _oLine
Length of a line.
Definition: border.h:128
int oFirstPoint() const
Offset from the start of the allocated memory to the first point.
Definition: border.h:215
int borderWidth() const
Usefull offsets for A.I.M.S.
Definition: border.h:200