Changeset 1002 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 06/07/06 10:59:55 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1001 r1002 39 39 }; 40 40 41 //typedef priority_queue<ViewCell *, vector<ViewCell *>, myless<vector<ViewCell *>::value_type> > FilterQueue;42 43 44 41 45 42 ViewCellsManager::ViewCellsManager(Environment *env): … … 205 202 ViewCellsManager::~ViewCellsManager() 206 203 { 207 DEL_PTR(mRenderer);204 //DEL_PTR(mRenderer); 208 205 209 206 if (!ViewCellsTreeConstructed()) 210 207 CLEAR_CONTAINER(mViewCells); 211 else212 208 //else 209 DEL_PTR(mViewCellsTree); 213 210 } 214 211 … … 306 303 } 307 304 } 308 Debug << "\nSampled " << i << " new view cells (" << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 305 Debug << "\nSampled " << i << " new view cells (" 306 << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 309 307 } 310 308 … … 395 393 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 396 394 397 395 return 0; 398 396 // take post processing time 399 397 startTime = GetTime(); 400 398 401 402 // testing the view cell filter functionality403 if (0) TestFilter(preprocessor->mObjects);404 405 399 // -- stats after contruction 406 400 ResetViewCells(); 407 408 401 Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 402 409 403 410 404 if (1) // export initial view cells … … 473 467 474 468 475 476 469 //-- post processing 477 470 VssRayContainer postProcessSamples; … … 494 487 495 488 496 497 489 cout << "starting post processing and visualization" << endl; 498 490 … … 514 506 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 515 507 516 // only for debugging purpose517 if (TEST_EMPTY_VIEW_CELLS) 518 CollectEmptyViewCells();519 508 disposeRays(postProcessSamples, outRays); 509 510 511 //return 1; 520 512 // evaluation of the paritition, i.e., a number of new samples are cast 521 513 if (mEvaluateViewCells) … … 523 515 EvalViewCellPartition(preprocessor); 524 516 } 525 517 518 526 519 //-- visualization 527 520 if (mShowVisualization) … … 679 672 const ObjectContainer &objects) 680 673 { 681 if (!ViewCellsConstructed() )674 if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 682 675 return false; 683 676 … … 764 757 sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 765 758 766 //Debug << "********************" << endl;767 //for (int i = 0; i < viewCells.size(); ++ i)768 // Debug << "pvs: " << mViewCellsTree->GetPvsSize(viewCells[i]) << " ";769 //Debug << "\n";770 759 maxPvs = mViewCellsTree->GetPvsSize(viewCells.back()); 771 760 minVal = 0; … … 844 833 845 834 835 bool ViewCellsManager::GetExportPvs() const 836 { 837 return mExportPvs; 838 } 839 840 846 841 void ViewCellsManager::EvalViewCellPartition(Preprocessor *preprocessor) 847 842 { … … 862 857 Debug << "view cell stats prefix: " << statsPrefix << endl; 863 858 864 //VssRayContainer outRays;859 865 860 // should directional sampling be used? 866 861 bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); … … 932 927 933 928 //-- histogram 934 935 929 936 930 bool useHisto; … … 1207 1201 bool ViewCellsManager::ViewCellsTreeConstructed() const 1208 1202 { 1209 return mViewCellsTree->GetRoot();1203 return (mViewCellsTree && mViewCellsTree->GetRoot()); 1210 1204 } 1211 1205 … … 1419 1413 1420 1414 1421 void ViewCellsManager::DeriveViewCells (const ObjectContainer &objects,1422 1423 1415 void ViewCellsManager::DeriveViewCellsFromObjects(const ObjectContainer &objects, 1416 ViewCellContainer &viewCells, 1417 const int maxViewCells) const 1424 1418 { 1425 1419 // maximal max viewcells … … 1444 1438 1445 1439 Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 1446 1447 // copy mesh 1448 *mesh = *mi->GetMesh(); 1449 1440 1450 1441 // transform mesh 1451 Matrix4x4 m; 1452 mi->GetWorldTransform(m); 1453 mesh->ApplyTransformation(m); 1442 mi->GetTransformedMesh(*mesh); 1454 1443 1455 1444 // create bb + kd tree … … 2168 2157 2169 2158 2159 void ViewCellsManager::SetScalarPvsSize(ViewCell *vc, const int pvsSize) const 2160 { 2161 vc->mPvsSize = pvsSize; 2162 vc->mPvsSizeValid = true; 2163 } 2164 2165 2170 2166 /**********************************************************************/ 2171 2167 /* BspViewCellsManager implementation */ … … 2964 2960 { 2965 2961 pvs = root->GetPvs(); 2966 2967 root->mPvsSize = pvs.GetSize(); 2968 root->mPvsSizeValid = true; 2969 2962 SetScalarPvsSize(root, pvs.GetSize()); 2963 2970 2964 return; 2971 2965 } … … 3018 3012 if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 3019 3013 { 3020 interior-> mPvs = pvs;3014 interior->SetPvs(pvs); 3021 3015 } 3022 3016 3023 3017 // set new pvs size 3024 interior->mPvsSize = pvs.GetSize(); 3025 interior->mPvsSizeValid = true; 3018 SetScalarPvsSize(interior, pvs.GetSize()); 3026 3019 3027 3020 #else … … 3781 3774 Debug << "saved rays: " << (int)savedRays.size() << endl; 3782 3775 3783 3784 //TODO: remove 3776 long startTime; 3777 3785 3778 if (1) 3786 3779 mVspBspTree->Construct(constructionRays, &mViewSpaceBox); … … 3790 3783 // collapse invalid regions 3791 3784 cout << "collapsing invalid tree regions ... "; 3792 longstartTime = GetTime();3793 int collapsedLeaves = mVspBspTree->CollapseTree();3785 startTime = GetTime(); 3786 const int collapsedLeaves = mVspBspTree->CollapseTree(); 3794 3787 Debug << "collapsed in " << TimeDiff(startTime, GetTime()) * 1e-3 3795 3788 << " seconds" << endl; … … 3797 3790 cout << "finished" << endl; 3798 3791 3799 // 3792 //-- stats 3800 3793 Debug << mVspBspTree->GetStatistics() << endl; 3801 3794 … … 4211 4204 { 4212 4205 pvs = root->GetPvs(); 4213 4214 root->mPvsSize = root->GetPvs().GetSize(); 4215 root->mPvsSizeValid = true; 4216 4206 SetScalarPvsSize(root, root->GetPvs().GetSize()); 4207 4217 4208 return; 4218 4209 } … … 4266 4257 if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 4267 4258 { 4268 interior-> mPvs = pvs;4259 interior->SetPvs(pvs); 4269 4260 } 4270 4261 4271 4262 // set new pvs size 4272 interior->mPvsSize = pvs.GetSize();4273 interior->mPvsSizeValid = true;4263 SetScalarPvsSize(interior, pvs.GetSize()); 4264 4274 4265 4275 4266 #else … … 4325 4316 GetRaySets(sampleRays, mVisualizationSamples, visRays); 4326 4317 4327 4328 if (1) // export view cells4318 //-- export view cells 4319 if (1) 4329 4320 { // hack pvs 4330 int savedColorCode = mColorCode;4321 const int savedColorCode = mColorCode; 4331 4322 mColorCode = 1; 4332 4323 … … 4367 4358 mColorCode = savedColorCode; 4368 4359 } 4360 4369 4361 4370 4362 if (0) … … 5035 5027 // AxisAlignedBox3 box(center - Vector3(viewSpaceFilterSize/2), 5036 5028 // center + Vector3(viewSpaceFilterSize/2)); 5037 5038 5029 if (!ViewCellsConstructed()) 5039 5030 return; 5040 5031 5041 if (viewSpaceFilterSize >=0.0f) {5032 if (viewSpaceFilterSize >= 0.0f) { 5042 5033 5043 5034 bool usePrVS = false; 5044 5035 5045 5046 5036 if (!usePrVS) { 5047 5037 AxisAlignedBox3 box = GetViewCellBox(viewCell); … … 5052 5042 5053 5043 // cout<<"box="<<box<<endl; 5054 ViewCellContainer::const_iterator it =viewCells.begin(), it_end = viewCells.end();5044 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 5055 5045 5056 5046 int i; 5057 for (i=0; it != it_end; ++ it, i++) {5058 //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl;5047 for (i=0; it != it_end; ++ it, ++ i) { 5048 cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 5059 5049 pvs.Merge((*it)->GetPvs()); 5060 5050 } … … 5070 5060 } else 5071 5061 pvs = viewCell->GetPvs(); 5072 5062 5073 5063 if (spatialFilterSize >=0.0f) 5074 5064 ApplySpatialFilter(kdTree, spatialFilterSize, pvs); 5075 5065 5076 5066 } 5077 5067 … … 5097 5087 5098 5088 int i; 5099 for (i=0, it = mViewCells.begin(); it != it_end; ++ it, i++) {5089 for (i=0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 5100 5090 ApplyFilter(*it, 5101 5091 kdTree, … … 5107 5097 5108 5098 // now replace all pvss 5109 for (i= 0, it = mViewCells.begin(); it != it_end; ++ it, i++) { 5099 for (i = 0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 5100 5110 5101 ObjectPvs &pvs = (*it)->GetPvs(); 5111 5102 pvs.Clear(); … … 5114 5105 } 5115 5106 5116 delete newPvs;5107 delete [] newPvs; 5117 5108 } 5118 5109 … … 5180 5171 5181 5172 ////////////////////////////////// 5182 ViewCellsManager *ViewCellsManagerFactory::Create(const string mName)5173 /*ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 5183 5174 { 5184 5175 //TODO 5185 5176 return NULL;// new VspBspViewCellsManager(); 5186 } 5187 5188 5189 } 5177 }*/ 5178 5179 5180 }
Note: See TracChangeset
for help on using the changeset viewer.