00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef eman__polardata_h__
00037 #define eman__polardata_h__
00038
00039 #include <map>
00040 #include <vector>
00041 #include "log.h"
00042 #include "exception.h"
00043
00044 using std::map;
00045 using std::vector;
00046
00047 namespace EMAN
00048 {
00049 static const int MAXFFT=32768;
00050 class EMData;
00051
00053 class UnevenMatrix
00054 {
00055 public:
00056 UnevenMatrix() : data(0) {
00057 printf("Welcome to UnevenMatrix\n");
00058 }
00059 virtual ~UnevenMatrix() {
00060 if(data) {
00061 delete data;
00062 data = 0;
00063 }
00064 printf("Destructor of UnevenMatrix...\n");
00065 }
00066
00070 inline int get_xsize(int y) {
00071 int xsize = desc_data[y].x1 - desc_data[y].x0;
00072 if( xsize <= 0 ) {
00073 throw InvalidValueException(xsize, "xsize <= 0");
00074 }
00075 else {
00076 return xsize;
00077 }
00078 }
00079
00083 inline int get_xmin(int y) {
00084 return desc_data[y].x0;
00085 }
00086
00090 inline int get_xmax(int y) {
00091 return desc_data[y].x1 - 1;
00092 }
00093
00096 inline int get_size() {
00097 return tot_size;
00098 }
00099
00100 #ifdef DEBUG
00101 void print_UnevenMatrix() {
00102 printf("print function in UnevenMatrix\n");
00103 }
00104 #endif //DEBUG
00105
00106 protected:
00110 void alloc_data();
00111
00114 struct Xdim {
00115 int x0;
00116 int x1;
00117 Xdim() {}
00118 Xdim(int i0, int i1) : x0(i0), x1(i1) {
00119 if( x1 <= x0 ) {
00120 LOGERR("x dimension error ... x0(%d) > x1(%d)", x0, x1);
00121 }
00122 }
00123 };
00124
00127 float * data;
00128
00130 map< int, Xdim > desc_data;
00131
00133 int tot_size;
00134 };
00135
00140 class PolarData : public UnevenMatrix
00141 {
00142 public:
00143 PolarData() {printf("Welcome to PolarData class... \n");}
00144
00151 PolarData(EMData * image, int xcen, int ycen, string mode);
00152
00153 virtual ~PolarData() {
00154 printf("Destructor of PolarData...\n");
00155 }
00156
00157 #ifdef DEBUG
00158
00159 void print_polar() {
00160 printf("PolarData class is a specialized image class for storing the \n");
00161 printf("results of a transform from EMData to polar coordinates, currently \n");
00162 printf("support 2D only. Data on x dimension may be variable size, which \n");
00163 printf("is defined in map< int, Xdim > desc_data\n");
00164 }
00165
00166 int test_init_desc_data();
00167 #endif //DEBUG
00168
00169 private:
00171 map< int, float > weight;
00172
00179 vector<int> Numrinit(int first_ring, int last_ring, int skip, string mode);
00180
00184 int log2(int n);
00185
00190 vector<float> ringwe( vector<int> numr, string mode );
00191 };
00192
00193 }
00194
00195
00196 #endif //eman__polardata_h__