CiftiLib
A C++ library for CIFTI-2 and CIFTI-1 files
VoxelIJK.h
1 #ifndef __VOXEL_IJK_H__
2 #define __VOXEL_IJK_H__
3 
4 /*LICENSE_START*/
5 /*
6  * Copyright (c) 2014, Washington University School of Medicine
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without modification,
10  * are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include "stdint.h"
32 
33 namespace cifti {
34 
35  struct VoxelIJK
36  {
37  int64_t m_ijk[3];
38  VoxelIJK() { }
39  VoxelIJK(int64_t i, int64_t j, int64_t k) { m_ijk[0] = i; m_ijk[1] = j; m_ijk[2] = k; }
40  template<typename T>
41  VoxelIJK(const T ijk[3]) {
42  m_ijk[0] = ijk[0];
43  m_ijk[1] = ijk[1];
44  m_ijk[2] = ijk[2];
45  }
46  bool operator<(const VoxelIJK& rhs) const//so it kan be the key of a map
47  {
48  if (m_ijk[2] < rhs.m_ijk[2]) return true;//compare such that when sorted, m_ijk[0] moves fastest
49  if (m_ijk[2] > rhs.m_ijk[2]) return false;
50  if (m_ijk[1] < rhs.m_ijk[1]) return true;
51  if (m_ijk[1] > rhs.m_ijk[1]) return false;
52  return (m_ijk[0] < rhs.m_ijk[0]);
53  }
54  bool operator==(const VoxelIJK& rhs) const
55  {
56  return (m_ijk[0] == rhs.m_ijk[0] &&
57  m_ijk[1] == rhs.m_ijk[1] &&
58  m_ijk[2] == rhs.m_ijk[2]);
59  }
60  bool operator!=(const VoxelIJK& rhs) const { return !((*this) == rhs); }
61  };
62 
63 }
64 
65 #endif //__VOXEL_IJK_H__
cifti::VoxelIJK
Definition: VoxelIJK.h:36
cifti
namespace for all CiftiLib functionality
Definition: CiftiBrainModelsMap.h:42