PhotonMapEnergy.h

Go to the documentation of this file.
00001 /* $Id:$ */
00002 
00003 #ifndef __PHOTON_MAP_ENERGY_H
00004 #define __PHOTON_MAP_ENERGY_H
00005 
00006 #include <esg/energy/EnergyCoat.h>
00007 #include <esg/geometry/BVList.h>
00008 #include <esg/geometry/FDH6.h>
00009 #include <esg/energy/Photon.h>
00010 #include <esg/energy/PhotonMap.h>
00011 #include <esg/energy/IrradianceCache.h>
00012 
00017 namespace esg {
00018 
00019 class OGSCENE_EXPORT PhotonMapEnergy : public EnergyCoat {
00020 protected:
00021         vector<Photon>    _globalPhotons;
00022         vector<Photon>    _causticPhotons;
00023         PhotonMap *       _pGlobalMap;
00024         PhotonMap *       _pCausticsMap;
00025         IrradianceCache * _pIrradCache;
00026     
00027 public:
00031         PhotonMapEnergy()
00032             : EnergyCoat(NULL),
00033               _pGlobalMap(NULL),
00034               _pCausticsMap(NULL),
00035               _pIrradCache(NULL) {}
00036 
00041         virtual ~PhotonMapEnergy() {}
00042 
00046         virtual Type type(void) const { return MAP3D; }
00047 
00048 
00052         const PhotonMap* getGlobalMap() const { return _pGlobalMap; }
00053 
00058         const PhotonMap* getCausticsMap() const { return _pCausticsMap; }
00059 
00063         IrradianceCache* const getIrradianceCache() { return _pIrradCache; }
00064         
00072         void storeGlobalPhoton(const Photon& photon) {
00073             if (!_pGlobalMap) _globalPhotons.push_back(photon);
00074         }
00075 
00083         void storeCausticPhoton(const Photon& photon) {
00084             if (!_pCausticsMap) _causticPhotons.push_back(photon);
00085         }
00086 
00093         bool buildGlobalMap() {
00094             if (_pGlobalMap) return false;
00095             _pGlobalMap = new PhotonMap(_globalPhotons);
00096             _globalPhotons.clear();
00097             return true;
00098         }
00099 
00106         bool buildCausticsMap() {
00107             if (_pCausticsMap) return false;
00108             _pCausticsMap = new PhotonMap(_causticPhotons);
00109             _causticPhotons.clear();
00110             return true;
00111         }
00112 
00121         bool buildIrradianceCache(float wFactor, float dist) {
00122             if (_pIrradCache) {
00123                 delete _pIrradCache;
00124                 _pIrradCache = NULL;
00125             }
00126             try {
00127                 _pIrradCache = new IrradianceCache(wFactor, dist);
00128             } catch(invalid_argument e1) {
00129                 cerr << e1.what() << endl;
00130                 return false;
00131             } catch(runtime_error e2) {
00132                 cerr << e2.what() << endl;
00133                 return false;
00134             }
00135             return true;
00136         }
00137 
00141         bool isGlobalMapBuilt() const {
00142             return ((_pGlobalMap) ? true : false);
00143         }
00144         
00148         bool isCausticsMapBuilt() const {
00149             return ((_pCausticsMap) ? true : false);
00150         }
00151 
00155         unsigned numGlobalPhotons() const {
00156             return ((_pGlobalMap) ? _pGlobalMap->numPhotons() : 0);
00157         }
00158 
00162         unsigned numCausticPhotons() const {
00163             return ((_pCausticsMap) ? _pCausticsMap->numPhotons() : 0);
00164         }
00165 
00169         PhotonsIterator* globalMapIterator() const {
00170             return ((_pGlobalMap) ? _pGlobalMap->iterator() : NULL);
00171         }
00172 
00176         PhotonsIterator* causticsMapIterator() const {
00177             return ((_pCausticsMap) ? _pCausticsMap->iterator() : NULL);
00178         }
00179 
00180 
00181     /*
00182      * Average irradiance at the surface point
00183      */
00184     //Vector3 irradiance (const NearestPhotons& /* vicinity of point */,
00185         //              const Vector3*        /* oriented normal   */);
00186 
00187 }; // PhotonMapEnergy
00188 
00189 }; // namespace
00190 
00191 #endif // __PHOTON_MAP_ENERGY_H

Generated on Wed Jun 28 12:24:28 2006 for esg by  doxygen 1.4.6