Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Image3DSet.hpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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;/*FIXME*/}
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

Generated on Fri Jun 17 13:36:04 2005 for ImLib3D by  doxygen 1.4.2