Changeset 2602 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 01/16/08 21:30:29 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp
r2599 r2602 92 92 // We give a box to which each ray is clipped to before the 93 93 // ray shooting is computed ! 94 void HavranRayCaster::CastRaysPacket4(const Vector3 & boxmax,95 const Vector3 &boxmin,96 97 98 99 100 { 101 #if defined(_USE_HAVRAN_SSE)102 #ifdef USE_HAVRAN_RAYCASTER94 void HavranRayCaster::CastRaysPacket4(const Vector3 &minBox, 95 const Vector3 &maxBox, 96 const Vector3 origin4[], 97 const Vector3 direction4[], 98 int result4[], 99 float dist4[]) 100 { 101 #ifdef USE_HAVRAN_RAYCASTER 102 #ifdef _USE_HAVRAN_SSE 103 103 for (int i = 0; i < 4; i++) { 104 104 result4[i] = -1; 105 // raypack.SetObject(i, NULL);106 105 raypack.SetLoc(i, origin4[i]); 107 106 raypack.SetDir(i, direction4[i]); … … 111 110 // a particular ASDS, otherwise it is emulated by decomposition 112 111 // of a packet to individual rays and traced individually. 113 mKtbtree->FindNearestI(raypack, (Vector3&)boxmin, (Vector3&)boxmax); 114 // mKtbtree->FindNearestI(raypack, bmin, bmax); 112 mKtbtree->FindNearestI(raypack, minBox, maxBox); 115 113 116 114 for (int i = 0; i < 4; i++) { … … 120 118 if ( (intersectable = raypack.GetObject(i)) ) { 121 119 // $$JB this is very hacky - > should be replaced with fetching the index of the triangle 120 // $$VH - this is object ID - is this the triangle index ??? 122 121 result4[i] = intersectable->mId; 123 122 dist4[i] = raypack.GetT(i); … … 126 125 127 126 return; 128 #endif // USE_HAVRAN_RAYCASTER129 127 #else // _USE_HAVRAN_SSE 130 128 // Compute the result ray by ray … … 133 131 sray.mOrigin = origin4[i]; 134 132 sray.mDirection = direction4[i]; 135 mKtbtree->FindNearestI(sray, (Vector3&)boxmin, (Vector3&)boxmax);133 mKtbtree->FindNearestI(sray, minBox, maxBox); 136 134 if (SimpleRay::IntersectionRes[0].intersectable) { 137 135 // This is object ID - is this the triangle index ??? … … 145 143 146 144 #endif // _USE_HAVRAN_SSE 145 #endif // USE_HAVRAN_RAYCASTER 147 146 } 148 147 -
GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.h
r2599 r2602 76 76 // ray shooting is computed ! 77 77 virtual void CastRaysPacket4(const Vector3 &minBox, 78 79 80 81 82 78 const Vector3 &maxBox, 79 const Vector3 origin4[], 80 const Vector3 direction4[], 81 int result4[], 82 float dist4[]); 83 83 84 84 #ifdef _USE_HAVRAN_SSE -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r2599 r2602 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: út 15. I 21:38:1520083 # Generated by qmake (2.00a) (Qt 4.1.2) on: st 16. I 21:20:04 2008 4 4 # Project: preprocessor.pro 5 5 # Template: app -
GTP/trunk/Lib/Vis/Preprocessing/src/default.env
r2599 r2602 53 53 useGlDebugger false 54 54 # 0 = INTERNAL 1 = MLRT 2 = HAVRAN 55 rayCastMethod 155 rayCastMethod 2 56 56 57 57 # type sampling -
GTP/trunk/Lib/Vis/Preprocessing/src/havran/configh.h
r2592 r2602 59 59 60 60 #ifdef _MSC_VER 61 #define __SSE__62 61 // disable some Microsoft Visual Compiler warnings if necessary 63 62 #pragma warning( disable:4305 ) -
GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktball.cpp
r2592 r2602 402 402 403 403 int 404 CKTB::FindNearestI(const SimpleRay &ray, Vector3 &boxmin,Vector3 &boxmax)404 CKTB::FindNearestI(const SimpleRay &ray, const Vector3 &boxmin, const Vector3 &boxmax) 405 405 { 406 406 const AxisAlignedBox3 localbox(boxmin, boxmax); -
GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktball.h
r2592 r2602 174 174 175 175 int FindNearestI(const SimpleRay &ray); 176 int FindNearestI(const SimpleRay &ray, Vector3 &boxmin, Vector3 &boxmax);176 int FindNearestI(const SimpleRay &ray, const Vector3 &boxMin, const Vector3 &boxMax); 177 177 void SetOffset(int offset) { traversalClass->SetOffset(offset); } 178 178 int FindNearestI_16oneDir(SimpleRayContainer &rays, int offset, int copyOffset) { … … 192 192 // of a packet to individual rays and traced individually. 193 193 void FindNearestI(RayPacket2x2 &raypack); 194 void FindNearestI(RayPacket2x2 &raypack, Vector3 &boxmin, Vector3 &boxmax);194 void FindNearestI(RayPacket2x2 &raypack, const Vector3 &boxMin, const Vector3 &boxMax); 195 195 #endif 196 196 #else 197 197 void FindNearestI(RayPacket2x2 &raypack) { } 198 void FindNearestI(RayPacket2x2 &raypack, Vector3 &boxmin, Vector3 &boxmax) { }198 void FindNearestI(RayPacket2x2 &raypack, const Vector3 &boxMin, const Vector3 &boxMax) { } 199 199 #endif // __SSE__ 200 200 -
GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktbconf.h
r2592 r2602 24 24 25 25 // If we support the use of SSE instructions for ray shooting 26 #define _USE_HAVRAN_SSE26 //#define _USE_HAVRAN_SSE 27 27 28 28 namespace GtpVisibilityPreprocessor { … … 35 35 #define GPREFETCH(A, B) 36 36 #endif 37 37 38 38 #if defined(__INTEL_COMPILER)||defined(_MSC_VER) 39 39 // Intel compiler or Microsoft Compiler -
GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktbftrav.cpp
r2592 r2602 222 222 // to be contained in the scene box!!! 223 223 int 224 CKTBTraversal::FindNearestI(const SimpleRay & ray, const AxisAlignedBox3 &localbox)224 CKTBTraversal::FindNearestI(const SimpleRay &oray, const AxisAlignedBox3 &localbox) 225 225 { 226 226 #if 0 … … 238 238 float tmin, tmax; 239 239 SimpleRay::IntersectionRes[0].intersectable = 0; 240 SimpleRay ray(oray.mOrigin, oray.mDirection, 0, 0.f, 0); 240 241 241 242 // test if the whole CKTB tree is missed by the input ray … … 246 247 return 0; // no object can be intersected 247 248 } 249 float tminOffset = 0.f; 248 250 249 251 //#define _DEBUGKTB … … 267 269 if (tmin < 0.f) 268 270 tmin = 0.f; 271 else { 272 // Here the origin of the ray is always zero - it starts 273 // at the box face!! 274 tminOffset = tmin; 275 tmin = 0.f; 276 tmax -= tminOffset; 277 ray.mOrigin += ray.mDirection * tminOffset; 278 } 269 279 270 280 int index = 1; … … 368 378 _emptyLeavesTraversed += emptyLeavesTraversed; 369 379 #endif // __TRAVERSAL_STATISTICS 380 381 // We have to add the distance from the original ray origin 382 SimpleRay::IntersectionRes[0].tdist += tminOffset; 370 383 371 384 // signed distance should be already set in TestFullLeaf -
GTP/trunk/Lib/Vis/Preprocessing/src/havran/ktbtrav.h
r2592 r2602 150 150 // of a packet to individual rays and traced individually. 151 151 virtual void FindNearestI(RayPacket2x2 &raypack) { } 152 virtual void FindNearestI(RayPacket2x2 &raypack, Vector3 &boxmin, Vector3 &boxmax) { }152 virtual void FindNearestI(RayPacket2x2 &raypack, const Vector3 &boxMin, const Vector3 &boxMax) { } 153 153 #endif 154 154 … … 328 328 // of a packet to individual rays and traced individually. 329 329 virtual void FindNearestI(RayPacket2x2 &raypack); 330 virtual void FindNearestI(RayPacket2x2 &raypack, Vector3 &boxmin, Vector3 &boxmax);330 virtual void FindNearestI(RayPacket2x2 &raypack, const Vector3 &boxMin, const Vector3 &boxMax); 331 331 #endif // __SSE__ 332 332 #endif // _USE_HAVRAN_SSE … … 421 421 // of a packet to individual rays and traced individually. 422 422 virtual void FindNearestI(RayPacket2x2 &raypack); 423 virtual void FindNearestI(RayPacket2x2 &raypack, Vector3 &boxmin, Vector3 &boxmax);423 virtual void FindNearestI(RayPacket2x2 &raypack, const Vector3 &boxMin, const Vector3 &boxMax); 424 424 #endif // __SSE__ 425 425 #endif // _USE_HAVRAN_SSE -
GTP/trunk/Lib/Vis/Preprocessing/src/havran/testrt.cpp
r2595 r2602 37 37 #else 38 38 #if USE_THREADS 39 39 #include "BoostPreprocessorThread.h" 40 40 #endif 41 41 #endif … … 489 489 int cntIntelOurDistMismatch = 0; 490 490 bool printOut = false; 491 double sumDistIntel = 0. ;492 double cca sumDistOurAlg = 0.;491 double sumDistIntel = 0.f; 492 double sumDistOurAlg = 0.f; 493 493 double sumDistAbsDiff = 0.f; 494 494 #endif … … 536 536 float T = rays[i].IntersectionRes[0].tdist; 537 537 if ( (res != results[i].hitA) || 538 ((res)&&(results[i].hitA)&& (fabs(T - results[i].hitAT)) > 2.0f)538 ((res)&&(results[i].hitA)&& (fabs(T - results[i].hitAT)) > 0.1f) 539 539 ) 540 540 { … … 547 547 } 548 548 else { 549 if ((res = 0) && (results[i].hitA)) {549 if ((res == 0) && (results[i].hitA)) { 550 550 cntIntelYesWeNo++; 551 551 if (printOut) … … 578 578 << " userTime = " << timer.UserTime() << " realTime = " 579 579 << timer.RealTime() << endl; 580 ;581 580 cout << "Rays shot per milisecond [userTimer] = " 582 581 << ((double)cntRays * mult/(double)timer.UserTime()) / 1000.f << endl; … … 750 749 AxisAlignedBox3 bboxOrig = preprocessor->mSceneGraph->GetBox(); 751 750 751 #undef DEBUGRESULTS 752 752 //#define DEBUGRESULTS 753 753 … … 758 758 bool printOut = false; 759 759 double sumDistIntel = 0.; 760 double ccasumDistOurAlg = 0.;760 double sumDistOurAlg = 0.; 761 761 double sumDistAbsDiff = 0.f; 762 762 #endif … … 856 856 return; 857 857 } 858 859 // This is for testing RT implementation 860 void 861 TestRT_4_fromFile(int argc, char **argv) 862 { 863 int returnCode = 0; 864 865 InitTiming(); 866 Debug.open("debug.log"); 867 868 Environment::GetSingleton()->Parse(argc, argv, USE_EXE_PATH); 869 MeshKdTree::ParseEnvironment(); 870 871 char buff[128]; 872 Environment::GetSingleton()->GetStringValue("Preprocessor.type", buff); 873 string preprocessorType(buff); 874 875 if (!(preprocessor = PreprocessorFactory::CreatePreprocessor(preprocessorType))) 876 { 877 Environment::DelSingleton(); 878 cerr << "Unknown preprocessor type" << endl; 879 exit(1); 880 } 881 882 883 Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 884 string filename(buff); 885 886 const string externKdTree = ReplaceSuffix(filename, ".obj", ".kdf"); 887 const string internKdTree = GetInternFilename(filename, preprocessor->mLoadMeshes ? 888 ".kdm" : ".kdt"); 889 890 if (preprocessor->InitRayCast(externKdTree, internKdTree)) 891 { 892 cout << "ray casting initialized!" << endl; 893 } 894 else 895 { 896 cout << "ray casting initialization failed!" << endl; 897 Cleanup(); 898 exit(1); 899 } 900 901 //Debug << "using pvs type " << PVS_TYPE << endl; 902 903 ///////////// 904 //-- load scene 905 906 if (!preprocessor->LoadScene(filename)) 907 { 908 cout << "loading file " << filename << " failed" << endl; 909 Cleanup(); 910 exit(1); 911 } 912 913 //////////// 914 //-- initialize external ray caster 915 916 if (preprocessor->LoadInternKdTree(internKdTree)) 917 { 918 cout << "intern kd tree loaded!" << endl; 919 } 920 else 921 { 922 cout << "loading intern kd tree failed!" << endl; 923 Cleanup(); 924 exit(1); 925 } 926 927 // export objects as obj 928 if (preprocessor->mExportObj) 929 { 930 if (strstr(filename.c_str(), ".obj")) 931 { 932 cerr << "already in obj format" << endl; 933 if (0) preprocessor->ExportObj("test.obj", preprocessor->mObjects); 934 } 935 else 936 { 937 const string objname = GetInternFilename(filename, ".obj"); 938 939 cout << "exporting scene to " << objname << endl; 940 bool success = preprocessor->ExportObj(objname, preprocessor->mObjects); 941 942 if (success) 943 cout << "finished exporting obj" << endl; 944 else 945 cerr << "error exporting " << objname << endl; 946 } 947 } 948 949 Environment::GetSingleton()->GetStringValue("Rays.file", buff); 950 FILE *fp = fopen(buff, "rb"); 951 if (!fp) { 952 cerr << "ERROR: file " << buff << " cannot be opened for reading" << endl; 953 cerr << "EXITING" << endl; 954 exit(3); 955 } 956 cout << "File " << buff << " was opened successfully" << endl; 957 int cntMaxRays = 100000; 958 Environment::GetSingleton()->GetIntValue("Rays.cnt", cntMaxRays); 959 vector<SimpleRay> rays; 960 SimpleRay rayTest; 961 vector<RESult> results; 962 vector<AxisAlignedBox3> boxes; 963 964 int cntRays = 0; 965 for (int i = 0; cntRays < cntMaxRays;) { 966 int ch = fgetc(fp); 967 switch (ch) { 968 case 'I': { // two-sided rays of 16 969 Vector3 minv, maxv; 970 if (fscanf(fp, "%f %f %f %f %f %f\n", 971 &minv.x, &minv.y, &minv.z, 972 &maxv.x, &maxv.y, &maxv.z) != 6) { 973 cerr << "Problem parsing the ray file" << endl; 974 cerr << "EXITING for ray order" << i << endl; 975 goto FINISH; 976 } 977 boxes.push_back(AxisAlignedBox3(minv, maxv)); 978 979 for (int j = 0; j < 4; j++) { 980 int order; 981 float ox, oy, oz, dx, dy, dz; 982 int hitA; float hitAT; 983 int hitB; float hitBT; 984 if (fscanf(fp, "%d %f %f %f %f %f %f %d %f\n", 985 &order, &ox, &oy, &oz, &dx, &dy, &dz, 986 &hitA, &hitAT) != 9) { 987 cerr << "Problem parsing the ray file" << endl; 988 cerr << "EXITING for ray order" << order << endl; 989 goto FINISH; 990 } 991 Vector3 mPosition(ox, oy, oz); 992 Vector3 mDirection(dx, dy, dz); 993 rayTest.Set(mPosition, mDirection, 0, 1.0, true); 994 rays.push_back(rayTest); 995 results.push_back(RESult(hitA, hitAT, 0, -1.f)); 996 cntRays++; 997 i++; 998 } 999 break; 1000 } 1001 default: { 1002 cerr << "Not yet implemented or end of file" << endl; 1003 goto FINISH; 1004 } 1005 } // switch 1006 } // for i 1007 1008 FINISH: 1009 1010 fclose(fp); 1011 cout << "Starting to shoot " << cntRays << " rays" << endl; 1012 1013 RayCaster *raycaster = preprocessor->mRayCaster; 1014 VssRayContainer vssRays; 1015 AxisAlignedBox3 bboxOrig = preprocessor->mSceneGraph->GetBox(); 1016 1017 //#define DEBUGRESULTS 1018 1019 #ifdef DEBUGRESULTS 1020 int cntIntelYesWeNo = 0; 1021 int cntIntelNoWeYes = 0; 1022 int cntIntelOurDistMismatch = 0; 1023 bool printOut = false; 1024 double sumDistIntel = 0.f; 1025 double sumDistOurAlg = 0.f; 1026 double sumDistAbsDiff = 0.f; 1027 #endif 1028 1029 //cout << "Press a key to start ray shooting" << endl; 1030 //getchar(); 1031 cout << "Ray shooting " << cntRays << " rays started - " 1032 << (castDoubleRays ? " double " : " single ") 1033 << " dir " << endl; 1034 1035 long t1 = GetTime(); 1036 CTimer timer; 1037 timer.Reset(); 1038 timer.Start(); 1039 Vector3 boxMin, boxMax; 1040 1041 SimpleRayContainer raysToTest; 1042 int boxI = 0; 1043 for (int i = 0; i < cntRays - 4; i+= 4, boxI++) { 1044 Vector3 origin4[4]; 1045 Vector3 direction4[4]; 1046 int result4[4]; 1047 float dist4[4]; 1048 boxMin = boxes[boxI].Min(); 1049 boxMax = boxes[boxI].Max(); 1050 for (int j = 0; j < 4; j++) { 1051 int o = i+j; 1052 origin4[j] = rays[o].mOrigin; 1053 direction4[j] = rays[o].mDirection; 1054 } 1055 raycaster->CastRaysPacket4(boxMin, boxMax, 1056 origin4, direction4, 1057 result4, dist4); 1058 printf("I %4.7f %4.7f %4.7f %4.7f %4.7f %4.7f\n", 1059 boxMin.x, boxMin.y, boxMin.z, boxMax.x, boxMax.y, boxMax.z); 1060 1061 for (int j = 0; j < 4; j++) { 1062 printf("%d %4.7f %4.7f %4.7f %4.7f %4.7f %4.7f %d %4.7f\n", 1063 i+j, 1064 origin4[j].x, 1065 origin4[j].y, 1066 origin4[j].z, 1067 direction4[j].x, 1068 direction4[j].y, 1069 direction4[j].z, 1070 (result4[j] != -1) ? 1 : 0, 1071 (result4[j] != -1) ? dist4[j] : 0); 1072 } // for j 1073 } // for i 1074 1075 timer.Stop(); 1076 long t2 = GetTime(); 1077 cout<<"\n#RAY_CAST_TIME = "; 1078 cout << TimeDiff(t1, t2)<<" [mikrosec]" 1079 << " userTime = " << timer.UserTime() << " realTime = " 1080 << timer.RealTime() << endl; 1081 cout << "Rays shot per milisecond [userTimer] = " 1082 << ((double)cntRays/(double)timer.UserTime()) / 1000.f << endl; 1083 1084 #ifdef DEBUGRESULTS 1085 cout << "cntIntelYesWeNo = " << cntIntelYesWeNo << endl; 1086 cout << "cntIntelNoWeYes = " << cntIntelNoWeYes << endl; 1087 cout << "cntIntelOurDistMismatch = " << cntIntelOurDistMismatch++ << endl; 1088 cout << " sumDistIntel = " << sumDistIntel/(double)cntIntelOurDistMismatch << endl; 1089 cout << " sumDistOur = " << sumDistOurAlg/(double)cntIntelOurDistMismatch << endl; 1090 cout << " sumAbsDiffDist = " << sumDistAbsDiff/(double)cntIntelOurDistMismatch 1091 << endl; 1092 #endif 1093 cout << "Done\n" << endl; 1094 return; 1095 } -
GTP/trunk/Lib/Vis/Preprocessing/src/havran/testrt.h
r2595 r2602 13 13 TestRTfromFilePackets(int argc, char **argv); 14 14 15 void 16 TestRT_4_fromFile(int argc, char **argv); 17 15 18 #endif // _TESTRT_H_ 16 19 -
GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro
r2592 r2602 121 121 Intersectable.cpp TraversalTree.cpp ObjectPvs.cpp ObjectsParser.cpp \ 122 122 FilterBasedDistribution.cpp DifferenceSampling.cpp HavranRayCaster.cpp \ 123 OcclusionQuery.cpp 123 OcclusionQuery.cpp RandomViewCellsHandler.cpp 124 124 125 125
Note: See TracChangeset
for help on using the changeset viewer.