Main Page   Class Overview   Pixels   Images   Geometry   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  */
00011 
00012 #ifndef HxHistogramData_h
00013 #define HxHistogramData_h
00014 
00015 #include "HxRcObject.h"
00016 #include "HxValueType.h"
00017 
00018 
00019 class HxHistogramData : public HxRcObject {
00020 private:
00021                             HxHistogramData(const HxHistogramData&);
00022                             HxHistogramData(const HxValueType dataType,
00023                                 const HxHistogramData&);
00024                             HxHistogramData(HxValueType dataType, int dimensions,
00025                                 double lowBin1, double highBin1, int nBins1,
00026                                 double lowBin2, double highBin2, int nBins2,
00027                                 double lowBin3, double highBin3, int nBins3);
00028                             ~HxHistogramData();
00029 
00030     virtual HxRcObject*     clone() const;
00031 
00032     void                    incBin(int n);
00033 
00034     void                    setBin(const int n, const long count);
00035     void                    setBin(const int n, const double count);
00036     double                  getBin(const int n) const;
00037     long                    getBinLong(const int n) const;
00038 
00039     int                     _id;
00040     HxValueType             _dataType;
00041     int                     _nDims;
00042     int                     _dimSize1;
00043     int                     _dimSize2;
00044     int                     _dimSize3;
00045     int                     _totSize;
00046     union {
00047         double *            realValue;
00048         long   *            intValue;
00049     } _bins;
00050     double                  _lowBin1;
00051     double                  _lowBin2;
00052     double                  _lowBin3;
00053     double                  _highBin1;
00054     double                  _highBin2;
00055     double                  _highBin3;
00056     double                  _binWidth1;
00057     double                  _binWidth2;
00058     double                  _binWidth3;
00059     double                  _sum;
00060 
00061     static int              _nr;
00062 
00063     friend class            HxHistogram;
00064 };
00065 
00066 inline void
00067 HxHistogramData::incBin(const int n)
00068 {
00069     if (_dataType == REAL_VALUE)
00070         _bins.realValue[n] += 1.0;
00071     else
00072         _bins.intValue[n]++;
00073 }
00074 
00075 inline void
00076 HxHistogramData::setBin(const int n, const long count)
00077 {
00078     if (_dataType == REAL_VALUE)
00079         _bins.realValue[n] = count;
00080     else
00081         _bins.intValue[n] = count;
00082 }
00083 
00084 inline void
00085 HxHistogramData::setBin(const int n, const double count)
00086 {
00087     if (_dataType == REAL_VALUE)
00088         _bins.realValue[n] = count;
00089     else
00090         _bins.intValue[n] = (int)(count+0.5);
00091 }
00092 
00093 inline double
00094 HxHistogramData::getBin(const int n) const
00095 {
00096     if (_dataType == REAL_VALUE)
00097         return _bins.realValue[n];
00098     return _bins.intValue[n];
00099 }
00100 
00101 inline long
00102 HxHistogramData::getBinLong(const int n) const
00103 {
00104     if (_dataType == REAL_VALUE)
00105         return (long)(_bins.realValue[n]+0.5);
00106     return _bins.intValue[n];
00107 }
00108 
00109 #endif

Generated on Tue Jan 8 13:59:12 2002 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001