Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxHistogramData.h

00001 /*
00002  *  Copyright (c) 1997, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *
00006  *  Author(s):
00007  *  Dennis Koelma (koelma@wins.uva.nl)
00008  *  Edo Poll (poll@wins.uva.nl)
00009  *  Jeroen Vendrig (vendrig@wins.uva.nl)
00010  *  Jan-Mark Geusebroek (mark@science.uva.nl)
00011  */
00012 
00013 #ifndef HxHistogramData_h
00014 #define HxHistogramData_h
00015 
00016 #include "HxRcObject.h"
00017 #include "HxValueType.h"
00018 
00019 
00020 class HxHistogramData : public HxRcObject {
00021 private:
00022                             HxHistogramData(const HxHistogramData&);
00023                             HxHistogramData(const HxValueType dataType,
00024                                 const HxHistogramData&);
00025                             HxHistogramData(HxValueType dataType, int dimensions,
00026                                 double lowBin1, double highBin1, int nBins1,
00027                                 double lowBin2, double highBin2, int nBins2,
00028                                 double lowBin3, double highBin3, int nBins3);
00029                             ~HxHistogramData();
00030 
00031     static const double            _EPSILON;
00032 
00033     virtual HxRcObject*     clone() const;
00034 
00035     void                    incBin(int n);
00036 
00037     void                    setBin(const int n, const long count);
00038     void                    setBin(const int n, const double count);
00039     double                  getBin(const int n) const;
00040     long                    getBinLong(const int n) const;
00041 
00042     int                     _id;
00043     HxValueType             _dataType;
00044     int                     _nDims;
00045     int                     _dimSize1;
00046     int                     _dimSize2;
00047     int                     _dimSize3;
00048     int                     _totSize;
00049     union {
00050         double *            realValue;
00051         long   *            intValue;
00052     } _bins;
00053     double                  _lowBin1;
00054     double                  _lowBin2;
00055     double                  _lowBin3;
00056     double                  _highBin1;
00057     double                  _highBin2;
00058     double                  _highBin3;
00059     double                  _binWidth1;
00060     double                  _binWidth2;
00061     double                  _binWidth3;
00062 
00063     /* constants for conversion from value to bin */
00064     double                  _lowRange1;
00065     double                  _lowRange2;
00066     double                  _lowRange3;
00067     double                  _binFac1;
00068     double                  _binFac2;
00069     double                  _binFac3;
00070 
00071     double                  _sum;
00072 
00073     static int              _nr;
00074 
00075     friend class            HxHistogram;
00076 };
00077 
00078 inline void
00079 HxHistogramData::incBin(const int n)
00080 {
00081     if (_dataType == REAL_VALUE)
00082         _bins.realValue[n] += 1.0;
00083     else
00084         _bins.intValue[n]++;
00085 }
00086 
00087 inline void
00088 HxHistogramData::setBin(const int n, const long count)
00089 {
00090     if (_dataType == REAL_VALUE)
00091         _bins.realValue[n] = count;
00092     else
00093         _bins.intValue[n] = count;
00094 }
00095 
00096 inline void
00097 HxHistogramData::setBin(const int n, const double count)
00098 {
00099     if (_dataType == REAL_VALUE)
00100         _bins.realValue[n] = count;
00101     else
00102         _bins.intValue[n] = (int)(count+0.5);
00103 }
00104 
00105 inline double
00106 HxHistogramData::getBin(const int n) const
00107 {
00108     if (_dataType == REAL_VALUE)
00109         return _bins.realValue[n];
00110     return _bins.intValue[n];
00111 }
00112 
00113 inline long
00114 HxHistogramData::getBinLong(const int n) const
00115 {
00116     if (_dataType == REAL_VALUE)
00117         return (long)(_bins.realValue[n]+0.5);
00118     return _bins.intValue[n];
00119 }
00120 
00121 #endif

Generated on Tue Feb 3 14:18:35 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001