Index: /trunk/packages/vizservers/nanovis/Command.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/Command.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/Command.cpp	(revision 3559)
@@ -40,5 +40,6 @@
 #include <assert.h>
 #include <stdlib.h>
-
+#include <unistd.h>                     /* Needed for getpid, gethostname,
+                                         * write, etc. */
 #include <tcl.h>
 
@@ -55,5 +56,4 @@
 #include "CmdProc.h"
 #include "Trace.h"
-
 #ifdef PLANE_CMD
 #include "PlaneRenderer.h"
@@ -81,5 +81,5 @@
   0.25  0 1 1\n\
   0.50  0 1 0\n\
-  0.75  1 1 0\n\
+   0.75  1 1 0\n\
   1.00  1 0 0\n\
 } {\n\
Index: /trunk/packages/vizservers/nanovis/FlowCmd.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/FlowCmd.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/FlowCmd.cpp	(revision 3559)
@@ -5,10 +5,15 @@
  */
 #include <assert.h>
+#define _OPEN_SYS
+#include <fcntl.h>
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <sys/uio.h>
+#include <sys/stat.h>
 #include <stdlib.h>
 #include <stddef.h>
 #include <limits.h>
 #include <stdint.h>
+#include <unistd.h>
 #include <poll.h>
-
 #include <tcl.h>
 
@@ -23,12 +28,4 @@
 
 #include "nvconf.h"
-
-#if defined(HAVE_LIBAVCODEC) || defined(HAVE_LIBAVFORMAT)
-#define HAVE_FFMPEG 1
-#endif
-
-#ifdef HAVE_FFMPEG
-#include "RpAVTranslate.h"
-#endif
 
 #include "nanovis.h"
@@ -163,10 +160,4 @@
 FlowParticles::render() 
 {
-    TRACE("rendering particles %s", _name);
-    TRACE("rendering particles %s axis=%d", _name, _sv.position.axis);
-    TRACE("rendering particles %s position=%g", _name, _sv.position.value);
-    TRACE("rendering particles %s position=%g", _name, 
-          FlowCmd::GetRelativePosition(&_sv.position));
-
     _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position));
     _rendererPtr->setAxis(_sv.position.axis);
@@ -243,6 +234,4 @@
     }
 
-    TRACE("Box model bounds: (%g,%g,%g) - (%g,%g,%g)", x0, y0, z0, x1, y1, z1);
-
     Vector3f modelMin(x0, y0, z0);
     Vector3f modelMax(x1, y1, z1);
@@ -267,8 +256,4 @@
         if (worldVert.z > bboxMax.z) bboxMax.z = worldVert.z;
     }
-
-    TRACE("Box world bounds: (%g,%g,%g) - (%g,%g,%g)",
-          bboxMin.x, bboxMin.y, bboxMin.z,
-          bboxMax.x, bboxMax.y, bboxMax.z);
 }
 
@@ -276,6 +261,4 @@
 FlowBox::Render(Volume *vol)
 {
-    TRACE("Rendering box %s", _name);
-
     glPushAttrib(GL_ENABLE_BIT);
 
@@ -301,11 +284,4 @@
     max.z = vol->zAxis.max();
 
-    TRACE("box is %g,%g %g,%g %g,%g", 
-          _sv.corner1.x, _sv.corner2.x,
-          _sv.corner1.y, _sv.corner2.y,
-          _sv.corner1.z, _sv.corner2.z);
-    TRACE("world is %g,%g %g,%g %g,%g", 
-          min.x, max.x, min.y, max.y, min.z, max.z);
-
     float x0, y0, z0, x1, y1, z1;
     x0 = y0 = z0 = 0.0f;
@@ -323,6 +299,4 @@
         z1 = (_sv.corner2.z - min.z) / (max.z - min.z);
     }
-    TRACE("rendering box %g,%g %g,%g %g,%g", x0, x1, y0, y1, z0, z1);
-
     glColor4d(_sv.color.r, _sv.color.g, _sv.color.b, _sv.color.a);
     glLineWidth(_sv.lineWidth);
@@ -462,5 +436,4 @@
         }
     }
-    TRACE("in Render before boxes %s", _name);
     RenderBoxes();
 }
