CSPadPixCoords/test/ex_PixCoords2x1V2.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id$
00004 //
00005 // Description:
00006 //      Test class PixCoords2x1V2 of the CSPadPixCoords packadge
00007 //
00008 // Author List:
00009 //      Mikhail Dubrovin
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 
00017 #include "CSPadPixCoords/PixCoords2x1V2.h"
00018 #include "CSPadPixCoords/Image2D.h"
00019 
00020 #include <string>
00021 #include <iostream>
00022 
00023 //using std::cout;
00024 //using std::endl;
00025 
00026 using namespace std;
00027 
00028 typedef CSPadPixCoords::PixCoords2x1V2 PC2X1;
00029 
00030 //-----------------
00031 
00032 void test01()
00033 {
00034   PC2X1 *pix_coords_2x1 = new PC2X1();  
00035 
00036   pix_coords_2x1 -> print_member_data();
00037   pix_coords_2x1 -> print_coord_arrs_2x1();
00038   //pix_coords_2x1 -> print_xy_corners();
00039 }
00040 
00041 //-----------------
00042 
00043 void test02()
00044 {
00045   PC2X1 *pix_coords_2x1 = new PC2X1();  
00046 
00047   double* x_arr = pix_coords_2x1 -> get_x_map_2x1_pix ();
00048   double* y_arr = pix_coords_2x1 -> get_y_map_2x1_pix ();
00049 
00050   CSPadPixCoords::Image2D<double> *img2d_x = new CSPadPixCoords::Image2D<double>(x_arr, PC2X1::ROWS2X1, PC2X1::COLS2X1);
00051   CSPadPixCoords::Image2D<double> *img2d_y = new CSPadPixCoords::Image2D<double>(y_arr, PC2X1::ROWS2X1, PC2X1::COLS2X1);
00052 
00053   img2d_x  -> saveImageInFile("test-x-array.txt",0);
00054   img2d_y  -> saveImageInFile("test-y-array.txt",0);
00055 }
00056 
00057 
00058 //-----------------
00059 
00060 void test03()
00061 {
00062   enum{ NX=500, NY=500 };
00063   double img_arr[NY][NX];
00064   std::fill_n(&img_arr[0][0], int(NX*NY), double(0));
00065 
00066   PC2X1 *pix_coords_2x1 = new PC2X1(true);  
00067 
00068   // Assignment to coordinates
00069   unsigned NROWS = PC2X1::ROWS2X1;
00070   unsigned NCOLS = PC2X1::COLS2X1;
00071   double   PSIZE = 109.92;
00072 
00073   double angle = 5;
00074 
00075   pix_coords_2x1 -> print_map_min_max(PC2X1::PIX, 0);
00076   pix_coords_2x1 -> print_map_min_max(PC2X1::PIX, angle);
00077   pix_coords_2x1 -> print_map_min_max(PC2X1::UM, 0);
00078   pix_coords_2x1 -> print_map_min_max(PC2X1::UM, angle);
00079 
00080   //double* x_arr = pix_coords_2x1 -> get_x_map_2x1_um ();
00081   //double* y_arr = pix_coords_2x1 -> get_y_map_2x1_um ();
00082 
00083   double* x_arr = pix_coords_2x1 -> get_coord_map_2x1 (PC2X1::AXIS_X, PC2X1::UM, angle);
00084   double* y_arr = pix_coords_2x1 -> get_coord_map_2x1 (PC2X1::AXIS_Y, PC2X1::UM, angle);
00085 
00086   for (unsigned r=0; r<NROWS; r++){
00087   for (unsigned c=0; c<NCOLS; c++){
00088 
00089     int ix = 200 + (int)(x_arr[r*NCOLS + c] / PSIZE);
00090     int iy = 200 + (int)(y_arr[r*NCOLS + c] / PSIZE);
00091 
00092     img_arr[ix][iy] = ix;
00093   }
00094   }
00095 
00096   CSPadPixCoords::Image2D<double> *img2d = new CSPadPixCoords::Image2D<double>(&img_arr[0][0],NY,NX);
00097   img2d -> saveImageInFile("test-img.txt",0);
00098 }
00099 
00100 //-----------------
00101 
00102 int main ()
00103 {
00104   test01();
00105   //test02();
00106   test03();
00107 
00108   return 0;
00109 }
00110 
00111 //-----------------
00112 

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7