Changeset 1982 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 01/15/07 18:33:00 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1981 r1982 28 28 GvsPreprocessor::GvsPreprocessor(): 29 29 Preprocessor(), 30 //mSamplingType(SamplingStrategy::DIRECTION_BASED_DISTRIBUTION), 31 mSamplingType(SamplingStrategy::DIRECTION_BOX_BASED_DISTRIBUTION) 30 mSamplingType(SamplingStrategy::DIRECTION_BOX_BASED_DISTRIBUTION), 31 mNumViewCells(0), 32 mCurrentViewCell(NULL) 32 33 { 33 34 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); … … 55 56 mOnlyRandomSampling = false; 56 57 57 //mGvsStatsStream.open("gvspreprocessor.log");58 58 mGvsStats.Reset(); 59 } 60 61 62 bool GvsPreprocessor::NextViewCell() 63 { 64 if (mViewCellsManager->GetNumViewCells() == mNumViewCells) 65 return false; // no more view cells 66 67 mCurrentViewCell = mViewCellsManager->GetViewCell(mNumViewCells); 68 mViewCellsManager->CreateMesh(mCurrentViewCell); 69 70 ++ mNumViewCells; 71 72 return true; 59 73 } 60 74 … … 350 364 351 365 352 /*Vector3 GvsPreprocessor::GetPassingPoint(const VssRay ¤tRay,353 const Triangle3 &hitTriangle,354 const VssRay &oldRay) const355 {356 //-- intersect triangle plane with plane spanned by current samples357 Plane3 plane(currentRay.GetOrigin(), currentRay.GetTermination(), oldRay.GetTermination());358 Plane3 triPlane(hitTriangle.GetNormal(), hitTriangle.mVertices[0]);359 360 SimpleRay intersectLine = GetPlaneIntersection(plane, triPlane);361 362 // Evaluate new hitpoint just outside the triangle363 const float factor = 0.95f;364 const float t = triPlane.FindT(intersectLine);365 const Vector3 newPoint = intersectLine.mOrigin + t * factor * intersectLine.mDirection;366 367 return newPoint;368 }*/369 370 371 366 Vector3 GvsPreprocessor::GetPassingPoint(const VssRay ¤tRay, 372 367 const Triangle3 &occluder, … … 532 527 533 528 return castSamples; 529 } 530 531 532 void GvsPreprocessor::VisualizeViewCells() 533 { 534 char str[64]; sprintf(str, "tmp/pass%06d_%04d-", mNumViewCells, mPass); 535 536 // visualization 537 if (mGvsStats.mPassContribution > 0) 538 { 539 const bool exportRays = true; 540 const bool exportPvs = true; 541 542 mViewCellsManager->ExportSingleViewCells(mObjects, 543 10, 544 false, 545 exportPvs, 546 exportRays, 547 1000, 548 str); 549 } 550 551 // remove pass samples 552 ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end(); 553 554 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 555 { 556 (*vit)->DelRayRefs(); 557 } 558 } 559 560 561 void GvsPreprocessor::PerViewCellComputation() 562 { 563 const int maxViewCells = 5; 564 565 while (NextViewCell() && mNumViewCells < maxViewCells) 566 { 567 cout << "processing view cell " << mNumViewCells << endl; 568 569 while (mGvsStats.mTotalSamples < mTotalSamples) 570 { 571 ++ mPass; 572 573 mGvsStats.mTotalSamples += Pass(); 574 575 //////// 576 //-- stats 577 578 cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples 579 << " of " << mTotalSamples << endl; 580 581 mGvsStats.mPass = mPass; 582 mGvsStats.Stop(); 583 mGvsStats.Print(mGvsStatsStream); 584 //mViewCellsManager->PrintPvsStatistics(mGvsStats); 585 586 if (GVS_DEBUG) 587 VisualizeViewCells(); 588 } 589 590 // ComputeRenderError(); 591 } 592 } 593 594 595 void GvsPreprocessor::GlobalComputation() 596 { 597 while (mGvsStats.mTotalSamples < mTotalSamples) 598 { 599 ++ mPass; 600 601 mGvsStats.mTotalSamples += Pass(); 602 603 //////// 604 //-- stats 605 606 cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples 607 << " of " << mTotalSamples << endl; 608 609 mGvsStats.mPass = mPass; 610 mGvsStats.Stop(); 611 mGvsStats.Print(mGvsStatsStream); 612 //mViewCellsManager->PrintPvsStatistics(mGvsStats); 613 614 if (GVS_DEBUG) 615 VisualizeViewCells(); 616 } 534 617 } 535 618 … … 564 647 mGvsStats.Print(mGvsStatsStream); 565 648 566 while (mGvsStats.mTotalSamples < mTotalSamples) 567 { 568 ++ mPass; 569 570 mGvsStats.mTotalSamples += Pass(); 571 572 //////// 573 //-- stats 574 575 cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples << " of " << mTotalSamples << endl; 576 mGvsStats.mPass = mPass; 577 mGvsStats.Stop(); 578 mGvsStats.Print(mGvsStatsStream); 579 //mViewCellsManager->PrintPvsStatistics(mGvsStats); 580 581 if (GVS_DEBUG) 582 { 583 char str[64]; sprintf(str, "tmp/pass%04d-", mPass); 584 585 // visualization 586 if (mGvsStats.mPassContribution > 0) 587 { 588 const bool exportRays = true; 589 const bool exportPvs = true; 590 591 mViewCellsManager->ExportSingleViewCells(mObjects, 592 10, 593 false, 594 exportPvs, 595 exportRays, 596 1000, 597 str); 598 } 599 600 // remove pass samples 601 ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end(); 602 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 603 { 604 (*vit)->DelRayRefs(); 605 } 606 } 607 608 // ComputeRenderError(); 649 if (mPerViewCell) 650 { 651 PerViewCellComputation(); 652 } 653 else 654 { 655 GlobalComputation(); 609 656 } 610 657 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r1977 r1982 172 172 const VssRay &oldRay) const; 173 173 174 bool NextViewCell(); 175 176 void GlobalComputation(); 177 178 void PerViewCellComputation(); 179 180 void VisualizeViewCells(); 181 182 174 183 ////////////////////// 175 184 … … 203 212 204 213 ViewCell *mCurrentViewCell; 214 215 int mNumViewCells; 205 216 }; 206 217 -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r1980 r1982 194 194 OptimizeForWindowsApplication="TRUE" 195 195 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" 196 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT ;TRY_GLOBAL_LINES"196 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT" 197 197 RuntimeLibrary="2" 198 198 RuntimeTypeInfo="TRUE" -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1981 r1982 2282 2282 2283 2283 2284 int ViewCellsManager::GetNumViewCells() const 2285 { 2286 return (int)mViewCells.size(); 2287 } 2288 2289 2284 2290 float ViewCellsManager::ComputeSampleContribution(VssRay &ray, 2285 2291 const bool addRays, -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1981 r1982 171 171 const VssRayContainer &sampleRays) = 0; 172 172 173 /** collect objects intersecting a given spatial box */ 174 virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 173 /** collect objects intersecting a given spatial box. 174 */ 175 virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 175 176 176 177 /** type of the view cell container. … … 185 186 @param filename file to load 186 187 @return true on success 187 188 188 */ 189 virtual bool LoadViewCellsGeometry(const string filename, const bool extrudeBaseTriangle); 189 190 190 191 /** Merges two view cells. … … 210 211 ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height) const; 211 212 212 213 virtual Intersectable * 214 GetIntersectable(const VssRay &ray, const bool isTermination) const; 213 virtual Intersectable *GetIntersectable(const VssRay &ray, const bool isTermination) const; 215 214 216 215 /** Sets maximal number of samples used for the … … 272 271 virtual ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const = 0; 273 272 273 ViewCell *GetViewCell(const int idx) const {return mViewCells[idx];} 274 274 275 virtual void PrintPvsStatistics(ostream &s); 275 276 … … 324 325 virtual bool GetViewPoint(Vector3 &viewPoint) const; 325 326 326 327 virtual bool GetViewPoint(Vector3 &viewPoint, const Vector3 ¶ms) const; 327 328 328 329 /** Returns true if this view point is in the valid view space. … … 489 490 490 491 virtual void CompressViewCells(); 492 493 int GetNumViewCells() const; 491 494 492 495 /////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.