Changeset 2572 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 12/21/07 18:33:58 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_arena
r2571 r2572 10 10 PREFIX=../work/plots/osp-TEST 11 11 12 #-rss_distributions=mutation+object_direction+spatial \13 14 12 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 15 13 -rss_distributions=mutation+object_direction+spatial \ -
GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna
r2571 r2572 19 19 #PREFIX=../work/plots/atlanta2-rss9 20 20 21 #-rss_distributions=mutation+object_direction+spatial \ 21 22 22 23 23 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 24 -rss_distributions= object_direction\24 -rss_distributions=mutation+object_direction+spatial \ \ 25 25 -view_cells_use_kd_pvs+ -af_use_kd_pvs+ \ 26 26 -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \ -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2571 r2572 325 325 } 326 326 327 void 328 GlRenderer::InitGL() 329 { 330 mSphere = (GLUquadric *)gluNewQuadric(); 331 332 glMatrixMode(GL_PROJECTION); 333 glLoadIdentity(); 334 335 glMatrixMode(GL_MODELVIEW); 336 glLoadIdentity(); 337 338 glFrontFace(GL_CCW); 339 glCullFace(GL_BACK); 340 341 glShadeModel(GL_FLAT); 342 glDepthFunc(GL_LESS ); 343 glEnable(GL_DEPTH_TEST); 344 glEnable(GL_CULL_FACE); 345 346 InitExtensions(); 347 348 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 349 350 glEnable(GL_NORMALIZE); 351 352 glClearColor(0.0f, 0.0f, 1.0f, 1.0f); 353 354 OcclusionQuery::GenQueries(mOcclusionQueries, 10); 355 356 CreateVertexArrays(); 327 void GlRenderer::InitGL() 328 { 329 mSphere = (GLUquadric *)gluNewQuadric(); 330 331 glMatrixMode(GL_PROJECTION); 332 glLoadIdentity(); 333 334 glMatrixMode(GL_MODELVIEW); 335 glLoadIdentity(); 336 337 glFrontFace(GL_CCW); 338 glCullFace(GL_BACK); 339 340 glShadeModel(GL_FLAT); 341 glDepthFunc(GL_LESS ); 342 glEnable(GL_DEPTH_TEST); 343 glEnable(GL_CULL_FACE); 344 345 InitExtensions(); 346 347 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 348 349 glEnable(GL_NORMALIZE); 350 351 glClearColor(0.0f, 0.0f, 1.0f, 1.0f); 352 353 OcclusionQuery::GenQueries(mOcclusionQueries, 10); 354 355 CreateVertexArrays(); 357 356 } 358 357 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
r2187 r2572 13 13 14 14 15 FILE *fileOut = 0; 16 bool saveRays = true; 17 int cntSavedRaysFLUSH = 0; 18 unsigned long int cntSavedRays = 0; 19 const intSavedLIMIT = 1024; 20 void 21 InitSaving() 22 { 23 fileOut = fopen("fileRays.txt", "wb"); 24 if (!fileOut) { 25 cout << "ERROR: file fileRays.txt cannot be opened .. exiting" << endl; 26 exit(3); 27 } 28 } 29 void 30 FinishSaving() 31 { 32 fclose(fileOut); 33 } 34 35 36 15 37 IntelRayCaster::IntelRayCaster(const Preprocessor &preprocessor, 16 38 const string externKdTree): 17 39 RayCaster(preprocessor) 18 40 { 19 if (!InitRayCast(externKdTree)) 20 cout << "warning: intel ray tracer could not be initialized!" << endl; 41 if (!InitRayCast(externKdTree)) 42 cout << "warning: intel ray tracer could not be initialized!" << endl; 43 if (saveRays) 44 InitSaving(); 21 45 } 22 46 … … 24 48 IntelRayCaster::~IntelRayCaster() 25 49 { 50 if (saveRays) 51 FinishSaving(); 26 52 } 27 53 … … 29 55 bool IntelRayCaster::InitRayCast(const string externKdTree) 30 56 { 31 57 cout<<"Intel ray cast file: " << externKdTree << endl; 32 58 33 59 return mlrtaLoadAS(externKdTree.c_str()); 34 60 } 35 61 36 62 37 63 int IntelRayCaster::CastRay( 38 const SimpleRay &simpleRay, 39 VssRayContainer &vssRays, 40 const AxisAlignedBox3 &box, 41 const bool castDoubleRay, 42 const bool pruneInvalidRays 43 ) 44 { 45 //cout << "intel ray" << endl; 46 VssRay *vssRay = NULL; 47 int hits = 0; 48 int hittriangle; 49 Intersection hitA(simpleRay.mOrigin), hitB(simpleRay.mOrigin); 50 51 float dist; 52 double normal[3]; 53 54 hittriangle = mlrtaIntersectAS( 55 &simpleRay.mOrigin.x, 56 &simpleRay.mDirection.x, 57 normal, 58 dist); 59 60 if (hittriangle != -1 ) { 61 Intersectable *intersect = mPreprocessor.GetParentObject(hittriangle); 64 const SimpleRay &simpleRay, 65 VssRayContainer &vssRays, 66 const AxisAlignedBox3 &box, 67 const bool castDoubleRay, 68 const bool pruneInvalidRays 69 ) 70 { 71 //cout << "intel ray" << endl; 72 VssRay *vssRay = NULL; 73 int hits = 0; 74 int hittriangle; 75 Intersection hitA(simpleRay.mOrigin), hitB(simpleRay.mOrigin); 76 77 float dist; 78 float dist1, dist2; 79 double normal[3]; 80 81 hittriangle = mlrtaIntersectAS( 82 &simpleRay.mOrigin.x, 83 &simpleRay.mDirection.x, 84 normal, 85 dist); 86 dist1 = dist; 87 88 if (hittriangle != -1 ) { 89 Intersectable *intersect = mPreprocessor.GetParentObject(hittriangle); 90 91 if (intersect) 92 { 93 hitA.mObject = intersect; 94 hitA.mNormal = Vector3(normal[0], normal[1], normal[2]); 95 // Get the normal of that face 96 // Mesh *mesh = ((MeshInstance *)objectA)->GetMesh(); 97 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal; 98 //-rays[index+i].mDirection; // $$ temporary 99 hitA.mPoint = simpleRay.Extrap(dist); 100 } 101 } 102 103 if (castDoubleRay) 104 { 105 Vector3 dir = -simpleRay.mDirection; 106 hittriangle = mlrtaIntersectAS( 107 &simpleRay.mOrigin.x, 108 &dir.x, 109 normal, 110 dist); 111 dist2 = dist; 112 113 Intersectable *intersect = mPreprocessor.GetParentObject(hittriangle); 62 114 63 if (intersect) 64 { 65 hitA.mObject = intersect; 66 hitA.mNormal = Vector3(normal[0], normal[1], normal[2]); 67 // Get the normal of that face 68 // Mesh *mesh = ((MeshInstance *)objectA)->GetMesh(); 69 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal; 70 //-rays[index+i].mDirection; // $$ temporary 71 hitA.mPoint = simpleRay.Extrap(dist); 72 } 115 if (intersect) 116 { 117 hitB.mObject = intersect; 118 hitB.mNormal = Vector3(normal[0], normal[1], normal[2]); 119 // Get the normal of that face 120 // Mesh *mesh = ((MeshInstance *)objectB)->GetMesh(); 121 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal; 122 //-rays[index+i].mDirection; // $$ temporary 123 hitB.mPoint = simpleRay.Extrap(dist); 124 } 125 } 126 127 if (saveRays) { 128 if (castDoubleRay) 129 { 130 fprintf(fileOut, "D %d %4.7f %4.7f %4.7f %4.7f %4.7f %4.7f %d %4.7f %d %4.7f\n", 131 cntSavedRays, 132 simpleRay.mOrigin.x, 133 simpleRay.mOrigin.y, 134 simpleRay.mOrigin.z, 135 simpleRay.mDirection.x, 136 simpleRay.mDirection.y, 137 simpleRay.mDirection.z, 138 hitA.mObject ? 1 : 0, 139 hitA.mObject ? dist1 : 0, 140 hitB.mObject ? 1 : 0, 141 hitB.mObject ? dist2 : 0 142 ); 73 143 } 74 75 if (castDoubleRay) 76 { 77 Vector3 dir = -simpleRay.mDirection; 78 hittriangle = mlrtaIntersectAS( 79 &simpleRay.mOrigin.x, 80 &dir.x, 81 normal, 82 dist); 83 84 Intersectable *intersect = mPreprocessor.GetParentObject(hittriangle); 85 86 if (intersect) 87 { 88 hitB.mObject = intersect; 89 hitB.mNormal = Vector3(normal[0], normal[1], normal[2]); 90 // Get the normal of that face 91 // Mesh *mesh = ((MeshInstance *)objectB)->GetMesh(); 92 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal; 93 //-rays[index+i].mDirection; // $$ temporary 94 hitB.mPoint = simpleRay.Extrap(dist); 95 } 96 } 97 98 return ProcessRay( 99 simpleRay, 100 hitA, 101 hitB, 102 vssRays, 103 box, 104 castDoubleRay, 105 pruneInvalidRays 106 ); 107 } 108 144 else 145 fprintf(fileOut, "S %d %4.7f %4.7f %4.7f %4.7f %4.7f %4.7f %d %4.7f\n", 146 cntSavedRays, 147 simpleRay.mOrigin.x, 148 simpleRay.mOrigin.y, 149 simpleRay.mOrigin.z, 150 simpleRay.mDirection.x, 151 simpleRay.mDirection.y, 152 simpleRay.mDirection.z, 153 hitA.mObject ? 1 : 0, 154 hitA.mObject ? dist1 : 0 155 ); 156 cntSavedRays++; 157 cntSavedRaysFLUSH++; 158 if (cntSavedRaysFLUSH > intSavedLIMIT) { 159 fflush(fileOut); 160 cntSavedRaysFLUSH = 0; 161 } 162 } 163 164 return ProcessRay( 165 simpleRay, 166 hitA, 167 hitB, 168 vssRays, 169 box, 170 castDoubleRay, 171 pruneInvalidRays 172 ); 173 } 174 109 175 110 176 void IntelRayCaster::CastRays16( 111 112 113 114 115 116 { 117 118 } 119 177 SimpleRayContainer &rays, 178 VssRayContainer &vssRays, 179 const AxisAlignedBox3 &sbox, 180 const bool castDoubleRay, 181 const bool pruneInvalidRays) 182 { 183 CastRays16(rays, 0, vssRays, sbox, castDoubleRay, pruneInvalidRays); 184 } 185 120 186 void IntelRayCaster::CastRays16( 121 122 123 124 125 126 127 { 187 SimpleRayContainer &rays, 188 const int offset, 189 VssRayContainer &vssRays, 190 const AxisAlignedBox3 &sbox, 191 const bool castDoubleRay, 192 const bool pruneInvalidRays) 193 { 128 194 int i, k; 129 195 const int num = 16; … … 147 213 for (k=offset, i=0; i < num; i++, k++) { 148 214 #if DEBUG_RAYCAST 149 150 151 152 #endif 153 154 155 215 if (counter == 43964) { 216 Debug<<rays[k].mOrigin<<" "<<rays[k].mDirection<<endl; 217 } 218 #endif 219 mlrtaStoreRayAS16(&rays[k].mOrigin.x, 220 &rays[k].mDirection.x, 221 i); 156 222 } 157 223 … … 161 227 162 228 mlrtaTraverseGroupAS16(&min.x, 163 164 165 229 &max.x, 230 forward_hit_triangles, 231 forward_dist); 166 232 167 233 #if DEBUG_RAYCAST … … 170 236 171 237 if (castDoubleRay) { 172 for (k=offset, i=0; i < num; i++, k++) { 173 Vector3 dir = -rays[k].mDirection; 174 mlrtaStoreRayAS16(&rays[k].mOrigin.x, 175 &dir.x, 176 i); 177 } 238 for (k=offset, i=0; i < num; i++, k++) { 239 Vector3 dir = -rays[k].mDirection; 240 mlrtaStoreRayAS16(&rays[k].mOrigin.x, 241 &dir.x, 242 i); 243 } 244 245 #if DEBUG_RAYCAST 246 Debug<<"TB\n"<<flush; 247 #endif 248 249 mlrtaTraverseGroupAS16(&min.x, 250 &max.x, 251 backward_hit_triangles, 252 backward_dist); 253 } 178 254 179 255 #if DEBUG_RAYCAST 180 Debug<<"TB\n"<<flush; 181 #endif 182 183 mlrtaTraverseGroupAS16(&min.x, 184 &max.x, 185 backward_hit_triangles, 186 backward_dist); 187 } 256 Debug<<"BBB\n"<<flush; 257 #endif 258 259 if (saveRays) { 260 if (castDoubleRay) 261 fprintf(fileOut, "G\n"); 262 else 263 fprintf(fileOut, "H\n"); 264 } 265 266 for (i=0, k=offset; i < num; i++, k++) 267 { 268 Intersection hitA(rays[k].mOrigin), hitB(rays[k].mOrigin); 269 270 #if DEBUG_RAYCAST 271 Debug<<"FH\n"<<flush; 272 #endif 273 274 Intersectable *intersect = 275 mPreprocessor.GetParentObject(forward_hit_triangles[i]); 276 277 if (intersect) 278 { 279 hitA.mObject = intersect; 280 // Get the normal of that face 281 hitA.mNormal = mPreprocessor.GetParentNormal(forward_hit_triangles[i]); 282 283 //-rays[index+i].mDirection; // $$ temporary 284 hitA.mPoint = rays[k].Extrap(forward_dist[i]); 285 } 286 287 #if DEBUG_RAYCAST 288 Debug<<"BH\n"<<flush; 289 #endif 290 291 if (castDoubleRay) 292 { 293 Intersectable *intersect = 294 mPreprocessor.GetParentObject(backward_hit_triangles[i]); 295 296 if (intersect) 297 { 298 hitB.mObject = intersect; 299 hitB.mNormal = mPreprocessor.GetParentNormal(backward_hit_triangles[i]); 188 300 189 #if DEBUG_RAYCAST 190 Debug<<"BBB\n"<<flush; 191 #endif 192 193 for (i=0, k=offset; i < num; i++, k++) 194 { 195 Intersection hitA(rays[k].mOrigin), hitB(rays[k].mOrigin); 196 197 #if DEBUG_RAYCAST 198 Debug<<"FH\n"<<flush; 199 #endif 200 201 Intersectable *intersect = mPreprocessor.GetParentObject(forward_hit_triangles[i]); 202 203 if (intersect) 204 { 205 hitA.mObject = intersect; 206 // Get the normal of that face 207 hitA.mNormal = mPreprocessor.GetParentNormal(forward_hit_triangles[i]); 208 209 //-rays[index+i].mDirection; // $$ temporary 210 hitA.mPoint = rays[k].Extrap(forward_dist[i]); 211 } 212 213 #if DEBUG_RAYCAST 214 Debug<<"BH\n"<<flush; 215 #endif 216 217 if (castDoubleRay) 218 { 219 Intersectable *intersect = mPreprocessor.GetParentObject(backward_hit_triangles[i]); 220 221 if (intersect) 222 { 223 hitB.mObject = intersect; 224 hitB.mNormal = mPreprocessor.GetParentNormal(backward_hit_triangles[i]); 225 226 // normalB = rays[i].mDirection; // $$ temporary 227 hitB.mPoint = rays[k].Extrap(-backward_dist[i]); 228 } 229 } 230 231 #if DEBUG_RAYCAST 232 Debug<<"PR\n"<<flush; 301 // normalB = rays[i].mDirection; // $$ temporary 302 hitB.mPoint = rays[k].Extrap(-backward_dist[i]); 303 } 304 } 305 306 307 if (saveRays) { 308 if (castDoubleRay) 309 fprintf(fileOut, "%d %4.7f %4.7f %4.7f %4.7f %4.7f %4.7f %d %4.7f %d %4.7f\n", 310 cntSavedRays, 311 rays[k].mOrigin.x, 312 rays[k].mOrigin.y, 313 rays[k].mOrigin.z, 314 rays[k].mDirection.x, 315 rays[k].mDirection.y, 316 rays[k].mDirection.z, 317 hitA.mObject ? 1 : 0, 318 hitA.mObject ? forward_dist[i] : 0, 319 hitB.mObject ? 1 : 0, 320 hitB.mObject ? -backward_dist[i] : 0 321 ); 322 else 323 fprintf(fileOut, "%d %4.7f %4.7f %4.7f %4.7f %4.7f %4.7f %d %4.7f\n", 324 cntSavedRays, 325 rays[k].mOrigin.x, 326 rays[k].mOrigin.y, 327 rays[k].mOrigin.z, 328 rays[k].mDirection.x, 329 rays[k].mDirection.y, 330 rays[k].mDirection.z, 331 hitA.mObject ? 1 : 0, 332 hitA.mObject ? forward_dist[i] : 0 333 ); 334 cntSavedRays++; 335 cntSavedRaysFLUSH++; 336 } 337 338 339 #if DEBUG_RAYCAST 340 Debug<<"PR\n"<<flush; 233 341 #endif 234 342 235 343 #if 1 236 ProcessRay(rays[k], 237 hitA, 238 hitB, 239 vssRays, 240 sbox, 241 castDoubleRay, 242 pruneInvalidRays 243 ); 244 #endif 245 } 246 247 #if DEBUG_RAYCAST 248 Debug<<"C16F\n"<<flush; 344 ProcessRay(rays[k], 345 hitA, 346 hitB, 347 vssRays, 348 sbox, 349 castDoubleRay, 350 pruneInvalidRays 351 ); 352 #endif 353 } // for 354 355 if (saveRays) { 356 if (cntSavedRaysFLUSH > intSavedLIMIT) { 357 fflush(fileOut); 358 cntSavedRaysFLUSH = 0; 359 } 360 } 361 362 #if DEBUG_RAYCAST 363 Debug<<"C16F\n"<<flush; 249 364 #endif 250 365 } … … 256 371 void 257 372 IntelRayCaster::CastSimpleForwardRays( 258 259 260 373 SimpleRayContainer &rays, 374 const AxisAlignedBox3 &sbox 375 ) 261 376 { 262 377 int hit_triangles[16]; … … 272 387 273 388 for (i=0; i < packets; i++) { 274 for (j=0; j < 16; j++, k++) 275 mlrtaStoreRayAS16(&rays[k].mOrigin.x, 276 &rays[k].mDirection.x, 277 j); 278 279 mlrtaTraverseGroupAS16(&min.x, 280 &max.x, 281 hit_triangles, 282 dist); 283 284 } 389 for (j=0; j < 16; j++, k++) 390 mlrtaStoreRayAS16(&rays[k].mOrigin.x, 391 &rays[k].mDirection.x, 392 j); 393 394 mlrtaTraverseGroupAS16(&min.x, 395 &max.x, 396 hit_triangles, 397 dist); 398 } // for 285 399 286 400 … … 288 402 double normal[3]; 289 403 hit_triangles[0] = mlrtaIntersectAS( 290 291 292 293 404 &rays[k].mOrigin.x, 405 &rays[k].mDirection.x, 406 normal, 407 dist[0]); 294 408 } 295 409 … … 299 413 void 300 414 IntelRayCaster::CastRays( 301 302 303 304 305 415 SimpleRayContainer &rays, 416 VssRayContainer &vssRays, 417 const AxisAlignedBox3 &sbox, 418 const bool castDoubleRay, 419 const bool pruneInvalidRays ) 306 420 { 307 421 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2559 r2572 200 200 inStream.read(reinterpret_cast<char *>(&numTriangles), sizeof(int)); 201 201 root->mGeometry.reserve(numTriangles); 202 cout << "loading " << numTriangles << " triangles (" 203 << numTriangles * (sizeof(TriangleIntersectable) + sizeof(TriangleIntersectable *)) / (1024 * 1024) << " MB)" << endl; 202 cout << "loading " << numTriangles << " triangles (" << numTriangles * 203 (sizeof(TriangleIntersectable) + sizeof(TriangleIntersectable *)) / 204 (1024 * 1024) << " MB)" << endl; 204 205 205 206 int i = 0; 207 206 208 while (1) 207 209 { -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2571 r2572 720 720 721 721 RenderInfo(); 722 723 722 mFrame ++; 724 725 723 } 726 724 -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
r2176 r2572 69 69 Mesh *currentMesh = MeshManager::GetSingleton()->CreateResource(); 70 70 71 while(fscanf(file, "%s",str)!=EOF)71 while(fscanf(file, "%s", str)!=EOF) 72 72 { 73 73 switch (str[0]) … … 118 118 vertices.push_back((*c).second); 119 119 120 fscanf(file, "%s",str); // get the vertex label120 fscanf(file, "%s", str); // get the vertex label 121 121 122 122 while(str[0]!=')')
Note: See TracChangeset
for help on using the changeset viewer.