@@ -612,5 +585,4 @@
 {
     if (_volPtr != NULL) {
-        TRACE("from ScaleVectorField volId=%s", _volPtr->name());
         NanoVis::removeVolume(_volPtr);
         _volPtr = NULL;
@@ -694,5 +666,4 @@
     FlowBox *boxPtr;
     for (boxPtr = FirstBox(&iter); boxPtr != NULL; boxPtr = NextBox(&iter)) {
-        TRACE("found box %s", boxPtr->name());
         if (boxPtr->visible()) {
             boxPtr->Render(_volPtr);
@@ -748,9 +719,4 @@
     volPtr->zAxis.setRange(_dataPtr->zMin(), _dataPtr->zMax());
 
-    TRACE("min=%g %g %g max=%g %g %g mag=%g %g", 
-          NanoVis::xMin, NanoVis::yMin, NanoVis::zMin,
-          NanoVis::xMax, NanoVis::yMax, NanoVis::zMax,
-          NanoVis::magMin, NanoVis::magMax);
-
     volPtr->disableCutplane(0);
     volPtr->disableCutplane(1);
@@ -786,5 +752,4 @@
     const char *fileName;
     fileName = Tcl_GetString(objv[3]);
-    TRACE("Flow loading data from file %s", fileName);
 
     int nComponents;
@@ -830,5 +795,4 @@
         delete u2dPtr;
     } else {
-        TRACE("header is %.14s", buf.bytes());
         if (!dataPtr->importDx(result, nComponents, length, bytes)) {
             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
@@ -857,6 +821,4 @@
     Rappture::Outcome result;
 
-    TRACE("Flow Data Loading");
-
     int nBytes;
     if (Tcl_GetIntFromObj(interp, objv[3], &nBytes) != TCL_OK) {
@@ -882,5 +844,4 @@
     }
     Rappture::Buffer buf;
-    TRACE("Flow Data Loading %d %d", nBytes, nComponents);
     if (GetDataStream(interp, buf, nBytes) != TCL_OK) {
         return TCL_ERROR;
@@ -913,5 +874,4 @@
         delete u2dPtr;
     } else {
-        TRACE("header is %.14s", buf.bytes());
         if (!dataPtr->importDx(result, nComponents, length, bytes)) {
             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
@@ -925,16 +885,4 @@
         return TCL_ERROR;
     }
-    TRACE("nx = %d ny = %d nz = %d", dataPtr->xNum(), dataPtr->yNum(), dataPtr->zNum());
-    TRACE("x0 = %lg y0 = %lg z0 = %lg", dataPtr->xMin(), dataPtr->yMin(), dataPtr->zMin());
-    TRACE("lx = %lg ly = %lg lz = %lg",
-          dataPtr->xMax() - dataPtr->xMin(),
-          dataPtr->yMax() - dataPtr->yMin(),
-          dataPtr->zMax() - dataPtr->zMin());
-    TRACE("dx = %lg dy = %lg dz = %lg",
-          dataPtr->xNum() > 1 ? (dataPtr->xMax() - dataPtr->xMin())/(dataPtr->xNum()-1) : 0,
-          dataPtr->yNum() > 1 ? (dataPtr->yMax() - dataPtr->yMin())/(dataPtr->yNum()-1) : 0,
-          dataPtr->zNum() > 1 ? (dataPtr->zMax() - dataPtr->zMin())/(dataPtr->zNum()-1) : 0);
-    TRACE("magMin = %lg magMax = %lg",
-          dataPtr->magMin(), dataPtr->magMax());
     flowPtr->data(dataPtr);
     {
@@ -1093,5 +1041,4 @@
 {
     flags &= ~MAP_FLOWS;
-    TRACE("Enter");
 
     /* 
@@ -1138,6 +1085,4 @@
     }
 
-    TRACE("MapFlows magMin=%g magMax=%g", NanoVis::magMin, NanoVis::magMax);
-
     /* 
      * Step 2. Generate the vector field from each data set. 
@@ -1167,6 +1112,4 @@
                        bool onlyVisible)
 {
-    TRACE("Enter");
-
     min.set(FLT_MAX, FLT_MAX, FLT_MAX);
     max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
@@ -1207,5 +1150,4 @@
         for (box = flow->FirstBox(&iter); box != NULL;
              box = flow->NextBox(&iter)) {
-            TRACE("found box %s", box->name());
             if (!onlyVisible || box->visible()) {
                 Vector3f fbmin, fbmax;
@@ -1954,6 +1896,4 @@
 }
 
-#ifdef HAVE_FFMPEG
-
 /**
  * \brief Convert a Tcl_Obj representing the video format into its
@@ -1975,30 +1915,39 @@
                       char *record, int offset, int flags)
 {
-    Rappture::AVTranslate::VideoFormats *formatPtr = 
-        (Rappture::AVTranslate::VideoFormats *)(record + offset);
+    Tcl_Obj **formatObjPtr = (Tcl_Obj **)(record + offset);
+    Tcl_Obj *fmtObjPtr;
     const char *string;
     char c; 
-
-    string = Tcl_GetString(objPtr);
+    int length;
+
+    string = Tcl_GetStringFromObj(objPtr, &length);
     c = string[0];
-    if ((c == 'm') && (strcmp(string, "mpeg") == 0)) {
-        *formatPtr =  Rappture::AVTranslate::MPEG1;
-    } else if ((c == 't') && (strcmp(string, "theora") == 0)) {
-        *formatPtr = Rappture::AVTranslate::THEORA;
-    } else if ((c == 'm') && (strcmp(string, "mov") == 0)) {
-        *formatPtr = Rappture::AVTranslate::QUICKTIME;
+    if ((c == 'm') && (length > 1) && 
+        (strncmp(string, "mpeg", length) == 0)) {
+        fmtObjPtr =  Tcl_NewStringObj("mpeg1video", 10);
+    } else if ((c == 't') && (strncmp(string, "theora", length) == 0)) {
+        fmtObjPtr =  Tcl_NewStringObj("theora", 6);
+    } else if ((c == 'm') && (length > 1) &&
+               (strncmp(string, "mov", length) == 0)) {
+        fmtObjPtr =  Tcl_NewStringObj("mov", 3);
     } else {
         Tcl_AppendResult(interp, "bad video format \"", string,
                          "\": should be mpeg, theora, or mov", (char*)NULL);
-    }
-    return TCL_ERROR;
-}
-
-struct FlowVideoValues {
+        return TCL_ERROR;
+    }
+    if (*formatObjPtr != NULL) {
+        Tcl_DecrRefCount(*formatObjPtr);
+    }
+    Tcl_IncrRefCount(fmtObjPtr);
+    *formatObjPtr = fmtObjPtr;
+    return TCL_OK;
+}
+
+struct FlowVideoSwitches {
     float frameRate;         /**< Frame rate */
     int bitRate;             /**< Video bitrate */
     int width, height;       /**< Dimensions of video frame. */
-    int nFrames;
-    Rappture::AVTranslate::VideoFormats format;
+    int numFrames;
+    Tcl_Obj *formatObjPtr;
 };
 
@@ -2010,97 +1959,100 @@
 Rappture::SwitchSpec FlowCmd::videoSwitches[] = {
     {Rappture::SWITCH_INT, "-bitrate", "value",
-     offsetof(FlowVideoValues, bitRate), 0},
+     offsetof(FlowVideoSwitches, bitRate), 0},
     {Rappture::SWITCH_CUSTOM, "-format", "string",
-     offsetof(FlowVideoValues, format), 0, 0, &videoFormatSwitch},
+     offsetof(FlowVideoSwitches, formatObjPtr), 0, 0, &videoFormatSwitch},
     {Rappture::SWITCH_FLOAT, "-framerate", "value",
-     offsetof(FlowVideoValues, frameRate), 0},
+     offsetof(FlowVideoSwitches, frameRate), 0},
     {Rappture::SWITCH_INT, "-height", "integer",
-     offsetof(FlowVideoValues, height), 0},
+     offsetof(FlowVideoSwitches, height), 0},
     {Rappture::SWITCH_INT, "-numframes", "count",
-     offsetof(FlowVideoValues, nFrames), 0},
+     offsetof(FlowVideoSwitches, numFrames), 0},
     {Rappture::SWITCH_INT, "-width", "integer",
-     offsetof(FlowVideoValues, width), 0},
+     offsetof(FlowVideoSwitches, width), 0},
     {Rappture::SWITCH_END}
 };
 
-static int
-FlowVideoOp(ClientData clientData, Tcl_Interp *interp, int objc, 
-            Tcl_Obj *const *objv)
+#ifdef HAVE_FFMPEG
+
+static int
+ppmWriteToFile(Tcl_Interp *interp, const char *path, FlowVideoSwitches *switchesPtr)
+{
+    int f;
+    
+    /* Open the named file for writing. */
+    f = creat(path, 0600);
+    if (f < 0) {
+        Tcl_AppendResult(interp, "can't open temporary image file \"", path,
+                         "\": ", Tcl_PosixError(interp), (char *)NULL);
+        return TCL_ERROR;
+    }
+    // Generate the PPM binary file header
+    char header[200];
+#define PPM_MAXVAL 255
+    sprintf(header, "P6 %d %d %d\n", switchesPtr->width, switchesPtr->height, 
+        PPM_MAXVAL);
+
+    size_t header_length = strlen(header);
+    size_t wordsPerRow = (switchesPtr->width * 24 + 31) / 32;
+    size_t bytesPerRow = wordsPerRow * 4;
+    size_t rowLength = switchesPtr->width * 3;
+    size_t numRecords = switchesPtr->height + 1;
+
+    struct iovec *iov;
+    iov = (struct iovec *)malloc(sizeof(struct iovec) * numRecords);
+
+    // Add the PPM image header.
+    iov[0].iov_base = header;
+    iov[0].iov_len = header_length;
+
+    // Now add the image data, reversing the order of the rows.
+    int y;
+    unsigned char *srcRowPtr = NanoVis::screenBuffer;
+    /* Reversing the pointers for the image rows.  PPM is top-to-bottom. */
+    for (y = switchesPtr->height; y >= 1; y--) {
+        iov[y].iov_base = srcRowPtr;
+        iov[y].iov_len = rowLength;
+        srcRowPtr += bytesPerRow;
+    }
+    if (writev(f, iov, numRecords) < 0) {
+        Tcl_AppendResult(interp, "writing image to \"", path, "\" failed: ", 
+                         Tcl_PosixError(interp), (char *)NULL);
+        free(iov);
+        close(f);
+        return TCL_ERROR;
+    }
+    close(f);
+    free(iov);
+    return TCL_OK;
+}
+
+static int
+MakeImageFiles(Tcl_Interp *interp, char *tmpFileName, 
+               FlowVideoSwitches *switchesPtr, bool *cancelPtr)
 {
     struct pollfd pollResults;
-    int timeout;
-
     pollResults.fd = fileno(NanoVis::stdin);
     pollResults.events = POLLIN;
-
 #define PENDING_TIMEOUT          10  /* milliseconds. */
-    timeout = PENDING_TIMEOUT;
-
-    FlowVideoValues values;
-    const char *token;
-
-    token = Tcl_GetString(objv[2]);
-    values.frameRate = 25.0f;                // Default frame rate 25 fps
-    values.bitRate = 6000000;                // Default video bit rate.
-    values.width = NanoVis::winWidth;
-    values.height = NanoVis::winHeight;
-    values.nFrames = 100;
-    values.format = Rappture::AVTranslate::MPEG1;
-    if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches, 
-                                objc - 3, objv + 3, &values, SWITCH_DEFAULTS) < 0) {
-        return TCL_ERROR;
-    }
-    if ((values.width < 0) || (values.width > SHRT_MAX) || 
-        (values.height < 0) || (values.height > SHRT_MAX)) {
-        Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL);
-        return TCL_ERROR;
-    }
-    if ((values.frameRate < 0.0f) || (values.frameRate > 30.0f)) {
-        Tcl_AppendResult(interp, "bad frame rate.", (char *)NULL);
-        return TCL_ERROR;
-    }
-    if (values.bitRate < 0) {
-        Tcl_AppendResult(interp, "bad bit rate.", (char *)NULL);
-        return TCL_ERROR;
-    }
-    if (NanoVis::licRenderer == NULL) {
-        Tcl_AppendResult(interp, "no lic renderer.", (char *)NULL);
-        return TCL_ERROR;
-    }
-    // Save the old dimensions of the offscreen buffer.
+    int timeout = PENDING_TIMEOUT;
+
     int oldWidth, oldHeight;
     oldWidth = NanoVis::winWidth;
     oldHeight = NanoVis::winHeight;
 
