aimsdata  4.7.0
Neuroimaging data handling
connectivity.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 #ifndef AIMS_CONNECTIVITY_CONNECTCLASS_H
35 #define AIMS_CONNECTIVITY_CONNECTCLASS_H
36 
37 #include <string>
38 
40 #include <aims/vector/vector.h>
41 #include <aims/bucket/bucketMap.h> // for CoordinatesLess operator
42 #include <set>
43 
44 
45 namespace aims
46 {
47 
51  {
52  public:
54  enum Type
55  {
87  };
88 
89  static Type type_from_string(const std::string &);
90  static std::string type_to_string(Type);
91 
92  Connectivity( int oline, int oslice, Type type);
93  virtual ~Connectivity();
94 
96  Type type() const { return _type; }
98  std::string type_string() const { return type_to_string(_type); }
100  int nbNeighbors() const { return _nbNeighbors; }
102  int offset( int n ) const { return _offset[n]; }
104  const Point3d& xyzOffset( int n ) const { return _xyzOffset[n]; }
106  const Point3df& dir( int n ) const { return _dir[n]; }
107  bool isNeighbor( const Point3d & offset )
108  { return _xyzOffsets.find( offset ) != _xyzOffsets.end(); }
109 
110  Connectivity&
111  operator=(const Connectivity& other)
112  {
113  if( &other == this )
114  return *this ;
115 
116  _xSize = other._xSize ;
117  _sliceSize = other._sliceSize ;
118  _type = other._type ;
119 
120  if( _xyzOffset ){
121  delete[] _xyzOffset;
122  _xyzOffset = 0 ;
123  }
124 
125  if(_offset){
126  delete[] _offset;
127  _offset = 0 ;
128  }
129 
130  if( _dir ){
131  delete[] _dir;
132  _dir = 0 ;
133  }
134  setConnectivity() ;
135  return *this ;
136  }
137 
138  protected:
139  int _xSize;
146  int *_offset;
150  std::set<Point3d, BucketMapLess> _xyzOffsets;
153 
155  void setConnectivity();
157  void setConnectivity_4_XY();
159  void setConnectivity_4_XZ();
161  void setConnectivity_4_YZ();
163  void setConnectivity_6_XYZ();
165  void setConnectivity_8_XY();
167  void setConnectivity_8_XZ();
169  void setConnectivity_8_YZ();
171  void setConnectivity_18_XYZ();
173  void setConnectivity_26_XYZ();
210  };
211 
212 }
213 
214 
215 #endif
const Point3d & xyzOffset(int n) const
Get the X/Y/Z offsets of the nth element.
Definition: connectivity.h:104
Connectivity & operator=(const Connectivity &other)
Definition: connectivity.h:111
void setConnectivity_5_XYminus()
5-neighbor connectivity in (xy) inferior in y plane
void setConnectivity_5_XYplus()
5-neighbor connectivity in (xy) superior in y plane
void setConnectivity_9_XZ_Yminus()
9-neighbor connectivity in (xyz) inferior in y space
Connectivity(int oline, int oslice, Type type)
void setConnectivity_5_XminusY()
5-neighbor connectivity in (xy) inferior in x plane
void setConnectivity_5_YZminus()
5-neighbor connectivity in (yz) inferior in z plane
Type
The different kinds of connectivity.
Definition: connectivity.h:54
void setConnectivity_4_XY()
4-neighbor connectivity in (xy) plane
The class for EcatSino data write operation.
Definition: border.h:42
int nbNeighbors() const
Get the number of neighbors for that connectivity.
Definition: connectivity.h:100
Type type() const
Get the type of the connectivity.
Definition: connectivity.h:96
void setConnectivity_5_YminusZ()
5-neighbor connectivity in (yz) inferior in y plane
int * _offset
Linear offset pointer.
Definition: connectivity.h:146
void setConnectivity_9_YZ_Xplus()
9-neighbor connectivity in (xyz) superior in x space
Type _type
Type of connectivity.
Definition: connectivity.h:142
const Point3df & dir(int n) const
Get the normalized directive vector of the nth element.
Definition: connectivity.h:106
void setConnectivity_5_XZplus()
5-neighbor connectivity in (xz) superior in z plane
Topology of a data container.
Definition: connectivity.h:50
Point3d * _xyzOffset
xyz offset pointer
Definition: connectivity.h:148
void setConnectivity_4_XZ()
4-neighbor connectivity in (xz) plane
void setConnectivity_5_YplusZ()
5-neighbor connectivity in (yz) superior in y plane
void setConnectivity_6_XYZ()
6-neighbor connectivity in (xyz) space
std::set< Point3d, BucketMapLess > _xyzOffsets
xyz offsets as a searchcable set
Definition: connectivity.h:150
void setConnectivity_18_XYZ()
18-neighbor connectivity in (xyz) space
void setConnectivity_8_YZ()
8-neighbor connectivity in (yz) plane
void setConnectivity_8_XZ()
8-neighbor connectivity in (xz) plane
void setConnectivity_9_XY_Zplus()
9-neighbor connectivity in (xyz) superior in z space
void setConnectivity_8_XY()
8-neighbor connectivity in (xy) plane
void setConnectivity_26_XYZ()
26-neighbor connectivity in (xyz) space
static std::string type_to_string(Type)
std::string type_string() const
Get the type of the connectivity.
Definition: connectivity.h:98
void setConnectivity_5_XZminus()
5-neighbor connectivity in (xz) inferior in z plane
Point3df * _dir
Normalized vectors for the different directions.
Definition: connectivity.h:152
bool isNeighbor(const Point3d &offset)
Definition: connectivity.h:107
void setConnectivity_5_XplusY()
5-neighbor connectivity in (xy) superior in x plane
void setConnectivity_4_YZ()
4-neighbor connectivity in (yz) plane
void setConnectivity_9_XZ_Yplus()
9-neighbor connectivity in (xyz) superior in y space
int offset(int n) const
Get the linear offset of the nth element.
Definition: connectivity.h:102
void setConnectivity_5_YZplus()
5-neighbor connectivity in (yz) superior in z plane
void setConnectivity_9_XY_Zminus()
9-neighbor connectivity in (xyz) inferior in z space
void setConnectivity_9_YZ_Xminus()
9-neighbor connectivity in (xyz) inferior in x space
virtual ~Connectivity()
static Type type_from_string(const std::string &)
void setConnectivity_5_XminusZ()
5-neighbor connectivity in (xz) inferior in x plane
void setConnectivity()
Set the right connectivity according to the given type.
int _nbNeighbors
Number of neighbors.
Definition: connectivity.h:144
void setConnectivity_5_XplusZ()
5-neighbor connectivity in (xz) superior in x plane