Changeset 2618 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 01/20/08 01:17:49 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r2615 r2618 762 762 } 763 763 764 int KdTree::CastLineSegment (const Vector3 &origin,764 int KdTree::CastLineSegment2(const Vector3 &origin, 765 765 const Vector3 &termination, 766 766 ViewCellContainer &viewcells) … … 850 850 if (tStack.empty()) 851 851 break; 852 853 entp = extp; 854 mint = maxt; 855 856 RayTraversalData &s = tStack.top(); 857 node = s.mNode; 858 extp = s.mExitPoint; 859 maxt = s.mMaxT; 860 tStack.pop(); 861 } 862 } 863 return hits; 864 } 865 866 int KdTree::CastLineSegment(const Vector3 &origin, 867 const Vector3 &termination, 868 ViewCellContainer &viewcells) 869 { 870 int hits = 0; 871 872 float mint = 0.0f, maxt = 1.0f; 873 const Vector3 dir = termination - origin; 874 875 stack<RayTraversalData> tStack; 876 877 Intersectable::NewMail(); 878 879 //maxt += Limits::Threshold; 880 881 Vector3 entp = origin; 882 Vector3 extp = termination; 883 884 KdNode *node = mRoot; 885 KdNode *farChild; 886 887 float position; 888 float tdist; 889 890 while (1) 891 { 892 if (!node->IsLeaf()) 893 { 894 KdInterior *in = static_cast<KdInterior *>(node); 895 position = in->mPosition; 896 switch (in->mAxis) { 897 case 0: 898 if (entp.x <= position) 899 { 900 if (extp.x <= position) 901 { 902 node = in->mBack; 903 // cases N1,N2,N3,P5,Z2,Z3 904 continue; 905 } 906 else 907 { 908 // case N4 909 node = in->mBack; 910 farChild = in->mFront; 911 } 912 } 913 else 914 { 915 if (position <= extp.x) 916 { 917 node = in->mFront; 918 // cases P1,P2,P3,N5,Z1 919 continue; 920 } 921 else 922 { 923 node = in->mFront; 924 farChild = in->mBack; 925 // case P4 926 } 927 } 928 929 // $$ modification 3.5.2004 - hints from Kamil Ghais 930 // case N4 or P4 931 tdist = (position - origin.x) / dir.x; 932 //tStack.push(RayTraversalData(farChild, extp, maxt)); //TODO 933 extp = origin + dir * tdist; 934 maxt = tdist; 935 936 break; 937 case 1: 938 939 if (entp.y <= position) 940 { 941 if (extp.y <= position) 942 { 943 node = in->mBack; 944 // cases N1,N2,N3,P5,Z2,Z3 945 continue; 946 } 947 else 948 { 949 // case N4 950 node = in->mBack; 951 farChild = in->mFront; 952 } 953 } 954 else 955 { 956 if (position <= extp.y) 957 { 958 node = in->mFront; 959 // cases P1,P2,P3,N5,Z1 960 continue; 961 } 962 else 963 { 964 node = in->mFront; 965 farChild = in->mBack; 966 // case P4 967 } 968 } 969 970 // $$ modification 3.5.2004 - hints from Kamil Ghais 971 // case N4 or P4 972 tdist = (position - origin.y) / dir.y; 973 //tStack.push(RayTraversalData(farChild, extp, maxt)); //TODO 974 extp = origin + dir * tdist; 975 maxt = tdist; 976 977 break; 978 case 2: 979 if (entp.z <= position) 980 { 981 if (extp.z <= position) 982 { 983 node = in->mBack; 984 // cases N1,N2,N3,P5,Z2,Z3 985 continue; 986 } 987 else 988 { 989 // case N4 990 node = in->mBack; 991 farChild = in->mFront; 992 } 993 } 994 else 995 { 996 if (position <= extp.z) 997 { 998 node = in->mFront; 999 // cases P1,P2,P3,N5,Z1 1000 continue; 1001 } 1002 else 1003 { 1004 node = in->mFront; 1005 farChild = in->mBack; 1006 // case P4 1007 } 1008 } 1009 1010 // $$ modification 3.5.2004 - hints from Kamil Ghais 1011 // case N4 or P4 1012 tdist = (position - origin.z) / dir.z; 1013 //tStack.push(RayTraversalData(farChild, extp, maxt)); //TODO 1014 extp = origin + dir * tdist; 1015 maxt = tdist; 1016 1017 break; 1018 1019 } 1020 1021 } 1022 else 1023 { 1024 // compute intersection with all objects in this leaf 1025 KdLeaf *leaf = static_cast<KdLeaf *>(node); 1026 1027 // add view cell to intersections 1028 ViewCell *vc = leaf->mViewCell; 1029 1030 if (!vc->Mailed()) 1031 { 1032 vc->Mail(); 1033 viewcells.push_back(vc); 1034 ++ hits; 1035 } 1036 1037 // get the next node from the stack 1038 if (tStack.empty()) 1039 break; 852 1040 853 1041 entp = extp; -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r2606 r2618 332 332 vector<ViewCell *> &viewcells); 333 333 334 // old version 335 int CastLineSegment2(const Vector3 &origin, 336 const Vector3 &termination, 337 vector<ViewCell *> &viewcells); 334 338 335 339 const KdTreeStatistics &GetStatistics() const { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2617 r2618 2587 2587 ViewCell::NewMail(); 2588 2588 2589 #ifdef USE_PERFTIMER2590 viewCellCastTimer.Entry();2591 #endif2592 2589 static ViewCellContainer viewCells; 2593 2590 static VssRay *lastVssRay = NULL; 2594 2591 2595 2592 // check if last ray was not same ray with reverse direction 2596 if (1)2593 // if (1) 2597 2594 // tmp matt: don't use when origin objects are not accounted for, currently the second ray is lost!! 2598 2595 // $$JB: reenabled again - should use the same viewcells for the next ray ray if 2599 2596 // it goes in the oposite direction 2600 //if (!lastVssRay ||2601 //!(ray.mOrigin == lastVssRay->mTermination) ||2602 //!(ray.mTermination == lastVssRay->mOrigin))2597 if (!lastVssRay || 2598 !(ray.mOrigin == lastVssRay->mTermination) || 2599 !(ray.mTermination == lastVssRay->mOrigin)) 2603 2600 { 2601 #ifdef USE_PERFTIMER 2602 viewCellCastTimer.Entry(); 2603 #endif 2604 2604 viewCells.clear(); 2605 2605 2606 2606 // traverse the view space subdivision 2607 2607 CastLineSegment(origin, termination, viewCells); 2608 2608 lastVssRay = &ray; 2609 }2610 2611 2609 #ifdef USE_PERFTIMER 2612 viewCellCastTimer.Exit();2610 viewCellCastTimer.Exit(); 2613 2611 #endif 2614 2612 } 2613 2615 2614 mSamplesStat.mViewCells += (int)viewCells.size(); 2616 2615
Note: See TracChangeset
for help on using the changeset viewer.