Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkIPLFileNameList.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 Program: Insight Segmentation & Registration Toolkit 00003 Module: $RCSfile: itkIPLFileNameList.h,v $ 00004 Language: C++ 00005 Date: $Date: 2004/01/08 00:39:06 $ 00006 Version: $Revision: 1.3 $ 00007 00008 Copyright (c) Insight Software Consortium. All rights reserved. 00009 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notices for more information. 00014 00015 =========================================================================*/ 00016 00017 #ifndef __IPLFileNameList_H__ 00018 #define __IPLFileNameList_H__ 00019 00020 #include "itkMacro.h" 00021 #include "itkObject.h" 00022 #include <stdio.h> 00023 #include <string> 00024 #include <list> 00026 #define IPLSetMacro(name,type) \ 00027 virtual void Set##name (const type _arg) \ 00028 { \ 00029 if (this->m_##name != _arg) \ 00030 { \ 00031 this->m_##name = _arg; \ 00032 } \ 00033 } 00034 00036 #define IPLGetMacro(name,type) \ 00037 virtual type Get##name () \ 00038 { \ 00039 return this->m_##name; \ 00040 } 00041 00042 namespace itk { 00046 class IPLFileSortInfo 00047 { 00048 public: 00049 IPLFileSortInfo() { 00050 m_SliceLocation = 0; 00051 m_SliceOffset = 0; 00052 m_echoNumber = 0; 00053 m_imageNumber = 0; 00054 m_data = 0; 00055 } 00056 virtual ~IPLFileSortInfo() { 00057 } 00058 IPLFileSortInfo(const char *const filename,float SliceLocation, 00059 int SliceOffset,int echoNumber,int imageNumber,void *data = 0) 00060 { 00061 m_imageFileName = filename; 00062 m_SliceLocation = SliceLocation; 00063 m_SliceOffset = SliceOffset; 00064 m_echoNumber = echoNumber; 00065 m_imageNumber = imageNumber; 00066 m_data = data; 00067 } 00068 00069 IPLSetMacro(imageFileName,std::string ); 00070 IPLGetMacro(imageFileName,std::string ); 00071 IPLSetMacro(SliceLocation,float ); 00072 IPLGetMacro(SliceLocation,float ); 00073 IPLSetMacro(SliceOffset,int ); 00074 IPLGetMacro(SliceOffset,int ); 00075 IPLSetMacro(echoNumber,int ); 00076 IPLGetMacro(echoNumber,int ); 00077 IPLSetMacro(imageNumber,int ); 00078 IPLGetMacro(imageNumber,int ); 00079 IPLSetMacro(data,void *); 00080 IPLGetMacro(data,const void *); 00081 private: 00082 std::string m_imageFileName; 00083 float m_SliceLocation; 00084 int m_SliceOffset; 00085 int m_echoNumber; 00086 int m_imageNumber; 00087 const void *m_data; 00088 }; 00089 00090 00094 class IPLFileNameList 00095 { 00096 public: 00097 typedef std::list<IPLFileSortInfo *> ListType; 00098 typedef ListType::iterator IteratorType; 00099 IPLFileNameList() 00100 { 00101 m_XDim = 0; 00102 m_YDim = 0; 00103 m_Key1 = 0; 00105 m_Key2 = 0; 00106 } 00107 virtual ~IPLFileNameList() 00108 { 00109 IteratorType it = begin(); 00110 IteratorType itend = end(); 00111 while(it != itend) 00112 { 00113 delete (*it); 00114 it++; 00115 } 00116 } 00117 IteratorType begin() { return m_List.begin(); } 00118 IteratorType end() { return m_List.end(); } 00119 IPLFileSortInfo *operator[](unsigned int __n) 00120 { 00121 IteratorType it = begin(); 00122 IteratorType itend= end(); 00123 for(unsigned int i = 0; it != itend && i != __n; it++, i++) 00124 ; 00125 if(it == itend) 00126 return 0; 00127 return *it; 00128 } 00129 signed int NumFiles() const { 00130 return m_List.size(); 00131 } 00132 bool AddElementToList(char const *const filename, 00133 const float sliceLocation, 00134 const int offset, 00135 const int XDim, 00136 const int YDim, 00137 const int imageNumber, 00138 const int Key1, 00139 const int Key2) 00140 { 00141 if(m_List.empty()) 00142 { 00143 m_XDim = XDim; 00144 m_YDim = YDim; 00145 m_Key1 = Key1; 00146 m_Key2 = Key2; 00147 } 00148 else if(XDim != m_XDim || YDim != YDim) 00149 { 00150 return false; 00151 } 00152 else if(Key1 != m_Key1 || Key2 != m_Key2) 00153 { 00154 return true; 00155 } 00156 m_List.push_back(new IPLFileSortInfo(filename, 00157 sliceLocation, 00158 offset, 00159 0, // echo number 00160 imageNumber)); 00161 return true; 00162 } 00163 void RemoveElementFromList(const int ElementToRemove) 00164 { 00165 IteratorType it = m_List.begin(); 00166 IteratorType itend = m_List.end(); 00167 int i = 0; 00168 for(i = 0; it != itend; i++, it++) 00169 { 00170 if(i != ElementToRemove) 00171 break; 00172 } 00173 if(it == itend) 00174 return; 00175 m_List.remove((*it)); 00176 00177 } 00178 00179 void sortImageListAscend (); 00180 void sortImageListDescend (); 00181 00182 int GetnumImageInfoStructs() const 00183 { 00184 return m_List.size(); 00185 } 00186 IPLSetMacro(XDim,int ); 00187 IPLGetMacro(XDim,int ); 00188 IPLSetMacro(YDim,int ); 00189 IPLGetMacro(YDim,int ); 00190 IPLSetMacro(Key1,int ); 00191 IPLGetMacro(Key1,int ); 00192 IPLSetMacro(Key2,int ); 00193 IPLGetMacro(Key2,int ); 00194 private: 00195 ListType m_List; 00196 int m_XDim; 00197 int m_YDim; 00198 int m_Key1; 00200 int m_Key2; 00201 }; 00202 00203 } 00204 00205 #endif /* __IPLFileNameList_H__ */

Generated at Sun Apr 1 02:36:15 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000