Changeset 2875 for trunk


Ignore:
Timestamp:
Mar 22, 2012 5:17:27 PM (12 years ago)
Author:
ldelgass
Message:

Don't use memset on this pointer -- will blow up if virtual methods are added.
Also formatting cleanups.

Location:
trunk/packages/vizservers/nanovis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/FlowCmd.cpp

    r2863 r2875  
    6565Rappture::SwitchSpec FlowCmd::_switches[] = {
    6666    {Rappture::SWITCH_BOOLEAN, "-arrows", "boolean",
    67         offsetof(FlowValues, showArrows), 0},
     67     offsetof(FlowValues, showArrows), 0},
    6868    {Rappture::SWITCH_CUSTOM, "-axis", "axis",
    69         offsetof(FlowValues, slicePos.axis), 0, 0, &axisSwitch},
     69     offsetof(FlowValues, slicePos.axis), 0, 0, &axisSwitch},
    7070    {Rappture::SWITCH_FLOAT, "-diffuse", "value",
    71         offsetof(FlowValues, diffuse), 0},
     71     offsetof(FlowValues, diffuse), 0},
    7272    {Rappture::SWITCH_BOOLEAN, "-hide", "boolean",
    73         offsetof(FlowValues, isHidden), 0},
     73     offsetof(FlowValues, isHidden), 0},
    7474    {Rappture::SWITCH_FLOAT, "-opacity", "value",
    75         offsetof(FlowValues, opacity), 0},
     75     offsetof(FlowValues, opacity), 0},
    7676    {Rappture::SWITCH_BOOLEAN, "-outline", "boolean",
    77         offsetof(FlowValues, showOutline), 0},
     77     offsetof(FlowValues, showOutline), 0},
    7878    {Rappture::SWITCH_CUSTOM, "-position", "number",
    79         offsetof(FlowValues, slicePos), 0, 0, &positionSwitch},
     79     offsetof(FlowValues, slicePos), 0, 0, &positionSwitch},
    8080    {Rappture::SWITCH_BOOLEAN, "-slice", "boolean",
    81         offsetof(FlowValues, sliceVisible), 0},
     81     offsetof(FlowValues, sliceVisible), 0},
    8282    {Rappture::SWITCH_FLOAT, "-specular", "value",
    83         offsetof(FlowValues, specular), 0},
     83     offsetof(FlowValues, specular), 0},
    8484    {Rappture::SWITCH_CUSTOM, "-transferfunction", "name",
    85         offsetof(FlowValues, tfPtr), 0, 0, &transferFunctionSwitch},
     85     offsetof(FlowValues, tfPtr), 0, 0, &transferFunctionSwitch},
    8686    {Rappture::SWITCH_BOOLEAN, "-volume", "boolean",
    87         offsetof(FlowValues, showVolume), 0},
     87     offsetof(FlowValues, showVolume), 0},
    8888    {Rappture::SWITCH_END}
    8989};
     
    9191Rappture::SwitchSpec FlowParticles::_switches[] = {
    9292    {Rappture::SWITCH_CUSTOM, "-axis", "string",
    93         offsetof(FlowParticlesValues, position.axis), 0, 0, &axisSwitch},
     93     offsetof(FlowParticlesValues, position.axis), 0, 0, &axisSwitch},
    9494    {Rappture::SWITCH_CUSTOM, "-color", "{r g b a}",
    95         offsetof(FlowParticlesValues, color), 0, 0,  &colorSwitch},
     95     offsetof(FlowParticlesValues, color), 0, 0,  &colorSwitch},
    9696    {Rappture::SWITCH_BOOLEAN, "-hide", "boolean",
    97         offsetof(FlowParticlesValues, isHidden), 0},
     97     offsetof(FlowParticlesValues, isHidden), 0},
    9898    {Rappture::SWITCH_CUSTOM, "-position", "number",
    99         offsetof(FlowParticlesValues, position), 0, 0, &positionSwitch},
     99     offsetof(FlowParticlesValues, position), 0, 0, &positionSwitch},
    100100    {Rappture::SWITCH_FLOAT, "-size", "float",
    101         offsetof(FlowParticlesValues, particleSize), 0},
     101     offsetof(FlowParticlesValues, particleSize), 0},
    102102    {Rappture::SWITCH_END}
    103103};
     
    105105Rappture::SwitchSpec FlowBox::_switches[] = {
    106106    {Rappture::SWITCH_CUSTOM, "-color", "{r g b a}",
    107         offsetof(FlowBoxValues, color), 0, 0,  &colorSwitch},
     107     offsetof(FlowBoxValues, color), 0, 0,  &colorSwitch},
    108108    {Rappture::SWITCH_CUSTOM, "-corner1", "{x y z}",
    109         offsetof(FlowBoxValues, corner1), 0, 0, &pointSwitch},
     109     offsetof(FlowBoxValues, corner1), 0, 0, &pointSwitch},
    110110    {Rappture::SWITCH_CUSTOM, "-corner2", "{x y z}",
    111         offsetof(FlowBoxValues, corner2), 0, 0, &pointSwitch},
     111     offsetof(FlowBoxValues, corner2), 0, 0, &pointSwitch},
    112112    {Rappture::SWITCH_BOOLEAN, "-hide", "boolean",
    113         offsetof(FlowBoxValues, isHidden), 0},
     113     offsetof(FlowBoxValues, isHidden), 0},
    114114    {Rappture::SWITCH_FLOAT, "-linewidth", "number",
    115         offsetof(FlowBoxValues, lineWidth), 0},
     115     offsetof(FlowBoxValues, lineWidth), 0},
    116116    {Rappture::SWITCH_END}
    117117};
    118118
    119 
    120119static Tcl_ObjCmdProc FlowInstObjCmd;
    121120static Tcl_CmdDeleteProc FlowInstDeleteProc;
    122121
    123 
    124 FlowParticles::FlowParticles(const char *name, Tcl_HashEntry *hPtr)
    125 {
    126     memset(this, 0, sizeof(FlowParticles));
    127     _name = name;
    128     _hashPtr = hPtr;
     122FlowParticles::FlowParticles(const char *name, Tcl_HashEntry *hPtr) :
     123    _name(name),
     124    _hashPtr(hPtr),
     125    _rendererPtr(new NvParticleRenderer(NMESH, NMESH))
     126{
     127    _sv.position.value = 0.0f;
     128    _sv.position.flags = RELPOS;
     129    _sv.position.axis = 0; // X_AXIS
     130    _sv.color.r = _sv.color.g = _sv.color.b = _sv.color.a = 1.0f;
    129131    _sv.isHidden = false;
    130     _sv.position.axis = 0;              /* X_AXIS */
    131     _sv.position.value = 0.0f; 
    132     _sv.position.flags = RELPOS;
    133     _sv.color.r = _sv.color.b = _sv.color.g = _sv.color.a = 1.0f;
    134     _rendererPtr = new NvParticleRenderer(NMESH, NMESH);
    135 }
    136 
    137 FlowParticles::~FlowParticles(void)
     132    _sv.particleSize = 1.2;
     133}
     134
     135FlowParticles::~FlowParticles()
    138136{
    139137    if (_rendererPtr != NULL) {
    140         delete _rendererPtr;
     138        delete _rendererPtr;
    141139    }
    142140    if (_hashPtr != NULL) {
    143         Tcl_DeleteHashEntry(_hashPtr);
     141        Tcl_DeleteHashEntry(_hashPtr);
    144142    }
    145143    Rappture::FreeSwitches(_switches, &_sv, 0);
     
    147145
    148146void
    149 FlowParticles::Render(void)
     147FlowParticles::Render()
    150148{
    151149    TRACE("rendering particles %s\n", _name);
     
    153151    TRACE("rendering particles %s position=%g\n", _name, _sv.position.value);
    154152    TRACE("rendering particles %s position=%g\n", _name,
    155            FlowCmd::GetRelativePosition(&_sv.position));
     153          FlowCmd::GetRelativePosition(&_sv.position));
    156154
    157155    _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position));
     
    162160
    163161void
    164 FlowParticles::Configure(void)
     162FlowParticles::Configure()
    165163{
    166164    _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position));
    167165    _rendererPtr->setColor(Vector4(_sv.color.r, _sv.color.g, _sv.color.b,
    168                 _sv.color.a));
     166                                   _sv.color.a));
    169167    _rendererPtr->particleSize(_sv.particleSize);
    170168    _rendererPtr->setAxis(_sv.position.axis);
     
    177175    _hashPtr = hPtr;
    178176    _sv.isHidden = false;
    179     _sv.corner1.x = 0.0f;       
    180     _sv.corner1.y = 0.0f;       
    181     _sv.corner1.z = 0.0f;       
    182     _sv.corner2.x = 1.0f;       
    183     _sv.corner2.y = 1.0f;       
    184     _sv.corner2.z = 1.0f;       
     177    _sv.corner1.x = 0.0f;
     178    _sv.corner1.y = 0.0f;
     179    _sv.corner1.z = 0.0f;
     180    _sv.corner2.x = 1.0f;
     181    _sv.corner2.y = 1.0f;
     182    _sv.corner2.z = 1.0f;
    185183    _sv.lineWidth = 1.2f;
    186184    _sv.color.r = _sv.color.b = _sv.color.g = _sv.color.a = 1.0f;
    187 
    188185}
    189186
     
    199196    glDisable(GL_TEXTURE_2D);
    200197    glEnable(GL_BLEND);
    201    
     198
    202199    glPushMatrix();
    203200    Vector3 origin = volPtr->location();
     
    208205    sy = volPtr->height / (double)volPtr->width;
    209206    if (volPtr->depth > 0.0) {
    210         sz = volPtr->depth  / (double)volPtr->width;
     207        sz = volPtr->depth  / (double)volPtr->width;
    211208    }
    212209    glScaled(sx, sy, sz);
     
    218215
    219216    TRACE("box is %g,%g %g,%g %g,%g\n",
    220           _sv.corner1.x, _sv.corner2.x,
    221           _sv.corner1.y, _sv.corner2.y,
    222            _sv.corner1.z, _sv.corner2.z);
     217          _sv.corner1.x, _sv.corner2.x,
     218          _sv.corner1.y, _sv.corner2.y,
     219          _sv.corner1.z, _sv.corner2.z);
    223220    TRACE("world is %g,%g %g,%g %g,%g\n",
    224            min.x, max.x, min.y, max.y, min.z, max.z);
     221          min.x, max.x, min.y, max.y, min.z, max.z);
    225222
    226223    float x0, y0, z0, x1, y1, z1;
     
    228225    x1 = y1 = z1 = 0.0f;
    229226    if (max.y  > min.y) {
    230         y0 = (_sv.corner1.y - min.y) / (max.y - min.y);
    231         y1 = (_sv.corner2.y - min.y) / (max.y - min.y);
     227        y0 = (_sv.corner1.y - min.y) / (max.y - min.y);
     228        y1 = (_sv.corner2.y - min.y) / (max.y - min.y);
    232229    }
    233230    if (max.z > min.z) {
    234         z0 = (_sv.corner1.z - min.z) / (max.z - min.z);
    235         z1 = (_sv.corner2.z - min.z) / (max.z - min.z);
     231        z0 = (_sv.corner1.z - min.z) / (max.z - min.z);
     232        z1 = (_sv.corner2.z - min.z) / (max.z - min.z);
    236233    }
    237234    if (max.x > min.x) {
    238         x0 = (_sv.corner1.x - min.x) / (max.x - min.x);
    239         x1 = (_sv.corner2.x - min.x) / (max.x - min.x);
     235        x0 = (_sv.corner1.x - min.x) / (max.x - min.x);
     236        x1 = (_sv.corner2.x - min.x) / (max.x - min.x);
    240237    }
    241238    TRACE("rendering box %g,%g %g,%g %g,%g\n", x0, x1, y0, y1, z0, z1);
     
    244241    glBegin(GL_LINE_LOOP);
    245242    {
    246         glVertex3d(x0, y0, z0);
    247         glVertex3d(x1, y0, z0);
    248         glVertex3d(x1, y1, z0);
    249         glVertex3d(x0, y1, z0);
     243        glVertex3d(x0, y0, z0);
     244        glVertex3d(x1, y0, z0);
     245        glVertex3d(x1, y1, z0);
     246        glVertex3d(x0, y1, z0);
    250247    }
    251248    glEnd();
    252249    glBegin(GL_LINE_LOOP);
    253250    {
    254         glVertex3d(x0, y0, z1);
    255         glVertex3d(x1, y0, z1);
    256         glVertex3d(x1, y1, z1);
    257         glVertex3d(x0, y1, z1);
     251        glVertex3d(x0, y0, z1);
     252        glVertex3d(x1, y0, z1);
     253        glVertex3d(x1, y1, z1);
     254        glVertex3d(x0, y1, z1);
    258255    }
    259256    glEnd();
     
    261258    glBegin(GL_LINE_LOOP);
    262259    {
    263         glVertex3d(x0, y0, z0);
    264         glVertex3d(x0, y0, z1);
    265         glVertex3d(x0, y1, z1);
    266         glVertex3d(x0, y1, z0);
     260        glVertex3d(x0, y0, z0);
     261        glVertex3d(x0, y0, z1);
     262        glVertex3d(x0, y1, z1);
     263        glVertex3d(x0, y1, z0);
    267264    }
    268265    glEnd();
     
    270267    glBegin(GL_LINE_LOOP);
    271268    {
    272         glVertex3d(x1, y0, z0);
    273         glVertex3d(x1, y0, z1);
    274         glVertex3d(x1, y1, z1);
    275         glVertex3d(x1, y1, z0);
     269        glVertex3d(x1, y0, z0);
     270        glVertex3d(x1, y0, z1);
     271        glVertex3d(x1, y1, z1);
     272        glVertex3d(x1, y1, z0);
    276273    }
    277274    glEnd();
     
    287284}
    288285
    289 
    290 FlowCmd::FlowCmd(Tcl_Interp *interp, const char *name, Tcl_HashEntry *hPtr)
    291 {
    292     memset(this, 0, sizeof(FlowCmd));
    293     _name = name;
    294     _interp = interp;
    295     _hashPtr = hPtr;
    296     _dataPtr = NULL;
     286FlowCmd::FlowCmd(Tcl_Interp *interp, const char *name, Tcl_HashEntry *hPtr) :
     287    _interp(interp),
     288    _hashPtr(hPtr),
     289    _name(name),
     290    _dataPtr(NULL),
     291    _volPtr(NULL),
     292    _fieldPtr(NULL)
     293{
     294    memset(&_sv, 0, sizeof(FlowValues));
    297295    _sv.sliceVisible = 1;
    298296    _sv.tfPtr = NanoVis::get_transfunc("default");
    299     _volPtr = NULL;
    300     _cmdToken = Tcl_CreateObjCommand(interp, (char *)_name,
    301         (Tcl_ObjCmdProc *)FlowInstObjCmd, this, FlowInstDeleteProc);
     297
    302298    Tcl_InitHashTable(&_particlesTable, TCL_STRING_KEYS);
    303299    Tcl_InitHashTable(&_boxTable, TCL_STRING_KEYS);
    304 }
    305 
    306 FlowCmd::~FlowCmd(void)
     300
     301    _cmdToken = Tcl_CreateObjCommand(_interp, (char *)_name,
     302                                     (Tcl_ObjCmdProc *)FlowInstObjCmd,
     303                                     this, FlowInstDeleteProc);
     304}
     305
     306FlowCmd::~FlowCmd()
    307307{
    308308    Rappture::FreeSwitches(_switches, &_sv, 0);
    309309    if (_hashPtr != NULL) {
    310         Tcl_DeleteHashEntry(_hashPtr);
     310        Tcl_DeleteHashEntry(_hashPtr);
    311311    }
    312312    if (_fieldPtr != NULL) {
    313         delete _fieldPtr;
     313        delete _fieldPtr;
    314314    }
    315315    if (_dataPtr != NULL) {
    316         delete _dataPtr;
    317     }
    318      if (_volPtr != NULL) {
    319         NanoVis::remove_volume(_volPtr);
    320         _volPtr = NULL;
     316        delete _dataPtr;
     317    }
     318    if (_volPtr != NULL) {
     319        NanoVis::remove_volume(_volPtr);
     320        _volPtr = NULL;
    321321    }
    322322
     
    324324    FlowBoxIterator boxIter;
    325325    for (boxPtr = FirstBox(&boxIter); boxPtr != NULL;
    326         boxPtr = NextBox(&boxIter)) {
    327         boxPtr->disconnect();
    328         delete boxPtr;
    329     }   
     326        boxPtr = NextBox(&boxIter)) {
     327        boxPtr->disconnect();
     328        delete boxPtr;
     329    }
    330330    FlowParticles *particlesPtr;
    331331    FlowParticlesIterator partIter;
    332332    for (particlesPtr = FirstParticles(&partIter); particlesPtr != NULL;
    333         particlesPtr = NextParticles(&partIter)) {
    334         particlesPtr->disconnect();
    335         delete particlesPtr;
    336     }   
     333        particlesPtr = NextParticles(&partIter)) {
     334        particlesPtr->disconnect();
     335        delete particlesPtr;
     336    }
    337337    Tcl_DeleteHashTable(&_particlesTable);
    338338    Tcl_DeleteHashTable(&_boxTable);
     
    340340
    341341void
    342 FlowCmd::ResetParticles(void)
     342FlowCmd::ResetParticles()
    343343{
    344344    FlowParticlesIterator iter;
    345345    FlowParticles *particlesPtr;
    346346    for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL;
    347         particlesPtr = NextParticles(&iter)) {
    348         particlesPtr->Reset();
     347        particlesPtr = NextParticles(&iter)) {
     348        particlesPtr->Reset();
    349349    }
    350350}
    351351
    352352void
    353 FlowCmd::Advect(void)
     353FlowCmd::Advect()
    354354{
    355355    NvVectorField *fieldPtr;
     
    359359    FlowParticles *particlesPtr;
    360360    for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL;
    361         particlesPtr = NextParticles(&iter)) {
    362         if (particlesPtr->visible()) {
    363             particlesPtr->Advect();
    364         }
     361        particlesPtr = NextParticles(&iter)) {
     362        if (particlesPtr->visible()) {
     363            particlesPtr->Advect();
     364        }
    365365    }
    366366}
    367367
    368368void
    369 FlowCmd::Render(void)
     369FlowCmd::Render()
    370370{
    371371    _fieldPtr->active(true);
     
    374374    FlowParticles *particlesPtr;
    375375    for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL;
    376         particlesPtr = NextParticles(&iter)) {
    377         if (particlesPtr->visible()) {
    378             particlesPtr->Render();
    379         }
     376        particlesPtr = NextParticles(&iter)) {
     377        if (particlesPtr->visible()) {
     378            particlesPtr->Render();
     379        }
    380380    }
    381381    TRACE("in Render before boxes %s\n", _name);
     
    391391    hPtr = Tcl_CreateHashEntry(&_particlesTable, particlesName, &isNew);
    392392    if (!isNew) {
    393         Tcl_AppendResult(interp, "particle injection plane \"",
    394                         particlesName, "\" already exists.", (char *)NULL);
    395         return TCL_ERROR;
     393        Tcl_AppendResult(interp, "particle injection plane \"",
     394                        particlesName, "\" already exists.", (char *)NULL);
     395        return TCL_ERROR;
    396396    }
    397397    particlesName = Tcl_GetHashKey(&_particlesTable, hPtr);
     
    399399    particlesPtr = new FlowParticles(particlesName, hPtr);
    400400    if (particlesPtr == NULL) {
    401         Tcl_AppendResult(interp, "can't allocate particle injection plane",
    402                 (char *)NULL);
    403         Tcl_DeleteHashEntry(hPtr);
    404         return TCL_ERROR;
     401        Tcl_AppendResult(interp, "can't allocate particle injection plane",
     402                         (char *)NULL);
     403        Tcl_DeleteHashEntry(hPtr);
     404        return TCL_ERROR;
    405405    }
    406406    Tcl_SetHashValue(hPtr, particlesPtr);
     
    410410int
    411411FlowCmd::GetParticles(Tcl_Interp *interp, Tcl_Obj *objPtr,
    412                       FlowParticles **particlesPtrPtr)
     412                      FlowParticles **particlesPtrPtr)
    413413{
    414414    Tcl_HashEntry *hPtr;
    415415    hPtr = Tcl_FindHashEntry(&_particlesTable, Tcl_GetString(objPtr));
    416416    if (hPtr == NULL) {
    417         if (interp != NULL) {
    418             Tcl_AppendResult(interp, "can't find a particle injection plane \"",
    419                         Tcl_GetString(objPtr), "\"", (char *)NULL);
    420         }
    421         return TCL_ERROR;
     417        if (interp != NULL) {
     418            Tcl_AppendResult(interp, "can't find a particle injection plane \"",
     419                            Tcl_GetString(objPtr), "\"", (char *)NULL);
     420        }
     421        return TCL_ERROR;
    422422    }
    423423    *particlesPtrPtr = (FlowParticles *)Tcl_GetHashValue(hPtr);
     
    429429{
    430430    iterPtr->hashPtr = Tcl_FirstHashEntry(&_particlesTable,
    431         &iterPtr->hashSearch);
     431                                          &iterPtr->hashSearch);
    432432    if (iterPtr->hashPtr == NULL) {
    433         return NULL;
     433        return NULL;
    434434    }
    435435    return (FlowParticles *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    440440{
    441441    if (iterPtr->hashPtr == NULL) {
    442         return NULL;
     442        return NULL;
    443443    }
    444444    iterPtr->hashPtr = Tcl_NextHashEntry(&iterPtr->hashSearch);
    445445    if (iterPtr->hashPtr == NULL) {
    446         return NULL;
     446        return NULL;
    447447    }
    448448    return (FlowParticles *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    456456    hPtr = Tcl_CreateHashEntry(&_boxTable, Tcl_GetString(objPtr), &isNew);
    457457    if (!isNew) {
    458         Tcl_AppendResult(interp, "box \"", Tcl_GetString(objPtr),
    459                 "\" already exists in flow \"", name(), "\"", (char *)NULL);
    460         return TCL_ERROR;
     458        Tcl_AppendResult(interp, "box \"", Tcl_GetString(objPtr),
     459                         "\" already exists in flow \"", name(), "\"", (char *)NULL);
     460        return TCL_ERROR;
    461461    }
    462462    const char *boxName;
     
    465465    boxPtr = new FlowBox(boxName, hPtr);
    466466    if (boxPtr == NULL) {
    467         Tcl_AppendResult(interp, "can't allocate box \"", boxName, "\"",
    468                         (char *)NULL);
    469         Tcl_DeleteHashEntry(hPtr);
    470         return TCL_ERROR;
     467        Tcl_AppendResult(interp, "can't allocate box \"", boxName, "\"",
     468                        (char *)NULL);
     469        Tcl_DeleteHashEntry(hPtr);
     470        return TCL_ERROR;
    471471    }
    472472    Tcl_SetHashValue(hPtr, boxPtr);
     
    480480    hPtr = Tcl_FindHashEntry(&_boxTable, Tcl_GetString(objPtr));
    481481    if (hPtr == NULL) {
    482         if (interp != NULL) {
    483             Tcl_AppendResult(interp, "can't find a box \"",
    484                 Tcl_GetString(objPtr), "\" in flow \"", name(), "\"",
    485                 (char *)NULL);
    486         }
    487         return TCL_ERROR;
     482        if (interp != NULL) {
     483            Tcl_AppendResult(interp, "can't find a box \"",
     484                             Tcl_GetString(objPtr), "\" in flow \"", name(), "\"",
     485                             (char *)NULL);
     486        }
     487        return TCL_ERROR;
    488488    }
    489489    *boxPtrPtr = (FlowBox *)Tcl_GetHashValue(hPtr);
     
    496496    iterPtr->hashPtr = Tcl_FirstHashEntry(&_boxTable, &iterPtr->hashSearch);
    497497    if (iterPtr->hashPtr == NULL) {
    498         return NULL;
     498        return NULL;
    499499    }
    500500    return (FlowBox *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    505505{
    506506    if (iterPtr->hashPtr == NULL) {
    507         return NULL;
     507        return NULL;
    508508    }
    509509    iterPtr->hashPtr = Tcl_NextHashEntry(&iterPtr->hashSearch);
    510510    if (iterPtr->hashPtr == NULL) {
    511         return NULL;
     511        return NULL;
    512512    }
    513513    return (FlowBox *)Tcl_GetHashValue(iterPtr->hashPtr);
    514514}
    515515
    516 
    517516void
    518 FlowCmd::InitializeParticles(void)
     517FlowCmd::InitializeParticles()
    519518{
    520519    FlowParticles *particlesPtr;
    521520    FlowParticlesIterator iter;
    522521    for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL;
    523         particlesPtr = NextParticles(&iter)) {
    524         particlesPtr->Initialize();
    525     }   
     522        particlesPtr = NextParticles(&iter)) {
     523        particlesPtr->Initialize();
     524    }
    526525}
    527526
     
    530529{
    531530    if (_volPtr != NULL) {
    532         TRACE("from ScaleVectorField volId=%s\n", _volPtr->name());
    533         NanoVis::remove_volume(_volPtr);
    534         _volPtr = NULL;
     531        TRACE("from ScaleVectorField volId=%s\n", _volPtr->name());
     532        NanoVis::remove_volume(_volPtr);
     533        _volPtr = NULL;
    535534    }
    536535    float *vdata;
    537536    vdata = GetScaledVector();
    538537    if (vdata == NULL) {
    539         return false;
     538        return false;
    540539    }
    541540    Volume *volPtr;
     
    543542    delete [] vdata;
    544543    if (volPtr == NULL) {
    545         return false;
     544        return false;
    546545    }
    547546    _volPtr = volPtr;
     
    549548    // Remove the associated vector field.
    550549    if (_fieldPtr != NULL) {
    551         delete _fieldPtr;
     550        delete _fieldPtr;
    552551    }
    553552    _fieldPtr = new NvVectorField();
    554553    if (_fieldPtr == NULL) {
    555         return false;
     554        return false;
    556555    }
    557556
     
    580579                           1.0f / _volPtr->aspect_ratio_depth,
    581580                           _volPtr->wAxis.max());
    582         SetCurrentPosition();
    583         SetAxis();
    584         SetActive();
     581        SetCurrentPosition();
     582        SetAxis();
     583        SetActive();
    585584    }
    586585
     
    594593                        //,volPtr->wAxis.max()
    595594                        );
    596         TRACE("Arrows enabled set to %d\n", _sv.showArrows);
    597         NanoVis::velocityArrowsSlice->axis(_sv.slicePos.axis);
    598         NanoVis::velocityArrowsSlice->slicePos(_sv.slicePos.value);
    599         NanoVis::velocityArrowsSlice->enabled(_sv.showArrows);
     595        TRACE("Arrows enabled set to %d\n", _sv.showArrows);
     596        NanoVis::velocityArrowsSlice->axis(_sv.slicePos.axis);
     597        NanoVis::velocityArrowsSlice->slicePos(_sv.slicePos.value);
     598        NanoVis::velocityArrowsSlice->enabled(_sv.showArrows);
    600599    }
    601600    FlowParticles *particlesPtr;
    602601    FlowParticlesIterator partIter;
    603602    for (particlesPtr = FirstParticles(&partIter); particlesPtr != NULL;
    604         particlesPtr = NextParticles(&partIter)) {
    605         particlesPtr->SetVectorField(_volPtr);
    606     }   
     603        particlesPtr = NextParticles(&partIter)) {
     604        particlesPtr->SetVectorField(_volPtr);
     605    }
    607606    return true;
    608607}
    609608
    610609void
    611 FlowCmd::RenderBoxes(void)
     610FlowCmd::RenderBoxes()
    612611{
    613612    FlowBoxIterator iter;
    614613    FlowBox *boxPtr;
    615614    for (boxPtr = FirstBox(&iter); boxPtr != NULL; boxPtr = NextBox(&iter)) {
    616         TRACE("found box %s\n", boxPtr->name());
    617         if (boxPtr->visible()) {
    618             boxPtr->Render(_volPtr);
    619         }
     615        TRACE("found box %s\n", boxPtr->name());
     616        if (boxPtr->visible()) {
     617            boxPtr->Render(_volPtr);
     618        }
    620619    }
    621620}
    622621
    623622float *
    624 FlowCmd::GetScaledVector(void)
     623FlowCmd::GetScaledVector()
    625624{
    626625    assert(_dataPtr->nComponents() == 3);
     
    628627    float *data = new float[n];
    629628    if (data == NULL) {
    630         return NULL;
     629        return NULL;
    631630    }
    632631    memset(data, 0, sizeof(float) * n);
     
    634633    const float *values = _dataPtr->values();
    635634    for (size_t iz=0; iz < _dataPtr->zNum(); iz++) {
    636         for (size_t iy=0; iy < _dataPtr->yNum(); iy++) {
    637             for (size_t ix=0; ix < _dataPtr->xNum(); ix++) {
    638                 double vx, vy, vz, vm;
    639                 vx = values[0];
    640                 vy = values[1];
    641                 vz = values[2];
    642                 vm = sqrt(vx*vx + vy*vy + vz*vz);
    643                 destPtr[0] = vm / NanoVis::magMax;
    644                 destPtr[1] = vx /(2.0*NanoVis::magMax) + 0.5;
    645                 destPtr[2] = vy /(2.0*NanoVis::magMax) + 0.5;
    646                 destPtr[3] = vz /(2.0*NanoVis::magMax) + 0.5;
    647                 values += 3;
    648                 destPtr += 4;
    649             }
    650         }
     635        for (size_t iy=0; iy < _dataPtr->yNum(); iy++) {
     636            for (size_t ix=0; ix < _dataPtr->xNum(); ix++) {
     637                double vx, vy, vz, vm;
     638                vx = values[0];
     639                vy = values[1];
     640                vz = values[2];
     641                vm = sqrt(vx*vx + vy*vy + vz*vz);
     642                destPtr[0] = vm / NanoVis::magMax;
     643                destPtr[1] = vx /(2.0*NanoVis::magMax) + 0.5;
     644                destPtr[2] = vy /(2.0*NanoVis::magMax) + 0.5;
     645                destPtr[3] = vz /(2.0*NanoVis::magMax) + 0.5;
     646                values += 3;
     647                destPtr += 4;
     648            }
     649        }
    651650    }
    652651    return data;
     
    659658
    660659    volPtr = NanoVis::load_volume(_name, _dataPtr->xNum(), _dataPtr->yNum(),
    661                                   _dataPtr->zNum(), 4, data,
    662                                   NanoVis::magMin, NanoVis::magMax, 0);
     660                                  _dataPtr->zNum(), 4, data,
     661                                  NanoVis::magMin, NanoVis::magMax, 0);
    663662    volPtr->xAxis.SetRange(_dataPtr->xMin(), _dataPtr->xMax());
    664663    volPtr->yAxis.SetRange(_dataPtr->yMin(), _dataPtr->yMax());
     
    669668    Vector3 physicalMax(NanoVis::xMax, NanoVis::yMax, NanoVis::zMax);
    670669    TRACE("min=%g %g %g max=%g %g %g mag=%g %g\n",
    671             NanoVis::xMin, NanoVis::yMin, NanoVis::zMin,
    672             NanoVis::xMax, NanoVis::yMax, NanoVis::zMax,
    673            NanoVis::magMin, NanoVis::magMax);
     670          NanoVis::xMin, NanoVis::yMin, NanoVis::zMin,
     671          NanoVis::xMax, NanoVis::yMax, NanoVis::zMax,
     672          NanoVis::magMin, NanoVis::magMax);
    674673    volPtr->setPhysicalBBox(physicalMin, physicalMax);
    675674    //volPtr->set_n_slice(256 - _volIndex);
     
    700699}
    701700
    702 
    703701static int
    704702FlowDataFileOp(ClientData clientData, Tcl_Interp *interp, int objc,
    705                Tcl_Obj *const *objv)
     703               Tcl_Obj *const *objv)
    706704{
    707705    Rappture::Outcome result;
     
    716714    }
    717715    if ((nComponents < 1) || (nComponents > 4)) {
    718         Tcl_AppendResult(interp, "bad # of components \"",
    719                         Tcl_GetString(objv[4]), "\"", (char *)NULL);
    720         return TCL_ERROR;
     716        Tcl_AppendResult(interp, "bad # of components \"",
     717                        Tcl_GetString(objv[4]), "\"", (char *)NULL);
     718        return TCL_ERROR;
    721719    }
    722720    Rappture::Buffer buf;
    723721    if (!buf.load(result, fileName)) {
    724         Tcl_AppendResult(interp, "can't load data from \"", fileName, "\": ",
    725                         result.remark(), (char *)NULL);
    726         return TCL_ERROR;
     722        Tcl_AppendResult(interp, "can't load data from \"", fileName, "\": ",
     723                        result.remark(), (char *)NULL);
     724        return TCL_ERROR;
    727725    }
    728726
     
    733731    char *bytes = (char *)buf.bytes();
    734732    if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
    735         if (!dataPtr->ImportDx(result, nComponents, length-4, bytes+4)) {
    736             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    737             delete dataPtr;
    738             return TCL_ERROR;
    739         }
     733        if (!dataPtr->ImportDx(result, nComponents, length-4, bytes+4)) {
     734            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     735            delete dataPtr;
     736            return TCL_ERROR;
     737        }
    740738    } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) {
    741         if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) {
    742             delete dataPtr;
    743             return TCL_ERROR;
    744         }
     739        if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) {
     740            delete dataPtr;
     741            return TCL_ERROR;
     742        }
    745743    } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) {
    746         Rappture::Unirect2d *u2dPtr;
    747         u2dPtr = new Rappture::Unirect2d(nComponents);
    748         if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) {
    749             delete u2dPtr;
    750             return TCL_ERROR;
    751         }
    752         dataPtr->Convert(u2dPtr);
    753         delete u2dPtr;
     744        Rappture::Unirect2d *u2dPtr;
     745        u2dPtr = new Rappture::Unirect2d(nComponents);
     746        if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) {
     747            delete u2dPtr;
     748            return TCL_ERROR;
     749        }
     750        dataPtr->Convert(u2dPtr);
     751        delete u2dPtr;
    754752    } else {
    755         TRACE("header is %.14s\n", buf.bytes());
    756         if (!dataPtr->ImportDx(result, nComponents, length, bytes)) {
    757             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    758             delete dataPtr;
    759             return TCL_ERROR;
    760         }
     753        TRACE("header is %.14s\n", buf.bytes());
     754        if (!dataPtr->ImportDx(result, nComponents, length, bytes)) {
     755            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     756            delete dataPtr;
     757            return TCL_ERROR;
     758        }
    761759    }
    762760    if (dataPtr->nValues() == 0) {
    763         delete dataPtr;
    764         Tcl_AppendResult(interp, "no data found in \"", fileName, "\"",
    765                         (char *)NULL);
    766         return TCL_ERROR;
     761        delete dataPtr;
     762        Tcl_AppendResult(interp, "no data found in \"", fileName, "\"",
     763                        (char *)NULL);
     764        return TCL_ERROR;
    767765    }
    768766    flowPtr->data(dataPtr);
     
    771769}
    772770
    773 /*
     771/**
    774772 * $flow data follows nbytes nComponents
    775773 */
    776774static int
    777775FlowDataFollowsOp(ClientData clientData, Tcl_Interp *interp, int objc,
    778                     Tcl_Obj *const *objv)
     776                  Tcl_Obj *const *objv)
    779777{
    780778    Rappture::Outcome result;
     
    784782    int nBytes;
    785783    if (Tcl_GetIntFromObj(interp, objv[3], &nBytes) != TCL_OK) {
    786         ERROR("Bad nBytes \"%s\"\n", Tcl_GetString(objv[3]));
     784        ERROR("Bad nBytes \"%s\"\n", Tcl_GetString(objv[3]));
    787785        return TCL_ERROR;
    788786    }
    789787    if (nBytes <= 0) {
    790         Tcl_AppendResult(interp, "bad # bytes request \"",
    791                 Tcl_GetString(objv[3]), "\" for \"data follows\"", (char *)NULL);
    792         ERROR("Bad nbytes %d\n", nBytes);
    793         return TCL_ERROR;
     788        Tcl_AppendResult(interp, "bad # bytes request \"",
     789                         Tcl_GetString(objv[3]), "\" for \"data follows\"", (char *)NULL);
     790        ERROR("Bad nbytes %d\n", nBytes);
     791        return TCL_ERROR;
    794792    }
    795793    int nComponents;
    796794    if (Tcl_GetIntFromObj(interp, objv[4], &nComponents) != TCL_OK) {
    797         ERROR("Bad # of components \"%s\"\n", Tcl_GetString(objv[4]));
     795        ERROR("Bad # of components \"%s\"\n", Tcl_GetString(objv[4]));
    798796        return TCL_ERROR;
    799797    }
    800798    if (nComponents <= 0) {
    801         Tcl_AppendResult(interp, "bad # of components request \"",
    802                 Tcl_GetString(objv[4]), "\" for \"data follows\"", (char *)NULL);
    803         ERROR("Bad # of components %d\n", nComponents);
    804         return TCL_ERROR;
     799        Tcl_AppendResult(interp, "bad # of components request \"",
     800                         Tcl_GetString(objv[4]), "\" for \"data follows\"", (char *)NULL);
     801        ERROR("Bad # of components %d\n", nComponents);
     802        return TCL_ERROR;
    805803    }
    806804    Rappture::Buffer buf;
     
    816814    char *bytes = (char *)buf.bytes();
    817815    if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
    818         if (!dataPtr->ImportDx(result, nComponents, length - 4, bytes + 4)) {
    819             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    820             delete dataPtr;
    821             return TCL_ERROR;
    822         }
     816        if (!dataPtr->ImportDx(result, nComponents, length - 4, bytes + 4)) {
     817            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     818            delete dataPtr;
     819            return TCL_ERROR;
     820        }
    823821    } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) {
    824         if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) {
    825             delete dataPtr;
    826             return TCL_ERROR;
    827         }
     822        if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) {
     823            delete dataPtr;
     824            return TCL_ERROR;
     825        }
    828826    } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) {
    829         Rappture::Unirect2d *u2dPtr;
    830         u2dPtr = new Rappture::Unirect2d(nComponents);
    831         if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) {
    832             delete u2dPtr;
    833             return TCL_ERROR;
    834         }
    835         dataPtr->Convert(u2dPtr);
    836         delete u2dPtr;
     827        Rappture::Unirect2d *u2dPtr;
     828        u2dPtr = new Rappture::Unirect2d(nComponents);
     829        if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) {
     830            delete u2dPtr;
     831            return TCL_ERROR;
     832        }
     833        dataPtr->Convert(u2dPtr);
     834        delete u2dPtr;
    837835    } else {
    838         TRACE("header is %.14s\n", buf.bytes());
    839         if (!dataPtr->ImportDx(result, nComponents, length, bytes)) {
    840             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    841             delete dataPtr;
    842             return TCL_ERROR;
    843         }
     836        TRACE("header is %.14s\n", buf.bytes());
     837        if (!dataPtr->ImportDx(result, nComponents, length, bytes)) {
     838            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     839            delete dataPtr;
     840            return TCL_ERROR;
     841        }
    844842    }
    845843    if (dataPtr->nValues() == 0) {
    846         delete dataPtr;
    847         Tcl_AppendResult(interp, "no data found in stream", (char *)NULL);
    848         return TCL_ERROR;
     844        delete dataPtr;
     845        Tcl_AppendResult(interp, "no data found in stream", (char *)NULL);
     846        return TCL_ERROR;
    849847    }
    850848    flowPtr->data(dataPtr);
    851849    {
    852850        char info[1024];
    853         ssize_t nWritten;
    854         size_t length;
     851        ssize_t nWritten;
     852        size_t length;
    855853
    856854        length = sprintf(info, "nv>data tag %s min %g max %g\n",
    857                 flowPtr->name(), dataPtr->magMin(), dataPtr->magMax());
     855                         flowPtr->name(), dataPtr->magMin(), dataPtr->magMax());
    858856        nWritten  = write(1, info, length);
    859         assert(nWritten == (ssize_t)strlen(info));
     857        assert(nWritten == (ssize_t)strlen(info));
    860858    }
    861859    NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     
    871869static int
    872870FlowDataOp(ClientData clientData, Tcl_Interp *interp, int objc,
    873            Tcl_Obj *const *objv)
     871           Tcl_Obj *const *objv)
    874872{
    875873    Tcl_ObjCmdProc *proc;
     
    887885{
    888886    if (posPtr->flags == RELPOS) {
    889         return posPtr->value;
     887        return posPtr->value;
    890888    }
    891889    switch (posPtr->axis) {
    892890    case AXIS_X: 
    893         return (posPtr->value - NanoVis::xMin) /
    894             (NanoVis::xMax - NanoVis::xMin);
     891        return (posPtr->value - NanoVis::xMin) /
     892            (NanoVis::xMax - NanoVis::xMin);
    895893    case AXIS_Y: 
    896         return (posPtr->value - NanoVis::yMin) /
    897             (NanoVis::yMax - NanoVis::yMin);
     894        return (posPtr->value - NanoVis::yMin) /
     895            (NanoVis::yMax - NanoVis::yMin);
    898896    case AXIS_Z: 
    899         return (posPtr->value - NanoVis::zMin) /
    900             (NanoVis::zMax - NanoVis::zMin);
     897        return (posPtr->value - NanoVis::zMin) /
     898            (NanoVis::zMax - NanoVis::zMin);
    901899    }
    902900    return 0.0;
     
    904902
    905903float
    906 FlowCmd::GetRelativePosition(void)
     904FlowCmd::GetRelativePosition()
    907905{
    908906    return FlowCmd::GetRelativePosition(&_sv.slicePos);
     
    912910
    913911void
    914 NanoVis::InitFlows(void)
     912NanoVis::InitFlows()
    915913{
    916914    Tcl_InitHashTable(&flowTable, TCL_STRING_KEYS);
     
    922920    iterPtr->hashPtr = Tcl_FirstHashEntry(&flowTable, &iterPtr->hashSearch);
    923921    if (iterPtr->hashPtr == NULL) {
    924         return NULL;
     922        return NULL;
    925923    }
    926924    return (FlowCmd *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    931929{
    932930    if (iterPtr->hashPtr == NULL) {
    933         return NULL;
     931        return NULL;
    934932    }
    935933    iterPtr->hashPtr = Tcl_NextHashEntry(&iterPtr->hashSearch);
    936934    if (iterPtr->hashPtr == NULL) {
    937         return NULL;
     935        return NULL;
    938936    }
    939937    return (FlowCmd *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    946944    hPtr = Tcl_FindHashEntry(&flowTable, Tcl_GetString(objPtr));
    947945    if (hPtr == NULL) {
    948         if (interp != NULL) {
    949             Tcl_AppendResult(interp, "can't find a flow \"",
    950                              Tcl_GetString(objPtr), "\"", (char *)NULL);
    951         }
    952         return TCL_ERROR;
     946        if (interp != NULL) {
     947            Tcl_AppendResult(interp, "can't find a flow \"",
     948                             Tcl_GetString(objPtr), "\"", (char *)NULL);
     949        }
     950        return TCL_ERROR;
    953951    }
    954952    *flowPtrPtr = (FlowCmd *)Tcl_GetHashValue(hPtr);
     
    965963    hPtr = Tcl_CreateHashEntry(&flowTable, name, &isNew);
    966964    if (!isNew) {
    967         Tcl_AppendResult(interp, "flow \"", name, "\" already exists.",
    968                         (char *)NULL);
    969         return TCL_ERROR;
     965        Tcl_AppendResult(interp, "flow \"", name, "\" already exists.",
     966                        (char *)NULL);
     967        return TCL_ERROR;
    970968    }
    971969    Tcl_CmdInfo cmdInfo;
    972970    if (Tcl_GetCommandInfo(interp, name, &cmdInfo)) {
    973         Tcl_AppendResult(interp, "an another command \"", name,
    974                         "\" already exists.", (char *)NULL);
    975         return TCL_ERROR;
    976     }   
     971        Tcl_AppendResult(interp, "an another command \"", name,
     972                        "\" already exists.", (char *)NULL);
     973        return TCL_ERROR;
     974    }
    977975    FlowCmd *flowPtr;
    978976    name = Tcl_GetHashKey(&flowTable, hPtr);
    979977    flowPtr = new FlowCmd(interp, name, hPtr);
    980978    if (flowPtr == NULL) {
    981         Tcl_AppendResult(interp, "can't allocate a flow object \"", name,
    982                         "\"", (char *)NULL);
    983         return TCL_ERROR;
     979        Tcl_AppendResult(interp, "can't allocate a flow object \"", name,
     980                        "\"", (char *)NULL);
     981        return TCL_ERROR;
    984982    }
    985983    Tcl_SetHashValue(hPtr, flowPtr);
     
    993991    FlowIterator iter;
    994992    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    995         flowPtr = NextFlow(&iter)) {
    996         flowPtr->disconnect();          /* Don't disrupt the hash walk */
    997         Tcl_DeleteCommand(interp, flowPtr->name());
     993        flowPtr = NextFlow(&iter)) {
     994        flowPtr->disconnect();                /* Don't disrupt the hash walk */
     995        Tcl_DeleteCommand(interp, flowPtr->name());
    998996    }
    999997    Tcl_DeleteHashTable(&flowTable);
     
    1001999
    10021000bool
    1003 NanoVis::MapFlows(void)
     1001NanoVis::MapFlows()
    10041002{
    10051003    flags &= ~MAP_FLOWS;
     
    10071005
    10081006    /*
    1009      * Step 1.  Get the overall min and max magnitudes of all the
    1010      *          flow vectors.
     1007     * Step 1. Get the overall min and max magnitudes of all the
     1008     *         flow vectors.
    10111009     */
    10121010    magMin = DBL_MAX, magMax = -DBL_MAX;
     
    10151013    FlowIterator iter;
    10161014    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1017         flowPtr = NextFlow(&iter)) {
    1018         double min, max;
    1019         if (!flowPtr->isDataLoaded()) {
    1020             continue;
    1021         }
    1022         Rappture::Unirect3d *dataPtr;
    1023         dataPtr = flowPtr->data();
    1024         min = dataPtr->magMin();
    1025         max = dataPtr->magMax();
    1026         if (min < magMin) {
    1027             magMin = min;
    1028         }
    1029         if (max > magMax) {
    1030             magMax = max;
    1031         }
    1032         if (dataPtr->xMin() < xMin) {
    1033             xMin = dataPtr->xMin();
    1034         }
    1035         if (dataPtr->yMin() < yMin) {
    1036             yMin = dataPtr->yMin();
    1037         }
    1038         if (dataPtr->zMin() < zMin) {
    1039             zMin = dataPtr->zMin();
    1040         }
    1041         if (dataPtr->xMax() > xMax) {
    1042             xMax = dataPtr->xMax();
    1043         }
    1044         if (dataPtr->yMax() > yMax) {
    1045             yMax = dataPtr->yMax();
    1046         }
    1047         if (dataPtr->zMax() > zMax) {
    1048             zMax = dataPtr->zMax();
    1049         }
     1015        flowPtr = NextFlow(&iter)) {
     1016        double min, max;
     1017        if (!flowPtr->isDataLoaded()) {
     1018            continue;
     1019        }
     1020        Rappture::Unirect3d *dataPtr;
     1021        dataPtr = flowPtr->data();
     1022        min = dataPtr->magMin();
     1023        max = dataPtr->magMax();
     1024        if (min < magMin) {
     1025            magMin = min;
     1026        }
     1027        if (max > magMax) {
     1028            magMax = max;
     1029        }
     1030        if (dataPtr->xMin() < xMin) {
     1031            xMin = dataPtr->xMin();
     1032        }
     1033        if (dataPtr->yMin() < yMin) {
     1034            yMin = dataPtr->yMin();
     1035        }
     1036        if (dataPtr->zMin() < zMin) {
     1037            zMin = dataPtr->zMin();
     1038        }
     1039        if (dataPtr->xMax() > xMax) {
     1040            xMax = dataPtr->xMax();
     1041        }
     1042        if (dataPtr->yMax() > yMax) {
     1043            yMax = dataPtr->yMax();
     1044        }
     1045        if (dataPtr->zMax() > zMax) {
     1046            zMax = dataPtr->zMax();
     1047        }
    10501048    }
    10511049    TRACE("MapFlows magMin=%g magMax=%g\n", NanoVis::magMin, NanoVis::magMax);
    10521050
    10531051    /*
    1054      * Step 2.  Generate the vector field from each data set.
     1052     * Step 2. Generate the vector field from each data set.
    10551053     */
    10561054    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1057          flowPtr = NextFlow(&iter)) {
    1058         if (!flowPtr->isDataLoaded()) {
    1059             continue;                   // Flow exists, but no data has
    1060                                         // been loaded yet.
    1061         }
    1062         if (flowPtr->visible()) {
    1063             flowPtr->InitializeParticles();
    1064         }
    1065         if (!flowPtr->ScaleVectorField()) {
    1066             return false;
    1067         }
    1068         // FIXME: This doesn't work when there is more than one flow.
    1069         licRenderer->set_offset(flowPtr->GetRelativePosition());
     1055         flowPtr = NextFlow(&iter)) {
     1056        if (!flowPtr->isDataLoaded()) {
     1057            continue; // Flow exists, but no data has been loaded yet.
     1058        }
     1059        if (flowPtr->visible()) {
     1060            flowPtr->InitializeParticles();
     1061        }
     1062        if (!flowPtr->ScaleVectorField()) {
     1063            return false;
     1064        }
     1065        // FIXME: This doesn't work when there is more than one flow.
     1066        licRenderer->set_offset(flowPtr->GetRelativePosition());
    10701067        NanoVis::velocityArrowsSlice->slicePos(flowPtr->GetRelativePosition());
    10711068       
     
    10761073
    10771074void
    1078 NanoVis::RenderFlows(void)
     1075NanoVis::RenderFlows()
    10791076{
    10801077    FlowCmd *flowPtr;
    10811078    FlowIterator iter;
    10821079    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1083         flowPtr = NextFlow(&iter)) {
    1084         if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
    1085             flowPtr->Render();
    1086         }
     1080        flowPtr = NextFlow(&iter)) {
     1081        if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
     1082            flowPtr->Render();
     1083        }
    10871084    }
    10881085    flags &= ~REDRAW_PENDING;
     
    10901087
    10911088void
    1092 NanoVis::ResetFlows(void)
     1089NanoVis::ResetFlows()
    10931090{
    10941091    FlowCmd *flowPtr;
     
    10961093
    10971094    if (licRenderer->active()) {
    1098         NanoVis::licRenderer->reset();
     1095        NanoVis::licRenderer->reset();
    10991096    }
    11001097    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1101         flowPtr = NextFlow(&iter)) {
    1102         if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
    1103             flowPtr->ResetParticles();
    1104         }
     1098        flowPtr = NextFlow(&iter)) {
     1099        if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
     1100            flowPtr->ResetParticles();
     1101        }
    11051102    }
    11061103}   
    11071104
    11081105void
    1109 NanoVis::AdvectFlows(void)
     1106NanoVis::AdvectFlows()
    11101107{
    11111108    FlowCmd *flowPtr;
    11121109    FlowIterator iter;
    11131110    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1114         flowPtr = NextFlow(&iter)) {
    1115         if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
    1116             flowPtr->Advect();
    1117         }
     1111        flowPtr = NextFlow(&iter)) {
     1112        if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
     1113            flowPtr->Advect();
     1114        }
    11181115    }
    11191116}   
    11201117
    1121 /*
    1122  *---------------------------------------------------------------------------
     1118/**
     1119 * \brief Convert a Tcl_Obj representing the label of a child node into its
     1120 * integer node id.
    11231121 *
    1124  * AxisSwitchProc --
     1122 * \param clientData Flag indicating if the node is considered before or
     1123 * after the insertion position.
     1124 * \param interp Interpreter to send results back to
     1125 * \param switchName Not used
     1126 * \param objPtr String representation
     1127 * \param record Structure record
     1128 * \param offset Not used
     1129 * \param flags Not used
    11251130 *
    1126  *      Convert a Tcl_Obj representing the label of a child node into its
    1127  *      integer node id.
    1128  *
    1129  * Results:
    1130  *      The return value is a standard Tcl result.
    1131  *
    1132  *---------------------------------------------------------------------------
     1131 * \return The return value is a standard Tcl result.
    11331132 */
    1134 /*ARGSUSED*/
    1135 static int
    1136 AxisSwitchProc(
    1137     ClientData clientData,      /* Flag indicating if the node is considered
    1138                                  * before or after the insertion position. */
    1139     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1140     const char *switchName,     /* Not used. */
    1141     Tcl_Obj *objPtr,            /* String representation */
    1142     char *record,               /* Structure record */
    1143     int offset,                 /* Not used. */
    1144     int flags)                  /* Not used. */
     1133static int
     1134AxisSwitchProc(ClientData clientData, Tcl_Interp *interp,
     1135               const char *switchName, Tcl_Obj *objPtr,
     1136               char *record, int offset, int flags)
    11451137{
    11461138    const char *string = Tcl_GetString(objPtr);
    11471139    if (string[1] == '\0') {
    1148         FlowCmd::SliceAxis *axisPtr = (FlowCmd::SliceAxis *)(record + offset);
     1140        FlowCmd::SliceAxis *axisPtr = (FlowCmd::SliceAxis *)(record + offset);
    11491141        char c;
    11501142        c = tolower((unsigned char)string[0]);
     
    11661158}
    11671159
    1168 /*
    1169  *---------------------------------------------------------------------------
     1160/**
     1161 * \brief Convert a Tcl_Obj representing the label of a list of four color
     1162 * components in to a RGBA color value.
    11701163 *
    1171  * ColorSwitchProc --
    1172  *
    1173  *      Convert a Tcl_Obj representing the label of a list of four color
    1174  *      components in to a RGBA color value.
    1175  *
    1176  * Results:
    1177  *      The return value is a standard Tcl result.
    1178  *
    1179  *---------------------------------------------------------------------------
     1164 * \param clientData Flag indicating if the node is considered before or
     1165 * after the insertion position.
     1166 * \param interp Interpreter to send results back to
     1167 * \param switchName Not used
     1168 * \param objPtr String representation
     1169 * \param record Structure record
     1170 * \param offset Not used
     1171 * \param flags Not used
     1172 *
     1173 * \return The return value is a standard Tcl result.
    11801174 */
    1181 /*ARGSUSED*/
    1182 static int
    1183 ColorSwitchProc(
    1184     ClientData clientData,      /* Flag indicating if the node is considered
    1185                                  * before or after the insertion position. */
    1186     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1187     const char *switchName,     /* Not used. */
    1188     Tcl_Obj *objPtr,            /* String representation */
    1189     char *record,               /* Structure record */
    1190     int offset,                 /* Not used. */
    1191     int flags)                  /* Not used. */
     1175static int
     1176ColorSwitchProc(ClientData clientData, Tcl_Interp *interp,
     1177                const char *switchName, Tcl_Obj *objPtr,
     1178                char *record, int offset, int flags)
    11921179{
    11931180    Tcl_Obj **objv;
     
    11961183
    11971184    if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
    1198         return TCL_ERROR;
     1185        return TCL_ERROR;
    11991186    }
    12001187    if ((objc < 3) || (objc > 4)) {
    1201         Tcl_AppendResult(interp, "wrong # of elements in color definition",
    1202                         (char *)NULL);
    1203         return TCL_ERROR;
     1188        Tcl_AppendResult(interp, "wrong # of elements in color definition",
     1189                        (char *)NULL);
     1190        return TCL_ERROR;
    12041191    }
    12051192    float values[4];
     
    12071194    values[3] = 1.0f;
    12081195    for (i = 0; i < objc; i++) {
    1209         float value;
    1210 
    1211         if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) {
    1212             return TCL_ERROR;
    1213         }
    1214         if ((value < 0.0) || (value > 1.0)) {
    1215             Tcl_AppendResult(interp, "bad component value in \"",
    1216                 Tcl_GetString(objPtr), "\": color values must be [0..1]",
    1217                 (char *)NULL);
    1218             return TCL_ERROR;
    1219         }
    1220         values[i] = value;
    1221     }       
     1196        float value;
     1197
     1198        if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) {
     1199            return TCL_ERROR;
     1200        }
     1201        if ((value < 0.0) || (value > 1.0)) {
     1202            Tcl_AppendResult(interp, "bad component value in \"",
     1203                             Tcl_GetString(objPtr), "\": color values must be [0..1]",
     1204                             (char *)NULL);
     1205            return TCL_ERROR;
     1206        }
     1207        values[i] = value;
     1208    }
    12221209    colorPtr->r = values[0];
    12231210    colorPtr->g = values[1];
     
    12271214}
    12281215
    1229 /*
    1230  *---------------------------------------------------------------------------
     1216/**
     1217 * \brief Convert a Tcl_Obj representing the a 3-D coordinate into a point.
    12311218 *
    1232  * PointSwitchProc --
     1219 * \param clientData Flag indicating if the node is considered before or
     1220 * after the insertion position.
     1221 * \param interp Interpreter to send results back to
     1222 * \param switchName Not used
     1223 * \param objPtr String representation
     1224 * \param record Structure record
     1225 * \param offset Not used
     1226 * \param flags Not used
    12331227 *
    1234  *      Convert a Tcl_Obj representing the a 3-D coordinate into
    1235  *      a point.
    1236  *
    1237  * Results:
    1238  *      The return value is a standard Tcl result.
    1239  *
    1240  *---------------------------------------------------------------------------
     1228 * \return The return value is a standard Tcl result.
    12411229 */
    1242 /*ARGSUSED*/
    1243 static int
    1244 PointSwitchProc(
    1245     ClientData clientData,      /* Flag indicating if the node is considered
    1246                                  * before or after the insertion position. */
    1247     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1248     const char *switchName,     /* Not used. */
    1249     Tcl_Obj *objPtr,            /* String representation */
    1250     char *record,               /* Structure record */
    1251     int offset,                 /* Not used. */
    1252     int flags)                  /* Not used. */
     1230static int
     1231PointSwitchProc(ClientData clientData, Tcl_Interp *interp,
     1232                const char *switchName, Tcl_Obj *objPtr,
     1233                char *record, int offset, int flags)
    12531234{
    12541235    FlowPoint *pointPtr = (FlowPoint *)(record + offset);
     
    12571238
    12581239    if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
    1259         return TCL_ERROR;
     1240        return TCL_ERROR;
    12601241    }
    12611242    if (objc != 3) {
    1262         Tcl_AppendResult(interp, "wrong # of elements for box coordinates: "
    1263                         " should be \"x y z\"", (char *)NULL);
    1264         return TCL_ERROR;
     1243        Tcl_AppendResult(interp, "wrong # of elements for box coordinates: "
     1244                        " should be \"x y z\"", (char *)NULL);
     1245        return TCL_ERROR;
    12651246    }
    12661247    float values[3];
    12671248    int i;
    12681249    for (i = 0; i < objc; i++) {
    1269         float value;
    1270 
    1271         if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) {
    1272             return TCL_ERROR;
    1273         }
    1274         values[i] = value;
    1275     }       
     1250        float value;
     1251
     1252        if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) {
     1253            return TCL_ERROR;
     1254        }
     1255        values[i] = value;
     1256    }
    12761257    pointPtr->x = values[0];
    12771258    pointPtr->y = values[1];
     
    12801261}
    12811262
    1282 /*
    1283  *---------------------------------------------------------------------------
     1263/**
     1264 * \brief Convert a Tcl_Obj representing the a 3-D coordinate into a point.
    12841265 *
    1285  * PositionSwitchProc --
     1266 * \param clientData Flag indicating if the node is considered before or
     1267 * after the insertion position.
     1268 * \param interp Interpreter to send results back to
     1269 * \param switchName Not used
     1270 * \param objPtr String representation
     1271 * \param record Structure record
     1272 * \param offset Not used
     1273 * \param flags Not used
    12861274 *
    1287  *      Convert a Tcl_Obj representing the a 3-D coordinate into
    1288  *      a point.
    1289  *
    1290  * Results:
    1291  *      The return value is a standard Tcl result.
    1292  *
    1293  *---------------------------------------------------------------------------
     1275 * \return The return value is a standard Tcl result.
    12941276 */
    1295 /*ARGSUSED*/
    1296 static int
    1297 PositionSwitchProc(
    1298     ClientData clientData,      /* Flag indicating if the node is considered
    1299                                  * before or after the insertion position. */
    1300     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1301     const char *switchName,     /* Not used. */
    1302     Tcl_Obj *objPtr,            /* String representation */
    1303     char *record,               /* Structure record */
    1304     int offset,                 /* Not used. */
    1305     int flags)                  /* Not used. */
     1277static int
     1278PositionSwitchProc(ClientData clientData, Tcl_Interp *interp,
     1279                   const char *switchName, Tcl_Obj *objPtr,
     1280                   char *record, int offset, int flags)
    13061281{
    13071282    FlowPosition *posPtr = (FlowPosition *)(record + offset);
     
    13121287    p = strrchr((char *)string, '%');
    13131288    if (p == NULL) {
    1314         float value;
    1315 
    1316         if (GetFloatFromObj(interp, objPtr, &value) != TCL_OK) {
    1317             return TCL_ERROR;
    1318         }
    1319         posPtr->value = value;
    1320         posPtr->flags = ABSPOS;
     1289        float value;
     1290
     1291        if (GetFloatFromObj(interp, objPtr, &value) != TCL_OK) {
     1292            return TCL_ERROR;
     1293        }
     1294        posPtr->value = value;
     1295        posPtr->flags = ABSPOS;
    13211296    } else {
    1322         double value;
    1323 
    1324         *p = '\0';
    1325         if (Tcl_GetDouble(interp, string, &value) != TCL_OK) {
    1326             return TCL_ERROR;
    1327         }
    1328         posPtr->value = (float)value * 0.01;
    1329         posPtr->flags = RELPOS;
    1330     }
    1331     return TCL_OK;
    1332 }
    1333 
    1334 /*
    1335  *---------------------------------------------------------------------------
     1297        double value;
     1298
     1299        *p = '\0';
     1300        if (Tcl_GetDouble(interp, string, &value) != TCL_OK) {
     1301            return TCL_ERROR;
     1302        }
     1303        posPtr->value = (float)value * 0.01;
     1304        posPtr->flags = RELPOS;
     1305    }
     1306    return TCL_OK;
     1307}
     1308
     1309/**
     1310 * \brief Convert a Tcl_Obj representing the transfer function into a
     1311 *  TransferFunction pointer. 
    13361312 *
    1337  * TransferFunctionSwitchProc --
     1313 * The transfer function must have been previously defined.
    13381314 *
    1339  *      Convert a Tcl_Obj representing the transfer function into a
    1340  *      TransferFunction pointer.  The transfer function must have been
    1341  *      previously defined.
     1315 * \param clientData Flag indicating if the node is considered before or
     1316 * after the insertion position.
     1317 * \param interp Interpreter to send results back to
     1318 * \param switchName Not used
     1319 * \param objPtr String representation
     1320 * \param record Structure record
     1321 * \param offset Not used
     1322 * \param flags Not used
    13421323 *
    1343  * Results:
    1344  *      The return value is a standard Tcl result.
    1345  *
    1346  *---------------------------------------------------------------------------
     1324 * \return The return value is a standard Tcl result.
    13471325 */
    1348 /*ARGSUSED*/
    1349 static int
    1350 TransferFunctionSwitchProc(
    1351     ClientData clientData,      /* Flag indicating if the node is considered
    1352                                  * before or after the insertion position. */
    1353     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1354     const char *switchName,     /* Not used. */
    1355     Tcl_Obj *objPtr,            /* String representation */
    1356     char *record,               /* Structure record */
    1357     int offset,                 /* Not used. */
    1358     int flags)                  /* Not used. */
     1326static int
     1327TransferFunctionSwitchProc(ClientData clientData, Tcl_Interp *interp,
     1328                           const char *switchName, Tcl_Obj *objPtr,
     1329                           char *record, int offset, int flags)
    13591330{
    13601331    TransferFunction **funcPtrPtr = (TransferFunction **)(record + offset);
     
    13721343static int
    13731344FlowConfigureOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1374                 Tcl_Obj *const *objv)
     1345                Tcl_Obj *const *objv)
    13751346{
    13761347    FlowCmd *flowPtr = (FlowCmd *)clientData;
    13771348
    13781349    if (flowPtr->ParseSwitches(interp, objc - 2, objv + 2) != TCL_OK) {
    1379         return TCL_ERROR;
     1350        return TCL_ERROR;
    13801351    }
    13811352    NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     
    13851356static int
    13861357FlowParticlesAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1387                    Tcl_Obj *const *objv)
     1358                   Tcl_Obj *const *objv)
    13881359{
    13891360    FlowCmd *flowPtr = (FlowCmd *)clientData;
    13901361
    13911362    if (flowPtr->CreateParticles(interp, objv[3]) != TCL_OK) {
    1392         return TCL_ERROR;
     1363        return TCL_ERROR;
    13931364    }
    13941365    FlowParticles *particlesPtr;
    13951366    if (flowPtr->GetParticles(interp, objv[3], &particlesPtr) != TCL_OK) {
    1396         return TCL_ERROR;
     1367        return TCL_ERROR;
    13971368    }
    13981369    if (particlesPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) {
    1399         delete particlesPtr;
    1400         return TCL_ERROR;
     1370        delete particlesPtr;
     1371        return TCL_ERROR;
    14011372    }
    14021373    particlesPtr->Configure();
     
    14081379static int
    14091380FlowParticlesConfigureOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1410                         Tcl_Obj *const *objv)
     1381                        Tcl_Obj *const *objv)
    14111382{
    14121383    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    14141385    FlowParticles *particlesPtr;
    14151386    if (flowPtr->GetParticles(interp, objv[3], &particlesPtr) != TCL_OK) {
    1416         return TCL_ERROR;
     1387        return TCL_ERROR;
    14171388    }
    14181389    if (particlesPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) {
    1419         return TCL_ERROR;
     1390        return TCL_ERROR;
    14201391    }
    14211392    particlesPtr->Configure();
     
    14261397static int
    14271398FlowParticlesDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1428                       Tcl_Obj *const *objv)
     1399                      Tcl_Obj *const *objv)
    14291400{
    14301401    FlowCmd *flowPtr = (FlowCmd *)clientData;
    14311402    int i;
    14321403    for (i = 3; i < objc; i++) {
    1433         FlowParticles *particlesPtr;
    1434 
    1435         if (flowPtr->GetParticles(NULL, objv[i], &particlesPtr) == TCL_OK) {
    1436             delete particlesPtr;
    1437         }
     1404        FlowParticles *particlesPtr;
     1405
     1406        if (flowPtr->GetParticles(NULL, objv[i], &particlesPtr) == TCL_OK) {
     1407            delete particlesPtr;
     1408        }
    14381409    }
    14391410    NanoVis::EventuallyRedraw();
     
    14431414static int
    14441415FlowParticlesNamesOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1445                      Tcl_Obj *const *objv)
     1416                     Tcl_Obj *const *objv)
    14461417{
    14471418    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    14511422    FlowParticles *particlesPtr;
    14521423    for (particlesPtr = flowPtr->FirstParticles(&iter); particlesPtr != NULL;
    1453         particlesPtr = flowPtr->NextParticles(&iter)) {
    1454         Tcl_Obj *objPtr;
    1455 
    1456         objPtr = Tcl_NewStringObj(particlesPtr->name(), -1);
    1457         Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
     1424        particlesPtr = flowPtr->NextParticles(&iter)) {
     1425        Tcl_Obj *objPtr;
     1426
     1427        objPtr = Tcl_NewStringObj(particlesPtr->name(), -1);
     1428        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    14581429    }
    14591430    Tcl_SetObjResult(interp, listObjPtr);
     
    14611432}
    14621433
    1463 /*
    1464  *---------------------------------------------------------------------------
    1465  *
    1466  * FlowParticlesObjCmd --
    1467  *
    1468  *      This procedure is invoked to process commands on behalf of the flow
    1469  *      object.
    1470  *
    1471  * Results:
    1472  *      A standard Tcl result.
    1473  *
    1474  * Side effects:
    1475  *      See the user documentation.
    1476  *
    1477  * $flow particles oper $name
    1478  *---------------------------------------------------------------------------
    1479  */
    14801434static Rappture::CmdSpec flowParticlesOps[] = {
    14811435    {"add",        1, FlowParticlesAddOp,        4, 0, "name ?switches?",},
    14821436    {"configure",  1, FlowParticlesConfigureOp,  4, 0, "name ?switches?",},
    1483     {"delete",     1, FlowParticlesDeleteOp,     4, 0, "?name...?"},
     1437    {"delete",     1, FlowParticlesDeleteOp,     4, 0, "?name...?"},
    14841438    {"names",      1, FlowParticlesNamesOp,      3, 4, "?pattern?"},
    14851439};
     
    14871441static int nFlowParticlesOps = NumCmdSpecs(flowParticlesOps);
    14881442
     1443/**
     1444 * \brief This procedure is invoked to process commands on behalf of the flow
     1445 * object.
     1446 *
     1447 * Side effects: See the user documentation.
     1448 *
     1449 * $flow particles oper $name
     1450 *
     1451 * \return A standard Tcl result.
     1452 */
    14891453static int
    14901454FlowParticlesOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1491                Tcl_Obj *const *objv)
     1455                Tcl_Obj *const *objv)
    14921456{
    14931457    Tcl_ObjCmdProc *proc;
    14941458    proc = Rappture::GetOpFromObj(interp, nFlowParticlesOps, flowParticlesOps,
    1495         Rappture::CMDSPEC_ARG2, objc, objv, 0);
     1459                                  Rappture::CMDSPEC_ARG2, objc, objv, 0);
    14961460    if (proc == NULL) {
    1497         return TCL_ERROR;
     1461        return TCL_ERROR;
    14981462    }
    14991463    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    15071471static int
    15081472FlowBoxAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1509                Tcl_Obj *const *objv)
     1473             Tcl_Obj *const *objv)
    15101474{
    15111475    FlowCmd *flowPtr = (FlowCmd *)clientData;
    15121476
    15131477    if (flowPtr->CreateBox(interp, objv[3]) != TCL_OK) {
    1514         return TCL_ERROR;
     1478        return TCL_ERROR;
    15151479    }
    15161480    FlowBox *boxPtr;
    15171481    if (flowPtr->GetBox(interp, objv[3], &boxPtr) != TCL_OK) {
    1518         return TCL_ERROR;
     1482        return TCL_ERROR;
    15191483    }
    15201484    if (boxPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) {
    1521         delete boxPtr;
    1522         return TCL_ERROR;
     1485        delete boxPtr;
     1486        return TCL_ERROR;
    15231487    }
    15241488    NanoVis::EventuallyRedraw();
     
    15291493static int
    15301494FlowBoxDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1531                    Tcl_Obj *const *objv)
     1495                Tcl_Obj *const *objv)
    15321496{
    15331497    FlowCmd *flowPtr = (FlowCmd *)clientData;
    15341498    int i;
    15351499    for (i = 3; i < objc; i++) {
    1536         FlowBox *boxPtr;
    1537 
    1538         if (flowPtr->GetBox(NULL, objv[i], &boxPtr) == TCL_OK) {
    1539             delete boxPtr;
    1540         }
     1500        FlowBox *boxPtr;
     1501
     1502        if (flowPtr->GetBox(NULL, objv[i], &boxPtr) == TCL_OK) {
     1503            delete boxPtr;
     1504        }
    15411505    }
    15421506    NanoVis::EventuallyRedraw();
     
    15461510static int
    15471511FlowBoxNamesOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1548              Tcl_Obj *const *objv)
     1512               Tcl_Obj *const *objv)
    15491513{
    15501514    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    15541518    FlowBox *boxPtr;
    15551519    for (boxPtr = flowPtr->FirstBox(&iter); boxPtr != NULL;
    1556         boxPtr = flowPtr->NextBox(&iter)) {
    1557         Tcl_Obj *objPtr;
    1558 
    1559         objPtr = Tcl_NewStringObj(boxPtr->name(), -1);
    1560         Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
     1520        boxPtr = flowPtr->NextBox(&iter)) {
     1521        Tcl_Obj *objPtr;
     1522
     1523        objPtr = Tcl_NewStringObj(boxPtr->name(), -1);
     1524        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    15611525    }
    15621526    Tcl_SetObjResult(interp, listObjPtr);
     
    15661530static int
    15671531FlowBoxConfigureOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1568                         Tcl_Obj *const *objv)
     1532                   Tcl_Obj *const *objv)
    15691533{
    15701534    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    15721536    FlowBox *boxPtr;
    15731537    if (flowPtr->GetBox(interp, objv[3], &boxPtr) != TCL_OK) {
    1574         return TCL_ERROR;
     1538        return TCL_ERROR;
    15751539    }
    15761540    if (boxPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) {
    1577         return TCL_ERROR;
     1541        return TCL_ERROR;
    15781542    }
    15791543    NanoVis::EventuallyRedraw();
     
    15811545}
    15821546
    1583 /*
    1584  *---------------------------------------------------------------------------
    1585  *
    1586  * FlowBoxOp--
    1587  *
    1588  *      This procedure is invoked to process commands on behalf of the flow
    1589  *      object.
    1590  *
    1591  * Results:
    1592  *      A standard Tcl result.
    1593  *
    1594  * Side effects:
    1595  *      See the user documentation.
    1596  *
    1597  *---------------------------------------------------------------------------
    1598  */
    15991547static Rappture::CmdSpec flowBoxOps[] = {
    16001548    {"add",        1, FlowBoxAddOp,        4, 0, "name ?switches?",},
    16011549    {"configure",  1, FlowBoxConfigureOp,  4, 0, "name ?switches?",},
    1602     {"delete",     1, FlowBoxDeleteOp,     3, 0, "?name...?"},
     1550    {"delete",     1, FlowBoxDeleteOp,     3, 0, "?name...?"},
    16031551    {"names",      1, FlowBoxNamesOp,      3, 0, "?pattern?"},
    16041552};
     
    16061554static int nFlowBoxOps = NumCmdSpecs(flowBoxOps);
    16071555
     1556/**
     1557 * \brief This procedure is invoked to process commands on behalf of the flow
     1558 *         object.
     1559 *
     1560 * Side effects:  See the user documentation.
     1561 *
     1562 * \return A standard Tcl result.
     1563 */
    16081564static int
    16091565FlowBoxOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1610                Tcl_Obj *const *objv)
     1566          Tcl_Obj *const *objv)
    16111567{
    16121568    Tcl_ObjCmdProc *proc;
    16131569    proc = Rappture::GetOpFromObj(interp, nFlowBoxOps, flowBoxOps,
    1614         Rappture::CMDSPEC_ARG2, objc, objv, 0);
     1570                                  Rappture::CMDSPEC_ARG2, objc, objv, 0);
    16151571    if (proc == NULL) {
    1616         return TCL_ERROR;
     1572        return TCL_ERROR;
    16171573    }
    16181574    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    16251581
    16261582/*
    1627  * ----------------------------------------------------------------------
    16281583 * CLIENT COMMAND:
    16291584 *   $flow legend <width> <height>
     
    16331588 * to one, drawn in the given transfer function.  The resulting image
    16341589 * is returned in the size <width> x <height>.
    1635  * ----------------------------------------------------------------------
    16361590 */
    16371591static int
    16381592FlowLegendOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1639           Tcl_Obj *const *objv)
     1593             Tcl_Obj *const *objv)
    16401594{
    16411595    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    16461600    if (tf == NULL) {
    16471601        Tcl_AppendResult(interp, "unknown transfer function \"", string, "\"",
    1648                              (char*)NULL);
     1602                         (char*)NULL);
    16491603        return TCL_ERROR;
    16501604    }
     
    16631617}
    16641618
    1665 /*
    1666  *---------------------------------------------------------------------------
    1667  *
    1668  * FlowInstObjCmd --
    1669  *
    1670  *      This procedure is invoked to process commands on behalf of the flow
    1671  *      object.
    1672  *
    1673  * Results:
    1674  *      A standard Tcl result.
    1675  *
    1676  * Side effects:
    1677  *      See the user documentation.
    1678  *
    1679  *---------------------------------------------------------------------------
    1680  */
    16811619static Rappture::CmdSpec flowInstOps[] = {
    16821620    {"box",         1, FlowBoxOp,        2, 0, "oper ?args?"},
    16831621    {"configure",   1, FlowConfigureOp,  2, 0, "?switches?"},
    1684     {"data",        1, FlowDataOp,       2, 0, "oper ?args?"},
     1622    {"data",        1, FlowDataOp,       2, 0, "oper ?args?"},
    16851623    {"legend",      1, FlowLegendOp,     4, 4, "w h"},
    16861624    {"particles",   1, FlowParticlesOp,  2, 0, "oper ?args?"}
     
    16881626static int nFlowInstOps = NumCmdSpecs(flowInstOps);
    16891627
     1628/**
     1629 * \brief This procedure is invoked to process commands on behalf of the flow
     1630 * object.
     1631 *
     1632 * Side effects: See the user documentation.
     1633 *
     1634 * \return A standard Tcl result.
     1635 */
    16901636static int
    16911637FlowInstObjCmd(ClientData clientData, Tcl_Interp *interp, int objc,
    1692                Tcl_Obj *const *objv)
     1638               Tcl_Obj *const *objv)
    16931639{
    16941640    Tcl_ObjCmdProc *proc;
    16951641    proc = Rappture::GetOpFromObj(interp, nFlowInstOps, flowInstOps,
    1696         Rappture::CMDSPEC_ARG1, objc, objv, 0);
     1642                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    16971643    if (proc == NULL) {
    1698         return TCL_ERROR;
     1644        return TCL_ERROR;
    16991645    }
    17001646    assert(CheckGL(AT));
     
    17071653}
    17081654
    1709 /*
    1710  *---------------------------------------------------------------------------
     1655/**
     1656 * \brief Deletes the command associated with the tree.
    17111657 *
    1712  * FlowInstDeleteProc --
    1713  *
    1714  *      Deletes the command associated with the tree.  This is called only
    1715  *      when the command associated with the tree is destroyed.
    1716  *
    1717  * Results:
    1718  *      None.
    1719  *
    1720  *---------------------------------------------------------------------------
     1658 * This is called only when the command associated with the tree is destroyed.
    17211659 */
    17221660static void
     
    17271665}
    17281666
    1729 /*
    1730  *---------------------------------------------------------------------------
    1731  *
    1732  * FlowAddOp --
    1733  *
    1734  *---------------------------------------------------------------------------
    1735  */
    1736 /*ARGSUSED*/
    17371667static int
    17381668FlowAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1739           Tcl_Obj *const *objv)
     1669          Tcl_Obj *const *objv)
    17401670{
    17411671    if (NanoVis::CreateFlow(interp, objv[2]) != TCL_OK) {
    1742         return TCL_ERROR;
     1672        return TCL_ERROR;
    17431673    }
    17441674    FlowCmd *flowPtr;
    17451675    if (NanoVis::GetFlow(interp, objv[2], &flowPtr) != TCL_OK) {
    1746         return TCL_ERROR;
     1676        return TCL_ERROR;
    17471677    }
    17481678    if (flowPtr->ParseSwitches(interp, objc - 3, objv + 3) != TCL_OK) {
    1749         Tcl_DeleteCommand(interp, flowPtr->name());
    1750         return TCL_ERROR;
     1679        Tcl_DeleteCommand(interp, flowPtr->name());
     1680        return TCL_ERROR;
    17511681    }
    17521682    Tcl_SetObjResult(interp, objv[2]);
     
    17551685}
    17561686
    1757 /*
    1758  *---------------------------------------------------------------------------
    1759  *
    1760  * FlowDeleteOp --
    1761  *
    1762  *---------------------------------------------------------------------------
    1763  */
    1764 /*ARGSUSED*/
    17651687static int
    17661688FlowDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1767              Tcl_Obj *const *objv)
     1689             Tcl_Obj *const *objv)
    17681690{
    17691691    int i;
    17701692
    17711693    for (i = 2; i < objc; i++) {
    1772         FlowCmd *flowPtr;
    1773 
    1774         if (NanoVis::GetFlow(interp, objv[i], &flowPtr) != TCL_OK) {
    1775             return TCL_ERROR;
    1776         }
    1777         Tcl_DeleteCommand(interp, flowPtr->name());
     1694        FlowCmd *flowPtr;
     1695
     1696        if (NanoVis::GetFlow(interp, objv[i], &flowPtr) != TCL_OK) {
     1697            return TCL_ERROR;
     1698        }
     1699        Tcl_DeleteCommand(interp, flowPtr->name());
    17781700    }
    17791701    NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     
    17811703}
    17821704
    1783 /*
    1784  *---------------------------------------------------------------------------
    1785  *
    1786  * FlowExistsOp --
    1787  *
    1788  *---------------------------------------------------------------------------
    1789  */
    1790 /*ARGSUSED*/
    17911705static int
    17921706FlowExistsOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1793              Tcl_Obj *const *objv)
     1707             Tcl_Obj *const *objv)
    17941708{
    17951709    bool value;
     
    17981712    value = false;
    17991713    if (NanoVis::GetFlow(NULL, objv[2], &flowPtr) == TCL_OK) {
    1800         value = true;
     1714        value = true;
    18011715    }
    18021716    Tcl_SetBooleanObj(Tcl_GetObjResult(interp), (int)value);
     
    18041718}
    18051719
    1806 /*
    1807  *---------------------------------------------------------------------------
    1808  *
    1809  * FlowGotoOp --
    1810  *
    1811  *      flow goto number
    1812  *
    1813  *---------------------------------------------------------------------------
     1720/**
     1721 * \brief flow goto number
    18141722 */
    18151723static int
    18161724FlowGotoOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1817              Tcl_Obj *const *objv)
     1725           Tcl_Obj *const *objv)
    18181726{
    18191727    int nSteps;
     
    18221730    }
    18231731    if ((nSteps < 0) || (nSteps > SHRT_MAX)) {
    1824         Tcl_AppendResult(interp, "flow goto: bad # of steps \"",
    1825                         Tcl_GetString(objv[2]), "\"", (char *)NULL);
    1826         return TCL_ERROR;
     1732        Tcl_AppendResult(interp, "flow goto: bad # of steps \"",
     1733                        Tcl_GetString(objv[2]), "\"", (char *)NULL);
     1734        return TCL_ERROR;
    18271735    }
    18281736    NanoVis::ResetFlows();
    18291737    if (NanoVis::flags & NanoVis::MAP_FLOWS) {
    1830         NanoVis::MapFlows();
     1738        NanoVis::MapFlows();
    18311739    }
    18321740    int i;
    18331741    NanoVis::AdvectFlows();
    18341742    for (i = 0; i < nSteps; i++) {
    1835         if (NanoVis::licRenderer->active()) {
    1836             NanoVis::licRenderer->convolve();
    1837         }
    1838         NanoVis::AdvectFlows();
     1743        if (NanoVis::licRenderer->active()) {
     1744            NanoVis::licRenderer->convolve();
     1745        }
     1746        NanoVis::AdvectFlows();
    18391747    }
    18401748    NanoVis::EventuallyRedraw();
     
    18421750}
    18431751
    1844 /*
    1845  *---------------------------------------------------------------------------
    1846  *
    1847  * FlowNamesOp --
    1848  *
    1849  *---------------------------------------------------------------------------
    1850  */
    1851 /*ARGSUSED*/
    18521752static int
    18531753FlowNamesOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1854             Tcl_Obj *const *objv)
     1754            Tcl_Obj *const *objv)
    18551755{
    18561756    Tcl_Obj *listObjPtr;
     
    18591759    FlowIterator iter;
    18601760    for (flowPtr = NanoVis::FirstFlow(&iter); flowPtr != NULL;
    1861         flowPtr = NanoVis::NextFlow(&iter)) {
    1862         Tcl_Obj *objPtr;
    1863 
    1864         objPtr = Tcl_NewStringObj(flowPtr->name(), -1);
    1865         Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
     1761        flowPtr = NanoVis::NextFlow(&iter)) {
     1762        Tcl_Obj *objPtr;
     1763
     1764        objPtr = Tcl_NewStringObj(flowPtr->name(), -1);
     1765        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    18661766    }
    18671767    Tcl_SetObjResult(interp, listObjPtr);
     
    18711771static int
    18721772FlowNextOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1873              Tcl_Obj *const *objv)
     1773           Tcl_Obj *const *objv)
    18741774{
    18751775    assert(NanoVis::licRenderer != NULL);
    18761776    if (NanoVis::flags & NanoVis::MAP_FLOWS) {
    1877         NanoVis::MapFlows();
     1777        NanoVis::MapFlows();
    18781778    }
    18791779    NanoVis::EventuallyRedraw();
     
    18851785static int
    18861786FlowResetOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1887              Tcl_Obj *const *objv)
     1787            Tcl_Obj *const *objv)
    18881788{
    18891789    NanoVis::ResetFlows();
     
    18931793#ifdef HAVE_FFMPEG
    18941794
    1895 /*
    1896  *---------------------------------------------------------------------------
     1795/**
     1796 * \brief Convert a Tcl_Obj representing the video format into its
     1797 * integer id.
    18971798 *
    1898  * VideoFormatSwitchProc --
     1799 * \param clientData Not used
     1800 * \param interp Interpreter to send results back to
     1801 * \param switchName Not used
     1802 * \param objPtr String representation
     1803 * \param record Structure record
     1804 * \param offset Not used
     1805 * \param flags Not used
    18991806 *
    1900  *      Convert a Tcl_Obj representing the video format into its
    1901  *      integer id.
    1902  *
    1903  * Results:
    1904  *      The return value is a standard Tcl result.
    1905  *
    1906  *---------------------------------------------------------------------------
     1807 * \return The return value is a standard Tcl result.
    19071808 */
    1908 /*ARGSUSED*/
    1909 static int
    1910 VideoFormatSwitchProc(
    1911     ClientData clientData,      /* Not used. */
    1912     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1913     const char *switchName,     /* Not used. */
    1914     Tcl_Obj *objPtr,            /* String representation */
    1915     char *record,               /* Structure record */
    1916     int offset,                 /* Not used. */
    1917     int flags)                  /* Not used. */
     1809static int
     1810VideoFormatSwitchProc(ClientData clientData, Tcl_Interp *interp,
     1811                      const char *switchName, Tcl_Obj *objPtr,
     1812                      char *record, int offset, int flags)
    19181813{
    19191814    Rappture::AVTranslate::VideoFormats *formatPtr =
    1920         (Rappture::AVTranslate::VideoFormats *)(record + offset);
     1815        (Rappture::AVTranslate::VideoFormats *)(record + offset);
    19211816    const char *string;
    19221817    char c;
     
    19251820    c = string[0];
    19261821    if ((c == 'm') && (strcmp(string, "mpeg") == 0)) {
    1927         *formatPtr =  Rappture::AVTranslate::MPEG1;
     1822        *formatPtr =  Rappture::AVTranslate::MPEG1;
    19281823    } else if ((c == 't') && (strcmp(string, "theora") == 0)) {
    1929         *formatPtr = Rappture::AVTranslate::THEORA;
     1824        *formatPtr = Rappture::AVTranslate::THEORA;
    19301825    } else if ((c == 'm') && (strcmp(string, "mov") == 0)) {
    1931         *formatPtr = Rappture::AVTranslate::QUICKTIME;
     1826        *formatPtr = Rappture::AVTranslate::QUICKTIME;
    19321827    } else {
    1933         Tcl_AppendResult(interp, "bad video format \"", string,
    1934                      "\": should be mpeg, theora, or mov", (char*)NULL);
     1828        Tcl_AppendResult(interp, "bad video format \"", string,
     1829                         "\": should be mpeg, theora, or mov", (char*)NULL);
    19351830    }
    19361831    return TCL_ERROR;
     
    19381833
    19391834struct FlowVideoValues {
    1940     float frameRate;                    /* Frame rate */
    1941     int bitRate;                        /* Video bitrate */
    1942     int width, height;                  /* Dimensions of video frame. */
     1835    float frameRate;         /**< Frame rate */
     1836    int bitRate;             /**< Video bitrate */
     1837    int width, height;       /**< Dimensions of video frame. */
    19431838    int nFrames;
    19441839    Rappture::AVTranslate::VideoFormats format;
     
    19521847Rappture::SwitchSpec FlowCmd::videoSwitches[] = {
    19531848    {Rappture::SWITCH_INT, "-bitrate", "value",
    1954         offsetof(FlowVideoValues, bitRate), 0},
     1849     offsetof(FlowVideoValues, bitRate), 0},
    19551850    {Rappture::SWITCH_CUSTOM, "-format", "string",
    1956         offsetof(FlowVideoValues, format), 0, 0, &videoFormatSwitch},
     1851     offsetof(FlowVideoValues, format), 0, 0, &videoFormatSwitch},
    19571852    {Rappture::SWITCH_FLOAT, "-framerate", "value",
    1958         offsetof(FlowVideoValues, frameRate), 0},
     1853     offsetof(FlowVideoValues, frameRate), 0},
    19591854    {Rappture::SWITCH_INT, "-height", "integer",
    1960         offsetof(FlowVideoValues, height), 0},
     1855     offsetof(FlowVideoValues, height), 0},
    19611856    {Rappture::SWITCH_INT, "-numframes", "count",
    1962         offsetof(FlowVideoValues, nFrames), 0},
     1857     offsetof(FlowVideoValues, nFrames), 0},
    19631858    {Rappture::SWITCH_INT, "-width", "integer",
    1964         offsetof(FlowVideoValues, width), 0},
     1859     offsetof(FlowVideoValues, width), 0},
    19651860    {Rappture::SWITCH_END}
    19661861};
     
    19681863static int
    19691864FlowVideoOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1970             Tcl_Obj *const *objv)
     1865            Tcl_Obj *const *objv)
    19711866{
    19721867    struct pollfd pollResults;
     
    19761871    pollResults.events = POLLIN;
    19771872
    1978 #define PENDING_TIMEOUT         10  /* milliseconds. */
     1873#define PENDING_TIMEOUT          10  /* milliseconds. */
    19791874    timeout = PENDING_TIMEOUT;
    19801875
     
    19831878
    19841879    token = Tcl_GetString(objv[2]);
    1985     values.frameRate = 25.0f;           // Default frame rate 25 fps
    1986     values.bitRate = 6000000;           // Default video bit rate.
     1880    values.frameRate = 25.0f;                // Default frame rate 25 fps
     1881    values.bitRate = 6000000;                // Default video bit rate.
    19871882    values.width = NanoVis::win_width;
    19881883    values.height = NanoVis::win_height;
     
    19901885    values.format = Rappture::AVTranslate::MPEG1;
    19911886    if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches,
    1992         objc - 3, objv + 3, &values, SWITCH_DEFAULTS) < 0) {
    1993         return TCL_ERROR;
     1887                                objc - 3, objv + 3, &values, SWITCH_DEFAULTS) < 0) {
     1888        return TCL_ERROR;
    19941889    }
    19951890    if ((values.width < 0) || (values.width > SHRT_MAX) ||
    1996         (values.height < 0) || (values.height > SHRT_MAX)) {
    1997         Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL);
    1998         return TCL_ERROR;
     1891        (values.height < 0) || (values.height > SHRT_MAX)) {
     1892        Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL);
     1893        return TCL_ERROR;
    19991894    }
    20001895    if ((values.frameRate < 0.0f) || (values.frameRate > 30.0f)) {
    2001         Tcl_AppendResult(interp, "bad frame rate.", (char *)NULL);
    2002         return TCL_ERROR;
     1896        Tcl_AppendResult(interp, "bad frame rate.", (char *)NULL);
     1897        return TCL_ERROR;
    20031898    }
    20041899    if (values.bitRate < 0) {
    2005         Tcl_AppendResult(interp, "bad bit rate.", (char *)NULL);
    2006         return TCL_ERROR;
     1900        Tcl_AppendResult(interp, "bad bit rate.", (char *)NULL);
     1901        return TCL_ERROR;
    20071902    }
    20081903    if (NanoVis::licRenderer == NULL) {
    2009         Tcl_AppendResult(interp, "no lic renderer.", (char *)NULL);
    2010         return TCL_ERROR;
     1904        Tcl_AppendResult(interp, "no lic renderer.", (char *)NULL);
     1905        return TCL_ERROR;
    20111906    }
    20121907    // Save the old dimensions of the offscreen buffer.
     
    20261921    if (!movie.init(context, tmpFileName)) {
    20271922        Tcl_AppendResult(interp, "can't initialized movie \"", tmpFileName,
    2028                 "\": ", context.remark(), (char *)NULL);
    2029         return TCL_ERROR;
     1923                         "\": ", context.remark(), (char *)NULL);
     1924        return TCL_ERROR;
    20301925    }
    20311926    if ((values.width != oldWidth) || (values.height != oldHeight)) {
    2032         // Resize to the requested size.
    2033         NanoVis::resize_offscreen_buffer(values.width, values.height);
     1927        // Resize to the requested size.
     1928        NanoVis::resize_offscreen_buffer(values.width, values.height);
    20341929    }
    20351930    // Now compute the line padding for the offscreen buffer.
     
    20411936    bool canceled = false;
    20421937    for (int i = 1; i <= values.nFrames; i++) {
    2043         if (((i & 0xF) == 0) && (poll(&pollResults, 1, 0) > 0)) {
    2044             /* If there's another command on stdin, that means the client is
    2045              * trying to cancel this operation. */
    2046             canceled = true;
    2047             break;
    2048         }
    2049         if (NanoVis::licRenderer->active()) {
    2050             NanoVis::licRenderer->convolve();
    2051         }
    2052         NanoVis::AdvectFlows();
    2053         NanoVis::offscreen_buffer_capture();
     1938        if (((i & 0xF) == 0) && (poll(&pollResults, 1, 0) > 0)) {
     1939            /* If there's another command on stdin, that means the client is
     1940             * trying to cancel this operation. */
     1941            canceled = true;
     1942            break;
     1943        }
     1944        if (NanoVis::licRenderer->active()) {
     1945            NanoVis::licRenderer->convolve();
     1946        }
     1947        NanoVis::AdvectFlows();
     1948        NanoVis::offscreen_buffer_capture();
    20541949        NanoVis::display();
    20551950        NanoVis::read_screen();
     
    20601955    TRACE("FLOW end\n");
    20611956    if (!canceled) {
    2062         Rappture::Buffer data;
    2063 
    2064         /* FIXME: find a way to get the data from the movie object as a
    2065         * void* */
    2066         if (!data.load(context, tmpFileName)) {
    2067             Tcl_AppendResult(interp, "can't load data from temporary file \"",
    2068                 tmpFileName, "\": ", context.remark(), (char *)NULL);
    2069             return TCL_ERROR;
    2070         }
    2071 
    2072         char command[200];
    2073         sprintf(command,"nv>image -bytes %lu -type movie -token \"%s\"\n",
    2074                 (unsigned long)data.size(), token);
    2075         NanoVis::sendDataToClient(command, data.bytes(), data.size());
     1957        Rappture::Buffer data;
     1958
     1959        /* FIXME: find a way to get the data from the movie object as a
     1960        * void* */
     1961        if (!data.load(context, tmpFileName)) {
     1962            Tcl_AppendResult(interp, "can't load data from temporary file \"",
     1963                             tmpFileName, "\": ", context.remark(), (char *)NULL);
     1964            return TCL_ERROR;
     1965        }
     1966
     1967        char command[200];
     1968        sprintf(command,"nv>image -bytes %lu -type movie -token \"%s\"\n",
     1969                (unsigned long)data.size(), token);
     1970        NanoVis::sendDataToClient(command, data.bytes(), data.size());
    20761971    }
    20771972    if ((values.width != oldWidth) || (values.height != oldHeight)) {
    2078         NanoVis::resize_offscreen_buffer(oldWidth, oldHeight);
     1973        NanoVis::resize_offscreen_buffer(oldWidth, oldHeight);
    20791974    }
    20801975    NanoVis::ResetFlows();
    20811976    if (unlink(tmpFileName) != 0) {
    20821977        Tcl_AppendResult(interp, "can't unlink temporary movie file \"",
    2083                 tmpFileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
    2084         return TCL_ERROR;
     1978                         tmpFileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
     1979        return TCL_ERROR;
    20851980    }
    20861981    return TCL_OK;
    20871982}
    20881983#else
     1984/**
     1985 *  Not implemented
     1986 */
    20891987static int
    20901988FlowVideoOp(ClientData clientData, Tcl_Interp *interp, int objc,
    2091             Tcl_Obj *const *objv)
    2092 {
    2093     return TCL_OK;                      /* Not implemented */
    2094 }
    2095 #endif  /* HAVE_FFMPEG */
    2096 
    2097 /*
    2098  *---------------------------------------------------------------------------
    2099  *
    2100  * FlowObjCmd --
    2101  *
    2102  *---------------------------------------------------------------------------
    2103  */
     1989            Tcl_Obj *const *objv)
     1990{
     1991    return TCL_OK;
     1992}
     1993#endif /* HAVE_FFMPEG */
     1994
    21041995static Rappture::CmdSpec flowCmdOps[] = {
    21051996    {"add",      1, FlowAddOp,     3, 0, "name ?option value...?",},
     
    21142005static int nFlowCmdOps = NumCmdSpecs(flowCmdOps);
    21152006
    2116 /*ARGSUSED*/
    21172007static int
    21182008FlowCmdProc(ClientData clientData, Tcl_Interp *interp, int objc,
    2119             Tcl_Obj *const *objv)
     2009            Tcl_Obj *const *objv)
    21202010{
    21212011    Tcl_ObjCmdProc *proc;
    21222012
    21232013    proc = Rappture::GetOpFromObj(interp, nFlowCmdOps, flowCmdOps,
    2124         Rappture::CMDSPEC_ARG1, objc, objv, 0);
     2014                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    21252015    if (proc == NULL) {
    2126         return TCL_ERROR;
     2016        return TCL_ERROR;
    21272017    }
    21282018    return (*proc) (clientData, interp, objc, objv);
    21292019}
    21302020
    2131 /*
    2132  *---------------------------------------------------------------------------
    2133  *
    2134  * FlowCmdInitProc --
    2135  *
    2136  *      This procedure is invoked to initialize the "tree" command.
    2137  *
    2138  * Results:
    2139  *      None.
     2021/**
     2022 *\brief This procedure is invoked to initialize the "tree" command.
    21402023 *
    21412024 * Side effects:
    2142  *      Creates the new command and adds a new entry into a global Tcl
    2143  *      associative array.
    2144  *
    2145  *---------------------------------------------------------------------------
     2025 *    Creates the new command and adds a new entry into a global Tcl
     2026 *    associative array.
    21462027 */
    21472028int
     
    21532034}
    21542035
    2155 
    21562036#ifdef notdef
    21572037
     
    21622042    char *p, *endPtr;
    21632043
    2164   line = getline(&p, endPtr);
    2165   if (line == endPtr) {
    2166       vtkErrorMacro(<<"Premature EOF reading first line! " << " for file: "
    2167                     << (this->FileName?this->FileName:"(Null FileName)"));
    2168       return false;
    2169   }
    2170   if (sscanf(line, "# vtk DataFile Version %s", version) != 1) {
    2171       vtkErrorMacro(<< "Unrecognized file type: "<< line << " for file: "
    2172                     << (this->FileName?this->FileName:"(Null FileName)"));
    2173       return false;
    2174   }   
    2175   // Read title
    2176   line = getline(&p, endPtr);
    2177   if (line == endPtr) {
    2178       vtkErrorMacro(<<"Premature EOF reading title! " << " for file: "
    2179                     << (this->FileName?this->FileName:"(Null FileName)"));
    2180       return false;
    2181   }
    2182   if (_title != NULL) {
    2183       delete [] _title;
    2184   }
    2185   _title = new char[strlen(line) + 1];
    2186   strcpy(_title, line);
    2187 
    2188   // Read type
    2189   line = getline(&p, endPtr);
    2190   if (line == endPtr) {
    2191       vtkErrorMacro(<<"Premature EOF reading file type!" << " for file: "
    2192                     << (this->FileName?this->FileName:"(Null FileName)"));
    2193       return false;
    2194   }
    2195   word = GetWord(line, &endPtr);
    2196   if (strncasecmp(word, "ascii", 5) == 0) {
    2197       _fileType = VTK_ASCII;
    2198   } else if (strcasecmp(word, "binary", 6) == 0) {
    2199       _fileType = VTK_BINARY;
    2200   } else {
    2201       vtkErrorMacro(<< "Unrecognized file type: "<< line << " for file: "
    2202                     << (this->FileName?this->FileName:"(Null FileName)"));
    2203       _fileType = 0;
    2204       return false;
    2205 
    2206   }
    2207   // Read dataset type
    2208   line = getline(&p, endPtr);
    2209   if (line == endPtr) {
    2210       vtkErrorMacro(<<"Premature EOF reading file type!" << " for file: "
    2211                     << (this->FileName?this->FileName:"(Null FileName)"));
    2212       return false;
    2213   }
    2214   word = GetWord(line, &endPtr);
    2215   if (strncasecmp(word, "dataset", 7) == 0) {
    2216       // Read dataset type
    2217       line = getline(&p, endPtr);
    2218       if (line == endPtr) {
    2219           // EOF
    2220       }
    2221       type = GetWord(line, &endPtr);
    2222       if (strncasecmp(word, "structured_grid", 15) == 0) {
    2223           vtkErrorMacro(<< "Cannot read dataset type: " << line);
    2224           return 1;
    2225       }
    2226     // Read keyword and dimensions
    2227     //
    2228     while (!done)
    2229       {
    2230       if (!this->ReadString(line))
    2231         {
    2232         break;
    2233         }
    2234 
    2235       // Have to read field data because it may be binary.
    2236       if (! strncmp(this->LowerCase(line), "field", 5))
    2237         {
    2238         vtkFieldData* fd = this->ReadFieldData();
    2239         fd->Delete();
    2240         }
    2241 
    2242       if ( ! strncmp(this->LowerCase(line),"dimensions",10) )
    2243         {
    2244         int ext[6];
    2245         if (!(this->Read(ext+1) &&
    2246               this->Read(ext+3) &&
    2247               this->Read(ext+5)))
    2248           {
    2249           vtkErrorMacro(<<"Error reading dimensions!");
    2250           this->CloseVTKFile ();
    2251           return 1;
    2252           }
    2253         // read dimensions, change to extent;
    2254         ext[0] = ext[2] = ext[4] = 0;
    2255         --ext[1];
    2256         --ext[3];
    2257         --ext[5];
    2258         outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
    2259                      ext, 6);
    2260         // That is all we wanted !!!!!!!!!!!!!!!
    2261         this->CloseVTKFile();
    2262         return 1;
    2263         }
    2264       }
    2265     }
    2266 
    2267 
    2268 
    2269   float progress=this->GetProgress();
    2270   this->UpdateProgress(progress + 0.5*(1.0 - progress));
    2271  
    2272   return 1;
     2044    line = getline(&p, endPtr);
     2045    if (line == endPtr) {
     2046        vtkErrorMacro(<<"Premature EOF reading first line! " << " for file: "
     2047                      << (this->FileName?this->FileName:"(Null FileName)"));
     2048        return false;
     2049    }
     2050    if (sscanf(line, "# vtk DataFile Version %s", version) != 1) {
     2051        vtkErrorMacro(<< "Unrecognized file type: "<< line << " for file: "
     2052                      << (this->FileName?this->FileName:"(Null FileName)"));
     2053        return false;
     2054    }
     2055
     2056    // Read title
     2057    line = getline(&p, endPtr);
     2058    if (line == endPtr) {
     2059        vtkErrorMacro(<<"Premature EOF reading title! " << " for file: "
     2060                      << (this->FileName?this->FileName:"(Null FileName)"));
     2061        return false;
     2062    }
     2063    if (_title != NULL) {
     2064        delete [] _title;
     2065    }
     2066    _title = new char[strlen(line) + 1];
     2067    strcpy(_title, line);
     2068
     2069    // Read type
     2070    line = getline(&p, endPtr);
     2071    if (line == endPtr) {
     2072        vtkErrorMacro(<<"Premature EOF reading file type!" << " for file: "
     2073                      << (this->FileName?this->FileName:"(Null FileName)"));
     2074        return false;
     2075    }
     2076    word = GetWord(line, &endPtr);
     2077    if (strncasecmp(word, "ascii", 5) == 0) {
     2078        _fileType = VTK_ASCII;
     2079    } else if (strcasecmp(word, "binary", 6) == 0) {
     2080        _fileType = VTK_BINARY;
     2081    } else {
     2082        vtkErrorMacro(<< "Unrecognized file type: "<< line << " for file: "
     2083                      << (this->FileName?this->FileName:"(Null FileName)"));
     2084        _fileType = 0;
     2085        return false;
     2086    }
     2087
     2088    // Read dataset type
     2089    line = getline(&p, endPtr);
     2090    if (line == endPtr) {
     2091        vtkErrorMacro(<<"Premature EOF reading file type!" << " for file: "
     2092                      << (this->FileName?this->FileName:"(Null FileName)"));
     2093        return false;
     2094    }
     2095    word = GetWord(line, &endPtr);
     2096    if (strncasecmp(word, "dataset", 7) == 0) {
     2097        // Read dataset type
     2098        line = getline(&p, endPtr);
     2099        if (line == endPtr) {
     2100            // EOF
     2101        }
     2102        type = GetWord(line, &endPtr);
     2103        if (strncasecmp(word, "structured_grid", 15) == 0) {
     2104            vtkErrorMacro(<< "Cannot read dataset type: " << line);
     2105            return 1;
     2106        }
     2107        // Read keyword and dimensions
     2108        //
     2109        while (!done) {
     2110            if (!this->ReadString(line)) {
     2111                break;
     2112            }
     2113
     2114            // Have to read field data because it may be binary.
     2115            if (! strncmp(this->LowerCase(line), "field", 5)) {
     2116                vtkFieldData* fd = this->ReadFieldData();
     2117                fd->Delete();
     2118            }
     2119
     2120            if ( ! strncmp(this->LowerCase(line),"dimensions",10) ) {
     2121                int ext[6];
     2122                if (!(this->Read(ext+1) &&
     2123                      this->Read(ext+3) &&
     2124                      this->Read(ext+5))) {
     2125                    vtkErrorMacro(<<"Error reading dimensions!");
     2126                    this->CloseVTKFile ();
     2127                    return 1;
     2128                }
     2129                // read dimensions, change to extent;
     2130                ext[0] = ext[2] = ext[4] = 0;
     2131                --ext[1];
     2132                --ext[3];
     2133                --ext[5];
     2134                outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
     2135                             ext, 6);
     2136                // That is all we wanted !!!!!!!!!!!!!!!
     2137                this->CloseVTKFile();
     2138                return 1;
     2139            }
     2140        }
     2141    }
     2142
     2143    float progress = this->GetProgress();
     2144    this->UpdateProgress(progress + 0.5*(1.0 - progress));
     2145
     2146    return 1;
    22732147}
    22742148#endif
  • trunk/packages/vizservers/nanovis/FlowCmd.h

    r2844 r2875  
    4949
    5050struct FlowParticlesValues {
    51     FlowPosition position;      ///< Position on axis of particle plane
    52     FlowColor color;            ///< Color of particles
     51    FlowPosition position;        ///< Position on axis of particle plane
     52    FlowColor color;              ///< Color of particles
    5353    /// Indicates if particle injection plane is active or not
    5454    int isHidden;
    55     float particleSize;         ///< Size of the particles
     55    float particleSize;           ///< Size of the particles
    5656};
    5757
     
    130130    const char *_name;
    131131    Tcl_HashEntry *_hashPtr;
    132     NvParticleRenderer *_rendererPtr;   ///< Particle renderer
     132    NvParticleRenderer *_rendererPtr;        ///< Particle renderer
    133133    FlowParticlesValues _sv;
    134134
     
    142142
    143143struct FlowBoxValues {
    144     float position;             ///< Position on axis of particle plane
    145     FlowPoint corner1, corner2; ///< Coordinates of the box.
    146     FlowColor color;            ///< Color of particles
     144    float position;                ///< Position on axis of particle plane
     145    FlowPoint corner1, corner2;    ///< Coordinates of the box.
     146    FlowColor color;               ///< Color of particles
    147147    float lineWidth;
    148148    /// Indicates if particle injection plane is active or not
     
    190190
    191191private:
    192     const char *_name;                  /* Name of this box in the hash
    193                                          * table. */
    194     Tcl_HashEntry *_hashPtr;            /* Pointer to this entry in the hash
    195                                          * table of boxes. */
     192    const char *_name;          ///< Name of this box in the hash table.
     193    Tcl_HashEntry *_hashPtr;    ///< Pointer to this entry in the hash table of boxes.
    196194    FlowBoxValues _sv;
    197195    static Rappture::SwitchSpec _switches[];
     
    207205    int showOutline;
    208206    int isHidden;
    209     /* The following are settings for the volume.*/
    210     float diffuse;
    211     float specular;
    212     float opacity;
     207    float diffuse;  ///< Diffuse volume shading
     208    float specular; ///< Specular volume shading
     209    float opacity;  ///< Volume opacity
    213210};
    214211
     
    230227
    231228    int GetParticles(Tcl_Interp *interp, Tcl_Obj *objPtr,
    232                      FlowParticles **particlePtrPtr);
     229                     FlowParticles **particlePtrPtr);
    233230
    234231    void Render();
Note: See TracChangeset for help on using the changeset viewer.