- Timestamp:
- 01/15/07 21:59:52 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
r1966 r1984 74 74 75 75 mMixtureDistribution->GenerateSamples(mSamplesPerPass, rays); 76 77 CastRays(rays, vssRays, true, pruneInvalidRays); 76 77 bool doubleRays = true; 78 CastRays(rays, vssRays, doubleRays, pruneInvalidRays); 78 79 totalVssRays += (int)vssRays.size(); 79 80 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
r1983 r1984 28 28 bool IntelRayCaster::InitRayCast(const string externKdTree) 29 29 { 30 31 30 cout<<"Ray Cast file: " << externKdTree << endl; 31 return mlrtaLoadAS(externKdTree.c_str()); 32 32 } 33 33 … … 51 51 52 52 hittriangle = mlrtaIntersectAS( 53 &simpleRay.mOrigin.x,54 &simpleRay.mDirection.x,55 normal,56 dist);57 53 &simpleRay.mOrigin.x, 54 &simpleRay.mDirection.x, 55 normal, 56 dist); 57 58 58 if (hittriangle != -1 ) { 59 59 Intersectable *intersect = mPreprocessor.GetParentObject(hittriangle); … … 73 73 if (castDoubleRay) 74 74 { 75 Vector3 dir = -simpleRay.mDirection; 75 cerr<<"HERE"<<endl; 76 Vector3 dir = -simpleRay.mDirection; 76 77 hittriangle = mlrtaIntersectAS( 77 78 &simpleRay.mOrigin.x, … … 122 123 #endif 123 124 124 int forward_hit_triangles[16];125 float forward_dist[16];126 127 int backward_hit_triangles[16];128 float backward_dist[16];125 static int forward_hit_triangles[16]; 126 static float forward_dist[16]; 127 128 static int backward_hit_triangles[16]; 129 static float backward_dist[16]; 129 130 130 131 … … 185 186 Debug<<"FH\n"<<flush; 186 187 #endif 188 187 189 Intersectable *intersect = mPreprocessor.GetParentObject(forward_hit_triangles[i]); 188 190 -
GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp
r1972 r1984 49 49 mPreprocessor.SetupRay(ray, simpleRay.mOrigin, simpleRay.mDirection); 50 50 ray.mFlags &= ~Ray::CULL_BACKFACES; 51 52 if (mKdTree->CastRay(ray)) 53 { 54 hitA.mObject = ray.intersections[0].mObject; 55 hitA.mPoint = ray.Extrap(ray.intersections[0].mT); 56 hitA.mNormal = ray.intersections[0].mNormal; 57 // cout << "hita: " << hitA.mPoint << " !obj: " << hitA.mObject << endl; 58 } 59 60 mPreprocessor.SetupRay(ray, simpleRay.mOrigin, -simpleRay.mDirection); 61 ray.mFlags &= ~Ray::CULL_BACKFACES; 62 63 if (castDoubleRay && mKdTree->CastRay(ray)) 64 { 65 hitB.mObject = ray.intersections[0].mObject; 66 hitB.mPoint = ray.Extrap(ray.intersections[0].mT); 67 hitB.mNormal = ray.intersections[0].mNormal; 68 } 51 52 53 if (mKdTree->CastRay(ray)) { 54 hitA.mObject = ray.intersections[0].mObject; 55 hitA.mPoint = ray.Extrap(ray.intersections[0].mT); 56 hitA.mNormal = ray.intersections[0].mNormal; 57 // cout << "hita: " << hitA.mPoint << " !obj: " << hitA.mObject << endl; 58 } 59 60 mPreprocessor.SetupRay(ray, simpleRay.mOrigin, -simpleRay.mDirection); 61 ray.mFlags &= ~Ray::CULL_BACKFACES; 62 63 if (castDoubleRay && mKdTree->CastRay(ray)) { 64 hitB.mObject = ray.intersections[0].mObject; 65 hitB.mPoint = ray.Extrap(ray.intersections[0].mT); 66 hitB.mNormal = ray.intersections[0].mNormal; 67 } 69 68 70 69 return ProcessRay( 71 72 73 74 75 76 77 78 70 simpleRay, 71 hitA, 72 hitB, 73 vssRays, 74 box, 75 castDoubleRay, 76 pruneInvalidRays 77 ); 79 78 } 80 79 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1974 r1984 606 606 ) 607 607 { 608 608 609 int hits = 0; 609 610 … … 614 615 615 616 // ray.ComputeInvertedDir(); 616 617 617 Intersectable::NewMail(); 618 618 -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r1983 r1984 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: po 15. I 15:33:1220073 # Generated by qmake (2.00a) (Qt 4.1.2) on: po 15. I 21:59:19 2007 4 4 # Project: preprocessor.pro 5 5 # Template: app … … 63 63 $(MAKE) -f $(MAKEFILE).Debug uninstall 64 64 65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc 2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc.net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 66 66 C:\Qt\4.1.2\mkspecs\features\qt_config.prf \ 67 67 C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \ -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1978 r1984 404 404 { 405 405 if (index == -1) 406 406 return NULL; 407 407 408 408 if (!mFaceParents.empty()) … … 419 419 } 420 420 else 421 { 422 if (index >= (int)mObjects.size()) 423 { 424 cerr << "Warning: triangle index out of range! " << index << endl; 425 return NULL; 426 } 427 else 428 { 429 return mObjects[index]; 430 } 431 } 421 { 422 if (index >= (int)mObjects.size()) { 423 cerr<<"Warning: triangle index out of range! "<<index<<endl; 424 return NULL; 425 } 426 else 427 { 428 return mObjects[index]; 429 } 430 } 432 431 } 433 432 … … 1156 1155 mRayCaster->SortRays(rays); 1157 1156 cout<<"Rays sorted in "<<TimeDiff(t1, GetTime())<<" s."<<endl; 1157 1158 if (1) { 1159 VssRayContainer tmpRays; 1160 for (int i=0; i < 200; i++) { 1161 tmpRays.push_back(new VssRay(rays[i].mOrigin, 1162 rays[i].mOrigin + 100.0f*rays[i].mDirection, 1163 NULL, 1164 NULL 1165 ) 1166 ); 1167 1168 } 1169 ExportRays("sorted_rays.x3d", tmpRays, 200); 1170 } 1158 1171 #endif 1159 1172 … … 1188 1201 1189 1202 if ((int)rays.size() > 10000 && i % 10000 == 0) 1190 1203 cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 1191 1204 } 1192 1205 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h
r1983 r1984 11 11 class QtGlViewer : public QGLWidget 12 12 { 13 13 14 Q_OBJECT 14 15 -
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
r1974 r1984 123 123 RayCaster::SortRays(SimpleRayContainer &rays) 124 124 { 125 _SortRays(rays, 0, rays.size()-1, 0); 125 AxisAlignedBox3 box = 126 mPreprocessor.mViewCellsManager->GetViewSpaceBox(); 127 128 float b[12]={ 129 box.Min().x, 130 box.Min().y, 131 box.Min().z, 132 -1, 133 -1, 134 -1, 135 box.Max().x, 136 box.Max().y, 137 box.Max().z, 138 1, 139 1, 140 1 141 }; 142 143 _SortRays(rays, 144 0, 145 rays.size()-1, 146 0, 147 b 148 ); 126 149 } 127 150 … … 130 153 const int l, 131 154 const int r, 132 const int axis) 155 const int depth, 156 float box[12]) 133 157 { 134 158 // pick-up a pivot 135 int i=l,j=r; 136 float x = rays[(l+r)/2].GetParam(axis); 159 int axis; 160 161 float maxDiff = -1.0f; 162 // get the largest axis 163 int offset = 0; 164 165 if (depth%5==0) 166 offset = 3; 167 168 for (int i=offset; i < offset+3; i++) { 169 float diff = box[i+6] - box[i]; 170 if (diff > maxDiff) { 171 maxDiff = diff; 172 axis = i; 173 } 174 } 175 176 // cout<<depth<<" "<<axis<<endl; 177 178 int i=l,j=r; 179 float x = (box[axis] + box[axis+6])*0.5f; 180 // float x = rays[(l+r)/2].GetParam(axis); 137 181 do { 138 while(rays[i].GetParam(axis) < x )182 while(rays[i].GetParam(axis) < x && i<=j) 139 183 i++; 140 while(x < rays[j].GetParam(axis) )184 while(x < rays[j].GetParam(axis) && i<=j) 141 185 j--; 142 186 … … 148 192 } while (i<=j); 149 193 150 if (l + 16 < j ) 151 _SortRays(rays, l, j, (axis+1)%6); 152 153 if (i + 16 < r) 154 _SortRays(rays, i, r, (axis+1)%6); 194 if (l + 64 < j ) { 195 // set new max 196 float save = box[axis+6]; 197 box[axis+6] = x; 198 _SortRays(rays, l, j, depth+1, box); 199 box[axis+6] = save; 200 } 201 202 if (i + 64 < r) { 203 // set new min 204 box[axis] = x; 205 _SortRays(rays, i, r, depth+1, box); 206 } 155 207 } 156 208 … … 166 218 const bool pruneInvalidRays) 167 219 { 168 220 int hits = 0; 169 221 170 222 #if DEBUG_RAYCAST -
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
r1974 r1984 68 68 69 69 protected: 70 void 71 _SortRays(SimpleRayContainer &rays,72 const int l,73 const int r,74 const int axis);75 70 void _SortRays(SimpleRayContainer &rays, 71 const int l, 72 const int r, 73 const int depth, 74 float box[12]); 75 76 76 struct Intersection 77 77 {
Note: See TracChangeset
for help on using the changeset viewer.