[301] | 1 | // ----------------------------------------------------------------------- |
---|
[570] | 2 | // Object3D.hh: Definition of the Object3D class that holds |
---|
[301] | 3 | // pixel information for a three-dimensional object. |
---|
| 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 | // ----------------------------------------------------------------------- |
---|
[238] | 29 | #ifndef OBJECT3D_H |
---|
| 30 | #define OBJECT3D_H |
---|
| 31 | |
---|
[393] | 32 | #include <duchamp/PixelMap/Voxel.hh> |
---|
| 33 | #include <duchamp/PixelMap/Scan.hh> |
---|
| 34 | #include <duchamp/PixelMap/Object2D.hh> |
---|
[238] | 35 | #include <vector> |
---|
[244] | 36 | #include <algorithm> |
---|
[570] | 37 | #include <map> |
---|
[244] | 38 | #include <iostream> |
---|
[238] | 39 | |
---|
[252] | 40 | namespace PixelInfo |
---|
[238] | 41 | { |
---|
| 42 | |
---|
[528] | 43 | /// @brief A set of pixels in 3D. |
---|
| 44 | /// |
---|
[570] | 45 | /// @details This stores the pixels in a STL map, connecting a |
---|
| 46 | /// channel number (z-value) to a unique Object2D. Also recorded |
---|
| 47 | /// are the average x-, y- and z-values (via their sums), as well as |
---|
| 48 | /// their extrema. |
---|
[253] | 49 | |
---|
[252] | 50 | class Object3D |
---|
| 51 | { |
---|
| 52 | public: |
---|
[365] | 53 | Object3D(); |
---|
[252] | 54 | Object3D(const Object3D& o); |
---|
| 55 | Object3D& operator= (const Object3D& o); |
---|
| 56 | virtual ~Object3D(){}; |
---|
| 57 | |
---|
[528] | 58 | /// @brief Is a 3-D voxel in the Object? |
---|
[570] | 59 | bool isInObject(long x, long y, long z); |
---|
[528] | 60 | /// @brief Is a 3-D voxel in the Object? |
---|
[570] | 61 | bool isInObject(Voxel v){return isInObject(v.getX(),v.getY(),v.getZ());}; |
---|
[238] | 62 | |
---|
[528] | 63 | /// @brief Add a single 3-D voxel to the Object. |
---|
[570] | 64 | virtual void addPixel(long x, long y, long z); |
---|
[528] | 65 | /// @brief Add a single 3-D voxel to the Object. |
---|
[570] | 66 | virtual void addPixel(Voxel v){addPixel(v.getX(),v.getY(),v.getZ());}; |
---|
[528] | 67 | /// @brief Add a scan to the object |
---|
[570] | 68 | void addScan(Scan s, long z); |
---|
[528] | 69 | /// @brief Add a full channel map to the Object. |
---|
[570] | 70 | void addChannel(const long &z, Object2D &obj); |
---|
[238] | 71 | |
---|
[528] | 72 | /// @brief Calculate the averages and extrema of the three coordinates. |
---|
[570] | 73 | void calcParams(); |
---|
[528] | 74 | /// @brief Return the average x-value. |
---|
[570] | 75 | float getXaverage(); |
---|
[528] | 76 | /// @brief Return the average y-value. |
---|
[570] | 77 | float getYaverage(); |
---|
[528] | 78 | /// @brief Return the average z-value. |
---|
[570] | 79 | float getZaverage(); |
---|
[528] | 80 | /// @brief Return the minimum x-value. |
---|
[570] | 81 | long getXmin(){return xmin;}; |
---|
[528] | 82 | /// @brief Return the minimum y-value. |
---|
[570] | 83 | long getYmin(){return ymin;}; |
---|
[528] | 84 | /// @brief Return the minimum z-value. |
---|
[570] | 85 | long getZmin(){return zmin;}; |
---|
[528] | 86 | /// @brief Return the maximum x-value. |
---|
[570] | 87 | long getXmax(){return xmax;}; |
---|
[528] | 88 | /// @brief Return the maximum y-value. |
---|
[570] | 89 | long getYmax(){return ymax;}; |
---|
[528] | 90 | /// @brief Return the maximum z-value. |
---|
[570] | 91 | long getZmax(){return zmax;}; |
---|
[238] | 92 | |
---|
[528] | 93 | /// @brief Return the number of distinct voxels in the Object. |
---|
[570] | 94 | unsigned int getSize(){return numVox;}; |
---|
[253] | 95 | |
---|
[528] | 96 | /// @brief Return the number of distinct channels in the Object. |
---|
[570] | 97 | long getNumDistinctZ(){return chanlist.size();}; |
---|
[253] | 98 | |
---|
[528] | 99 | /// @brief Return the number of channels in the Object. |
---|
[570] | 100 | long getNumChanMap(){return chanlist.size();}; |
---|
[253] | 101 | |
---|
[528] | 102 | /// @brief Return the number of spatial pixels -- ie. the number of distinct (x,y) sets in the Object. |
---|
[570] | 103 | long getSpatialSize(); |
---|
[253] | 104 | |
---|
[528] | 105 | /// @brief Return a vector set of all voxels in the Object. |
---|
[252] | 106 | std::vector<Voxel> getPixelSet(); |
---|
[241] | 107 | |
---|
[570] | 108 | /// @brief Return a vector list of the channel numbers in the Object |
---|
| 109 | std::vector<long> getChannelList(); |
---|
[253] | 110 | |
---|
[570] | 111 | /// @brief Return the largest number of adjacent channels in the Object. |
---|
| 112 | int getMaxAdjacentChannels(); |
---|
[238] | 113 | |
---|
[570] | 114 | /// @brief Get the channel map for channel z. |
---|
| 115 | Object2D getChanMap(long z); |
---|
| 116 | |
---|
[528] | 117 | /// @brief Return an Object2D showing the spatial (x,y) distribution of voxels in the Object |
---|
[252] | 118 | Object2D getSpatialMap(); |
---|
[238] | 119 | |
---|
[528] | 120 | /// @brief Add constant offsets to each of the dimensions, changing the parameters at the same time. |
---|
[570] | 121 | virtual void addOffsets(long xoff, long yoff, long zoff); |
---|
[240] | 122 | |
---|
[528] | 123 | /// @brief Output operator for the Object3D. |
---|
[252] | 124 | friend std::ostream& operator<< ( std::ostream& theStream, Object3D& obj); |
---|
[238] | 125 | |
---|
[528] | 126 | /// @brief Add two Object3Ds. Overlapping channels are combined using addChannel(). |
---|
[570] | 127 | friend Object3D operator+ (Object3D lhs, Object3D rhs); |
---|
[240] | 128 | |
---|
[570] | 129 | protected: |
---|
| 130 | std::map<long,Object2D> chanlist; ///< The list of 2D channel maps |
---|
| 131 | unsigned long numVox; ///< How many voxels in the Object? |
---|
| 132 | float xSum; ///< Sum of the x-values |
---|
| 133 | float ySum; ///< Sum of the y-values |
---|
| 134 | float zSum; ///< Sum of the z-values |
---|
| 135 | long xmin,xmax; ///< min and max x-values of object |
---|
| 136 | long ymin,ymax; ///< min and max y-values of object |
---|
| 137 | long zmin,zmax; ///< min and max z-values of object |
---|
[252] | 138 | }; |
---|
[240] | 139 | |
---|
[252] | 140 | } |
---|
[238] | 141 | |
---|
| 142 | #endif //OBJECT3D_H |
---|