Changeset 1522 for GTP/trunk/Lib
- Timestamp:
- 09/27/06 19:23:51 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1486 r1522 489 489 const float renderCostDecr = oldRenderCost - newRenderCost; 490 490 491 //#ifdef _DEBUG491 #ifdef _DEBUG 492 492 Debug << "old render cost: " << oldRenderCost << endl; 493 493 Debug << "new render cost: " << newRenderCost << endl; 494 494 Debug << "render cost decrease: " << renderCostDecr << endl; 495 //#endif495 #endif 496 496 splitCandidate.SetRenderCostDecrease(renderCostDecr); 497 497 … … 527 527 (0 528 528 || (mBvhStats.Leaves() >= mTermMaxLeaves) 529 || (mBvhStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance)529 //|| (mBvhStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 530 530 //|| mOutOfMemory 531 531 ); … … 974 974 975 975 #ifdef _DEBUG 976 Debug << "\n§§§§ eval local cost§§§§" << endl976 Debug << "\n§§§§ bvh eval const decrease §§§§" << endl 977 977 << "back pvs: " << (int)objectsBack.size() << " front pvs: " << (int)objectsFront.size() << " total pvs: " << nTotalObjects << endl 978 978 << "back p: " << volBack / viewSpaceVol << " front p " << volFront / viewSpaceVol << " p: " << totalVol / viewSpaceVol << endl … … 1656 1656 const ObjectContainer &objects) 1657 1657 { 1658 /////////////////////////////////////// ////////////////////////1659 //-- note matt:we assume that we have objects sorted by their id =>1658 /////////////////////////////////////// 1659 //-- we assume that we have objects sorted by their id => 1660 1660 //-- we don't have to sort them here and an binary search 1661 1661 //-- for identifying if a object is in a leaf. … … 1665 1665 1666 1666 mBvhStats.nodes = 1; 1667 1668 1667 1669 1668 // store pointer to this tree 1670 1669 BvhSubdivisionCandidate::sBvHierarchy = this; -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1520 r1522 1272 1272 RegisterOption("GvsPreprocessor.epsilon", 1273 1273 optFloat, 1274 "gvs_epsilon ",1274 "gvs_epsilon=", 1275 1275 "0.00001"); 1276 1276 1277 1277 RegisterOption("GvsPreprocessor.threshold", 1278 1278 optFloat, 1279 "gvs_threshold ",1279 "gvs_threshold=", 1280 1280 "1.5"); 1281 1281 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1521 r1522 8 8 #include "Plane3.h" 9 9 #include "RayCaster.h" 10 #include "Exporter.h" 10 11 11 12 … … 13 14 { 14 15 16 struct VizStruct 17 { 18 Polygon3 *enlargedTriangle; 19 Triangle3 originalTriangle; 20 VssRay *ray; 21 }; 22 23 static vector<VizStruct> vizContainer; 15 24 16 25 GvsPreprocessor::GvsPreprocessor(): Preprocessor(), mSamplingType(0) … … 59 68 bool GvsPreprocessor::HandleRay(VssRay *vssRay) 60 69 { 61 if (mViewCellsManager->ComputeSampleContribution(*vssRay, true, false)) 70 const int oldContri = vssRay->mPvsContribution; 71 mViewCellsManager->ComputeSampleContribution(*vssRay, true, false); 72 73 if ((vssRay->mPvsContribution - oldContri) > 0) // new contribution 62 74 { 63 75 //cout << "h"; 64 76 mRayQueue.push(vssRay); 77 mVssRays.push_back(new VssRay(*vssRay)); 65 78 return true; 66 79 } … … 159 172 160 173 VssRay *newRay = mRayCaster->CastSingleRay(sray.mOrigin, sray.mDirection, 1, mViewSpaceBox); 161 bool addedToQueue = HandleRay(newRay); 174 175 if (!newRay) return 0; 176 const bool enqueued = HandleRay(newRay); 162 177 163 178 const int s1 = SubdivideEdge(hitTriangle, p1, p, x, *newRay, oldRay); … … 165 180 return s1 + s2; 166 181 167 if (! addedToQueue)182 if (!enqueued) 168 183 delete newRay; 169 184 } … … 181 196 { 182 197 hitTriangle = dynamic_cast<TriangleIntersectable *>(tObj)->GetItem(); 198 cout << "t: " << hitTriangle << endl << endl; 199 } 200 else 201 { 202 cout << "not yet implemented" << endl; 183 203 } 184 204 … … 200 220 } 201 221 222 VizStruct dummy; 223 dummy.enlargedTriangle = new Polygon3(enlargedTriangle); 224 dummy.originalTriangle = hitTriangle; 225 //dummy.ray = new VssRay(currentRay); 226 vizContainer.push_back(dummy); 227 202 228 // establish visibility 203 229 VssRayContainer vssRays; 204 230 CastRays(simpleRays, vssRays, false); 231 205 232 // add to ray queue 206 233 EnqueueRays(vssRays); 207 /* 234 #if 0 208 235 // recursivly subdivide each edge 209 236 for (int i = 0; i < 9; ++ i) … … 217 244 currentRay); 218 245 } 219 */ 246 #endif 220 247 return (int)vssRays.size(); 221 248 } … … 375 402 } 376 403 404 Visualize(); 377 405 return true; 378 406 } 379 407 380 } 408 409 void GvsPreprocessor::Visualize() 410 { 411 Exporter *exporter = Exporter::GetExporter("gvs.wrl"); 412 413 if (!exporter) 414 return; 415 416 vector<VizStruct>::const_iterator vit, vit_end = vizContainer.end(); 417 for (vit = vizContainer.begin(); vit != vit_end; ++ vit) 418 { 419 cout << "v"; 420 exporter->ExportPolygon((*vit).enlargedTriangle); 421 //Material m; 422 //Polygon3 poly = Polygon3((*vit).originalTriangle); 423 // exporter->ExportPolygon(&poly); 424 } 425 426 exporter->ExportRays(mVssRays); 427 delete exporter; 428 } 429 430 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r1521 r1522 100 100 void EnqueueRays(VssRayContainer &samples); 101 101 102 /** 103 Hepler function for adaptive border sampling. It finds 102 /** Hepler function for adaptive border sampling. It finds 104 103 new sample points around a triangle in a eps environment 105 104 */ … … 116 115 const VssRay &oldRay); 117 116 117 void Visualize(); 118 118 ////////////////////// 119 119 … … 128 128 float mEps; 129 129 float mThreshold; 130 VssRayContainer mVssRays; 130 131 }; 131 132 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1486 r1522 243 243 ); 244 244 245 if ( 1&& terminationCriteriaMet)245 if (0 && terminationCriteriaMet) 246 246 { 247 247 Debug << "hierarchy global termination criteria met:" << endl; … … 331 331 cout << "\nstarting view space hierarchy construction ... " << endl; 332 332 333 mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses 334 333 335 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 334 336 SubdivisionCandidate *vsc = … … 345 347 const ObjectContainer &objects) 346 348 { 349 mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses 350 347 351 if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 348 352 { … … 407 411 // cost ratio of cost decrease / totalCost 408 412 const float costRatio = mCurrentCandidate->GetRenderCostDecrease() / mTotalCost; 409 Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl;413 //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 410 414 411 415 if (costRatio < mTermMinGlobalCostRatio) … … 606 610 cout << "\nresetting bv hierarchy" << endl; 607 611 mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 608 mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses612 609 613 DEL_PTR(mBvHierarchy); 610 614 mBvHierarchy = new BvHierarchy(); -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1521 r1522 434 434 cout << "loading view cells from " << buf << endl; 435 435 mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true); 436 if (!mViewCellsManager) 437 return false; 436 438 } 437 439 else -
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
r1521 r1522 32 32 if (!rays.empty()) 33 33 return rays.back(); 34 else 35 return NULL; 34 36 } 35 37 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1520 r1522 1830 1830 { 1831 1831 ViewCell *viewcell = *it; 1832 1833 if (viewcell->GetValid()) 1834 { 1835 // if ray not outside of view space 1832 1833 if (viewcell->GetValid()) // tests if view cellis in valid view space 1834 { 1836 1835 float contribution; 1837 1836 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1449 r1522 562 562 // || mOutOfMemory 563 563 || (mVspStats.Leaves() >= mMaxViewCells) 564 || (mVspStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance)564 // || (mVspStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 565 565 ); 566 566 … … 571 571 Debug << "leaves: " << mVspStats.Leaves() << " " << mMaxViewCells << endl; 572 572 } 573 573 574 return terminationCriteriaMet; 574 575 } … … 1482 1483 const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 1483 1484 1484 //#ifdef _DEBUG1485 #ifdef _DEBUG 1485 1486 Debug << "\nvsp render cost decrease" << endl 1486 1487 << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl … … 1488 1489 << "old rc: " << normalizedOldRenderCost << " new rc: " << newRenderCost / viewSpaceVol << endl 1489 1490 << "render cost decrease: " << renderCostDecrease << endl; 1490 //#endif1491 #endif 1491 1492 return renderCostDecrease; 1492 1493 } -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1501 r1522 164 164 165 165 // parse view cells related options 166 preprocessor->PrepareViewCells(); 166 if (!preprocessor->PrepareViewCells()) 167 { 168 Cleanup(); 169 exit(1); 170 } 167 171 168 172 if (0)
Note: See TracChangeset
for help on using the changeset viewer.