Changeset 4612
- Timestamp:
- Aug 2, 2014, 11:06:20 AM (10 years ago)
- Location:
- nanovis/branches/1.1
- Files:
-
- 4 deleted
- 22 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
nanovis/branches/1.1
- Property svn:mergeinfo changed
/trunk/packages/vizservers/nanovis merged: 3597
- Property svn:mergeinfo changed
-
nanovis/branches/1.1/Command.cpp
r3568 r4612 26 26 * o Use Tcl command option parser to reduce size of procedures, remove 27 27 * lots of extra error checking code. (almost there) 28 * o Convert GetVolumeIndices to GetVolumes. Goal is to remove29 * all references of Nanovis::volume[] from this file. Don't30 * want to know how volumes are stored. Same for heightmaps.31 * o Rationalize volume id scheme. Right now it's the index in32 * the vector. 1) Use a list instead of a vector. 2) carry33 * an id field that's a number that gets incremented each new volume.34 28 * o Add bookkeeping for volumes, heightmaps, flows, etc. to track 35 * 1) id # 2) simulation # 3) include/exclude. The include/exclude29 * 1) simulation # 2) include/exclude. The include/exclude 36 30 * is to indicate whether the item should contribute to the overall 37 31 * limits of the axes. … … 45 39 46 40 #include <RpField1D.h> 47 #include <RpFieldRect3D.h>48 #include <RpFieldPrism3D.h>49 41 #include <RpEncode.h> 50 42 #include <RpOutcome.h> … … 55 47 #include "nanovis.h" 56 48 #include "CmdProc.h" 49 #include "FlowCmd.h" 57 50 #include "Trace.h" 58 51 #ifdef USE_POINTSET_RENDERER … … 109 102 }"; 110 103 111 static Tcl_ObjCmdProc AxisCmd;112 static Tcl_ObjCmdProc CameraCmd;113 static Tcl_ObjCmdProc CutplaneCmd;114 extern Tcl_AppInitProc FlowCmdInitProc;115 static Tcl_ObjCmdProc GridCmd;116 static Tcl_ObjCmdProc LegendCmd;117 static Tcl_ObjCmdProc ScreenCmd;118 static Tcl_ObjCmdProc SnapshotCmd;119 static Tcl_ObjCmdProc TransfuncCmd;120 static Tcl_ObjCmdProc Unirect2dCmd;121 static Tcl_ObjCmdProc UpCmd;122 static Tcl_ObjCmdProc VolumeCmd;123 124 104 bool 125 105 GetBooleanFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, bool *boolPtr) … … 2228 2208 return interp; 2229 2209 } 2230 2231 -
nanovis/branches/1.1/Doxyfile.in
r3567 r4612 599 599 # subdirectory from a directory tree whose root is specified with the INPUT tag. 600 600 601 EXCLUDE = @srcdir@/newmat11 @srcdir@/CircularQueue.h @srcdir@/ParticleEmitter.h @srcdir@/ParticleEmitter.cpp @srcdir@/ParticleSystem.h @srcdir@/ParticleSystem.cpp @srcdir@/ParticleSystemFactory.h @srcdir@/ParticleSystemFactory.cpp @srcdir@/BucketSort.h @srcdir@/BucketSort.cpp @srcdir@/PCASplit.h @srcdir@/PCASplit.cpp @srcdir@/PointSet.h @srcdir@/PointSet.cpp @srcdir@/PointSetRenderer.h @srcdir@/PointSetRenderer.cpp @srcdir@/PointShader.h @srcdir@/PointShader.cpp @srcdir@/NvVectorField.h @srcdir@/NvVectorField.cpp @srcdir@/NvFlowVisRenderer.h @srcdir@/NvFlowVisRenderer.cpp601 EXCLUDE = @srcdir@/newmat11 @srcdir@/CircularQueue.h @srcdir@/ParticleEmitter.h @srcdir@/ParticleEmitter.cpp @srcdir@/ParticleSystem.h @srcdir@/ParticleSystem.cpp @srcdir@/ParticleSystemFactory.h @srcdir@/ParticleSystemFactory.cpp @srcdir@/BucketSort.h @srcdir@/BucketSort.cpp @srcdir@/PCASplit.h @srcdir@/PCASplit.cpp @srcdir@/PointSet.h @srcdir@/PointSet.cpp @srcdir@/PointSetRenderer.h @srcdir@/PointSetRenderer.cpp @srcdir@/PointShader.h @srcdir@/PointShader.cpp 602 602 603 603 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or -
nanovis/branches/1.1/FlowCmd.cpp
r3584 r4612 16 16 #include <unistd.h> 17 17 #include <poll.h> 18 18 19 #include <tcl.h> 19 20 20 #include <RpField1D.h>21 #include <RpFieldRect3D.h>22 #include <RpFieldPrism3D.h>23 21 #include <RpOutcome.h> 24 22 … … 29 27 #include "nanovis.h" 30 28 #include "CmdProc.h" 29 #include "Command.h" 31 30 #include "FlowCmd.h" 32 31 #include "FlowTypes.h" 32 #include "Flow.h" 33 33 #include "FlowBox.h" 34 34 #include "FlowParticles.h" … … 36 36 #include "TransferFunction.h" 37 37 #include "NvLIC.h" 38 #include "Trace.h"39 38 #include "Unirect.h" 40 39 #include "VelocityArrowsSlice.h" 41 40 #include "Volume.h" 41 #include "Trace.h" 42 42 43 43 using namespace vrmath; … … 68 68 }; 69 69 70 Rappture::SwitchSpec Flow Cmd::_switches[] = {70 Rappture::SwitchSpec Flow::_switches[] = { 71 71 {Rappture::SWITCH_FLOAT, "-ambient", "value", 72 72 offsetof(FlowValues, ambient), 0}, … … 128 128 }; 129 129 130 static Tcl_ObjCmdProc FlowInstObjCmd;131 static Tcl_CmdDeleteProc FlowInstDeleteProc;132 133 FlowCmd::FlowCmd(Tcl_Interp *interp, const char *name) :134 _interp(interp),135 _name(name),136 _data(NULL),137 _volume(NULL),138 _field(NULL)139 {140 memset(&_sv, 0, sizeof(FlowValues));141 _sv.sliceVisible = 1;142 _sv.transferFunction = NanoVis::getTransferFunction("default");143 144 _cmdToken = Tcl_CreateObjCommand(_interp, (char *)name,145 (Tcl_ObjCmdProc *)FlowInstObjCmd,146 this, FlowInstDeleteProc);147 }148 149 FlowCmd::~FlowCmd()150 {151 TRACE("Enter");152 153 Rappture::FreeSwitches(_switches, &_sv, 0);154 if (_field != NULL) {155 delete _field;156 }157 if (_data != NULL) {158 delete _data;159 }160 if (_volume != NULL) {161 NanoVis::removeVolume(_volume);162 _volume = NULL;163 }164 for (BoxHashmap::iterator itr = _boxTable.begin();165 itr != _boxTable.end(); ++itr) {166 delete itr->second;167 }168 _boxTable.clear();169 for (ParticlesHashmap::iterator itr = _particlesTable.begin();170 itr != _particlesTable.end(); ++itr) {171 delete itr->second;172 }173 _particlesTable.clear();174 }175 176 void177 FlowCmd::getBounds(Vector3f& min,178 Vector3f& max,179 bool onlyVisible)180 {181 TRACE("Enter");182 183 if (onlyVisible && !visible())184 return;185 186 #if 0 // Using volume bounds instead of these187 if (isDataLoaded()) {188 Vector3f umin, umax;189 Rappture::Unirect3d *unirect = data();190 unirect->getWorldSpaceBounds(umin, umax);191 if (min.x > umin.x) {192 min.x = umin.x;193 }194 if (max.x < umax.x) {195 max.x = umax.x;196 }197 if (min.y > umin.y) {198 min.y = umin.y;199 }200 if (max.y < umax.y) {201 max.y = umax.y;202 }203 if (min.z > umin.z) {204 min.z = umin.z;205 }206 if (max.z < umax.z) {207 max.z = umax.z;208 }209 }210 #endif211 for (BoxHashmap::iterator itr = _boxTable.begin();212 itr != _boxTable.end(); ++itr) {213 FlowBox *box = itr->second;214 if (!onlyVisible || box->visible()) {215 Vector3f fbmin, fbmax;216 box->getWorldSpaceBounds(fbmin, fbmax,217 getVolume());218 if (min.x > fbmin.x) {219 min.x = fbmin.x;220 }221 if (max.x < fbmax.x) {222 max.x = fbmax.x;223 }224 if (min.y > fbmin.y) {225 min.y = fbmin.y;226 }227 if (max.y < fbmax.y) {228 max.y = fbmax.y;229 }230 if (min.z > fbmin.z) {231 min.z = fbmin.z;232 }233 if (max.z < fbmax.z) {234 max.z = fbmax.z;235 }236 }237 }238 }239 240 void241 FlowCmd::resetParticles()242 {243 for (ParticlesHashmap::iterator itr = _particlesTable.begin();244 itr != _particlesTable.end(); ++itr) {245 itr->second->reset();246 }247 }248 249 void250 FlowCmd::advect()251 {252 NvVectorField *fieldPtr = getVectorField();253 fieldPtr->active(true);254 for (ParticlesHashmap::iterator itr = _particlesTable.begin();255 itr != _particlesTable.end(); ++itr) {256 if (itr->second->visible()) {257 itr->second->advect();258 }259 }260 }261 262 void263 FlowCmd::render()264 {265 _field->active(true);266 _field->render();267 for (ParticlesHashmap::iterator itr = _particlesTable.begin();268 itr != _particlesTable.end(); ++itr) {269 if (itr->second->visible()) {270 itr->second->render();271 }272 }273 renderBoxes();274 }275 276 FlowParticles *277 FlowCmd::createParticles(const char *particlesName)278 {279 ParticlesHashmap::iterator itr = _particlesTable.find(particlesName);280 if (itr != _particlesTable.end()) {281 TRACE("Deleting existing particle injection plane '%s'", particlesName);282 delete itr->second;283 _particlesTable.erase(itr);284 }285 FlowParticles *particles = new FlowParticles(particlesName);286 _particlesTable[particlesName] = particles;287 return particles;288 }289 290 FlowParticles *291 FlowCmd::getParticles(const char *particlesName)292 {293 ParticlesHashmap::iterator itr;294 itr = _particlesTable.find(particlesName);295 if (itr == _particlesTable.end()) {296 TRACE("Can't find particle injection plane '%s' in '%s'", particlesName, name());297 return NULL;298 }299 return itr->second;300 }301 302 void303 FlowCmd::deleteParticles(const char *particlesName)304 {305 ParticlesHashmap::iterator itr = _particlesTable.find(particlesName);306 if (itr == _particlesTable.end()) {307 TRACE("Can't find particle injection plane '%s' in '%s'", particlesName, name());308 return;309 }310 delete itr->second;311 _particlesTable.erase(itr);312 }313 314 void315 FlowCmd::getParticlesNames(std::vector<std::string>& names)316 {317 for (ParticlesHashmap::iterator itr = _particlesTable.begin();318 itr != _particlesTable.end(); ++itr) {319 names.push_back(std::string(itr->second->name()));320 }321 }322 323 FlowBox *324 FlowCmd::createBox(const char *boxName)325 {326 BoxHashmap::iterator itr = _boxTable.find(boxName);327 if (itr != _boxTable.end()) {328 TRACE("Deleting existing box '%s'", boxName);329 delete itr->second;330 _boxTable.erase(itr);331 }332 FlowBox *box = new FlowBox(boxName);333 _boxTable[boxName] = box;334 return box;335 }336 337 FlowBox *338 FlowCmd::getBox(const char *boxName)339 {340 BoxHashmap::iterator itr = _boxTable.find(boxName);341 if (itr == _boxTable.end()) {342 TRACE("Can't find box '%s' in '%s'", boxName, name());343 return NULL;344 }345 return itr->second;346 }347 348 void349 FlowCmd::deleteBox(const char *boxName)350 {351 BoxHashmap::iterator itr = _boxTable.find(boxName);352 if (itr == _boxTable.end()) {353 TRACE("Can't find box '%s' in '%s'", boxName, name());354 return;355 }356 delete itr->second;357 _boxTable.erase(itr);358 }359 360 void FlowCmd::getBoxNames(std::vector<std::string>& names)361 {362 for (BoxHashmap::iterator itr = _boxTable.begin();363 itr != _boxTable.end(); ++itr) {364 names.push_back(std::string(itr->second->name()));365 }366 }367 368 void369 FlowCmd::initializeParticles()370 {371 for (ParticlesHashmap::iterator itr = _particlesTable.begin();372 itr != _particlesTable.end(); ++itr) {373 itr->second->initialize();374 }375 }376 377 bool378 FlowCmd::scaleVectorField()379 {380 if (_volume != NULL) {381 TRACE("Removing existing volume: %s", _volume->name());382 NanoVis::removeVolume(_volume);383 _volume = NULL;384 }385 float *vdata = getScaledVector();386 if (vdata == NULL) {387 return false;388 }389 Volume *volume = makeVolume(vdata);390 delete [] vdata;391 if (volume == NULL) {392 return false;393 }394 _volume = volume;395 396 // Remove the associated vector field.397 if (_field != NULL) {398 delete _field;399 }400 _field = new NvVectorField();401 if (_field == NULL) {402 return false;403 }404 405 Vector3f scale = volume->getPhysicalScaling();406 Vector3f location = _volume->location();407 408 _field->setVectorField(_volume,409 location,410 scale.x,411 scale.y,412 scale.z,413 NanoVis::magMax);414 415 if (NanoVis::licRenderer != NULL) {416 NanoVis::licRenderer->417 setVectorField(_volume->textureID(),418 location,419 scale.x,420 scale.y,421 scale.z,422 _volume->wAxis.max());423 setCurrentPosition();424 setAxis();425 setActive();426 }427 428 if (NanoVis::velocityArrowsSlice != NULL) {429 NanoVis::velocityArrowsSlice->430 setVectorField(_volume->textureID(),431 location,432 scale.x,433 scale.y,434 scale.z,435 _volume->wAxis.max());436 NanoVis::velocityArrowsSlice->axis(_sv.slicePos.axis);437 NanoVis::velocityArrowsSlice->slicePos(_sv.slicePos.value);438 NanoVis::velocityArrowsSlice->enabled(_sv.showArrows);439 }440 441 for (ParticlesHashmap::iterator itr = _particlesTable.begin();442 itr != _particlesTable.end(); ++itr) {443 itr->second->setVectorField(_volume,444 location,445 scale.x,446 scale.y,447 scale.z,448 _volume->wAxis.max());449 }450 return true;451 }452 453 void454 FlowCmd::renderBoxes()455 {456 for (BoxHashmap::iterator itr = _boxTable.begin();457 itr != _boxTable.end(); ++itr) {458 if (itr->second->visible()) {459 itr->second->render(_volume);460 }461 }462 }463 464 float *465 FlowCmd::getScaledVector()466 {467 assert(_data->nComponents() == 3);468 size_t n = _data->nValues() / _data->nComponents() * 4;469 float *data = new float[n];470 if (data == NULL) {471 return NULL;472 }473 memset(data, 0, sizeof(float) * n);474 float *destPtr = data;475 const float *values = _data->values();476 for (size_t iz = 0; iz < _data->zNum(); iz++) {477 for (size_t iy = 0; iy < _data->yNum(); iy++) {478 for (size_t ix = 0; ix < _data->xNum(); ix++) {479 double vx, vy, vz, vm;480 vx = values[0];481 vy = values[1];482 vz = values[2];483 vm = sqrt(vx*vx + vy*vy + vz*vz);484 destPtr[0] = vm / NanoVis::magMax;485 destPtr[1] = vx /(2.0*NanoVis::magMax) + 0.5;486 destPtr[2] = vy /(2.0*NanoVis::magMax) + 0.5;487 destPtr[3] = vz /(2.0*NanoVis::magMax) + 0.5;488 values += 3;489 destPtr += 4;490 }491 }492 }493 return data;494 }495 496 Volume *497 FlowCmd::makeVolume(float *data)498 {499 Volume *volume =500 NanoVis::loadVolume(_name.c_str(),501 _data->xNum(),502 _data->yNum(),503 _data->zNum(),504 4, data,505 NanoVis::magMin, NanoVis::magMax, 0);506 volume->xAxis.setRange(_data->xMin(), _data->xMax());507 volume->yAxis.setRange(_data->yMin(), _data->yMax());508 volume->zAxis.setRange(_data->zMin(), _data->zMax());509 510 TRACE("min=%g %g %g max=%g %g %g mag=%g %g",511 NanoVis::xMin, NanoVis::yMin, NanoVis::zMin,512 NanoVis::xMax, NanoVis::yMax, NanoVis::zMax,513 NanoVis::magMin, NanoVis::magMax);514 515 volume->disableCutplane(0);516 volume->disableCutplane(1);517 volume->disableCutplane(2);518 519 /* Initialize the volume with the previously configured values. */520 volume->transferFunction(_sv.transferFunction);521 volume->dataEnabled(_sv.showVolume);522 volume->twoSidedLighting(_sv.twoSidedLighting);523 volume->outline(_sv.showOutline);524 volume->opacityScale(_sv.opacity);525 volume->ambient(_sv.ambient);526 volume->diffuse(_sv.diffuse);527 volume->specularLevel(_sv.specular);528 volume->specularExponent(_sv.specularExp);529 volume->visible(_sv.showVolume);530 531 Vector3f volScaling = volume->getPhysicalScaling();532 Vector3f loc(volScaling);533 loc *= -0.5;534 volume->location(loc);535 536 Volume::updatePending = true;537 return volume;538 }539 540 130 static int 541 131 FlowDataFileOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 566 156 Rappture::Unirect3d *dataPtr; 567 157 dataPtr = new Rappture::Unirect3d(nComponents); 568 Flow Cmd *flowPtr = (FlowCmd*)clientData;158 Flow *flow = (Flow *)clientData; 569 159 size_t length = buf.size(); 570 160 char *bytes = (char *)buf.bytes(); … … 603 193 return TCL_ERROR; 604 194 } 605 flow Ptr->data(dataPtr);195 flow->data(dataPtr); 606 196 NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS); 607 197 return TCL_OK; … … 649 239 dataPtr = new Rappture::Unirect3d(nComponents); 650 240 651 Flow Cmd *flowPtr = (FlowCmd*)clientData;241 Flow *flow = (Flow *)clientData; 652 242 size_t length = buf.size(); 653 243 char *bytes = (char *)buf.bytes(); … … 699 289 TRACE("magMin = %lg magMax = %lg", 700 290 dataPtr->magMin(), dataPtr->magMax()); 701 flow Ptr->data(dataPtr);291 flow->data(dataPtr); 702 292 { 703 293 char info[1024]; … … 706 296 707 297 length = sprintf(info, "nv>data tag %s min %g max %g\n", 708 flow Ptr->name(), dataPtr->magMin(), dataPtr->magMax());298 flow->name(), dataPtr->magMin(), dataPtr->magMax()); 709 299 nWritten = write(1, info, length); 710 300 assert(nWritten == (ssize_t)strlen(info)); … … 732 322 } 733 323 return (*proc) (clientData, interp, objc, objv); 734 }735 736 float737 FlowCmd::getRelativePosition(FlowPosition *posPtr)738 {739 if (posPtr->flags == RELPOS) {740 return posPtr->value;741 }742 switch (posPtr->axis) {743 case AXIS_X:744 return (posPtr->value - NanoVis::xMin) /745 (NanoVis::xMax - NanoVis::xMin);746 case AXIS_Y:747 return (posPtr->value - NanoVis::yMin) /748 (NanoVis::yMax - NanoVis::yMin);749 case AXIS_Z:750 return (posPtr->value - NanoVis::zMin) /751 (NanoVis::zMax - NanoVis::zMin);752 }753 return 0.0;754 }755 756 float757 FlowCmd::getRelativePosition()758 {759 return FlowCmd::getRelativePosition(&_sv.slicePos);760 }761 762 /* Static NanoVis class commands. */763 764 FlowCmd *765 NanoVis::getFlow(const char *name)766 {767 FlowHashmap::iterator itr = flowTable.find(name);768 if (itr == flowTable.end()) {769 TRACE("Can't find flow '%s'", name);770 return NULL;771 }772 return itr->second;773 }774 775 FlowCmd *776 NanoVis::createFlow(Tcl_Interp *interp, const char *name)777 {778 FlowHashmap::iterator itr = flowTable.find(name);779 if (itr != flowTable.end()) {780 ERROR("Flow '%s' already exists", name);781 return NULL;782 }783 FlowCmd *flow = new FlowCmd(interp, name);784 flowTable[name] = flow;785 return flow;786 }787 788 /**789 * \brief Delete flow object and hash table entry790 *791 * This is called by the flow command instance delete callback792 */793 void794 NanoVis::deleteFlow(const char *name)795 {796 FlowHashmap::iterator itr = flowTable.find(name);797 if (itr != flowTable.end()) {798 delete itr->second;799 flowTable.erase(itr);800 }801 }802 803 /**804 * \brief Delete all flow object commands805 *806 * This will also delete the flow objects and hash table entries807 */808 void809 NanoVis::deleteFlows(Tcl_Interp *interp)810 {811 FlowHashmap::iterator itr;812 for (itr = flowTable.begin();813 itr != flowTable.end(); ++itr) {814 Tcl_DeleteCommandFromToken(interp, itr->second->getCommandToken());815 }816 flowTable.clear();817 }818 819 bool820 NanoVis::mapFlows()821 {822 TRACE("Enter");823 824 flags &= ~MAP_FLOWS;825 826 /*827 * Step 1. Get the overall min and max magnitudes of all the828 * flow vectors.829 */830 magMin = DBL_MAX, magMax = -DBL_MAX;831 832 for (FlowHashmap::iterator itr = flowTable.begin();833 itr != flowTable.end(); ++itr) {834 FlowCmd *flow = itr->second;835 double min, max;836 if (!flow->isDataLoaded()) {837 continue;838 }839 Rappture::Unirect3d *data = flow->data();840 min = data->magMin();841 max = data->magMax();842 if (min < magMin) {843 magMin = min;844 }845 if (max > magMax) {846 magMax = max;847 }848 if (data->xMin() < xMin) {849 xMin = data->xMin();850 }851 if (data->yMin() < yMin) {852 yMin = data->yMin();853 }854 if (data->zMin() < zMin) {855 zMin = data->zMin();856 }857 if (data->xMax() > xMax) {858 xMax = data->xMax();859 }860 if (data->yMax() > yMax) {861 yMax = data->yMax();862 }863 if (data->zMax() > zMax) {864 zMax = data->zMax();865 }866 }867 868 TRACE("magMin=%g magMax=%g", NanoVis::magMin, NanoVis::magMax);869 870 /*871 * Step 2. Generate the vector field from each data set.872 */873 for (FlowHashmap::iterator itr = flowTable.begin();874 itr != flowTable.end(); ++itr) {875 FlowCmd *flow = itr->second;876 if (!flow->isDataLoaded()) {877 continue; // Flow exists, but no data has been loaded yet.878 }879 if (flow->visible()) {880 flow->initializeParticles();881 }882 if (!flow->scaleVectorField()) {883 return false;884 }885 // FIXME: This doesn't work when there is more than one flow.886 licRenderer->setOffset(flow->getRelativePosition());887 velocityArrowsSlice->slicePos(flow->getRelativePosition());888 }889 advectFlows();890 return true;891 }892 893 void894 NanoVis::getFlowBounds(Vector3f& min,895 Vector3f& max,896 bool onlyVisible)897 {898 TRACE("Enter");899 900 min.set(FLT_MAX, FLT_MAX, FLT_MAX);901 max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);902 903 for (FlowHashmap::iterator itr = flowTable.begin();904 itr != flowTable.end(); ++itr) {905 itr->second->getBounds(min, max, onlyVisible);906 }907 }908 909 void910 NanoVis::renderFlows()911 {912 for (FlowHashmap::iterator itr = flowTable.begin();913 itr != flowTable.end(); ++itr) {914 FlowCmd *flow = itr->second;915 if (flow->isDataLoaded() && flow->visible()) {916 flow->render();917 }918 }919 flags &= ~REDRAW_PENDING;920 }921 922 void923 NanoVis::resetFlows()924 {925 if (licRenderer->active()) {926 NanoVis::licRenderer->reset();927 }928 for (FlowHashmap::iterator itr = flowTable.begin();929 itr != flowTable.end(); ++itr) {930 FlowCmd *flow = itr->second;931 if (flow->isDataLoaded() && flow->visible()) {932 flow->resetParticles();933 }934 }935 }936 937 void938 NanoVis::advectFlows()939 {940 for (FlowHashmap::iterator itr = flowTable.begin();941 itr != flowTable.end(); ++itr) {942 FlowCmd *flow = itr->second;943 if (flow->isDataLoaded() && flow->visible()) {944 flow->advect();945 }946 }947 324 } 948 325 … … 969 346 const char *string = Tcl_GetString(objPtr); 970 347 if (string[1] == '\0') { 971 Flow Cmd::SliceAxis *axisPtr = (FlowCmd::SliceAxis *)(record + offset);348 Flow::SliceAxis *axisPtr = (Flow::SliceAxis *)(record + offset); 972 349 char c; 973 350 c = tolower((unsigned char)string[0]); 974 351 if (c == 'x') { 975 *axisPtr = Flow Cmd::AXIS_X;352 *axisPtr = Flow::AXIS_X; 976 353 return TCL_OK; 977 354 } else if (c == 'y') { 978 *axisPtr = Flow Cmd::AXIS_Y;355 *axisPtr = Flow::AXIS_Y; 979 356 return TCL_OK; 980 357 } else if (c == 'z') { 981 *axisPtr = Flow Cmd::AXIS_Z;358 *axisPtr = Flow::AXIS_Z; 982 359 return TCL_OK; 983 360 } … … 1175 552 Tcl_Obj *const *objv) 1176 553 { 1177 Flow Cmd *flowPtr = (FlowCmd*)clientData;1178 1179 if (flow Ptr->parseSwitches(interp, objc - 2, objv + 2) != TCL_OK) {554 Flow *flow = (Flow *)clientData; 555 556 if (flow->parseSwitches(interp, objc - 2, objv + 2) != TCL_OK) { 1180 557 return TCL_ERROR; 1181 558 } … … 1188 565 Tcl_Obj *const *objv) 1189 566 { 1190 Flow Cmd *flow = (FlowCmd*)clientData;567 Flow *flow = (Flow *)clientData; 1191 568 const char *particlesName = Tcl_GetString(objv[3]); 1192 569 FlowParticles *particles = flow->createParticles(particlesName); … … 1212 589 Tcl_Obj *const *objv) 1213 590 { 1214 Flow Cmd *flow = (FlowCmd*)clientData;591 Flow *flow = (Flow *)clientData; 1215 592 const char *particlesName = Tcl_GetString(objv[3]); 1216 593 FlowParticles *particles = flow->getParticles(particlesName); … … 1233 610 Tcl_Obj *const *objv) 1234 611 { 1235 Flow Cmd *flow = (FlowCmd*)clientData;612 Flow *flow = (Flow *)clientData; 1236 613 for (int i = 3; i < objc; i++) { 1237 614 flow->deleteParticles(Tcl_GetString(objv[i])); … … 1245 622 Tcl_Obj *const *objv) 1246 623 { 1247 Flow Cmd *flow = (FlowCmd*)clientData;624 Flow *flow = (Flow *)clientData; 1248 625 Tcl_Obj *listObjPtr; 1249 626 listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); … … 1288 665 return TCL_ERROR; 1289 666 } 1290 Flow Cmd *flowPtr = (FlowCmd*)clientData;1291 Tcl_Preserve(flow Ptr);667 Flow *flow = (Flow *)clientData; 668 Tcl_Preserve(flow); 1292 669 int result; 1293 670 result = (*proc) (clientData, interp, objc, objv); 1294 Tcl_Release(flow Ptr);671 Tcl_Release(flow); 1295 672 return result; 1296 673 } … … 1300 677 Tcl_Obj *const *objv) 1301 678 { 1302 Flow Cmd *flow = (FlowCmd*)clientData;679 Flow *flow = (Flow *)clientData; 1303 680 const char *boxName = Tcl_GetString(objv[3]); 1304 681 FlowBox *box = flow->createBox(boxName); … … 1322 699 Tcl_Obj *const *objv) 1323 700 { 1324 Flow Cmd *flow = (FlowCmd*)clientData;701 Flow *flow = (Flow *)clientData; 1325 702 const char *boxName = Tcl_GetString(objv[3]); 1326 703 FlowBox *box = flow->getBox(boxName); … … 1341 718 Tcl_Obj *const *objv) 1342 719 { 1343 Flow Cmd *flow = (FlowCmd*)clientData;720 Flow *flow = (Flow *)clientData; 1344 721 for (int i = 3; i < objc; i++) { 1345 722 flow->deleteBox(Tcl_GetString(objv[i])); … … 1353 730 Tcl_Obj *const *objv) 1354 731 { 1355 Flow Cmd *flow = (FlowCmd*)clientData;732 Flow *flow = (Flow *)clientData; 1356 733 Tcl_Obj *listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); 1357 734 std::vector<std::string> names; … … 1393 770 return TCL_ERROR; 1394 771 } 1395 Flow Cmd *flowPtr = (FlowCmd*)clientData;1396 Tcl_Preserve(flow Ptr);772 Flow *flow = (Flow *)clientData; 773 Tcl_Preserve(flow); 1397 774 int result; 1398 775 result = (*proc) (clientData, interp, objc, objv); 1399 Tcl_Release(flow Ptr);776 Tcl_Release(flow); 1400 777 return result; 1401 778 } … … 1414 791 Tcl_Obj *const *objv) 1415 792 { 1416 Flow Cmd *flowPtr = (FlowCmd*)clientData;793 Flow *flow = (Flow *)clientData; 1417 794 1418 795 const char *string = Tcl_GetString(objv[1]); 1419 796 TransferFunction *tf; 1420 tf = flow Ptr->getTransferFunction();797 tf = flow->getTransferFunction(); 1421 798 if (tf == NULL) { 1422 799 Tcl_AppendResult(interp, "unknown transfer function \"", string, "\"", … … 1455 832 * \return A standard Tcl result. 1456 833 */ 1457 staticint834 int 1458 835 FlowInstObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, 1459 836 Tcl_Obj *const *objv) … … 1466 843 } 1467 844 assert(CheckGL(AT)); 1468 Flow Cmd *flow = (FlowCmd*)clientData;845 Flow *flow = (Flow *)clientData; 1469 846 Tcl_Preserve(flow); 1470 847 int result = (*proc) (clientData, interp, objc, objv); … … 1478 855 * This is called only when the command associated with the flow is destroyed. 1479 856 */ 1480 staticvoid857 void 1481 858 FlowInstDeleteProc(ClientData clientData) 1482 859 { 1483 Flow Cmd *flow = (FlowCmd*)clientData;860 Flow *flow = (Flow *)clientData; 1484 861 NanoVis::deleteFlow(flow->name()); 1485 862 } … … 1496 873 return TCL_ERROR; 1497 874 } 1498 Flow Cmd*flow = NanoVis::createFlow(interp, name);875 Flow *flow = NanoVis::createFlow(interp, name); 1499 876 if (flow == NULL) { 1500 877 Tcl_AppendResult(interp, "Flow \"", name, "\" already exists", … … 1516 893 { 1517 894 for (int i = 2; i < objc; i++) { 1518 Flow Cmd*flow = NanoVis::getFlow(Tcl_GetString(objv[i]));895 Flow *flow = NanoVis::getFlow(Tcl_GetString(objv[i])); 1519 896 if (flow != NULL) { 1520 897 Tcl_DeleteCommandFromToken(interp, flow->getCommandToken()); … … 1530 907 { 1531 908 bool value = false; 1532 Flow Cmd*flow = NanoVis::getFlow(Tcl_GetString(objv[2]));909 Flow *flow = NanoVis::getFlow(Tcl_GetString(objv[2])); 1533 910 if (flow != NULL) { 1534 911 value = true; … … 1577 954 for (NanoVis::FlowHashmap::iterator itr = NanoVis::flowTable.begin(); 1578 955 itr != NanoVis::flowTable.end(); ++itr) { 1579 Flow Cmd*flow = itr->second;956 Flow *flow = itr->second; 1580 957 Tcl_Obj *objPtr = Tcl_NewStringObj(flow->name(), -1); 1581 958 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); … … 1668 1045 }; 1669 1046 1670 Rappture::SwitchSpec FlowCmd::videoSwitches[] = {1047 static Rappture::SwitchSpec flowVideoSwitches[] = { 1671 1048 {Rappture::SWITCH_INT, "-bitrate", "value", 1672 1049 offsetof(FlowVideoSwitches, bitRate), 0}, … … 1872 1249 switches.formatObjPtr = Tcl_NewStringObj("mpeg1video", 10); 1873 1250 Tcl_IncrRefCount(switches.formatObjPtr); 1874 if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches,1251 if (Rappture::ParseSwitches(interp, flowVideoSwitches, 1875 1252 objc - 3, objv + 3, &switches, SWITCH_DEFAULTS) < 0) { 1876 1253 return TCL_ERROR; … … 1918 1295 tmpFileName[length] = '\0'; 1919 1296 rmdir(tmpFileName); 1920 Rappture::FreeSwitches( FlowCmd::videoSwitches, &switches, 0);1297 Rappture::FreeSwitches(flowVideoSwitches, &switches, 0); 1921 1298 return result; 1922 1299 } -
nanovis/branches/1.1/FlowCmd.h
r3567 r4612 25 25 #define FLOWCMD_H 26 26 27 #include <tr1/unordered_map>28 #include <vector>29 #include <string>30 31 27 #include <tcl.h> 32 28 33 #include <vrmath/Vector3f.h> 34 35 #include "Switch.h" 36 #include "FlowTypes.h" 37 #include "FlowParticles.h" 38 #include "FlowBox.h" 39 #include "NvLIC.h" 40 #include "NvParticleRenderer.h" 41 #include "NvVectorField.h" 42 #include "Unirect.h" 43 #include "Volume.h" 44 #include "TransferFunction.h" 45 46 struct FlowValues { 47 TransferFunction *transferFunction; 48 FlowPosition slicePos; 49 int showArrows; 50 int sliceVisible; 51 int showVolume; 52 int showOutline; 53 int isHidden; 54 int twoSidedLighting; 55 float ambient; ///< Ambient volume shading 56 float diffuse; ///< Diffuse volume shading 57 float specular; ///< Specular level volume shading 58 float specularExp; ///< Specular exponent volume shading 59 float opacity; ///< Volume opacity scaling 60 }; 61 62 class FlowCmd 63 { 64 public: 65 enum SliceAxis { AXIS_X, AXIS_Y, AXIS_Z }; 66 67 FlowCmd(Tcl_Interp *interp, const char *name); 68 69 ~FlowCmd(); 70 71 void getBounds(vrmath::Vector3f& min, 72 vrmath::Vector3f& max, 73 bool onlyVisible); 74 75 FlowParticles *createParticles(const char *particlesName); 76 77 FlowParticles *getParticles(const char *particlesName); 78 79 void deleteParticles(const char *particlesName); 80 81 void getParticlesNames(std::vector<std::string>& names); 82 83 void render(); 84 85 void advect(); 86 87 void resetParticles(); 88 89 void initializeParticles(); 90 91 FlowBox *createBox(const char *boxName); 92 93 FlowBox *getBox(const char *boxName); 94 95 void deleteBox(const char *boxName); 96 97 void getBoxNames(std::vector<std::string>& names); 98 99 float *getScaledVector(); 100 101 Volume *makeVolume(float *data); 102 103 void initVectorField(); 104 105 NvVectorField *getVectorField() 106 { 107 return _field; 108 } 109 110 bool scaleVectorField(); 111 112 bool visible() 113 { 114 return !_sv.isHidden; 115 } 116 117 const char *name() const 118 { 119 return _name.c_str(); 120 } 121 122 bool isDataLoaded() 123 { 124 return (_data != NULL); 125 } 126 127 Rappture::Unirect3d *data() 128 { 129 return _data; 130 } 131 132 void data(Rappture::Unirect3d *data) 133 { 134 if (_data != NULL) { 135 delete _data; 136 } 137 _data = data; 138 } 139 140 void activateSlice() 141 { 142 /* Must set axis before offset or position goes to wrong axis. */ 143 NanoVis::licRenderer->setAxis(_sv.slicePos.axis); 144 NanoVis::licRenderer->setOffset(_sv.slicePos.value); 145 NanoVis::licRenderer->active(true); 146 } 147 148 void ceactivateSlice() 149 { 150 NanoVis::licRenderer->active(false); 151 } 152 153 SliceAxis getAxis() 154 { 155 return (SliceAxis)_sv.slicePos.axis; 156 } 157 158 TransferFunction *getTransferFunction() 159 { 160 return _sv.transferFunction; 161 } 162 163 float getRelativePosition(); 164 165 void setAxis() 166 { 167 NanoVis::licRenderer->setAxis(_sv.slicePos.axis); 168 } 169 170 void setAxis(FlowCmd::SliceAxis axis) 171 { 172 _sv.slicePos.axis = axis; 173 NanoVis::licRenderer->setAxis(_sv.slicePos.axis); 174 } 175 176 void setCurrentPosition(float position) 177 { 178 _sv.slicePos.value = position; 179 NanoVis::licRenderer->setOffset(_sv.slicePos.value); 180 } 181 182 void setCurrentPosition() 183 { 184 NanoVis::licRenderer->setOffset(_sv.slicePos.value); 185 } 186 187 void setActive(bool state) 188 { 189 _sv.sliceVisible = state; 190 NanoVis::licRenderer->active(state); 191 } 192 193 void setActive() 194 { 195 NanoVis::licRenderer->active(_sv.sliceVisible); 196 } 197 198 void setVectorField(NvVectorField *field) 199 { 200 deleteVectorField(); 201 _field = field; 202 } 203 204 void deleteVectorField() 205 { 206 if (_field != NULL) { 207 delete _field; 208 _field = NULL; 209 } 210 } 211 212 const Volume *getVolume() const 213 { 214 return _volume; 215 } 216 217 int parseSwitches(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) 218 { 219 if (Rappture::ParseSwitches(interp, _switches, objc, objv, &_sv, 220 SWITCH_DEFAULTS) < 0) { 221 return TCL_ERROR; 222 } 223 return TCL_OK; 224 } 225 226 Tcl_Command getCommandToken() 227 { 228 return _cmdToken; 229 } 230 231 static float getRelativePosition(FlowPosition *pos); 232 233 static Rappture::SwitchSpec videoSwitches[]; 234 235 private: 236 typedef std::string ParticlesId; 237 typedef std::string BoxId; 238 typedef std::tr1::unordered_map<ParticlesId, FlowParticles *> ParticlesHashmap; 239 typedef std::tr1::unordered_map<BoxId, FlowBox *> BoxHashmap; 240 241 void configure(); 242 243 void renderBoxes(); 244 245 Tcl_Interp *_interp; 246 /** 247 * Name of the flow. This may differ 248 * from the name of the command 249 * associated with the flow, if the 250 * command was renamed. */ 251 std::string _name; 252 253 /** 254 * Command associated with the flow. 255 * When the command is deleted, so is 256 * the flow. */ 257 Tcl_Command _cmdToken; 258 259 /** 260 * Uniform rectangular data 261 * representing the mesh and vector 262 * field values. These values are 263 * kept to regenerate the volume 264 * associated with the flow. */ 265 Rappture::Unirect3d *_data; 266 267 /** 268 * The volume associated with the 269 * flow. This isn't the same thing as 270 * a normal volume displayed. */ 271 Volume *_volume; 272 273 /** 274 * Vector field generated from the 275 * above volume */ 276 NvVectorField *_field; 277 278 /** 279 * For each field there can be one or 280 * more particle injection planes 281 * where the particles are injected 282 * into the flow. */ 283 ParticlesHashmap _particlesTable; 284 285 /** 286 * A table of boxes. There maybe 287 * zero or more boxes associated 288 * with each field. */ 289 BoxHashmap _boxTable; 290 291 FlowValues _sv; 292 293 static Rappture::SwitchSpec _switches[]; 294 }; 295 296 extern int GetDataStream(Tcl_Interp *interp, Rappture::Buffer &buf, int nBytes); 297 298 extern int GetBooleanFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 299 bool *boolVal); 300 301 extern int GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 302 float *floatVal); 303 304 extern int GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 305 int *axisVal); 306 307 extern int GetVolumeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 308 Volume **volume); 29 extern Tcl_AppInitProc FlowCmdInitProc; 30 extern Tcl_ObjCmdProc FlowInstObjCmd; 31 extern Tcl_CmdDeleteProc FlowInstDeleteProc; 309 32 310 33 #endif -
nanovis/branches/1.1/FlowParticles.cpp
r3567 r4612 16 16 #include "nanovis.h" // For NMESH 17 17 #include "FlowParticles.h" 18 #include "Flow Cmd.h"18 #include "Flow.h" 19 19 #include "Trace.h" 20 20 … … 48 48 TRACE("Particles '%s' axis: %d pos: %g rel pos: %g", 49 49 _name.c_str(), _sv.position.axis, _sv.position.value, 50 Flow Cmd::getRelativePosition(&_sv.position));50 Flow::getRelativePosition(&_sv.position)); 51 51 52 _renderer->setPos(Flow Cmd::getRelativePosition(&_sv.position));52 _renderer->setPos(Flow::getRelativePosition(&_sv.position)); 53 53 _renderer->setAxis(_sv.position.axis); 54 54 assert(_renderer->active()); … … 59 59 FlowParticles::configure() 60 60 { 61 _renderer->setPos(Flow Cmd::getRelativePosition(&_sv.position));61 _renderer->setPos(Flow::getRelativePosition(&_sv.position)); 62 62 _renderer->setColor(Vector4f(_sv.color.r, 63 63 _sv.color.g, -
nanovis/branches/1.1/FlowParticles.h
r3568 r4612 12 12 #define FLOWPARTICLES_H 13 13 14 #include <cassert> 14 15 #include <string> 15 16 -
nanovis/branches/1.1/HeightMap.cpp
r3502 r4612 23 23 24 24 HeightMap::HeightMap() : 25 _vertexBufferObjectID(0), 26 _texcoordBufferObjectID(0), 27 _vertexCount(0), 28 _contour( 0),29 _t fPtr(0),25 _vertexBufferObjectID(0), 26 _texcoordBufferObjectID(0), 27 _vertexCount(0), 28 _contour(NULL), 29 _transferFunc(NULL), 30 30 _opacity(0.5f), 31 _indexBuffer( 0),32 _indexCount(0), 33 _contourColor(1.0f, 0.0f, 0.0f), 34 _contourVisible(false), 31 _indexBuffer(NULL), 32 _indexCount(0), 33 _contourColor(1.0f, 0.0f, 0.0f), 34 _contourVisible(false), 35 35 _visible(false), 36 _scale(1.0f, 1.0f, 1.0f), 36 _scale(1.0f, 1.0f, 1.0f), 37 37 _centerPoint(0.0f, 0.0f, 0.0f), 38 38 _heights(NULL) … … 93 93 glDisableClientState(GL_NORMAL_ARRAY); 94 94 95 if (_t fPtr) {95 if (_transferFunc) { 96 96 // PUT vertex program here 97 97 // 98 98 // 99 99 _shader->bind(); 100 _shader->setFPTextureParameter("tf", _t fPtr->id());100 _shader->setFPTextureParameter("tf", _transferFunc->id()); 101 101 _shader->setFPParameter1f("opacity", _opacity); 102 102 103 103 glEnable(GL_TEXTURE_1D); 104 _t fPtr->getTexture()->activate();104 _transferFunc->getTexture()->activate(); 105 105 106 106 glEnableClientState(GL_TEXTURE_COORD_ARRAY); … … 125 125 126 126 glDisableClientState(GL_VERTEX_ARRAY); 127 if (_t fPtr!= NULL) {128 _t fPtr->getTexture()->deactivate();127 if (_transferFunc != NULL) { 128 _transferFunc->getTexture()->deactivate(); 129 129 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 130 130 … … 384 384 } 385 385 ContourLineFilter lineFilter; 386 //lineFilter.transferFunction(_t fPtr);386 //lineFilter.transferFunction(_transferFunc); 387 387 _contour = lineFilter.create(0.0f, 1.0f, 10, map, xNum, yNum); 388 388 … … 398 398 Vector3f* vertices = new Vector3f[xNum * yNum]; 399 399 400 Vector3f* dstData Ptr= vertices;401 float* srcData Ptr= height;400 Vector3f* dstData = vertices; 401 float* srcData = height; 402 402 403 403 for (int y = 0; y < yNum; ++y) { … … 409 409 410 410 xCoord = xMin + ((xMax - xMin) * x) / (xNum - 1); 411 dstData Ptr->set(xCoord, *srcDataPtr, yCoord);412 413 ++dstData Ptr;414 ++srcData Ptr;411 dstData->set(xCoord, *srcData, yCoord); 412 413 ++dstData; 414 ++srcData; 415 415 } 416 416 } … … 422 422 */ 423 423 void 424 HeightMap::mapToGrid(Grid *grid Ptr)424 HeightMap::mapToGrid(Grid *grid) 425 425 { 426 426 int count = _xNum * _yNum; … … 432 432 // this surface's y-values (heights) into the grid's axis coordinates. 433 433 434 float yScale = 1.0 / (grid Ptr->yAxis.max() - gridPtr->yAxis.min());434 float yScale = 1.0 / (grid->yAxis.max() - grid->yAxis.min()); 435 435 float *p, *q, *pend; 436 436 float *normHeights = new float[count]; 437 437 for (p = _heights, pend = p + count, q = normHeights; p < pend; p++, q++) { 438 *q = (*p - grid Ptr->yAxis.min()) * yScale;438 *q = (*p - grid->yAxis.min()) * yScale; 439 439 } 440 440 Vector3f *t, *texcoord; … … 450 450 float xMin, xMax, zMin, zMax; 451 451 452 xScale = 1.0 / (grid Ptr->xAxis.max() - gridPtr->xAxis.min());453 xMin = (xAxis.min() - grid Ptr->xAxis.min()) * xScale;454 xMax = (xAxis.max() - grid Ptr->xAxis.min()) * xScale;455 zScale = 1.0 / (grid Ptr->zAxis.max() - gridPtr->zAxis.min());456 zMin = (zAxis.min() - grid Ptr->zAxis.min()) * zScale;457 zMax = (zAxis.max() - grid Ptr->zAxis.min()) * zScale;452 xScale = 1.0 / (grid->xAxis.max() - grid->xAxis.min()); 453 xMin = (xAxis.min() - grid->xAxis.min()) * xScale; 454 xMax = (xAxis.max() - grid->xAxis.min()) * xScale; 455 zScale = 1.0 / (grid->zAxis.max() - grid->zAxis.min()); 456 zMin = (zAxis.min() - grid->zAxis.min()) * zScale; 457 zMax = (zAxis.max() - grid->zAxis.min()) * zScale; 458 458 459 459 Vector3f* vertices; … … 477 477 } 478 478 ContourLineFilter lineFilter; 479 //lineFilter.transferFunction(_t fPtr);479 //lineFilter.transferFunction(_transferFunc); 480 480 _contour = lineFilter.create(0.0f, 1.0f, 10, vertices, _xNum, _yNum); 481 481 -
nanovis/branches/1.1/HeightMap.h
r3502 r4612 49 49 void setHeight(int xCount, int yCount, vrmath::Vector3f *heights); 50 50 #endif 51 void mapToGrid(Grid *grid Ptr);51 void mapToGrid(Grid *grid); 52 52 53 53 /** 54 54 *@brief Define a color map for color shading of heightmap 55 55 */ 56 void transferFunction(TransferFunction *t fPtr)56 void transferFunction(TransferFunction *transferFunc) 57 57 { 58 _t fPtr = tfPtr;58 _transferFunc = transferFunc; 59 59 } 60 60 … … 64 64 TransferFunction *transferFunction() 65 65 { 66 return _t fPtr;66 return _transferFunc; 67 67 } 68 68 … … 128 128 int _vertexCount; 129 129 nv::graphics::Geometry *_contour; 130 TransferFunction *_t fPtr;130 TransferFunction *_transferFunc; 131 131 float _opacity; 132 132 NvShader *_shader; -
nanovis/branches/1.1/Makefile.in
r4611 r4612 111 111 ContourLineFilter.o \ 112 112 ConvexPolygon.o \ 113 Flow.o \ 113 114 FlowBox.o \ 114 115 FlowCmd.o \ … … 125 126 NvShader.o \ 126 127 NvStdVertexShader.o \ 127 NvVectorField.o \128 128 NvVolumeShader.o \ 129 129 NvZincBlendeReconstructor.o \ … … 174 174 175 175 ifdef NOTDEF 176 OBJS += NvFlowVisRenderer.o \ 177 ParticleEmitter.o \ 176 OBJS += ParticleEmitter.o \ 178 177 ParticleSystem.o \ 179 178 ParticleSystemFactory.o … … 274 273 Chain.o: Chain.cpp Chain.h 275 274 CmdProc.o: CmdProc.cpp CmdProc.h 276 Command.o: Command.cpp nanovis.h $(AUXSRC) CmdProc.h Trace.h PlaneRenderer.h PointSet.h dxReader.h Grid.h HeightMap.h NvCamera.h NvZincBlendeReconstructor.h Unirect.h Volume.h VolumeRenderer.h275 Command.o: Command.cpp nanovis.h $(AUXSRC) FlowCmd.h CmdProc.h Trace.h PlaneRenderer.h PointSet.h dxReader.h Grid.h HeightMap.h NvCamera.h NvZincBlendeReconstructor.h Unirect.h Volume.h VolumeRenderer.h 277 276 ContourLineFilter.o: ContourLineFilter.cpp ContourLineFilter.h 278 277 ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h $(VRMATH_DIR)/include/vrmath/Vector4f.h $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h Plane.h 278 Flow.o: Flow.h FlowCmd.h FlowTypes.h FlowBox.h FlowParticles.h Switch.h Trace.h 279 279 FlowBox.o: FlowBox.h FlowTypes.h Switch.h Trace.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h $(VRMATH_DIR)/include/vrmath/Vector4f.h $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h 280 FlowCmd.o: FlowCmd.cpp FlowCmd.h FlowParticles.h FlowBox.h FlowTypes.h Switch.h Trace.h TransferFunction.h nanovis.h CmdProc.h NvLIC.h Unirect.h Volume.h VelocityArrowsSlice.h $(VRMATH_DIR)/include/vrmath/Vector3f.h280 FlowCmd.o: FlowCmd.cpp FlowCmd.h FlowParticles.h FlowBox.h FlowTypes.h Command.h Switch.h Trace.h TransferFunction.h nanovis.h CmdProc.h NvLIC.h Unirect.h Volume.h VelocityArrowsSlice.h $(VRMATH_DIR)/include/vrmath/Vector3f.h 281 281 FlowParticles.o: FlowParticles.h FlowTypes.h FlowCmd.h Switch.h Trace.h NvParticleRenderer.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h $(VRMATH_DIR)/include/vrmath/Vector4f.h 282 282 GradientFilter.o: GradientFilter.cpp GradientFilter.h … … 285 285 NvCamera.o: NvCamera.cpp NvCamera.h config.h $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h 286 286 NvColorTableShader.o: NvColorTableShader.cpp NvColorTableShader.h NvShader.h 287 NvFlowVisRenderer.o: NvFlowVisRenderer.cpp NvFlowVisRenderer.h288 287 NvLIC.o: NvLIC.cpp NvLIC.h 289 288 NvParticleAdvectionShader.o: NvParticleAdvectionShader.cpp NvParticleAdvectionShader.h NvShader.h … … 292 291 NvShader.o: NvShader.cpp NvShader.h 293 292 NvStdVertexShader.o: NvStdVertexShader.cpp NvStdVertexShader.h NvShader.h 294 NvVectorField.o: NvVectorField.cpp NvVectorField.h NvParticleRenderer.h295 293 NvVolumeShader.o: NvVolumeShader.cpp NvVolumeShader.h NvShader.h 296 294 NvZincBlendeReconstructor.o: NvZincBlendeReconstructor.cpp NvZincBlendeReconstructor.h ZincBlendeVolume.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h … … 314 312 Trace.o: Trace.cpp Trace.h 315 313 TransferFunction.o: TransferFunction.cpp 316 Unirect.o: Unirect.cpp Unirect.h Trace.h314 Unirect.o: Unirect.cpp Unirect.h Command.h Trace.h 317 315 VelocityArrowsSlice.o: VelocityArrowsSlice.cpp VelocityArrowsSlice.h 318 316 Volume.o: Volume.cpp Volume.h $(AUXSRC) … … 322 320 ZincBlendeVolume.o: ZincBlendeVolume.cpp ZincBlendeVolume.h $(AUXSRC) 323 321 dxReader.o: dxReader.cpp ReaderCommon.h config.h nanovis.h Unirect.h ZincBlendeVolume.h NvZincBlendeReconstructor.h 324 nanovis.o: nanovis.cpp nanovis.h $(AUXSRC) FlowCmd.h Grid.h HeightMap.h NvCamera.h NvFlowVisRenderer.h NvLIC.h NvZincBlendeReconstructor.h PerfQuery.h PlaneRenderer.h PointSetRenderer.h PointSet.h Switch.h Trace.h Unirect.h VelocityArrowsSlice.h VolumeInterpolator.h VolumeRenderer.h ZincBlendeVolume.h Axis.h Chain.h322 nanovis.o: nanovis.cpp nanovis.h $(AUXSRC) Command.h Flow.h Grid.h HeightMap.h NvCamera.h NvLIC.h NvZincBlendeReconstructor.h PerfQuery.h PlaneRenderer.h PointSetRenderer.h PointSet.h Switch.h Trace.h Unirect.h VelocityArrowsSlice.h VolumeInterpolator.h VolumeRenderer.h ZincBlendeVolume.h Axis.h Chain.h 325 323 md5.o: md5.h -
nanovis/branches/1.1/PlaneRenderer.cpp
r3502 r4612 37 37 38 38 int 39 PlaneRenderer::addPlane(Texture2D *p , TransferFunction *tfPtr)39 PlaneRenderer::addPlane(Texture2D *planeTexture, TransferFunction *tf) 40 40 { 41 41 int ret = _numPlanes; 42 42 43 _plane.push_back(p );44 _tf.push_back(tf Ptr);43 _plane.push_back(planeTexture); 44 _tf.push_back(tf); 45 45 46 46 if (ret == 0) -
nanovis/branches/1.1/Trace.cpp
r3559 r4612 45 45 46 46 bool 47 CheckFBO(GLenum *status Ptr)47 CheckFBO(GLenum *status) 48 48 { 49 *status Ptr= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);50 return (*status Ptr== GL_FRAMEBUFFER_COMPLETE_EXT);49 *status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); 50 return (*status == GL_FRAMEBUFFER_COMPLETE_EXT); 51 51 } 52 52 -
nanovis/branches/1.1/Trace.h
r3452 r4612 30 30 #define INFO(...) LogMessage(LOG_INFO, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) 31 31 32 extern bool CheckFBO(GLenum *status Ptr);32 extern bool CheckFBO(GLenum *status); 33 33 extern void PrintFBOStatus(GLenum status, const char *prefix); 34 34 extern bool CheckGL(const char *prefix); -
nanovis/branches/1.1/Unirect.cpp
r3559 r4612 6 6 */ 7 7 #include <float.h> 8 8 9 #include <tcl.h> 9 10 … … 11 12 #include <RpFieldRect3D.h> 12 13 14 #include "Command.h" 13 15 #include "Unirect.h" 14 16 #include "Trace.h" 15 16 extern int GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,17 float *valuePtr);18 19 extern int GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr);20 17 21 18 static inline char * -
nanovis/branches/1.1/Volume.cpp
r3567 r4612 38 38 _height(h), 39 39 _depth(d), 40 _t fPtr(NULL),40 _transferFunc(NULL), 41 41 _ambient(0.6f), 42 42 _diffuse(0.4f), -
nanovis/branches/1.1/Volume.h
r3567 r4612 277 277 TransferFunction *transferFunction() 278 278 { 279 return _t fPtr;280 } 281 282 void transferFunction(TransferFunction *t fPtr)283 { 284 _t fPtr = tfPtr;279 return _transferFunc; 280 } 281 282 void transferFunction(TransferFunction *transferFunc) 283 { 284 _transferFunc = transferFunc; 285 285 } 286 286 … … 366 366 * render this volume. 367 367 */ 368 TransferFunction *_t fPtr;368 TransferFunction *_transferFunc; 369 369 370 370 float _ambient; ///< Ambient material coefficient -
nanovis/branches/1.1/VolumeInterpolator.cpp
r3502 r4612 125 125 126 126 void 127 VolumeInterpolator::addVolume(Volume * refPtr)127 VolumeInterpolator::addVolume(Volume *volume) 128 128 { 129 129 if (_volumes.size() != 0) { 130 if (_volumes[0]->width() != refPtr->width() ||131 _volumes[0]->height() != refPtr->height() ||132 _volumes[0]->depth() != refPtr->depth() ||133 _volumes[0]->numComponents() != refPtr->numComponents()) {130 if (_volumes[0]->width() != volume->width() || 131 _volumes[0]->height() != volume->height() || 132 _volumes[0]->depth() != volume->depth() || 133 _volumes[0]->numComponents() != volume->numComponents()) { 134 134 TRACE("The volume should be the same width, height, number of components"); 135 135 return; 136 136 } 137 137 } else { 138 _dataCount = refPtr->width() * refPtr->height() * refPtr->depth();139 _numComponents = refPtr->numComponents();138 _dataCount = volume->width() * volume->height() * volume->depth(); 139 _numComponents = volume->numComponents(); 140 140 _numBytes = _dataCount * _numComponents * sizeof(float); 141 Vector3f loc = refPtr->location();141 Vector3f loc = volume->location(); 142 142 _volume = new Volume(loc.x, loc.y, loc.z, 143 refPtr->width(),144 refPtr->height(),145 refPtr->depth(),146 refPtr->numComponents(),147 refPtr->data(),148 refPtr->wAxis.min(),149 refPtr->wAxis.max(),150 refPtr->nonZeroMin());143 volume->width(), 144 volume->height(), 145 volume->depth(), 146 volume->numComponents(), 147 volume->data(), 148 volume->wAxis.min(), 149 volume->wAxis.max(), 150 volume->nonZeroMin()); 151 151 152 152 _volume->numSlices(256-1); … … 156 156 _volume->visible(true); 157 157 _volume->dataEnabled(true); 158 _volume->ambient( refPtr->ambient());159 _volume->diffuse( refPtr->diffuse());160 _volume->specularLevel( refPtr->specularLevel());161 _volume->specularExponent( refPtr->specularExponent());162 _volume->opacityScale( refPtr->opacityScale());158 _volume->ambient(volume->ambient()); 159 _volume->diffuse(volume->diffuse()); 160 _volume->specularLevel(volume->specularLevel()); 161 _volume->specularExponent(volume->specularExponent()); 162 _volume->opacityScale(volume->opacityScale()); 163 163 _volume->isosurface(0); 164 164 TRACE("VOL : location %f %f %f\n\tid : %s", loc.x, loc.y, loc.z, 165 refPtr->name());165 volume->name()); 166 166 } 167 167 _volumes.push_back(_volume); 168 TRACE("a Volume[%s] is added to VolumeInterpolator", refPtr->name());168 TRACE("a Volume[%s] is added to VolumeInterpolator", volume->name()); 169 169 } 170 170 -
nanovis/branches/1.1/VolumeRenderer.cpp
r3567 r4612 132 132 TRACE("start loop %d", volumes.size()); 133 133 for (size_t i = 0; i < volumes.size(); i++) { 134 Volume *vol Ptr= volumes[i];134 Volume *volume = volumes[i]; 135 135 polys[i] = NULL; 136 136 actual_slices[i] = 0; 137 137 138 int n_slices = vol Ptr->numSlices();139 if (vol Ptr->isosurface()) {138 int n_slices = volume->numSlices(); 139 if (volume->isosurface()) { 140 140 // double the number of slices 141 141 n_slices <<= 1; … … 143 143 144 144 //volume start location 145 Vector3f volPos = vol Ptr->location();146 Vector3f volScaling = vol Ptr->getPhysicalScaling();145 Vector3f volPos = volume->location(); 146 Vector3f volScaling = volume->getPhysicalScaling(); 147 147 148 148 TRACE("VOL POS: %g %g %g", … … 196 196 //draw volume bounding box with translation (the correct location in 197 197 //space) 198 if (vol Ptr->outline()) {198 if (volume->outline()) { 199 199 float olcolor[3]; 200 vol Ptr->getOutlineColor(olcolor);200 volume->getOutlineColor(olcolor); 201 201 drawBoundingBox(x0, y0, z0, x0+1, y0+1, z0+1, 202 202 (double)olcolor[0], (double)olcolor[1], (double)olcolor[2], … … 222 222 size_t n_actual_slices; 223 223 224 if (vol Ptr->dataEnabled()) {224 if (volume->dataEnabled()) { 225 225 if (z_step == 0.0f) 226 226 n_actual_slices = 1; … … 244 244 // vice versa. 245 245 246 for (int j = 0; j < vol Ptr->getCutplaneCount(); j++) {247 if (!vol Ptr->isCutplaneEnabled(j)) {246 for (int j = 0; j < volume->getCutplaneCount(); j++) { 247 if (!volume->isCutplaneEnabled(j)) { 248 248 continue; 249 249 } 250 float offset = vol Ptr->getCutplane(j)->offset;251 int axis = vol Ptr->getCutplane(j)->orient;250 float offset = volume->getCutplane(j)->offset; 251 int axis = volume->getCutplane(j)->orient; 252 252 253 253 switch (axis) { … … 279 279 280 280 _cutplaneShader->bind(); 281 _cutplaneShader->setFPTextureParameter("volume", vol Ptr->textureID());282 _cutplaneShader->setFPTextureParameter("tf", vol Ptr->transferFunction()->id());281 _cutplaneShader->setFPTextureParameter("volume", volume->textureID()); 282 _cutplaneShader->setFPTextureParameter("tf", volume->transferFunction()->id()); 283 283 284 284 glPushMatrix(); … … 383 383 384 384 for (size_t i = 0; i < total_rendered_slices; i++) { 385 Volume *vol Ptr= NULL;385 Volume *volume = NULL; 386 386 387 387 int volume_index = slices[i].volumeId; … … 390 390 float z_step = z_steps[volume_index]; 391 391 392 vol Ptr= volumes[volume_index];393 394 Vector3f volScaling = vol Ptr->getPhysicalScaling();392 volume = volumes[volume_index]; 393 394 Vector3f volScaling = volume->getPhysicalScaling(); 395 395 396 396 glPushMatrix(); … … 398 398 399 399 // FIXME: compute view-dependent volume sample distance 400 double avgSampleDistance = 1.0 / pow(vol Ptr->width() * volScaling.x *401 vol Ptr->height() * volScaling.y *402 vol Ptr->depth() * volScaling.z, 1.0/3.0);400 double avgSampleDistance = 1.0 / pow(volume->width() * volScaling.x * 401 volume->height() * volScaling.y * 402 volume->depth() * volScaling.z, 1.0/3.0); 403 403 float sampleRatio = z_step / avgSampleDistance; 404 404 405 405 #ifdef notdef 406 406 TRACE("shading slice: volume %s addr=%x slice=%d, volume=%d z_step=%g avgSD=%g", 407 vol Ptr->name(), volPtr, slice_index, volume_index, z_step, avgSampleDistance);407 volume->name(), volume, slice_index, volume_index, z_step, avgSampleDistance); 408 408 #endif 409 activateVolumeShader(vol Ptr, false, sampleRatio);409 activateVolumeShader(volume, false, sampleRatio); 410 410 glPopMatrix(); 411 411 … … 493 493 494 494 void 495 VolumeRenderer::activateVolumeShader(Volume *vol Ptr, bool sliceMode,495 VolumeRenderer::activateVolumeShader(Volume *volume, bool sliceMode, 496 496 float sampleRatio) 497 497 { 498 498 //vertex shader 499 499 _stdVertexShader->bind(); 500 TransferFunction *t fPtr = volPtr->transferFunction();501 if (vol Ptr->volumeType() == Volume::CUBIC) {502 _regularVolumeShader->bind(t fPtr->id(), volPtr, sliceMode, sampleRatio);503 } else if (vol Ptr->volumeType() == Volume::ZINCBLENDE) {504 _zincBlendeShader->bind(t fPtr->id(), volPtr, sliceMode, sampleRatio);500 TransferFunction *transferFunc = volume->transferFunction(); 501 if (volume->volumeType() == Volume::CUBIC) { 502 _regularVolumeShader->bind(transferFunc->id(), volume, sliceMode, sampleRatio); 503 } else if (volume->volumeType() == Volume::ZINCBLENDE) { 504 _zincBlendeShader->bind(transferFunc->id(), volume, sliceMode, sampleRatio); 505 505 } 506 506 } -
nanovis/branches/1.1/VtkReader.cpp
r3576 r4612 342 342 lz = (nz - 1) * dz; 343 343 344 Volume *vol Ptr= NULL;344 Volume *volume = NULL; 345 345 double vmin = DBL_MAX; 346 346 double nzero_min = DBL_MAX; … … 477 477 vmin, vmax, nzero_min); 478 478 479 vol Ptr= NanoVis::loadVolume(tag, nx, ny, nz, 4, data,479 volume = NanoVis::loadVolume(tag, nx, ny, nz, 4, data, 480 480 vmin, vmax, nzero_min); 481 vol Ptr->xAxis.setRange(x0, x0 + lx);482 vol Ptr->yAxis.setRange(y0, y0 + ly);483 vol Ptr->zAxis.setRange(z0, z0 + lz);484 vol Ptr->updatePending = true;481 volume->xAxis.setRange(x0, x0 + lx); 482 volume->yAxis.setRange(y0, y0 + ly); 483 volume->zAxis.setRange(z0, z0 + lz); 484 volume->updatePending = true; 485 485 486 486 delete [] data; … … 492 492 float dy0 = -0.5*ly/lx; 493 493 float dz0 = -0.5*lz/lx; 494 if (vol Ptr) {495 vol Ptr->location(vrmath::Vector3f(dx0, dy0, dz0));494 if (volume) { 495 volume->location(vrmath::Vector3f(dx0, dy0, dz0)); 496 496 TRACE("Set volume location to %g %g %g", dx0, dy0, dz0); 497 497 } 498 return vol Ptr;499 } 498 return volume; 499 } -
nanovis/branches/1.1/dxReader.cpp
r3576 r4612 225 225 return NULL; 226 226 } 227 Volume *vol Ptr= NULL;227 Volume *volume = NULL; 228 228 float *data = NULL; 229 229 double vmin = DBL_MAX; … … 481 481 vmin, vmax, nzero_min); 482 482 483 vol Ptr= NanoVis::loadVolume(tag, nx, ny, nz, 4, data,483 volume = NanoVis::loadVolume(tag, nx, ny, nz, 4, data, 484 484 vmin, vmax, nzero_min); 485 vol Ptr->xAxis.setRange(x0, x0 + lx);486 vol Ptr->yAxis.setRange(y0, y0 + ly);487 vol Ptr->zAxis.setRange(z0, z0 + lz);488 vol Ptr->updatePending = true;485 volume->xAxis.setRange(x0, x0 + lx); 486 volume->yAxis.setRange(y0, y0 + ly); 487 volume->zAxis.setRange(z0, z0 + lz); 488 volume->updatePending = true; 489 489 490 490 // TBD.. 491 491 #if 0 && defined(USE_POINTSET_RENDERER) 492 492 PointSet *pset = new PointSet(); 493 pset->initialize(vol Ptr, (float*)data);493 pset->initialize(volume, (float*)data); 494 494 pset->setVisible(true); 495 495 NanoVis::pointSet.push_back(pset); 496 496 updateColor(pset); 497 vol Ptr->pointsetIndex = NanoVis::pointSet.size() - 1;497 volume->pointsetIndex = NanoVis::pointSet.size() - 1; 498 498 #endif 499 499 delete [] data; … … 505 505 float dy0 = -0.5*ly/lx; 506 506 float dz0 = -0.5*lz/lx; 507 if (vol Ptr) {508 vol Ptr->location(vrmath::Vector3f(dx0, dy0, dz0));507 if (volume) { 508 volume->location(vrmath::Vector3f(dx0, dy0, dz0)); 509 509 TRACE("Set volume location to %g %g %g", dx0, dy0, dz0); 510 510 } 511 return vol Ptr;511 return volume; 512 512 } -
nanovis/branches/1.1/nanovis.cpp
r4611 r4612 59 59 #include "define.h" 60 60 61 #include "FlowCmd.h" 61 #include "Command.h" 62 #include "Flow.h" 62 63 #include "Grid.h" 63 64 #include "HeightMap.h" 64 65 #include "NvCamera.h" 65 66 #include "NvShader.h" 66 #include "NvFlowVisRenderer.h"67 67 #include "NvLIC.h" 68 68 #include "NvZincBlendeReconstructor.h" … … 82 82 using namespace nv::graphics; 83 83 using namespace nv::util; 84 using namespace vrmath; 84 85 85 86 #define SIZEOF_BMP_HEADER 54 … … 141 142 float NanoVis::wMin = FLT_MAX; 142 143 float NanoVis::wMax = -FLT_MAX; 143 vrmath::Vector3f NanoVis::sceneMin, NanoVis::sceneMax;144 Vector3f NanoVis::sceneMin, NanoVis::sceneMax; 144 145 145 146 VolumeRenderer *NanoVis::volRenderer = NULL; 146 #ifdef notdef147 NvFlowVisRenderer *NanoVis::flowVisRenderer = NULL;148 #endif149 147 VelocityArrowsSlice *NanoVis::velocityArrowsSlice = NULL; 150 148 NvLIC *NanoVis::licRenderer = NULL; … … 167 165 GLuint NanoVis::_finalDepthRb = 0; 168 166 169 // in Command.cpp170 extern Tcl_Interp *initTcl();171 172 167 // Default camera location. 173 168 float def_eye_x = 0.0f; … … 199 194 delete legendTexture; 200 195 } 201 #ifdef notdef202 if (flowVisRenderer != NULL) {203 TRACE("Deleting flowVisRenderer");204 delete flowVisRenderer;205 }206 #endif207 196 TRACE("Deleting flows"); 208 197 deleteFlows(interp); … … 570 559 /** \brief Load a 3D volume 571 560 * 572 * \param n_component the number of scalars for each space point. All component 561 * \param name Volume ID 562 * \param width Number of samples in X direction 563 * \param height Number of samples in Y direction 564 * \param depth Number of samples in Z direction 565 * \param numComponents the number of scalars for each space point. All component 573 566 * scalars for a point are placed consequtively in data array 574 567 * width, height and depth: number of points in each dimension 568 * \param data Array of floats 569 * \param vmin Min value of field 570 * \param vmax Max value of field 571 * \param nonZeroMin Minimum non-zero value of field 575 572 * \param data pointer to an array of floats. 576 573 */ 577 574 Volume * 578 575 NanoVis::loadVolume(const char *name, int width, int height, int depth, 579 int n _component, float *data, double vmin, double vmax,580 double n zero_min)576 int numComponents, float *data, double vmin, double vmax, 577 double nonZeroMin) 581 578 { 582 579 VolumeHashmap::iterator itr = volumeTable.find(name); … … 588 585 Volume *volume = new Volume(0.f, 0.f, 0.f, 589 586 width, height, depth, 590 n _component,591 data, vmin, vmax, n zero_min);587 numComponents, 588 data, vmin, vmax, nonZeroMin); 592 589 Volume::updatePending = true; 593 590 volume->name(name); … … 884 881 fonts->setFont("verdana"); 885 882 886 #ifdef notdef887 flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH);888 #endif889 883 velocityArrowsSlice = new VelocityArrowsSlice; 890 891 884 licRenderer = new NvLIC(NMESH, NPIX, NPIX, _licAxis, _licSlice); 892 885 … … 936 929 initOffscreenBuffer(); //frame buffer object for offscreen rendering 937 930 938 //create volume renderer and add volumes to it931 //create volume renderer 939 932 volRenderer = new VolumeRenderer(); 940 933 … … 949 942 TRACE("leaving initGL"); 950 943 } 951 952 #ifdef DO_RLE953 char rle[512*512*3];954 int rleSize;955 956 short offsets[512*512*3];957 int offsetsSize;958 959 static void960 doRle()961 {962 int len = NanoVis::winWidth*NanoVis::winHeight*3;963 rleSize = 0;964 offsetsSize = 0;965 966 int i = 0;967 while (i < len) {968 if (NanoVis::screenBuffer[i] == 0) {969 int pos = i+1;970 while ( (pos < len) && (NanoVis::screenBuffer[pos] == 0)) {971 pos++;972 }973 offsets[offsetsSize++] = -(pos - i);974 i = pos;975 }976 977 else {978 int pos;979 for (pos = i; (pos < len) && (NanoVis::screenBuffer[pos] != 0); pos++){980 rle[rleSize++] = NanoVis::screenBuffer[pos];981 }982 offsets[offsetsSize++] = (pos - i);983 i = pos;984 }985 986 }987 }988 #endif989 944 990 945 // used internally to build up the BMP file header … … 1525 1480 continue; 1526 1481 1527 vrmath::Vector3f bmin, bmax;1482 Vector3f bmin, bmax; 1528 1483 volume->getWorldSpaceBounds(bmin, bmax); 1529 1484 if (bmin.x > bmax.x) … … 1557 1512 continue; 1558 1513 1559 vrmath::Vector3f bmin, bmax;1514 Vector3f bmin, bmax; 1560 1515 heightMap->getWorldSpaceBounds(bmin, bmax); 1561 1516 if (bmin.x > bmax.x) … … 1582 1537 } 1583 1538 1584 vrmath::Vector3f flowMin, flowMax;1539 Vector3f flowMin, flowMax; 1585 1540 getFlowBounds(flowMin, flowMax, onlyVisible); 1586 1541 if (flowMin.x < flowMax.x) { … … 1622 1577 TRACE("Setting bgcolor to %g %g %g", color[0], color[1], color[2]); 1623 1578 glClearColor(color[0], color[1], color[2], 1); 1579 } 1580 1581 Flow * 1582 NanoVis::getFlow(const char *name) 1583 { 1584 FlowHashmap::iterator itr = flowTable.find(name); 1585 if (itr == flowTable.end()) { 1586 TRACE("Can't find flow '%s'", name); 1587 return NULL; 1588 } 1589 return itr->second; 1590 } 1591 1592 Flow * 1593 NanoVis::createFlow(Tcl_Interp *interp, const char *name) 1594 { 1595 FlowHashmap::iterator itr = flowTable.find(name); 1596 if (itr != flowTable.end()) { 1597 ERROR("Flow '%s' already exists", name); 1598 return NULL; 1599 } 1600 Flow *flow = new Flow(interp, name); 1601 flowTable[name] = flow; 1602 return flow; 1603 } 1604 1605 /** 1606 * \brief Delete flow object and hash table entry 1607 * 1608 * This is called by the flow command instance delete callback 1609 */ 1610 void 1611 NanoVis::deleteFlow(const char *name) 1612 { 1613 FlowHashmap::iterator itr = flowTable.find(name); 1614 if (itr != flowTable.end()) { 1615 delete itr->second; 1616 flowTable.erase(itr); 1617 } 1618 } 1619 1620 /** 1621 * \brief Delete all flow object commands 1622 * 1623 * This will also delete the flow objects and hash table entries 1624 */ 1625 void 1626 NanoVis::deleteFlows(Tcl_Interp *interp) 1627 { 1628 FlowHashmap::iterator itr; 1629 for (itr = flowTable.begin(); 1630 itr != flowTable.end(); ++itr) { 1631 Tcl_DeleteCommandFromToken(interp, itr->second->getCommandToken()); 1632 } 1633 flowTable.clear(); 1634 } 1635 1636 bool 1637 NanoVis::mapFlows() 1638 { 1639 TRACE("Enter"); 1640 1641 flags &= ~MAP_FLOWS; 1642 1643 /* 1644 * Step 1. Get the overall min and max magnitudes of all the 1645 * flow vectors. 1646 */ 1647 magMin = DBL_MAX, magMax = -DBL_MAX; 1648 1649 for (FlowHashmap::iterator itr = flowTable.begin(); 1650 itr != flowTable.end(); ++itr) { 1651 Flow *flow = itr->second; 1652 double min, max; 1653 if (!flow->isDataLoaded()) { 1654 continue; 1655 } 1656 Rappture::Unirect3d *data = flow->data(); 1657 min = data->magMin(); 1658 max = data->magMax(); 1659 if (min < magMin) { 1660 magMin = min; 1661 } 1662 if (max > magMax) { 1663 magMax = max; 1664 } 1665 if (data->xMin() < xMin) { 1666 xMin = data->xMin(); 1667 } 1668 if (data->yMin() < yMin) { 1669 yMin = data->yMin(); 1670 } 1671 if (data->zMin() < zMin) { 1672 zMin = data->zMin(); 1673 } 1674 if (data->xMax() > xMax) { 1675 xMax = data->xMax(); 1676 } 1677 if (data->yMax() > yMax) { 1678 yMax = data->yMax(); 1679 } 1680 if (data->zMax() > zMax) { 1681 zMax = data->zMax(); 1682 } 1683 } 1684 1685 TRACE("magMin=%g magMax=%g", NanoVis::magMin, NanoVis::magMax); 1686 1687 /* 1688 * Step 2. Generate the vector field from each data set. 1689 */ 1690 for (FlowHashmap::iterator itr = flowTable.begin(); 1691 itr != flowTable.end(); ++itr) { 1692 Flow *flow = itr->second; 1693 if (!flow->isDataLoaded()) { 1694 continue; // Flow exists, but no data has been loaded yet. 1695 } 1696 if (flow->visible()) { 1697 flow->initializeParticles(); 1698 } 1699 if (!flow->scaleVectorField()) { 1700 return false; 1701 } 1702 // FIXME: This doesn't work when there is more than one flow. 1703 licRenderer->setOffset(flow->getRelativePosition()); 1704 velocityArrowsSlice->slicePos(flow->getRelativePosition()); 1705 } 1706 advectFlows(); 1707 return true; 1708 } 1709 1710 void 1711 NanoVis::getFlowBounds(Vector3f& min, 1712 Vector3f& max, 1713 bool onlyVisible) 1714 { 1715 TRACE("Enter"); 1716 1717 min.set(FLT_MAX, FLT_MAX, FLT_MAX); 1718 max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX); 1719 1720 for (FlowHashmap::iterator itr = flowTable.begin(); 1721 itr != flowTable.end(); ++itr) { 1722 itr->second->getBounds(min, max, onlyVisible); 1723 } 1724 } 1725 1726 void 1727 NanoVis::renderFlows() 1728 { 1729 for (FlowHashmap::iterator itr = flowTable.begin(); 1730 itr != flowTable.end(); ++itr) { 1731 Flow *flow = itr->second; 1732 if (flow->isDataLoaded() && flow->visible()) { 1733 flow->render(); 1734 } 1735 } 1736 flags &= ~REDRAW_PENDING; 1737 } 1738 1739 void 1740 NanoVis::resetFlows() 1741 { 1742 if (licRenderer->active()) { 1743 NanoVis::licRenderer->reset(); 1744 } 1745 for (FlowHashmap::iterator itr = flowTable.begin(); 1746 itr != flowTable.end(); ++itr) { 1747 Flow *flow = itr->second; 1748 if (flow->isDataLoaded() && flow->visible()) { 1749 flow->resetParticles(); 1750 } 1751 } 1752 } 1753 1754 void 1755 NanoVis::advectFlows() 1756 { 1757 for (FlowHashmap::iterator itr = flowTable.begin(); 1758 itr != flowTable.end(); ++itr) { 1759 Flow *flow = itr->second; 1760 if (flow->isDataLoaded() && flow->visible()) { 1761 flow->advect(); 1762 } 1763 } 1624 1764 } 1625 1765 … … 1652 1792 bindOffscreenBuffer(); 1653 1793 1654 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//clear screen1655 1656 //3D rendering mode 1794 //clear screen 1795 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1796 1657 1797 glEnable(GL_DEPTH_TEST); 1658 1798 glEnable(GL_COLOR_MATERIAL); … … 1701 1841 velocityArrowsSlice->render(); 1702 1842 } 1703 #ifdef notdef1704 if ((flowVisRenderer != NULL) && (flowVisRenderer->active())) {1705 flowVisRenderer->render();1706 }1707 #endif1708 1843 if (!flowTable.empty()) { 1709 1844 renderFlows(); … … 1826 1961 exitService(90); 1827 1962 } 1828 #ifdef DO_RLE 1829 doRle(); 1830 int sizes[2] = { offsets_size*sizeof(offsets[0]), rle_size }; 1831 TRACE("Writing %d,%d", sizes[0], sizes[1]); 1832 write(1, &sizes, sizeof(sizes)); 1833 write(1, offsets, offsets_size*sizeof(offsets[0])); 1834 write(1, rle, rle_size); //unsigned byte 1835 #else 1963 1836 1964 ppmWrite("nv>image -type image -bytes"); 1837 #endif 1965 1838 1966 TRACE("Leave"); 1839 1967 } -
nanovis/branches/1.1/nanovis.h
r4611 r4612 51 51 class PointSetRenderer; 52 52 class NvParticleRenderer; 53 class NvFlowVisRenderer;54 53 class PlaneRenderer; 55 54 class VelocityArrowsSlice; … … 58 57 class Texture2D; 59 58 class HeightMap; 60 class NvVectorField;61 59 class Grid; 62 60 class NvCamera; 63 61 class TransferFunction; 64 62 class Volume; 65 class Flow Cmd;63 class Flow; 66 64 67 65 class NanoVis … … 88 86 typedef std::tr1::unordered_map<TransferFunctionId, TransferFunction *> TransferFunctionHashmap; 89 87 typedef std::tr1::unordered_map<VolumeId, Volume *> VolumeHashmap; 90 typedef std::tr1::unordered_map<FlowId, Flow Cmd*> FlowHashmap;88 typedef std::tr1::unordered_map<FlowId, Flow *> FlowHashmap; 91 89 typedef std::tr1::unordered_map<HeightMapId, HeightMap *> HeightMapHashmap; 92 90 … … 134 132 135 133 static Volume *loadVolume(const char *tag, int width, int height, int depth, 136 int n , float*data, double vmin, double vmax,134 int numComponents, float *data, double vmin, double vmax, 137 135 double nonZeroMin); 138 136 139 static void removeVolume(Volume *vol Ptr);137 static void removeVolume(Volume *volume); 140 138 141 139 static void readScreen() … … 149 147 } 150 148 151 static Flow Cmd*getFlow(const char *name);152 static Flow Cmd*createFlow(Tcl_Interp *interp, const char *name);149 static Flow *getFlow(const char *name); 150 static Flow *createFlow(Tcl_Interp *interp, const char *name); 153 151 static void deleteFlow(const char *name); 154 152 static void deleteFlows(Tcl_Interp *interp); … … 190 188 191 189 static VolumeRenderer *volRenderer; 192 #ifdef notdef193 static NvFlowVisRenderer *flowVisRenderer;194 #endif195 190 static VelocityArrowsSlice *velocityArrowsSlice; 196 191 static NvLIC *licRenderer;
Note: See TracChangeset
for help on using the changeset viewer.