[301] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // Voxel.hh: Definition of the Voxel class, storing a single 3D voxel |
---|
| 3 | // plus an associated flux. |
---|
| 4 | // ----------------------------------------------------------------------- |
---|
| 5 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
| 6 | // |
---|
| 7 | // This program is free software; you can redistribute it and/or modify it |
---|
| 8 | // under the terms of the GNU General Public License as published by the |
---|
| 9 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
| 10 | // option) any later version. |
---|
| 11 | // |
---|
| 12 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
| 13 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
| 15 | // for more details. |
---|
| 16 | // |
---|
| 17 | // You should have received a copy of the GNU General Public License |
---|
| 18 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
| 19 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
| 20 | // |
---|
| 21 | // Correspondence concerning Duchamp may be directed to: |
---|
| 22 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
| 23 | // Postal address: Dr. Matthew Whiting |
---|
| 24 | // Australia Telescope National Facility, CSIRO |
---|
| 25 | // PO Box 76 |
---|
| 26 | // Epping NSW 1710 |
---|
| 27 | // AUSTRALIA |
---|
| 28 | // ----------------------------------------------------------------------- |
---|
[237] | 29 | #ifndef VOXEL_H |
---|
| 30 | #define VOXEL_H |
---|
| 31 | |
---|
| 32 | #include <iostream> |
---|
| 33 | |
---|
[252] | 34 | namespace PixelInfo |
---|
| 35 | { |
---|
| 36 | //========================================================================== |
---|
[237] | 37 | |
---|
[528] | 38 | /// Voxel class. |
---|
| 39 | /// A 3-dimensional pixel, with x,y,z position + flux |
---|
[237] | 40 | |
---|
[252] | 41 | class Voxel |
---|
| 42 | { |
---|
| 43 | public: |
---|
[528] | 44 | /// @brief Default constructor. |
---|
[252] | 45 | Voxel(){}; |
---|
[528] | 46 | /// @brief Specific constructor, defining an (x,y,z) location and flux f. |
---|
[270] | 47 | Voxel(long x, long y, long z, float f); |
---|
[742] | 48 | /// @brief Specific constructor, defining an (x,y,z) location, setting f=0. |
---|
| 49 | Voxel(long x, long y, long z); |
---|
[1290] | 50 | /// @brief Specific constructor, defining an (x,y) location, setting z=0 and f=0. |
---|
| 51 | Voxel(long x, long y); |
---|
[528] | 52 | /// @brief Copy constructor. |
---|
[270] | 53 | Voxel(const Voxel& v); |
---|
[528] | 54 | /// @brief Assignment operator. |
---|
[270] | 55 | Voxel& operator= (const Voxel& v); |
---|
[252] | 56 | virtual ~Voxel(){}; |
---|
[237] | 57 | |
---|
[252] | 58 | // accessor functions |
---|
| 59 | void setX(long x){itsX = x;}; |
---|
| 60 | void setY(long y){itsY = y;}; |
---|
| 61 | void setZ(long z){itsZ = z;}; |
---|
| 62 | void setF(float f){itsF = f;}; |
---|
[528] | 63 | /// @brief Define an (x,y) coordinate |
---|
[252] | 64 | void setXY(long x, long y){itsX = x; itsY = y;}; |
---|
[528] | 65 | /// @brief Define an (x,y,z) coordinate |
---|
[252] | 66 | void setXYZ(long x, long y, long z){itsX = x; itsY = y; itsZ = z;}; |
---|
[528] | 67 | /// @brief Define an (x,y) coordinate with a flux f |
---|
[252] | 68 | void setXYF(long x, long y, float f){itsX = x; itsY = y; itsF = f;}; |
---|
[528] | 69 | /// @brief Define an (x,y,z) coordinate with a flux f |
---|
[252] | 70 | void setXYZF(long x, long y, long z, float f){itsX = x; itsY = y; itsZ = z; itsF = f;}; |
---|
| 71 | long getX(){return itsX;}; |
---|
| 72 | long getY(){return itsY;}; |
---|
| 73 | long getZ(){return itsZ;}; |
---|
| 74 | float getF(){return itsF;}; |
---|
[472] | 75 | |
---|
[528] | 76 | /// @brief Return an index value for an array |
---|
[1155] | 77 | size_t arrayIndex(const size_t *dim); |
---|
[472] | 78 | |
---|
[528] | 79 | /// @brief Operator to print information of voxel. |
---|
[252] | 80 | friend std::ostream& operator<< ( std::ostream& theStream, Voxel& vox); |
---|
[237] | 81 | |
---|
[528] | 82 | /// @brief Operator to test for equality. |
---|
[418] | 83 | friend bool operator== (Voxel lhs, Voxel rhs); |
---|
[858] | 84 | |
---|
| 85 | /// @brief Less-than operator to allow ordering |
---|
| 86 | friend bool operator< (Voxel lhs, Voxel rhs); |
---|
[418] | 87 | |
---|
[528] | 88 | /// @brief Function to test for equality of positions only. |
---|
[418] | 89 | bool match(Voxel other); |
---|
| 90 | |
---|
| 91 | |
---|
[252] | 92 | protected: |
---|
| 93 | long itsX; ///< x-position of pixel |
---|
| 94 | long itsY; ///< y-position of pixel |
---|
| 95 | long itsZ; ///< z-position of pixel |
---|
| 96 | float itsF; ///< flux of pixel |
---|
| 97 | }; |
---|
[237] | 98 | |
---|
| 99 | |
---|
[252] | 100 | } |
---|
[237] | 101 | |
---|
| 102 | #endif // VOXEL_H |
---|