Changeset 2116


Ignore:
Timestamp:
02/15/07 00:35:41 (17 years ago)
Author:
mattausch
Message:

implemented hashpvs

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
4 added
31 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Containers.h

    r1344 r2116  
    6969 
    7070/// vertex index container 
    71 //typedef std::vector<short> VertexIndexContainer; 
    7271typedef std::vector<int> VertexIndexContainer; 
    7372 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h

    r2091 r2116  
    77 
    88 
    9  
    109#include "Material.h" 
    1110#include "Containers.h" 
    12 #include "VssRay.h" 
     11//#include "VssRay.h" 
    1312#include "AxisAlignedBox3.h" 
    1413 
     
    3130class BvHierarchy; 
    3231class TransformedMeshInstance; 
     32class MeshInstance; 
     33class VssRay; 
     34//class Material; 
    3335 
     36struct VssRayContainer; 
    3437 
    3538class Exporter 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2053 r2116  
    55#include "ViewCellsManager.h" 
    66#include "SceneGraph.h" 
    7 #include "Pvs.h" 
     7//#include "ObjectPvs.h" 
    88#include "Viewcell.h" 
    99#include "Beam.h" 
     
    9393 
    9494  if (mViewCellsManager->GetViewCellPoints()->size()) 
    95         mPvsStatFrames = mViewCellsManager->GetViewCellPoints()->size(); 
     95        mPvsStatFrames = (int)mViewCellsManager->GetViewCellPoints()->size(); 
    9696  else 
    9797        Environment::GetSingleton()->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r2050 r2116  
    77#include "Renderer.h" 
    88#include "Beam.h" 
    9 #include "Pvs.h" 
     9#include "ObjectPvs.h" 
    1010 
    1111 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2053 r2116  
    1111#include "SamplingStrategy.h" 
    1212#include "BvHierarchy.h" 
     13#include "Polygon3.h" 
    1314 
    1415 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h

    r2102 r2116  
    22#define __HASHPVS_H 
    33 
    4 #include <hash_map> 
    5 #include <vector> 
     4//#include <hash_map> 
     5#include <hash_set> 
    66#include "common.h" 
    77#include <math.h> 
     
    1313namespace GtpVisibilityPreprocessor { 
    1414 
    15 class KdNode; 
    16 class BspNode; 
    17 class Ray; 
    18 class Intersectable; 
    19 class ViewCell; 
     15 
     16template<typename T> 
     17struct my_hash_compare 
     18{ 
     19   enum 
     20   { 
     21      bucket_size = 4, 
     22      min_buckets = 80 
     23   }; 
     24 
     25   size_t operator()(T a) const 
     26   { 
     27      size_t h = (size_t)(a->GetId());// % 2000; 
     28      //for (; *s; ++s) 
     29      //   h = 5 * h + *s; 
     30      return h; 
     31   } 
     32 
     33   bool operator()(T a, T b) const 
     34   { 
     35      return a < b; 
     36   } 
     37}; 
     38 
     39/* 
     40template<typename T> 
     41struct gt 
     42{ 
     43        bool operator() (T s1, T s2) const 
     44        { 
     45                return s1 > s2; 
     46        } 
     47}; 
     48*/ 
     49//#define HASH_SET stdext::hash_set<T, stdext::hash_compare<T, gt<T> > > 
     50#define HASH_SET stdext::hash_set<T, my_hash_compare<T> > 
     51 
     52/** Iterator over a hash pvs. 
     53*/ 
     54template<typename T, typename S> 
     55class HashPvsIterator 
     56{ 
     57public: 
     58         
     59        HashPvsIterator<T, S>() {} 
     60 
     61        HashPvsIterator<T, S>(const typename HASH_SET::const_iterator &itCurrent, 
     62                                                  const typename HASH_SET::const_iterator &itEnd): 
     63        mItCurrent(itCurrent), mItEnd(itEnd) 
     64        { 
     65        } 
     66 
     67        bool HasMoreEntries() const  
     68        { 
     69                return (mItCurrent != mItEnd); 
     70        } 
     71 
     72        PvsEntry<T, S> Next() 
     73        { 
     74                // hack: create new pvs entry 
     75                return PvsEntry<T, S>(*(mItCurrent) ++, S(0.0)); 
     76        } 
     77         
     78private: 
     79        typename HASH_SET::const_iterator mItCurrent; 
     80        typename HASH_SET::const_iterator mItEnd; 
     81}; 
    2082 
    2183 
     
    2385        mainly from a view cell, but also e.g., from objects. 
    2486*/ 
    25 template<typename T> 
    26 class HashPvs: public PvsBase<T> 
    27 { 
    28         template<typename T> 
    29                 friend class PvsIterator2; 
     87template<typename T, typename S> 
     88class HashPvs//: public PvsBase<T> 
     89{ 
     90        template<typename T, typename S> friend class HashPvsIterator; 
    3091 
    3192public: 
    3293 
     94        //HashPvs(): mEntries((Intersectable *)100) {}; 
    3395        HashPvs() {}; 
    3496        //virtual ~HashPvs() {}; 
     
    40102                @returns contribution of sample (0 or 1) 
    41103        */ 
    42         float AddSample(T sample); 
     104        float AddSample(T sample, const float pdf); 
    43105 
    44106        /** Adds sample to PVS without checking for presence of the sample 
    45107                warning: pvs remains unsorted! 
    46108        */ 
    47         void AddSampleDirty(T sample); 
     109        void AddSampleDirty(T sample, const float pdf); 
    48110 
    49111        /** Adds sample dirty (on the end of the vector) but 
    50112                first checks if sample is already in clean part of the pvs. 
    51113        */ 
    52         bool AddSampleDirtyCheck(T sample); 
     114        bool AddSampleDirtyCheck(T sample, const float pdf); 
    53115 
    54116        /** Sort pvs entries - this should always be called after a 
     
    61123        void Clear(const bool trim = true); 
    62124 
    63         //static void Merge(PvsBase &mergedPvs, const PvsBase &a, const PvsBase &b); 
    64  
    65125        bool IsDirty() const; 
    66126 
    67127        bool RequiresResort() const; 
    68128 
    69         //typename PvsIterator<T> GetIterator() const; 
    70  
     129        /** Finds sample in PVS. 
     130                @param checkDirty if dirty part of the pvs should be checked for entry  
     131                (warning: linear runtime in dirty part) 
     132                @returns iterator on the sample if found, else the place where  
     133                it would be added in the sorted vector. 
     134        */ 
     135        bool Find(T sample, typename HASH_SET::iterator &it); 
     136 
     137        typename HashPvsIterator<T, S> GetIterator() const; 
     138 
     139        /** Compute continuous PVS difference  
     140        */ 
     141        float GetPvsHomogenity(HashPvs<T, S> &pvs); 
     142 
     143        static void Merge(HashPvs<T, S> &mergedPvs,  
     144                                          const HashPvs<T, S> &a,  
     145                                          const HashPvs<T, S> &b); 
     146 
     147        static int GetEntrySizeByte();  
     148        static float GetEntrySize(); 
     149 
     150        bool GetSampleContribution(T sample, 
     151                                                   const float pdf, 
     152                                                           float &contribution); 
     153 
     154        int GetSamples() const 
     155        { 
     156                return mSamples; 
     157        } 
     158 
     159        void MergeInPlace(const HashPvs<T, S> &a) 
     160        { 
     161                cerr << "not implemented yet" << endl; 
     162        } 
     163 
     164        bool RequiresResortLog() const 
     165        { 
     166                return false; 
     167        } 
     168 
     169        void Reserve(const int n)  
     170        {  
     171                // not necessary 
     172        } 
     173 
     174        /** Sort pvs entries assume that the pvs contains unique entries 
     175        */ 
     176        void SimpleSort() 
     177        { 
     178                // not necessary 
     179        } 
     180 
     181        int SubtractPvs(const HashPvs<T, S> &pvs) 
     182        { 
     183                cerr << "not yet implemented" << endl; 
     184                return 0; 
     185        } 
     186 
     187        /** Compute continuous PVS difference  
     188        */ 
     189        void ComputeContinuousPvsDifference(HashPvs<T, S> &pvs,  
     190                                                                                float &pvsReduction, 
     191                                                                                float &pvsEnlargement) 
     192        { 
     193                cerr << "not yet implemented" << endl; 
     194        } 
    71195protected: 
    72196 
    73         /// vector of PVS entries 
    74         vector<T> mEntries;  
     197        /// hash table of PVS entries 
     198        HASH_SET mEntries;  
    75199 
    76200        /// Number of samples used to create the PVS 
     
    79203 
    80204 
    81 template <typename T> 
    82 int HashPvs<T>::GetSize() const 
    83 { 
    84         return 0; 
    85 } 
    86  
    87  
    88 template <typename T> 
    89 bool HashPvs<T>::Empty() const 
     205template <typename T, typename S> 
     206bool HashPvs<T, S>::Find(T sample, typename HASH_SET::iterator &it) 
     207{ 
     208        it = mEntries.find(sample); 
     209 
     210        // already in map 
     211        return (it != mEntries.end()); 
     212} 
     213 
     214 
     215template <typename T, typename S> 
     216int HashPvs<T, S>::GetSize() const 
     217{ 
     218        return (int)mEntries.size(); 
     219} 
     220 
     221 
     222template <typename T, typename S> 
     223bool HashPvs<T, S>::Empty() const 
     224{ 
     225        return mEntries.empty(); 
     226} 
     227 
     228 
     229template <typename T, typename S> 
     230float HashPvs<T, S>::AddSample(T sample, const float pdf) 
     231{ 
     232        HASH_SET::iterator it; 
     233 
     234        if (Find(sample, it)) 
     235                return 0.0f; 
     236         
     237        mEntries.insert(sample); 
     238        return 1.0f; 
     239} 
     240         
     241 
     242template <typename T, typename S> 
     243void HashPvs<T, S>::AddSampleDirty(T sample, const float pdf) 
     244{ 
     245        HASH_SET::iterator it; 
     246 
     247        // not yet in map 
     248        if (!Find(sample, it)) 
     249        { 
     250                mEntries.insert(sample);         
     251        } 
     252} 
     253 
     254 
     255template <typename T, typename S> 
     256bool HashPvs<T, S>::AddSampleDirtyCheck(T sample,  
     257                                                                                const float pdf) 
     258{ 
     259        HASH_SET::iterator it; 
     260 
     261        // already in map 
     262        if (Find(sample, it)) 
     263                return false; 
     264         
     265        mEntries.insert(sample); 
     266        return true; 
     267} 
     268 
     269 
     270template <typename T, typename S> 
     271void HashPvs<T, S>::Sort() 
     272{ 
     273} 
     274 
     275 
     276template <typename T, typename S> 
     277void HashPvs<T, S>::Clear(const bool trim = true) 
     278{ 
     279        mEntries.clear(); 
     280} 
     281 
     282 
     283template <typename T, typename S> 
     284bool HashPvs<T, S>::IsDirty() const 
    90285{ 
    91286        return false; 
     
    93288 
    94289 
    95 template <typename T> 
    96 float HashPvs<T>::AddSample(T sample) 
    97 { 
    98         return 0; 
    99 } 
    100          
    101  
    102 template <typename T> 
    103 void HashPvs<T>::AddSampleDirty(T sample) 
    104 { 
    105 } 
    106  
    107  
    108 template <typename T> 
    109 bool HashPvs<T>::AddSampleDirtyCheck(T sample) 
     290template <typename T, typename S> 
     291bool HashPvs<T, S>::RequiresResort() const 
    110292{ 
    111293        return false; 
     
    113295 
    114296 
    115 template <typename T> 
    116 void HashPvs<T>::Sort() 
    117 { 
    118 } 
    119  
    120  
    121 template <typename T> 
    122 void HashPvs<T>::Clear(const bool trim = true) 
    123 { 
    124 } 
    125  
    126  
    127 template <typename T> 
    128 bool HashPvs<T>::IsDirty() const 
    129 { 
    130         return false; 
    131 } 
    132  
    133  
    134 template <typename T> 
    135 bool HashPvs<T>::RequiresResort() const 
    136 { 
    137         return false; 
    138 } 
    139  
    140 //typename PvsIterator<T> GetIterator() const; 
     297template <typename T, typename S> 
     298typename HashPvsIterator<T, S> HashPvs<T, S>::GetIterator() const 
     299{ 
     300        HashPvsIterator<T, S> pit(mEntries.begin(), mEntries.end()); 
     301 
     302        return pit; 
     303} 
     304 
     305 
     306template <typename T, typename S> 
     307float HashPvs<T, S>::GetEntrySize() 
     308{ 
     309        return (float)(sizeof(T)) / float(1024 * 1024); 
     310} 
     311 
     312 
     313template <typename T, typename S> 
     314int HashPvs<T, S>::GetEntrySizeByte() 
     315{ 
     316        return sizeof(T); 
     317} 
     318 
     319 
     320template <typename T, typename S> 
     321float HashPvs<T, S>::GetPvsHomogenity(HashPvs<T, S> &pvs)  
     322{ 
     323        float pvsReduction, pvsEnlargement; 
     324 
     325        ComputeContinuousPvsDifference(pvs,     pvsReduction, pvsEnlargement); 
     326 
     327        return pvsReduction + pvsEnlargement; 
     328} 
     329 
     330 
     331template <typename T, typename S> 
     332bool HashPvs<T, S>::GetSampleContribution(T sample, 
     333                                                                          const float pdf, 
     334                                                                          float &contribution)  
     335{ 
     336        HASH_SET::iterator it; 
     337        const bool entryFound = Find(sample, it); 
     338 
     339        if (entryFound)   
     340        { 
     341                contribution = 0.0f; 
     342                return false; 
     343        } 
     344        else  
     345        { 
     346                contribution = 1.0f; 
     347                return true; 
     348        } 
     349} 
     350 
     351 
     352template <typename T, typename S> 
     353void HashPvs<T, S>::Merge(HashPvs<T, S> &mergedPvs,  
     354                                                  const HashPvs<T, S> &a,  
     355                                                  const HashPvs<T, S> &b) 
     356{ 
     357        HASH_SET::const_iterator ait, ait_end = a.mEntries.end(); 
     358 
     359        for (ait = a.mEntries.begin(); ait != ait_end; ++ ait) 
     360        { 
     361                mergedPvs.AddSample(*ait, 1.0f); 
     362        } 
     363 
     364        HASH_SET::const_iterator bit, bit_end = b.mEntries.end(); 
     365 
     366        for (bit = b.mEntries.begin(); bit != bit_end; ++ bit) 
     367        { 
     368                mergedPvs.AddSample(*bit, 1.0f); 
     369        } 
     370 
     371        //cerr << "not implemented" << endl;  
     372} 
    141373 
    142374} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r2094 r2116  
    4343class ViewCellsParseHandlers; 
    4444class TraversalTree; 
    45  
     45class ObjectPvs; 
    4646 
    4747 
     
    679679        ViewCellContainer mOldViewCells; 
    680680 
    681         ObjectPvs mOldPvs; 
     681        //ObjectPvs mOldPvs; 
    682682}; 
    683683 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r2113 r2116  
    33 
    44#include "AxisAlignedBox3.h" 
    5 #include "Pvs.h" 
    65#include <set> 
    7 #include "VssRay.h" 
     6//#include "VssRay.h" 
    87#include "Mailable.h" 
    98 
     
    1514class BvhNode; 
    1615class Intersectable; 
     16class VssRay; 
    1717struct Face; 
    1818 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectionBoundingBoxConverter.cpp

    r2113 r2116  
    11#include "IntersectionBoundingBoxConverter.h" 
    22#include "KdTree.h" 
     3#include "IntersectableWrapper.h" 
    34 
    45 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r2091 r2116  
    77#include "ViewCell.h" 
    88#include "Beam.h" 
     9#include "ViewCell.h" 
     10#include "IntersectableWrapper.h" 
    911 
    1012 
     
    8587{ 
    8688    DEL_PTR(mRoot); 
    87  
    8889        CLEAR_CONTAINER(mKdIntersectables); 
    8990} 
     
    14571458KdTree::GetOrCreateKdIntersectable(KdNode *node) 
    14581459{ 
    1459  
    1460   if (node == NULL) 
    1461         return NULL; 
    1462  
    1463   if (node->mIntersectable == NULL) { 
    1464         // not in map => create new entry 
    1465         node->mIntersectable = new KdIntersectable(node, GetBox(node)); 
    1466         mKdIntersectables.push_back(node->mIntersectable); 
    1467   } 
    1468  
    1469   return node->mIntersectable; 
     1460        if (node == NULL) 
     1461                return NULL; 
     1462 
     1463        if (node->mIntersectable == NULL)  
     1464        { 
     1465                // not in map => create new entry 
     1466                node->mIntersectable = new KdIntersectable(node, GetBox(node)); 
     1467                mKdIntersectables.push_back(node->mIntersectable); 
     1468                node->mIntersectable->SetId((int)mKdIntersectables.size()); 
     1469        } 
     1470 
     1471        return node->mIntersectable; 
    14701472} 
    14711473 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r2113 r2116  
    88#include "AxisAlignedBox3.h" 
    99#include "Ray.h" 
    10 #include "Pvs.h" 
     10//#include "ObjectPvs.h" 
    1111#include "Viewcell.h" 
    1212#include "VssRay.h" 
    13 #include "IntersectableWrapper.h" 
    14  
     13//#include "IntersectableWrapper.h" 
     14#include "gzstream.h" 
    1515 
    1616namespace GtpVisibilityPreprocessor { 
    1717 
    18    
    19   class KdNode; 
    20   class KdLeaf; 
    21   class KdInterior; 
    22   class Intersectable; 
    23   class Beam; 
    24  
    25   class KdTree; 
     18class KdNode; 
     19class KdLeaf; 
     20class KdInterior; 
     21class Intersectable; 
     22class KdIntersectable; 
     23class Beam; 
     24class KdTree; 
     25//class KdViewCell; 
    2626   
    2727  //  KdTree *SceneKdTree; 
     
    213213         
    214214  /** PVS consisting of visible KdTree nodes */ 
    215   KdPvs mKdPvs; 
     215  //KdPvs mKdPvs; 
    216216 
    217217  /// pvs of view cells seeing this node. 
     
    619619  AxisAlignedBox3 mBox; 
    620620  KdTreeStatistics mStat; 
     621 
    621622public: 
    622623  /// stores the kd node intersectables used for pvs 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjExporter.h

    r1694 r2116  
    1212#include "Containers.h" 
    1313#include "VssRay.h" 
    14 #include "ViewCell.h" 
     14//#include "ViewCell.h" 
    1515 
    1616namespace GtpVisibilityPreprocessor { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp

    r2100 r2116  
    2727 
    2828 
     29int MailablePvsData::sMailId = 1; 
     30int MailablePvsData::sReservedMailboxes = 1; 
     31 
     32 
    2933        //////////// 
    3034//-- static members 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp

    r2053 r2116  
    1616{ 
    1717} 
     18 
    1819 
    1920Polygon3::Polygon3(const VertexContainer &vertices):  
     
    6768} 
    6869 
     70 
     71Polygon3::~Polygon3()  
     72{ 
     73        DEL_PTR(mPlane); 
     74} 
    6975 
    7076Plane3 Polygon3::GetSupportingPlane()// const 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h

    r1420 r2116  
    33 
    44 
    5 //#include <iostream> 
    6 //#include <math.h> 
    7 //#include "common.h" 
     5#include <iostream> 
     6#include "common.h" 
    87#include "Containers.h" 
    9 #include "Mesh.h" 
     8#include "Vector3.h" 
    109#include <iomanip> 
    1110 
     
    1817class AxisAlignedBox3; 
    1918class Ray; 
    20 //typedef Vertex3 Vector3; 
     19class Mesh; 
     20class MeshInstance; 
     21class Material; 
     22struct Triangle3; 
     23 
    2124 
    2225/** Class representing a planar convex polygon in 3d. 
     
    4144        Polygon3(const Triangle3 &tri); 
    4245 
    43         ~Polygon3() {DEL_PTR(mPlane);} 
     46        ~Polygon3(); 
    4447         
    4548        /** Copies all the vertices of the face. 
     
    173176 
    174177        //s << setprecision(6) << "Polygon:\n"; 
    175         for (it = A.mVertices.begin(); it != A.mVertices.end(); ++it) 
     178        for (it = A.mVertices.begin(); it != A.mVertices.end(); ++ it) 
     179        { 
    176180                s << *it << " "; 
    177          
     181        } 
     182 
    178183        return s; 
    179184} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2115 r2116  
    2020                                Name="VCCLCompilerTool" 
    2121                                Optimization="0" 
    22                                 AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost" 
    23                                 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;" 
     22                                AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;Timer" 
     23                                PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_HASH_PVS" 
    2424                                MinimalRebuild="TRUE" 
    2525                                BasicRuntimeChecks="3" 
     
    7272                                OptimizeForWindowsApplication="TRUE" 
    7373                                AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;Timer" 
    74                                 PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 
     74                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_HASH_PVS" 
    7575                                ExceptionHandling="TRUE" 
    7676                                RuntimeLibrary="2" 
     
    383383                        </File> 
    384384                        <File 
     385                                RelativePath=".\BitVectorPvs.h"> 
     386                        </File> 
     387                        <File 
    385388                                RelativePath="..\src\BoostPreprocessorThread.cpp"> 
    386389                        </File> 
     
    581584                        </File> 
    582585                        <File 
    583                                 RelativePath=".\ObjectsParser.cpp"> 
    584                         </File> 
    585                         <File 
    586                                 RelativePath=".\ObjectsParser.h"> 
    587                         </File> 
    588                         <File 
    589                                 RelativePath=".\ObjectsParserXerces.h"> 
     586                                RelativePath=".\ObjectPvs.cpp"> 
     587                        </File> 
     588                        <File 
     589                                RelativePath=".\ObjectPvs.h"> 
    590590                        </File> 
    591591                        <File 
     
    767767                        </File> 
    768768                        <File 
    769                                 RelativePath="..\src\Pvs.cpp"> 
    770                         </File> 
    771                         <File 
    772769                                RelativePath="..\src\Pvs.h"> 
    773770                        </File> 
    774771                        <File 
    775772                                RelativePath=".\PvsBase.h"> 
     773                        </File> 
     774                        <File 
     775                                RelativePath=".\PvsDefinitions.h"> 
    776776                        </File> 
    777777                        <File 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r2100 r2116  
    1 #ifndef __PVS_H 
    2 #define __PVS_H 
    3  
    4 #include <map> 
     1#ifndef __VERBOSEPVS_H 
     2#define __VERBOSEPVS_H 
     3 
    54#include <vector> 
    65#include "common.h" 
    76#include <math.h> 
     7#include "PvsBase.h" 
     8 
     9 
    810using namespace std; 
    911 
    1012namespace GtpVisibilityPreprocessor { 
    11  
    12 class KdNode; 
    13 class BspNode; 
    14 class Ray; 
    15 class Intersectable; 
    16 class ViewCell; 
    17  
    18  
    19 /** Information stored with a PVS entry. Consists of the number 
    20         the object was seen from the view cell. 
    21 */ 
    22 template<typename T, typename S> 
    23 struct PvsEntry  
    24 { 
    25 public: 
    26  
    27         PvsEntry() {} 
    28  
    29         PvsEntry(T sample, const S &data): mObject(sample), mData(data) {} 
    30  
    31         T mObject; 
    32         S mData; 
    33  
    34         template<typename T, typename S> 
    35         friend int operator< (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b); 
    36         template<typename T, typename S> 
    37         friend int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b); 
    38 }; 
    39  
    40  
    41 template<typename T, typename S> 
    42 int operator< (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) 
    43 { 
    44         return a.mObject < b.mObject; 
    45 }  
    46  
    47 template<typename T, typename S> 
    48 int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) 
    49 { 
    50         return a.mObject == b.mObject; 
    51 }  
    52  
    53  
    54 template<typename T, typename S> 
    55 struct LtSample 
    56 { 
    57     bool operator()(const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) const 
    58     { 
    59                 return a.mObject < b.mObject; 
    60         }  
    61 }; 
    62  
    63 template<typename T, typename S> 
    64 int equalSample (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) 
    65 { 
    66         return a.mObject == b.mObject; 
    67 }  
    68  
    69 /** Information stored with a PVS entry. Consists of the number 
    70         the object was seen from the view cell. 
    71 */ 
    72 struct PvsData { 
    73 public: 
    74         PvsData() {} 
    75         PvsData(const float sumPdf): 
    76         mSumPdf(sumPdf) {} 
    77          
    78         // $$JB in order to return meaningfull values 
    79         // it assumes that the sum pdf has been normalized somehow!!! 
    80         inline float GetVisibility()  
    81         {  
    82                 return mSumPdf;  
    83         } 
    84  
    85         /// sum of probability density of visible sample rays 
    86         float mSumPdf; 
    87 }; 
    88  
    89  
    90 class MailablePvsData  
    91 { 
    92 public: 
    93         // sum of probability density of visible sample rays 
    94         float mSumPdf; 
    95         int mCounter; 
    96  
    97         MailablePvsData() {} 
    98         MailablePvsData(const float sumPdf): 
    99         mSumPdf(sumPdf) {} 
    100  
    101         // $$JB in order to return meaningfull values 
    102         // it assumes that the sum pdf has been normalized somehow!!! 
    103         float GetVisibility()  
    104         {  
    105                 return mSumPdf;  
    106         } 
    107  
    108         /////////////// 
    109         //  Mailing stuff 
    110  
    111         // last mail id -> warning not thread safe! 
    112         // both mailId and mailbox should be unique for each thread!!! 
    113         static int sMailId; 
    114         static int sReservedMailboxes; 
    115  
    116         static void NewMail(const int reserve = 1) { 
    117                 sMailId += sReservedMailboxes; 
    118                 sReservedMailboxes = reserve; 
    119         } 
    120  
    121         void Mail() { mMailbox = sMailId; } 
    122         bool Mailed() const { return mMailbox == sMailId; } 
    123  
    124         void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 
    125         bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 
    126  
    127         int IncMail() { return ++ mMailbox - sMailId; } 
    128          
    129         ////////////////////////////////////////// 
    130  
    131 protected: 
    132  
    133         int mMailbox; 
    134  
    135 }; 
    13613 
    13714 
     
    14017{ 
    14118public: 
    142          
    143         PvsIterator<T, S>() {} 
    144  
     19        PvsIterator<T, S>(){} 
    14520        PvsIterator<T, S>(const typename vector<PvsEntry<T, S> >::const_iterator &itCurrent, 
    14621                                          const typename vector<PvsEntry<T, S> >::const_iterator &itEnd): 
     
    15833                return *(mItCurrent ++); 
    15934        } 
    160          
     35 
    16136private: 
    16237        typename vector<PvsEntry<T, S> >::const_iterator mItCurrent; 
     
    16944*/ 
    17045template<typename T, typename S> 
    171 class Pvs 
    172 { 
    173         template<typename T, typename S> 
    174                 friend class PvsIterator; 
     46class VerbosePvs 
     47{ 
     48        template<typename T, typename S> friend class PvsIterator; 
    17549 
    17650public: 
    17751 
    178         Pvs(): mSamples(0), mEntries(), mLastSorted(0), mQueriesSinceSort(0) {} 
     52        VerbosePvs(): mSamples(0), mEntries(), mLastSorted(0), mQueriesSinceSort(0) {} 
    17953 
    18054        /** creates pvs and initializes it with the given entries.  
    18155        Assumes that entries are sorted- 
    18256        */ 
    183         Pvs(const vector<PvsEntry<T, S> > &samples); 
    184         virtual ~Pvs() {}; 
     57        VerbosePvs(const vector<PvsEntry<T, S> > &samples); 
     58        virtual ~VerbosePvs() {}; 
    18559 
    18660        /** Compresses PVS lossless or lossy. 
     
    21488        Warning: very slow! 
    21589        */ 
    216         void MergeInPlace(const Pvs<T, S> &a); 
     90        void MergeInPlace(const VerbosePvs<T, S> &a); 
    21791 
    21892        /** Difference of pvs to pvs b. 
    21993        @returns number of different entries. 
    22094        */ 
    221         int Diff(const Pvs<T, S> &b); 
     95        int Diff(const VerbosePvs<T, S> &b); 
    22296 
    22397        /** Finds sample in PVS. 
     
    246120                first checks if sample is already in clean part of the pvs. 
    247121        */ 
    248         bool AddSampleDirtyCheck(T sample, const float pdf);//, float &contribution); 
     122        bool AddSampleDirtyCheck(T sample, const float pdf); 
    249123 
    250124        /** Sort pvs entries - this should always be called after a 
     
    260134                @returns PvsData 
    261135        */ 
    262         typename std::vector<PvsEntry<T, S> >::iterator AddSample2(T sample, const float pdf); 
     136        typename std::vector<PvsEntry<T, S> >::iterator  
     137                AddSample2(T sample, const float pdf); 
    263138 
    264139        /** Subtracts one pvs from another one. 
     
    266141                @returns new pvs size 
    267142        */ 
    268         int SubtractPvs(const Pvs<T, S> &pvs); 
     143        int SubtractPvs(const VerbosePvs<T, S> &pvs); 
    269144 
    270145        /** Returns PVS data, i.e., how often it was seen from the view cell,  
     
    284159        /** Compute continuous PVS difference  
    285160        */ 
    286         void ComputeContinuousPvsDifference(Pvs<T, S> &pvs,  
     161        void ComputeContinuousPvsDifference(VerbosePvs<T, S> &pvs,  
    287162                                                                                float &pvsReduction, 
    288163                                                                                float &pvsEnlargement); 
     
    299174        /** Compute continuous PVS difference  
    300175        */ 
    301         float GetPvsHomogenity(Pvs<T, S> &pvs); 
    302  
    303         static void Merge(Pvs<T, S> &mergedPvs, const Pvs<T, S> &a, const Pvs<T, S> &b); 
     176        float GetPvsHomogenity(VerbosePvs<T, S> &pvs); 
     177 
     178        static void Merge(VerbosePvs<T, S> &mergedPvs,  
     179                                          const VerbosePvs<T, S> &a,  
     180                                          const VerbosePvs<T, S> &b); 
    304181 
    305182        int GetSamples() const 
     
    320197                const int dirtySize = n - mLastSorted; 
    321198 
    322 #define LOG2E 1.442695040f 
     199                const double LOG2E = 1.442695040f; 
    323200 
    324201                const float logN = log((float)max(1, n))/LOG2E; 
     
    344221        } 
    345222 
    346  
    347223        int GetLastSorted() const 
    348224        { 
     
    354230protected: 
    355231 
    356         static void Merge(Pvs<T, S> &mergedPvs,  
     232        static void Merge(VerbosePvs<T, S> &mergedPvs,  
    357233                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &aBegin, 
    358234                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &aEnd, 
     
    362238                                          const int bSamples); 
    363239 
     240        ////////////////////////////// 
     241 
    364242        /// vector of PVS entries 
    365243        vector<PvsEntry<T, S> > mEntries;  
     
    376254 
    377255template <typename T, typename S> 
    378 Pvs<T, S>::Pvs(const vector<PvsEntry<T, S> > &samples) 
     256VerbosePvs<T, S>::VerbosePvs(const vector<PvsEntry<T, S> > &samples) 
    379257{ 
    380258        mEntries.reserve(samples.size()); 
     
    386264 
    387265template <typename T, typename S> 
    388 void Pvs<T, S>::Sort() 
    389 { 
    390         std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 
    391         std::vector<PvsEntry<T, S> >::iterator it_end = mEntries.end(); 
     266void VerbosePvs<T, S>::Sort() 
     267{ 
     268        vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 
     269        vector<PvsEntry<T, S> >::iterator it_end = mEntries.end(); 
    392270 
    393271        // throw out double entries 
     
    411289 
    412290template <typename T, typename S> 
    413 void Pvs<T, S>::SimpleSort() 
     291void VerbosePvs<T, S>::SimpleSort() 
    414292{ 
    415293        //  sort(mEntries.begin(), mEntries.end()); 
    416         std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 
     294        vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 
    417295 
    418296        sort(it, mEntries.end()); 
     
    431309template <typename T, typename S> 
    432310void 
    433 Pvs<T, S>::ComputeContinuousPvsDifference(Pvs<T, S> &b, 
     311VerbosePvs<T, S>::ComputeContinuousPvsDifference(VerbosePvs<T, S> &b, 
    434312                                                                                  float &pvsReduction, 
    435313                                                                                  float &pvsEnlargement) 
     
    439317 
    440318        // Uses sum of log differences, which corresponds to entropy 
    441         std::vector<PvsEntry<T, S> >::iterator it; 
     319        vector<PvsEntry<T, S> >::iterator it; 
    442320 
    443321        for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it)  
     
    514392 
    515393template <typename T, typename S> 
    516 int Pvs<T, S>::Diff(const Pvs<T, S> &b) 
     394int VerbosePvs<T, S>::Diff(const VerbosePvs<T, S> &b) 
    517395{ 
    518396        int dif = 0; 
     
    533411 
    534412template <typename T, typename S>  
    535 void Pvs<T, S>::MergeInPlace(const Pvs<T, S> &a) 
     413void VerbosePvs<T, S>::MergeInPlace(const VerbosePvs<T, S> &a) 
    536414{ 
    537415        // early exit 
     
    559437 
    560438template <typename T, typename S> 
    561 void Pvs<T, S>::Merge(Pvs<T, S> &mergedPvs, const Pvs<T, S> &a, const Pvs<T, S> &b) 
    562 { 
    563         std::vector<PvsEntry<T, S> >::const_iterator ait = a.mEntries.begin(), ait_end = a.mEntries.end(); 
    564         std::vector<PvsEntry<T, S> >::const_iterator bit = b.mEntries.begin(), bit_end = b.mEntries.end(); 
     439void VerbosePvs<T, S>::Merge(VerbosePvs<T, S> &mergedPvs,  
     440                                                         const VerbosePvs<T, S> &a,  
     441                                                         const VerbosePvs<T, S> &b) 
     442{ 
     443        std::vector<PvsEntry<T, S> >::const_iterator ait =  
     444                a.mEntries.begin(), ait_end = a.mEntries.end(); 
     445        std::vector<PvsEntry<T, S> >::const_iterator bit =  
     446                b.mEntries.begin(), bit_end = b.mEntries.end(); 
    565447         
    566448        Merge(mergedPvs,  
     
    573455 
    574456template <typename T, typename S> 
    575 void Pvs<T, S>::Merge(Pvs<T, S> &mergedPvs,  
     457void VerbosePvs<T, S>::Merge(VerbosePvs<T, S> &mergedPvs,  
    576458                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &aBegin, 
    577459                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &aEnd, 
     
    627509 
    628510 
    629 template <typename T, typename S> void Pvs<T, S>::Clear(const bool trim = true) 
     511template <typename T, typename S> void VerbosePvs<T, S>::Clear(const bool trim = true) 
    630512{ 
    631513        mEntries.clear(); 
     
    640522 
    641523 
    642 template <typename T, typename S> void Pvs<T, S>::Trim() 
     524template <typename T, typename S> void VerbosePvs<T, S>::Trim() 
    643525{ 
    644526        vector<PvsEntry<T,S> >(mEntries).swap(mEntries); 
     
    647529 
    648530template <typename T, typename S>  
    649 bool Pvs<T, S>::Find(T sample, 
     531bool VerbosePvs<T, S>::Find(T sample, 
    650532                                         typename vector<PvsEntry<T, S> >::iterator &it, 
    651533                                         const bool checkDirty) 
     
    684566 
    685567template <typename T, typename S> 
    686 void Pvs<T, S>::GetData(const int index, T &entry, S &data) 
     568void VerbosePvs<T, S>::GetData(const int index, T &entry, S &data) 
    687569{ 
    688570        std::vector<PvsEntry<T, S> >::iterator i = mEntries.begin(); 
     
    695577 
    696578template <typename T, typename S> 
    697 float Pvs<T, S>::AddSample(T sample, const float pdf) 
     579float VerbosePvs<T, S>::AddSample(T sample, const float pdf) 
    698580{ 
    699581        ++ mSamples; 
     
    719601 
    720602template <typename T, typename S> 
    721 void Pvs<T, S>::AddSampleDirty(T sample, const float pdf) 
     603void VerbosePvs<T, S>::AddSampleDirty(T sample, const float pdf) 
    722604{ 
    723605        ++ mSamples; 
     
    727609 
    728610template <typename T, typename S> 
    729 typename vector< PvsEntry<T, S> >::iterator Pvs<T, S>::AddSample2(T sample,  
     611typename vector< PvsEntry<T, S> >::iterator VerbosePvs<T, S>::AddSample2(T sample,  
    730612                                                                                                                                  const float pdf) 
    731613{ 
     
    751633 
    752634 
    753 /** Adds sample dirty (on the end of the vector) but 
    754         first checks if sample is already in clean part of the pvs. 
    755 */ 
    756635template <typename T, typename S>  
    757 bool Pvs<T, S>::AddSampleDirtyCheck(T sample, 
     636bool VerbosePvs<T, S>::AddSampleDirtyCheck(T sample, 
    758637                                                                        const float pdf) 
    759638                                                                        //,float &contribution) 
     
    784663 
    785664template <typename T, typename S> 
    786 bool Pvs<T, S>::GetSampleContribution(T sample, 
     665bool VerbosePvs<T, S>::GetSampleContribution(T sample, 
    787666                                                                          const float pdf, 
    788667                                                                          float &contribution)  
     
    806685 
    807686template <typename T, typename S> 
    808 bool Pvs<T, S>::RemoveSample(T sample, const float pdf) 
     687bool VerbosePvs<T, S>::RemoveSample(T sample, const float pdf) 
    809688{ 
    810689        -- mSamples; 
     
    831710 
    832711template <typename T, typename S> 
    833 int Pvs<T, S>::SubtractPvs(const Pvs<T, S> &pvs) 
     712int VerbosePvs<T, S>::SubtractPvs(const VerbosePvs<T, S> &pvs) 
    834713{ 
    835714        const int samples = mSamples - pvs.mSamples; 
     
    849728 
    850729template <typename T, typename S> 
    851 void Pvs<T, S>::CollectEntries(std::vector<T> &entries) 
     730void VerbosePvs<T, S>::CollectEntries(std::vector<T> &entries) 
    852731{ 
    853732        std::vector<PvsEntry<T, S> >:: 
     
    861740 
    862741template <typename T, typename S> 
    863 void Pvs<T, S>::NormalizeMaximum() 
     742void VerbosePvs<T, S>::NormalizeMaximum() 
    864743{ 
    865744        std::vector<PvsEntry<T, S> >:: 
     
    880759                (*it)->second.sumPdf *= maxSum; 
    881760        } 
    882  
    883 } 
    884  
    885  
    886 template <typename T, typename S> 
    887 float Pvs<T, S>::GetEntrySize() 
     761} 
     762 
     763 
     764template <typename T, typename S> 
     765float VerbosePvs<T, S>::GetEntrySize() 
    888766{ 
    889767        return (float)(sizeof(T) + sizeof(S)) / float(1024 * 1024); 
     
    892770 
    893771template <typename T, typename S> 
    894 int Pvs<T, S>::GetEntrySizeByte() 
     772int VerbosePvs<T, S>::GetEntrySizeByte() 
    895773{ 
    896774        return sizeof(T) + sizeof(S); 
     
    899777 
    900778template <typename T, typename S> 
    901 float Pvs<T, S>::GetPvsHomogenity(Pvs<T, S> &pvs)  
     779float VerbosePvs<T, S>::GetPvsHomogenity(VerbosePvs<T, S> &pvs)  
    902780{ 
    903781        float pvsReduction, pvsEnlargement; 
    904782 
    905783        ComputeContinuousPvsDifference(pvs,     pvsReduction, pvsEnlargement); 
    906  
    907784        return pvsReduction + pvsEnlargement; 
    908785} 
     
    910787 
    911788template <typename T, typename S> 
    912 typename PvsIterator<T, S> Pvs<T, S>::GetIterator() const 
     789typename PvsIterator<T, S> VerbosePvs<T, S>::GetIterator() const 
    913790{ 
    914791        PvsIterator<T, S> pit(mEntries.begin(), mEntries.end()); 
    915  
    916792        return pit; 
    917793} 
    918794 
    919  
    920 /////////////////////////////////////// 
    921  
    922 /** Class instantiating the Pvs template for kd tree nodes. 
    923 */ 
    924 class KdPvs: public Pvs<KdNode *, PvsData> 
    925 { 
    926 public: 
    927         int Compress(); 
    928 }; 
    929  
    930  
    931 //////////// 
    932 //-- typedefs 
    933  
    934 typedef PvsEntry<Intersectable *, PvsData> ObjectPvsEntry; 
    935 typedef std::vector<ObjectPvsEntry> ObjectPvsEntries; 
    936 typedef Pvs<ViewCell *, MailablePvsData> ViewCellPvs; 
    937 typedef PvsIterator<Intersectable *, PvsData> ObjectPvsIterator; 
    938  
    939  
    940 class ObjectPvs: public Pvs<Intersectable *, PvsData> 
    941 { 
    942 public: 
    943         /** Counts object int the pvs. Different to method "GetSize", not 
    944                 only the raw container size is returned, 
    945                 but the individual contributions of the entries are summed up. 
    946         */ 
    947         float EvalPvsCost() const; 
    948  
    949         friend ostream &operator<<(ostream &s, const ObjectPvs &p)  
    950         { 
    951                 ObjectPvsIterator pit = p.GetIterator(); 
    952  
    953                 while (pit.HasMoreEntries()) 
    954                 {                
    955                         const ObjectPvsEntry &entry = pit.Next(); 
    956                         Intersectable *obj = entry.mObject; 
    957  
    958                         cout << obj << " "; 
    959                 } 
    960                  
    961                 return s; 
    962         } 
    963 }; 
    964  
    965  
    966  
    967795} 
    968796 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r2076 r2116  
    569569 
    570570#if 1 
    571   cout<<"view cell cast time:"<<viewCellCastTimer.TotalTime()<<" s"<<endl; 
    572   cout<<"pvs time:"<<pvsTimer.TotalTime()<<" s"<<endl; 
    573   cout<<"halton time:"<<haltonTimer.TotalTime()<<" s"<<endl; 
    574   //  cout<<"obj time:"<<objTimer.TotalTime()<<" s"<<endl; 
     571  const float vcTime = viewCellCastTimer.TotalTime(); 
     572  const float pvsTime = pvsTimer.TotalTime(); 
     573  const float haltonTime = haltonTimer.TotalTime(); 
     574 
     575  cout << "view cell cast time: " << vcTime << " s" << endl; 
     576  cout << "pvs time: " << pvsTime << " s" << endl; 
     577  cout << "halton time: "<< haltonTime << " s" << endl; 
     578  // cout<<"obj time:"<<objTimer.TotalTime()<<" s"<<endl; 
     579 
     580  Debug << "view cell cast time: " << vcTime << " s" << endl; 
     581  Debug << "pvs time: " << pvsTime << " s" << endl; 
     582  Debug << "halton time: "<< haltonTime << " s" << endl; 
    575583#endif 
    576584} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SimpleRay.h

    r2105 r2116  
    4040  SimpleRay(const Vector3 &o, 
    4141                        const Vector3 &d, 
    42                         const short distribution, 
     42                        const unsigned char distribution, 
    4343                        const float weight, 
    4444                        const unsigned char flags = F_BIDIRECTIONAL 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj

    r2066 r2116  
    2121                                Optimization="0" 
    2222                                AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost" 
    23                                 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;NO_QT" 
     23                                PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;NO_QT;USE_HASH_PVS" 
    2424                                MinimalRebuild="TRUE" 
    2525                                BasicRuntimeChecks="3" 
     
    8181                                OptimizeForWindowsApplication="TRUE" 
    8282                                AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\MultiLevelRayTracing;Timer" 
    83                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;NO_QT" 
     83                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;NO_QT;USE_HASH_PVS" 
    8484                                RuntimeLibrary="2" 
    8585                                EnableEnhancedInstructionSet="2" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TraversalTree.h

    r2093 r2116  
    88#include "AxisAlignedBox3.h" 
    99#include "Ray.h" 
    10 #include "Pvs.h" 
    11 #include "Viewcell.h" 
    12 #include "VssRay.h" 
    13 #include "IntersectableWrapper.h" 
     10//#include "ObjectPvs.h" 
     11//#include "Viewcell.h" 
     12//#include "VssRay.h" 
     13//#include "IntersectableWrapper.h" 
    1414 
    1515 
     
    1717 
    1818   
    19   class TraversalNode; 
    20   class TraversalLeaf; 
    21   class TraversalInterior; 
    22   class Intersectable; 
    23   class Beam; 
    24  
    25   class TraversalTree; 
    26    
    27   //  TraversalTree *SceneTraversalTree; 
     19class TraversalNode; 
     20class TraversalLeaf; 
     21class TraversalInterior; 
     22class Intersectable; 
     23class Beam; 
     24 
     25class TraversalTree; 
     26   
     27//  TraversalTree *SceneTraversalTree; 
    2828 
    2929// -------------------------------------------------------------- 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r1999 r2116  
    88#include "Material.h" 
    99#include "gzstream.h" 
    10  
     10#include "ObjectPvs.h" 
    1111 
    1212namespace GtpVisibilityPreprocessor { 
     
    2424class ViewCellLeaf; 
    2525 
     26 
     27//class ObjectPvs; 
    2628 
    2729 
     
    282284        } 
    283285 
    284         ////////// 
    285         //-- mailing stuff 
    286  
    287         //      static void NewMail(const int reserve = 1)  
    288         //      { 
    289         //              sMailId += sReservedMailboxes; 
    290         //              sReservedMailboxes = reserve; 
    291         //      } 
    292  
    293         //      void Mail() { mMailbox = sMailId; } 
    294         //      bool Mailed() const { return mMailbox == sMailId; } 
    295  
    296         //      void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 
    297         //      bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 
    298  
    299         //      int IncMail() { return ++ mMailbox - sMailId; } 
    300  
    301  
    302         // last mail id -> warning not thread safe! 
    303         // both mailId and mailbox should be unique for each thread!!! 
    304  
    305         //static int sMailId; 
    306         //static int sReservedMailboxes; 
    307286 
    308287        int GetFilteredPvsSize() const  
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2115 r2116  
    2828 
    2929 
     30 
    3031#define USE_RAY_LENGTH_AS_CONTRIBUTION 0 
    3132#define DIST_WEIGHTED_CONTRIBUTION 0 
     
    170171        } 
    171172                 
    172     Debug << "casting initial strategies: "; 
    173  
     173    Debug << "casting strategies: "; 
    174174        for (int i = 0; i < (int)mStrategies.size(); ++ i) 
    175175                Debug << mStrategies[i] << " "; 
     
    730730{ 
    731731        long startTime = GetTime(); 
    732  
     732         
    733733        SimpleRayContainer simpleRays; 
    734734         
     
    10181018 
    10191019 
    1020 ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename,  
    1021                                                                                                   ObjectContainer &pvsObjects, 
    1022                                                                                                   bool finalizeViewCells, 
    1023                                                                                                   BoundingBoxConverter *bconverter) 
    1024                                                                                                   
    1025 { 
    1026         ObjectContainer dummys; 
    1027  
    1028         return LoadViewCells(filename,  
    1029                                                  pvsObjects, 
    1030                                                  dummys, 
    1031                                                  finalizeViewCells, 
    1032                                                  bconverter); 
    1033 } 
    10341020 
    10351021 
     
    10591045        } 
    10601046         
     1047        //cout << "viewcells parsed " <<endl; 
     1048 
    10611049        if (0) 
    10621050        { 
     
    11271115                if (mUseKdPvs) 
    11281116                { 
    1129                         vector<KdIntersectable *>::iterator kit, kit_end =  
    1130                                 GetPreprocessor()->mKdTree->mKdIntersectables.end(); 
     1117                        vector<KdIntersectable *>::iterator kit, kit_end = GetPreprocessor()->mKdTree->mKdIntersectables.end(); 
    11311118 
    11321119                        int id = 0; 
     
    11381125                                obj->SetId(id); 
    11391126         
    1140                                 stream << "<BoundingBox" << " id=\""    << id << "\"" 
    1141                                            << " min=\""      << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    1142                                            << " max=\""      << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
     1127                                stream << "<BoundingBox" << " id=\"" << id << "\"" 
     1128                                           << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
     1129                                           << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
    11431130                        } 
    11441131                } 
     
    11541141                                //-- the bounding boxes 
    11551142 
    1156                                 stream << "<BoundingBox" << " id=\""    << (*oit)->GetId()    << "\"" 
    1157                                            << " min=\""      << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    1158                                            << " max=\""      << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
     1143                                stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 
     1144                                           << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
     1145                                           << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
    11591146                        } 
    11601147                } 
     
    15601547                 
    15611548                castSamples += samplesPerPass; 
    1562                 //HashPvs<int> dummy; 
    15631549 
    15641550                Real timeDiff = TimeDiff(startTime, GetTime()); 
     
    20702056                                                                                         const bool useHitObjects) 
    20712057{ 
    2072   float sum = 0.0f; 
    2073  
    2074   VssRayContainer::const_iterator it, it_end = rays.end(); 
    2075  
    2076   for (it = rays.begin(); it != it_end; ++ it)  
    2077         { 
    2078           if (!ViewCellsConstructed()) { 
    2079                 // view cells not yet constructed 
    2080                 // just take the lenghts of the rays as contributions 
    2081                 if ((*it)->mTerminationObject) 
    2082                   sum += (*it)->Length(); 
    2083           } else { 
    2084                 sum += ComputeSampleContribution(*(*it), addRays, storeViewCells, useHitObjects); 
    2085           } 
    2086         } 
    2087  
    2088   //cout<<"view cell cast time:"<<viewCellCastTimer.TotalTime()<<" s"<<endl; 
    2089  // cout<<"pvs time:"<<pvsTimer.TotalTime()<<" s"<<endl; 
    2090    
    2091   return sum; 
     2058        float sum = 0.0f; 
     2059 
     2060        VssRayContainer::const_iterator it, it_end = rays.end(); 
     2061 
     2062        for (it = rays.begin(); it != it_end; ++ it)  
     2063        { 
     2064                if (!ViewCellsConstructed())  
     2065                { 
     2066                        // view cells not yet constructed 
     2067                        // just take the lenghts of the rays as contributions 
     2068                        if ((*it)->mTerminationObject) 
     2069                        { 
     2070                                sum += (*it)->Length(); 
     2071                        } 
     2072                }  
     2073                else  
     2074                { 
     2075                        sum += ComputeSampleContribution(*(*it), addRays, storeViewCells, useHitObjects); 
     2076                } 
     2077        } 
     2078 
     2079        cout << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 
     2080        Debug << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 
     2081 
     2082        cout << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 
     2083        Debug << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 
     2084         
     2085        return sum; 
    20922086} 
    20932087 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2115 r2116  
    77#include "Containers.h" 
    88#include "ViewCell.h" 
    9 #include "ViewCellBsp.h" 
     9//#include "ViewCellBsp.h" 
    1010 
    1111namespace GtpVisibilityPreprocessor { 
     
    4343struct AxisAlignedPlane; 
    4444struct BspRay; 
    45  
    46  
    47  
    48  
    49   struct PvsFilterStatistics { 
     45class BspTree; 
     46 
     47 
     48 
     49struct PvsFilterStatistics  
     50{ 
    5051        PvsFilterStatistics():  
    51   mAvgFilterRadius(0.0f), mLocalFilterCount(0), mGlobalFilterCount(0) {} 
     52        mAvgFilterRadius(0.0f), mLocalFilterCount(0), mGlobalFilterCount(0) {} 
     53         
    5254        float mAvgFilterRadius; 
    5355        int mLocalFilterCount; 
    5456        int mGlobalFilterCount; 
    55          
    56   }; 
    57    
     57}; 
     58 
    5859/** Probably Visible Set  
    5960*/ 
     
    6162{ 
    6263public: 
    63   /// root of view cells tree 
    64   ViewCell *mViewCell; 
    65  
    66   // input parameter is the render budget for the PrVs 
    67   float mRenderBudget; 
    68  
    69   // some characteristic values could be stored as well 
     64        /// root of view cells tree 
     65        ViewCell *mViewCell; 
     66 
     67        // input parameter is the render budget for the PrVs 
     68        float mRenderBudget; 
     69 
     70        // some characteristic values could be stored as well 
    7071}; 
    7172 
     
    8586{ 
    8687public: 
    87    
    88   struct PerViewCellStat { 
    89         float pvsSize; 
    90         float relPvsIncrease; 
    91   }; 
    92  
    93   struct SamplesStatistics { 
    94         int mRays; 
    95         int mViewCells; 
    96         int mContributingRays; 
    97         int mPvsContributions; 
    98         void Reset() { 
    99           mRays = 0; 
    100           mViewCells = 0; 
    101           mContributingRays = 0; 
    102           mPvsContributions = 0; 
     88 
     89        struct PerViewCellStat  
     90        { 
     91                float pvsSize; 
     92                float relPvsIncrease; 
    10393        }; 
    104   }; 
    105  
    106   struct PvsStatistics  
     94 
     95        struct SamplesStatistics  
    10796        { 
    108           float minPvs; 
    109           float maxPvs; 
    110           float avgPvs; 
    111           float avgPvsEntries; 
    112            
    113           float avgFilteredPvs; 
    114           float avgFilteredPvsEntries; 
    115  
    116           float avgFilterContribution; 
    117           float avgFilterRadius; 
    118           float avgFilterRatio; 
    119           float avgRelPvsIncrease; 
    120           float devRelPvsIncrease; 
    121           int viewcells; 
     97                int mRays; 
     98                int mViewCells; 
     99                int mContributingRays; 
     100                int mPvsContributions; 
     101                void Reset()  
     102                { 
     103                        mRays = 0; 
     104                        mViewCells = 0; 
     105                        mContributingRays = 0; 
     106                        mPvsContributions = 0; 
     107                }; 
     108        }; 
     109 
     110        struct PvsStatistics  
     111        { 
     112                float minPvs; 
     113                float maxPvs; 
     114                float avgPvs; 
     115                float avgPvsEntries; 
     116 
     117                float avgFilteredPvs; 
     118                float avgFilteredPvsEntries; 
     119 
     120                float avgFilterContribution; 
     121                float avgFilterRadius; 
     122                float avgFilterRatio; 
     123                float avgRelPvsIncrease; 
     124                float devRelPvsIncrease; 
     125                int viewcells; 
    122126        }; 
    123127   
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h

    r2115 r2116  
    2727class BvHierarchy; 
    2828class HierarchyManager; 
     29class ObjectPvs; 
     30class BspNode; 
    2931 
    3032 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r2073 r2116  
    619619                // update scalar pvs size value 
    620620                ObjectPvs &pvs = viewCell->GetPvs(); 
    621                 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.EvalPvsCost(), pvs.GetSize()); 
     621                mViewCellsManager->UpdateScalarPvsSize(viewCell,  
     622                                                                                           pvs.EvalPvsCost(),  
     623                                                                                           pvs.GetSize()); 
    622624 
    623625                mVspStats.contributingSamples += conSamp; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r2066 r2116  
    1616#include "RayCaster.h" 
    1717#include "SamplingStrategy.h" 
    18  
     18#include "ViewCellBsp.h" 
    1919 
    2020 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp

    r1966 r2116  
    11#include "VssRay.h" 
    22#include "AxisAlignedBox3.h" 
     3#include "Ray.h" 
     4 
    35 
    46namespace GtpVisibilityPreprocessor { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h

    r2014 r2116  
    33 
    44#include <vector> 
     5 
     6#include "Vector3.h" 
     7#include "Containers.h" 
     8 
    59using namespace std; 
    6 #include "Vector3.h" 
    7 #include "Ray.h" 
    8 #include "Containers.h" 
     10 
    911 
    1012namespace GtpVisibilityPreprocessor { 
     
    1315class Intersectable; 
    1416class KdNode; 
     17class Ray; 
    1518 
    1619#define ABS_CONTRIBUTION_WEIGHT 0.0f 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r1789 r2116  
    3232#include "IntersectableWrapper.h" 
    3333#include <assert.h> 
    34  
     34#include "Polygon3.h" 
    3535 
    3636namespace GtpVisibilityPreprocessor { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r2115 r2116  
    1 /*#ifdef GTP_INTERNAL 
    2 #ifndef USE_QT 
    3 #define USE_QT 1 
    4 #else 
    5 #define USE_QT 0 
    6 #endif 
    7 #endif 
    8 */ 
    9  
    101#define USE_THREADS 0 
    112 
     
    2920#include "SceneGraph.h" 
    3021#include "GlobalLinesRenderer.h" 
     22#include "PvsDefinitions.h" 
    3123 
    3224#include "ViewCellsManager.h" 
     
    227219 
    228220 
     221        if (HASH_PVS) 
     222                Debug << "using hash pvs" << endl; 
     223        else 
     224                Debug << "using verbose pvs" << endl; 
     225 
    229226        ///////////// 
    230227        //-- load scene  
Note: See TracChangeset for help on using the changeset viewer.