Changeset 4063


Ignore:
Timestamp:
Nov 15, 2013 3:32:03 PM (10 years ago)
Author:
ldelgass
Message:

Remove some more Rappture deps from nanovis

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

Legend:

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

    r4056 r4063  
    3333
    3434#include <assert.h>
     35#include <errno.h>
    3536#include <stdlib.h>
    3637#include <unistd.h>                     /* Needed for getpid, gethostname,
     
    4041#include <RpField1D.h>
    4142#include <RpEncode.h>
    42 #include <RpOutcome.h>
    4343#include <RpBuffer.h>
    4444
     
    5757#ifdef USE_VTK
    5858#include "VtkDataSetReader.h"
     59#else
     60#include "VtkReader.h"
    5961#endif
    60 #include "VtkReader.h"
    6162#include "BMPWriter.h"
    6263#include "PPMWriter.h"
     
    153154}
    154155
    155 bool
    156 nv::SocketRead(Rappture::Buffer &buf, size_t len)
    157 {
    158     ReadBuffer::BufferStatus status;
    159     status = g_inBufPtr->followingData(buf, len);
    160     TRACE("followingData status: %d", status);
    161     return (status == ReadBuffer::OK);
    162 }
    163 
    164156static int
    165157ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr)
     
    534526/**
    535527 * Read the requested number of bytes from standard input into the given
    536  * buffer.  The buffer is then decompressed and decoded.
     528 * buffer.  The buffer must have already been allocated for nBytes.  The
     529 * buffer is then decompressed and decoded.
    537530 */
    538531int
    539532nv::GetDataStream(Tcl_Interp *interp, Rappture::Buffer &buf, int nBytes)
    540533{
    541     if (!SocketRead(buf, nBytes)) {
    542         return TCL_ERROR;
    543     }
     534    if (!SocketRead((char *)buf.bytes(), nBytes)) {
     535        return TCL_ERROR;
     536    }
     537    buf.count(nBytes);
    544538    Rappture::Outcome err;
    545539    TRACE("Checking header[%.13s]", buf.bytes());
     
    12801274    if ((nBytes > 5) && (strncmp(bytes, "<HDR>", 5) == 0)) {
    12811275        TRACE("ZincBlende Stream loading...");
    1282         volume = (Volume *)ZincBlendeReconstructor::getInstance()->loadFromMemory(const_cast<char *>(bytes));
     1276        volume = (Volume *)ZincBlendeReconstructor::getInstance()->loadFromMemory(bytes);
    12831277        if (volume == NULL) {
    12841278            Tcl_AppendResult(interp, "can't get volume instance", (char *)NULL);
     
    13011295            abort();
    13021296        }
    1303         Rappture::Outcome context;
    13041297#ifdef USE_VTK
    1305         volume = load_vtk_volume_stream(context, tag, bytes, nBytes);
     1298        volume = load_vtk_volume_stream(tag, bytes, nBytes);
    13061299#else
    13071300        std::stringstream fdata;
    13081301        fdata.write(bytes, nBytes);
    1309         volume = load_vtk_volume_stream(context, tag, fdata);
     1302        volume = load_vtk_volume_stream(tag, fdata);
    13101303#endif
    13111304        if (volume == NULL) {
    1312             Tcl_AppendResult(interp, context.remark(), (char*)NULL);
     1305            Tcl_AppendResult(interp, "Failed to load VTK file", (char*)NULL);
    13131306            return TCL_ERROR;
    13141307        }
     
    13261319        std::stringstream fdata;
    13271320        fdata.write(bytes, nBytes);
    1328         Rappture::Outcome context;
    1329         volume = load_dx_volume_stream(context, tag, fdata);
     1321        volume = load_dx_volume_stream(tag, fdata);
    13301322        if (volume == NULL) {
    1331             Tcl_AppendResult(interp, context.remark(), (char*)NULL);
     1323            Tcl_AppendResult(interp, "Failed to load DX file", (char*)NULL);
    13321324            return TCL_ERROR;
    13331325        }
     
    17651757    }
    17661758    Unirect2d data(1);
    1767     if (data.parseBuffer(interp, buf) != TCL_OK) {
     1759    if (data.parseBuffer(interp, buf.bytes(), buf.size()) != TCL_OK) {
    17681760        return TCL_ERROR;
    17691761    }
  • trunk/packages/vizservers/nanovis/Command.h

    r3613 r4063  
    3737extern bool SocketRead(char *bytes, size_t len);
    3838
    39 extern bool SocketRead(Rappture::Buffer &buf, size_t len);
    40 
    4139extern int processCommands(Tcl_Interp *interp,
    4240                           ReadBuffer *inBufPtr,
  • trunk/packages/vizservers/nanovis/FlowCmd.cpp

    r4056 r4063  
    1717#include <poll.h>
    1818
     19#include <sstream>
     20
    1921#include <tcl.h>
    2022
    21 #include <RpOutcome.h>
     23#include <RpBuffer.h>
    2224
    2325#include <vrmath/Vector3f.h>
     
    3234#ifdef USE_VTK
    3335#include "VtkDataSetReader.h"
     36#else
     37#include "VtkReader.h"
    3438#endif
    35 #include "VtkReader.h"
    3639#include "FlowCmd.h"
    3740#include "FlowTypes.h"
     
    135138};
    136139
    137 static int
    138 FlowDataFileOp(ClientData clientData, Tcl_Interp *interp, int objc,
    139                Tcl_Obj *const *objv)
    140 {
    141     Rappture::Outcome result;
    142 
    143     const char *fileName;
    144     fileName = Tcl_GetString(objv[3]);
    145     TRACE("File: %s", fileName);
    146 
    147     int nComponents;
    148     if (Tcl_GetIntFromObj(interp, objv[4], &nComponents) != TCL_OK) {
    149         return TCL_ERROR;
    150     }
    151     if ((nComponents < 1) || (nComponents > 4)) {
    152         Tcl_AppendResult(interp, "bad # of components \"",
    153                          Tcl_GetString(objv[4]), "\"", (char *)NULL);
    154         return TCL_ERROR;
    155     }
    156     Rappture::Buffer buf;
    157     if (!buf.load(result, fileName)) {
    158         Tcl_AppendResult(interp, "can't load data from \"", fileName, "\": ",
    159                          result.remark(), (char *)NULL);
    160         return TCL_ERROR;
    161     }
    162 
    163     Unirect3d *dataPtr;
    164     dataPtr = new Unirect3d(nComponents);
    165     Flow *flow = (Flow *)clientData;
    166     size_t length = buf.size();
    167     char *bytes = (char *)buf.bytes();
    168     if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
    169         if (!dataPtr->importDx(result, nComponents, length-4, bytes+4)) {
    170             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    171             delete dataPtr;
    172             return TCL_ERROR;
    173         }
    174     } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) {
    175         if (dataPtr->parseBuffer(interp, buf) != TCL_OK) {
    176             delete dataPtr;
    177             return TCL_ERROR;
    178         }
    179     } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) {
    180         Unirect2d *u2dPtr;
    181         u2dPtr = new Unirect2d(nComponents);
    182         if (u2dPtr->parseBuffer(interp, buf) != TCL_OK) {
    183             delete u2dPtr;
    184             return TCL_ERROR;
    185         }
    186         dataPtr->convert(u2dPtr);
    187         delete u2dPtr;
    188     } else {
    189         TRACE("header is %.14s", buf.bytes());
    190         if (!dataPtr->importDx(result, nComponents, length, bytes)) {
    191             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    192             delete dataPtr;
    193             return TCL_ERROR;
    194         }
    195     }
    196     if (dataPtr->nValues() == 0) {
    197         delete dataPtr;
    198         Tcl_AppendResult(interp, "no data found in \"", fileName, "\"",
    199                          (char *)NULL);
    200         return TCL_ERROR;
    201     }
    202     flow->data(dataPtr);
    203     Flow::updatePending = true;
    204     NanoVis::eventuallyRedraw();
    205     return TCL_OK;
    206 }
    207 
    208140/**
    209141 * $flow data follows nbytes nComponents
     
    213145                  Tcl_Obj *const *objv)
    214146{
    215     Rappture::Outcome result;
    216 
    217147    TRACE("Enter");
    218148
     
    253183    if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
    254184        unirect = new Unirect3d(nComponents);
    255         if (!unirect->importDx(result, nComponents, length - 4, bytes + 4)) {
    256             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     185        if (!unirect->importDx(nComponents, length - 4, bytes + 4)) {
     186            Tcl_AppendResult(interp, "Failed to load DX file", (char *)NULL);
    257187            delete unirect;
    258188            return TCL_ERROR;
     
    260190    } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) {
    261191        unirect = new Unirect3d(nComponents);
    262         if (unirect->parseBuffer(interp, buf) != TCL_OK) {
     192        if (unirect->parseBuffer(interp, bytes, length) != TCL_OK) {
    263193            delete unirect;
    264194            return TCL_ERROR;
     
    268198        Unirect2d *u2dPtr;
    269199        u2dPtr = new Unirect2d(nComponents);
    270         if (u2dPtr->parseBuffer(interp, buf) != TCL_OK) {
     200        if (u2dPtr->parseBuffer(interp, bytes, length) != TCL_OK) {
    271201            delete unirect;
    272202            delete u2dPtr;
     
    277207    } else if ((length > 14) && (strncmp(bytes, "# vtk DataFile", 14) == 0)) {
    278208        TRACE("VTK loading...");
    279         std::stringstream fdata;
    280         fdata.write(bytes, length);
    281209        if (length <= 0) {
    282210            ERROR("data buffer is empty");
    283211            abort();
    284212        }
    285         Rappture::Outcome context;
    286213#ifdef USE_VTK
    287         volume = load_vtk_volume_stream(context, flow->name(), bytes, length);
     214        volume = load_vtk_volume_stream(flow->name(), bytes, length);
    288215#else
    289216        std::stringstream fdata;
    290         fdata.write(bytes, nBytes);
    291         volume = load_vtk_volume_stream(context, flow->name(), fdata);
     217        fdata.write(bytes, length);
     218        volume = load_vtk_volume_stream(flow->name(), fdata);
    292219#endif
    293220        if (volume == NULL) {
    294             Tcl_AppendResult(interp, context.remark(), (char*)NULL);
     221            Tcl_AppendResult(interp, "Failed to load VTK file", (char*)NULL);
    295222            return TCL_ERROR;
    296223        }
     
    298225        TRACE("header is %.14s", buf.bytes());
    299226        unirect = new Unirect3d(nComponents);
    300         if (!unirect->importDx(result, nComponents, length, bytes)) {
    301             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     227        if (!unirect->importDx(nComponents, length, bytes)) {
     228            Tcl_AppendResult(interp, "Failed to load DX file", (char *)NULL);
    302229            delete unirect;
    303230            return TCL_ERROR;
     
    350277
    351278static CmdSpec flowDataOps[] = {
    352     {"file",    2, FlowDataFileOp,    5, 5, "fileName nComponents",},
    353279    {"follows", 2, FlowDataFollowsOp, 5, 5, "size nComponents",},
    354280};
     
    11961122        return TCL_ERROR;
    11971123    }
    1198     Rappture::Buffer data;
     1124    char *data = NULL;
    11991125    size_t total = 0;
    12001126    for (;;) {
     
    12021128        char buffer[BUFSIZ];
    12031129       
    1204         numRead = fread(buffer, sizeof(unsigned char), BUFSIZ, f);
     1130        numRead = fread(buffer, sizeof(char), BUFSIZ, f);
    12051131        total += numRead;
    12061132        if (numRead == 0) {             // EOF
     
    12141140            return TCL_ERROR;
    12151141        }
    1216         if (!data.append(buffer, numRead)) {
     1142        data = (char *)realloc(data, total);
     1143        if (data == NULL) {
    12171144            ERROR("Can't append movie data to buffer %d bytes",
    12181145                  numRead);
     
    12211148            return TCL_ERROR;
    12221149        }
    1223     }
    1224     if (data.size() == 0) {
     1150        memcpy(data + (total - numRead), buffer, numRead);
     1151    }
     1152    if (total == 0) {
    12251153        ERROR("ffmpeg returned 0 bytes");
    12261154    }
    12271155    // Send zero length to client so it can deal with error
    12281156    sprintf(cmd,"nv>image -type movie -token \"%s\" -bytes %lu\n",
    1229             token, (unsigned long)data.size());
    1230     nv::sendDataToClient(cmd, data.bytes(), data.size());
     1157            token, total);
     1158    // Memory is freed by this call
     1159    nv::sendDataToClient(cmd, data, total);
    12311160    return TCL_OK;
    12321161}
  • trunk/packages/vizservers/nanovis/Makefile.in

    r4060 r4063  
    5757VTK_LIB_DIR     = @VTK_LIB_DIR@
    5858VTK_INC_DIR     = @VTK_INC_DIR@
     59ifdef USE_VTK
    5960VTK_INC_SPEC    = -I$(VTK_INC_DIR)/vtk-$(VTK_VERSION)
    6061VTK_LIB_SPEC    = -L$(VTK_LIB_DIR) \
     
    7172                -lvtkCommonTransforms-$(VTK_VERSION) \
    7273                -lvtkCommonMath-$(VTK_VERSION)
     74else
     75VTK_INC_SPEC    =
     76VTK_LIB_SPEC    =
     77endif
    7378
    7479EXTRA_LIBS      = -lm -lpthread
     
    174179                VolumeRenderer.o \
    175180                VolumeShader.o \
    176                 VtkReader.o \
    177181                ZincBlendeReconstructor.o \
    178182                ZincBlendeVolume.o \
     
    231235OBJS +=         DataSetResample.o \
    232236                VtkDataSetReader.o
     237else
     238OBJS +=         VtkReader.o
    233239endif
    234240
  • trunk/packages/vizservers/nanovis/ReadBuffer.cpp

    r3605 r4063  
    143143}
    144144
    145 ReadBuffer::BufferStatus
    146 ReadBuffer::followingData(Rappture::Buffer& out, size_t numBytes)
    147 {
    148     TRACE("Enter");
    149     while (numBytes > 0) {
    150         size_t bytesLeft;
    151 
    152         bytesLeft = _fill - _mark;
    153         if (bytesLeft > 0) {
    154             int size;
    155 
    156             /* Pull bytes out of the buffer, updating the mark. */
    157             size = (bytesLeft >  numBytes) ? numBytes : bytesLeft;
    158             out.append((const char *)_bytes + _mark, size);
    159             _mark += size;
    160             numBytes -= size;
    161         }
    162         if (numBytes == 0) {
    163             /* Received requested # bytes. */
    164             return ReadBuffer::OK;
    165         }
    166         /* Didn't get enough bytes, need to read some more. */
    167         _lastStatus = doFill();
    168         if (_lastStatus == ReadBuffer::ERROR ||
    169             _lastStatus == ReadBuffer::ENDFILE) {
    170             return _lastStatus;
    171         }
    172     }
    173     return ReadBuffer::OK;
    174 }
    175 
    176145/**
    177146 * \brief Returns the next available line (terminated by a newline)
  • trunk/packages/vizservers/nanovis/ReadBuffer.h

    r3605 r4063  
    3535
    3636    BufferStatus followingData(unsigned char *out, size_t numBytes);
    37 
    38     BufferStatus followingData(Rappture::Buffer& out, size_t numBytes);
    3937
    4038    /**
  • trunk/packages/vizservers/nanovis/Unirect.cpp

    r4056 r4063  
    4242
    4343int
    44 nv::Unirect2d::parseBuffer(Tcl_Interp *interp, Rappture::Buffer &buf)
    45 {
    46     Tcl_Obj *objPtr = Tcl_NewStringObj(buf.bytes(), buf.size());
     44nv::Unirect2d::parseBuffer(Tcl_Interp *interp, const char *bytes, size_t len)
     45{
     46    Tcl_Obj *objPtr = Tcl_NewStringObj(bytes, len);
    4747    Tcl_Obj **objv;
    4848    int objc;
     
    5959
    6060int
    61 nv::Unirect3d::parseBuffer(Tcl_Interp *interp, Rappture::Buffer &buf)
     61nv::Unirect3d::parseBuffer(Tcl_Interp *interp, const char *bytes, size_t len)
    6262{
    6363    Tcl_Obj *objPtr;
    64     objPtr = Tcl_NewStringObj(buf.bytes(), buf.size());
     64    objPtr = Tcl_NewStringObj(bytes, len);
    6565    Tcl_Obj **objv;
    6666    int objc;
     
    487487
    488488bool
    489 nv::Unirect3d::importDx(Rappture::Outcome &result, size_t nComponents,
     489nv::Unirect3d::importDx(size_t nComponents,
    490490                        size_t length, char *string)
    491491{
     
    510510                   &nx, &ny, &nz) == 3) {
    511511            if ((nx < 0) || (ny < 0) || (nz < 0)) {
    512                 result.addError("invalid grid size: x=%d, y=%d, z=%d",
    513                         nx, ny, nz);
     512                ERROR("invalid grid size: x=%d, y=%d, z=%d",
     513                      nx, ny, nz);
    514514                return false;
    515515            }
     
    528528                " rank 1 items %d data follows", &npts) == 1) {
    529529            if (npts < 0) {
    530                 result.addError("bad # points %d", npts);
     530                ERROR("bad # points %d", npts);
    531531                return false;
    532532            }
    533533            TRACE("#points=%d", npts);
    534534            if (npts != nx*ny*nz) {
    535                 result.addError("inconsistent data: expected %d points"
    536                                 " but found %d points", nx*ny*nz, npts);
     535                ERROR("inconsistent data: expected %d points"
     536                      " but found %d points", nx*ny*nz, npts);
    537537                return false;
    538538            }
     
    541541                " times %d data follows", &npts) == 1) {
    542542            if (npts != nx*ny*nz) {
    543                 result.addError("inconsistent data: expected %d points"
    544                                 " but found %d points", nx*ny*nz, npts);
     543                ERROR("inconsistent data: expected %d points"
     544                      " but found %d points", nx*ny*nz, npts);
    545545                return false;
    546546            }
     
    549549    }
    550550    if (npts != nx*ny*nz) {
    551         result.addError("inconsistent data: expected %d points"
    552                         " but found %d points", nx*ny*nz, npts);
     551        ERROR("inconsistent data: expected %d points"
     552              " but found %d points", nx*ny*nz, npts);
    553553        return false;
    554554    }
     
    605605    /* Make sure that we read all of the expected points. */
    606606    if (_nValues != (size_t)npts) {
    607         result.addError("inconsistent data: expected %d points"
    608                         " but found %d points", npts, _nValues);
     607        ERROR("inconsistent data: expected %d points"
     608              " but found %d points", npts, _nValues);
    609609        free(_values);
    610610        _values = NULL;
  • trunk/packages/vizservers/nanovis/Unirect.h

    r4056 r4063  
    1212#include <tcl.h>
    1313
    14 #include <rappture.h>
     14#include <RpBuffer.h>
    1515
    1616#include <vrmath/Vector3f.h>
     
    222222    int loadData(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv);
    223223
    224     int parseBuffer(Tcl_Interp *interp, Rappture::Buffer &buf);
    225 
    226     bool importDx(Rappture::Outcome &result, size_t nComponents,
    227                   size_t length, char *string);
     224    int parseBuffer(Tcl_Interp *interp, const char *bytes, size_t len);
     225
     226    bool importDx(size_t nComponents, size_t length, char *string);
    228227
    229228    bool convert(Unirect2d *dataPtr);
     
    382381    int loadData(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv);
    383382
    384     int parseBuffer(Tcl_Interp *interp, Rappture::Buffer &buf);
     383    int parseBuffer(Tcl_Interp *interp, const char *bytes, size_t len);
    385384
    386385    bool isInitialized()
  • trunk/packages/vizservers/nanovis/VtkDataSetReader.cpp

    r3943 r4063  
    1616#include <vtkCharArray.h>
    1717
    18 #include <RpOutcome.h>
    19 
    2018#include <vrmath/Vector3f.h>
    2119
     
    3230
    3331Volume *
    34 nv::load_vtk_volume_stream(Rappture::Outcome& result, const char *tag, const char *bytes, int nBytes)
     32nv::load_vtk_volume_stream(const char *tag, const char *bytes, int nBytes)
    3533{
    3634    TRACE("Enter tag:%s", tag);
  • trunk/packages/vizservers/nanovis/VtkDataSetReader.h

    r3870 r4063  
    99#include <iostream>
    1010
    11 namespace Rappture {
    12 class Outcome;
    13 }
    14 
    1511namespace nv {
    1612
     
    1814
    1915extern Volume *
    20 load_vtk_volume_stream(Rappture::Outcome& status, const char *tag, const char *bytes, int nBytes);
     16load_vtk_volume_stream(const char *tag, const char *bytes, int nBytes);
    2117
    2218}
  • trunk/packages/vizservers/nanovis/VtkReader.cpp

    r3870 r4063  
    88#include <float.h>
    99
    10 #include <RpOutcome.h>
    1110#include <RpField1D.h>
    1211#include <RpFieldRect3D.h>
     
    184183
    185184Volume *
    186 nv::load_vtk_volume_stream(Rappture::Outcome& result, const char *tag, std::iostream& fin)
     185nv::load_vtk_volume_stream(const char *tag, std::iostream& fin)
    187186{
    188187    TRACE("Enter tag:%s", tag);
     
    208207        fin.getline(line, sizeof(line) - 1);
    209208        if (fin.fail()) {
    210             result.error("Error in data stream");
     209            ERROR("Error in data stream");
    211210            return NULL;
    212211        }
     
    223222                    isRect = 1;
    224223                } else {
    225                     result.addError("Unsupported DataSet type '%s'", str);
     224                    ERROR("Unsupported DataSet type '%s'", str);
    226225                    return NULL;
    227226                }
    228227            } else if (sscanf(start, "DIMENSIONS %d %d %d", &nx, &ny, &nz) == 3) {
    229228                if (nx <= 0 || ny <= 0 || nz <= 0) {
    230                     result.error("Found non-positive dimensions");
     229                    ERROR("Found non-positive dimensions");
    231230                    return NULL;
    232231                }
     
    236235            } else if (sscanf(start, "SPACING %lg %lg %lg", &dx, &dy, &dz) == 3) {
    237236                if ((nx > 1 && dx == 0.0) || (ny > 1 && dy == 0.0) || (nz > 1 && dz == 0.0)) {
    238                     result.error("Found zero spacing for dimension");
     237                    ERROR("Found zero spacing for dimension");
    239238                    return NULL;
    240239                }
     
    242241            } else if (sscanf(start, "POINT_DATA %d", &npts) == 1) {
    243242                if (npts < 1 || npts != nx * ny * nz) {
    244                     result.addError("Error in data stream: unexpected number of point data: %d", npts);
     243                    ERROR("Error in data stream: unexpected number of point data: %d", npts);
    245244                    return NULL;
    246245                }
    247246                if (isBinary < 0 || fin.eof()) {
    248247                    // Should know if ASCII or BINARY by now
    249                     result.error("Error in data stream");
     248                    ERROR("Error in data stream");
    250249                    return NULL;
    251250                }
    252251                fin.getline(line, sizeof(line) - 1);
    253252                if (fin.fail()) {
    254                     result.error("Error in data stream");
     253                    ERROR("Error in data stream");
    255254                    return NULL;
    256255                }
     
    258257                    ;  // skip leading blanks
    259258                if (sscanf(start, "SCALARS %s %s", str, type) != 2) {
    260                     result.error("Error in data stream");
     259                    ERROR("Error in data stream");
    261260                    return NULL;
    262261                }
     
    268267                    ftype = UCHAR;
    269268                    if (!isBinary) {
    270                         result.addError("unsigned char only supported in binary VTK files");
     269                        ERROR("unsigned char only supported in binary VTK files");
    271270                        return NULL;
    272271                    }
     
    280279                    ftype = UINT;
    281280                } else {
    282                     result.addError("Unsupported scalar type: '%s'", type);
     281                    ERROR("Unsupported scalar type: '%s'", type);
    283282                    return NULL;
    284283                }
    285284                if (fin.eof()) {
    286                     result.error("Error in data stream");
     285                    ERROR("Error in data stream");
    287286                    return NULL;
    288287                }
    289288                fin.getline(line, sizeof(line) - 1);
    290289                if (fin.fail()) {
    291                     result.error("Error in data stream");
     290                    ERROR("Error in data stream");
    292291                    return NULL;
    293292                }
     
    297296                    // skip lookup table, but don't read ahead
    298297                    if (fin.eof()) {
    299                         result.error("Error in data stream");
     298                        ERROR("Error in data stream");
    300299                        return NULL;
    301300                    }
    302301                } else {
    303302                    // Lookup table line is required
    304                     result.error("Missing LOOKUP_TABLE");
     303                    ERROR("Missing LOOKUP_TABLE");
    305304                    return NULL;
    306305                }
     
    311310                    if (fin.fail()) {
    312311                        deleteFieldData(fieldData, ftype);
    313                         result.error("Error in data stream");
     312                        ERROR("Error in data stream");
    314313                        return NULL;
    315314                    }
     
    321320                        if (fin.fail()) {
    322321                            deleteFieldData(fieldData, ftype);
    323                             result.error("Error in data stream");
     322                            ERROR("Error in data stream");
    324323                            return NULL;
    325324                        }
     
    334333    if (isRect < 0 || numRead != npts || npts < 1) {
    335334        deleteFieldData(fieldData, ftype);
    336         result.error("Error in data stream");
     335        ERROR("Error in data stream");
    337336        return NULL;
    338337    }
     
    469468    } else {
    470469        deleteFieldData(fieldData, ftype);
    471         result.error("Unsupported DataSet");
     470        ERROR("Unsupported DataSet");
    472471        return NULL;
    473472    }
  • trunk/packages/vizservers/nanovis/VtkReader.h

    r3613 r4063  
    99#include <iostream>
    1010
    11 namespace Rappture {
    12 class Outcome;
    13 }
    14 
    1511namespace nv {
    1612
     
    1814
    1915extern Volume *
    20 load_vtk_volume_stream(Rappture::Outcome& status, const char *tag, std::iostream& fin);
     16load_vtk_volume_stream(const char *tag, std::iostream& fin);
    2117
    2218}
  • trunk/packages/vizservers/nanovis/ZincBlendeReconstructor.cpp

    r3630 r4063  
    6161    do {
    6262        getLine(stream);
    63         if (buff[0] == '#') {
     63        if (_buff[0] == '#') {
    6464            continue;
    65         } else if (strstr((const char*) buff, "object") != 0) {
     65        } else if (strstr((const char*) _buff, "object") != 0) {
    6666            TRACE("VERSION 1");
    6767            version = 1;
    6868            break;
    69         } else if (strstr(buff, "record format") != 0) {
     69        } else if (strstr(_buff, "record format") != 0) {
    7070            TRACE("VERSION 2");
    7171            version = 2;
     
    7777        float dummy;
    7878
    79         sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4], &width, &height, &depth);
    80         getLine(stream);
    81         sscanf(buff, "%s%f%f%f", str[0], &(origin.x), &(origin.y), &(origin.z));
    82         getLine(stream);
    83         sscanf(buff, "%s%f%f%f", str[0], &(delta.x), &dummy, &dummy);
    84         getLine(stream);
    85         sscanf(buff, "%s%f%f%f", str[0], &dummy, &(delta.y), &dummy);
    86         getLine(stream);
    87         sscanf(buff, "%s%f%f%f", str[0], &dummy, &dummy, &(delta.z));
     79        sscanf(_buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4], &width, &height, &depth);
     80        getLine(stream);
     81        sscanf(_buff, "%s%f%f%f", str[0], &(origin.x), &(origin.y), &(origin.z));
     82        getLine(stream);
     83        sscanf(_buff, "%s%f%f%f", str[0], &(delta.x), &dummy, &dummy);
     84        getLine(stream);
     85        sscanf(_buff, "%s%f%f%f", str[0], &dummy, &(delta.y), &dummy);
     86        getLine(stream);
     87        sscanf(_buff, "%s%f%f%f", str[0], &dummy, &dummy, &(delta.z));
    8888        do {
    8989            getLine(stream);
    90         } while (strcmp(buff, "<\\HDR>") != 0);
     90        } while (strcmp(_buff, "<\\HDR>") != 0);
    9191
    9292        width = width / 4;
     
    111111        do {
    112112            getLine(stream);
    113             if ((pt = strstr(buff, "delta")) != 0) {
     113            if ((pt = strstr(_buff, "delta")) != 0) {
    114114                sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z));
    115115#ifdef _LOADER_DEBUG_
    116116                TRACE("delta : %f %f %f", delta.x, delta.y, delta.z);
    117117#endif
    118             } else if ((pt = strstr(buff, "datacount")) != 0) {
     118            } else if ((pt = strstr(_buff, "datacount")) != 0) {
    119119                sscanf(pt, "%s%d", str[0], &datacount);
    120120#ifdef _LOADER_DEBUG_
    121121                TRACE("datacount = %d", datacount);
    122122#endif
    123             } else if ((pt = strstr(buff, "datatype")) != 0) {
     123            } else if ((pt = strstr(_buff, "datatype")) != 0) {
    124124                sscanf(pt, "%s%s", str[0], str[1]);
    125125                if (strcmp(str[1], "double64")) {
    126126                }
    127             } else if ((pt = strstr(buff, "count")) != 0) {
     127            } else if ((pt = strstr(_buff, "count")) != 0) {
    128128                sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth);
    129129#ifdef _LOADER_DEBUG_
    130130                TRACE("width height depth %d %d %d", width, height, depth);
    131131#endif
    132             } else if ((pt = strstr(buff, "emptymark")) != 0) {
     132            } else if ((pt = strstr(_buff, "emptymark")) != 0) {
    133133                sscanf(pt, "%s%lf", str[0], &emptyvalue);
    134134#ifdef _LOADER_DEBUG_
    135135                TRACE("emptyvalue %lf", emptyvalue);
    136136#endif
    137             } else if ((pt = strstr(buff, "emprymark")) != 0) {
     137            } else if ((pt = strstr(_buff, "emprymark")) != 0) {
    138138                sscanf(pt, "%s%lf", str[0], &emptyvalue);
    139139#ifdef _LOADER_DEBUG_
     
    141141#endif
    142142            }
    143         } while (strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0);
     143        } while (strcmp(_buff, "<\\HDR>") != 0 && strcmp(_buff, "</HDR>") != 0);
    144144
    145145        data = malloc(width * height * depth * 8 * 4 * sizeof(double));
     
    363363        sin.get(ch);
    364364        if (ch == '\n') break;
    365         buff[index++] = ch;
     365        _buff[index++] = ch;
    366366        if (ch == '>') {
    367             if (buff[1] == '\\')
     367            if (_buff[1] == '\\')
    368368                break;
    369369        }
    370370    } while (!sin.eof());
    371371
    372     buff[index] = '\0';
    373 
    374 #ifdef _LOADER_DEBUG_
    375     TRACE("%s", buff);
     372    _buff[index] = '\0';
     373
     374#ifdef _LOADER_DEBUG_
     375    TRACE("%s", _buff);
    376376#endif
    377377}
    378378
    379379ZincBlendeVolume *
    380 ZincBlendeReconstructor::loadFromMemory(void *dataBlock)
     380ZincBlendeReconstructor::loadFromMemory(const void *dataBlock)
    381381{
    382382    ZincBlendeVolume *volume = NULL;
     
    386386    int version = 1;
    387387
    388     unsigned char *stream = (unsigned char *)dataBlock;
     388    const unsigned char *stream = (const unsigned char *)dataBlock;
    389389    char str[5][20];
    390390    do {
    391391        getLine(stream);
    392         if (buff[0] == '#') {
     392        if (_buff[0] == '#') {
    393393            continue;
    394         } else if (strstr((const char *)buff, "object") != 0) {
     394        } else if (strstr((const char *)_buff, "object") != 0) {
    395395            TRACE("VERSION 1");
    396396            version = 1;
    397397            break;
    398         } else if (strstr(buff, "record format") != 0) {
     398        } else if (strstr(_buff, "record format") != 0) {
    399399            TRACE("VERSION 2");
    400400            version = 2;
     
    406406        float dummy;
    407407
    408         sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4],&width, &height, &depth);
    409         getLine(stream);
    410         sscanf(buff, "%s%f%f%f", str[0], &(origin.x), &(origin.y), &(origin.z));
    411         getLine(stream);
    412         sscanf(buff, "%s%f%f%f", str[0], &(delta.x), &dummy, &dummy);
    413         getLine(stream);
    414         sscanf(buff, "%s%f%f%f", str[0], &dummy, &(delta.y), &dummy);
    415         getLine(stream);
    416         sscanf(buff, "%s%f%f%f", str[0], &dummy, &dummy, &(delta.z));
     408        sscanf(_buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4],&width, &height, &depth);
     409        getLine(stream);
     410        sscanf(_buff, "%s%f%f%f", str[0], &(origin.x), &(origin.y), &(origin.z));
     411        getLine(stream);
     412        sscanf(_buff, "%s%f%f%f", str[0], &(delta.x), &dummy, &dummy);
     413        getLine(stream);
     414        sscanf(_buff, "%s%f%f%f", str[0], &dummy, &(delta.y), &dummy);
     415        getLine(stream);
     416        sscanf(_buff, "%s%f%f%f", str[0], &dummy, &dummy, &(delta.z));
    417417        do {
    418418            getLine(stream);
    419         } while (strcmp(buff, "<\\HDR>") != 0);
     419        } while (strcmp(_buff, "<\\HDR>") != 0);
    420420
    421421        width = width / 4;
     
    435435        do {
    436436            getLine(stream);
    437             if ((pt = strstr(buff, "delta")) != 0) {   
     437            if ((pt = strstr(_buff, "delta")) != 0) {   
    438438                sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z));
    439439#ifdef _LOADER_DEBUG_
    440440                TRACE("delta : %f %f %f", delta.x, delta.y, delta.z);
    441441#endif
    442             } else if ((pt = strstr(buff, "datacount")) != 0) {
     442            } else if ((pt = strstr(_buff, "datacount")) != 0) {
    443443                sscanf(pt, "%s%d", str[0], &datacount);
    444444                TRACE("datacount = %d", datacount);
    445             } else if ((pt = strstr(buff, "datatype")) != 0) {
     445            } else if ((pt = strstr(_buff, "datatype")) != 0) {
    446446                sscanf(pt, "%s%s", str[0], str[1]);
    447447                if (strcmp(str[1], "double64")) {
    448448                }
    449             } else if ((pt = strstr(buff, "count")) != 0) {
     449            } else if ((pt = strstr(_buff, "count")) != 0) {
    450450                sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth);
    451451#ifdef _LOADER_DEBUG_
    452452                TRACE("width height depth %d %d %d", width, height, depth);
    453453#endif
    454             } else if ((pt = strstr(buff, "emptymark")) != 0) {
     454            } else if ((pt = strstr(_buff, "emptymark")) != 0) {
    455455                sscanf(pt, "%s%lf", str[0], &emptyvalue);
    456456#ifdef _LOADER_DEBUG_
    457457                TRACE("emptyvalue %lf", emptyvalue);
    458458#endif
    459             } else if ((pt = strstr(buff, "emprymark")) != 0) {
     459            } else if ((pt = strstr(_buff, "emprymark")) != 0) {
    460460                sscanf(pt, "%s%lf", str[0], &emptyvalue);
    461461#ifdef _LOADER_DEBUG_
     
    463463#endif
    464464            }
    465         } while (strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0);
     465        } while (strcmp(_buff, "<\\HDR>") != 0 && strcmp(_buff, "</HDR>") != 0);
    466466
    467467        if (datacount == -1) datacount = width * height * depth;
     
    478478}
    479479
    480 void ZincBlendeReconstructor::getLine(unsigned char*& stream)
     480void ZincBlendeReconstructor::getLine(const unsigned char*& stream)
    481481{
    482482    char ch;
     
    486486        ++stream;
    487487        if (ch == '\n') break;
    488         buff[index++] = ch;
     488        _buff[index++] = ch;
    489489        if (ch == '>') {
    490             if (buff[1] == '\\')
     490            if (_buff[1] == '\\')
    491491                break;
    492492        }
    493493    } while (1);
    494494
    495     buff[index] = '\0';
    496 
    497 #ifdef _LOADER_DEBUG_
    498     TRACE("%s", buff);
    499 #endif
    500 }
     495    _buff[index] = '\0';
     496
     497#ifdef _LOADER_DEBUG_
     498    TRACE("%s", _buff);
     499#endif
     500}
  • trunk/packages/vizservers/nanovis/ZincBlendeReconstructor.h

    r3611 r4063  
    3535    ZincBlendeVolume *loadFromStream(std::istream& stream);
    3636
    37     ZincBlendeVolume *loadFromMemory(void *dataBlock);
     37    ZincBlendeVolume *loadFromMemory(const void *dataBlock);
    3838
    3939    /**
     
    6767     */
    6868    void getLine(std::istream& stream);
    69     void getLine(unsigned char*& stream);
     69    void getLine(const unsigned char*& stream);
    7070
    71     char buff[255];
     71    char _buff[255];
    7272
    7373    /// A ZincBlendeReconstructor Singleton instance
  • trunk/packages/vizservers/nanovis/dxReader.cpp

    r3874 r4063  
    2929#include <string>
    3030
    31 #include <RpOutcome.h>
    3231#include <RpField1D.h>
    3332#include <RpFieldRect3D.h>
     
    5857 */
    5958Volume *
    60 nv::load_dx_volume_stream(Rappture::Outcome& result, const char *tag,
    61                           std::iostream& fin)
     59nv::load_dx_volume_stream(const char *tag, std::iostream& fin)
    6260{
    6361    TRACE("Enter tag:%s", tag);
     
    8381        fin.getline(line, sizeof(line) - 1);
    8482        if (fin.fail()) {
    85             result.error("error in data stream");
     83            ERROR("error in data stream");
    8684            return NULL;
    8785        }
     
    158156                    ftri.close();
    159157                } else {
    160                     result.error("triangularization failed");
     158                    ERROR("triangularization failed");
    161159                    return NULL;
    162160                }
     
    183181                }
    184182                if (count > 1) {
    185                     result.addError("don't know how to handle multiple non-zero"
    186                                     " delta values");
     183                    ERROR("don't know how to handle multiple non-zero"
     184                          " delta values");
    187185                    return NULL;
    188186                }
     
    190188                              &dummy, type, &npts) == 3) {
    191189                if (isrect && (npts != nx*ny*nz)) {
    192                     result.addError("inconsistent data: expected %d points"
    193                                     " but found %d points", nx*ny*nz, npts);
     190                    ERROR("inconsistent data: expected %d points"
     191                          " but found %d points", nx*ny*nz, npts);
    194192                    return NULL;
    195193                } else if (!isrect && (npts != nxy*nz)) {
    196                     result.addError("inconsistent data: expected %d points"
    197                                     " but found %d points", nxy*nz, npts);
     194                    ERROR("inconsistent data: expected %d points"
     195                          " but found %d points", nxy*nz, npts);
    198196                    return NULL;
    199197                }
     
    202200                              &dummy, type, &npts) == 3) {
    203201                if (npts != nx*ny*nz) {
    204                     result.addError("inconsistent data: expected %d points"
    205                                     " but found %d points", nx*ny*nz, npts);
     202                    ERROR("inconsistent data: expected %d points"
     203                          " but found %d points", nx*ny*nz, npts);
    206204                    return NULL;
    207205                }
     
    220218    // read data points
    221219    if (fin.eof()) {
    222         result.error("data not found in stream");
     220        ERROR("data not found in stream");
    223221        return NULL;
    224222    }
     
    247245            fin.getline(line,sizeof(line)-1);
    248246            if (fin.fail()) {
    249                 result.addError("error reading data points");
     247                ERROR("error reading data points");
    250248                return NULL;
    251249            }
     
    287285        // make sure that we read all of the expected points
    288286        if (nread != npts) {
    289             result.addError("inconsistent data: expected %d points"
    290                             " but found %d points", npts, nread);
     287            ERROR("inconsistent data: expected %d points"
     288                  " but found %d points", npts, nread);
    291289            return NULL;
    292290        }
     
    390388            fin >> dval;
    391389            if (fin.fail()) {
    392                 result.addError("after %d of %d points: can't read number",
    393                                 nread, npts);
     390                ERROR("after %d of %d points: can't read number",
     391                      nread, npts);
    394392                return NULL;
    395393            } else {
     
    407405        // make sure that we read all of the expected points
    408406        if (nread != npts) {
    409             result.addError("inconsistent data: expected %d points"
    410                             " but found %d points", npts, nread);
     407            ERROR("inconsistent data: expected %d points"
     408                  " but found %d points", npts, nread);
    411409            return NULL;
    412410        }
  • trunk/packages/vizservers/nanovis/dxReader.h

    r3611 r4063  
    99#include <iostream>
    1010
    11 namespace Rappture {
    12 class Outcome;
    13 }
    14 
    1511namespace nv {
    1612
     
    1814
    1915extern Volume *
    20 load_dx_volume_stream(Rappture::Outcome& status, const char *tag,
    21                       std::iostream& fin);
     16load_dx_volume_stream(const char *tag, std::iostream& fin);
    2217
    2318}
  • trunk/packages/vizservers/nanovis/nanovisServer.cpp

    r3630 r4063  
    284284#endif
    285285
     286/**
     287 * \brief Send a command with data payload
     288 *
     289 * data pointer is freed on completion of the response
     290 */
    286291void
    287 nv::sendDataToClient(const char *command, const char *data, size_t dlen)
     292nv::sendDataToClient(const char *command, char *data, size_t dlen)
    288293{
    289294#ifdef USE_THREADS
     
    301306    iov[0].iov_len = strlen(command);
    302307    // Data
    303     iov[1].iov_base = const_cast<char *>(data);
     308    iov[1].iov_base = data;
    304309    iov[1].iov_len = dlen;
    305310    if (writev(nv::g_fdOut, iov, numRecords) < 0) {
     
    307312    }
    308313    delete [] iov;
     314    free(data);
    309315#endif
    310316}
  • trunk/packages/vizservers/nanovis/nanovisServer.h

    r3614 r4063  
    5555    extern int writeToStatsFile(int f, const char *s, size_t length);
    5656#endif
    57     extern void sendDataToClient(const char *command, const char *data,
     57    extern void sendDataToClient(const char *command, char *data,
    5858                                 size_t dlen);
    5959}
  • trunk/packages/vizservers/nanovis/protocol-nanovis.txt

    r3630 r4063  
    110110          -transferfunction <name>
    111111          -volume <bool>
    112 <flowObj> data file <fileName> <numComponents>
    113           Load a data file.  fileName is path to file on server
    114112<flowObj> data follows <nbytes> <numComponents>
    115113          Send flow data.  Data bytes follow the newline after the command
Note: See TracChangeset for help on using the changeset viewer.