-    TRACE("FLOW started");
-
-    Rappture::Outcome context;
-
-    Rappture::AVTranslate movie(values.width, values.height,
-                                values.bitRate, 
-                                values.frameRate);
-    char tmpFileName[200];
-    sprintf(tmpFileName,"/tmp/flow%d.mpeg", getpid());
-    if (!movie.init(context, tmpFileName)) {
-        Tcl_AppendResult(interp, "can't initialized movie \"", tmpFileName, 
-                         "\": ", context.remark(), (char *)NULL);
-        return TCL_ERROR;
-    }
-    if ((values.width != oldWidth) || (values.height != oldHeight)) {
+    if ((switchesPtr->width != oldWidth) || 
+        (switchesPtr->height != oldHeight)) {
         // Resize to the requested size.
-        NanoVis::resizeOffscreenBuffer(values.width, values.height);
-    }
-    // Now compute the line padding for the offscreen buffer.
-    int pad = 0;
-    if (( 3 * values.width) % 4 > 0) {
-        pad = 4 - ((3* values.width) % 4);
+        NanoVis::resizeOffscreenBuffer(switchesPtr->width, switchesPtr->height);
     }
     NanoVis::ResetFlows();
-    bool canceled = false;
-    for (int i = 1; i <= values.nFrames; i++) {
-        if (((i & 0xF) == 0) && (poll(&pollResults, 1, 0) > 0)) {
+    *cancelPtr = false;
+    int result = TCL_OK;
+    size_t length = strlen(tmpFileName);
+    for (int i = 1; i <= switchesPtr->numFrames; i++) {
+        if (((i & 0xF) == 0) && (poll(&pollResults, 1, timeout) > 0)) {
             /* If there's another command on stdin, that means the client is
              * trying to cancel this operation. */
-            canceled = true;
+            *cancelPtr = true;
             break;
         }
@@ -2119,34 +2071,138 @@
         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
 
-        movie.append(context, NanoVis::screenBuffer, pad);
-    }
-    movie.done(context);
-    TRACE("FLOW end");
-    if (!canceled) {
-        Rappture::Buffer data;
-
-        /* FIXME: find a way to get the data from the movie object as a
-         * void* */
-        if (!data.load(context, tmpFileName)) {
-            Tcl_AppendResult(interp, "can't load data from temporary file \"",
-                             tmpFileName, "\": ", context.remark(), (char *)NULL);
+        sprintf(tmpFileName + length, "/image%d.ppm", i);
+        result = ppmWriteToFile(interp, tmpFileName, switchesPtr);
+        if (result != TCL_OK) {
+            break;
+        }
+    }
+    if ((switchesPtr->width != oldWidth) || 
+        (switchesPtr->height != oldHeight)) {
+        NanoVis::resizeOffscreenBuffer(oldWidth, oldHeight);
+    }
+    tmpFileName[length] = '\0';
+    NanoVis::ResetFlows();
+    return result;
+}
+
+static int
+MakeMovie(Tcl_Interp *interp, char *tmpFileName, const char *token,
+          FlowVideoSwitches *switchesPtr)
+{
+#ifndef FFMPEG 
+#  define FFMPEG "/usr/bin/ffmpeg"
+#endif
+    /* Generate the movie from the frame images by exec-ing ffmpeg */
+    /* The ffmpeg command is
+     *   ffmpeg -f image2 -i /var/tmp/xxxxx/image%d.ppm                 \
+     *      -b bitrate -f framerate /var/tmp/xxxxx/movie.mpeg 
+     */
+    char cmd[BUFSIZ];
+    sprintf(cmd, "%s -f image2 -i %s/image%%d.ppm -f %s -b:v %d -r %f -",
+            FFMPEG, tmpFileName, Tcl_GetString(switchesPtr->formatObjPtr), 
+            switchesPtr->bitRate, switchesPtr->frameRate);
+    TRACE("MakeMovie %s", cmd);
+    FILE *f;
+    f = popen(cmd, "r");
+    if (f == NULL) {
+        Tcl_AppendResult(interp, "can't run ffmpeg: ", 
+                         Tcl_PosixError(interp), (char *)NULL);
+        return TCL_ERROR;
+    }
+    Rappture::Buffer data;
+    size_t total = 0;
+    for (;;) {
+        ssize_t numRead;
+        char buffer[BUFSIZ]; 
+        
+        numRead = fread(buffer, sizeof(unsigned char), BUFSIZ, f);
+        total += numRead;
+        if (numRead == 0) {             // EOF
+            break;
+        }
+        if (numRead < 0) {              // Error
+            ERROR("MakeMovie: can't read movie data: %s",
+                  Tcl_PosixError(interp));
+            Tcl_AppendResult(interp, "can't read movie data: ", 
+                Tcl_PosixError(interp), (char *)NULL);
             return TCL_ERROR;
         }
-
-        char command[200];
-        sprintf(command,"nv>image -type movie -token \"%s\" -bytes %lu\n", 
-                token, (unsigned long)data.size());
-        NanoVis::sendDataToClient(command, data.bytes(), data.size());
-    }
-    if ((values.width != oldWidth) || (values.height != oldHeight)) {
-        NanoVis::resizeOffscreenBuffer(oldWidth, oldHeight);
-    }
-    NanoVis::ResetFlows();
-    if (unlink(tmpFileName) != 0) {
-        Tcl_AppendResult(interp, "can't unlink temporary movie file \"",
-                         tmpFileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
-        return TCL_ERROR;
-    }
-    return TCL_OK;
+        if (!data.append(buffer, numRead)) {
+            ERROR("MakeMovie: can't append movie data to buffer %d bytes",
+                  numRead);
+            Tcl_AppendResult(interp, "can't append movie data to buffer",
+                             (char *)NULL);
+            return TCL_ERROR;
+        }
+    }
+    sprintf(cmd,"nv>image -type movie -token \"%s\" -bytes %lu\n", 
+            token, (unsigned long)data.size());
+    NanoVis::sendDataToClient(cmd, data.bytes(), data.size());
+    return TCL_OK;
+}
+
+static int
+FlowVideoOp(ClientData clientData, Tcl_Interp *interp, int objc, 
+            Tcl_Obj *const *objv)
+{
+    FlowVideoSwitches switches;
+    const char *token;
+
+    token = Tcl_GetString(objv[2]);
+    switches.frameRate = 25.0f;                // Default frame rate 25 fps
+    switches.bitRate = 6000000;                // Default video bit rate.
+    switches.width = NanoVis::winWidth;
+    switches.height = NanoVis::winHeight;
+    switches.numFrames = 100;
+    switches.formatObjPtr = Tcl_NewStringObj("mpeg1video", 10);
+    Tcl_IncrRefCount(switches.formatObjPtr);
+    if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches, 
+                objc - 3, objv + 3, &switches, SWITCH_DEFAULTS) < 0) {
+        return TCL_ERROR;
+    }
+    if ((switches.width < 0) || (switches.width > SHRT_MAX) || 
+        (switches.height < 0) || (switches.height > SHRT_MAX)) {
+        Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL);
+        return TCL_ERROR;
+    }
+    if ((switches.frameRate < 0.0f) || (switches.frameRate > 30.0f)) {
+        Tcl_AppendResult(interp, "bad frame rate.", (char *)NULL);
+        return TCL_ERROR;
+    }
+    if (switches.bitRate < 0) {
+        Tcl_AppendResult(interp, "bad bit rate.", (char *)NULL);
+        return TCL_ERROR;
+    }
+    if (NanoVis::licRenderer == NULL) {
+        Tcl_AppendResult(interp, "no lic renderer.", (char *)NULL);
+        return TCL_ERROR;
+    }
+    TRACE("FLOW started");
+
+    char *tmpFileName;
+    char nameTemplate[200];
+    strcpy(nameTemplate,"/var/tmp/flowXXXXXX");
+    tmpFileName = mkdtemp(nameTemplate);
+    int result = TCL_OK;
+    if (tmpFileName == NULL) {
+        Tcl_AppendResult(interp, "can't create temporary directory \"",
+                         nameTemplate, "\" for frame image files: ", 
+                         Tcl_PosixError(interp), (char *)NULL);
+        return TCL_ERROR;
+    }
+    size_t length = strlen(tmpFileName);
+    bool canceled = false;
+    result = MakeImageFiles(interp, tmpFileName, &switches, &canceled);
+    if ((result == TCL_OK) && (!canceled)) {
+        result = MakeMovie(interp, tmpFileName, token, &switches);
+    }
+    for (int i = 1; i <= switches.numFrames; i++) {
+        sprintf(tmpFileName + length, "/image%d.ppm", i);
+        unlink(tmpFileName);
+    }        
+    tmpFileName[length] = '\0';
+    rmdir(tmpFileName);
+    Rappture::FreeSwitches(FlowCmd::videoSwitches, &switches, 0);
+    return result;
 }
 #else
