Ignore:
Timestamp:
Aug 2, 2014 11:06:20 AM (10 years ago)
Author:
ldelgass
Message:

merge r3597 from trunk

Location:
nanovis/branches/1.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nanovis/branches/1.1

  • nanovis/branches/1.1/FlowCmd.cpp

    r3584 r4612  
    1616#include <unistd.h>
    1717#include <poll.h>
     18
    1819#include <tcl.h>
    1920
    20 #include <RpField1D.h>
    21 #include <RpFieldRect3D.h>
    22 #include <RpFieldPrism3D.h>
    2321#include <RpOutcome.h>
    2422
     
    2927#include "nanovis.h"
    3028#include "CmdProc.h"
     29#include "Command.h"
    3130#include "FlowCmd.h"
    3231#include "FlowTypes.h"
     32#include "Flow.h"
    3333#include "FlowBox.h"
    3434#include "FlowParticles.h"
     
    3636#include "TransferFunction.h"
    3737#include "NvLIC.h"
    38 #include "Trace.h"
    3938#include "Unirect.h"
    4039#include "VelocityArrowsSlice.h"
    4140#include "Volume.h"
     41#include "Trace.h"
    4242
    4343using namespace vrmath;
     
    6868};
    6969
    70 Rappture::SwitchSpec FlowCmd::_switches[] = {
     70Rappture::SwitchSpec Flow::_switches[] = {
    7171    {Rappture::SWITCH_FLOAT, "-ambient", "value",
    7272     offsetof(FlowValues, ambient), 0},
     
    128128};
    129129
    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 void
    177 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 these
    187     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 #endif
    211     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 void
    241 FlowCmd::resetParticles()
    242 {
    243     for (ParticlesHashmap::iterator itr = _particlesTable.begin();
    244          itr != _particlesTable.end(); ++itr) {
    245         itr->second->reset();
    246     }
    247 }
    248 
    249 void
    250 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 void
    263 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 void
    303 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 void
    315 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 void
    349 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 void
    369 FlowCmd::initializeParticles()
    370 {
    371     for (ParticlesHashmap::iterator itr = _particlesTable.begin();
    372          itr != _particlesTable.end(); ++itr) {
    373         itr->second->initialize();
    374     }
    375 }
    376 
    377 bool
    378 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 void
    454 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 
    540130static int
    541131FlowDataFileOp(ClientData clientData, Tcl_Interp *interp, int objc,
     
    566156    Rappture::Unirect3d *dataPtr;
    567157    dataPtr = new Rappture::Unirect3d(nComponents);
    568     FlowCmd *flowPtr = (FlowCmd *)clientData;
     158    Flow *flow = (Flow *)clientData;
    569159    size_t length = buf.size();
    570160    char *bytes = (char *)buf.bytes();
     
    603193        return TCL_ERROR;
    604194    }
    605     flowPtr->data(dataPtr);
     195    flow->data(dataPtr);
    606196    NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
    607197    return TCL_OK;
     
    649239    dataPtr = new Rappture::Unirect3d(nComponents);
    650240
    651     FlowCmd *flowPtr = (FlowCmd *)clientData;
     241    Flow *flow = (Flow *)clientData;
    652242    size_t length = buf.size();
    653243    char *bytes = (char *)buf.bytes();
     
    699289    TRACE("magMin = %lg magMax = %lg",
    700290          dataPtr->magMin(), dataPtr->magMax());
    701     flowPtr->data(dataPtr);
     291    flow->data(dataPtr);
    702292    {
    703293        char info[1024];
     
    706296
    707297        length = sprintf(info, "nv>data tag %s min %g max %g\n",
    708                          flowPtr->name(), dataPtr->magMin(), dataPtr->magMax());
     298                         flow->name(), dataPtr->magMin(), dataPtr->magMax());
    709299        nWritten  = write(1, info, length);
    710300        assert(nWritten == (ssize_t)strlen(info));
     
    732322    }
    733323    return (*proc) (clientData, interp, objc, objv);
    734 }
    735 
    736 float
    737 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 float
    757 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 entry
    790  *
    791  * This is called by the flow command instance delete callback
    792  */
    793 void
    794 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 commands
    805  *
    806  * This will also delete the flow objects and hash table entries
    807  */
    808 void
    809 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 bool
    820 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 the
    828      *         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 void
    894 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 void
    910 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 void
    923 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 void
    938 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     }
    947324}
    948325
     
    969346    const char *string = Tcl_GetString(objPtr);
    970347    if (string[1] == '\0') {
    971         FlowCmd::SliceAxis *axisPtr = (FlowCmd::SliceAxis *)(record + offset);
     348        Flow::SliceAxis *axisPtr = (Flow::SliceAxis *)(record + offset);
    972349        char c;
    973350        c = tolower((unsigned char)string[0]);
    974351        if (c == 'x') {
    975             *axisPtr = FlowCmd::AXIS_X;
     352            *axisPtr = Flow::AXIS_X;
    976353            return TCL_OK;
    977354        } else if (c == 'y') {
    978             *axisPtr = FlowCmd::AXIS_Y;
     355            *axisPtr = Flow::AXIS_Y;
    979356            return TCL_OK;
    980357        } else if (c == 'z') {
    981             *axisPtr = FlowCmd::AXIS_Z;
     358            *axisPtr = Flow::AXIS_Z;
    982359            return TCL_OK;
    983360        }
     
    1175552                Tcl_Obj *const *objv)
    1176553{
    1177     FlowCmd *flowPtr = (FlowCmd *)clientData;
    1178 
    1179     if (flowPtr->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) {
    1180557        return TCL_ERROR;
    1181558    }
     
    1188565                   Tcl_Obj *const *objv)
    1189566{
    1190     FlowCmd *flow = (FlowCmd *)clientData;
     567    Flow *flow = (Flow *)clientData;
    1191568    const char *particlesName = Tcl_GetString(objv[3]);
    1192569    FlowParticles *particles = flow->createParticles(particlesName);
     
    1212589                         Tcl_Obj *const *objv)
    1213590{
    1214     FlowCmd *flow = (FlowCmd *)clientData;
     591    Flow *flow = (Flow *)clientData;
    1215592    const char *particlesName = Tcl_GetString(objv[3]);
    1216593    FlowParticles *particles = flow->getParticles(particlesName);
     
    1233610                      Tcl_Obj *const *objv)
    1234611{
    1235     FlowCmd *flow = (FlowCmd *)clientData;
     612    Flow *flow = (Flow *)clientData;
    1236613    for (int i = 3; i < objc; i++) {
    1237614        flow->deleteParticles(Tcl_GetString(objv[i]));
     
    1245622                     Tcl_Obj *const *objv)
    1246623{
    1247     FlowCmd *flow = (FlowCmd *)clientData;
     624    Flow *flow = (Flow *)clientData;
    1248625    Tcl_Obj *listObjPtr;
    1249626    listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL);
     
    1288665        return TCL_ERROR;
    1289666    }
    1290     FlowCmd *flowPtr = (FlowCmd *)clientData;
    1291     Tcl_Preserve(flowPtr);
     667    Flow *flow = (Flow *)clientData;
     668    Tcl_Preserve(flow);
    1292669    int result;
    1293670    result = (*proc) (clientData, interp, objc, objv);
    1294     Tcl_Release(flowPtr);
     671    Tcl_Release(flow);
    1295672    return result;
    1296673}
     
    1300677             Tcl_Obj *const *objv)
    1301678{
    1302     FlowCmd *flow = (FlowCmd *)clientData;
     679    Flow *flow = (Flow *)clientData;
    1303680    const char *boxName = Tcl_GetString(objv[3]);
    1304681    FlowBox *box = flow->createBox(boxName);
     
    1322699                   Tcl_Obj *const *objv)
    1323700{
    1324     FlowCmd *flow = (FlowCmd *)clientData;
     701    Flow *flow = (Flow *)clientData;
    1325702    const char *boxName = Tcl_GetString(objv[3]);
    1326703    FlowBox *box = flow->getBox(boxName);
     
    1341718                Tcl_Obj *const *objv)
    1342719{
    1343     FlowCmd *flow = (FlowCmd *)clientData;
     720    Flow *flow = (Flow *)clientData;
    1344721    for (int i = 3; i < objc; i++) {
    1345722        flow->deleteBox(Tcl_GetString(objv[i]));
     
    1353730               Tcl_Obj *const *objv)
    1354731{
    1355     FlowCmd *flow = (FlowCmd *)clientData;
     732    Flow *flow = (Flow *)clientData;
    1356733    Tcl_Obj *listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL);
    1357734    std::vector<std::string> names;
     
    1393770        return TCL_ERROR;
    1394771    }
    1395     FlowCmd *flowPtr = (FlowCmd *)clientData;
    1396     Tcl_Preserve(flowPtr);
     772    Flow *flow = (Flow *)clientData;
     773    Tcl_Preserve(flow);
    1397774    int result;
    1398775    result = (*proc) (clientData, interp, objc, objv);
    1399     Tcl_Release(flowPtr);
     776    Tcl_Release(flow);
    1400777    return result;
    1401778}
     
    1414791             Tcl_Obj *const *objv)
    1415792{
    1416     FlowCmd *flowPtr = (FlowCmd *)clientData;
     793    Flow *flow = (Flow *)clientData;
    1417794   
    1418795    const char *string = Tcl_GetString(objv[1]);
    1419796    TransferFunction *tf;
    1420     tf = flowPtr->getTransferFunction();
     797    tf = flow->getTransferFunction();
    1421798    if (tf == NULL) {
    1422799        Tcl_AppendResult(interp, "unknown transfer function \"", string, "\"",
     
    1455832 * \return A standard Tcl result.
    1456833 */
    1457 static int
     834int
    1458835FlowInstObjCmd(ClientData clientData, Tcl_Interp *interp, int objc,
    1459836               Tcl_Obj *const *objv)
     
    1466843    }
    1467844    assert(CheckGL(AT));
    1468     FlowCmd *flow = (FlowCmd *)clientData;
     845    Flow *flow = (Flow *)clientData;
    1469846    Tcl_Preserve(flow);
    1470847    int result = (*proc) (clientData, interp, objc, objv);
     
    1478855 * This is called only when the command associated with the flow is destroyed.
    1479856 */
    1480 static void
     857void
    1481858FlowInstDeleteProc(ClientData clientData)
    1482859{
    1483     FlowCmd *flow = (FlowCmd *)clientData;
     860    Flow *flow = (Flow *)clientData;
    1484861    NanoVis::deleteFlow(flow->name());
    1485862}
     
    1496873        return TCL_ERROR;
    1497874    }
    1498     FlowCmd *flow = NanoVis::createFlow(interp, name);
     875    Flow *flow = NanoVis::createFlow(interp, name);
    1499876    if (flow == NULL) {
    1500877        Tcl_AppendResult(interp, "Flow \"", name, "\" already exists",
     
    1516893{
    1517894    for (int i = 2; i < objc; i++) {
    1518         FlowCmd *flow = NanoVis::getFlow(Tcl_GetString(objv[i]));
     895        Flow *flow = NanoVis::getFlow(Tcl_GetString(objv[i]));
    1519896        if (flow != NULL) {
    1520897            Tcl_DeleteCommandFromToken(interp, flow->getCommandToken());
     
    1530907{
    1531908    bool value = false;
    1532     FlowCmd *flow = NanoVis::getFlow(Tcl_GetString(objv[2]));
     909    Flow *flow = NanoVis::getFlow(Tcl_GetString(objv[2]));
    1533910    if (flow != NULL) {
    1534911        value = true;
     
    1577954    for (NanoVis::FlowHashmap::iterator itr = NanoVis::flowTable.begin();
    1578955         itr != NanoVis::flowTable.end(); ++itr) {
    1579         FlowCmd *flow = itr->second;
     956        Flow *flow = itr->second;
    1580957        Tcl_Obj *objPtr = Tcl_NewStringObj(flow->name(), -1);
    1581958        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
     
    16681045};
    16691046
    1670 Rappture::SwitchSpec FlowCmd::videoSwitches[] = {
     1047static Rappture::SwitchSpec flowVideoSwitches[] = {
    16711048    {Rappture::SWITCH_INT, "-bitrate", "value",
    16721049     offsetof(FlowVideoSwitches, bitRate), 0},
     
    18721249    switches.formatObjPtr = Tcl_NewStringObj("mpeg1video", 10);
    18731250    Tcl_IncrRefCount(switches.formatObjPtr);
    1874     if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches,
     1251    if (Rappture::ParseSwitches(interp, flowVideoSwitches,
    18751252                objc - 3, objv + 3, &switches, SWITCH_DEFAULTS) < 0) {
    18761253        return TCL_ERROR;
     
    19181295    tmpFileName[length] = '\0';
    19191296    rmdir(tmpFileName);
    1920     Rappture::FreeSwitches(FlowCmd::videoSwitches, &switches, 0);
     1297    Rappture::FreeSwitches(flowVideoSwitches, &switches, 0);
    19211298    return result;
    19221299}
Note: See TracChangeset for help on using the changeset viewer.