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

polardata.h

Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Grant Tang, 02/06/2006 (gtang@bcm.edu)
00007  * Copyright (c) 2000-2006 Baylor College of Medicine
00008  * 
00009  * This software is issued under a joint BSD/GNU license. You may use the
00010  * source code in this file under either license. However, note that the
00011  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00012  * so you are responsible for compliance with the licenses of these packages
00013  * if you opt to use BSD licensing. The warranty disclaimer below holds
00014  * in either instance.
00015  * 
00016  * This complete copyright notice must be included in any revised version of the
00017  * source code. Additional authorship citations may be added, but existing
00018  * author citations must be preserved.
00019  * 
00020  * This program is free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by
00022  * the Free Software Foundation; either version 2 of the License, or
00023  * (at your option) any later version.
00024  * 
00025  * This program is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00028  * GNU General Public License for more details.
00029  * 
00030  * You should have received a copy of the GNU General Public License
00031  * along with this program; if not, write to the Free Software
00032  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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__

Generated on Tue Jun 11 13:46:16 2013 for EMAN2 by  doxygen 1.3.9.1