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

HxIndxHisto.h

00001 /*
00002  *  Copyright (c) 2000, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *  Author(s):
00006  *  Jan-Mark Geusebroek (mark@wins.uva.nl)
00007  *
00008  */
00009 
00010 /*
00011  *  JV, 06Mar03: added at+get+getKey+listAt functions for access to histograms
00012  *  JV, 06Mar03: added reconstruction information to header
00013  *  JV, 06Mar03: added dimensionSize+dimensionality inquiry
00014  *  JV, 06Mar03: added support for varying datatype histograms (long or float)
00015  */
00016 
00017 #ifndef HxIndxHisto_H
00018 #define HxIndxHisto_H
00019 
00020 #include "HxIndxArray.h"
00021 #include "HxHistoList.h"
00022 
00023 template<class ArrayT> ArrayT* getData(HxHistoList);
00024 template long* getData(HxHistoList);
00025 template float* getData(HxHistoList);
00026 
00027 template<class HeaderT>
00028 class IndxHistHeaderT {
00029     public:
00030         friend STD_OSTREAM& operator<<(STD_OSTREAM& os,
00031             const IndxHistHeaderT& l)
00032                 {return os << l.bins << " bins, " << l.chans <<
00033                     ((l.chans == 1) ?  HxString(" channel") :
00034                         HxString(" channels"));}
00035                         
00037     int     dimensionality() const
00038             {   if (dimensionSize(3)>1)
00039                     return 3;
00040                 else
00041                     if (dimensionSize(2)>1)
00042                         return 2;
00043                 return 1;
00044             }
00045             
00049     int     dimensionSize(int d) const
00050             { return dim[d-1]; }
00051             
00053     double          lowBin(int d) const
00054             { return low[d-1]; }
00055             
00057     double          highBin(int d) const
00058             { return high[d-1]; }
00059             
00063     HxValueType     dataType() const
00064             { return _dataType;}
00065 
00066     int         bins; /* Redundant, but kept for backwards compatibility. */
00067     int         chans;
00068     HeaderT     header; /* Contains application-dependent info. */
00069     
00070     int         dim[3];
00071     double      low[3];
00072     double      high[3];
00073     HxValueType _dataType;        
00074 };
00075 
00076 /* ArrayT is histogram type (long or double), HeaderT is the comment type */
00077 template<class ArrayT, class HeaderT>
00078 class indexedHisto : public indexedArray<ArrayT, IndxHistHeaderT<HeaderT> >  {
00079 public:
00080     void        create(HxString indexFile, HeaderT header);
00081     void        add(HxString& key, HxHistoList& l); 
00082     void        search(HxHistoList& target, int n = 10, int refine = 0);
00083 
00084                 /* Header information about the histograms. */
00085     int         bins() const;
00086     int         chans() const;
00087     HeaderT     header() const;    
00088     int         dimensionSize(int d) const;
00089     int         dimensionality() const;             
00090     HxValueType dataType() const;   
00091     double      lowBin(int d) const;
00092     double      highBin(int d) const;
00093 
00094     friend STD_OSTREAM& operator<<(STD_OSTREAM& os,
00095         const indexedHisto& l)
00096             {return l.put(os);}
00097 
00098     int         arraySize(const IndxHistHeaderT<HeaderT>& header) const
00099                     {return header.bins*header.chans;}
00100 
00101     virtual double      compare(ArrayT *e1, ArrayT *e2,
00102                     const IndxHistHeaderT<HeaderT>& header) const;
00103 
00104                 /* Returns data for the ndx-th element in the c-th channel. */
00105     HxHistogram at(int ndx, int c=0) const;
00106                     
00107                 /* Returns the data for the ndx-th element */
00108     HxHistoList listAt(int ndx) const;
00109 
00110                 /* Returns the data for given key. */
00111     HxHistogram get(HxString key, int c=0) const;
00112 
00113                 /* Returns the key of the ndx-th element. */
00114     HxString    getKey(int ndx) const       
00115                 {return indexedArray<ArrayT, IndxHistHeaderT<HeaderT> >
00116                     ::getKey(ndx);}
00117 
00118 private:
00119                 /* Converts the data to histogram. */
00120     HxHistogram makeHistogram(ArrayT* arr, int c=0) const;
00121     
00122     int         _create;
00123     HeaderT     _header;
00124 };
00125 
00126 
00127 #ifdef INC_TEMPLATE_SRC
00128 #include "HxIndxHisto.c"
00129 #endif
00130 
00131 #endif

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