Changeset 1415 for GTP/trunk/Lib
- Timestamp:
- 09/18/06 18:57:34 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
r1047 r1415 2129 2129 AxisAlignedBox3 &back) const 2130 2130 { 2131 if ( (value >= mMin[axis]) && (value <= mMax[axis]))2131 if ((value >= mMin[axis]) && (value <= mMax[axis])) 2132 2132 { 2133 2133 front.mMin = mMin; front.mMax = mMax; … … 2139 2139 } 2140 2140 2141 2142 } 2141 2142 void AxisAlignedBox3::Scale(const float scale) 2143 { 2144 Vector3 newSize = Size()*(scale*0.5f); 2145 Vector3 center = Center(); 2146 mMin = center - newSize; 2147 mMax = center + newSize; 2148 } 2149 2150 2151 void AxisAlignedBox3::Scale(const Vector3 &scale) 2152 { 2153 Vector3 newSize = Size()*(scale*0.5f); 2154 Vector3 center = Center(); 2155 mMin = center - newSize; 2156 mMax = center + newSize; 2157 } 2158 2159 2160 void AxisAlignedBox3::Translate(const Vector3 &shift) 2161 { 2162 mMin += shift; 2163 mMax += shift; 2164 } 2165 2166 2167 } -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r1414 r1415 72 72 mMin -= v; 73 73 } 74 75 74 76 75 void SetMin(const Vector3 &v) { … … 167 166 /** Scales the box with the factor. 168 167 */ 169 void Scale(const float scale) { 170 Vector3 newSize = Size()*(scale*0.5f); 171 Vector3 center = Center(); 172 mMin = center - newSize; 173 mMax = center + newSize; 174 } 175 176 void Scale(const Vector3 &scale) { 177 Vector3 newSize = Size()*(scale*0.5f); 178 Vector3 center = Center(); 179 mMin = center - newSize; 180 mMax = center + newSize; 181 } 182 168 void Scale(const float scale); 169 170 void Scale(const Vector3 &scale); 171 183 172 /** Translates the box with the factor. 184 173 */ 185 void Translate(const Vector3 &shift) { 186 mMin += shift; 187 mMax += shift; 188 } 174 void Translate(const Vector3 &shift); 189 175 190 176 /** Returns the square of the minimal and maximal distance to -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1414 r1415 608 608 } 609 609 610 #if 0 610 611 cout << "depth: " << data.mDepth << " objects: " << (int)leaf->mObjects.size() 611 612 << " rays: " << data.mNumRays << " rays / objects " 612 613 << (float)data.mNumRays / (float)leaf->mObjects.size() << endl; 614 #endif 613 615 } 614 616 … … 1423 1425 ViewCellContainer viewCells; 1424 1426 CollectViewCells(node->mObjects, viewCells); 1427 if (0) cout << "collected " << (int)viewCells.size() << " dirty candidates" << endl; 1425 1428 1426 1429 // split candidates handling 1427 1430 // these view cells are thrown into dirty list 1428 1431 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1429 1430 Debug << "collecting " << (int)viewCells.size() << " dirty candidates" << endl;1431 1432 1432 1433 for (vit = viewCells.begin(); vit != vit_end; ++ vit) -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1414 r1415 1748 1748 "false"); 1749 1749 1750 1751 1752 /************************************************************************************/ 1753 /* VSS Preprocessor cells related options */ 1754 /************************************************************************************/ 1750 RegisterOption("Preprocessor.kdTreeFilename", 1751 optString, 1752 "preprocessor_kd_tree_filename=", 1753 "vienna_kdtree.bin.gz"); 1754 1755 1756 /*************************************************************************/ 1757 /* VSS Preprocessor cells related options */ 1758 /*************************************************************************/ 1755 1759 1756 1760 RegisterOption("VssTree.maxDepth", optInt, "kd_depth=", "12"); -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r1405 r1415 33 33 34 34 35 bool Exporter::ExportOspTree(const OspTree &ospTree, const int maxPvs) 35 bool Exporter::ExportOspTree(const OspTree &ospTree, 36 const int maxPvs 37 ) 36 38 { 37 39 vector<KdLeaf *> leaves; 38 40 ospTree.CollectLeaves(leaves); 39 40 41 mUseForcedMaterial = true; 41 42 … … 69 70 SetForcedMaterial(RandomMaterial()); 70 71 } 71 72 72 if (0) ExportGeometry(leaf->mObjects); 73 73 } … … 80 80 { 81 81 KdNode *node = kdObj.GetItem(); 82 83 82 Intersectable::NewMail(); 84 83 … … 106 105 107 106 bool Exporter::ExportBvHierarchy(const BvHierarchy &bvHierarchy, 108 const int maxPvs) 107 const int maxPvs, 108 AxisAlignedBox3 *box) 109 109 { 110 110 vector<BvhLeaf *> leaves; … … 112 112 113 113 mUseForcedMaterial = true; 114 115 114 vector<BvhLeaf *>::const_iterator it, it_end = leaves.end(); 116 115 … … 126 125 continue; 127 126 127 if (box && !Overlap(*box, leaf->GetBoundingBox())) 128 continue; 129 128 130 SetWireframe(); 129 131 SetForcedMaterial(white); … … 223 225 224 226 void Exporter::ExportGeometry(const ObjectContainer &objects, 225 const bool exportSingleMesh) 227 const bool exportSingleMesh, 228 AxisAlignedBox3 *bbox) 226 229 { 227 230 ObjectContainer::const_iterator oit, oit_end = objects.end(); … … 231 234 for (oit = objects.begin(); oit != oit_end; ++ oit) 232 235 { 233 if (0) SetForcedMaterial(RandomMaterial()); 234 ExportIntersectable(*oit); 236 if (bbox && Overlap(*bbox, (*oit)->GetBox())) 237 { 238 if (0) SetForcedMaterial(RandomMaterial()); 239 ExportIntersectable(*oit); 240 } 235 241 } 236 242 … … 238 244 } 239 245 246 247 /////////////////////////////////////////// 240 248 //-- all objects exported as one mesh 241 249 //-- hack: currently works only for triangles 250 242 251 PolygonContainer polys; 243 252 … … 245 254 { 246 255 Intersectable *obj = *oit; 256 257 if (bbox && !Overlap(*bbox, (*oit)->GetBox())) 258 continue; 259 247 260 switch (obj->Type()) 248 261 { -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h
r1404 r1415 73 73 74 74 virtual bool 75 ExportOspTree(const OspTree &tree, const int maxPvs);// = 0; 76 77 // virtual bool 78 // ExportRays(const vector<Ray> &rays, 79 // const float length=1000, 80 // const RgbColor &color = RgbColor(1,1,1) 81 // ) = 0; 75 ExportOspTree(const OspTree &tree, const int maxPvs); 82 76 83 77 virtual bool … … 123 117 124 118 virtual void 125 ExportGeometry(const ObjectContainer &objects, const bool exportSingleMesh = false );119 ExportGeometry(const ObjectContainer &objects, const bool exportSingleMesh = false, AxisAlignedBox3 *bbox = NULL); 126 120 127 121 virtual void … … 153 147 154 148 void ExportKdIntersectable(const KdIntersectable &kdObj); 155 bool ExportBvHierarchy(const BvHierarchy &bvHierarchy, const int maxPvs );149 bool ExportBvHierarchy(const BvHierarchy &bvHierarchy, const int maxPvs, AxisAlignedBox3 *box = NULL); 156 150 157 151 virtual void ExportMeshInstance(MeshInstance *mi); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1379 r1415 309 309 { 310 310 cout << "starting bv hierarchy construction ... " << endl; 311 312 311 mBvHierarchy->CreateRoot(objects); 313 312 … … 317 316 318 317 mTotalCost = mBvHierarchy->mTotalCost; 319 Debug << " reseting cost, new total cost: " << mTotalCost << endl;318 Debug << "\nreseting cost, new total cost: " << mTotalCost << endl; 320 319 321 320 mTQueue.Push(sc); … … 373 372 } 374 373 } 374 375 375 return true;//!globalTerminationCriteriaMet; 376 376 } … … 458 458 } 459 459 460 /////////////////// ////////460 /////////////////// 461 461 //-- subdivide leaf node 462 462 463 if (ApplySubdivisionCandidate(mCurrentCandidate)) 463 464 { 464 cout << "subdividing candidate " << ++ i << " of type " << mCurrentCandidate->Type() << endl; 465 cout << mCurrentCandidate->Type() << " "; 466 if (0) cout << "subdividing candidate " << ++ i << " of type " << mCurrentCandidate->Type() << endl; 465 467 mHierarchyStats.nodes += 2; 466 468 … … 474 476 475 477 // we use objects for evaluating vsp tree construction until 476 // a certain depth once a certain depth existiert ... .478 // a certain depth once a certain depth existiert ... 477 479 if (StartObjectSpaceSubdivision()) 478 480 { 479 481 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 480 482 481 cout << " starting object space subdivision at depth "483 cout << "\nstarting object space subdivision at depth " 482 484 << mVspTree->mVspStats.maxDepth << " (" 483 485 << mMinDepthForObjectSpaceSubdivion << ") " << endl; … … 494 496 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 495 497 496 cout << " starting view space subdivision at depth "498 cout << "\nstarting view space subdivision at depth " 497 499 << GetObjectSpaceSubdivisionDepth() << " (" 498 500 << mMinDepthForViewSpaceSubdivion << ") " << endl; … … 608 610 vector<SubdivisionCandidate *> dirtyList; 609 611 CollectDirtyCandidates(dirtyList); 610 cout << "repairing " << (int)dirtyList.size() << " candidates ... "; 611 612 if (0) cout << "repairing " << (int)dirtyList.size() << " candidates ... "; 613 614 ///////////////////////////////// 612 615 //-- reevaluate the dirty list 616 613 617 SubdivisionCandidateContainer::const_iterator sit, sit_end = dirtyList.end(); 614 618 … … 638 642 mHierarchyStats.repairTime += timeDiff; 639 643 640 cout << "finished in " << timeDiff * 1e-3f << " secs" << endl;644 if (0) cout << "finished in " << timeDiff * 1e-3f << " secs" << endl; 641 645 } 642 646 … … 753 757 case BV_BASED_OBJ_SUBDIV: 754 758 { 755 ExportBvHierarchy(exporter, objects); 759 AxisAlignedBox3 bbox = mBvHierarchy->GetBoundingBox(); 760 bbox.Scale(Vector3(0.5, 1, 0.5)); 761 762 ExportBvHierarchy(exporter, objects, &bbox); 756 763 break; 757 764 } … … 763 770 764 771 void HierarchyManager::ExportBvHierarchy(Exporter *exporter, 765 const ObjectContainer &objects) const 772 const ObjectContainer &objects, 773 AxisAlignedBox3 *bbox) const 766 774 { 767 775 exporter->SetWireframe(); 768 exporter->ExportBvHierarchy(*mBvHierarchy, 0 );776 exporter->ExportBvHierarchy(*mBvHierarchy, 0, bbox); 769 777 } 770 778 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1379 r1415 251 251 252 252 void ExportOspTree(Exporter *exporter, const ObjectContainer &objects) const; 253 void ExportBvHierarchy(Exporter *exporter, const ObjectContainer &objects) const; 253 254 void ExportBvHierarchy( 255 Exporter *exporter, 256 const ObjectContainer &objects, 257 AxisAlignedBox3 *box) const; 254 258 255 259 void PrepareBvHierarchy( -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1414 r1415 1380 1380 { 1381 1381 EvaluateLeafStats(tData); 1382 cout << "l"; 1383 } 1384 } 1382 //cout << "l"; 1383 } 1384 } 1385 1385 1386 Debug << mStat << endl; 1386 1387 -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r1315 r1415 155 155 } 156 156 157 // if not using kd tree root, delete tree (otherwise mKdTree has to do the job) 157 // delete hierarchy only if not using the hierarchy from 158 // some other kd tree (otherwise the other kd tree has to do the job) 158 159 if (!mCopyFromKdTree) 159 160 DEL_PTR(mRoot); -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1414 r1415 154 154 char buffer[256]; 155 155 Environment::GetSingleton()->GetStringValue("Preprocessor.visibilityFile", buffer); 156 156 157 mVisibilityFileName = buffer; 157 158 Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilityFilter", mApplyVisibilityFilter ); … … 372 373 mSceneGraph->CollectObjects(&root->mObjects); 373 374 374 long startTime = GetTime();375 const long startTime = GetTime(); 375 376 cout << "building kd tree ... " << endl; 376 377 377 378 mKdTree->Construct(); 378 379 379 cout << "construction finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs " << endl; 380 cout << "finished kd tree construction in " << TimeDiff(startTime, GetTime()) * 1e-3 381 << " secs " << endl; 380 382 381 383 return true; 382 384 } 385 383 386 384 387 void … … 787 790 bool Preprocessor::InitRayCast(const string externKdTree) 788 791 { 792 bool loadKdTree, exportKdTree; 793 794 Environment::GetSingleton()->GetBoolValue("Preprocessor.loadKdTree", loadKdTree); 795 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportKdTree", exportKdTree); 796 797 char kdtreename[100]; 798 Environment::GetSingleton()->GetStringValue("Preprocessor.kdTreeFilename", kdtreename); 799 800 801 if (!loadKdTree) 802 { 803 ///////////////// 804 //-- build new kd tree from scene geometry 805 806 BuildKdTree(); 807 KdTreeStatistics(cout); 808 } 809 else 810 { 811 const long startTime = GetTime(); 812 cout << "loading kd tree file " << kdtreename << " ... "; 813 814 if (!LoadKdTree(kdtreename)) 815 { 816 cout << "error loading kd tree with filename " << kdtreename << endl; 817 return false; 818 } 819 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 820 821 if (0) 822 { 823 Exporter *exporter = Exporter::GetExporter("dummykd.x3d"); 824 825 if (exporter) 826 { 827 exporter->ExportKdTree(*mKdTree, true); 828 delete exporter; 829 } 830 } 831 } 832 833 if (exportKdTree) 834 { 835 const long startTime = GetTime(); 836 cout << "exporting kd tree ... "; 837 if (!ExportKdTree(kdtreename)) 838 { 839 cout << " error exporting kd tree with filename " << kdtreename << endl; 840 } 841 else 842 { 843 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 844 } 845 } 846 789 847 switch (mRayCastMethod) // use intel ray tracing 790 848 { -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1414 r1415 280 280 ///////////////////////// 281 281 282 282 int mRayCastMethod; 283 283 /// samples used for construction of the BSP view cells tree. 284 284 int mBspConstructionSamples; -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1328 r1415 88 88 89 89 90 #if 0 //matt: this moved up to preprocessor90 #if 0 //matt: this moved up into preprocessor 91 91 int 92 92 RssPreprocessor::CastRay( -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1414 r1415 1946 1946 } 1947 1947 1948 1948 // matt: todo 1949 1949 void ViewCellsManager::ExportViewCellsForViz(Exporter *exporter) const 1950 1950 { … … 2640 2640 mViewCellsTree->SetRoot(root); 2641 2641 2642 // compute pvs2642 // recompute pvs in the whole hierarchy 2643 2643 ObjectPvs pvs; 2644 2644 UpdatePvsForEvaluation(root, pvs); 2645 2645 } 2646 2647 cout << "finished" << endl; 2648 cout << "merged view cells in " 2649 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 2650 2651 Debug << "Postprocessing: Merged view cells in " 2652 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl << endl; 2653 2654 2655 ///////////////////////////////////////// 2656 //-- visualization and statistics 2646 2657 2647 2658 // export statistics after merge … … 2653 2664 } 2654 2665 2655 //-- stats and visualizations 2656 cout << "finished" << endl; 2657 cout << "merged view cells in " 2658 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 2659 2660 Debug << "Postprocessing: Merged view cells in " 2661 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl << endl; 2662 2663 2664 //-- visualization and statistics 2665 // reset view cells and stats 2666 ResetViewCells(); 2666 ResetViewCells(); // reset view cells 2667 2667 Debug << "\nView cells after merge:\n" << mCurrentViewCellsStats << endl; 2668 2668 … … 2763 2763 { 2764 2764 mColorCode = 1; // hack color code 2765 Exporter *exporter = Exporter::GetExporter("final_view_cells. x3d");2765 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 2766 2766 2767 2767 cout << "exporting view cells after merge (pvs size) ... "; … … 3815 3815 SimulationStatistics ss; 3816 3816 dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 3817 Debug << "render time before refine\n " << ss << endl;3817 Debug << "render time before refine\n\n" << ss << endl; 3818 3818 3819 3819 const long startTime = GetTime(); … … 3898 3898 //-- render simulation after merge + refine 3899 3899 3900 cout << "\nview cells partition render time before compress" ;3900 cout << "\nview cells partition render time before compress" << endl << endl;; 3901 3901 dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 3902 3902 SimulationStatistics ss; … … 4449 4449 // find view cells associated with the samples 4450 4450 // store the sample pvs with the pvs associated with the view cell 4451 // 4451 4452 // for each view cell: 4452 4453 // compute difference point sampled pvs - view cell pvs … … 4490 4491 m.mDiffuseColor.b = 1.0f; 4491 4492 //exporter->SetForcedMaterial(m); 4492 4493 // ExportViewCellGeometry(exporter, vc, mClipPlane); 4494 4495 /* // counting the pvss 4496 for (rit = samples.begin(); rit != rit_end; ++ rit) 4497 { 4498 RenderCostSample sample = *rit; 4499 4500 ViewCell *vc = GetViewCell(sample.mPosition); 4501 4502 AxisAlignedBox3 box(sample.mPosition - Vector3(1, 1, 1), sample.mPosition + Vector3(1, 1, 1)); 4503 Mesh *hMesh = CreateMeshFromBox(box); 4504 4505 DEL_PTR(hMesh); 4506 4507 */ 4493 //ExportViewCellGeometry(exporter, vc, mClipPlane); 4494 4495 /* // counting the pvss 4496 for (rit = samples.begin(); rit != rit_end; ++ rit) 4497 { 4498 RenderCostSample sample = *rit; 4499 ViewCell *vc = GetViewCell(sample.mPosition); 4500 4501 AxisAlignedBox3 box(sample.mPosition - Vector3(1, 1, 1), sample.mPosition + Vector3(1, 1, 1)); 4502 Mesh *hMesh = CreateMeshFromBox(box); 4503 4504 DEL_PTR(hMesh); 4505 } 4506 */ 4508 4507 } 4509 4508 } … … 4801 4800 4802 4801 // print subdivision statistics 4802 Debug << endl << endl; 4803 4803 mHierarchyManager->PrintHierarchyStatistics(Debug); 4804 4804 … … 4815 4815 4816 4816 const long startTime = GetTime(); 4817 4818 4817 cout << "Computing remaining ray contributions ... "; 4819 4818 … … 4822 4821 ComputeSampleContributions(savedRays, true, false); 4823 4822 4824 cout << "finished" << endl; 4825 4826 Debug << "Computed remaining ray contribution in " << TimeDiff(startTime, GetTime()) * 1e-3 4823 Debug << "finished computing remaining ray contribution in " << TimeDiff(startTime, GetTime()) * 1e-3 4827 4824 << " secs" << endl; 4828 4825 4829 cout << "construction finished" << endl;4830 4831 // real meshes are contructed at this stage4832 4826 if (0) 4833 4827 { 4828 // real meshes are constructed at this stage 4834 4829 cout << "finalizing view cells ... "; 4835 4830 FinalizeViewCells(true); … … 4908 4903 //-- render simulation after merge + refine 4909 4904 4910 cout << "\nview cells partition render time before compress" ;4905 cout << "\nview cells partition render time before compress" << endl << endl; 4911 4906 dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 4912 4907 SimulationStatistics ss; … … 5028 5023 5029 5024 if (clipPlane) 5025 { 5030 5026 plane = clipPlane->GetPlane(); 5027 } 5028 5029 AxisAlignedBox3 bbox = GetViewSpaceBox(); 5030 bbox.Scale(Vector3(0.5, 1, 0.5)); 5031 5031 5032 5032 for (it = leaves.begin(); it != it_end; ++ it) … … 5037 5037 const AxisAlignedBox3 box = mHierarchyManager->GetVspTree()->GetBoundingBox(vspVc->mLeaf); 5038 5038 5039 if (!Overlap(box, bbox)) 5040 continue; 5041 5039 5042 if (clipPlane) 5040 5043 { … … 5081 5084 if (1) 5082 5085 { 5086 ///////////////////////////// 5083 5087 //-- export final view cells 5084 5088 5085 // hack pvs5089 // hack color code (show pvs size) 5086 5090 const int savedColorCode = mColorCode; 5087 5091 mColorCode = 0; … … 5091 5095 if (exporter) 5092 5096 { 5093 cout << "exporting view cells after post process ... "; 5097 const long starttime = GetTime(); 5098 cout << "exporting final view cells (after initial construction + post process) ... "; 5094 5099 5095 5100 if (mExportGeometry) … … 5113 5118 delete exporter; 5114 5119 5115 cout << "finished " << endl;5120 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 5116 5121 } 5117 5122 … … 5126 5131 if (exporter) 5127 5132 { 5133 const long starttime = GetTime(); 5134 5128 5135 cout << "exporting object space hierarchy ... "; 5129 5136 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects); 5130 5137 5131 5138 delete exporter; 5132 cout << "finished " << endl;5139 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 5133 5140 } 5134 5141 } … … 5153 5160 const bool sortViewCells = true; 5154 5161 5155 // sort view cells to visualize the largest view cells5156 5162 if (sortViewCells) 5157 5163 { 5158 5164 //stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 5165 // sort view cells to visualize the view cells with highest render cost 5159 5166 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 5160 5167 } 5161 5168 5162 5169 int limit = min(leafOut, (int)mViewCells.size()); 5163 5164 5170 int raysOut = 0; 5165 5171 5166 5172 /////////////////////////// 5167 5173 //-- some rays for output 5168 5174 … … 5249 5255 } 5250 5256 5251 // --export rays piercing this view cell5257 // export rays piercing this view cell 5252 5258 exporter->ExportRays(vcRays, RgbColor(1, 1, 0)); 5253 5259 } 5254 5260 } 5255 5261 5262 5263 ///////////////// 5256 5264 //-- export view cell geometry 5257 5265 … … 5267 5275 5268 5276 #if 0 5277 ////////// 5269 5278 //-- export pvs 5270 5279 … … 5336 5345 return false; 5337 5346 5347 const long starttime = GetTime(); 5338 5348 cout << "exporting view cells to xml ... "; 5339 5349 … … 5349 5359 ////////////////////////////////////////////////////////////// 5350 5360 //-- export bounding boxes 5361 //-- The bounding boxes are used to identify 5362 //-- the objects in the rendering engine 5351 5363 5352 5364 stream << "<BoundingBoxes>" << endl; … … 5356 5368 { 5357 5369 const AxisAlignedBox3 box = (*oit)->GetBox(); 5358 5359 //-- the bounding boxes5360 5370 stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 5361 5371 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 5362 5372 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 5363 5373 } 5364 5365 5374 stream << "</BoundingBoxes>" << endl; 5366 5375 5367 //////////////////////////////////////////////////////////////// 5376 5377 ////////////////////////// 5368 5378 //-- export the view cells and the pvs 5369 5379 … … 5374 5384 stream << "</ViewCells>" << endl; 5375 5385 5376 5386 ////////////////////// 5377 5387 //-- export the view space hierarchy 5378 5388 … … 5384 5394 stream << "</ViewSpaceHierarchy>" << endl; 5385 5395 5386 5396 ////////////////////// 5387 5397 //-- export the object space partition 5388 5398 … … 5392 5402 stream.close(); 5393 5403 5394 cout << "finished" << endl; 5395 5404 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3 << " secs" << endl; 5396 5405 return true; 5397 5406 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1379 r1415 94 94 app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; 95 95 96 app << "#AXIS_ALIGNED_SPLITS (number of axis aligned splits)\n" << splits[0] + splits[1] + splits[2] << endl;97 98 96 app << "#N_SPLITS ( Number of splits in axes x y z)\n"; 99 97 100 98 for (int i = 0; i < 3; ++ i) 101 99 app << splits[i] << " "; 100 102 101 app << endl; 103 102 … … 529 528 || (data.mPvs <= mTermMinPvs) 530 529 || (data.mProbability <= mTermMinProbability) 531 || (data.GetAvgRayContribution() > mTermMaxRayContribution)530 //|| (data.GetAvgRayContribution() > mTermMaxRayContribution) 532 531 || (data.mDepth >= mTermMaxDepth) 533 532 ); 534 533 535 if ( 1&& localTerminationCriteriaMet)536 { 537 Debug << " ********local termination *********" << endl;534 if (0 && localTerminationCriteriaMet) 535 { 536 Debug << "local termination criteria met:" << endl; 538 537 Debug << "rays: " << (int)data.mRays->size() << " " << mTermMinRays << endl; 539 538 Debug << "pvs: " << data.mPvs << " " << mTermMinPvs << endl; … … 552 551 // || mOutOfMemory 553 552 || (mVspStats.Leaves() >= mMaxViewCells) 554 //|| (mGlobalCostMisses >= mTermGlobalCostMissTolerance)553 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 555 554 ); 556 555 557 556 if (0 && terminationCriteriaMet) 558 557 { 559 Debug << " ********* terminationCriteriaMet *********" << endl;558 Debug << "globlal termination criteria met:" << endl; 560 559 Debug << "cost misses: " << mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 561 560 Debug << "leaves: " << mVspStats.Leaves() << " " << mMaxViewCells << endl; … … 768 767 VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode); 769 768 770 //////////////////////////////////////////////////////// ///////////771 //-- the front and back traversal data isfilled with the new values769 //////////////////////////////////////////////////////// 770 //-- the front and back traversal data are filled with the new values 772 771 773 772 frontData.mDepth = tData.mDepth + 1; … … 807 806 // two more leaves 808 807 mVspStats.nodes += 2; 809 808 /// and a new split 809 ++ mVspStats.splits[splitPlane.mAxis]; 810 810 811 811 /////////////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1404 r1415 220 220 void X3dParseHandlers::EndShape() 221 221 { 222 //-- if shape is merely a definition => don't create particular mesh instance 223 if (!mCurrentMesh || mIsMeshDefinition) 224 { 225 return; 226 } 227 228 //////////////////////////////////// 229 //-- each triangle is one single mesh 230 231 if (!mLoadMeshes) 232 { 233 cout << "m"; 234 Mesh tempMesh(*mCurrentMesh); 235 ApplyTransformations(mTransformations, &tempMesh); 236 237 FaceContainer::const_iterator fit, fit_end = tempMesh.mFaces.end(); 238 239 for (fit = tempMesh.mFaces.begin(); fit != fit_end; ++ fit) 240 { 241 cout << "f"; 242 // triangulate the faces 243 Face *face = *fit; 244 vector<Triangle3> triangles; 245 Polygon3 poly(face, &tempMesh); 246 poly.Triangulate(triangles); 247 248 vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 249 250 for (tit = triangles.begin(); tit != tit_end; ++ tit) 251 { 252 //cout << "triangle: " << *tit << endl; 253 TriangleIntersectable *ti = new TriangleIntersectable(*tit); 254 mCurrentNode->mGeometry.push_back(ti); 255 } 222 ////////////// 223 //-- shape is only a definition => 224 //-- don't create particular mesh instance 225 226 if (!mCurrentMesh || mIsMeshDefinition) 227 { 228 return; 229 } 230 231 if (!mLoadMeshes) 232 { 233 //////////////////////////////////// 234 //-- load data as single triangles instead of whole meshes 235 236 //cout << "m"; 237 Mesh tempMesh(*mCurrentMesh); 238 ApplyTransformations(mTransformations, &tempMesh); 239 240 FaceContainer::const_iterator fit, fit_end = tempMesh.mFaces.end(); 241 242 for (fit = tempMesh.mFaces.begin(); fit != fit_end; ++ fit) 243 { 244 //cout << "f"; 245 // triangulate the faces 246 Face *face = *fit; 247 vector<Triangle3> triangles; 248 Polygon3 poly(face, &tempMesh); 249 poly.Triangulate(triangles); 250 251 vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 252 253 for (tit = triangles.begin(); tit != tit_end; ++ tit) 254 { 255 //cout << "triangle: " << *tit << endl; 256 TriangleIntersectable *ti = new TriangleIntersectable(*tit); 257 mCurrentNode->mGeometry.push_back(ti); 258 } 256 259 #if 0 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 260 // we create a new mesh for each face from the current mesh 261 Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 262 263 VertexIndexContainer::const_iterator vit, vit_end = face->mVertexIndices.end(); 264 265 int i = 0; 266 // dummy vertex indices container 267 VertexIndexContainer vcIndices; 268 269 for (vit = face->mVertexIndices.begin(); vit != vit_end; ++ vit, ++ i) 270 { 271 cout << "i"; 272 const int index = (*vit); 273 // add vertices 274 mesh->mVertices.push_back(mCurrentMesh->mVertices[index]); 275 // indices don't make much sense if mesh == face, but we need them anyway ... 276 vcIndices.push_back(i); 277 } 278 279 mesh->mFaces.push_back(new Face(vcIndices)); 280 281 // write transformations directly into the mesh 282 // note: could be transformed in parent mesh, save some transformations 283 ApplyTransformations(mTransformations, mesh); 284 285 mesh->Preprocess(); 286 287 if (mesh->mFaces.empty()) 288 { 289 cout << "error: empy mesh" << endl; 290 } 291 else 292 { 293 // make an instance of this mesh 294 MeshInstance *mi = new MeshInstance(mesh); 295 mCurrentNode->mGeometry.push_back(mi); 296 297 if (mCurrentMaterial && !mCurrentMesh->mMaterial) 298 { 299 // HACK: add the material to the mesh directly if no material yet 300 mCurrentMesh->mMaterial = mCurrentMaterial; 301 } 302 } 300 303 #endif 301 302 303 304 305 306 307 304 } 305 306 // this mesh is not needed, unless it is used as a definition 307 if (!mUsingMeshDefinition) 308 { 309 MeshManager::GetSingleton()->DestroyEntry(mCurrentMesh->GetId()); 310 } 308 311 } 309 312 else // default usage: create a mesh instance from the current mesh … … 321 324 else 322 325 { 323 326 // make an instance of this mesh 324 327 TransformedMeshInstance *tmi = new TransformedMeshInstance(mCurrentMesh); 325 328 326 327 328 329 } 330 329 // apply transformation on the instance of the mesh 330 ApplyTransformations(mTransformations, tmi); 331 mi = tmi; 332 } 333 331 334 if (mCurrentMaterial) 332 335 { … … 341 344 } 342 345 } 343 346 344 347 // create local mesh kd tree 345 348 mCurrentMesh->Preprocess(); … … 368 371 369 372 VertexIndexContainer vertices; 370 373 371 374 mIsMeshDefinition = false; 372 375 mUsingMeshDefinition = false; … … 579 582 580 583 if (element == "Shape") { 581 cout << "+";584 //cout << "+"; 582 585 583 586 // reset current shape values -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1414 r1415 149 149 } 150 150 151 //////////////////////////////////////// 151 152 ///////////// 152 153 //-- load scene 153 154 … … 175 176 exit(1); 176 177 } 177 178 bool loadKdTree, exportKdTree;179 180 Environment::GetSingleton()->GetBoolValue("Preprocessor.loadKdTree", loadKdTree);181 182 const string kdtreename("kd.bin.gz");183 184 if (!loadKdTree)185 {186 //-- build new kd tree from scene geometry187 preprocessor->BuildKdTree();188 preprocessor->KdTreeStatistics(cout);189 }190 else191 {192 const long startTime = GetTime();193 cout << "loading kd tree ... ";194 195 if (!preprocessor->LoadKdTree(kdtreename))196 {197 cout << "error loading kd tree with filename " << kdtreename << endl;198 Cleanup();199 exit(1);200 }201 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;202 203 if (0)204 {205 Exporter *exporter = Exporter::GetExporter("dummykd.x3d");206 207 if (exporter)208 {209 exporter->ExportKdTree(*preprocessor->mKdTree, true);210 delete exporter;211 }212 }213 }214 215 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportKdTree", exportKdTree);216 217 if (exportKdTree)218 {219 const long startTime = GetTime();220 cout << "exporting kd tree ... ";221 if (!preprocessor->ExportKdTree(kdtreename))222 {223 cout << " error exporting kd tree with filename " << kdtreename << endl;224 }225 else226 {227 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;228 }229 }230 231 178 232 179 // parse view cells related options … … 301 248 } 302 249 250 // release memory 303 251 Cleanup(); 304 252
Note: See TracChangeset
for help on using the changeset viewer.