Ignore:
Timestamp:
11/15/06 14:56:00 (18 years ago)
Author:
bittner
Message:

pvs updates

File:
1 edited

Legend:

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

    r1751 r1757  
    159159public: 
    160160 
    161         Pvs(): mSamples(0), mEntries() {} 
     161        Pvs(): mSamples(0), mEntries(), mLastSorted(0) {} 
    162162 
    163163        /** creates pvs and initializes it with the given entries.  
     
    205205        */ 
    206206        float AddSample(T sample, const float pdf); 
    207          
     207 
     208  /** Adds sample to PVS without checking for presence of the sample 
     209          pvs remians unsorted! 
     210  */ 
     211  void AddSampleDirty(T sample, const float pdf); 
     212 
     213  /** Sort pvs entries - this should always be called after a 
     214          sequence of AddSampleDirty calls */ 
     215  void Sort(); 
     216   
    208217        /** Adds sample to PVS. Assumes that the pvs is sorted 
    209218                @returns contribution of sample (0 or 1) 
     
    271280        /// Number of samples used to create the PVS 
    272281        int mSamples; 
     282   
     283  /// Last sorted entry in the pvs (important for find and merge 
     284  int mLastSorted; 
     285   
    273286}; 
    274287 
     
    279292        mEntries.reserve(samples.size()); 
    280293        mEntries = samples; 
    281 } 
    282  
     294        mLastSorted = 0; 
     295} 
     296 
     297template <typename T, typename S> 
     298void Pvs<T, S>::Sort() 
     299{ 
     300  std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin(); 
     301  it.inc(mLastSorted); 
     302  sort(it, mEntries.end()); 
     303  mLastSorted = mEntries.size() - 1; 
     304} 
    283305 
    284306/** 
     
    500522 
    501523template <typename T, typename S> 
     524void Pvs<T, S>::AddSampleDirty(T sample, const float pdf) 
     525{ 
     526  ++ mSamples; 
     527  mEntries.push_back(PvsEntry<T, S>(sample, pdf)); 
     528} 
     529                                          
     530 
     531template <typename T, typename S> 
    502532typename vector< PvsEntry<T, S> >::iterator Pvs<T, S>::AddSample2(T sample, const float pdf) 
    503533{ 
Note: See TracChangeset for help on using the changeset viewer.