kspaceFirstOrder3D-OMP  1.1
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
 All Classes Files Functions Variables Typedefs Enumerations Friends Pages
IndexMatrix.h
Go to the documentation of this file.
1 /**
2  * @file IndexMatrix.h
3  * @author Jiri Jaros \n
4  * Faculty of Information Technology\n
5  * Brno University of Technology \n
6  * jarosjir@fit.vutbr.cz
7  *
8  * @brief The header file containing the class for 64b integer matrices.
9  *
10  * @version kspaceFirstOrder3D 2.15
11  *
12  * @date 26 July 2011, 15:16 (created) \n
13  * 25 September 2014, 17:28 (revised)
14  *
15  * @section License
16  * This file is part of the C++ extension of the k-Wave Toolbox (http://www.k-wave.org).\n
17  * Copyright (C) 2014 Jiri Jaros and Bradley Treeby
18  *
19  * This file is part of k-Wave. k-Wave is free software: you can redistribute it
20  * and/or modify it under the terms of the GNU Lesser General Public License as
21  * published by the Free Software Foundation, either version 3 of the License,
22  * or (at your option) any later version.
23  *
24  * k-Wave is distributed in the hope that it will be useful, but
25  * WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27  * See the GNU Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public License
30  * along with k-Wave. If not, see <http://www.gnu.org/licenses/>.
31  */
32 
33 #ifndef INDEXMATRIXDATA_H
34 #define INDEXMATRIXDATA_H
35 
36 
38 
39 #include <Utils/DimensionSizes.h>
40 
41 /**
42  * @class TIndexMatrix
43  * @brief The class for 64b unsigned integers (indices). It is used for
44  * sensor_mask_index or sensor_corners_mask to get the address of sampled voxels.
45  *
46  * @details The class for 64b unsigned integers (indices). It is used for
47  * sensor_mask_index or sensor_corners_mask to get the address of sampled voxels.
48  *
49  */
51 {
52  public:
53 
54  /// Constructor allocating memory.
55  TIndexMatrix(const TDimensionSizes& DimensionSizes);
56 
57  /// Destructor.
58  virtual ~TIndexMatrix()
59  {
60  FreeMemory();
61  };
62 
63  /// Read data from the HDF5 file.
64  virtual void ReadDataFromHDF5File(THDF5_File & HDF5_File,
65  const char * MatrixName);
66  /// Write data into the HDF5 file.
67  virtual void WriteDataToHDF5File(THDF5_File & HDF5_File,
68  const char * MatrixName,
69  const size_t CompressionLevel);
70 
71  /**
72  * Operator [].
73  * @param [in] index - 1D index into the matrix
74  * @return Value of the index
75  */
76  size_t& operator [](const size_t& index)
77  {
78  return pMatrixData[index];
79  };
80 
81  /**
82  * Operator [], constant version
83  * @param [in] index - 1D index into the matrix
84  * @return Value of the index
85  */
86  const size_t & operator [](const size_t& index) const
87  {
88  return pMatrixData[index];
89  };
90 
91  /**
92  * @brief Get the top left corner of the index-th cuboid.
93  * @details Get the top left corner of the index-th cuboid. Cuboids are
94  * stored as 6-tuples (two 3D coordinates).
95  * This gives the first three coordinates
96  * @param [in] index - Id of the corner
97  * @return the top left corner
98  */
99  TDimensionSizes GetTopLeftCorner(const size_t& index) const
100  {
101  size_t X = pMatrixData[6 * index ];
102  size_t Y = pMatrixData[6 * index +1];
103  size_t Z = pMatrixData[6 * index +2];
104 
105  return TDimensionSizes(X, Y, Z);
106  };
107 
108  /**
109  * @brief Get the bottom right corner of the index-th cuboid
110  * @details Get the top bottom right of the index-th cuboid. Cuboids are
111  * stored as 6-tuples (two 3D coordinates).
112  * This gives the first three coordinates
113  * @param [in] index -Id of the corner
114  * @return the bottom right corner
115  */
116  TDimensionSizes GetBottomRightCorner(const size_t & index) const
117  {
118  size_t X = pMatrixData[6 * index + 3];
119  size_t Y = pMatrixData[6 * index + 4];
120  size_t Z = pMatrixData[6 * index + 5];
121 
122  return TDimensionSizes(X, Y, Z);
123  };
124 
125  /// Recompute indices MATALAB->C++.
126  void RecomputeIndicesToCPP();
127 
128  /// Recompute indices C++ -> MATLAB.
130 
131  /// Get the total number of elements to be sampled within all cuboids.
133 
134 
135 
136  protected:
137  /// Default constructor not allowed for public.
139 
140  /// Copy constructor not allowed for public.
141  TIndexMatrix(const TIndexMatrix& src);
142 
143  /// Operator = not allowed for public.
145 
146  private:
147 
148  /// Number of elements to get 4MB block of data.
149  static const size_t ChunkSize_1D_4MB = 1048576; //(4MB)
150  /// Number of elements to get 1MB block of data.
151  static const size_t ChunkSize_1D_1MB = 262144; //(1MB)
152  /// Number of elements to get 256KB block of data.
153  static const size_t ChunkSize_1D_256KB = 65536; //(256KB)
154 
155 };// end of TIndexMatrixData
156 //------------------------------------------------------------------------------
157 #endif /* INDEXMATRIXDATA_H */
static const size_t ChunkSize_1D_256KB
Number of elements to get 256KB block of data.
Definition: IndexMatrix.h:153
size_t GetTotalNumberOfElementsInAllCuboids() const
Get the total number of elements to be sampled within all cuboids.
TDimensionSizes GetBottomRightCorner(const size_t &index) const
Get the bottom right corner of the index-th cuboid.
Definition: IndexMatrix.h:116
void RecomputeIndicesToMatlab()
Recompute indices C++ -> MATLAB.
TIndexMatrix()
Default constructor not allowed for public.
Definition: IndexMatrix.h:138
static const size_t ChunkSize_1D_1MB
Number of elements to get 1MB block of data.
Definition: IndexMatrix.h:151
TDimensionSizes GetTopLeftCorner(const size_t &index) const
Get the top left corner of the index-th cuboid.
Definition: IndexMatrix.h:99
The header file containing the structure with 3D dimension sizes.
size_t & operator[](const size_t &index)
Definition: IndexMatrix.h:76
Abstract base class for index based matrices defining basic interface. Higher dimensional matrices st...
void RecomputeIndicesToCPP()
Recompute indices MATALAB->C++.
size_t * pMatrixData
Raw matrix data.
The class for 64b unsigned integers (indices). It is used for sensor_mask_index or sensor_corners_mas...
Definition: IndexMatrix.h:50
TIndexMatrix & operator=(const TIndexMatrix &src)
Operator = not allowed for public.
virtual void WriteDataToHDF5File(THDF5_File &HDF5_File, const char *MatrixName, const size_t CompressionLevel)
Write data into the HDF5 file.
The header file containing the base class for index matrices (based on the size_t datatype)...
virtual void ReadDataFromHDF5File(THDF5_File &HDF5_File, const char *MatrixName)
Read data from the HDF5 file.
Definition: IndexMatrix.cpp:90
virtual ~TIndexMatrix()
Destructor.
Definition: IndexMatrix.h:58
static const size_t ChunkSize_1D_4MB
Number of elements to get 4MB block of data.
Definition: IndexMatrix.h:149
Class wrapping the HDF5 routines.
Definition: HDF5_File.h:506
Structure with 4D dimension sizes (3 in space and 1 in time).
virtual void FreeMemory()
Memory deallocation.