source: GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp @ 1894

Revision 1894, 2.7 KB checked in by mattausch, 18 years ago (diff)
  • Property svn:executable set to *
Line 
1#include "SceneGraph.h"
2#include "KdTree.h"
3#include "X3dExporter.h"
4#include "Environment.h"
5#include "Polygon3.h"
6#include "VssRay.h"
7#include "RssTree.h"
8#include "ViewCellsManager.h"
9#include "RenderSimulator.h"
10#include "GlRenderer.h"
11#include "SamplingStrategy.h"
12#include "PreprocessorThread.h"
13#include "CombinedPreprocessor.h"
14
15
16namespace GtpVisibilityPreprocessor {
17
18const bool pruneInvalidRays = false;
19
20 
21  CombinedPreprocessor::CombinedPreprocessor():
22        Preprocessor()
23  {
24        // this should increase coherence of the samples
25        Environment::GetSingleton()->GetIntValue("RssPreprocessor.vssSamples", mTotalSamples);
26        Environment::GetSingleton()->GetIntValue("RssPreprocessor.samplesPerPass", mSamplesPerPass);
27        Environment::GetSingleton()->GetIntValue("RssPreprocessor.vssSamplesPerPass",
28                                                                                         mSamplesPerEvaluation);
29       
30       
31        //  Environment::GetSingleton()->GetBoolValue("RssPreprocessor.Export.rays", mExportRays);
32        //  Environment::GetSingleton()->GetIntValue("RssPreprocessor.Export.numRays", mExportNumRays);
33  }
34 
35
36bool
37CombinedPreprocessor::ComputeVisibility()
38{
39 
40  Debug << "Preprocessor type: combined" << endl;
41  cout<<"Combined Preprocessor started\n"<<flush;
42 
43  // if not already loaded, construct view cells from file
44  if (!mLoadViewCells) {
45        // construct view cells using it's own set of samples
46        mViewCellsManager->Construct(this);
47       
48        //-- several visualizations and statistics
49        Debug << "view cells construction finished: " << endl;
50        mViewCellsManager->PrintStatistics(Debug);
51  }
52 
53 
54  // now decode distribution string
55  char buff[1024];
56  Environment::GetSingleton()->GetStringValue("RssPreprocessor.distributions",
57                                                                                          buff);
58 
59
60  mMixtureDistribution = new MixtureDistribution(*this);
61  mMixtureDistribution->Construct(buff);
62 
63  SimpleRayContainer rays;
64  VssRayContainer vssRays;
65
66  int lastEvaluation = 0;
67  int totalVssRays = 0;
68  mPass = 0;
69 
70  long startTime = GetTime();
71  for (int i=0; i < mTotalSamples; i += mSamplesPerPass, mPass++) {
72
73        if (i - lastEvaluation >= mSamplesPerEvaluation) {
74          mStats <<
75                "#Pass\n" <<mPass<<endl<<
76                "#Time\n" << TimeDiff(startTime, GetTime())<<endl<<
77                "#TotalSamples\n" <<i<<endl<<
78                "#RssSamples\n" <<totalVssRays<<endl;
79          vssRays.PrintStatistics(mStats);
80          mViewCellsManager->PrintPvsStatistics(mStats);
81          lastEvaluation = i;
82        }
83       
84        cout<<"Progress : "<<(100.0f*i)/mTotalSamples<<"%"<<endl;
85        rays.clear();
86        vssRays.clear();
87       
88        mMixtureDistribution->GenerateSamples(mSamplesPerPass, rays);
89       
90        CastRays(rays, vssRays, true, pruneInvalidRays);
91        totalVssRays += (int)vssRays.size();
92       
93        mMixtureDistribution->ComputeContributions(vssRays);
94
95  }
96  return true;
97 
98}
99
100}
Note: See TracBrowser for help on using the repository browser.