Changeset 2017 for GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
- Timestamp:
- 01/22/07 23:35:03 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2015 r2017 268 268 269 269 270 271 270 bool VspInterior::IsLeaf() const 271 { 272 return false; 273 } 274 275 276 VspNode *VspInterior::GetBack() 277 { 278 return mBack; 279 } 280 281 282 VspNode *VspInterior::GetFront() 283 { 284 return mFront; 285 } 286 287 288 AxisAlignedPlane VspInterior::GetPlane() const 289 { 290 return mPlane; 291 } 292 293 294 float VspInterior::GetPosition() const 295 { 296 return mPlane.mPosition; 297 } 298 299 300 int VspInterior::GetAxis() const 301 { 302 return mPlane.mAxis; 303 } 272 304 273 305 … … 356 388 357 389 390 ViewCellLeaf *VspLeaf::GetViewCell() const 391 { 392 return mViewCell; 393 } 358 394 359 395 … … 364 400 365 401 402 bool VspLeaf::IsLeaf() const 403 { 404 return true; 405 } 366 406 367 407 … … 665 705 // todo remove dynamic cast 666 706 VspSubdivisionCandidate *sc = 667 dynamic_cast<VspSubdivisionCandidate *>(splitCandidate);707 static_cast<VspSubdivisionCandidate *>(splitCandidate); 668 708 669 709 VspTraversalData &tData = sc->mParentData; … … 718 758 if (newNode->IsLeaf()) // subdivision terminated 719 759 { 720 VspLeaf *leaf = dynamic_cast<VspLeaf *>(newNode);760 VspLeaf *leaf = static_cast<VspLeaf *>(newNode); 721 761 722 762 #if 0 … … 787 827 } 788 828 789 VspLeaf *leaf = dynamic_cast<VspLeaf *>(splitCandidate.mParentData.mNode);829 VspLeaf *leaf = static_cast<VspLeaf *>(splitCandidate.mParentData.mNode); 790 830 791 831 ///////////// … … 882 922 VspTraversalData &backData) 883 923 { 884 VspLeaf *leaf = dynamic_cast<VspLeaf *>(sc.mParentData.mNode);924 VspLeaf *leaf = static_cast<VspLeaf *>(sc.mParentData.mNode); 885 925 886 926 const VspTraversalData &tData = sc.mParentData; … … 1441 1481 if (parent) 1442 1482 { 1443 parentAxis = dynamic_cast<VspInterior *>(parent)->GetAxis();1483 parentAxis = static_cast<VspInterior *>(parent)->GetAxis(); 1444 1484 } 1445 1485 … … 1816 1856 { 1817 1857 // test if this leaf is in valid view space 1818 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node);1858 VspLeaf *leaf = static_cast<VspLeaf *>(node); 1819 1859 1820 1860 if (leaf->TreeValid() && … … 1827 1867 else 1828 1868 { 1829 VspInterior *interior = dynamic_cast<VspInterior *>(node);1869 VspInterior *interior = static_cast<VspInterior *>(node); 1830 1870 1831 1871 nodeStack.push(interior->GetBack()); … … 1851 1891 { 1852 1892 // the node became a leaf -> evaluate stats for leafs 1853 VspLeaf *leaf = dynamic_cast<VspLeaf *>(data.mNode);1893 VspLeaf *leaf = static_cast<VspLeaf *>(data.mNode); 1854 1894 1855 1895 if (data.mPvs > mVspStats.maxPvs) … … 1926 1966 if (node->IsLeaf()) 1927 1967 { 1928 BspViewCell *viewCell = dynamic_cast<VspLeaf *>(node)->GetViewCell();1968 BspViewCell *viewCell = static_cast<VspLeaf *>(node)->GetViewCell(); 1929 1969 1930 1970 if (!viewCell->GetValid()) 1931 1971 { 1932 BspViewCell *viewCell = dynamic_cast<VspLeaf *>(node)->GetViewCell();1972 BspViewCell *viewCell = static_cast<VspLeaf *>(node)->GetViewCell(); 1933 1973 1934 1974 ViewCellContainer leaves; … … 1939 1979 for (it = leaves.begin(); it != it_end; ++ it) 1940 1980 { 1941 VspLeaf *l = dynamic_cast<BspViewCell *>(*it)->mLeaf;1981 VspLeaf *l = static_cast<BspViewCell *>(*it)->mLeaf; 1942 1982 l->SetViewCell(GetOrCreateOutOfBoundsCell()); 1943 1983 ++ mVspStats.invalidLeaves; … … 1952 1992 else 1953 1993 { 1954 VspInterior *interior = dynamic_cast<VspInterior *>(node);1994 VspInterior *interior = static_cast<VspInterior *>(node); 1955 1995 1956 1996 nodeStack.push(interior->GetFront()); … … 2005 2045 if (node->IsLeaf()) 2006 2046 { 2007 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node);2047 VspLeaf *leaf = static_cast<VspLeaf *>(node); 2008 2048 2009 2049 if (!leaf->GetViewCell()->GetValid()) … … 2019 2059 else 2020 2060 { 2021 VspInterior *interior = dynamic_cast<VspInterior *>(node);2061 VspInterior *interior = static_cast<VspInterior *>(node); 2022 2062 2023 2063 nodeStack.push(interior->GetFront()); … … 2051 2091 if (!onlyValid || node->TreeValid()) 2052 2092 { 2053 ViewCellLeaf *leafVc = dynamic_cast<VspLeaf *>(node)->GetViewCell();2093 ViewCellLeaf *leafVc = static_cast<VspLeaf *>(node)->GetViewCell(); 2054 2094 2055 2095 ViewCell *viewCell = mViewCellsTree->GetActiveViewCell(leafVc); … … 2064 2104 else 2065 2105 { 2066 VspInterior *interior = dynamic_cast<VspInterior *>(node);2106 VspInterior *interior = static_cast<VspInterior *>(node); 2067 2107 2068 2108 nodeStack.push(interior->GetFront()); … … 2089 2129 if (node->IsLeaf()) 2090 2130 { 2091 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node);2131 VspLeaf *leaf = static_cast<VspLeaf *>(node); 2092 2132 2093 2133 if (leaf != n && (!onlyUnmailed || !leaf->Mailed())) … … 2096 2136 else 2097 2137 { 2098 VspInterior *interior = dynamic_cast<VspInterior *>(node);2138 VspInterior *interior = static_cast<VspInterior *>(node); 2099 2139 2100 2140 if (interior->GetPosition() > box.Max(interior->GetAxis())) … … 2134 2174 if (node->IsLeaf()) 2135 2175 { 2136 return dynamic_cast<VspLeaf *>(node);2176 return static_cast<VspLeaf *>(node); 2137 2177 } 2138 2178 else 2139 2179 { 2140 VspInterior *interior = dynamic_cast<VspInterior *>(node);2180 VspInterior *interior = static_cast<VspInterior *>(node); 2141 2181 VspNode *next; 2142 2182 … … 2186 2226 { 2187 2227 if ( (!onlyUnmailed || !node->Mailed()) ) 2188 return dynamic_cast<VspLeaf *>(node);2228 return static_cast<VspLeaf *>(node); 2189 2229 } 2190 2230 else 2191 2231 { 2192 VspInterior *interior = dynamic_cast<VspInterior *>(node);2232 VspInterior *interior = static_cast<VspInterior *>(node); 2193 2233 2194 2234 // random decision … … 2336 2376 int axis; 2337 2377 2338 ViewCell::NewMail();2339 2340 2378 while (1) 2341 2379 { 2342 2380 if (!node->IsLeaf()) 2343 2381 { 2344 VspInterior *in = (VspInterior *)node;2382 VspInterior *in = static_cast<VspInterior *>(node); 2345 2383 position = in->GetPosition(); 2346 2384 axis = in->GetAxis(); … … 2387 2425 { 2388 2426 // compute intersection with all objects in this leaf 2389 VspLeaf *leaf = (VspLeaf *)node;2427 VspLeaf *leaf = static_cast<VspLeaf *>(node); 2390 2428 ViewCell *viewCell; 2391 // if (0) 2392 // viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 2393 // else 2394 2395 viewCell = leaf->GetViewCell(); 2396 2429 if (0) 2430 viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 2431 else 2432 viewCell = leaf->GetViewCell(); 2433 2397 2434 // don't have to mail if each view cell belongs to exactly one leaf 2398 // $$ JB -> always mailbox so that we have less conditions 2399 if (!viewCell->Mailed()) { 2400 viewCell->Mail(); 2401 2402 viewcells.push_back(viewCell); 2403 ++ hits; 2404 } 2405 2435 if (!useMailboxing || !viewCell->Mailed()) 2436 { 2437 if (useMailboxing) 2438 viewCell->Mail(); 2439 2440 viewcells.push_back(viewCell); 2441 ++ hits; 2442 } 2443 2406 2444 // get the next node from the stack 2407 2445 if (tStack.empty()) 2408 2409 2446 break; 2447 2410 2448 entp = extp; 2411 2449 mint = maxt; … … 2454 2492 if (!node->IsLeaf()) 2455 2493 { 2456 VspInterior *in = dynamic_cast<VspInterior *>(node);2494 VspInterior *in = static_cast<VspInterior *>(node); 2457 2495 position = in->GetPosition(); 2458 2496 axis = in->GetAxis(); … … 2499 2537 { 2500 2538 // compute intersection with all objects in this leaf 2501 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node);2539 VspLeaf *leaf = static_cast<VspLeaf *>(node); 2502 2540 ViewCell *vc = leaf->GetViewCell(); 2503 2541 … … 2545 2583 if (node->IsLeaf()) 2546 2584 { 2547 /*const AxisAlignedBox3 box = GetBoundingBox( dynamic_cast<VspLeaf *>(node));2585 /*const AxisAlignedBox3 box = GetBoundingBox(static_cast<VspLeaf *>(node)); 2548 2586 if (!box.IsInside(point)) 2549 2587 cerr << "error, point " << point << " should be in view cell " << box << endl; 2550 2588 */ 2551 viewcell = dynamic_cast<VspLeaf *>(node)->GetViewCell();2589 viewcell = static_cast<VspLeaf *>(node)->GetViewCell(); 2552 2590 break; 2553 2591 } 2554 2592 else 2555 2593 { 2556 VspInterior *interior = dynamic_cast<VspInterior *>(node);2594 VspInterior *interior = static_cast<VspInterior *>(node); 2557 2595 2558 2596 // random decision … … 2592 2630 return false; 2593 2631 2594 VspInterior *in = dynamic_cast<VspInterior *>(node);2632 VspInterior *in = static_cast<VspInterior *>(node); 2595 2633 2596 2634 if (in->GetPosition() - viewPoint[in->GetAxis()] <= 0) … … 2628 2666 { 2629 2667 node = node->GetParent(); 2630 VspInterior *interior = dynamic_cast<VspInterior *>(node);2668 VspInterior *interior = static_cast<VspInterior *>(node); 2631 2669 2632 2670 // the parent is valid iff both leaves are valid … … 2650 2688 if (node->IsLeaf()) 2651 2689 { 2652 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node);2690 VspLeaf *leaf = static_cast<VspLeaf *>(node); 2653 2691 ViewCell *viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 2654 2692 … … 2661 2699 else 2662 2700 { 2663 VspInterior *interior = dynamic_cast<VspInterior *>(node);2701 VspInterior *interior = static_cast<VspInterior *>(node); 2664 2702 2665 2703 AxisAlignedPlane plane = interior->GetPlane(); … … 2731 2769 if (!node->IsLeaf()) 2732 2770 { 2733 return ( dynamic_cast<VspInterior *>(node))->GetBoundingBox();2734 } 2735 2736 VspInterior *parent = dynamic_cast<VspInterior *>(node->GetParent());2771 return (static_cast<VspInterior *>(node))->GetBoundingBox(); 2772 } 2773 2774 VspInterior *parent = static_cast<VspInterior *>(node->GetParent()); 2737 2775 2738 2776 AxisAlignedBox3 box(parent->GetBoundingBox()); … … 2766 2804 if (node->IsLeaf()) 2767 2805 { 2768 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node);2806 VspLeaf *leaf = static_cast<VspLeaf *>(node); 2769 2807 2770 2808 if (!leaf->GetViewCell()->Mailed() && leaf->TreeValid()) … … 2776 2814 else 2777 2815 { 2778 VspInterior *interior = dynamic_cast<VspInterior *>(node);2816 VspInterior *interior = static_cast<VspInterior *>(node); 2779 2817 2780 2818 VspNode *first = interior->GetFront(); … … 2887 2925 2888 2926 // root and bounding box were already constructed 2889 VspLeaf *leaf = dynamic_cast<VspLeaf *>(mRoot);2927 VspLeaf *leaf = static_cast<VspLeaf *>(mRoot); 2890 2928 2891 2929 ////////// … … 3304 3342 { 3305 3343 // todo remove dynamic cast 3306 VspSubdivisionCandidate *sc = dynamic_cast<VspSubdivisionCandidate *>(splitCandidate);3344 VspSubdivisionCandidate *sc = static_cast<VspSubdivisionCandidate *>(splitCandidate); 3307 3345 3308 3346 VspTraversalData &tData = sc->mParentData; … … 3318 3356 VspTraversalData tBackData; 3319 3357 3320 VspInterior *oldInterior = dynamic_cast<VspInterior *>(oldNode);3358 VspInterior *oldInterior = static_cast<VspInterior *>(oldNode); 3321 3359 3322 3360 // create new interior node and two leaf node … … 3387 3425 { 3388 3426 const ObjectPvsEntry &entry = oit.Next(); 3389 BvhNode *obj = dynamic_cast<BvhNode *>(entry.mObject);3427 BvhNode *obj = static_cast<BvhNode *>(entry.mObject); 3390 3428 3391 3429 if (!obj->IsRoot()) … … 3416 3454 { 3417 3455 const ObjectPvsEntry &entry = oit.Next(); 3418 BvhNode *obj = dynamic_cast<BvhNode *>(entry.mObject);3456 BvhNode *obj = static_cast<BvhNode *>(entry.mObject); 3419 3457 3420 3458 if (!obj->IsRoot()) … … 3486 3524 if (!node->IsLeaf()) 3487 3525 { 3488 VspInterior *in = dynamic_cast<VspInterior *>(node);3526 VspInterior *in = static_cast<VspInterior *>(node); 3489 3527 position = in->GetPosition(); 3490 3528 axis = in->GetAxis(); … … 3531 3569 { 3532 3570 // compute intersection with all objects in this leaf 3533 VspLeaf *leaf = dynamic_cast<VspLeaf *>(node);3571 VspLeaf *leaf = static_cast<VspLeaf *>(node); 3534 3572 ViewCell *viewCell; 3535 3573 if (0)
Note: See TracChangeset
for help on using the changeset viewer.