Changeset 1778 for GTP/trunk/Lib/Vis
- Timestamp:
- 11/21/06 19:41:11 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1774 r1778 40 40 41 41 42 /// sorting operator 43 inline static bool ilt2(Intersectable *obj1, Intersectable *obj2) 44 { 45 return obj1->GetBox().SurfaceArea() < obj2->GetBox().SurfaceArea(); 46 } 47 42 48 /***************************************************************/ 43 49 /* class BvhNode implementation */ … … 219 225 ReadEnvironment(); 220 226 mSubdivisionCandidates = new SortableEntryContainer; 221 for (int i = 0; i < 3; ++ i)227 for (int i = 0; i < 4; ++ i) 222 228 mSortedObjects[i] = NULL; 223 229 } … … 230 236 231 237 // delete the presorted objects 232 for (int i = 0; i < 3; ++ i)238 for (int i = 0; i < 4; ++ i) 233 239 { 234 240 DEL_PTR(mSortedObjects[i]); … … 1194 1200 ofstream volrStats; 1195 1201 1196 const bool printStats = 1197 PrepareOutput(axis, mBvhStats.Leaves(), sumStats, vollStats, volrStats); 1202 const bool printStats = PrepareOutput(axis, 1203 mBvhStats.Leaves(), 1204 sumStats, 1205 vollStats, 1206 volrStats); 1198 1207 #endif 1199 1208 … … 1346 1355 // collect and mark the view cells as belonging to front pvs 1347 1356 ViewCellContainer viewCells; 1348 CollectViewCells(tData.mNode->mObjects, viewCells, true, true); 1349 1357 1358 const int numRays = CollectViewCells(tData.mNode->mObjects, viewCells, true, true); 1359 //cout << "here4 " << numRays << endl; 1360 1350 1361 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1351 1362 for (vit = viewCells.begin(); vit != vit_end; ++ vit) … … 1443 1454 sAxis = box.Size().DrivingAxis(); 1444 1455 } 1445 1446 1456 1447 1457 // only use a subset of the rays for visibility based heuristics … … 1743 1753 1744 1754 if (onlyMailedRays && !ray->Mailed()) 1755 {//if (onlyMailedRays)cout << "u"; 1745 1756 continue; 1757 }//else if (onlyMailedRays) cout << "z"; 1746 1758 1747 1759 //ray->Mail(); … … 2139 2151 } 2140 2152 } 2153 2154 // create new objects 2155 if (!mSortedObjects[3]) 2156 { 2157 mSortedObjects[3] = new SortableEntryContainer(); 2158 } 2159 /* 2160 // last sorted list: by size 2161 tData.mSortedObjects[3] = new ObjectContainer(); 2162 tData.mSortedObjects[3]->reserve((int)mSortedObjects[i]->size()); 2163 2164 SortableEntryContainer::const_iterator oit, oit_end = mSortedObjects[i]->end(); 2165 2166 for (oit = mSortedObjects[3]->begin(); oit != oit_end; ++ oit) 2167 { 2168 tData.mSortedObjects[3]->push_back((*oit).mObject); 2169 } 2170 */ 2141 2171 } 2142 2172 … … 2443 2473 2444 2474 2445 void BvHierarchy::InititialSubdivision() 2446 { 2447 } 2448 2449 2450 void ChooseSplitPlane(BvhLeaf *leaf) 2451 {/* 2452 std::stable_sort(objects.begin(), objects.end(), ilt); 2453 2454 // intersected objects 2455 MeshInstance sObj(NULL); 2456 2457 if (sObj.mId >= 0) 2458 { 2459 ObjectContainer::iterator oit = 2460 lower_bound(objects.begin(), objects.end(), &sObj, ilt); 2461 sourceObj = *oit; 2462 } 2463 */ 2464 } 2465 2466 2467 bool BvHierarchy::InitialTerminationCriteriaMet(BvhLeaf *leaf) 2468 { 2469 /*if (((int)leaf->mObjects.size() < mInititialObjectsSize) || 2470 (leaf->mObjects.end().GetBoundingBox().SurfaceArea() < mMinInitialSuffaceArea)) 2471 2472 { 2473 return true; 2475 void BvHierarchy::InititialSubdivision(ObjectContainer &objects) 2476 { 2477 /*std::stable_sort(objects.begin(), objects.end(), ilt2); 2478 ObjectContainer::iterator oit; 2479 2480 stack<BvhLeaf *> tStack; 2481 2482 while (!tStack.empty()) 2483 { 2484 BvhLeaf *leaf = tStack.top(); 2485 2486 if (!InitialTerminationCriteriaMet(leaf)) 2487 { 2488 ChooseSplitIndex(objects, oit); 2489 SubdivideLeaf(leaf, oit); 2490 } 2474 2491 }*/ 2492 } 2493 2494 2495 void BvHierarchy::ChooseSplitIndex(const ObjectContainer &objects, 2496 ObjectContainer::const_iterator &oit) 2497 { 2498 ObjectContainer::const_iterator oit2, oit2_end = objects.end(); 2499 2500 float maxAreaDiff = 0.0f; 2501 2502 for (oit2 = objects.begin(); oit2 != (objects.end() - 1); ++ oit2) 2503 { 2504 Intersectable *obj = *oit2; 2505 Intersectable *obj2 = *(oit2 + 1); 2506 2507 const float areaDiff = 2508 fabs(obj->GetBox().SurfaceArea() - obj2->GetBox().SurfaceArea()); 2509 2510 if (areaDiff > maxAreaDiff) 2511 { 2512 maxAreaDiff = areaDiff; 2513 oit = oit2; 2514 } 2515 } 2516 } 2517 2518 2519 bool BvHierarchy::InitialTerminationCriteriaMet(BvhLeaf *leaf) const 2520 { 2521 if (((int)leaf->mObjects.size() < mInititialObjectsSize) || 2522 (leaf->mObjects.back()->GetBox().SurfaceArea() < mMinInitialSurfaceArea)) 2523 2524 { 2525 return true; 2526 } 2527 2475 2528 return false; 2476 2529 } -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1774 r1778 404 404 mNumRays(0) 405 405 { 406 mSortedObjects[0] = mSortedObjects[1] = mSortedObjects[2] = NULL; 406 for (int i = 0; i < 4; ++ i) 407 mSortedObjects[i] = NULL; 407 408 } 408 409 … … 419 420 mNumRays(numRays) 420 421 { 421 mSortedObjects[0] = mSortedObjects[1] = mSortedObjects[2] = NULL; 422 for (int i = 0; i < 4; ++ i) 423 mSortedObjects[i] = NULL; 422 424 } 423 425 … … 427 429 { 428 430 DEL_PTR(mNode); 429 DEL_PTR(mSortedObjects[0]); 430 DEL_PTR(mSortedObjects[1]); 431 DEL_PTR(mSortedObjects[2]); 431 for (int i = 0; i < 4; ++ i) 432 DEL_PTR(mSortedObjects[i]); 432 433 } 433 434 … … 447 448 int mNumRays; 448 449 /// the sorted objects for the three dimensions 449 ObjectContainer *mSortedObjects[ 3];450 ObjectContainer *mSortedObjects[4]; 450 451 }; 451 452 … … 895 896 some criteria (size, shader) 896 897 */ 897 void InititialSubdivision(); 898 899 void ChooseSplitPlane(BvhLeaf *leaf); 900 901 bool InitialTerminationCriteriaMet(BvhLeaf *leaf); 902 float mMinInitialSuffaceArea; 898 void InititialSubdivision(ObjectContainer &objects); 899 900 void ChooseSplitIndex(const ObjectContainer &objects, 901 ObjectContainer::const_iterator &oit); 902 903 bool InitialTerminationCriteriaMet(BvhLeaf *leaf) const; 904 float mMinInitialSurfaceArea; 905 int mInititialObjectsSize; 903 906 protected: 904 907 … … 987 990 bool mUseBboxAreaForSah; 988 991 989 SortableEntryContainer *mSortedObjects[ 3];992 SortableEntryContainer *mSortedObjects[4]; 990 993 991 994 int mMinRaysForVisibility; -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1764 r1778 30 30 31 31 32 32 33 /*******************************************************************/ 33 34 /* class HierarchyManager implementation */ … … 1899 1900 float rc = 0; 1900 1901 ObjectPvs pvs; 1901 mVspTree->mViewCellsTree->GetPvs(vc, pvs); 1902 1902 1903 //mVspTree->mViewCellsTree->GetPvs(vc, pvs); 1904 GetPvsIncrementally(vc, pvs); 1905 1903 1906 vc->SetPvs(pvs); 1904 1907 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1773 r1778 129 129 { 130 130 mStrategies.push_back(SamplingStrategy::VIEWSPACE_BORDER_BASED_DISTRIBUTION); 131 132 // ratio 3:1 133 mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 134 mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 131 135 mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 132 136 } … … 405 409 406 410 // cast initial samples 411 412 // mix of sampling strategies 413 vector<int>dummy; 414 //dummy.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 415 //dummy.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 416 //dummy.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 417 407 418 CastPassSamples(mInitialSamples, mStrategies, initialSamples); 408 419 … … 561 572 if (mShowVisualization) 562 573 { 563 cout << "************************\n*********************\n";564 574 if (0) 565 575 { … … 5998 6008 Debug << "casting " << samplesPerPass << " samples ... "; 5999 6009 6010 vector<int>dummyStrat; 6011 6012 dummyStrat.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 6013 dummyStrat.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 6014 dummyStrat.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 6015 //dummyStrat.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 6016 6000 6017 CastPassSamples(samplesPerPass, mStrategies, evaluationSamples); 6001 6018
Note: See TracChangeset
for help on using the changeset viewer.