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

vuSphericLightfieldBasicConverter.cpp

Go to the documentation of this file.
00001 #include "vuSphericLightfieldBasicConverter.h"
00002 
00003 void vuBasicLightfieldConverter::convert(const char *inFile,
00004                                          const char *outFile,
00005                                          bool isVerbose) 
00006 {
00007 }
00008 
00009 template <int SI, class TI, int SO, class TO>
00010 bool vuSphericLightfieldBasicConverter<SI,TI,SO,TO>::
00011 _areViewsValid(vuSphericView<SI,TI> *in, vuSphericView<SO,TO> *out)
00012 {
00013   if (in == NULL || out == NULL)                    return false;
00014   if ((in->getWidth()==0) || (in->getHeight()==0))  return false;
00015   if (in->getWidth()  != out->getWidth())           return false;
00016   if (in->getHeight() != out->getHeight())          return false;
00017 
00018   return true;
00019 }
00020 
00021 template <int SI, class TI, int SO, class TO>
00022 void vuSphericLightfieldBasicConverter<SI,TI,SO,TO>::
00023 convert(const char *inFile, const char *outFile, bool isVerbose)
00024 {
00025   vuSphericLightfieldFile<SI,TI> in(inFile);
00026 
00027   if (!in.open())       exitWithHint(in);
00028   if (!in.readHeader()) exitWithHint(in);
00029 
00030   dword width  = in.getWidth();
00031   dword height = in.getHeight();
00032   dword cnt    = in.getNumberOfViews();
00033 
00034   if (isVerbose) {
00035     cerr << "Input file: resolution= " << width << "x" << height << endl;
00036     cerr << "                 views= " << cnt   << endl;
00037   }
00038 
00039   vuSphericLightfieldFile<SO, TO> out(width, height, cnt, outFile);
00040 
00041   if (!out.open())        exitWithHint(out);
00042   if (!out.writeHeader()) exitWithHint(out);
00043 
00044   vuSphericView<SI,TI> *inView  = new vuSphericView<SI, TI>;
00045   vuSphericView<SO,TO> *outView = NULL;
00046 
00047   outView = new vuSphericView<SO,TO>(width, height);
00048 
00049   for (dword i=0; i<cnt; i++) {
00050     if (isVerbose) cerr << "view: " << i;
00051 
00052     if (!in.readView(inView))
00053       cerr << "Warning: Could not read view " << i << endl;
00054     else {
00055       outView->setLookFrom(inView->getLookFrom());
00056       outView->setUp(inView->getUp());
00057       _convert(inView, outView);
00058       if (!out.writeView(outView)) exitWithHint(out);
00059     }
00060 
00061     if (isVerbose) cerr << endl;
00062   }
00063   in.close();
00064   out.close();
00065 
00066   CHECKNDELETE(inView);
00067   CHECKNDELETE(outView);
00068 }
00069 
00070 template <int SI, class TI, int SO, class TO>
00071 void vuSphericLightfieldBasicConverter<SI,TI,SO,TO>::
00072 exitWithHint(vuLightfieldFile &file)
00073 {
00074   cerr << "Error while processing file '" << file.getFileName();
00075   cerr << "': " << file.getErrorMessage() << endl;
00076   exit(1);
00077 }
00078 

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