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

vuSphericLightfieldFourier.cpp

Go to the documentation of this file.
00001 #include "vuSphericLightfieldFourier.h"
00002 #include "../vuFixelType.h"
00003 
00004 template <int SI, class TI, int SO, class TO>
00005 vuSphericLightfieldFourier<SI,TI,SO,TO>::vuSphericLightfieldFourier()
00006 {
00007   m_PlanExists = false;
00008 }
00009 
00010 template <int SI, class TI, int SO, class TO>
00011 vuSphericLightfieldFourier<SI,TI,SO,TO>::~vuSphericLightfieldFourier()
00012 {
00013   if (m_PlanExists) {
00014     fftwnd_destroy_plan(m_Plan);
00015     fftwnd_destroy_plan(m_PlanForward);
00016     m_PlanExists = false;
00017   }
00018 }
00019 
00020 template <int SI, class TI, int SO, class TO>
00021 void vuSphericLightfieldFourier<SI,TI,SO,TO>::_ensurePlan(dword width,
00022                                                           dword height)
00023 {
00024   if (!m_PlanExists) {
00025     //cerr << "creating plan... ";
00026     m_Plan = fftw2d_create_plan(height, width, FFTW_BACKWARD, FFTW_MEASURE
00027                                 | FFTW_IN_PLACE);
00028 
00029     m_PlanForward = fftw2d_create_plan(height, width, FFTW_FORWARD,
00030                                        FFTW_MEASURE | FFTW_IN_PLACE);
00031     m_PlanExists = true;
00032     //cerr << "Done." << endl;
00033   }
00034 }
00035 
00036 template <int SI, class TI, int SO, class TO>
00037 void vuSphericLightfieldFourier<SI,TI,SO,TO>::_convert(vuSphericView<SI,TI>*in,
00038                                                       vuSphericView<SO,TO>*out)
00039 {
00040   if (!_areViewsValid(in, out)) return;
00041 
00042   dword width  = in->getWidth();
00043   dword height = in->getHeight();
00044 
00045   _ensurePlan(width, height);
00046 
00047   if ((SI == 1) && (SO == 2)) {
00048     const TI *src = in->getMap()->getBuffer();
00049     TO      *dest = out->getMap()->getBuffer();
00050 
00051     for (dword j=0; j<height; j++) {
00052       for (dword i=0; i<width; i++) {
00053         *dest = vuFixelTypeConverter<TI,TO>::getValue(*src);
00054         dest++;
00055         *dest = (TO)0;
00056         dest++; src++;
00057       }
00058     }
00059     //cerr << "AAABB++++++++++++++++++" << endl;
00060     fftwnd_one(m_PlanForward, (fftw_complex*)out->getMap()->getBuffer(), NULL);      
00061     fftwnd_one(m_Plan, (fftw_complex*)out->getMap()->getBuffer(), NULL);
00062 
00063     vuFixelMap<SO,TO> *map = out->getMap();
00064 
00065     *map *= ((float)1/(float)(width*height));
00066   }
00067   else if ((SI == 2) && (SO == 2)) {
00068     const TI *src = in->getMap()->getBuffer();
00069     TO      *dest = out->getMap()->getBuffer();
00070 
00071     for (dword j=0; j<height; j++) {
00072       for (dword i=0; i<width; i++) {
00073         *(dest++) = vuFixelTypeConverter<TI,TO>::getValue(*(src++));
00074         *(dest++) = vuFixelTypeConverter<TI,TO>::getValue(*(src++));
00075       }
00076     }
00077     fftwnd_one(m_Plan, (fftw_complex*)out->getMap()->getBuffer(), NULL);
00078   }
00079 
00080 }
00081 
00082 vuBasicLightfieldConverter*
00083 vuSphericLightfieldFourierFactory::getConverter(vuString &name)
00084 {
00085   if      (name == "1F1F")
00086     return new vuSphLFFourier1F1F();
00087   else if (name == "1F2F")
00088     return new vuSphLFFourier1F2F();
00089   //    else if (name == "1F3F")
00090   //  return new vuSphLFFourier1F3F();
00091   //else if (name == "2F1F")
00092   //  return new vuSphLFFourier2F1F();
00093   else if (name == "2F2F")
00094     return new vuSphLFFourier2F2F();
00095   //else if (name == "2F3F")
00096   //  return new vuSphLFFourier2F3F();
00097   //else if (name == "3F1F")
00098   //  return new vuSphLFFourier3F1F();
00099   //else if (name == "3F2F")
00100   //  return new vuSphLFFourier3F2F();
00101   //else if (name == "3F3F")
00102   //  return new vuSphLFFourier3F3F();
00103   else if (name == "1B2F")
00104     return new vuSphLFFourier1B2F();
00105   else 
00106     return NULL;
00107 }

Generated on Wed Dec 15 21:20:37 2004 for vuVolume by  doxygen 1.3.9.1