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

ImageProcessor.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  */
00029 #ifndef _ImageProcessor_hpp
00030 #define _ImageProcessor_hpp
00031 
00032 #include<ImLib3D/Image3D.hpp>
00033 
00034 
00035 
00038 enum ImageArgFlag   
00039 {
00040     IMARG_NOTDEFINED,           
00041     IMARG_INPLACE,              
00042     IMARG_NOTINPLACE            
00043 };
00044 
00045 
00046 template<class ImageType> class ImageProcessorArgs;
00047 
00049 
00052 template <class ImageType,class ImageTypeCst=ImageType>
00053 class ImageArg
00054 {
00055     friend class ImageProcessorArgs<ImageType>;
00056     ImageTypeCst *image;
00057     bool srcIsConst;
00058     ImageType *duplicate;
00059     Size3D newSize;
00060 public:
00061     void SetConst(bool v=true){srcIsConst=v;}
00062     ImageArg(ImageTypeCst &_image,ImageArgFlag f0=IMARG_NOTDEFINED):
00063         image(&_image),srcIsConst(true),duplicate(NULL)
00064     {
00065         if(f0==IMARG_INPLACE){srcIsConst=false;}
00066         if(f0==IMARG_NOTINPLACE){srcIsConst=true;}
00067     }
00068 };
00069 
00070 
00071 #define TMPDEF ImageArg<Im,const Im>
00072 
00073 template <class Im> inline vector<TMPDEF > ImArgs(const Im &a1,const Im &a2,const Im &a3,const Im &a4)
00074 {TMPDEF s[]={TMPDEF(a1),TMPDEF(a2),TMPDEF(a3),TMPDEF(a4)};vector<TMPDEF > v;v.insert(v.end(),s,s+4);return v;}
00075 template <class Im> inline vector<TMPDEF > ImArgs(const Im &a1,const Im &a2,const Im &a3)
00076 {TMPDEF s[]={TMPDEF(a1),TMPDEF(a2),TMPDEF(a3)};vector<TMPDEF > v;v.insert(v.end(),s,s+3);return v;}
00077 template <class Im> inline vector<TMPDEF > ImArgs(const Im &a1,const Im &a2)
00078 {TMPDEF s[]={TMPDEF(a1),TMPDEF(a2)};vector<TMPDEF > v;v.insert(v.end(),s,s+2);return v;}
00079 template <class Im> inline vector<TMPDEF > ImArgs(const Im &a1)
00080 {TMPDEF s[]={TMPDEF(a1)};vector<TMPDEF > v;v.insert(v.end(),s,s+1);return v;}
00081 
00082 #undef TMPDEF
00083 
00084 
00090 template <class ImageType>
00091 class ImageProcessorArgs
00092 {
00093 private:
00094     typedef ImageArg<ImageType,      ImageType> ImArg;
00095     typedef ImageArg<ImageType,const ImageType> ImArgCst;
00096     bool useLargerSrcBounds;
00097     Size3D bounds;
00098 
00099     vector<ImArgCst>  srcArgs;
00100     vector<ImArg   > destArgs;
00101 public:
00102     ImageProcessorArgs(const vector<ImageArg<ImageType,const ImageType> > &srcs,ImageArg<ImageType> dest):
00103         useLargerSrcBounds(false)
00104     {
00105         for(uint i=0;i<srcs.size();i++)
00106         {
00107             AddSrc (ImageArg<ImageType,const ImageType>(srcs[i]));
00108         }
00109         AddDest(dest);
00110     }
00111     ImageProcessorArgs():
00112         useLargerSrcBounds(false)
00113     {
00114     }
00115     ~ImageProcessorArgs()
00116     {
00117         Finished();
00118     }
00120     void AddSrc (ImArgCst arg){ srcArgs.push_back(arg);}
00122     void AddDest(ImArg    arg){destArgs.push_back(arg);}
00123 
00124 
00125     void SameSize();
00126     void SetDestSize(Size3D size);
00127     void InPlace();
00128 
00130     void AllSameSizeAssert();
00131 //  void AllSameSizeForce();
00132     void NoMasksAssert(){;}
00133 //  void NoSupportAssert();
00134     void UseLargerSrcBounds();
00135 
00137     ImageType &GetDest(int argn=0);
00139     const ImageType &GetSrc(int argn=0);
00140 
00142 
00146     void Finished();
00147 
00148 };
00149 
00150 #include<ImLib3D/ImageProcessor.hxx>
00151 
00152 #endif  //_ImageProcessor_hpp

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