00001 //------------------------------------------------------------------------ 00002 // 00003 // Joe Kniss 00004 // 8-8-03 00005 // ________ ____ ___ 00006 // | \ / | / / 00007 // +---+ \/ |/ / 00008 // +--+| |\ /| < 00009 // | || | \ / | |\ \ 00010 // | | \/ | | \ \ 00011 // \_____| |__| \__\ 00012 // Copyright 2003 00013 // Joe Michael Kniss 00014 // <<< jmk@cs.utah.edu >>> 00015 // "All Your Base are Belong to Us" 00016 //------------------------------------------------------------------------- 00017 00018 /// TFImage.h 00019 00020 #ifndef __SIMIAN_TF_IMAGE_MAP_DOT_H 00021 #define __SIMIAN_TF_IMAGE_MAP_DOT_H 00022 00023 #include <nrro/nrroImage.h> 00024 #include <mathGutz.h> 00025 #include <map> 00026 #include "TFParams.h" 00027 00028 00029 /////////////////////////////////////////////////////////////////////////// 00030 /// Image class, subclass of NrroImage 00031 /////////////////////////////////////////////////////////////////////////// 00032 class TFImage : public NrroImage { 00033 public: 00034 typedef gutz::vec<double,STF::TF_MAX_R> DVecType; 00035 00036 TFImage(int type, int format, int sx, int sy); 00037 00038 virtual ~TFImage() {} 00039 00040 gutz::vec2i getAxes() const {return _axes;} 00041 void setAxes(const gutz::vec2i &a) {_axes = a;} 00042 00043 ////////////////////////////////////////////////////// 00044 ///@name Changed 00045 /// for collaboration with the transfer function, this 00046 /// integer gets set to the tfs changeID so it can tell 00047 /// if the image is up to date. 00048 ///@{ 00049 int getLastChanged() const { return _lastChanged; } 00050 void setLastChanged(int ch) { _lastChanged = ch; } 00051 ///@} 00052 00053 /// clear the image 00054 void clear(const DVecType cv = DVecType(0.0)); 00055 /// kind based on STF::TF_4MAP_KINDS 00056 void clear(int kind); 00057 00058 protected: 00059 gutz::vec2i _axes; 00060 int _lastChanged; 00061 }; 00062 00063 /////////////////////////////////////////////////////////////////////////// 00064 /// Speciallized TFImage smart ptr for auto cast to bases 00065 /////////////////////////////////////////////////////////////////////////// 00066 class TFImageSP : public gutz::SmartPtr<TFImage> 00067 { 00068 public: 00069 typedef gutz::SmartPtr<TFImage> btype; 00070 00071 TFImageSP() : btype() {} 00072 TFImageSP(TFImage *im) : btype(im) {} 00073 TFImageSP(const TFImageSP &im) : btype(im) {} 00074 virtual ~TFImageSP() {} 00075 00076 TFImageSP &operator=(const TFImageSP &im) 00077 { 00078 assign(im._ref); 00079 return *this; 00080 } 00081 00082 /// auto conversion to NrroSP 00083 operator NrroSP () { return NrroSP(getPtr()); } 00084 /// auto conversion to Nrro* 00085 operator Nrro* () { return getPtr(); } 00086 /// auto conversion to NrroImageSP 00087 operator NrroImageSP () { return NrroImageSP(getPtr()); } 00088 /// auto conversion to NrroImage* 00089 operator NrroImage* () { return getPtr(); } 00090 }; 00091 00092 /////////////////////////////////////////////////////////////////////////// 00093 /// TFImageSP map for collaboration with the TF 00094 /////////////////////////////////////////////////////////////////////////// 00095 struct TFImageSPMapCmp 00096 { 00097 bool operator()(const gutz::vec2i &v1, const gutz::vec2i &v2) const 00098 { 00099 return v1 < v2; 00100 } 00101 }; 00102 00103 typedef std::map<gutz::vec2i, TFImageSP, TFImageSPMapCmp> TFImageSPMap; 00104 typedef TFImageSPMap::iterator TFImageSPMapIter; 00105 typedef TFImageSPMap::const_iterator TFImageSPMapCIter; 00106 00107 00108 00109 #endif 00110 00111