source: trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.cpp @ 191

Revision 191, 833 bytes checked in by bittner, 19 years ago (diff)

basic sampling strategies

Line 
1#include <iostream>
2using namespace std;
3#include "Pvs.h"
4
5KdPvsData *
6KdPvs::Find(KdNode *node)
7{
8  KdPvsMap::iterator i = mEntries.find(node);
9  if (i != mEntries.end()) {
10    //    cout<<node<<" "<<(*i).first<<" "<<(*i).second.mVisibleSamples<<endl;
11    return &(*i).second;
12  } else
13    return NULL;
14}
15
16int
17KdPvs::AddNodeSample(KdNode *node)
18{
19  int result;
20 
21  KdPvsData *data = Find(node);
22  if (data) {
23    data->mVisibleSamples++;
24    result = 0;
25  } else {
26    mEntries[node] = KdPvsData(1);
27    result = 1;
28  }
29  return  result;
30}
31
32
33void
34KdPvs::GetData(const int index,
35               KdNode *&node,
36               KdPvsData &data
37               )
38{
39  KdPvsMap::iterator i = mEntries.begin();
40  for (int k = 0; k!=index && i != mEntries.end(); i++, k++);
41  node = (*i).first;
42  data = (*i).second;
43}
Note: See TracBrowser for help on using the repository browser.