Changeset 1478 for trunk/packages/vizservers/nanovis/nanovis.cpp
- Timestamp:
- May 30, 2009, 8:07:17 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/nanovis.cpp
r1475 r1478 17 17 18 18 #include <assert.h> 19 #include <errno.h> 19 20 #include <fcntl.h> 20 21 #include <fstream> … … 106 107 int NanoVis::updir = Y_POS; 107 108 NvCamera* NanoVis::cam = NULL; 108 NanoVis::VolumeMap NanoVis::volumeMap; 109 int NanoVis::_last_data_id = 0; 109 vector<Volume *> NanoVis::volumes; 110 110 vector<HeightMap*> NanoVis::heightMap; 111 VolumeRenderer* NanoVis::vol_renderer = 0;112 PointSetRenderer* NanoVis::pointset_renderer = 0;111 VolumeRenderer* NanoVis::vol_renderer = NULL; 112 PointSetRenderer* NanoVis::pointset_renderer = NULL; 113 113 vector<PointSet*> NanoVis::pointSet; 114 PlaneRenderer* NanoVis::plane_render = 0;114 PlaneRenderer* NanoVis::plane_render = NULL; 115 115 Texture2D* NanoVis::plane[10]; 116 116 NvColorTableRenderer* NanoVis::color_table_renderer = NULL; … … 426 426 if (path == NULL) { 427 427 fprintf(stderr, "can't find program \"%s\"\n", fileName); 428 assert(path != NULL);429 } 430 printf("cg program compiling: %s\n", path);428 Trace("can't find program \"%s\"\n", fileName); 429 } 430 Trace("cg program compiling: %s\n", path); 431 431 fflush(stdout); 432 432 CGprogram program; … … 434 434 entryPoint, NULL); 435 435 cgGLLoadProgram(program); 436 437 436 CGerror LastError = cgGetError(); 438 if (LastError) 439 {440 printf("Error message: %s\n", cgGetLastListing(context));441 442 437 if (LastError) { 438 printf("Error message: %s\n", cgGetLastListing(context)); 439 Trace("Error message: %s\n", cgGetLastListing(context)); 440 } 441 Trace("successfully compiled program: %s\n", path); 443 442 delete [] path; 444 445 443 return program; 446 444 } … … 514 512 */ 515 513 Volume * 516 NanoVis::load_volume(int volDataID, int width, int height, int depth,514 NanoVis::load_volume(int dataID, int width, int height, int depth, 517 515 int n_component, float* data, double vmin, 518 516 double vmax, double nzero_min) 519 517 { 520 NanoVis::VolumeMap::iterator iter = volumeMap.find(volDataID); 521 if (iter != volumeMap.end()) 522 { 523 Volume* vol = iter->second; 524 if (vol != NULL) 525 { 526 iter->second = NULL; 527 528 if (vol->pointsetIndex != -1) 529 { 530 // TBD 531 /* 532 if (((unsigned int) vol->pointsetIndex) < pointSet.size() && 533 pointSet[vol->pointsetIndex] != NULL) { 534 delete pointSet[vol->pointsetIndex]; 535 pointSet[vol->pointsetIndex] = 0; 536 } 537 */ 538 } 539 } 540 vol->unref(); 541 } 542 543 Volume* newVol = new Volume(0.f, 0.f, 0.f, width, height, depth, 1., 544 n_component, data, vmin, vmax, nzero_min); 545 newVol->setDataID(volDataID); 546 volumeMap[volDataID] = newVol; 547 548 549 fprintf(stderr, "VOLID=%d, # of volumes=%d\n", volDataID, volumeMap.size()); 550 return newVol; 518 // Check if we're attempting to load the volume into an already 519 // occupied slot. 520 521 522 Volume* volPtr = new Volume(0.f, 0.f, 0.f, width, height, depth, 1., 523 n_component, data, vmin, vmax, nzero_min); 524 if (dataID < 0) { 525 dataID = volumes.size(); 526 volumes.push_back(volPtr); 527 } else { 528 int i; 529 // Create new slots it needed. 530 for (i = volumes.size(); i <= dataID; i++) { 531 volumes.push_back(NULL); 532 } 533 assert (volumes[dataID] == NULL); 534 volumes[dataID] = volPtr; 535 } 536 volPtr->dataID(dataID); 537 fprintf(stderr, "VOLID=%d, # of volume slots=%d\n", dataID, 538 volumes.size()); 539 return volPtr; 551 540 } 552 541 … … 1241 1230 srcRowPtr += bytesPerRow; 1242 1231 } 1243 writev(0, iov, nRecs); 1232 if (writev(0, iov, nRecs) < 0) { 1233 fprintf(stderr, "write failed: %s\n", strerror(errno)); 1234 } 1244 1235 free(iov); 1245 1236 stats.nFrames++; … … 1281 1272 iov[1].iov_base = (char *)data; 1282 1273 iov[1].iov_len = dlen; 1283 writev(0, iov, nRecs); 1274 if (writev(0, iov, nRecs) < 0) { 1275 fprintf(stderr, "write failed: %s\n", strerror(errno)); 1276 } 1284 1277 free(iov); 1285 1278 // stats.nFrames++; … … 1547 1540 xMin = yMin = zMin = wMin = DBL_MAX; 1548 1541 xMax = yMax = zMax = wMax = -DBL_MAX; 1549 NanoVis::VolumeMap::iterator iter;1550 for (iter = volume Map.begin(); iter != volumeMap.end(); ++iter)1551 {1552 Volume *volPtr = iter->second; 1553 1542 vector<Volume *>::iterator iter; 1543 for (iter = volumes.begin(); iter != volumes.end(); ++iter) { 1544 Volume *volPtr; 1545 1546 volPtr = (*iter); 1554 1547 if (volPtr == NULL) { 1555 continue; 1556 } 1557 if (!volPtr->visible()) { 1558 continue; 1548 continue; // Empty slot. 1559 1549 } 1560 1550 if (xMin > volPtr->xAxis.min()) { … … 1879 1869 volPtr->disable_cutplane(1); 1880 1870 volPtr->disable_cutplane(2); 1881 1882 NanoVis::vol_renderer->add_volume(volPtr, 1883 NanoVis::get_transfunc("default")); 1871 volPtr->transferFunction(NanoVis::get_transfunc("default")); 1872 1884 1873 float dx0 = -0.5; 1885 1874 float dy0 = -0.5*volPtr->height/volPtr->width; … … 2278 2267 iov[2].iov_len = 1; 2279 2268 iov[2].iov_base = (char *)'\n'; 2280 writev(0, iov, 3); 2269 if (writev(0, iov, 3) < 0) { 2270 fprintf(stderr, "write failed: %s\n", strerror(errno)); 2271 } 2281 2272 if (debug_flag) { 2282 2273 fprintf(stderr, "leaving xinetd_listen\n"); … … 2557 2548 } 2558 2549 2559 int NanoVis::generate_data_identifier() 2560 { 2561 return _last_data_id++; 2562 } 2563 2564 void NanoVis::remove_volume(int volDataID) 2565 { 2566 2567 NanoVis::VolumeMap::iterator iter = volumeMap.find(volDataID); 2568 if (iter != volumeMap.end()) 2569 { 2570 (*iter).second->unref(); 2571 volumeMap.erase(iter); 2572 } 2573 } 2550 void 2551 NanoVis::remove_volume(size_t index) 2552 { 2553 fprintf(stderr, "index=%d #volumes=%d\n", index, volumes.size()); 2554 assert(index < volumes.size()); 2555 Volume* volPtr; 2556 volPtr = volumes[index]; 2557 if (volPtr == NULL) { 2558 return; // Empty slot 2559 } 2560 delete volPtr; // Delete the volume and mark the 2561 volumes[index] = NULL; // slot as empty. 2562 }
Note: See TracChangeset
for help on using the changeset viewer.