00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00020 #ifndef _Image3DSet_hpp
00021 #define _Image3DSet_hpp
00022
00023 #include<ImLib3D/Image3D.hpp>
00024 #include<vector>
00025 #include<string>
00026
00028
00032 template <class ImageType>
00033 class Image3DSet
00034 {
00035 public:
00036 Image3DSet(const vector<string> & _fileNames,bool _fileIsReadOnly=true,bool _isMemOnly=false);
00037 Image3DSet(bool _fileIsReadOnly=true,bool _isMemOnly=false);
00038 Image3DSet(const Image3DSet<ImageType>& _other);
00039 virtual ~Image3DSet();
00040 public:
00041 typedef typename ImageType::value_type Im3DValue;
00042 typedef typename ImageType::value_type value_type;
00043 enum ImageStatus
00044 {
00045 ON_FILE,
00046 IN_MEM
00047 };
00048
00049 protected:
00050 vector<string> fileNames;
00051 mutable vector<ImageType*> images;
00052 mutable vector<ImageStatus> status;
00053 int nbImages;
00054 bool fileIsReadOnly;
00055 bool isMemOnly;
00056
00057 mutable int lruGap;
00059 mutable double startTime;
00061 mutable vector<double> lastTimeUsed;
00062
00063 void DeleteImages();
00064 void FlushToDisk(int i) const;
00065 void LoadImage(int i) const;
00066 void LoadAllImages();
00067 void FlushAllToDisk();
00068 int LeastRecentlyUsed() const;
00069 bool Fits(int i) const{return true;}
00070 public:
00072 virtual void Clear(bool _fileIsReadOnly=true,bool _isMemOnly=false);
00074 ImageType &operator[](int position){return GetImage(position);}
00075 const ImageType &operator[](int position) const {return GetImage(position);}
00076 ImageType &GetImage(int position);
00077 const ImageType &GetImage(int position) const;
00078 string GetFilename(int position){return fileNames[position];}
00079 bool IsEmpty() const {return nbImages==0;}
00080 int Size() const {return nbImages;}
00081 Im3DValue &operator()(const Vect3Di &gpos,int pos){return GetImage(pos)(gpos );}
00082 Im3DValue &operator()(int x,int y,int z ,int pos){return GetImage(pos)(x,y,z);}
00083 Im3DValue Value (const Vect3Di &gpos,int pos){return GetImage(pos)(gpos );}
00084 Im3DValue Value (int x,int y,int z ,int pos){return GetImage(pos)(x,y,z);}
00085 int AddImage(ImageType *image,const string &fileName="");
00086 int GetPosition(const string &filename);
00087 ImageType* RemoveImage(const string &filename);
00088 ImageType* RemoveImage(int position);
00089 bool IsAllSameSize();
00090 vector<string> ImagesThatAreAlike();
00091 vector<string> GetFileList(){return fileNames;}
00092 template<class T> friend ostream& operator<<(ostream& s, const Image3DSet<T>& set);
00093 };
00094
00095 typedef Image3DSet<Image3Df> Image3DfSet;
00096 #include<ImLib3D/Image3DSet.hxx>
00097
00098 #endif //_Image3DSet_hpp