Changeset 801 for GTP/trunk/Lib
- Timestamp:
- 04/24/06 08:21:10 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r752 r801 2014 2014 "100000"); 2015 2015 2016 RegisterOption("VspBspTree.Construction.minBand", 2017 optFloat, 2018 "vsp_bsp_construction_min_band=", 2019 "0.4"); 2020 2021 RegisterOption("VspBspTree.Construction.maxBand", 2022 optFloat, 2023 "vsp_bsp_construction_min_band=", 2024 "0.6"); 2025 2016 2026 RegisterOption("VspBspTree.Construction.epsilon", 2017 2027 optFloat, -
GTP/trunk/Lib/Vis/Preprocessing/src/RayInfo.cpp
r694 r801 144 144 145 145 // segment is not intersecting plane: fond out if on front or back side 146 if (t >= GetMaxT() - thresh)146 if (t >= (GetMaxT() - thresh)) 147 147 { 148 148 return splitPlane.Side(ExtrapOrigin()); 149 149 } 150 150 151 if (t <= GetMinT() + thresh)151 if (t <= (GetMinT() + thresh)) 152 152 { 153 153 return splitPlane.Side(ExtrapTermination()); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r752 r801 262 262 float ViewCell::GetRenderCost() const 263 263 { 264 return (float)mPvs.GetSize() * GetVolume(); 264 //return (float)mPvs.GetSize() * GetVolume(); 265 return (float)mPvsSize * GetVolume(); 265 266 } 266 267 … … 575 576 576 577 //const float maxAvgCost = 350; 577 while (!mMergeQueue.empty())// NumActiveViewCells > mMergeMinViewCells))578 while (!mMergeQueue.empty())//nmNumActiveViewCells > mMergeMinViewCells)) 578 579 { 579 580 //-- reset merge queue if the ratio of current expected cost / real expected cost … … 661 662 realAvgRenderCost = (float)totalPvs / (float)realNumActiveViewCells; 662 663 663 // set merge cost to this node 664 mergedVc->SetMergeCost(totalRenderCost); 664 // set merge cost to this node for priority traversal 665 //mergedVc->SetMergeCost(totalRenderCost); 666 // HACK 667 mergedVc->SetMergeCost(1.0f / (float)realNumActiveViewCells); 665 668 666 669 //if (mViewCellsManager->EqualToSpatialNode(mergedVc)) … … 736 739 mMergeQueue.pop(); 737 740 } 738 741 //hack!! 742 //mRoot->GetPvs().Clear(); 739 743 // TODO delete because makes no sense here 740 744 mergeStats.expectedRenderCost = realExpectedCost; … … 1608 1612 void ViewCellsTree::GetPvs(ViewCell *vc, ObjectPvs &pvs) const 1609 1613 { 1614 // pvs is stored in each cell 1615 if (mViewCellsStorage == PVS_IN_INTERIORS) 1616 { 1617 pvs = vc->GetPvs(); 1618 return; 1619 } 1620 1610 1621 Intersectable::NewMail(); 1611 1622 1612 if (mViewCellsStorage == PVS_IN_INTERIORS)1613 pvs = vc->GetPvs();1614 1623 1615 1624 int pvsSize = 0; … … 1631 1640 tstack.pop(); 1632 1641 1642 // add new pvs 1633 1643 pvs.AddPvs(vc->GetPvs()); 1634 1644 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r752 r801 190 190 { 191 191 return a->GetRenderCost() < b->GetRenderCost(); 192 } 193 194 static bool LargerRenderCost(const ViewCell *a, const ViewCell *b) 195 { 196 return a->GetRenderCost() > b->GetRenderCost(); 192 197 } 193 198 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r752 r801 173 173 Debug << "export to file: " << mExportViewCells << endl; 174 174 175 Debug << "active : " << mNumActiveViewCells << endl;175 Debug << "active view cells: " << mNumActiveViewCells << endl; 176 176 Debug << "post process compress: " << mCompressViewCells << endl; 177 177 Debug << "visualization use clipPlane: " << mUseClipPlaneForViz << endl; … … 179 179 Debug << "evaluate view cells: " << mEvaluateViewCells << endl; 180 180 Debug << "sampling type: " << mSamplingType << endl; 181 Debug << "render cost evaluation type " << mRenderCostEvaluationType << endl;181 Debug << "render cost evaluation type: " << mRenderCostEvaluationType << endl; 182 182 Debug << "evaluation sampling type: " << mEvaluationSamplingType << endl; 183 183 Debug << "show visualization: " << mShowVisualization << endl; … … 479 479 if (TEST_EMPTY_VIEW_CELLS) 480 480 CollectEmptyViewCells(); 481 482 481 482 // evaluation of the paritition, i.e., a number of new samples are cast 483 if (mEvaluateViewCells) 484 { 485 EvalViewCellPartition(preprocessor); 486 } 487 483 488 //-- visualization 484 489 if (mShowVisualization) … … 500 505 } 501 506 502 // evaluation of the paritition, i.e., a number of new samples are cast503 if (mEvaluateViewCells)504 {505 EvalViewCellPartition(preprocessor);506 }507 508 507 return numSamples; 509 508 } … … 696 695 bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 697 696 698 cout << "collect leaf view cells and reseting pvs ... "; 699 700 ViewCellContainer leaves; 701 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 702 cout << " ... "; 697 698 /*ViewCellContainer leaves; 699 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 700 */ 701 cout << "reseting pvs ... "; 702 703 703 704 bool startFromZero = true; 704 705 … … 744 745 cout << "compute new statistics ... "; 745 746 746 // propagate pvs or pvs size information 747 /*Debug << "*******+" << endl; 748 float overall = 0; 749 stable_sort(leaves.begin(), leaves.end(), ViewCell::SmallerPvs); 750 for (int i = 0; i < leaves.size(); ++ i) 751 { 752 overall += leaves[i]->GetPvs().GetSize(); 753 Debug << "i " << i << " !size: " << leaves[i]->GetPvs().GetSize() << " vol: " << leaves[i]->GetVolume() << " overall " << overall << endl; 754 755 } 756 */ 757 758 //-- propagate pvs or pvs size information 747 759 ObjectPvs pvs; 748 760 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 749 761 750 762 751 // output stats763 //-- output stats 752 764 sprintf(s, "-%09d-eval.log", castSamples); 753 765 string fileName = string(statsPrefix) + string(s); … … 1793 1805 if (!mOnlyValidViewCells || (*it)->GetValid()) 1794 1806 { 1795 ExportColor(exporter, *it); 1807 ExportColor(exporter, *it); 1808 1796 1809 ExportViewCellGeometry(exporter, *it, 1797 1810 mUseClipPlaneForViz ? &mClipPlane : NULL); … … 2145 2158 2146 2159 //exporter->SetWireframe(); 2147 exporter->SetFilled(); 2160 //exporter->SetFilled(); 2161 bool b = mUseClipPlaneForViz; 2162 mUseClipPlaneForViz = false; 2148 2163 ExportViewCellsForViz(exporter); 2149 2164 mUseClipPlaneForViz = b; 2150 2165 delete exporter; 2151 2166 } … … 2168 2183 // export single view cells 2169 2184 ExportBspPvs(objects); 2170 }2171 2172 2173 inline bool vc_gt(ViewCell *a, ViewCell *b)2174 {2175 return a->GetPvs().GetSize() > b->GetPvs().GetSize();2176 2185 } 2177 2186 … … 2219 2228 // sort view cells to get largest view cells 2220 2229 if (0) 2221 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt);2230 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 2222 2231 2223 2232 int limit = min(leafOut, (int)mViewCells.size()); … … 3329 3338 case 1: // pvs 3330 3339 { 3331 importance = (float) vc->GetPvs().GetSize() /3340 importance = (float)mViewCellsTree->GetPvsSize(vc) / 3332 3341 (float)mCurrentViewCellsStats.maxPvs; 3333 3342 } … … 3541 3550 // compute tree by merging the nodes based on cost heuristics 3542 3551 mViewCellsTree->ConstructMergeTree(rays, objects); 3552 3553 //cout << "here344" << endl; 3554 //ObjectPvs pvs; 3555 //UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 3543 3556 } 3544 3557 else … … 3881 3894 pvs = root->GetPvs(); 3882 3895 3883 root->mPvsSize = pvs.GetSize();3896 root->mPvsSize = root->GetPvs().GetSize(); 3884 3897 root->mPvsSizeValid = true; 3885 3898 … … 3887 3900 } 3888 3901 3902 //-- interior node => propagate pvs up 3889 3903 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 3904 interior->GetPvs().Clear(); 3905 pvs.Clear(); 3906 vector<ObjectPvs> pvsList; 3907 3890 3908 ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 3891 3909 3892 vector<ObjectPvs> pvsList;3893 3894 3895 3910 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit) 3896 3911 { … … 3905 3920 3906 3921 #if 1 3922 3907 3923 Intersectable::NewMail(); 3908 3924 … … 3933 3949 { 3934 3950 interior->mPvs = pvs; 3951 //cout << "here233" << endl; 3935 3952 } 3936 3953 … … 3940 3957 3941 3958 #else 3959 3942 3960 // really merge cells: slow put sumpdf is correct 3943 ViewCellInterior *viewCellInterior = new ViewCellInterior();3944 3945 3961 viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 3946 3962 viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); … … 3995 4011 { // hack pvs 3996 4012 int savedColorCode = mColorCode; 3997 mColorCode = 0; 4013 mColorCode = 1; 4014 3998 4015 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 3999 4016 … … 4020 4037 } 4021 4038 4039 //exporter->SetFilled(); 4040 bool b = mUseClipPlaneForViz; 4041 mUseClipPlaneForViz = false; 4022 4042 ExportViewCellsForViz(exporter); 4043 mUseClipPlaneForViz = b; 4044 4023 4045 delete exporter; 4024 4046 cout << "finished" << endl; … … 4148 4170 4149 4171 const bool sortViewCells = true; 4172 4150 4173 4151 4174 // sort view cells to visualize the largest view cells 4152 4175 if (sortViewCells) 4153 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 4154 4176 { 4177 //stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 4178 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 4179 } 4180 4155 4181 int limit = min(leafOut, (int)mViewCells.size()); 4156 4182 … … 4168 4194 else 4169 4195 vc = mViewCells[(int)RandomValue(0, (float)mViewCells.size() - 1)]; 4196 4197 ObjectPvs pvs; 4198 mViewCellsTree->GetPvs(vc, pvs); 4170 4199 4171 4200 //bspLeaves[j]->Mail(); … … 4175 4204 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 4176 4205 4206 //-- export the sample rays 4177 4207 if (1 || mExportRays) 4178 4208 { … … 4212 4242 vcRays.push_back(*rit); 4213 4243 } 4244 4214 4245 //-- export rays piercing this view cell 4215 4246 exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); … … 4221 4252 VssRayContainer vcRays; 4222 4253 raysOut = min((int)rays.size(), mVisualizationSamples); 4254 4223 4255 // check whether we can add the current ray to the output rays 4224 4256 for (int k = 0; k < raysOut; ++ k) … … 4251 4283 exporter->SetFilled(); 4252 4284 4253 4285 //-- export pvs 4254 4286 if (1) 4255 4287 { 4256 4288 ObjectPvsMap::const_iterator oit, 4257 oit_end = vc->GetPvs().mEntries.end(); 4258 4259 4260 exporter->SetFilled(); 4289 oit_end = pvs.mEntries.end(); 4261 4290 4262 4291 Intersectable::NewMail(); 4263 4292 4264 4293 // output PVS of view cell 4265 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)4294 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 4266 4295 { 4267 4296 Intersectable *intersect = (*oit).first; … … 4277 4306 } 4278 4307 } 4279 else 4280 { 4308 4309 if (0) 4310 { // export scene geometry 4281 4311 m.mDiffuseColor = RgbColor(1, 0, 0); 4282 4312 exporter->SetForcedMaterial(m); … … 4338 4368 case 1: // pvs 4339 4369 { 4340 importance = (float) vc->GetPvs().GetSize() /4370 importance = (float)mViewCellsTree->GetPvsSize(vc) / 4341 4371 #if 1 // hack for result 4342 4372 (float)mCurrentViewCellsStats.maxPvs; … … 4377 4407 const Plane3 *clipPlane) const 4378 4408 { 4379 if (vc->GetMesh())4380 {4381 exporter->ExportMesh(vc->GetMesh());4382 4383 return;4384 }4385 4386 4387 4409 if (clipPlane) 4388 4410 { … … 4418 4440 //Debug << "geo size: " << geom.Size() << endl; 4419 4441 //Debug << "size b: " << back.Size() << " f: " << front.Size() << endl; 4442 4420 4443 if (back.Valid()) 4421 4444 { … … 4427 4450 else 4428 4451 { 4429 BspNodeGeometry geom; 4430 mVspBspTree->ConstructGeometry(vc, geom); 4431 4432 exporter->ExportPolygons(geom.GetPolys()); 4452 // export mesh if available 4453 /* if (vc->GetMesh()) 4454 { 4455 exporter->ExportMesh(vc->GetMesh()); 4456 } 4457 else 4458 {*/ 4459 BspNodeGeometry geom; 4460 mVspBspTree->ConstructGeometry(vc, geom); 4461 exporter->ExportPolygons(geom.GetPolys()); 4462 //} 4433 4463 } 4434 4464 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r752 r801 118 118 environment->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 119 119 environment->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 120 environment->GetBoolValue("VspBspTree.simulateOctree", m SimulateOctree);120 environment->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis); 121 121 environment->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 122 122 environment->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType); … … 127 127 environment->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog); 128 128 mSubdivisionStats.open(subdivisionStatsLog); 129 130 environment->GetFloatValue("VspBspTree.Construction.minBand", mMinBand); 131 environment->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand); 129 132 130 133 //-- debug output … … 156 159 Debug << "priority queue type: " << mNodePriorityQueueType << endl; 157 160 Debug << "empty view cells merge: " << mEmptyViewCellsMergeAllowed << endl; 158 Debug << "octree: " << mSimulateOctree << endl; 161 Debug << "octree: " << mCirculatingAxis << endl; 162 Debug << "minband: " << mMinBand << endl; 163 Debug << "maxband: " << mMaxBand << endl; 164 159 165 160 166 Debug << "Split plane strategy: "; … … 1215 1221 const float sizeBox = maxBox - minBox; 1216 1222 1217 const float minBand = minBox + 0.1f* sizeBox;1218 const float maxBand = minBox + 0.9f* sizeBox;1223 const float minBand = minBox + mMinBand * sizeBox; 1224 const float maxBand = minBox + mMaxBand * sizeBox; 1219 1225 1220 1226 SortSplitCandidates(rays, axis, minBand, maxBand); … … 1407 1413 1408 1414 int sAxis = 0; 1409 1410 bool useSpecialAxis = mOnlyDrivingAxis || mUseRandomAxis || mSimulateOctree; 1415 bool maxDepthForDrivingAxis = 0; 1416 1417 const bool useSpecialAxis = mOnlyDrivingAxis || mUseRandomAxis || 1418 mCirculatingAxis || (tData.mDepth < maxDepthForDrivingAxis); 1419 1411 1420 1412 1421 // use some kind of specialised fixed axis 1413 if (mOnlyDrivingAxis) 1422 if (mUseRandomAxis) 1423 sAxis = Random(3); 1424 else if (mCirculatingAxis) 1425 sAxis = (tData.mAxis + 1) % 3; 1426 else if (mOnlyDrivingAxis || (tData.mDepth < maxDepthForDrivingAxis)) 1414 1427 sAxis = box.Size().DrivingAxis(); 1415 else if (mUseRandomAxis) 1416 sAxis = Random(3); 1417 else if (mSimulateOctree) 1418 sAxis = (tData.mAxis + 1) % 3; 1428 1419 1429 1420 1430 //Debug << "use special axis: " << useSpecialAxis << endl; … … 1519 1529 int &splitAxis) 1520 1530 { 1531 // hack 1532 if (data.mDepth < 0) 1533 { 1534 cout << "d: " << data.mDepth << endl; 1535 // return axis aligned split 1536 AxisAlignedBox3 box; 1537 box.Initialize(); 1538 1539 // create bounding box of region 1540 data.mGeometry->GetBoundingBox(box); 1541 1542 const int axis = box.Size().DrivingAxis(); 1543 const Vector3 position = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 1544 1545 Vector3 norm(0,0,0); norm[axis] = 1.0f; 1546 bestPlane = Plane3(norm, position); 1547 splitAxis = axis; 1548 return true; 1549 } 1550 1521 1551 // simplest strategy: just take next polygon 1522 1552 if (mSplitPlaneStrategy & RANDOM_POLYGON) … … 1623 1653 } 1624 1654 1625 1626 // if (lowestCost > 10)1627 // Debug << "warning!! lowest cost: " << lowestCost << endl;1628 1629 1655 #ifdef _DEBUG 1630 1656 Debug << "plane lowest cost: " << lowestCost << endl; 1631 1657 #endif 1632 1658 1659 // exeeded relative max cost ratio 1633 1660 if (lowestCost > mTermMaxCostRatio) 1634 1661 { … … 2052 2079 2053 2080 //-- compute heurstics 2054 // 2081 //-- we take simplified computation for mid split 2055 2082 2056 2083 pOverall = data.mProbability; … … 2776 2803 BspNodeGeometry nodeGeom; 2777 2804 ConstructGeometry(n, nodeGeom); 2805 // const float eps = 0.5f; 2778 2806 const float eps = 0.01f; 2779 2780 2807 // split planes from the root to this node 2781 2808 // needed to verify that we found neighbor leaf -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r735 r801 795 795 int mTotalPvsSize; 796 796 797 float mMinBand; 798 float mMaxBand; 799 797 800 //int mSplits; 798 801 /// subdivision stats output file … … 807 810 int mCreatedViewCells; 808 811 /// if vsp bsp tree should simulate octree 809 bool m SimulateOctree;812 bool mCirculatingAxis; 810 813 811 814 /// if we should use breath first priority for the splits -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h
r752 r801 92 92 MeshDefinitions mMeshDefinitions; 93 93 94 // TODO: for storing meshes 95 MeshContainer *mMeshes; 94 96 bool mIsMeshDefinition; 95 97 // Handlers for X3D
Note: See TracChangeset
for help on using the changeset viewer.