#include "SceneGraph.h" #include "KdTree.h" #include "X3dExporter.h" #include "Environment.h" #include "Polygon3.h" #include "VssRay.h" #include "RssTree.h" #include "ViewCellsManager.h" #include "RenderSimulator.h" #include "GlRenderer.h" #include "SamplingStrategy.h" #include "PreprocessorThread.h" #include "CombinedPreprocessor.h" #include "RayCaster.h" namespace GtpVisibilityPreprocessor { const bool pruneInvalidRays = true; CombinedPreprocessor::CombinedPreprocessor(): Preprocessor() { // this should increase coherence of the samples // Environment::GetSingleton()->GetIntValue("RssPreprocessor.vssSamples", mTotalSamples); // Environment::GetSingleton()->GetIntValue("RssPreprocessor.samplesPerPass", mSamplesPerPass); // Environment::GetSingleton()->GetIntValue("RssPreprocessor.vssSamplesPerPass", // mSamplesPerEvaluation); } bool CombinedPreprocessor::ComputeVisibility() { Debug << "Preprocessor type: combined" << endl; cout<<"Combined Preprocessor started\n"<Construct(this); //-- several visualizations and statistics Debug << "view cells construction finished: " << endl; mViewCellsManager->PrintStatistics(Debug); } // now decode distribution string char buff[1024]; Environment::GetSingleton()->GetStringValue("RssPreprocessor.distributions", buff); mMixtureDistribution = new MixtureDistribution(*this); mMixtureDistribution->Construct(buff); SimpleRayContainer rays; VssRayContainer vssRays; int lastEvaluation = 0; int totalVssRays = 0; mPass = 0; vector rayBuffer; rays.reserve(mSamplesPerPass); rayBuffer.reserve(2*mSamplesPerPass); long startTime = GetTime(); for (int i=0; i < mTotalSamples; i += mSamplesPerPass, mPass++) { mRayCaster->InitPass(); cout<<"Progress :"<GenerateSamples(mSamplesPerPass, rays); bool doubleRays = true; CastRays(rays, vssRays, doubleRays, pruneInvalidRays); totalVssRays += (int)vssRays.size(); mMixtureDistribution->ComputeContributions(vssRays); if (mExportRays) { Debug<<"Exporting rays..."<UpdateDistributions(vssRays); if (i - lastEvaluation >= mSamplesPerEvaluation) { long time = TimeDiff(startTime, GetTime()); mViewCellsManager->PrintPvsStatistics(mStats); mStats << "#Pass\n" < mTotalTime) break; #if 0 cerr<<"deleting rays"<RefCount() == 0) delete vssRays[j]; } cerr<<"done."<RequiresRays()) // CLEAR_CONTAINER(vssRays); } EvalViewCellHistogram(); if (mExportAnimation && mExportRays) { char filename[64]; sprintf(filename, "rss-rays-i.x3d"); //rayBuffer.resize(mPass); ExportRayAnimation(filename, rayBuffer); } return true; } }