Changeset 1478 for trunk/packages/vizservers/nanovis/FlowCmd.cpp
- Timestamp:
- May 30, 2009, 8:07:17 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/FlowCmd.cpp
r1475 r1478 186 186 187 187 glPushMatrix(); 188 Vector3 *originPtr = volPtr->get_location();189 glTranslatef(origin Ptr->x, originPtr->y, originPtr->z);188 Vector3 origin = volPtr->location(); 189 glTranslatef(origin.x, origin.y, origin.z); 190 190 191 191 double sx, sy, sz; … … 272 272 _interp = interp; 273 273 _hashPtr = hPtr; 274 _volDataID = -1; /* Indicates that no volume slot has275 * been allocated for this vector. */276 274 _sv.sliceVisible = 1; 277 275 _sv.tfPtr = NanoVis::get_transfunc("default"); 278 276 _volPtr = NULL; 277 _volId = -1; 279 278 _cmdToken = Tcl_CreateObjCommand(interp, (char *)_name, 280 279 (Tcl_ObjCmdProc *)FlowInstObjCmd, this, FlowInstDeleteProc); … … 296 295 } 297 296 if (_volPtr != NULL) { 298 _volPtr->unref();299 _volPtr = NULL;300 NanoVis::remove_volume(_volDataID);301 NanoVis::vol_renderer->remove_volume(_volDataID);297 assert((size_t)_volId == _volPtr->dataID()); 298 fprintf(stderr, "from ~FlowCmd volId=%d\n", _volId); 299 NanoVis::remove_volume(_volId); 300 _volPtr = NULL; 302 301 } 303 302 … … 497 496 498 497 void 499 FlowCmd::InitVectorField(void)500 {501 if (_volPtr != NULL) {502 _volPtr->unref();503 _volPtr = NULL;504 NanoVis::remove_volume(_volDataID);505 NanoVis::vol_renderer->remove_volume(_volDataID);506 }507 // Remove the associated vector field.508 if (_fieldPtr != NULL) {509 delete _fieldPtr;510 _fieldPtr = NULL;511 }512 513 }514 515 void516 498 FlowCmd::InitializeParticles(void) 517 499 { … … 528 510 { 529 511 if (_volPtr != NULL) { 530 _volPtr->unref(); 512 assert((size_t)_volId == _volPtr->dataID()); 513 fprintf(stderr, "from ScaleVectorField volId=%d\n", _volId); 514 NanoVis::remove_volume(_volId); 531 515 _volPtr = NULL; 532 NanoVis::remove_volume(_volDataID);533 NanoVis::vol_renderer->remove_volume(_volDataID);534 516 } 535 517 float *vdata; … … 546 528 _volPtr = volPtr; 547 529 530 // Remove the associated vector field. 531 if (_fieldPtr != NULL) { 532 delete _fieldPtr; 533 } 548 534 _fieldPtr = new NvVectorField(); 549 535 if (_fieldPtr == NULL) { … … 556 542 depth = NanoVis::zMax - NanoVis::zMin; 557 543 558 Vector3 *locationPtr = _volPtr->get_location();544 Vector3 loc = _volPtr->location(); 559 545 /*This is wrong. Need to compute origin. */ 560 NanoVis::xOrigin = loc ationPtr->x;561 NanoVis::yOrigin = loc ationPtr->y;562 NanoVis::zOrigin = loc ationPtr->z;563 564 _fieldPtr->setVectorField(_volPtr, *locationPtr,546 NanoVis::xOrigin = loc.x; 547 NanoVis::yOrigin = loc.y; 548 NanoVis::zOrigin = loc.z; 549 550 _fieldPtr->setVectorField(_volPtr, loc, 565 551 1.0f, height / width, depth / width, NanoVis::magMax); 566 552 567 553 if (NanoVis::licRenderer != NULL) { 568 NanoVis::licRenderer->setVectorField(_volPtr->id, 569 *locationPtr, 554 NanoVis::licRenderer->setVectorField(_volPtr->id, loc, 570 555 1.0f / _volPtr->aspect_ratio_width, 571 556 1.0f / _volPtr->aspect_ratio_height, … … 632 617 FlowCmd::MakeVolume(float *data) 633 618 { 634 if (_volDataID < 0) {635 _volDataID = NanoVis::generate_data_identifier();636 Trace("VolumeDataID is %d\n", _volDataID);637 }638 619 Volume *volPtr; 639 volPtr = NanoVis::load_volume(_volDataID, _dataPtr->xNum(), 640 _dataPtr->yNum(), _dataPtr->zNum(), 4, data, 641 NanoVis::magMin, NanoVis::magMax, 0); 620 /* Reuse the volume index. The first time it's -1, which means to generate 621 * a new volume slot. */ 622 volPtr = NanoVis::load_volume(_volId, _dataPtr->xNum(), _dataPtr->yNum(), 623 _dataPtr->zNum(), 4, data, NanoVis::magMin, NanoVis::magMax, 0); 624 /* Save the volume index. This only matters the first time through. */ 625 _volId = volPtr->dataID(); 642 626 volPtr->xAxis.SetRange(_dataPtr->xMin(), _dataPtr->xMax()); 643 627 volPtr->yAxis.SetRange(_dataPtr->yMin(), _dataPtr->yMax()); … … 645 629 volPtr->wAxis.SetRange(NanoVis::magMin, NanoVis::magMax); 646 630 647 /*volPtr->update_pending = false;*/648 631 Vector3 physicalMin(NanoVis::xMin, NanoVis::yMin, NanoVis::zMin); 649 632 Vector3 physicalMax(NanoVis::xMax, NanoVis::yMax, NanoVis::zMax); … … 653 636 // volPtr->set_n_slice(512- _volIndex); 654 637 // TBD.. 655 volPtr-> set_n_slice(256);638 volPtr->n_slices(256); 656 639 volPtr->disable_cutplane(0); 657 640 volPtr->disable_cutplane(1); 658 641 volPtr->disable_cutplane(2); 659 642 660 NanoVis::vol_renderer->add_volume(volPtr, _sv.tfPtr); 661 volPtr->data(_sv.showVolume); 643 // Automatically set the volume with the previously configured values. 644 volPtr->transferFunction(_sv.tfPtr); 645 volPtr->data_enabled(_sv.showVolume); 662 646 volPtr->outline(_sv.showOutline); 663 647 volPtr->opacity_scale(_sv.opacity); 664 648 volPtr->specular(_sv.specular); 665 649 volPtr->diffuse(_sv.diffuse); 666 650 Trace("volume is now %d %d\n", _sv.showVolume, volPtr->visible()); 651 volPtr->visible(_sv.showVolume); 667 652 float dx0 = -0.5; 668 653 float dy0 = -0.5*volPtr->height/volPtr->width; 669 654 float dz0 = -0.5*volPtr->depth/volPtr->width; 670 volPtr-> move(Vector3(dx0, dy0, dz0));655 volPtr->location(Vector3(dx0, dy0, dz0)); 671 656 Volume::update_pending = true; 672 657 return volPtr; … … 785 770 return TCL_ERROR; 786 771 } 772 Rappture::Unirect3d *dataPtr; 773 dataPtr = new Rappture::Unirect3d(nComponents); 774 787 775 FlowCmd *flowPtr = (FlowCmd *)clientData; 788 776 size_t length = buf.size(); 789 777 char *bytes = (char *)buf.bytes(); 790 778 if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) { 791 Rappture::Unirect3d *dataPtr;792 dataPtr = new Rappture::Unirect3d(nComponents);793 779 if (!dataPtr->ImportDx(result, nComponents, length - 4, bytes + 4)) { 794 780 Tcl_AppendResult(interp, result.remark(), (char *)NULL); … … 798 784 flowPtr->SetData(dataPtr); 799 785 } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) { 800 Rappture::Unirect3d *dataPtr;801 dataPtr = new Rappture::Unirect3d(nComponents);802 786 if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) { 803 787 delete dataPtr; … … 812 796 return TCL_ERROR; 813 797 } 814 Rappture::Unirect3d *dataPtr;815 dataPtr = new Rappture::Unirect3d(nComponents);816 798 dataPtr->Convert(u2dPtr); 817 799 flowPtr->SetData(dataPtr); … … 819 801 } else { 820 802 fprintf(stderr, "header is %.14s\n", buf.bytes()); 821 Rappture::Unirect3d *dataPtr;822 803 dataPtr = new Rappture::Unirect3d(nComponents); 823 804 if (!dataPtr->ImportDx(result, nComponents, length, bytes)) { … … 833 814 size_t length; 834 815 835 length = sprintf(info, "nv>data tag %s id 0 min %g max %g vmin %g vmax %g\n", 836 flowPtr->name(), NanoVis::magMin, 837 NanoVis::magMax, NanoVis::xMin, NanoVis::xMax); 816 length = sprintf(info, "nv>data tag %s min %g max %g\n", 817 flowPtr->name(), dataPtr->magMin(), dataPtr->magMax()); 838 818 nWritten = write(0, info, length); 839 819 assert(nWritten == (ssize_t)strlen(info)); … … 1030 1010 /* 1031 1011 * Step 2. Generate the vector field from each data set. 1032 * Delete the currently generated fields.1033 1012 */ 1034 1013 for (flowPtr = FirstFlow(&iter); flowPtr != NULL; 1035 1014 flowPtr = NextFlow(&iter)) { 1036 1015 if (!flowPtr->isDataLoaded()) { 1037 continue; 1038 } 1039 flowPtr->InitVectorField(); 1040 if (!flowPtr->visible()) { 1041 continue; 1042 } 1043 flowPtr->InitializeParticles(); 1016 continue; // Flow exists, but no data has 1017 // been loaded yet. 1018 } 1019 if (flowPtr->visible()) { 1020 flowPtr->InitializeParticles(); 1021 } 1044 1022 if (!flowPtr->ScaleVectorField()) { 1045 1023 return false; 1046 1024 } 1025 // FIXME: This doesn't work when there is more than one flow. 1047 1026 licRenderer->set_offset(flowPtr->GetRelativePosition()); 1048 1027 }
Note: See TracChangeset
for help on using the changeset viewer.