Index: /trunk/packages/vizservers/nanovis/GradientFilter.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/GradientFilter.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/GradientFilter.cpp	(revision 3559)
@@ -161,5 +161,5 @@
     g_sliceDists[2] = spacing[2];
 
-    int i, j, k, dir, di, vdi, idz, idy, idx;
+    int i, j, k, dir, idz, idy, idx;
     float *gp;
 
@@ -196,6 +196,4 @@
     TRACE("computing gradients ... may take a while");
 
-    di = 0;
-    vdi = 0;
     gp = gradients;
     for (idz = 0; idz < sizes[2]; idz++) {
Index: /trunk/packages/vizservers/nanovis/Makefile.in
===================================================================
--- /trunk/packages/vizservers/nanovis/Makefile.in	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/Makefile.in	(revision 3559)
@@ -137,5 +137,4 @@
 		ReaderCommon.o \
 		RenderVertexArray.o \
-		RpAVTranslate.o \
 		Switch.o \
 		Texture1D.o \
Index: unk/packages/vizservers/nanovis/RpAVTranslate.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/RpAVTranslate.cpp	(revision 3558)
+++ 	(revision )
@@ -1,484 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ======================================================================
- *  Rappture::AVTranslate
- *
- *  AUTHOR:  Derrick Kearney, Purdue University
- *
- *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
- * ----------------------------------------------------------------------
- *  See the file "license.terms" for information on usage and
- *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- * ======================================================================
- */
-
-
-#include "nvconf.h"
-
-#if defined(HAVE_LIBAVCODEC) || defined(HAVE_LIBAVFORMAT)
-#include <cstdlib>
-#include <cstdio>
-#include <cstring>
-#include <cmath>
-#include <fstream>
-#include <assert.h>
-
-extern "C" {
-#ifdef HAVE_FFMPEG_MEM_H
-#include <ffmpeg/mem.h>
-#endif
-#ifdef HAVE_LIBAVUTIL_MEM_H
-#include <libavutil/mem.h>
-#endif
-}
-
-#include "RpAVTranslate.h"
-
-#ifndef HAVE_AVMEDIA_TYPE_VIDEO
-#define AVMEDIA_TYPE_VIDEO	CODEC_TYPE_VIDEO
-#endif	/* HAVE_AVMEDIA_TYPE_VIDEO */
-
-#ifndef AV_PKT_FLAG_KEY
-#define AV_PKT_FLAG_KEY		PKT_FLAG_KEY		
-#endif
-
-#ifndef HAVE_AV_GUESS_FORMAT
-#define av_guess_format		guess_format
-#endif	/*HAVE_AV_GUESS_FORMAT*/
-
-#ifndef HAVE_AV_DUMP_FORMAT
-#define av_dump_format		dump_format
-#endif	/*HAVE_AV_DUMP_FORMAT*/
-
-#ifndef HAVE_AVIO_OPEN
-#define avio_open		url_fopen	
-#endif	/*HAVE_AVIO_OPEN*/
-
-#ifndef HAVE_AVIO_CLOSE
-#define avio_close		url_fclose	
-#endif	/*HAVE_AVIO_CLOSE*/
-
-#ifndef AVIO_FLAG_WRITE
-#define AVIO_FLAG_WRITE         URL_WRONLY
-#endif
-
-#ifndef HAVE_AVFORMAT_NEW_STREAM
-#define avformat_new_stream     av_new_stream
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-using namespace Rappture;
-
-AVTranslate::AVTranslate(size_t width, size_t height) : 
-    _width (width),
-    _height (height),
-    _bitRate(400000),
-    _frameRate(25.0f),
-    _videoOutbufSize(200000),
-    _videoOutbuf(NULL),
-    _fmtPtr(NULL),
-    _ocPtr(NULL),
-    _avStreamPtr(NULL),
-    _pictPtr(NULL),
-    _rgbPictPtr(NULL)
-{
-}
-
-AVTranslate::AVTranslate(size_t width, size_t height, size_t bitRate,
-			 float frameRate) :
-    _width (width),
-    _height (height),
-    _bitRate(bitRate),
-    _frameRate(frameRate),
-    _videoOutbufSize(200000),
-    _videoOutbuf(NULL),
-    _fmtPtr(NULL),
-    _ocPtr(NULL),
-    _avStreamPtr(NULL),
-    _pictPtr(NULL),
-    _rgbPictPtr(NULL)
-{
-}
-
-/**
- * Copy constructor
- * @param AVTranslate object to copy
- */
- /*
-AVTranslate::AVTranslate(const AVTranslate& o)
-{}
-*/
-
-AVTranslate::~AVTranslate()
-{
-#ifdef notdef
-    /* FIXME:: This can't be right.  Don't want to automatically write out
-     * trailer etc. on destruction of this object. */
-    done();
-#endif
-}
-
-
-bool
-AVTranslate::init(Outcome &status, const char *filename)
-{
-    status.addContext("Rappture::AVTranslate::init()");
-    /* Initialize libavcodec, and register all codecs and formats */
-#ifdef HAVE_AVCODEC_REGISTER_ALL
-    avcodec_register_all();
-#else
-    avcodec_init();
-#endif
-    av_register_all();
-
-    /* Auto detect the output format from the name. default is mpeg. */
-    _fmtPtr = av_guess_format(NULL, filename, NULL);
-    if (_fmtPtr == NULL) {
-        /*
-	  TRACE(  "Could not deduce output format from"
-                 "file extension: using MPEG.\n");
-        */
-        _fmtPtr = av_guess_format("mpeg", NULL, NULL);
-    }
-    if (_fmtPtr == NULL) {
-        status.addError("Could not find suitable output format");
-        return false;
-    }
-
-#ifdef HAVE_AVFORMAT_ALLOC_CONTEXT
-    /* Allocate the output media context. */
-    _ocPtr = avformat_alloc_context();
-#else 
-    _ocPtr = av_alloc_format_context();
-#endif
-    if (!_ocPtr) {
-        status.addError("Memory error while allocating format context");
-        return false;
-    }
-    _ocPtr->oformat = _fmtPtr;
-    snprintf(_ocPtr->filename, sizeof(_ocPtr->filename), "%s", filename);
-
-    /* Add the video stream using the default format codecs and initialize the
-       codecs. */
-    _avStreamPtr = NULL;
-    if (_fmtPtr->video_codec != CODEC_ID_NONE) {
-        if ( (!addVideoStream(status, _fmtPtr->video_codec, &_avStreamPtr)) ) {
-            return false;
-        }
-    }
-
-#if defined(HAVE_AV_SET_PARAMETERS) && !defined(HAVE_AVFORMAT_WRITE_HEADER)
-    /* Set the output parameters (must be done even if no parameters). */
-    if (av_set_parameters(_ocPtr, NULL) < 0) {
-        status.addError("Invalid output format parameters");
-        return false;
-    }
-#endif
-    av_dump_format(_ocPtr, 0, filename, 1);
-
-    /* Now that all the parameters are set, we can open the video codec and
-       allocate the necessary encode buffers */
-    if (_avStreamPtr) {
-        if (!openVideo(status)) {
-            return false;
-        }
-    }
-
-    /* Open the output file, if needed. */
-    if (!(_fmtPtr->flags & AVFMT_NOFILE)) {
-        if (avio_open(&_ocPtr->pb, filename, AVIO_FLAG_WRITE) < 0) {
-            status.addError("Could not open '%s'", filename);
-            return false;
-        }
-    }
-
-    /* write the stream header, if any */
-#ifdef HAVE_AVFORMAT_WRITE_HEADER
-    avformat_write_header(_ocPtr, NULL);
-#else
-    av_write_header(_ocPtr);
-#endif
-    return true;
-}
-
-bool
-AVTranslate::append(Outcome &status, uint8_t *rgbData, size_t linePad)
-{
-    status.addContext("Rappture::AVTranslate::append()");
-    if (rgbData == NULL) {
-        status.addError("rdbData pointer is NULL");
-        return false;
-    }
-    /* Copy the data into the picture without the padding and reversing the
-     * rows. Note that the origin of the GL image is the lower-left while for
-     * the movie it's upper-left. */
-    size_t bytesPerRow = _width * 3;
-    size_t bytesPerLine = bytesPerRow + linePad;
-    uint8_t *srcRowPtr = rgbData + ((_height - 1) * bytesPerLine);
-    uint8_t *destPtr = _rgbPictPtr->data[0];
-    for (size_t y = 0; y < _height; y++) {
-	uint8_t *sp, *send;
-	
-        for (sp = srcRowPtr, send = sp + bytesPerRow; sp < send; sp++, destPtr++) {
-            *destPtr = *sp;
-        }
-        srcRowPtr -= bytesPerLine;
-    }
-
-#ifdef HAVE_IMG_CONVERT
-    // Use img_convert instead of sws_scale because img_convert is LGPL and
-    // sws_scale is GPL
-    img_convert((AVPicture *)_pictPtr, PIX_FMT_YUV420P,
-                (AVPicture *)_rgbPictPtr, PIX_FMT_RGB24,
-                _width, _height);
-#endif	/*HAVE_IMG_CONVERT*/
-    writeVideoFrame(status);
-
-    return true;
-}
-
-
-bool
-AVTranslate::done(Outcome &status)
-{
-    size_t i = 0;
-
-    /* Close each codec */
-    if (_avStreamPtr) {
-        closeVideo(status);
-    }
-
-    /* Write the trailer, if any */
-    av_write_trailer(_ocPtr);
-
-    /* Free the streams */
-    for(i = 0; i < _ocPtr->nb_streams; i++) {
-        av_freep(&_ocPtr->streams[i]->codec);
-        // _ocPtr->streams[i]->codec = NULL;
-
-        av_freep(&_ocPtr->streams[i]);
-        // _ocPtr->streams[i] = NULL;
-    }
-
-    if (!(_fmtPtr->flags & AVFMT_NOFILE)) {
-        /* close the output file */
-        avio_close(_ocPtr->pb);
-    }
-
-    /* Free the stream */
-    av_free(_ocPtr);
-    _ocPtr = NULL;
-    return true;
-}
-
-
-/* Add a video output stream */
-bool
-AVTranslate::addVideoStream(Outcome &status, CodecID codec_id, 
-			    AVStream **streamPtrPtr)
-{
-    status.addContext("Rappture::AVTranslate::add_video_stream()");
-    if (streamPtrPtr == NULL) {
-        status.addError("AVStream **st is NULL");
-        return false;
-    }
-
-    AVStream *streamPtr;
-    streamPtr = avformat_new_stream(_ocPtr, 0);
-    if (streamPtr == NULL) {
-        status.addError("Could not alloc stream");
-        return false;
-    }
-
-    AVCodecContext *codecPtr;
-    codecPtr = streamPtr->codec;
-    codecPtr->codec_id = codec_id;
-    codecPtr->codec_type = AVMEDIA_TYPE_VIDEO;
-
-    /* Put sample parameters */
-    codecPtr->bit_rate = _bitRate;
-    /* resolution must be a multiple of two */
-    codecPtr->width = _width;
-    codecPtr->height = _height;
-    /* time base: this is the fundamental unit of time (in seconds) in terms
-       of which frame timestamps are represented. for fixed-fps content,
-       timebase should be 1/framerate and timestamp increments should be
-       identically 1. */
-    codecPtr->time_base.den = _frameRate;
-    codecPtr->time_base.num = 1;
-    codecPtr->gop_size = 12;		/* Emit one intra frame every twelve
-					 * frames at most */
-    codecPtr->pix_fmt = PIX_FMT_YUV420P;
-    if (codecPtr->codec_id == CODEC_ID_MPEG2VIDEO) {
-        /* just for testing, we also add B frames */
-        codecPtr->max_b_frames = 2;
-    }
-    if (codecPtr->codec_id == CODEC_ID_MPEG1VIDEO) {
-        /* Needed to avoid using macroblocks in which some coeffs overflow.
-           This does not happen with normal video, it just happens here as the
-           motion of the chroma plane does not match the luma plane. */
-        codecPtr->mb_decision=2;
-    }
-    /* some formats want stream headers to be separate */
-    if((strcmp(_ocPtr->oformat->name, "mp4") == 0) || 
-       (strcmp(_ocPtr->oformat->name, "mov") == 0) ||
-       (strcmp(_ocPtr->oformat->name, "3gp") == 0)) {
-        codecPtr->flags |= CODEC_FLAG_GLOBAL_HEADER;
-    }
-    *streamPtrPtr = streamPtr;
-    return true;
-}
-
-bool
-AVTranslate::allocPicture(Outcome &status, PixelFormat pixFmt, 
-     AVFrame **framePtrPtr)
-{
-    status.addContext("Rappture::AVTranslate::allocPicture()");
-    if (framePtrPtr == NULL) {
-        status.addError("AVFrame **p == NULL");
-        return false;
-    }
-
-    AVFrame *framePtr;
-    framePtr = avcodec_alloc_frame();
-    if (framePtr == NULL) {
-        status.addError("Memory error: Could not alloc frame");
-        return false;
-    }
-
-    size_t size;
-    size = avpicture_get_size(pixFmt, _width, _height);
-
-    uint8_t *bits;
-    bits = (uint8_t *)av_malloc(size);
-    if (bits == NULL) {
-        av_free(framePtr);
-        status.addError("Memory error: Could not alloc picture buffer");
-        return false;
-    }
-    avpicture_fill((AVPicture *)framePtr, bits, pixFmt, _width, _height);
-    *framePtrPtr = framePtr;
-    return true;
-}
-
-bool
-AVTranslate::openVideo(Outcome &status)
-{
-    AVCodec *codec;
-    AVCodecContext *c;
-    int result;
-
-    status.addContext("Rappture::AVTranslate::openVideo()");
-    c = _avStreamPtr->codec;
-
-    /* find the video encoder */
-    codec = avcodec_find_encoder(c->codec_id);
-    if (codec == NULL) {
-        status.addError("can't find codec %d\n", c->codec->id);
-        return false;
-    }
-#ifdef HAVE_AVCODEC_OPEN2
-    result = avcodec_open2(c, codec, NULL);
-#else 
-    result = avcodec_open(c, codec);
-#endif
-    /* open the codec */
-    if (result < 0) {
-        status.addError("can't open codec %d", c->codec->id);
-        return false;
-    }
-
-    _videoOutbuf = NULL;
-    if (!(_ocPtr->oformat->flags & AVFMT_RAWPICTURE)) {
-        /* allocate output buffer */
-        /* XXX: API change will be done */
-        /* buffers passed into lav* can be allocated any way you prefer,
-           as long as they're aligned enough for the architecture, and
-           they're freed appropriately (such as using av_free for buffers
-           allocated with av_malloc) */
-        _videoOutbuf = (uint8_t *) av_malloc(_videoOutbufSize);
-    }
-    /* Allocate the encoded raw picture */
-    if (!allocPicture(status, c->pix_fmt, &_pictPtr)) {
-        return false;
-    }
-    if (!allocPicture(status, PIX_FMT_RGB24, &_rgbPictPtr)) {
-        status.addError("allocPicture: can't allocate picture");
-        return false;
-    }
-    return true;
-}
-
-bool
-AVTranslate::writeVideoFrame(Outcome &status)
-{
-    AVCodecContext *contextPtr;
-
-    status.addContext("Rappture::AVTranslate::writeVideoframe()");
-    contextPtr = _avStreamPtr->codec;
-
-    /* encode the image */
-    int size;
-    size = avcodec_encode_video(contextPtr, _videoOutbuf, _videoOutbufSize, 
-	_pictPtr);
-    if (size < 0) {
-        status.addError("Error while writing video frame");
-	return false;
-    }
-    if (size == 0) {
-	return true;		/* Image was buffered */
-    }
-    AVPacket pkt;
-    av_init_packet(&pkt);
-
-    pkt.pts = av_rescale_q(contextPtr->coded_frame->pts, contextPtr->time_base,
-			   _avStreamPtr->time_base);
-    if (contextPtr->coded_frame->key_frame) {
-	pkt.flags |= AV_PKT_FLAG_KEY;
-    }
-    pkt.stream_index = _avStreamPtr->index;
-    pkt.data = _videoOutbuf;
-    pkt.size = size;
-    
-    /* write the compressed frame i the media file */
-    if (av_write_frame(_ocPtr, &pkt) < 0) {
-        status.addError("Error while writing video frame");
-	return false;
-    }
-    return true;
-}
-
-
-bool
-AVTranslate::closeVideo(Outcome &status)
-{
-    if (_avStreamPtr != NULL) {
-	avcodec_close(_avStreamPtr->codec);
-    }
-    if (_pictPtr != NULL) {
-	av_free(_pictPtr->data[0]);
-	av_free(_pictPtr);
-	_pictPtr = NULL;
-    }
-    if (_rgbPictPtr != NULL) {
-	av_free(_rgbPictPtr->data[0]);
-	av_free(_rgbPictPtr);
-	_rgbPictPtr = NULL;
-    }
-    if (_videoOutbuf != NULL) {
-	av_free(_videoOutbuf);
-	_videoOutbuf = NULL;
-    }
-    return true;
-}
-
-/*
-status.addError("error while opening file");
-status.addContext("Rappture::Buffer::dump()");
-return status;
-*/
-
-#endif /* HAVE_LIBAVCODEC && HAVE_LIBAVFORMAT */
Index: unk/packages/vizservers/nanovis/RpAVTranslate.h
===================================================================
--- /trunk/packages/vizservers/nanovis/RpAVTranslate.h	(revision 3558)
+++ 	(revision )
@@ -1,130 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ======================================================================
- *  Rappture::AVTranslate
- *
- *  AUTHOR:  Derrick Kearney, Purdue University
- *
- *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
- * ----------------------------------------------------------------------
- *  See the file "license.terms" for information on usage and
- *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- * ======================================================================
- */
-
-#ifndef RP_AVTRANSLATE_H
-#define RP_AVTRANSLATE_H 1
-
-#include "nvconf.h"
-
-extern "C" {
-#ifndef INT64_C
-#if SIZEOF_LONG == 8
-#  define INT64_C(c)  c ## L
-#  define UINT64_C(c) c ## UL
-#else
-#  define INT64_C(c)  c ## LL
-#  define UINT64_C(c) c ## ULL
-# endif
-#endif
-#ifdef HAVE_FFMPEG_AVFORMAT_H
-#include <ffmpeg/avformat.h>
-#endif
-#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
-#include <libavformat/avformat.h>
-#endif
-}
-#include <RpOutcome.h>
-
-namespace Rappture {
-
-class AVTranslate
-{
-public:
-    enum VideoFormats {
-        MPEG1,
-        MPEG4,
-        THEORA,
-        QUICKTIME
-    };
-
-    AVTranslate(size_t width, size_t height);
-
-    AVTranslate(size_t width, size_t height, size_t bitRate, float frameRate);
-
-    virtual ~AVTranslate();
-
-    bool init(Outcome &status, const char *filename);
-
-    bool append(Outcome &status, uint8_t *rgbData, size_t linePad);
-
-    bool done(Outcome &status);
-
-private:
-    bool addVideoStream(Outcome &status, CodecID codecId, AVStream **stream);
-
-    bool allocPicture(Outcome &status, PixelFormat pixFmt, AVFrame **pic );
-
-    bool openVideo(Outcome &status);
-
-    bool writeVideoFrame(Outcome &status);
-
-    bool closeVideo(Outcome &status);
-
-    size_t width()
-    {
-        return _width;
-    }
-
-    void width(size_t width)
-    {
-        _width = width;
-    }
-
-    size_t height()
-    {
-        return _width;
-    }
-
-    void height(size_t width)
-    {
-        _width = width;
-    }
-
-    size_t bitRate()
-    {
-        return _bitRate;
-    }
-
-    void bitRate(size_t bitRate)
-    {
-        _bitRate = bitRate;
-    }
-
-    float frameRate()
-    {
-        return _frameRate;
-    }
-
-    void frameRate(size_t frameRate)
-    {
-        _frameRate = frameRate;
-    }
-
-    size_t _width;
-    size_t _height;
-    size_t _bitRate;
-    float _frameRate;         ///< frames/seconds
-    size_t _videoOutbufSize;
-    uint8_t *_videoOutbuf;
-
-    AVOutputFormat *_fmtPtr;
-    AVFormatContext *_ocPtr;
-    AVStream *_avStreamPtr;
-    AVFrame *_pictPtr, *_rgbPictPtr;
-
-};
-
-}
- 
-#endif
Index: /trunk/packages/vizservers/nanovis/Texture1D.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/Texture1D.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/Texture1D.cpp	(revision 3559)
@@ -76,5 +76,7 @@
     glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, _interpType);
 
