Changeset 2530 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 07/06/07 03:18:02 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BitVectorPvs.h
r2206 r2530 267 267 268 268 template <typename T, typename S> 269 bool BitVectorPvs<T, S>::AddSampleDirtyCheck(T sample, 270 const float pdf) 269 bool BitVectorPvs<T, S>::AddSampleDirtyCheck(T sample, const float pdf) 271 270 { 272 271 if (Find(sample)) -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r2350 r2530 761 761 762 762 if (mHierarchyManager->mConsiderMemory) 763 {764 763 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst); 765 }766 764 } 767 765 -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r2524 r2530 1132 1132 "kd_split_method=", 1133 1133 "spatialMedian"); 1134 1135 1134 1136 1135 RegisterOption("KdTree.pvsArea", -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2116 r2530 63 63 KdTree *tree): 64 64 Renderer(sceneGraph, viewCellsManager), 65 mKdTree(tree) 65 mKdTree(tree), 66 mUseFalseColors(false) 66 67 { 67 68 mSceneGraph->CollectObjects(&mObjects); … … 231 232 232 233 233 void 234 GlRenderer::RenderMeshInstance(MeshInstance *mi) 235 { 236 RenderMesh(mi->GetMesh()); 234 void GlRenderer::RenderMeshInstance(MeshInstance *mi) 235 { 236 RenderMesh(mi->GetMesh()); 237 237 } 238 238 -
GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h
r2206 r2530 93 93 public: 94 94 95 HashPvs() //: mEntries(1009)95 HashPvs() 96 96 { 97 97 mEntries.set_deleted_key(-1); 98 98 mEntries.set_empty_key(-2); 99 99 }; 100 //virtual ~HashPvs() {};101 100 102 101 int GetSize() const; … … 107 106 */ 108 107 float AddSample(T sample, const float pdf); 109 110 108 /** Adds sample to PVS without checking for presence of the sample 111 109 warning: pvs remains unsorted! 112 110 */ 113 111 void AddSampleDirty(T sample, const float pdf); 114 115 112 /** Adds sample dirty (on the end of the vector) but 116 113 first checks if sample is already in clean part of the pvs. 117 114 */ 118 115 bool AddSampleDirtyCheck(T sample, const float pdf); 119 120 116 /** Sort pvs entries - this should always be called after a 121 117 sequence of AddSampleDirty calls 122 118 */ 123 119 void Sort(); 124 125 120 /** Clears the pvs. 126 121 */ … … 130 125 131 126 inline bool RequiresResort() const; 132 133 127 /** Finds sample in PVS. 134 128 @param checkDirty if dirty part of the pvs should be checked for entry … … 140 134 141 135 typename HashPvsIterator<T, S> GetIterator() const; 142 143 136 /** Compute continuous PVS difference 144 137 */ … … 156 149 float &contribution); 157 150 158 int GetSamples() const 159 { 160 return mSamples; 151 inline int GetSamples() const { return mSamples; } 161 152 } 162 153 … … 166 157 } 167 158 168 bool RequiresResortLog() const 169 { 170 return false; 171 } 172 173 void Reserve(const int n) 174 { 175 // not necessary 176 } 159 inline bool RequiresResortLog() const { return false; } 160 161 void Reserve(const int n) { // not necessary } 177 162 178 163 /** Sort pvs entries assume that the pvs contains unique entries 179 164 */ 180 void SimpleSort() 181 { 182 // not necessary 183 } 165 void SimpleSort() { // not necessary } 184 166 185 167 int SubtractPvs(const HashPvs<T, S> &pvs) … … 188 170 return 0; 189 171 } 190 191 172 /** Compute continuous PVS difference 192 173 */ … … 197 178 cerr << "not yet implemented" << endl; 198 179 } 180 181 199 182 protected: 200 183 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r2353 r2530 197 197 */ 198 198 HierarchyManager(const int objectSpaceHierarchyType); 199 200 199 /** Hack: OspTree will copy the content from this kd tree. 201 200 Only view space hierarchy will be constructed. 202 201 */ 203 202 HierarchyManager(KdTree *kdTree); 204 205 203 /** Deletes space partition and view space partition. 206 204 */ 207 205 ~HierarchyManager(); 208 209 206 /** Constructs the view space and object space subdivision from a given set of rays 210 207 and a set of objects. … … 233 230 */ 234 231 int GetObjectSpaceSubdivisionType() const; 235 236 232 /** The type of view space space subdivison 237 233 */ 238 234 int GetViewSpaceSubdivisionType() const; 239 240 235 /** Sets a pointer to the view cells manager. 241 236 */ 242 237 void SetViewCellsManager(ViewCellsManager *vcm); 243 244 238 /** Sets a pointer to the view cells tree. 245 239 */ 246 240 void SetViewCellsTree(ViewCellsTree *vcTree); 247 248 241 /** Exports the object hierarchy to disc. 249 242 */ 250 243 void ExportObjectSpaceHierarchy(OUT_STREAM &stream); 251 252 244 /** Print out statistics. 253 245 */ 254 246 void PrintHierarchyStatistics(std::ostream &stream) const; 255 256 247 /** Returns the view space partition tree. 257 248 */ 258 249 VspTree *GetVspTree(); 259 260 250 /** Returns object space bounding box. 261 251 */ 262 252 AxisAlignedBox3 GetObjectSpaceBox() const; 263 264 253 /** Exports object space hierarchy for visualization. 265 254 */ … … 275 264 276 265 Intersectable *GetIntersectable(Intersectable *obj, const Vector3 &point) const; 277 278 266 /** Export object space partition bounding boxes. 279 267 */ … … 306 294 const float totalPvs, 307 295 const float raysPerObjects) const; 308 309 310 296 /** Casts line segment into the view cells tree. 311 297 @param origin the origin of the line segment … … 346 332 347 333 348 ////////////// ////////////////349 // the main loop334 ////////////// 335 // these functions implement the main loop 350 336 351 337 /** This is for interleaved construction / sequential construction. … … 355 341 const ObjectContainer &objects, 356 342 AxisAlignedBox3 *forcedViewSpace); 357 358 343 /** This is for interleaved construction using some objects 359 344 and some view space splits. … … 365 350 const int minSteps, 366 351 const int maxSteps); 367 368 352 /** Default subdivision method. 369 353 */ … … 371 355 372 356 373 ////////////////////////// //////////////////////357 ////////////////////////// 374 358 375 359 /** Evaluates the subdivision candidate and executes the split. … … 380 364 std::vector<SubdivisionCandidate *> &dirtyList 381 365 ); 382 383 366 /** Tests if hierarchy construction is finished. 384 367 */ 385 368 bool FinishedConstruction() const; 386 387 369 /** Returns next subdivision candidate from the split queue. 388 370 */ 389 371 SubdivisionCandidate *NextSubdivisionCandidate(SplitQueue &splitQueue); 390 391 372 /** Repairs the dirty entries of the subdivision candidate queue. The 392 373 list of entries is given in the dirty list. … … 397 378 SplitQueue &splitQueue, 398 379 const bool recomputeSplitPlaneOnRepair); 399 400 380 /** Collect subdivision candidates which were affected by the splits from the 401 381 chosenCandidates list. … … 403 383 void CollectDirtyCandidates(const SubdivisionCandidateContainer &chosenCandidates, 404 384 SubdivisionCandidateContainer &dirtyList); 405 406 385 /** Print subdivision stats for log. 407 386 */ … … 420 399 void CollectViewSpaceDirtyList(SubdivisionCandidate *sc, 421 400 SubdivisionCandidateContainer &dirtyList); 422 423 401 /** Collect affected object space candidates. 424 402 */ 425 403 void CollectObjectSpaceDirtyList(SubdivisionCandidate *sc, 426 404 SubdivisionCandidateContainer &dirtyList); 427 428 405 /** Export object space partition tree. 429 406 */ 430 407 void ExportOspTree(Exporter *exporter, 431 408 const ObjectContainer &objects) const; 432 433 409 /** Parse the environment variables. 434 410 */ … … 463 439 */ 464 440 bool ObjectSpaceSubdivisionConstructed() const; 465 466 441 /** Was view space subdivision already constructed? 467 442 */ 468 443 bool ViewSpaceSubdivisionConstructed() const; 469 470 444 /** Reset the split queue, i.e., reevaluate the split candidates. 471 445 */ 472 446 void ResetQueue(SplitQueue &splitQueue, const bool recomputeSplitPlane); 473 474 447 /** After the suddivision has ended, do some final tasks. 475 448 */ 476 449 void FinishObjectSpaceSubdivision(const ObjectContainer &objects, 477 450 const bool removeRayRefs = true) const; 478 479 451 /** Returns depth of object space subdivision. 480 452 */ 481 453 int GetObjectSpaceSubdivisionDepth() const; 482 483 454 /** Returns number of leaves in object space subdivision. 484 455 */ 485 456 int GetObjectSpaceSubdivisionLeaves() const; 486 457 int GetObjectSpaceSubdivisionNodes() const; 487 488 458 /** Construct object space partition interleaved with view space partition. 489 459 Each time the best object or view space candidate is selected … … 493 463 const ObjectContainer &objects, 494 464 AxisAlignedBox3 *forcedViewSpace); 495 496 465 /** Construct object space partition interleaved with view space partition. 497 466 The method chooses a number candidates of each type for subdivision. … … 505 474 const ObjectContainer &objects, 506 475 AxisAlignedBox3 *forcedViewSpace); 507 508 476 /** Use iteration to construct the object space hierarchy. 509 477 */ … … 511 479 const ObjectContainer &objects, 512 480 AxisAlignedBox3 *forcedViewSpace); 513 514 481 /** Based on a given subdivision, we try to optimize using an 515 482 multiple iteration over view and object space. … … 518 485 const ObjectContainer &objects, 519 486 AxisAlignedBox3 *forcedViewSpace); 520 521 487 /** Reset the object space subdivision. 522 488 E.g., deletes hierarchy and resets stats. … … 533 499 534 500 void CreateTraversalTree(); 501 535 502 536 503 /////////////////////////// … … 570 537 protected: 571 538 539 friend VspTree; 540 friend OspTree; 541 friend BvHierarchy; 542 friend ViewCellsParseHandlers; 543 544 572 545 /** construction types 573 546 sequential: construct first view space, then object space … … 580 553 /// type of hierarchy construction 581 554 int mConstructionType; 582 583 555 /// Type of object space partition 584 556 int mObjectSpaceSubdivisionType; … … 586 558 int mViewSpaceSubdivisionType; 587 559 588 /// the traversal queue560 /// the queue maintains the split candidates during traversal 589 561 SplitQueue mTQueue; 590 591 ////////////592 //-- helper variables593 594 // the original osp type595 int mSavedObjectSpaceSubdivisionType;596 // the original vsp type597 int mSavedViewSpaceSubdivisionType;598 562 599 563 … … 601 565 // Hierarchies 602 566 567 /// the bounding volume hierarchy 568 BvHierarchy *mBvHierarchy; 603 569 /// view space hierarchy 604 570 VspTree *mVspTree; … … 608 574 float mInitialRenderCost; 609 575 610 //float mMaxAvgRayContri;611 //float mMinAvgRayContri;612 613 576 float mMaxAvgRaysPerObject; 614 577 float mMinAvgRaysPerObject; 615 578 616 // quick hack: 617 public: 618 /// bounding volume hierarchy 619 BvHierarchy *mBvHierarchy; 620 579 580 /// an internal tree optimized for view cell traversal 621 581 bool mUseTraversalTree; 622 623 float mMinRenderCost;624 625 protected:626 582 627 583 … … 638 594 float mTermMaxMemory; 639 595 596 float mMinRenderCost; 597 640 598 641 599 //////////////////// … … 651 609 int mMinDepthForViewSpaceSubdivion; 652 610 653 //int mMinRenderCostDecrease;654 655 std::ofstream mSubdivisionStats;656 657 611 /// if the queue should be repaired after a subdivision steps 658 612 bool mRepairQueue; 659 613 660 614 bool mStartWithObjectSpace; 661 /** if multi level construction method should be used662 w here we iterate over both hierarchies until we663 converge to the optimum. 615 /** multi level construction method means that 616 we iterate over both hierarchies until we 617 converge to the optimum. 664 618 */ 665 619 bool mUseMultiLevelConstruction; 666 667 620 /// number of iteration steps for multilevel approach 668 621 int mNumMultiLevels; 669 670 622 /** if split plane should be recomputed for the repair. 671 623 Otherwise only the priority is recomputed, the 672 split plane itself stays the same 624 split plane itself stays the same. 673 625 */ 674 626 bool mRecomputeSplitPlaneOnRepair; 675 627 676 628 /** If memory should be considered during choosing 677 of the next split type during gradient method. 629 of the next split type during gradient method. 678 630 */ 679 631 bool mConsiderMemory; … … 684 636 685 637 int mTimeStamp; 686 friend VspTree;687 friend OspTree;688 friend BvHierarchy;689 638 690 639 float mPriority; 691 640 692 friend ViewCellsParseHandlers; 693 641 642 //////////// 643 //-- helper variables 644 645 // the original osp type 646 int mSavedObjectSpaceSubdivisionType; 647 // the original vsp type 648 int mSavedViewSpaceSubdivisionType; 649 650 651 /// this is just a cache used during evaluation 694 652 ViewCellContainer mOldViewCells; 653 654 std::ofstream mSubdivisionStats; 695 655 }; 696 656 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r2353 r2530 126 126 OptimizeForWindowsApplication="TRUE" 127 127 AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";"$(CG_INC_PATH)";Timer;..\src\sparsehash\src\google\sparsehash;..\src\sparsehash\src\windows;..\src\sparsehash\src\google;..\src\sparsehash\src;..\src\ootl\;..\src\ootl\src\;..\src\ootl\src\cpp;..\src\ootl\src\cpp\include\;..\src\ootl\src\include\ootl;..\src\ootl\src\include\ootl\sandbox;..\src\ootl\src\cpp\include\ootl\mswin" 128 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL;USE_QT;USE_ HASH_PV"128 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL;USE_QT;USE_VERBOSE_PV" 129 129 StringPooling="TRUE" 130 130 MinimalRebuild="TRUE" … … 1041 1041 </File> 1042 1042 <File 1043 RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h"> 1044 </File> 1045 <File 1043 1046 RelativePath=".\sparsehash\src\windows\hash_fun.h"> 1044 </File>1045 <File1046 RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h">1047 1047 </File> 1048 1048 <File -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r2529 r2530 8 8 9 9 10 //11 10 12 11 namespace GtpVisibilityPreprocessor { 13 12 14 13 14 /** Iterator over the pvs. 15 */ 15 16 template<typename T, typename S> 16 17 class PvsIterator … … 24 25 } 25 26 26 bool HasMoreEntries() const 27 { 28 return (mItCurrent != mItEnd); 29 } 30 31 T Next(S &pdf) 32 { 27 inline bool HasMoreEntries() const { return (mItCurrent != mItEnd); } 28 29 inline T Next(S &pdf) { 33 30 pdf = (*mItCurrent).mData; 34 31 return (*(mItCurrent ++)).mObject; 35 32 } 36 33 37 T Next() 38 { 39 return (*(mItCurrent ++)).mObject; 40 } 34 inline T Next() { return (*(mItCurrent ++)).mObject; } 35 41 36 42 37 private: 38 43 39 typename vector<PvsEntry<T, S> >::const_iterator mItCurrent; 44 40 typename vector<PvsEntry<T, S> >::const_iterator mItEnd; … … 56 52 public: 57 53 58 VerbosePvs(): mSamples(0), mEntries(), mLastSorted(0), mQueriesSinceSort(0) {} 54 VerbosePvs(): mSamples(0), mEntries(), mLastSorted(0), mQueriesSinceSort(0) 55 {} 59 56 60 57 /** creates pvs and initializes it with the given entries. … … 619 616 620 617 template <typename T, typename S> 621 bool VerbosePvs<T, S>::AddSampleDirtyCheck(T sample, 622 const float pdf) 623 //,float &contribution) 618 bool VerbosePvs<T, S>::AddSampleDirtyCheck(T sample, const float pdf) 624 619 { 625 620 ++ mSamples; … … 633 628 634 629 data.mSumPdf += pdf; 635 //contribution = pdf / data.mSumPdf;636 637 630 return false; 638 631 } … … 640 633 { 641 634 AddSampleDirty(sample, pdf); 642 //contribution = 1.0f;643 644 635 return true; 645 636 } -
GTP/trunk/Lib/Vis/Preprocessing/src/PvsBase.h
r2529 r2530 5 5 #include "Containers.h" 6 6 7 // 7 8 8 9 9 namespace GtpVisibilityPreprocessor { 10 10 11 //class Intersectable;12 11 13 12 /** Information stored with a PVS entry. Consists of the number -
GTP/trunk/Lib/Vis/Preprocessing/src/PvsDefinitions.h
r2176 r2530 31 31 } 32 32 33 #else 34 35 //#ifdef USE_VERBOSE_PVS 33 #else // USE_VERBOSE_PVS 36 34 #include "Pvs.h" 37 35 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2529 r2530 134 134 Intersectable::NewMail(); 135 135 for (; it.HasMoreEntries(); ) { 136 ObjectPvsEntry entry = it.Next(); 137 Intersectable *object = entry.mObject; 138 RenderIntersectable(object); 136 RenderIntersectable(it.Next()); 139 137 } 140 138 … … 208 206 ObjectPvsIterator it = pvs.GetIterator(); 209 207 for (; it.HasMoreEntries(); ) { 210 ObjectPvsEntry entry = it.Next(); 211 Intersectable *object = entry.mObject; 212 RenderIntersectable(object); 208 RenderIntersectable(it.Next()); 213 209 } 214 210 … … 402 398 Intersectable::NewMail(); 403 399 400 PvsData pvsData; 401 404 402 // Render PVS 405 403 if (mUseSpatialFilter && mRenderBoxes) { … … 411 409 mPvsSize = mPvsCache.mPvs.GetSize(); 412 410 for (; it.HasMoreEntries(); ) { 413 ObjectPvsEntry entry = it.Next(); 414 Intersectable *object = entry.mObject; 411 Intersectable *object = it.Next(pvsData); 415 412 416 413 if (mRenderVisibilityEstimates) { 417 414 //float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 418 415 // glColor3f(visibility, 0.0f, 0.0f); 419 cerr << "sumpdf: " << entry.mData.mSumPdf << endl;420 RgbColor color = RainbowColorMapping(mTransferFunction*log10( entry.mData.mSumPdf + 1));416 //cerr << "sumpdf: " << pvsData.mSumPdf << endl; 417 RgbColor color = RainbowColorMapping(mTransferFunction*log10(pvsData.mSumPdf + 1)); 421 418 glColor3f(color.r, color.g, color.b); 422 419 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface.vcproj
r2017 r2530 166 166 Name="VCCLCompilerTool" 167 167 AdditionalIncludeDirectories="..\..\src;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\..\..\..\..\..\..\NonGTP\Zlib\include;"$(CG_INC_PATH)"" 168 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;QTGLRENDERER_EXPORTS "168 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;QTGLRENDERER_EXPORTS;USE_VERBOSE_PVS" 169 169 RuntimeLibrary="2" 170 170 UsePrecompiledHeader="0" -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r2381 r2530 145 145 OptimizeForWindowsApplication="TRUE" 146 146 AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;"$(QTDIR)\include\QtOpenGl";"$(QTDIR)\include\Qt";"$(QTDIR)\include\QtCore";"$(QTDIR)\include";QtInterface;..\src\sparsehash\src\;..\src\ootl\src\include\ootl;..\src\ootl\src\include\ootl\sandbox;$(NOINHERIT)" 147 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT;USE_CG;USE_ HASH_PV"147 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT;USE_CG;USE_VERBOSE_PV" 148 148 StringPooling="TRUE" 149 149 MinimalRebuild="TRUE" -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2529 r2530 6746 6746 6747 6747 6748 static voidPrintCompressionStats(HierarchyManager *hm, const int pvsEntries)6749 { 6750 float mem = (float)pvsEntries * ObjectPvs::GetEntrySize();6748 void VspOspViewCellsManager::PrintCompressionStats(HierarchyManager *hm, const int pvsEntries) 6749 { 6750 const float mem = (float)pvsEntries * ObjectPvs::GetEntrySize(); 6751 6751 6752 6752 float fullmem = mem + -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r2394 r2530 1326 1326 1327 1327 virtual void CompressViewCells(); 1328 1329 1328 /** Prepare view cells for use after loading them from disc. 1330 1329 */ 1331 1330 void PrepareLoadedViewCells(); 1332 1333 1331 /** Constructs merge hierarchy which corresponds to the spatial hierarchy. 1334 1332 */ 1335 1333 ViewCell *ConstructSpatialMergeTree(VspNode *root); 1336 1337 1334 /** Exports visualization of the PVS. 1338 1335 */ 1339 1336 void ExportPvs(const ObjectContainer &objects, const VssRayContainer &rays); 1340 1341 1337 /** Returns a hierarchy manager of the given name. 1342 1338 */ 1343 1339 static HierarchyManager *CreateHierarchyManager(const string &name); 1344 1345 1340 /** collect objects intersecting a given spatial box 1346 1341 */ 1347 1342 virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 1348 1343 1349 1350 ///////////////////////////////////////// 1344 static void PrintCompressionStats(HierarchyManager *hm, const int pvsEntries); 1345 1346 1347 //////////////////// 1351 1348 1352 1349 bool mCompressObjects;
Note: See TracChangeset
for help on using the changeset viewer.