Changeset 693 for GTP/trunk/Lib/Vis
- Timestamp:
- 03/13/06 16:29:28 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r492 r693 78 78 void AddRectangle(const Rectangle3 &triangle); 79 79 80 81 bool 82 80 void Cleanup(); 81 82 bool ValidateFace(const int face); 83 83 84 84 void AddFace(Face *face) -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r675 r693 1280 1280 const float vol = box.GetVolume(); 1281 1281 1282 Debug << "vsb volume: " << vol << endl; 1283 Debug << "root volume: " << mRoot->GetVolume() << endl; 1284 Debug << "root pvs: " << mRoot->GetPvs().GetSize() << endl; 1285 1282 1286 int totalPvs; 1283 1287 float totalRenderCost, avgRenderCost, expectedCost; … … 1394 1398 mRoot = root; 1395 1399 } 1396 1397 1400 1398 1401 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r685 r693 136 136 137 137 138 void ViewCellsManager::CollectEmptyViewCells() 139 { 140 mEmptyViewCells.clear(); 141 ViewCellContainer leaves; 142 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 143 144 ViewCellContainer::const_iterator it, it_end = leaves.end(); 145 146 cout << "collecting empty view cells" << endl; 147 int i = 0; 148 for (it = leaves.begin(); it != it_end; ++ it) 149 { 150 if ((*it)->GetPvs().Empty()) 151 { 152 ++ i; 153 mEmptyViewCells.push_back(*it); 154 } 155 } 156 cout << "view cells found: " << i << endl; 157 } 158 159 160 void ViewCellsManager::TestEmptyViewCells() 161 { 162 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), mEmptyViewCells); 163 164 ViewCellContainer::const_iterator it, it_end = mEmptyViewCells.end(); 165 166 char buf[50]; 167 int i = 0; 168 for (it = mEmptyViewCells.begin(); it != it_end; ++ it) 169 { 170 if (!(*it)->GetPvs().Empty()) 171 { 172 sprintf(buf, "empty-viewcells-%09d.x3d", (*it)->GetId()); 173 Exporter *exporter = Exporter::GetExporter(buf); 174 175 if (exporter && i < 20) 176 { 177 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << endl; 178 ExportViewCellGeometry(exporter, *it); 179 } 180 181 ++ i; 182 } 183 } 184 Debug << "\nfound " << i << " new view cells (" << " of " << mEmptyViewCells.size() << ")" << endl << endl; 185 } 186 187 138 188 int ViewCellsManager::CastPassSamples(const int samplesPerPass, 139 189 const int sampleType, … … 235 285 } 236 286 237 238 287 //-- guided rays are used for further sampling 239 288 const int n = mConstructionSamples; //+initialSamples; … … 308 357 // merge the view cells 309 358 PostProcess(preprocessor->mObjects, postProcessSamples); 359 360 // only for testing 361 CollectEmptyViewCells(); 310 362 311 363 … … 441 493 disposeRays(evaluationSamples, NULL); 442 494 } 495 496 // find empty view cells bug 497 TestEmptyViewCells(); 443 498 } 444 499 … … 728 783 { 729 784 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 785 786 // volume and area of the view cells are recomputed and a view cell mesh is created 730 787 for (it = mViewCells.begin(); it != it_end; ++ it) 731 788 { … … 1146 1203 } 1147 1204 } 1148 1149 1205 } 1150 1206 … … 1418 1474 cout << "finished" << endl; 1419 1475 } 1476 1477 1478 // only for testing 1479 TestSubdivision(); 1420 1480 1421 1481 mColorCode = savedColorCode; … … 1692 1752 1693 1753 1754 void BspViewCellsManager::TestSubdivision() 1755 { 1756 ViewCellContainer leaves; 1757 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 1758 1759 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1760 1761 const float vol = mViewSpaceBox.GetVolume(); 1762 float subdivVol = 0; 1763 float newVol = 0; 1764 1765 for (it = leaves.begin(); it != it_end; ++ it) 1766 { 1767 BspNodeGeometry geom; 1768 BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf; 1769 mBspTree->ConstructGeometry(leaf, geom); 1770 1771 const float lVol = geom.GetVolume(); 1772 1773 newVol += lVol; 1774 subdivVol += (*it)->GetVolume(); 1775 } 1776 1777 Debug << "exact volume: " << vol << endl; 1778 Debug << "subdivision volume: " << subdivVol << endl; 1779 Debug << "new volume: " << newVol << endl; 1780 } 1781 1782 1694 1783 void BspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 1695 1784 ViewCell *vc, … … 1762 1851 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1763 1852 1764 1853 for (it = leaves.begin(); it != it_end; ++ it) 1765 1854 { 1766 1855 BspNodeGeometry geom; … … 1768 1857 mBspTree->ConstructGeometry(leaf, geom); 1769 1858 1770 area += geom.GetArea(); 1771 volume += geom.GetVolume(); 1772 CreateMesh(*it); 1859 float lVol = geom.GetVolume(); 1860 float lArea = geom.GetArea(); 1861 1862 //(*it)->SetVolume(vol); 1863 //(*it)->SetArea(area); 1864 1865 area += lArea; 1866 volume += lVol; 1867 1868 CreateMesh(*it); 1773 1869 } 1774 1870 … … 2937 3033 2938 3034 3035 Debug << "here4" << endl; 3036 // only for testing 3037 TestSubdivision(); 3038 2939 3039 //-- refines the merged view cells 2940 3040 if (0) … … 2953 3053 cout << ss << endl; 2954 3054 Debug << ss << endl; 2955 2956 3055 2957 3056 … … 3619 3718 CreateUniqueViewCellIds(); 3620 3719 3621 3622 3720 stream.open(filename.c_str()); 3623 3721 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; … … 3678 3776 ViewCellContainer::const_iterator it, it_end = leaves.end(); 3679 3777 3680 3778 for (it = leaves.begin(); it != it_end; ++ it) 3681 3779 { 3682 3780 BspNodeGeometry geom; … … 3684 3782 mVspBspTree->ConstructGeometry(leaf, geom); 3685 3783 3686 area += geom.GetArea(); 3687 volume += geom.GetVolume(); 3688 CreateMesh(*it); 3784 float lVol = geom.GetVolume(); 3785 float lArea = geom.GetArea(); 3786 3787 //(*it)->SetVolume(vol); 3788 //(*it)->SetArea(area); 3789 3790 area += lArea; 3791 volume += lVol; 3792 3793 CreateMesh(*it); 3689 3794 } 3690 3795 … … 3694 3799 3695 3800 3801 void VspBspViewCellsManager::TestSubdivision() 3802 { 3803 ViewCellContainer leaves; 3804 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 3805 3806 ViewCellContainer::const_iterator it, it_end = leaves.end(); 3807 3808 const float vol = mViewSpaceBox.GetVolume(); 3809 float subdivVol = 0; 3810 float newVol = 0; 3811 3812 for (it = leaves.begin(); it != it_end; ++ it) 3813 { 3814 BspNodeGeometry geom; 3815 BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf; 3816 mVspBspTree->ConstructGeometry(leaf, geom); 3817 3818 const float lVol = geom.GetVolume(); 3819 3820 newVol += lVol; 3821 subdivVol += (*it)->GetVolume(); 3822 } 3823 3824 Debug << "exact volume: " << vol << endl; 3825 Debug << "subdivision volume: " << subdivVol << endl; 3826 Debug << "new volume: " << newVol << endl; 3827 } 3828 3829 3696 3830 void VspBspViewCellsManager::PrepareLoadedViewCells() 3697 3831 { 3698 3832 // TODO: do I still need this here? 3699 3833 if (0) 3700 mVspBspTree->RepairViewCellsLeafLists();3834 mVspBspTree->RepairViewCellsLeafLists(); 3701 3835 } 3702 3836 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r677 r693 500 500 bool mEvaluateViewCells; 501 501 502 bool mShowVisualization; 502 bool mShowVisualization; 503 504 // HACK in order to detect empty view cells 505 void CollectEmptyViewCells(); 506 void TestEmptyViewCells(); 507 508 ViewCellContainer mEmptyViewCells; 503 509 }; 504 510 … … 590 596 void ExportBspPvs(const ObjectContainer &objects); 591 597 598 void TestSubdivision(); 592 599 }; 593 600 … … 827 834 const VssRayContainer &rays); 828 835 836 void TestSubdivision(); 829 837 }; 830 838 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r685 r693 158 158 // cast again to ensure that there is no objectA 159 159 SetupRay(ray, pointB, direction); 160 ray.mFlags |= Ray::CULL_BACKFACES w;160 ray.mFlags |= Ray::CULL_BACKFACES; 161 161 162 162 if (mKdTree->CastRay(ray)) -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r660 r693 87 87 } 88 88 89 // HACK 90 void RotateMesh(Mesh *mesh) 91 { 92 VertexContainer::const_iterator it, it_end = mesh->mVertices.end(); 93 94 const float angle = 30.0f * PI / 180.0f; 95 const Matrix4x4 rot = RotationYMatrix(30); 96 97 for (it = mesh->mVertices.begin(); it != it_end; ++ it) 98 { 99 const Vector3 pt = rot * (*it); 100 } 101 } 102 103 89 104 void 90 105 X3dParseHandlers::EndShape() … … 109 124 110 125 mesh->mFaces.push_back(new Face(vc)); 126 if (0) 127 RotateMesh(mesh); 111 128 mesh->Preprocess(); 112 129 // make an instance of this mesh … … 121 138 } 122 139 else 123 { 124 140 { 125 141 if (mCurrentMesh->mFaces.size()) 126 142 { 143 // HACK 144 if (0) 145 RotateMesh(mCurrentMesh); 127 146 mCurrentMesh->Preprocess(); 128 147 // make an instance of this mesh -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r574 r693 42 42 environment->Parse(argc, argv, USE_EXE_PATH); 43 43 MeshKdTree::ParseEnvironment(); 44 44 45 45 char buff[128]; 46 46 environment->GetStringValue("Preprocessor.type", buff); … … 65 65 exit(1); 66 66 } 67 67 68 68 69 QApplication *app = NULL;
Note: See TracChangeset
for help on using the changeset viewer.