-    GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
+    GLuint format[5] = { 
+        (unsigned int)-1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA 
+    };
 
     glTexImage1D(GL_TEXTURE_1D, 0, format[_numComponents], _width, 0,
Index: /trunk/packages/vizservers/nanovis/Texture2D.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/Texture2D.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/Texture2D.cpp	(revision 3559)
@@ -72,8 +72,10 @@
 void Texture2D::update(void *data)
 {
-    static GLuint floatFormats[] = { -1, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB };
-    static GLuint halfFloatFormats[] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
-    static GLuint basicFormats[] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
-
+    static GLuint halfFloatFormats[] = { 
+        (unsigned int)-1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, 
+        GL_RGB16F_ARB, GL_RGBA16F_ARB };
+    static GLuint basicFormats[] = { 
+        (unsigned int)-1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA 
+    };
     glBindTexture(GL_TEXTURE_2D, _id);
 
Index: /trunk/packages/vizservers/nanovis/Texture3D.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/Texture3D.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/Texture3D.cpp	(revision 3559)
@@ -76,8 +76,10 @@
 void Texture3D::update(void *data)
 {
-    static GLuint floatFormats[] = { -1, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB };
-    static GLuint halfFloatFormats[] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
-    static GLuint basicFormats[] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
-
+    static GLuint halfFloatFormats[] = { 
+        (unsigned int)-1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, 
+        GL_RGB16F_ARB, GL_RGBA16F_ARB };
+    static GLuint basicFormats[] = { 
+        (unsigned int)-1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA 
+    };
     glBindTexture(GL_TEXTURE_3D, _id);
 
Index: /trunk/packages/vizservers/nanovis/Trace.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/Trace.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/Trace.cpp	(revision 3559)
@@ -54,5 +54,7 @@
 PrintFBOStatus(GLenum status, const char *prefix) 
 {
+#ifdef WANT_TRACE
     const char *mesg;
+
     switch(status) {
     case GL_FRAMEBUFFER_COMPLETE_EXT:
@@ -78,4 +80,5 @@
     }
     TRACE("FB Status: %s: %s", prefix, mesg);
+#endif  /*WANT_TRACE*/
 }
 
@@ -83,9 +86,12 @@
 CheckGL(const char *prefix)
 {
-    const char *mesg;
     GLenum status = (GLenum)glGetError();
+    if (status == GL_NO_ERROR) {
+	return true;
+    }
+#ifdef WANT_TRACE
+    const char *mesg;                   
+
     switch(status) {
-    case GL_NO_ERROR:
-	return true;
     case GL_INVALID_ENUM:
 	mesg = "GL_INVALID_ENUM";			break;
@@ -107,4 +113,5 @@
     } 
     TRACE("GL Status: %s: %s", prefix, mesg);
+#endif
     return false;
 }
Index: /trunk/packages/vizservers/nanovis/Unirect.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/Unirect.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/Unirect.cpp	(revision 3559)
@@ -89,7 +89,5 @@
     int num[3], nValues;
     float min[3], max[3];
-    float *values;
-    const char *units[4], *order;
-
+    const char *units[4];
 
     if ((objc-1) & 0x01) {
@@ -106,8 +104,7 @@
     axis3 = 2;			/* Z-axis */
 
-    values = NULL;
     num[0] = num[1] = num[2] = nValues = 0;
     min[0] = min[1] = min[2] = max[0] = max[1] = max[2] = 0.0f;
-    order = units[0] = units[1] = units[2] = units[3] = NULL;
+    units[0] = units[1] = units[2] = units[3] = NULL;
 
     int i;
Index: /trunk/packages/vizservers/nanovis/nanovis.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/nanovis.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/nanovis.cpp	(revision 3559)
@@ -247,4 +247,5 @@
         TRACE("Deleting screenBuffer");
         delete [] screenBuffer;
+        screenBuffer = NULL;
     }
     if (perf != NULL) {
@@ -1302,24 +1303,7 @@
 NanoVis::sendDataToClient(const char *command, const char *data, size_t dlen)
 {
-    /*
-      char header[200];
-
-      // Generate the PPM binary file header
-      sprintf(header, "P6 %d %d %d\n", winWidth, winHeight, PPM_MAXVAL);
-
-      size_t header_length = strlen(header);
-      size_t data_length = winWidth * winHeight * 3;
-
-      char command[200];
-      sprintf(command, "%s %lu\n", prefix, 
-      (unsigned long)header_length + data_length);
-    */
-
-    //    size_t wordsPerRow = (winWidth * 24 + 31) / 32;
-    //    size_t bytesPerRow = wordsPerRow * 4;
-    //    size_t rowLength = winWidth * 3;
-    size_t nRecs = 2;
-
-    struct iovec *iov = new iovec[nRecs];
+    size_t numRecords = 2;
+
+    struct iovec *iov = new iovec[numRecords];
 
     // Write the nanovisviewer command, then the image header and data.
@@ -1332,10 +1316,8 @@
     iov[1].iov_base = (char *)data;
     iov[1].iov_len = dlen;
-    if (writev(1, iov, nRecs) < 0) {
+    if (writev(1, iov, numRecords) < 0) {
         ERROR("write failed: %s", strerror(errno));
     }
     delete [] iov;
-    // stats.nFrames++;
-    // stats.nBytes += (bytesPerRow * winHeight);
 }
 
Index: /trunk/packages/vizservers/nanovis/nvconf.h.in
===================================================================
--- /trunk/packages/vizservers/nanovis/nvconf.h.in	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/nvconf.h.in	(revision 3559)
@@ -1,6 +1,2 @@
-/*
- * Copyright (C) 2004-2013  HUBzero Foundation, LLC
- *
- */
 /* nanovis/nvconf.h.in.  Generated from configure.in by autoheader.  */
 
@@ -14,117 +10,12 @@
 #undef HAVE_ARPA_INET_H
 
-/* Define to 1 if you have the `avcodec_decode_video' function. */
-#undef HAVE_AVCODEC_DECODE_VIDEO
-
-/* Define to 1 if you have the `avcodec_decode_video2' function. */
-#undef HAVE_AVCODEC_DECODE_VIDEO2
-
-/* Define to 1 if you have the `avcodec_encode_video' function. */
-#undef HAVE_AVCODEC_ENCODE_VIDEO
-
-/* Define to 1 if you have the `avcodec_encode_video2' function. */
-#undef HAVE_AVCODEC_ENCODE_VIDEO2
-
-/* Define to 1 if you have the `avcodec_init' function. */
-#undef HAVE_AVCODEC_INIT
-
-/* Define to 1 if you have the `avcodec_open' function. */
-#undef HAVE_AVCODEC_OPEN
-
-/* Define to 1 if you have the `avcodec_open2' function. */
-#undef HAVE_AVCODEC_OPEN2
-
-/* Define to 1 if you have the `avcodec_register_all' function. */
-#undef HAVE_AVCODEC_REGISTER_ALL
-
-/* Define to 1 if you have the `avformat_alloc_context' function. */
-#undef HAVE_AVFORMAT_ALLOC_CONTEXT
-
-/* Define to 1 if you have the `avformat_new_stream' function. */
-#undef HAVE_AVFORMAT_NEW_STREAM
-
-/* Define to 1 if you have the `avformat_open_input' function. */
-#undef HAVE_AVFORMAT_OPEN_INPUT
-
-/* Define to 1 if you have the `avformat_write_header' function. */
-#undef HAVE_AVFORMAT_WRITE_HEADER
-
-/* Define to 1 if you have the `avio_close' function. */
-#undef HAVE_AVIO_CLOSE
-
-/* Define to 1 if you have the `avio_open' function. */
-#undef HAVE_AVIO_OPEN
-
-/* Define if AVMEDIA_TYPE_VIDEO enum exists. */
-#undef HAVE_AVMEDIA_TYPE_VIDEO
-
-/* Define to 1 if you have the `av_alloc_format_context' function. */
-#undef HAVE_AV_ALLOC_FORMAT_CONTEXT
-
-/* Define to 1 if you have the `av_dump_format' function. */
-#undef HAVE_AV_DUMP_FORMAT
-
-/* Define to 1 if you have the `av_guess_format' function. */
-#undef HAVE_AV_GUESS_FORMAT
-
-/* Define to 1 if you have the `av_new_stream' function. */
-#undef HAVE_AV_NEW_STREAM
-
-/* Define to 1 if you have the `av_open_input_file' function. */
-#undef HAVE_AV_OPEN_INPUT_FILE
-
-/* Define to 1 if you have the `av_set_parameters' function. */
-#undef HAVE_AV_SET_PARAMETERS
-
-/* Define to 1 if you have the `av_write_header' function. */
-#undef HAVE_AV_WRITE_HEADER
-
 /* Define to 1 if you have the <Cg/cgGL.h> header file. */
 #undef HAVE_CG_CGGL_H
 
-/* Define to 1 if you have the `dump_format' function. */
-#undef HAVE_DUMP_FORMAT
-
-/* Define to 1 if you have the <dx/dx.h> header file. */
-#undef HAVE_DX_DX_H
-
-/* Define to 1 if you have the <ffmpeg/avcodec.h> header file. */
-#undef HAVE_FFMPEG_AVCODEC_H
-
-/* Define to 1 if you have the <ffmpeg/avformat.h> header file. */
-#undef HAVE_FFMPEG_AVFORMAT_H
-
-/* Define to 1 if you have the <ffmpeg/avutil.h> header file. */
-#undef HAVE_FFMPEG_AVUTIL_H
-
-/* Define to 1 if you have the `guess_format' function. */
-#undef HAVE_GUESS_FORMAT
-
-/* Define to 1 if you have the `img_convert' function. */
-#undef HAVE_IMG_CONVERT
+/* nanovis can use ffmpeg to create videos. */
+#undef HAVE_FFMPEG
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `avcodec' library (-lavcodec). */
-#undef HAVE_LIBAVCODEC
-
-/* Define to 1 if you have the <libavcodec/avcodec.h> header file. */
-#undef HAVE_LIBAVCODEC_AVCODEC_H
-
-/* Define to 1 if you have the `avformat' library (-lavformat). */
-#undef HAVE_LIBAVFORMAT
-
-/* Define to 1 if you have the <libavformat/avformat.h> header file. */
-#undef HAVE_LIBAVFORMAT_AVFORMAT_H
-
-/* Define to 1 if you have the `avutil' library (-lavutil). */
-#undef HAVE_LIBAVUTIL
-
-/* Define to 1 if you have the <libavutil/avutil.h> header file. */
-#undef HAVE_LIBAVUTIL_AVUTIL_H
-
-/* Define to 1 if you have the `swscale' library (-lswscale). */
-#undef HAVE_LIBSWSCALE
 
 /* Define to 1 if you have the <memory.h> header file. */
@@ -155,7 +46,4 @@
 #undef HAVE_STRING_H
 
-/* Define to 1 if you have the `sws_scale' function. */
-#undef HAVE_SWS_SCALE
-
 /* Define to 1 if you have the <sys/socket.h> header file. */
 #undef HAVE_SYS_SOCKET_H
@@ -172,10 +60,4 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the `url_fclose' function. */
-#undef HAVE_URL_FCLOSE
-
-/* Define to 1 if you have the `url_fopen' function. */
-#undef HAVE_URL_FOPEN
 
 /* Define to 1 if you have the <vtkSmartPointer.h> header file. */
Index: /trunk/packages/vizservers/nanovis/util/Fonts.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/util/Fonts.cpp	(revision 3558)
+++ /trunk/packages/vizservers/nanovis/util/Fonts.cpp	(revision 3559)
@@ -161,6 +161,4 @@
         if (uiFileId == (unsigned int)c_nFileMagicHeader) {
             // read general font/texture dimensions
-            unsigned int uiTextureWidth, uiTextureHeight, uiFontHeight;
-            uiTextureWidth = uiTextureHeight = uiFontHeight = 0;
             fsInput.read(reinterpret_cast<char*>(&sFont._textureWidth), 
                          sizeof(unsigned int));
