Ignore:
Timestamp:
Sep 18, 2013, 5:51:50 AM (6 years ago)
Author:
ldelgass
Message:

First pass at loading VTK vector data for flows in nanovis

File:
1 edited

Legend:

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

    r3630 r3935  
    3030#include "Command.h"
    3131#include "PPMWriter.h"
     32#ifdef USE_VTK
     33#include "VtkDataSetReader.h"
     34#endif
     35#include "VtkReader.h"
    3236#include "FlowCmd.h"
    3337#include "FlowTypes.h"
     
    243247    size_t length = buf.size();
    244248
    245     Rappture::Unirect3d *dataPtr;
    246     dataPtr = new Rappture::Unirect3d(nComponents);
     249    Rappture::Unirect3d *unirect = NULL;
     250    Volume *volume = NULL;
    247251
    248252    Flow *flow = (Flow *)clientData;
    249253    if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
    250         if (!dataPtr->importDx(result, nComponents, length - 4, bytes + 4)) {
     254        unirect = new Rappture::Unirect3d(nComponents);
     255        if (!unirect->importDx(result, nComponents, length - 4, bytes + 4)) {
    251256            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    252             delete dataPtr;
     257            delete unirect;
    253258            return TCL_ERROR;
    254259        }
    255260    } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) {
    256         if (dataPtr->parseBuffer(interp, buf) != TCL_OK) {
    257             delete dataPtr;
     261        unirect = new Rappture::Unirect3d(nComponents);
     262        if (unirect->parseBuffer(interp, buf) != TCL_OK) {
     263            delete unirect;
    258264            return TCL_ERROR;
    259265        }
    260266    } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) {
     267        unirect = new Rappture::Unirect3d(nComponents);
    261268        Rappture::Unirect2d *u2dPtr;
    262269        u2dPtr = new Rappture::Unirect2d(nComponents);
     
    265272            return TCL_ERROR;
    266273        }
    267         dataPtr->convert(u2dPtr);
     274        unirect->convert(u2dPtr);
    268275        delete u2dPtr;
    269 #if 0
    270276    } else if ((length > 14) && (strncmp(bytes, "# vtk DataFile", 14) == 0)) {
    271277        TRACE("VTK loading...");
     
    277283        }
    278284        Rappture::Outcome context;
    279         volume = load_vtk_volume_stream(context, tag, fdata);
     285#ifdef USE_VTK
     286        volume = load_vtk_volume_stream(context, flow->name(), bytes, length);
     287#else
     288        std::stringstream fdata;
     289        fdata.write(bytes, nBytes);
     290        volume = load_vtk_volume_stream(context, flow->name(), fdata);
     291#endif
    280292        if (volume == NULL) {
    281293            Tcl_AppendResult(interp, context.remark(), (char*)NULL);
    282294            return TCL_ERROR;
    283295        }
    284 #endif
    285296    } else {
    286297        TRACE("header is %.14s", buf.bytes());
    287         if (!dataPtr->importDx(result, nComponents, length, bytes)) {
     298        if (!unirect->importDx(result, nComponents, length, bytes)) {
    288299            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    289             delete dataPtr;
    290             return TCL_ERROR;
    291         }
    292     }
    293     if (dataPtr->nValues() == 0) {
    294         delete dataPtr;
     300            delete unirect;
     301            return TCL_ERROR;
     302        }
     303    }
     304    if (unirect != NULL && unirect->nValues() == 0) {
     305        delete unirect;
    295306        Tcl_AppendResult(interp, "no data found in stream", (char *)NULL);
    296307        return TCL_ERROR;
    297308    }
     309#if 0
    298310    TRACE("nx = %d ny = %d nz = %d",
    299           dataPtr->xNum(), dataPtr->yNum(), dataPtr->zNum());
     311          unirect->xNum(), unirect->yNum(), unirect->zNum());
    300312    TRACE("x0 = %lg y0 = %lg z0 = %lg",
    301           dataPtr->xMin(), dataPtr->yMin(), dataPtr->zMin());
     313          unirect->xMin(), unirect->yMin(), unirect->zMin());
    302314    TRACE("lx = %lg ly = %lg lz = %lg",
    303           dataPtr->xMax() - dataPtr->xMin(),
    304           dataPtr->yMax() - dataPtr->yMin(),
    305           dataPtr->zMax() - dataPtr->zMin());
     315          unirect->xMax() - unirect->xMin(),
     316          unirect->yMax() - unirect->yMin(),
     317          unirect->zMax() - unirect->zMin());
    306318    TRACE("dx = %lg dy = %lg dz = %lg",
    307           dataPtr->xNum() > 1 ? (dataPtr->xMax() - dataPtr->xMin())/(dataPtr->xNum()-1) : 0,
    308           dataPtr->yNum() > 1 ? (dataPtr->yMax() - dataPtr->yMin())/(dataPtr->yNum()-1) : 0,
    309           dataPtr->zNum() > 1 ? (dataPtr->zMax() - dataPtr->zMin())/(dataPtr->zNum()-1) : 0);
     319          unirect->xNum() > 1 ? (unirect->xMax() - unirect->xMin())/(unirect->xNum()-1) : 0,
     320          unirect->yNum() > 1 ? (unirect->yMax() - unirect->yMin())/(unirect->yNum()-1) : 0,
     321          unirect->zNum() > 1 ? (unirect->zMax() - unirect->zMin())/(unirect->zNum()-1) : 0);
    310322    TRACE("magMin = %lg magMax = %lg",
    311           dataPtr->magMin(), dataPtr->magMax());
    312     flow->data(dataPtr);
     323          unirect->magMin(), unirect->magMax());
     324#endif
     325    if (unirect != NULL) {
     326        flow->data(unirect);
     327    } else {
     328        flow->data(volume);
     329    }
     330    double range[2];
     331    flow->getVectorRange(range);
    313332    {
    314333        char info[1024];
    315334        int length =
    316335            sprintf(info, "nv>data tag %s min %g max %g\n",
    317                     flow->name(), dataPtr->magMin(), dataPtr->magMax());
     336                    flow->name(), range[0], range[1]);
    318337#ifdef USE_THREADS
    319338        queueResponse(info, (size_t)length, Response::VOLATILE);
     
    840859    }
    841860    if (Flow::updatePending) {
    842         NanoVis::mapFlows();
     861        NanoVis::setFlowRanges();
    843862    }
    844863    NanoVis::renderLegend(tf, Flow::magMin, Flow::magMax, w, h, label);
     
    965984    NanoVis::resetFlows();
    966985    if (Flow::updatePending) {
    967         NanoVis::mapFlows();
     986        NanoVis::setFlowRanges();
    968987    }
    969988    for (int i = 0; i < nSteps; i++) {
     
    9971016    assert(NanoVis::licRenderer != NULL);
    9981017    if (Flow::updatePending) {
    999         NanoVis::mapFlows();
     1018        NanoVis::setFlowRanges();
    10001019    }
    10011020    NanoVis::licRenderer->convolve();
Note: See TracChangeset for help on using the changeset viewer.