Changeset 694 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 03/15/06 08:59:33 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r693 r694 17 17 18 18 #define SAMPLE_AFTER_SUBDIVISION 1 19 19 #define TEST_EMPTY_VIEW_CELLS 0 20 20 21 21 ViewCellsManager::ViewCellsManager(): … … 145 145 146 146 cout << "collecting empty view cells" << endl; 147 int i = 0;147 148 148 for (it = leaves.begin(); it != it_end; ++ it) 149 149 { 150 150 if ((*it)->GetPvs().Empty()) 151 151 { 152 ++ i;153 152 mEmptyViewCells.push_back(*it); 154 153 } 155 154 } 156 cout << "view cells found: " << i << endl; 157 } 158 159 160 void ViewCellsManager::TestEmptyViewCells() 161 { 162 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), mEmptyViewCells); 163 155 Debug << "empty view cells found: " << (int)mEmptyViewCells.size() << endl; 156 } 157 158 159 void ViewCellsManager::TestEmptyViewCells(const ObjectContainer &obj) 160 { 164 161 ViewCellContainer::const_iterator it, it_end = mEmptyViewCells.end(); 165 162 … … 170 167 if (!(*it)->GetPvs().Empty()) 171 168 { 172 sprintf(buf, "empty-viewcells-%09d.x3d", (*it)->GetId());169 sprintf(buf, "empty-viewcells-%09d.x3d", i/*(*it)->GetId()*/); 173 170 Exporter *exporter = Exporter::GetExporter(buf); 174 171 175 172 if (exporter && i < 20) 176 173 { 177 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << endl; 174 Ray *pray = (*it)->mPiercingRays[0]; 175 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << " " << pray->intersections.size() << endl; 176 177 exporter->ExportRays((*it)->mPiercingRays); 178 179 exporter->SetFilled(); 180 exporter->SetForcedMaterial(RgbColor(0,0,1)); 181 182 for (int j = 0; j < (int)pray->intersections.size(); ++ j) 183 { 184 if (pray->intersections[j].mObject) 185 exporter->ExportIntersectable(pray->intersections[j].mObject); 186 } 187 188 //exporter->SetWireframe(); 189 exporter->SetForcedMaterial(RgbColor(0,1,0)); 190 exporter->ExportGeometry(obj); 191 192 exporter->SetFilled(); 193 194 exporter->SetForcedMaterial(RgbColor(1,0,0)); 178 195 ExportViewCellGeometry(exporter, *it); 196 197 delete exporter; 179 198 } 180 199 200 181 201 ++ i; 182 202 } 183 203 } 184 Debug << "\n found " << i << " new view cells (" << " of " <<mEmptyViewCells.size() << ")" << endl << endl;204 Debug << "\nSampled " << i << " new view cells (" << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 185 205 } 186 206 … … 289 309 290 310 // should we use directional samples? 291 bool dirSamples = mSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION;311 bool dirSamples = (mSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 292 312 293 313 while (numSamples < n) … … 296 316 VssRayContainer constructionSamples; 297 317 298 const int samplingType = 299 dirSamples ?318 const int samplingType = mSamplingType; 319 /*dirSamples ? 300 320 Preprocessor::DIRECTION_BASED_DISTRIBUTION : 301 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 321 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION;*/ 302 322 303 323 if (0) … … 327 347 VssRayContainer postProcessSamples; 328 348 329 //-- construction rays => we use uniform samples for this349 //-- construction rays 330 350 CastPassSamples(mPostProcessSamples, 331 Preprocessor::DIRECTION_BASED_DISTRIBUTION,351 mSamplingType, 332 352 postProcessSamples); 333 353 … … 359 379 360 380 // only for testing 361 CollectEmptyViewCells(); 381 if (TEST_EMPTY_VIEW_CELLS) 382 CollectEmptyViewCells(); 362 383 363 384 … … 495 516 496 517 // find empty view cells bug 497 TestEmptyViewCells(); 518 if (TEST_EMPTY_VIEW_CELLS) 519 TestEmptyViewCells(preprocessor->mObjects); 498 520 } 499 521 … … 1083 1105 { 1084 1106 ViewCell *viewcell = *it; 1107 1085 1108 if (viewcell->GetValid()) 1086 1109 { 1110 // HACK 1111 if (TEST_EMPTY_VIEW_CELLS) 1112 for (int i = 0; i < mEmptyViewCells.size(); ++i) 1113 { 1114 if (viewcell == mEmptyViewCells[i]) 1115 { 1116 viewcell->mPiercingRays.push_back(new Ray(ray)); 1117 Debug << "empty view cell ray found: " << ray.mOriginObject << ", " << ray.mTerminationObject << endl; 1118 } 1119 } 1120 1087 1121 // if ray not outside of view space 1088 1122 float contribution; … … 1773 1807 newVol += lVol; 1774 1808 subdivVol += (*it)->GetVolume(); 1809 1810 float thres = 0.9; 1811 if ((lVol < ((*it)->GetVolume() * thres)) || 1812 (lVol * thres > ((*it)->GetVolume()))) 1813 Debug << "warning: " << lVol << " " << (*it)->GetVolume() << endl; 1775 1814 } 1776 1815 … … 3032 3071 MergeViewCells(postProcessRays, objects); 3033 3072 3034 3035 Debug << "here4" << endl;3036 3073 // only for testing 3037 3074 TestSubdivision(); … … 3341 3378 Debug << "\nOutput view cells: " << endl; 3342 3379 3380 const bool sortViewCells = true; 3381 3343 3382 // sort view cells to visualize the largest view cells 3344 if ( 0)3383 if (sortViewCells) 3345 3384 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 3346 3385 … … 3354 3393 cout << "creating output for view cell " << i << " ... "; 3355 3394 3356 3357 3395 ViewCell *vc; 3358 3396 3359 if ( 0) // largest view cell pvs first3397 if (sortViewCells) // largest view cell pvs first 3360 3398 vc = mViewCells[i]; 3361 3399 else … … 3370 3408 if (1 || mExportRays) 3371 3409 { 3410 // output rays stored with the view cells during subdivision 3372 3411 if (0) 3373 3412 { … … 3408 3447 } 3409 3448 3410 3449 // associate new rays with output view cell 3411 3450 if (1) 3412 3451 { … … 3598 3637 0.00000001f); 3599 3638 3600 //Debug << " heregeo size: " << geom.Size() << endl;3601 //Debug << " heresize b: " << back.Size() << " f: " << front.Size() << endl;3639 //Debug << "geo size: " << geom.Size() << endl; 3640 //Debug << "size b: " << back.Size() << " f: " << front.Size() << endl; 3602 3641 if (back.Valid()) 3603 3642 { 3604 3643 exporter->ExportPolygons(back.GetPolys()); 3605 3644 } 3606 //else Debug << "here2 size: " << back.Size() << endl;3645 3607 3646 } 3608 3647 }
Note: See TracChangeset
for help on using the changeset viewer.