Ignore:
Timestamp:
Dec 22, 2014, 7:18:59 AM (5 years ago)
Author:
ldelgass
Message:

Merge serveral changes from trunk. Does not include threading, world space
changes, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nanovis/branches/1.1/FlowCmd.cpp

    r4893 r4904  
    55 */
    66#include <assert.h>
     7#include <errno.h>
    78#define _OPEN_SYS
    89#include <fcntl.h>
     
    1718#include <poll.h>
    1819
     20#include <sstream>
     21
    1922#include <tcl.h>
    2023
    21 #include <RpOutcome.h>
    2224#include <RpBuffer.h>
    2325
     
    138140                  Tcl_Obj *const *objv)
    139141{
    140     Rappture::Outcome result;
    141 
    142142    TRACE("Enter");
    143143
     
    177177    if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
    178178        unirect = new Unirect3d(nComponents);
    179         if (!unirect->importDx(result, nComponents, length - 4, bytes + 4)) {
    180             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     179        if (!unirect->importDx(nComponents, length - 4, bytes + 4)) {
     180            Tcl_AppendResult(interp, "Failed to load DX file", (char *)NULL);
    181181            delete unirect;
    182182            return TCL_ERROR;
     
    184184    } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) {
    185185        unirect = new Unirect3d(nComponents);
    186         if (unirect->parseBuffer(interp, buf) != TCL_OK) {
     186        if (unirect->parseBuffer(interp, bytes, length) != TCL_OK) {
    187187            delete unirect;
    188188            return TCL_ERROR;
    189189        }
    190190    } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) {
    191         unirect = new Unirect3d(nComponents);
    192191        Unirect2d *u2dPtr = new Unirect2d(nComponents);
    193         if (u2dPtr->parseBuffer(interp, buf) != TCL_OK) {
     192        if (u2dPtr->parseBuffer(interp, bytes, length) != TCL_OK) {
    194193            delete u2dPtr;
    195194            return TCL_ERROR;
    196195        }
     196        unirect = new Unirect3d(nComponents);
    197197        unirect->convert(u2dPtr);
    198198        delete u2dPtr;
     
    200200        TRACE("header is %.14s", buf.bytes());
    201201        unirect = new Unirect3d(nComponents);
    202         if (!unirect->importDx(result, nComponents, length, bytes)) {
    203             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     202        if (!unirect->importDx(nComponents, length, bytes)) {
     203            Tcl_AppendResult(interp, "Failed to load DX file", (char *)NULL);
    204204            delete unirect;
    205205            return TCL_ERROR;
    206206        }
    207207    }
    208     if (unirect->nValues() == 0) {
     208    if (unirect != NULL && unirect->nValues() == 0) {
    209209        delete unirect;
    210210        Tcl_AppendResult(interp, "no data found in stream", (char *)NULL);
    211211        return TCL_ERROR;
    212212    }
    213     TRACE("nx = %d ny = %d nz = %d",
    214           unirect->xNum(), unirect->yNum(), unirect->zNum());
    215     TRACE("x0 = %lg y0 = %lg z0 = %lg",
    216           unirect->xMin(), unirect->yMin(), unirect->zMin());
    217     TRACE("lx = %lg ly = %lg lz = %lg",
    218           unirect->xMax() - unirect->xMin(),
    219           unirect->yMax() - unirect->yMin(),
    220           unirect->zMax() - unirect->zMin());
    221     TRACE("dx = %lg dy = %lg dz = %lg",
    222           unirect->xNum() > 1 ? (unirect->xMax() - unirect->xMin())/(unirect->xNum()-1) : 0,
    223           unirect->yNum() > 1 ? (unirect->yMax() - unirect->yMin())/(unirect->yNum()-1) : 0,
    224           unirect->zNum() > 1 ? (unirect->zMax() - unirect->zMin())/(unirect->zNum()-1) : 0);
    225     TRACE("magMin = %lg magMax = %lg",
    226           unirect->magMin(), unirect->magMax());
    227     flow->data(unirect);
    228     {
     213    if (unirect != NULL) {
     214        TRACE("nx = %d ny = %d nz = %d",
     215              unirect->xNum(), unirect->yNum(), unirect->zNum());
     216        TRACE("x0 = %lg y0 = %lg z0 = %lg",
     217              unirect->xMin(), unirect->yMin(), unirect->zMin());
     218        TRACE("lx = %lg ly = %lg lz = %lg",
     219              unirect->xMax() - unirect->xMin(),
     220              unirect->yMax() - unirect->yMin(),
     221              unirect->zMax() - unirect->zMin());
     222        TRACE("dx = %lg dy = %lg dz = %lg",
     223              unirect->xNum() > 1 ? (unirect->xMax() - unirect->xMin())/(unirect->xNum()-1) : 0,
     224              unirect->yNum() > 1 ? (unirect->yMax() - unirect->yMin())/(unirect->yNum()-1) : 0,
     225              unirect->zNum() > 1 ? (unirect->zMax() - unirect->zMin())/(unirect->zNum()-1) : 0);
     226        TRACE("magMin = %lg magMax = %lg",
     227              unirect->magMin(), unirect->magMax());
     228        flow->data(unirect);
     229
    229230        char info[1024];
    230231        int length =
     
    235236        }
    236237    }
    237     NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
     238    Flow::updatePending = true;
     239    NanoVis::eventuallyRedraw();
    238240    return TCL_OK;
    239241}
     
    280282    const char *string = Tcl_GetString(objPtr);
    281283    if (string[1] == '\0') {
    282         Flow::SliceAxis *axisPtr = (Flow::SliceAxis *)(record + offset);
     284        FlowSliceAxis *axisPtr = (FlowSliceAxis *)(record + offset);
    283285        char c;
    284286        c = tolower((unsigned char)string[0]);
    285287        if (c == 'x') {
    286             *axisPtr = Flow::AXIS_X;
     288            *axisPtr = AXIS_X;
    287289            return TCL_OK;
    288290        } else if (c == 'y') {
    289             *axisPtr = Flow::AXIS_Y;
     291            *axisPtr = AXIS_Y;
    290292            return TCL_OK;
    291293        } else if (c == 'z') {
    292             *axisPtr = Flow::AXIS_Z;
     294            *axisPtr = AXIS_Z;
    293295            return TCL_OK;
    294296        }
     
    491493        return TCL_ERROR;
    492494    }
    493     NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
     495    Flow::updatePending = true;
     496    NanoVis::eventuallyRedraw();
    494497    return TCL_OK;
    495498}
     
    514517    }
    515518    particles->configure();
     519    Flow::updatePending = true;
    516520    NanoVis::eventuallyRedraw();
    517521    Tcl_SetObjResult(interp, objv[3]);
     
    535539        return TCL_ERROR;
    536540    }
    537     particles->configure();
    538     NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
     541    if (particles->configure()) {
     542        Flow::updatePending = true;
     543    }
     544    NanoVis::eventuallyRedraw();
    539545    return TCL_OK;
    540546}
     
    742748        return TCL_ERROR;
    743749    }
    744     if (NanoVis::flags & NanoVis::MAP_FLOWS) {
    745         NanoVis::mapFlows();
     750    if (Flow::updatePending) {
     751        NanoVis::setFlowRanges();
    746752    }
    747753    NanoVis::renderLegend(tf, NanoVis::magMin, NanoVis::magMax, w, h, label);
     
    832838        }
    833839    }
    834     NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
     840    Flow::updatePending = true;
     841    NanoVis::eventuallyRedraw();
    835842    return TCL_OK;
    836843}
     
    866873    }
    867874    NanoVis::resetFlows();
    868     if (NanoVis::flags & NanoVis::MAP_FLOWS) {
    869         NanoVis::mapFlows();
    870     }
    871     NanoVis::advectFlows();
     875    if (Flow::updatePending) {
     876        NanoVis::setFlowRanges();
     877    }
    872878    for (int i = 0; i < nSteps; i++) {
    873         if (NanoVis::licRenderer->active()) {
    874             NanoVis::licRenderer->convolve();
    875         }
     879        NanoVis::licRenderer->convolve();
    876880        NanoVis::advectFlows();
    877881    }
     
    901905{
    902906    assert(NanoVis::licRenderer != NULL);
    903     if (NanoVis::flags & NanoVis::MAP_FLOWS) {
    904         NanoVis::mapFlows();
    905     }
    906     NanoVis::eventuallyRedraw();
     907    if (Flow::updatePending) {
     908        NanoVis::setFlowRanges();
     909    }
    907910    NanoVis::licRenderer->convolve();
    908911    NanoVis::advectFlows();
     912    NanoVis::eventuallyRedraw();
    909913    return TCL_OK;
    910914}
     
    918922}
    919923
    920 #ifdef HAVE_FFMPEG
     924#if defined(HAVE_FFMPEG) || defined(HAVE_AVCONV)
    921925
    922926/**
     
    10771081            break;
    10781082        }
    1079         if (NanoVis::licRenderer->active()) {
    1080             NanoVis::licRenderer->convolve();
    1081         }
     1083        NanoVis::licRenderer->convolve();
    10821084        NanoVis::advectFlows();
    10831085
     
    11111113          FlowVideoSwitches *switchesPtr)
    11121114{
    1113 #ifndef FFMPEG
    1114 #  define FFMPEG "/usr/bin/ffmpeg"
     1115    char cmd[BUFSIZ];
     1116#ifdef HAVE_AVCONV
     1117    /* Generate the movie from the frame images by exec-ing avconv */
     1118    /* The avconv command is
     1119     *   avconv -f image2 -i /var/tmp/xxxxx/image%d.ppm                 \
     1120     *      -f outformat -b bitrate -r framerate /var/tmp/xxxxx/movie.mpeg
     1121     */
     1122#ifndef AVCONV
     1123#  define AVCONV "/usr/bin/avconv"
    11151124#endif
     1125    sprintf(cmd, "%s -f image2 -i %s/image%%d.ppm -f %s -b %d -r %f -",
     1126            AVCONV, tmpFileName, Tcl_GetString(switchesPtr->formatObjPtr),
     1127            switchesPtr->bitRate, switchesPtr->frameRate);
     1128#else
    11161129    /* Generate the movie from the frame images by exec-ing ffmpeg */
    11171130    /* The ffmpeg command is
     
    11191132     *      -b bitrate -f framerate /var/tmp/xxxxx/movie.mpeg
    11201133     */
    1121     char cmd[BUFSIZ];
     1134#ifndef FFMPEG
     1135#  define FFMPEG "/usr/bin/ffmpeg"
     1136#endif
    11221137    sprintf(cmd, "%s -f image2 -i %s/image%%d.ppm -f %s -b %d -r %f -",
    11231138            FFMPEG, tmpFileName, Tcl_GetString(switchesPtr->formatObjPtr),
    11241139            switchesPtr->bitRate, switchesPtr->frameRate);
     1140#endif
    11251141    TRACE("Enter: %s", cmd);
    11261142    FILE *f = popen(cmd, "r");
Note: See TracChangeset for help on using the changeset viewer.