Changeset 801 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 04/24/06 08:21:10 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r752 r801 173 173 Debug << "export to file: " << mExportViewCells << endl; 174 174 175 Debug << "active : " << mNumActiveViewCells << endl;175 Debug << "active view cells: " << mNumActiveViewCells << endl; 176 176 Debug << "post process compress: " << mCompressViewCells << endl; 177 177 Debug << "visualization use clipPlane: " << mUseClipPlaneForViz << endl; … … 179 179 Debug << "evaluate view cells: " << mEvaluateViewCells << endl; 180 180 Debug << "sampling type: " << mSamplingType << endl; 181 Debug << "render cost evaluation type " << mRenderCostEvaluationType << endl;181 Debug << "render cost evaluation type: " << mRenderCostEvaluationType << endl; 182 182 Debug << "evaluation sampling type: " << mEvaluationSamplingType << endl; 183 183 Debug << "show visualization: " << mShowVisualization << endl; … … 479 479 if (TEST_EMPTY_VIEW_CELLS) 480 480 CollectEmptyViewCells(); 481 482 481 482 // evaluation of the paritition, i.e., a number of new samples are cast 483 if (mEvaluateViewCells) 484 { 485 EvalViewCellPartition(preprocessor); 486 } 487 483 488 //-- visualization 484 489 if (mShowVisualization) … … 500 505 } 501 506 502 // evaluation of the paritition, i.e., a number of new samples are cast503 if (mEvaluateViewCells)504 {505 EvalViewCellPartition(preprocessor);506 }507 508 507 return numSamples; 509 508 } … … 696 695 bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 697 696 698 cout << "collect leaf view cells and reseting pvs ... "; 699 700 ViewCellContainer leaves; 701 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 702 cout << " ... "; 697 698 /*ViewCellContainer leaves; 699 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 700 */ 701 cout << "reseting pvs ... "; 702 703 703 704 bool startFromZero = true; 704 705 … … 744 745 cout << "compute new statistics ... "; 745 746 746 // propagate pvs or pvs size information 747 /*Debug << "*******+" << endl; 748 float overall = 0; 749 stable_sort(leaves.begin(), leaves.end(), ViewCell::SmallerPvs); 750 for (int i = 0; i < leaves.size(); ++ i) 751 { 752 overall += leaves[i]->GetPvs().GetSize(); 753 Debug << "i " << i << " !size: " << leaves[i]->GetPvs().GetSize() << " vol: " << leaves[i]->GetVolume() << " overall " << overall << endl; 754 755 } 756 */ 757 758 //-- propagate pvs or pvs size information 747 759 ObjectPvs pvs; 748 760 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 749 761 750 762 751 // output stats763 //-- output stats 752 764 sprintf(s, "-%09d-eval.log", castSamples); 753 765 string fileName = string(statsPrefix) + string(s); … … 1793 1805 if (!mOnlyValidViewCells || (*it)->GetValid()) 1794 1806 { 1795 ExportColor(exporter, *it); 1807 ExportColor(exporter, *it); 1808 1796 1809 ExportViewCellGeometry(exporter, *it, 1797 1810 mUseClipPlaneForViz ? &mClipPlane : NULL); … … 2145 2158 2146 2159 //exporter->SetWireframe(); 2147 exporter->SetFilled(); 2160 //exporter->SetFilled(); 2161 bool b = mUseClipPlaneForViz; 2162 mUseClipPlaneForViz = false; 2148 2163 ExportViewCellsForViz(exporter); 2149 2164 mUseClipPlaneForViz = b; 2150 2165 delete exporter; 2151 2166 } … … 2168 2183 // export single view cells 2169 2184 ExportBspPvs(objects); 2170 }2171 2172 2173 inline bool vc_gt(ViewCell *a, ViewCell *b)2174 {2175 return a->GetPvs().GetSize() > b->GetPvs().GetSize();2176 2185 } 2177 2186 … … 2219 2228 // sort view cells to get largest view cells 2220 2229 if (0) 2221 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt);2230 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 2222 2231 2223 2232 int limit = min(leafOut, (int)mViewCells.size()); … … 3329 3338 case 1: // pvs 3330 3339 { 3331 importance = (float) vc->GetPvs().GetSize() /3340 importance = (float)mViewCellsTree->GetPvsSize(vc) / 3332 3341 (float)mCurrentViewCellsStats.maxPvs; 3333 3342 } … … 3541 3550 // compute tree by merging the nodes based on cost heuristics 3542 3551 mViewCellsTree->ConstructMergeTree(rays, objects); 3552 3553 //cout << "here344" << endl; 3554 //ObjectPvs pvs; 3555 //UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 3543 3556 } 3544 3557 else … … 3881 3894 pvs = root->GetPvs(); 3882 3895 3883 root->mPvsSize = pvs.GetSize();3896 root->mPvsSize = root->GetPvs().GetSize(); 3884 3897 root->mPvsSizeValid = true; 3885 3898 … … 3887 3900 } 3888 3901 3902 //-- interior node => propagate pvs up 3889 3903 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 3904 interior->GetPvs().Clear(); 3905 pvs.Clear(); 3906 vector<ObjectPvs> pvsList; 3907 3890 3908 ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 3891 3909 3892 vector<ObjectPvs> pvsList;3893 3894 3895 3910 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit) 3896 3911 { … … 3905 3920 3906 3921 #if 1 3922 3907 3923 Intersectable::NewMail(); 3908 3924 … … 3933 3949 { 3934 3950 interior->mPvs = pvs; 3951 //cout << "here233" << endl; 3935 3952 } 3936 3953 … … 3940 3957 3941 3958 #else 3959 3942 3960 // really merge cells: slow put sumpdf is correct 3943 ViewCellInterior *viewCellInterior = new ViewCellInterior();3944 3945 3961 viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 3946 3962 viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); … … 3995 4011 { // hack pvs 3996 4012 int savedColorCode = mColorCode; 3997 mColorCode = 0; 4013 mColorCode = 1; 4014 3998 4015 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 3999 4016 … … 4020 4037 } 4021 4038 4039 //exporter->SetFilled(); 4040 bool b = mUseClipPlaneForViz; 4041 mUseClipPlaneForViz = false; 4022 4042 ExportViewCellsForViz(exporter); 4043 mUseClipPlaneForViz = b; 4044 4023 4045 delete exporter; 4024 4046 cout << "finished" << endl; … … 4148 4170 4149 4171 const bool sortViewCells = true; 4172 4150 4173 4151 4174 // sort view cells to visualize the largest view cells 4152 4175 if (sortViewCells) 4153 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 4154 4176 { 4177 //stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 4178 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 4179 } 4180 4155 4181 int limit = min(leafOut, (int)mViewCells.size()); 4156 4182 … … 4168 4194 else 4169 4195 vc = mViewCells[(int)RandomValue(0, (float)mViewCells.size() - 1)]; 4196 4197 ObjectPvs pvs; 4198 mViewCellsTree->GetPvs(vc, pvs); 4170 4199 4171 4200 //bspLeaves[j]->Mail(); … … 4175 4204 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 4176 4205 4206 //-- export the sample rays 4177 4207 if (1 || mExportRays) 4178 4208 { … … 4212 4242 vcRays.push_back(*rit); 4213 4243 } 4244 4214 4245 //-- export rays piercing this view cell 4215 4246 exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); … … 4221 4252 VssRayContainer vcRays; 4222 4253 raysOut = min((int)rays.size(), mVisualizationSamples); 4254 4223 4255 // check whether we can add the current ray to the output rays 4224 4256 for (int k = 0; k < raysOut; ++ k) … … 4251 4283 exporter->SetFilled(); 4252 4284 4253 4285 //-- export pvs 4254 4286 if (1) 4255 4287 { 4256 4288 ObjectPvsMap::const_iterator oit, 4257 oit_end = vc->GetPvs().mEntries.end(); 4258 4259 4260 exporter->SetFilled(); 4289 oit_end = pvs.mEntries.end(); 4261 4290 4262 4291 Intersectable::NewMail(); 4263 4292 4264 4293 // output PVS of view cell 4265 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)4294 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 4266 4295 { 4267 4296 Intersectable *intersect = (*oit).first; … … 4277 4306 } 4278 4307 } 4279 else 4280 { 4308 4309 if (0) 4310 { // export scene geometry 4281 4311 m.mDiffuseColor = RgbColor(1, 0, 0); 4282 4312 exporter->SetForcedMaterial(m); … … 4338 4368 case 1: // pvs 4339 4369 { 4340 importance = (float) vc->GetPvs().GetSize() /4370 importance = (float)mViewCellsTree->GetPvsSize(vc) / 4341 4371 #if 1 // hack for result 4342 4372 (float)mCurrentViewCellsStats.maxPvs; … … 4377 4407 const Plane3 *clipPlane) const 4378 4408 { 4379 if (vc->GetMesh())4380 {4381 exporter->ExportMesh(vc->GetMesh());4382 4383 return;4384 }4385 4386 4387 4409 if (clipPlane) 4388 4410 { … … 4418 4440 //Debug << "geo size: " << geom.Size() << endl; 4419 4441 //Debug << "size b: " << back.Size() << " f: " << front.Size() << endl; 4442 4420 4443 if (back.Valid()) 4421 4444 { … … 4427 4450 else 4428 4451 { 4429 BspNodeGeometry geom; 4430 mVspBspTree->ConstructGeometry(vc, geom); 4431 4432 exporter->ExportPolygons(geom.GetPolys()); 4452 // export mesh if available 4453 /* if (vc->GetMesh()) 4454 { 4455 exporter->ExportMesh(vc->GetMesh()); 4456 } 4457 else 4458 {*/ 4459 BspNodeGeometry geom; 4460 mVspBspTree->ConstructGeometry(vc, geom); 4461 exporter->ExportPolygons(geom.GetPolys()); 4462 //} 4433 4463 } 4434 4464 }
Note: See TracChangeset
for help on using the changeset viewer.