Changeset 1586 for GTP/trunk/Lib
- Timestamp:
- 10/09/06 15:57:28 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.cpp
r1291 r1586 141 141 // don't stop until cursor is placed one element behind 142 142 // or end of vector is reached 143 StatsContainer::const_iterator equalCostIt = std::upper_bound(firstStats.begin(), firstStats.end(), *it, vlt); 143 StatsContainer::const_iterator equalCostIt = 144 std::upper_bound(firstStats.begin(), firstStats.end(), *it, vlt); 144 145 145 146 int j = (int)(equalCostIt - firstStats.begin()); -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp
r1344 r1586 55 55 } 56 56 57 int 58 TriangleIntersectable::GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) 59 { 60 // random barycentric coordinates 61 const float a = RandomValue(0, 1); 62 const float b = RandomValue(0, 1); 63 const float c = 1.0 - a - b; 64 65 point = mItem.mVertices[0] + a * (mItem.mVertices[1] - mItem.mVertices[0]) + 66 mItem.mVertices[0] + b * (mItem.mVertices[2] - mItem.mVertices[0]) + 67 mItem.mVertices[1] + c * (mItem.mVertices[2] - mItem.mVertices[1]); 68 69 normal = mItem.GetNormal(); 70 71 return 0; 72 } 73 57 74 58 75 } -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
r1581 r1586 185 185 return Intersectable::TRIANGLE_INTERSECTABLE; 186 186 } 187 188 int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal); 187 189 }; 188 190 -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r1449 r1586 422 422 Mesh::GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) 423 423 { 424 const int faceIndex = (int)RandomValue(0, (Real)((int)mFaces.size()-1)); 425 424 //const int faceIndex = (int)RandomValue(0, (Real)((int)mFaces.size()-1)); 425 const int faceIndex = (int)RandomValue(0, (Real)mFaces.size() - 0.5f); 426 426 427 // assume the face is convex and generate a convex combination 427 428 // … … 450 451 { 451 452 Plane3 plane; 452 int faceIndex = (int)RandomValue(0, (Real)((int)mFaces.size()-1));453 const int faceIndex = (int)RandomValue(0, (Real)mFaces.size() - 0.5f); 453 454 int tries; 454 455 for (tries = 0; tries < maxTries; tries++) { -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp
r1486 r1586 23 23 We eliminate already accounted kd nodes and objects using mailboxing. 24 24 */ 25 static int CountNewObjectsInKdNode(KdIntersectable *kdobj)25 static int EvalKdNodeContribution(KdIntersectable *kdobj) 26 26 { 27 27 int pvs = 0; … … 76 76 77 77 78 /** the pvs is the number of different objects in the node leaves78 /** Returns the the number of different objects in the leaves of the node. 79 79 We eliminate already accounted kd nodes and objects using mailboxing. 80 80 */ 81 static int CountNewObjectsInBvhNode(BvhIntersectable *bvhobj)81 static int EvalBvhNodeContribution(BvhIntersectable *bvhobj) 82 82 { 83 83 BvhNode *node= bvhobj->GetItem(); … … 113 113 { 114 114 BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(node); 115 115 116 116 // add #objects exclusivly in this node 117 117 pvs += (int)leaf->mObjects.size(); … … 126 126 } 127 127 } 128 128 129 return pvs; 129 130 } … … 151 152 // found kd node 152 153 KdIntersectable *kdObj = dynamic_cast<KdIntersectable *>(obj); 153 pvs += CountNewObjectsInKdNode(kdObj);154 pvs += EvalKdNodeContribution(kdObj); 154 155 break; 155 156 } … … 157 158 { 158 159 BvhIntersectable *bvhObj = dynamic_cast<BvhIntersectable *>(obj); 159 pvs += CountNewObjectsInBvhNode(bvhObj);160 pvs += EvalBvhNodeContribution(bvhObj); 160 161 break; 161 162 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1528 r1586 505 505 { 506 506 public: 507 /** Counts object int the pvs. Different to GetSize(), not507 /** Counts object int the pvs. Different to method "GetSize", not 508 508 only the raw container size is returned, 509 509 but the individual contributions of the entries are summed up. … … 512 512 }; 513 513 514 515 //////////// 514 516 //-- typedefs 515 517 -
GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.cpp
r1421 r1586 47 47 ////////////// 48 48 // specialised triangle ray casting version 49 50 /////////// 51 //-- calc ray-plane intersection 49 // using ray-plane intersection 52 50 53 51 // get triangle edge vectors and plane normal -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1585 r1586 53 53 } 54 54 55 /// Counts differences between pvss. 56 inline int CountDiffPvs(ViewCell *vc) 55 /** Counts contribution of the view cell to the pvs. 56 */ 57 inline int CountPvsContribution(ViewCell *vc) 57 58 { 58 59 int count = 0; … … 257 258 { 258 259 const bool result = mPvs.AddSample(sample, pdf, contribution); 259 mPvsSizeValid = false; // have to recompute pvs size 260 // have to recompute pvs size 261 mPvsSizeValid = false; 260 262 261 263 return result; … … 1038 1040 // set scalars 1039 1041 mViewCellsManager->UpdateScalarPvsSize(left, 1040 left->GetPvs().CountObjectsInPvs(),1041 left->GetPvs().GetSize());1042 left->GetPvs().CountObjectsInPvs(), 1043 left->GetPvs().GetSize()); 1042 1044 1043 1045 // remove pvs, we don't store interior pvss … … 1384 1386 void ViewCellsTree::EvalMergeCost(MergeCandidate &mc) const 1385 1387 { 1388 /////////////////// 1386 1389 //-- compute pvs difference 1390 1387 1391 int newPvs; 1392 1388 1393 if (1) // not valid if not using const cost per object!! 1394 { 1389 1395 newPvs = ComputeMergedPvsSize(mc.mLeftViewCell->GetPvs(), mc.mRightViewCell->GetPvs()); 1396 } 1390 1397 else 1398 { 1391 1399 newPvs = (int)ComputeMergedPvsCost(mc.mLeftViewCell->GetPvs(), mc.mRightViewCell->GetPvs()); 1400 } 1392 1401 1393 1402 const float newPenalty = EvalPvsPenalty(newPvs, … … 1399 1408 1400 1409 //-- compute ratio of old cost 1401 // 1402 // 1410 //-- (i.e., added size of left and right view cell times pvs size) 1411 //-- to new rendering cost (i.e, size of merged view cell times pvs size) 1403 1412 const float oldCost = GetRenderCost(vc1) + GetRenderCost(vc2); 1404 1413 … … 1419 1428 } 1420 1429 1421 1430 /////////////////////////// 1422 1431 //-- merge cost also takes deviation into account 1432 1423 1433 float newDev, oldDev; 1424 1434 … … 1788 1798 ObjectPvs newPvs; 1789 1799 1790 // sum differentintersectables1800 // sum up uniquely found intersectables 1791 1801 for (it = leaves.begin(); it != it_end; ++ it) 1792 1802 { … … 1881 1891 1882 1892 // matt: bug! must evaluate kd pvss also 1883 pvsSize += Count DiffPvs(root);1893 pvsSize += CountPvsContribution(root); 1884 1894 } 1885 1895 … … 1892 1902 tstack.pop(); 1893 1903 // matt: bug! must evaluate kd pvss also 1894 pvsSize += Count DiffPvs(vc);1904 pvsSize += CountPvsContribution(vc); 1895 1905 1896 1906 if (!vc->IsLeaf()) … … 1915 1925 int pvsSize = 0; 1916 1926 1927 ///////////////// 1917 1928 //-- compressed pvs 1918 1929 … … 1931 1942 root = root->GetParent(); 1932 1943 // count the pvs entries different from the already found ones 1933 pvsSize += Count DiffPvs(root);1944 pvsSize += CountPvsContribution(root); 1934 1945 } 1935 1946 … … 1943 1954 1944 1955 // count the pvs entries different from the already found ones 1945 pvsSize += Count DiffPvs(vc);1956 pvsSize += CountPvsContribution(vc); 1946 1957 1947 1958 if (!vc->IsLeaf()) … … 2029 2040 sizeof(PvsData) + sizeof(Intersectable *); 2030 2041 2031 return (float) GetStoredPvsEntriesNum(vc) * entrySize;2032 } 2033 2034 2035 int ViewCellsTree:: GetStoredPvsEntriesNum(ViewCell *root) const2042 return (float)CountStoredPvsEntries(vc) * entrySize; 2043 } 2044 2045 //#if HAS_TO_BE_REDONE 2046 int ViewCellsTree::CountStoredPvsEntries(ViewCell *root) const 2036 2047 { 2037 2048 int pvsSize = root->GetPvs().GetSize(); … … 2046 2057 for (it = interior->mChildren.begin(); it != it_end; ++ it) 2047 2058 { 2048 pvsSize += GetStoredPvsEntriesNum(*it);2059 pvsSize += CountStoredPvsEntries(*it); 2049 2060 } 2050 2061 } … … 2052 2063 return pvsSize; 2053 2064 } 2054 2065 //#endif 2055 2066 2056 2067 int ViewCellsTree::ViewCellsStorage() const -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1551 r1586 275 275 */ 276 276 bool mPvsSizeValid; 277 278 277 }; 279 278 … … 432 431 void GetPvs(ViewCell *vc, ObjectPvs &pvs) const; 433 432 434 /** Returns pvs size (i.e. the number of stored objects 433 /** Returns pvs size (i.e. the number of stored objects) 435 434 */ 436 435 int GetPvsSize(ViewCell *vc) const; 437 436 438 437 /** Returns number of entries associated with this view cell. 439 This returns the same value as the GetPvsSize function for object pvs, 440 but most likely different values for kd node based pvs. 438 439 This returns the same value as the "GetPvsSize" function for object pvs 440 but most likely different values if we use object space grouping. 441 E.g., using bounding volumes. 441 442 */ 442 443 int GetPvsEntries(ViewCell *vc) const; 443 444 444 /** Returns the actual number of stored entries in the view cells sub tree. 445 */ 446 int GetStoredPvsEntriesNum(ViewCell *root) const; 445 /** Returns the number of physically stored entries in the view cells sub tree. 446 This can vary based on the current storage method 447 */ 448 int CountStoredPvsEntries(ViewCell *root) const; 447 449 448 450 /** Returns memory cost of this view cell. … … 458 460 enum {PVS_IN_INTERIORS, COMPRESSED, PVS_IN_LEAVES}; 459 461 460 461 462 /** If view cells in this tree have compressed pvs. 462 463 */ … … 503 504 void SetViewCellsManager(ViewCellsManager *vcm); 504 505 506 505 507 protected: 506 508 509 /** Reads the environment and sets member variables. 510 */ 507 511 void ReadEnvironment(); 508 512 … … 598 602 void ExportPvs(ViewCell *viewCell, OUT_STREAM &stream); 599 603 604 /** Counts the logical number of entries in the pvs this view cell. 605 The pvs is assumed to be stored using lossless compression. 606 */ 600 607 int GetEntriesInPvsForCompressedStorage(ViewCell *vc) const; 608 609 /** Computes pvs size of this view cell. 610 The pvs is assumed to be stored using lossless compression. 611 */ 601 612 int GetPvsSizeForCompressedStorage(ViewCell *vc) const; 613 614 /** Computes pvs size of this view cell. 615 The pvs is assumed to be stored in the leaves. 616 */ 602 617 int GetPvsSizeForLeafStorage(ViewCell *vc) const; 618 619 /** Counts the logical number of entries in the pvs this view cell. 620 The pvs is assumed to be stored using the leaves. 621 */ 603 622 int GetEntriesInPvsForLeafStorage(ViewCell *vc) const; 604 623 624 /** Update stats for the log. 625 */ 605 626 void UpdateStats( 606 627 ofstream &stats, … … 618 639 const float volume); 619 640 641 642 ////////////////////////////////////// 643 620 644 /// if the view cell tree hold compressed pvs 621 645 int mViewCellsStorage; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1584 r1586 911 911 cout << "compute new statistics ... " << endl; 912 912 913 ///////////////7 913 914 //-- propagate pvs or pvs size information 915 914 916 ObjectPvs pvs; 915 917 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 916 918 919 /////////// 917 920 //-- output stats 918 921 sprintf(str, "-%09d-eval.log", castSamples); … … 1128 1131 ) const 1129 1132 { 1130 if (!vc->IsLeaf() && vc->GetMergeCost() < 0.0f) { 1131 ViewCellInterior *vci = (ViewCellInterior *) vc; 1132 ViewCellContainer::const_iterator it, it_end = vci->mChildren.end(); 1133 1134 for (it = vci->mChildren.begin(); it != it_end; ++ it) 1135 DeleteLocalMergeTree(*it); 1136 vci->mChildren.clear(); 1137 delete vci; 1133 if (!vc->IsLeaf() && vc->GetMergeCost() < 0.0f) 1134 { 1135 ViewCellInterior *vci = (ViewCellInterior *) vc; 1136 ViewCellContainer::const_iterator it, it_end = vci->mChildren.end(); 1137 1138 for (it = vci->mChildren.begin(); it != it_end; ++ it) 1139 DeleteLocalMergeTree(*it); 1140 1141 vci->mChildren.clear(); 1142 1143 delete vci; 1138 1144 } 1139 1145 } … … 1489 1495 //-- extrude new vertices for top of prism 1490 1496 1491 Vector3 triNorm = baseTri.GetNormal();1497 const Vector3 triNorm = baseTri.GetNormal(); 1492 1498 Triangle3 topTri; 1493 1499 … … 2236 2242 if (viewSpaceFilterSize >= 0.0f) { 2237 2243 2238 bool usePrVS = false;2244 const bool usePrVS = false; 2239 2245 2240 2246 if (!usePrVS) { … … 2351 2357 2352 2358 // $$ warning collect objects takes only unmailed ones! 2353 kdTree->CollectObjects(box, 2354 objects); 2359 kdTree->CollectObjects(box, objects); 2355 2360 // cout<<"collected objects="<<objects.size()<<endl; 2356 2361 ObjectContainer::const_iterator noi = objects.begin(); 2357 for (; noi != objects.end(); ++noi) { 2358 Intersectable *o = *noi; 2359 // $$ JB warning: pdfs are not correct at this point! 2360 nPvs.AddSample(o, Limits::Small); 2361 nPvsSize++; 2362 for (; noi != objects.end(); ++ noi) 2363 { 2364 Intersectable *o = *noi; 2365 // $$ JB warning: pdfs are not correct at this point! 2366 nPvs.AddSample(o, Limits::Small); 2367 nPvsSize ++; 2362 2368 } 2363 2369 } … … 2455 2461 } 2456 2462 2457 //-- interior node => propagate pvs up 2463 //////////////// 2464 //-- interior node => propagate pvs up the tree 2465 2458 2466 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 2459 2467 interior->GetPvs().Clear(); … … 2467 2475 ObjectPvs objPvs; 2468 2476 2477 ////////////////// 2469 2478 //-- recursivly compute child pvss 2479 2470 2480 UpdatePvsForEvaluation(*vit, objPvs); 2471 2481 … … 2478 2488 2479 2489 //-- faster way of computing pvs: 2480 // construct merged pvs by adding 2481 // and only those of the next pvs which were not mailed. 2482 // note: sumpdf is not correct!! 2490 //-- construct merged pvs by adding 2491 //-- and only those of the next pvs which were not mailed. 2492 //-- note: sumpdf is not correct!! 2493 2483 2494 vector<ObjectPvs>::iterator oit = pvsList.begin(); 2484 2495 … … 2508 2519 UpdateScalarPvsSize(interior, pvs.CountObjectsInPvs(), pvs.GetSize()); 2509 2520 2510 2511 #else// really merge cells: slow put sumPdf is correct2521 #else 2522 // really merge cells: slow put sumPdf is correct 2512 2523 viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 2513 2524 viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); … … 2561 2572 2562 2573 const float prop = (float)limit / ((float)rays.size() + Limits::Small); 2574 2563 2575 for (it = rays.begin(); it != it_end; ++ it) 2564 2576 { … … 4046 4058 //////////// 4047 4059 //-- compression 4048 4060 //#if HAS_TO_BE_REDONE 4049 4061 if (ViewCellsTreeConstructed() && mCompressViewCells) 4050 4062 { 4051 int pvsEntries = mViewCellsTree-> GetStoredPvsEntriesNum(mViewCellsTree->GetRoot());4063 int pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot()); 4052 4064 Debug << "number of entries before compress: " << pvsEntries << endl; 4053 4065 4054 4066 mViewCellsTree->SetViewCellsStorage(ViewCellsTree::COMPRESSED); 4055 4067 4056 pvsEntries = mViewCellsTree-> GetStoredPvsEntriesNum(mViewCellsTree->GetRoot());4068 pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot()); 4057 4069 Debug << "number of entries after compress: " << pvsEntries << endl; 4058 4070 } 4059 4071 //#endif 4060 4072 4061 4073 // collapse sibling leaves that share the same view cell … … 4919 4931 4920 4932 4921 /////////// ////4933 /////////// 4922 4934 //-- compression 4923 4935 4936 //#if HAS_TO_BE_REDONE 4924 4937 if (ViewCellsTreeConstructed() && mCompressViewCells) 4925 4938 { 4926 int pvsEntries = mViewCellsTree-> GetStoredPvsEntriesNum(mViewCellsTree->GetRoot());4939 int pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot()); 4927 4940 Debug << "number of entries before compress: " << pvsEntries << endl; 4928 4941 4929 4942 mViewCellsTree->SetViewCellsStorage(ViewCellsTree::COMPRESSED); 4930 4943 4931 pvsEntries = mViewCellsTree-> GetStoredPvsEntriesNum(mViewCellsTree->GetRoot());4944 pvsEntries = mViewCellsTree->CountStoredPvsEntries(mViewCellsTree->GetRoot()); 4932 4945 Debug << "number of entries after compress: " << pvsEntries << endl; 4933 4946 } 4947 //#endif 4934 4948 4935 4949 ///////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1581 r1586 983 983 984 984 int viewCellId; 985 986 int len = attributes.getLength(); 985 const int len = attributes.getLength(); 987 986 988 987 for (int i = 0; i < len; ++ i) … … 1038 1037 { 1039 1038 AxisAlignedPlane plane; 1040 int len = attributes.getLength();1039 const int len = attributes.getLength(); 1041 1040 1042 1041 for (int i = 0; i < len; ++ i) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1580 r1586 930 930 VspBspTraversalData tBackData; 931 931 932 //////////////////// 932 933 //-- continue subdivision 933 934 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1580 r1586 2339 2339 // compute intersection with all objects in this leaf 2340 2340 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 2341 ViewCell *vc = leaf->GetViewCell(); 2341 ViewCell *viewCell; 2342 if (0) 2343 viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 2344 else 2345 viewCell = leaf->GetViewCell(); 2342 2346 2343 2347 // don't have to mail if each view cell belongs to exactly one leaf 2344 if (!useMailboxing || !v c->Mailed())2348 if (!useMailboxing || !viewCell->Mailed()) 2345 2349 { 2346 2350 if (useMailboxing) 2347 v c->Mail();2348 2349 viewcells.push_back(v c);2351 viewCell->Mail(); 2352 2353 viewcells.push_back(viewCell); 2350 2354 ++ hits; 2351 2355 } 2352 #if 0 2353 leaf->mRays.push_back(RayInfo(new VssRay(origin, termination, NULL, NULL, 0))); 2354 #endif 2356 2355 2357 // get the next node from the stack 2356 2358 if (tStack.empty()) … … 2364 2366 extp = s.mExitPoint; 2365 2367 maxt = s.mMaxT; 2368 2366 2369 tStack.pop(); 2367 2370 } … … 2511 2514 2512 2515 if (active) 2516 { 2513 2517 return mViewCellsTree->GetActiveViewCell(viewcell); 2518 } 2514 2519 else 2520 { 2515 2521 return viewcell; 2522 } 2516 2523 } 2517 2524
Note: See TracChangeset
for help on using the changeset viewer.