Changeset 3958


Ignore:
Timestamp:
Sep 24, 2013, 4:41:59 PM (11 years ago)
Author:
gah
Message:

sync with trunk

Location:
branches/blt4/packages
Files:
6 added
59 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/packages/Makefile.in

    r1018 r3958  
    1515VPATH           = $(srcdir)
    1616
    17 .PHONY: optimizer
     17.PHONY: all install clean distclean optimizer
    1818
    1919all:
  • branches/blt4/packages/optimizer/examples/app-qdot.tcl

    r1166 r3958  
    1010#  AUTHOR:  Ganesh Hegde, Purdue University
    1111#  Adapted from: simple.tcl
    12 #  Copyright (c) 2008  Purdue Research Foundation
     12#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1313#
    1414#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/examples/rosenbrock.tcl

    r899 r3958  
    1111# ======================================================================
    1212#  AUTHOR:  Michael McLennan, Purdue University
    13 #  Copyright (c) 2004-2007  Purdue Research Foundation
     13#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1414#
    1515#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/examples/simple.tcl

    r1201 r3958  
    1111# ======================================================================
    1212#  AUTHOR:  Michael McLennan, Purdue University
    13 #  Copyright (c) 2008  Purdue Research Foundation
     13#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1414#
    1515#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/examples/simplesingle.tcl

    r1201 r3958  
    1111# ======================================================================
    1212#  AUTHOR:  Michael McLennan, Purdue University
    13 #  Copyright (c) 2008  Purdue Research Foundation
     13#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1414#
    1515#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/examples/visualize.tcl

    r899 r3958  
    1010# ======================================================================
    1111#  AUTHOR:  Michael McLennan, Purdue University
    12 #  Copyright (c) 2008  Purdue Research Foundation
     12#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1313#
    1414#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/src/pgapack/Makefile.in

    r1052 r3958  
    1212PGAPACK         = @PGAPACK@
    1313
    14 .PHONY: pgapack
     14.PHONY: all install test clean distclean pgapack
    1515
    1616all: pgapack
  • branches/blt4/packages/optimizer/src/plugin_pgapack.c

    r1271 r3958  
    88 * ======================================================================
    99 *  AUTHOR:  Michael McLennan, Purdue University
    10  *  Copyright (c) 2008  Purdue Research Foundation
     10 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1111 *
    1212 *  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/src/rp_optimizer.c

    r1166 r3958  
    99 * ======================================================================
    1010 *  AUTHOR:  Michael McLennan, Purdue University
    11  *  Copyright (c) 2008  Purdue Research Foundation
     11 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1212 *
    1313 *  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/src/rp_optimizer.h

    r1166 r3958  
    99 * ======================================================================
    1010 *  AUTHOR:  Michael McLennan, Purdue University
    11  *  Copyright (c) 2008  Purdue Research Foundation
     11 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1212 *
    1313 *  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/src/rp_optimizer_tcl.c

    r1166 r3958  
    88 * ======================================================================
    99 *  AUTHOR:  Michael McLennan, Purdue University
    10  *  Copyright (c) 2008  Purdue Research Foundation
     10 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1111 *
    1212 *  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/src/rp_tcloptions.c

    r898 r3958  
    1010 * ======================================================================
    1111 *  AUTHOR:  Michael McLennan, Purdue University
    12  *  Copyright (c) 2008  Purdue Research Foundation
     12 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1313 *
    1414 *  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/src/rp_tcloptions.h

    r898 r3958  
    1010 * ======================================================================
    1111 *  AUTHOR:  Michael McLennan, Purdue University
    12  *  Copyright (c) 2008  Purdue Research Foundation
     12 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1313 *
    1414 *  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/src/tclconfig/mkindex.tcl

    r897 r3958  
    77# ======================================================================
    88#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2004-2005  Purdue Research Foundation
     9#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1010#
    1111#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/src/tclconfig/patchlevel.tcl

    r897 r3958  
    66# ======================================================================
    77#  AUTHOR:  Michael McLennan, Purdue University
    8 #  Copyright (c) 2004-2005  Purdue Research Foundation
     8#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    99#
    1010#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/src/test.c

    r809 r3958  
    88 * ======================================================================
    99 *  AUTHOR:  Michael McLennan, Purdue University
    10  *  Copyright (c) 2004-2007  Purdue Research Foundation
     10 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1111 *
    1212 *  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/tests/aaa.test

    r903 r3958  
    77# ======================================================================
    88#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2008  Purdue Research Foundation
     9#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1010#
    1111#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/tests/all.tcl

    r897 r3958  
    77# ======================================================================
    88#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2008  Purdue Research Foundation
     9#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1010#
    1111#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/optimizer/tests/pgapack.test

    r898 r3958  
    88# ======================================================================
    99#  AUTHOR:  Michael McLennan, Purdue University
    10 #  Copyright (c) 2008  Purdue Research Foundation
     10#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1111#
    1212#  See the file "license.terms" for information on usage and
  • branches/blt4/packages/vizservers/nanovis/BMPWriter.cpp

    r3892 r3958  
    99 */
    1010
     11#ifndef USE_THREADS
     12#include <unistd.h>
     13#endif
    1114#include <cstdlib>
    1215#include <cstring>
  • branches/blt4/packages/vizservers/nanovis/Camera.cpp

    r3892 r3958  
    286286    }
    287287
     288    TRACE("near: %g far: %g", _near, _far);
     289
    288290    // Extend the bounds a bit
    289291    _near = 0.99 * _near - (_far - _near) * 0.5;
    290292    _far  = 1.01 * _far  + (_far - _near) * 0.5;
     293
     294    TRACE("after extend: near: %g far: %g", _near, _far);
    291295
    292296    // Ensure near is closer than far
  • branches/blt4/packages/vizservers/nanovis/Camera.h

    r3892 r3958  
    5555    }
    5656
    57     float getDistance() const
     57    double getDistance() const
    5858    {
    5959        return vrmath::Vector3f(_focalPoint - _position).length();
  • branches/blt4/packages/vizservers/nanovis/Command.cpp

    r3892 r3958  
    5555#include "FlowCmd.h"
    5656#include "dxReader.h"
     57#ifdef USE_VTK
     58#include "VtkDataSetReader.h"
     59#endif
    5760#include "VtkReader.h"
    5861#include "BMPWriter.h"
     
    763766}
    764767
     768static int
     769CutplaneVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     770                  Tcl_Obj *const *objv)
     771{
     772    bool state;
     773    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     774        return TCL_ERROR;
     775    }
     776
     777    std::vector<Volume *> ivol;
     778    if (GetVolumes(interp, objc - 3, objv + 3, &ivol) != TCL_OK) {
     779        return TCL_ERROR;
     780    }
     781    std::vector<Volume *>::iterator iter;
     782    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
     783        (*iter)->cutplanesVisible(state);
     784    }
     785    return TCL_OK;
     786}
     787
    765788static Rappture::CmdSpec cutplaneOps[] = {
    766789    {"position", 1, CutplanePositionOp, 4, 0, "relval axis ?indices?",},
    767790    {"state",    1, CutplaneStateOp,    4, 0, "bool axis ?indices?",},
     791    {"visible",  1, CutplaneVisibleOp,  3, 0, "bool ?indices?",},
    768792};
    769793static int nCutplaneOps = NumCmdSpecs(cutplaneOps);
     
    12731297    } else if ((nBytes > 14) && (strncmp(bytes, "# vtk DataFile", 14) == 0)) {
    12741298        TRACE("VTK loading...");
    1275         std::stringstream fdata;
    1276         fdata.write(bytes, nBytes);
    12771299        if (nBytes <= 0) {
    12781300            ERROR("data buffer is empty");
     
    12801302        }
    12811303        Rappture::Outcome context;
     1304#ifdef USE_VTK
     1305        volume = load_vtk_volume_stream(context, tag, bytes, nBytes);
     1306#else
     1307        std::stringstream fdata;
     1308        fdata.write(bytes, nBytes);
    12821309        volume = load_vtk_volume_stream(context, tag, fdata);
     1310#endif
    12831311        if (volume == NULL) {
    12841312            Tcl_AppendResult(interp, context.remark(), (char*)NULL);
     
    12921320        }
    12931321        TRACE("DX loading...");
    1294         std::stringstream fdata;
    1295         fdata.write(bytes, nBytes);
    12961322        if (nBytes <= 0) {
    12971323            ERROR("data buffer is empty");
    12981324            abort();
    12991325        }
     1326        std::stringstream fdata;
     1327        fdata.write(bytes, nBytes);
    13001328        Rappture::Outcome context;
    13011329        volume = load_dx_volume_stream(context, tag, fdata);
  • branches/blt4/packages/vizservers/nanovis/Doxyfile.in

    r3892 r3958  
    599599# subdirectory from a directory tree whose root is specified with the INPUT tag.
    600600
    601 EXCLUDE                = @srcdir@/newmat11 @srcdir@/CircularQueue.h @srcdir@/ParticleEmitter.h @srcdir@/ParticleEmitter.cpp @srcdir@/ParticleSystem.h @srcdir@/ParticleSystem.cpp @srcdir@/ParticleSystemFactory.h @srcdir@/ParticleSystemFactory.cpp @srcdir@/BucketSort.h @srcdir@/BucketSort.cpp @srcdir@/PCASplit.h @srcdir@/PCASplit.cpp @srcdir@/PointSet.h @srcdir@/PointSet.cpp @srcdir@/PointSetRenderer.h @srcdir@/PointSetRenderer.cpp @srcdir@/PointShader.h @srcdir@/PointShader.cpp
     601EXCLUDE                = @srcdir@/bak @srcdir@/newmat11 @srcdir@/CircularQueue.h @srcdir@/ParticleEmitter.h @srcdir@/ParticleEmitter.cpp @srcdir@/ParticleSystem.h @srcdir@/ParticleSystem.cpp @srcdir@/ParticleSystemFactory.h @srcdir@/ParticleSystemFactory.cpp @srcdir@/BucketSort.h @srcdir@/BucketSort.cpp @srcdir@/PCASplit.h @srcdir@/PCASplit.cpp @srcdir@/PointSet.h @srcdir@/PointSet.cpp @srcdir@/PointSetRenderer.h @srcdir@/PointSetRenderer.cpp @srcdir@/PointShader.h @srcdir@/PointShader.cpp
    602602
    603603# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
  • branches/blt4/packages/vizservers/nanovis/Flow.cpp

    r3892 r3958  
    4141    _interp(interp),
    4242    _name(name),
    43     _data(NULL),
    4443    _volume(NULL)
    4544{
     
    5958    Rappture::FreeSwitches(_switches, &_sv, 0);
    6059
    61     if (_data != NULL) {
    62         delete _data;
    63     }
    6460    if (_volume != NULL) {
    6561        NanoVis::removeVolume(_volume);
     
    9187    if (isDataLoaded()) {
    9288        BBox bbox;
    93         data()->getBounds(bbox.min, bbox.max);
     89        _volume->getBounds(bbox.min, bbox.max);
    9490        allBounds.extend(bbox);
    9591    }
     
    115111    switch (position->axis) {
    116112    case AXIS_X: 
    117         return (position->value - _data->xMin()) /
    118             (_data->xMax() - _data->xMin());
     113        return (position->value - _volume->xAxis.min()) /
     114            (_volume->xAxis.max() - _volume->xAxis.min());
    119115    case AXIS_Y: 
    120         return (position->value - _data->yMin()) /
    121             (_data->yMax() - _data->yMin());
     116        return (position->value - _volume->yAxis.min()) /
     117            (_volume->yAxis.max() - _volume->yAxis.min());
    122118    case AXIS_Z: 
    123         return (position->value - _data->zMin()) /
    124             (_data->zMax() - _data->zMin());
     119        return (position->value - _volume->zAxis.min()) /
     120            (_volume->zAxis.max() - _volume->zAxis.min());
    125121    }
    126122    return 0.0;
     
    303299Flow::scaleVectorField()
    304300{
    305     float *vdata = getScaledVector();
    306     if (_volume != NULL) {
    307         TRACE("Updating existing volume: %s", _volume->name());
    308         _volume->setData(vdata, magMin, magMax, 0);
    309     } else {
    310         _volume = makeVolume(vdata);
    311         if (_volume == NULL) {
    312             return false;
    313         }
    314     }
    315     delete [] vdata;
     301    if (_volume == NULL) {
     302        ERROR("Called with NULL _volume");
     303        return false;
     304    }
     305
    316306    // FIXME: LIC and arrows should be per-flow
    317307    if (NanoVis::licRenderer != NULL) {
     
    346336
    347337float *
    348 Flow::getScaledVector()
    349 {
    350     assert(_data->nComponents() == 3);
    351     size_t n = _data->nValues() / _data->nComponents() * 4;
     338Flow::getScaledVector(Rappture::Unirect3d *unirect)
     339{
     340    assert(unirect->nComponents() == 3);
     341    size_t n = unirect->nValues() / unirect->nComponents() * 4;
    352342    float *data = new float[n];
    353343    memset(data, 0, sizeof(float) * n);
    354344    float *dest = data;
    355     const float *values = _data->values();
    356     for (size_t iz = 0; iz < _data->zNum(); iz++) {
    357         for (size_t iy = 0; iy < _data->yNum(); iy++) {
    358             for (size_t ix = 0; ix < _data->xNum(); ix++) {
     345    const float *values = unirect->values();
     346    for (size_t iz = 0; iz < unirect->zNum(); iz++) {
     347        for (size_t iy = 0; iy < unirect->yNum(); iy++) {
     348            for (size_t ix = 0; ix < unirect->xNum(); ix++) {
    359349                double vx, vy, vz, vm;
    360350                vx = values[0];
     
    362352                vz = values[2];
    363353                vm = sqrt(vx*vx + vy*vy + vz*vz);
    364                 dest[0] = vm / magMax;
    365                 dest[1] = vx /(2.0 * magMax) + 0.5;
    366                 dest[2] = vy /(2.0 * magMax) + 0.5;
    367                 dest[3] = vz /(2.0 * magMax) + 0.5;
     354                dest[0] = vm / unirect->magMax();
     355                dest[1] = vx /(2.0 * unirect->magMax()) + 0.5;
     356                dest[2] = vy /(2.0 * unirect->magMax()) + 0.5;
     357                dest[3] = vz /(2.0 * unirect->magMax()) + 0.5;
    368358                values += 3;
    369359                dest += 4;
     
    375365
    376366Volume *
    377 Flow::makeVolume(float *data)
     367Flow::makeVolume(Rappture::Unirect3d *unirect, float *data)
    378368{
    379369    Volume *volume =
    380370        NanoVis::loadVolume(_name.c_str(),
    381                             _data->xNum(),
    382                             _data->yNum(),
    383                             _data->zNum(),
     371                            unirect->xNum(),
     372                            unirect->yNum(),
     373                            unirect->zNum(),
    384374                            4, data,
    385                             magMin, magMax, 0);
    386     volume->xAxis.setRange(_data->xMin(), _data->xMax());
    387     volume->yAxis.setRange(_data->yMin(), _data->yMax());
    388     volume->zAxis.setRange(_data->zMin(), _data->zMax());
    389 
    390     TRACE("mag=%g %g", magMin, magMax);
    391 
    392     volume->disableCutplane(0);
    393     volume->disableCutplane(1);
    394     volume->disableCutplane(2);
     375                            unirect->magMin(),
     376                            unirect->magMax(),
     377                            0);
     378    volume->xAxis.setRange(unirect->xMin(), unirect->xMax());
     379    volume->yAxis.setRange(unirect->yMin(), unirect->yMax());
     380    volume->zAxis.setRange(unirect->zMin(), unirect->zMax());
     381
     382    TRACE("mag=%g %g", unirect->magMin(), unirect->magMax());
     383
     384    return volume;
     385}
     386
     387void
     388Flow::initVolume()
     389{
     390    _volume->disableCutplane(0);
     391    _volume->disableCutplane(1);
     392    _volume->disableCutplane(2);
    395393
    396394    /* Initialize the volume with the previously configured values. */
    397     volume->transferFunction(_sv.transferFunction);
    398     volume->dataEnabled(_sv.showVolume);
    399     volume->twoSidedLighting(_sv.twoSidedLighting);
    400     volume->outline(_sv.showOutline);
    401     volume->opacityScale(_sv.opacity);
    402     volume->ambient(_sv.ambient);
    403     volume->diffuse(_sv.diffuse);
    404     volume->specularLevel(_sv.specular);
    405     volume->specularExponent(_sv.specularExp);
     395    _volume->transferFunction(_sv.transferFunction);
     396    _volume->dataEnabled(_sv.showVolume);
     397    _volume->twoSidedLighting(_sv.twoSidedLighting);
     398    _volume->outline(_sv.showOutline);
     399    _volume->opacityScale(_sv.opacity);
     400    _volume->ambient(_sv.ambient);
     401    _volume->diffuse(_sv.diffuse);
     402    _volume->specularLevel(_sv.specular);
     403    _volume->specularExponent(_sv.specularExp);
    406404
    407405    Volume::updatePending = true;
    408     return volume;
    409 }
     406}
  • branches/blt4/packages/vizservers/nanovis/Flow.h

    r3892 r3958  
    8383    void getBoxNames(std::vector<std::string>& names);
    8484
    85     bool scaleVectorField();
    86 
    8785    bool visible()
    8886    {
     
    9795    bool isDataLoaded()
    9896    {
    99         return (_data != NULL);
    100     }
    101 
    102     Rappture::Unirect3d *data()
    103     {
    104         return _data;
    105     }
    106 
    107     void data(Rappture::Unirect3d *data)
    108     {
    109         if (_data != NULL) {
    110             delete _data;
    111         }
    112         _data = data;
     97        return (_volume != NULL);
     98    }
     99
     100    void getVectorRange(double range[])
     101    {
     102        range[0] = _volume->wAxis.min();
     103        range[1] = _volume->wAxis.max();
     104    }
     105
     106    void data(Rappture::Unirect3d *unirect)
     107    {
     108        float *vdata = getScaledVector(unirect);
     109        _volume = makeVolume(unirect, vdata);
     110        delete [] vdata;
     111        delete unirect;
     112        initVolume();
     113        scaleVectorField();
     114    }
     115
     116    void data(Volume *volume)
     117    {
     118        _volume = volume;
     119        initVolume();
     120        scaleVectorField();
    113121    }
    114122
     
    198206    typedef std::tr1::unordered_map<BoxId, FlowBox *> BoxHashmap;
    199207
    200     float *getScaledVector();
    201 
    202     Volume *makeVolume(float *data);
     208    void initVolume();
     209
     210    bool scaleVectorField();
     211
     212    float *getScaledVector(Rappture::Unirect3d *unirect);
     213
     214    Volume *makeVolume(Rappture::Unirect3d *unirect, float *data);
    203215
    204216    void renderBoxes();
     
    219231
    220232    /**
    221      * Uniform rectangular data
    222      * representing the mesh and vector
    223      * field values.  These values are
    224      * kept to regenerate the volume
    225      * associated with the flow. */
    226     Rappture::Unirect3d *_data;
    227 
    228     /**
    229233     * The volume associated with the
    230234     * flow.  This isn't the same thing as
  • branches/blt4/packages/vizservers/nanovis/FlowCmd.cpp

    r3892 r3958  
    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);
    263270        if (u2dPtr->parseBuffer(interp, buf) != TCL_OK) {
     271            delete unirect;
    264272            delete u2dPtr;
    265273            return TCL_ERROR;
    266274        }
    267         dataPtr->convert(u2dPtr);
     275        unirect->convert(u2dPtr);
    268276        delete u2dPtr;
    269 #if 0
    270277    } else if ((length > 14) && (strncmp(bytes, "# vtk DataFile", 14) == 0)) {
    271278        TRACE("VTK loading...");
     
    277284        }
    278285        Rappture::Outcome context;
    279         volume = load_vtk_volume_stream(context, tag, fdata);
     286#ifdef USE_VTK
     287        volume = load_vtk_volume_stream(context, flow->name(), bytes, length);
     288#else
     289        std::stringstream fdata;
     290        fdata.write(bytes, nBytes);
     291        volume = load_vtk_volume_stream(context, flow->name(), fdata);
     292#endif
    280293        if (volume == NULL) {
    281294            Tcl_AppendResult(interp, context.remark(), (char*)NULL);
    282295            return TCL_ERROR;
    283296        }
    284 #endif
    285297    } else {
    286298        TRACE("header is %.14s", buf.bytes());
    287         if (!dataPtr->importDx(result, nComponents, length, bytes)) {
     299        unirect = new Rappture::Unirect3d(nComponents);
     300        if (!unirect->importDx(result, nComponents, length, bytes)) {
    288301            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    289             delete dataPtr;
    290             return TCL_ERROR;
    291         }
    292     }
    293     if (dataPtr->nValues() == 0) {
    294         delete dataPtr;
     302            delete unirect;
     303            return TCL_ERROR;
     304        }
     305    }
     306    if (unirect != NULL && unirect->nValues() == 0) {
     307        delete unirect;
    295308        Tcl_AppendResult(interp, "no data found in stream", (char *)NULL);
    296309        return TCL_ERROR;
    297310    }
    298     TRACE("nx = %d ny = %d nz = %d",
    299           dataPtr->xNum(), dataPtr->yNum(), dataPtr->zNum());
    300     TRACE("x0 = %lg y0 = %lg z0 = %lg",
    301           dataPtr->xMin(), dataPtr->yMin(), dataPtr->zMin());
    302     TRACE("lx = %lg ly = %lg lz = %lg",
    303           dataPtr->xMax() - dataPtr->xMin(),
    304           dataPtr->yMax() - dataPtr->yMin(),
    305           dataPtr->zMax() - dataPtr->zMin());
    306     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);
    310     TRACE("magMin = %lg magMax = %lg",
    311           dataPtr->magMin(), dataPtr->magMax());
    312     flow->data(dataPtr);
     311    if (unirect != NULL) {
     312        TRACE("nx = %d ny = %d nz = %d",
     313              unirect->xNum(), unirect->yNum(), unirect->zNum());
     314        TRACE("x0 = %lg y0 = %lg z0 = %lg",
     315              unirect->xMin(), unirect->yMin(), unirect->zMin());
     316        TRACE("lx = %lg ly = %lg lz = %lg",
     317              unirect->xMax() - unirect->xMin(),
     318              unirect->yMax() - unirect->yMin(),
     319              unirect->zMax() - unirect->zMin());
     320        TRACE("dx = %lg dy = %lg dz = %lg",
     321              unirect->xNum() > 1 ? (unirect->xMax() - unirect->xMin())/(unirect->xNum()-1) : 0,
     322              unirect->yNum() > 1 ? (unirect->yMax() - unirect->yMin())/(unirect->yNum()-1) : 0,
     323              unirect->zNum() > 1 ? (unirect->zMax() - unirect->zMin())/(unirect->zNum()-1) : 0);
     324        TRACE("magMin = %lg magMax = %lg",
     325              unirect->magMin(), unirect->magMax());
     326
     327        flow->data(unirect);
     328    } else {
     329        flow->data(volume);
     330    }
     331    double range[2];
     332    flow->getVectorRange(range);
    313333    {
    314334        char info[1024];
    315335        int length =
    316336            sprintf(info, "nv>data tag %s min %g max %g\n",
    317                     flow->name(), dataPtr->magMin(), dataPtr->magMax());
     337                    flow->name(), range[0], range[1]);
    318338#ifdef USE_THREADS
    319339        queueResponse(info, (size_t)length, Response::VOLATILE);
     
    840860    }
    841861    if (Flow::updatePending) {
    842         NanoVis::mapFlows();
     862        NanoVis::setFlowRanges();
    843863    }
    844864    NanoVis::renderLegend(tf, Flow::magMin, Flow::magMax, w, h, label);
     
    965985    NanoVis::resetFlows();
    966986    if (Flow::updatePending) {
    967         NanoVis::mapFlows();
     987        NanoVis::setFlowRanges();
    968988    }
    969989    for (int i = 0; i < nSteps; i++) {
     
    9971017    assert(NanoVis::licRenderer != NULL);
    9981018    if (Flow::updatePending) {
    999         NanoVis::mapFlows();
     1019        NanoVis::setFlowRanges();
    10001020    }
    10011021    NanoVis::licRenderer->convolve();
  • branches/blt4/packages/vizservers/nanovis/Grid.cpp

    r3892 r3958  
    2020
    2121#define NUMDIGITS       6
    22 #define GRID_TICK       0.05
     22#define TICK_LENGTH     0.05
     23#define LABEL_OFFSET    0.06
     24#define TITLE_OFFSET    0.2
    2325
    2426Grid::Grid() :
     
    5557    glEnable(GL_DEPTH_TEST);
    5658    glDisable(GL_TEXTURE_2D);
     59#ifdef notdef
    5760    glEnable(GL_BLEND);
    58 #ifdef notdef
    5961    glEnable(GL_LINE_SMOOTH);
     62#else
     63    glDisable(GL_BLEND);
    6064#endif
    6165
     
    7377    {
    7478        glVertex3f(0.0f, 0.0f, 0.0f);
    75         glVertex3f(1.0f + GRID_TICK, 0.0f, 0.0f);
     79        glVertex3f(1.0f + TICK_LENGTH/xAxis.range(), 0.0f, 0.0f);
    7680        glVertex3f(0.0f, 0.0f, 0.0f);
    77         glVertex3f(0.0f, 1.0f + GRID_TICK, 0.0f);
     81        glVertex3f(0.0f, 1.0f + TICK_LENGTH/yAxis.range(), 0.0f);
    7882        glVertex3f(0.0f, 0.0f, 0.0f);
    79         glVertex3f(0.0f, 0.0f, 1.0f + GRID_TICK);
     83        glVertex3f(0.0f, 0.0f, 1.0f + TICK_LENGTH/zAxis.range());
    8084    }
    8185    glEnd();
     
    96100            glVertex3f(x, 1.0f, 0.0f);
    97101            glVertex3f(x, 0.0f, 0.0f);
    98             glVertex3f(x, 0.0f, 1.0f + GRID_TICK);
     102            glVertex3f(x, 0.0f, 1.0f + TICK_LENGTH/zAxis.range());
    99103        }
    100104        for (result = yAxis.firstMajor(iter); result; result = iter.next()) {
     
    102106            y = yAxis.map(iter.getValue());
    103107            glVertex3f(0.0f, y, 0.0f);
    104             glVertex3f(1.0f + GRID_TICK, y, 0.0f);
     108            glVertex3f(1.0f + TICK_LENGTH/xAxis.range(), y, 0.0f);
    105109            glVertex3f(0.0f, y, 0.0f);
    106110            glVertex3f(0.0f, y, 1.0f);
     
    112116            glVertex3f(0.0f, 1.0f, z);
    113117            glVertex3f(0.0f, 0.0f, z);
    114             glVertex3f(1.0f + GRID_TICK, 0.0f, z);
     118            glVertex3f(1.0f + TICK_LENGTH/xAxis.range(), 0.0f, z);
    115119        }
    116120    }
     
    163167        glGetDoublev(GL_PROJECTION_MATRIX, prjm);
    164168        glGetIntegerv(GL_VIEWPORT, viewport);
    165        
     169
    166170        _font->begin();
    167         if (gluProject(1.2, 0.0, 0.0, mv, prjm, viewport, &wx, &wy, &wz)) {
     171        if (gluProject(1.0 + TITLE_OFFSET/xAxis.range(), 0.0, 0.0, mv, prjm, viewport, &wx, &wy, &wz) &&
     172            wz >= 0.0 && wz <= 1.0) {
    168173            glLoadIdentity();
    169174            glTranslatef((int) wx, viewport[3] - (int) wy, 0);
     
    175180        }
    176181       
    177         if (gluProject(0.0, 1.2, 0.0, mv, prjm, viewport, &wx, &wy, &wz)) {
     182        if (gluProject(0.0, 1.0 + TITLE_OFFSET/yAxis.range(), 0.0, mv, prjm, viewport, &wx, &wy, &wz) &&
     183            wz >= 0.0 && wz <= 1.0) {
    178184            glLoadIdentity();
    179185            glTranslatef((int) wx, viewport[3] - (int)wy, 0);
     
    185191        }
    186192       
    187         if (gluProject(0.0, 0.0, 1.2, mv, prjm, viewport, &wx, &wy, &wz)) {
     193        if (gluProject(0.0, 0.0, 1.0 + TITLE_OFFSET/zAxis.range(), mv, prjm, viewport, &wx, &wy, &wz) &&
     194            wz >= 0.0 && wz <= 1.0) {
    188195            glLoadIdentity();
    189196            glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f);
     
    200207            float x;
    201208            x = xAxis.map(iter.getValue());
    202             if (gluProject(x, 0.0f, 1.06f, mv, prjm, viewport, &wx, &wy, &wz)) {
     209            if (gluProject(x, 0.0f, 1.0 + LABEL_OFFSET/zAxis.range(), mv, prjm, viewport, &wx, &wy, &wz) &&
     210                wz >= 0.0 && wz <= 1.0) {
    203211                char buff[20];
    204212                glLoadIdentity();
     
    211219            float y;
    212220            y = yAxis.map(iter.getValue());
    213             if (gluProject(1.06f, y, 0.0f, mv, prjm, viewport, &wx, &wy, &wz)) {
     221            if (gluProject(1.0 + LABEL_OFFSET/xAxis.range(), y, 0.0f, mv, prjm, viewport, &wx, &wy, &wz) &&
     222                wz >= 0.0 && wz <= 1.0) {
    214223                char buff[20];
    215224                glLoadIdentity();
     
    219228            }
    220229        }
    221         for (result = zAxis.firstMajor(iter); result; result = iter.next()) {
     230        for (result = zAxis.firstMajor(iter) + LABEL_OFFSET/xAxis.range(); result; result = iter.next()) {
    222231            float z;
    223232            z = zAxis.map(iter.getValue());
    224             if (gluProject(1.06f, 0.0f, z, mv, prjm, viewport, &wx, &wy, &wz)) {
     233            if (gluProject(1.0 + LABEL_OFFSET/xAxis.range(), 0.0f, z, mv, prjm, viewport, &wx, &wy, &wz) &&
     234                wz >= 0.0 && wz <= 1.0) {
    225235                char buff[20];
    226236                glLoadIdentity();
  • branches/blt4/packages/vizservers/nanovis/Makefile.in

    r3892 r3958  
    33USE_POINTSET_RENDERER   = #yes
    44USE_PARTICLE_SYSTEM     = #yes
     5USE_VTK                 = yes
    56
    67SHELL = /bin/sh
     
    5354VRMATH_LIB_SPEC = $(VRMATH_LIB)
    5455
     56VTK_LIB_DIR     = @VTK_LIB_DIR@
     57VTK_INC_SPEC    = @VTK_INC_SPEC@
     58VTK_LIB_SPEC    = \
     59                -lvtkIOCore-6.0 \
     60                -lvtkIOLegacy-6.0 \
     61                -lvtkFiltersCore-6.0 \
     62                -lvtkImagingHybrid-6.0 \
     63                -lvtkImagingCore-6.0 \
     64                -lvtkCommonCore-6.0 \
     65                -lvtkCommonDataModel-6.0 \
     66                -lvtkCommonExecutionModel-6.0  \
     67                -lvtkCommonMisc-6.0  \
     68                -lvtkCommonSystem-6.0 \
     69                -lvtkCommonTransforms-6.0 \
     70                -lvtkCommonMath-6.0
     71
    5572EXTRA_LIBS      = -lm -lpthread
    5673RP_DIR          =  @RP_DIR@
     
    7390                $(UTIL_LIB_SPEC) \
    7491                $(VRMATH_LIB_SPEC) \
     92                $(VTK_LIB_SPEC) \
    7593                $(TCL_LIB_SPEC) \
    7694                $(CG_LIB_SPEC) \
     
    85103                $(MAT_INC_SPEC) \
    86104                $(VRMATH_INC_SPEC) \
     105                $(VTK_INC_SPEC) \
    87106                $(TCL_INC_SPEC) \
    88107                $(CG_INC_SPEC) \
     
    103122ifdef USE_POINTSET_RENDERER
    104123DEFINES         += -DUSE_POINTSET_RENDERER
     124endif
     125ifdef USE_VTK
     126DEFINES         += -DUSE_VTK
    105127endif
    106128CXX_SWITCHES    = $(CFLAGS) $(EXTRA_CFLAGS) $(DEFINES) $(INCLUDES)
     
    204226endif
    205227
     228ifdef USE_VTK
     229OBJS +=         DataSetResample.o \
     230                VtkDataSetReader.o
     231endif
     232
    206233.PHONY: all install install-resources install-shaders install-nanovis docs clean-docs clean distclean graphics imgloaders newmat11 util vrmath
    207234
     
    287314ContourLineFilter.o: ContourLineFilter.cpp ContourLineFilter.h
    288315ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h $(VRMATH_DIR)/include/vrmath/Vector4f.h $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h Plane.h
     316DataSetResample.o: DataSetResample.cpp DataSetResample.h
    289317Flow.o: Flow.cpp Flow.h FlowCmd.h FlowTypes.h FlowBox.h FlowParticles.h LIC.h VelocityArrowsSlice.h Switch.h Unirect.h Volume.h TransferFunction.h Trace.h
    290318FlowBox.o: FlowBox.cpp FlowBox.h FlowTypes.h Switch.h Trace.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h $(VRMATH_DIR)/include/vrmath/Vector4f.h $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h
     
    293321GradientFilter.o: GradientFilter.cpp GradientFilter.h
    294322Grid.o: Grid.cpp Grid.h Axis.h Chain.h $(UTIL_DIR)/Fonts.h $(VRMATH_DIR)/include/vrmath/Color4f.h $(VRMATH_DIR)/include/vrmath/Vector4f.h
    295 HeightMap.o: HeightMap.cpp HeightMap.h
    296 LIC.o: LIC.cpp LIC.h
     323HeightMap.o: HeightMap.cpp HeightMap.h Shader.h
     324LIC.o: LIC.cpp LIC.h Shader.h
    297325OrientationIndicator.o: OrientationIndicator.cpp OrientationIndicator.h
    298326ParticleAdvectionShader.o: ParticleAdvectionShader.cpp ParticleAdvectionShader.h Shader.h
     
    312340RegularVolumeShader.o: RegularVolumeShader.cpp RegularVolumeShader.h VolumeShader.h Shader.h
    313341RenderVertexArray.o: RenderVertexArray.cpp RenderVertexArray.h
    314 Shader.o: Shader.cpp Shader.h
     342Shader.o: Shader.cpp Shader.h config.h
    315343ShaderGL.o: ShaderGL.cpp ShaderGL.h
    316344StdVertexShader.o: StdVertexShader.cpp StdVertexShader.h Shader.h
     
    327355VolumeRenderer.o: VolumeRenderer.cpp VolumeRenderer.h ConvexPolygon.h Volume.h nanovis.h Trace.h Plane.h StdVertexShader.h Shader.h
    328356VolumeShader.o: VolumeShader.cpp VolumeShader.h Shader.h
    329 VtkReader.o: VtkReader.h Trace.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h ReaderCommon.h nanovis.h
     357VtkDataSetReader.o: VtkDataSetReader.cpp VtkDataSetReader.h DataSetResample.h $(VRMATH_DIR)/include/vrmath/Vector3f.h ReaderCommon.h Trace.h Volume.h nanovis.h config.h
     358VtkReader.o: VtkReader.h Trace.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h ReaderCommon.h nanovis.h config.h
    330359ZincBlendeReconstructor.o: ZincBlendeReconstructor.cpp ZincBlendeReconstructor.h ZincBlendeVolume.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h
    331360ZincBlendeVolume.o: ZincBlendeVolume.cpp ZincBlendeVolume.h config.h define.h
  • branches/blt4/packages/vizservers/nanovis/ReaderCommon.cpp

    r3892 r3958  
    6464
    6565/**
     66 * \brief Normalize data to [0,1] based on vmin,vmax range
     67 *
     68 * Data outside of given range is clamped, and NaNs are set to
     69 * -1 in the output
     70 *
     71 * \param data Float array of unnormalized data, will be normalized on return
     72 * \param count Number of elts in array
     73 * \param stride Stride between values in data array
     74 * \param vmin Minimum value in data array
     75 * \param vmax Maximum value in data array
     76 */
     77void
     78nv::normalizeVector(float *data, int count, double vmin, double vmax)
     79{
     80    for (int p = 0; p < count; p++) {
     81        int i = p * 4;
     82        data[i  ] = data[i]/vmax;
     83        data[i+1] = data[i+1]/(2.0 * vmax) + 0.5;
     84        data[i+2] = data[i+2]/(2.0 * vmax) + 0.5;
     85        data[i+3] = data[i+3]/(2.0 * vmax) + 0.5;
     86    }
     87}
     88
     89/**
    6690 * \brief Compute Sobel filtered gradients for a 3D volume
    6791 *
  • branches/blt4/packages/vizservers/nanovis/ReaderCommon.h

    r3892 r3958  
    1515normalizeScalar(float *data, int count, int stride, double min, double max);
    1616
     17extern void
     18normalizeVector(float *data, int count, double min, double max);
     19
    1720extern float *
    1821computeGradient(float *data,
  • branches/blt4/packages/vizservers/nanovis/Shader.cpp

    r3892 r3958  
    1212#include <util/FilePath.h>
    1313
     14#include "config.h"
    1415#include "Shader.h"
    1516#include "Trace.h"
     
    1819using namespace nv::util;
    1920
     21/**
     22 * These correspond to NV_vertex_program3 and NV_fragment_program2:
     23 * CG_PROFILE_VP40
     24 * CG_PROFILE_FP40
     25 *
     26 * These correspond to ARB_vertex_program and ARB_fragment_program:
     27 * CG_PROFILE_ARBVP1
     28 * CG_PROFILE_ARBFP1
     29 *
     30 * Generic GLSL targets:
     31 * CG_PROFILE_GLSLV
     32 * CG_PROFILE_GLSLF
     33 */
     34#ifdef USE_ARB_PROGRAMS
     35CGprofile Shader::_defaultVertexProfile = CG_PROFILE_ARBVP1;
     36CGprofile Shader::_defaultFragmentProfile = CG_PROFILE_ARBFP1;
     37#else
    2038CGprofile Shader::_defaultVertexProfile = CG_PROFILE_VP40;
    2139CGprofile Shader::_defaultFragmentProfile = CG_PROFILE_FP40;
     40#endif
    2241CGcontext Shader::_cgContext = NULL;
    2342
  • branches/blt4/packages/vizservers/nanovis/Shader.h

    r3892 r3958  
    4949    void loadFragmentProgram(const char *fileName);
    5050
     51    bool isVertexProgramLoaded()
     52    {
     53        return (getVP() == NULL);
     54    }
     55
     56    bool isFragmentProgramLoaded()
     57    {
     58        return (getFP() == NULL);
     59    }
     60
    5161    void setVPParameter1f(const char *name, float val)
    5262    {
     
    284294    void resetPrograms();
    285295
    286 
    287296    CGprogram getVP()
    288297    {
  • branches/blt4/packages/vizservers/nanovis/Unirect.cpp

    r3892 r3958  
    88
    99#include <tcl.h>
    10 
    11 #include <RpField1D.h>
    12 #include <RpFieldRect3D.h>
    1310
    1411#include "Command.h"
     
    634631}
    635632
    636 bool
    637 Rappture::Unirect3d::resample(Rappture::Outcome &result, size_t nSamples)
    638 {
    639     Rappture::Mesh1D xgrid(_xMin, _xMax, _xNum);
    640     Rappture::Mesh1D ygrid(_yMin, _yMax, _yNum);
    641     Rappture::Mesh1D zgrid(_zMin, _zMax, _zNum);
    642     Rappture::FieldRect3D xfield(xgrid, ygrid, zgrid);
    643     Rappture::FieldRect3D yfield(xgrid, ygrid, zgrid);
    644     Rappture::FieldRect3D zfield(xgrid, ygrid, zgrid);
    645 
    646     size_t i, j;
    647     for (i = 0, j = 0; i < _nValues; i += _nComponents, j++) {
    648         double vx, vy, vz;
    649 
    650         vx = _values[i];
    651         vy = _values[i+1];
    652         vz = _values[i+2];
    653        
    654         xfield.define(j, vx);
    655         yfield.define(j, vy);
    656         zfield.define(j, vz);
    657     }
    658     // Figure out a good mesh spacing
    659     double dx, dy, dz;
    660     double lx, ly, lz;
    661     lx = xfield.rangeMax(Rappture::xaxis) - xfield.rangeMin(Rappture::xaxis);
    662     ly = xfield.rangeMax(Rappture::yaxis) - xfield.rangeMin(Rappture::yaxis);
    663     lz = xfield.rangeMax(Rappture::zaxis) - xfield.rangeMin(Rappture::zaxis);
    664 
    665     double dmin;
    666     dmin = pow((lx*ly*lz)/((nSamples-1)*(nSamples-1)*(nSamples-1)), 0.333);
    667 
    668     /* Recompute new number of points for each axis. */
    669     _xNum = (size_t)ceil(lx/dmin);
    670     _yNum = (size_t)ceil(ly/dmin);
    671     _zNum = (size_t)ceil(lz/dmin);
    672 
    673 #ifndef HAVE_NPOT_TEXTURES
    674     // must be an even power of 2 for older cards
    675     _xNum = (int)pow(2.0, ceil(log10((double)_xNum)/log10(2.0)));
    676     _yNum = (int)pow(2.0, ceil(log10((double)_yNum)/log10(2.0)));
    677     _zNum = (int)pow(2.0, ceil(log10((double)_zNum)/log10(2.0)));
    678 #endif
    679 
    680     dx = lx/(double)(_xNum-1);
    681     dy = ly/(double)(_yNum-1);
    682     dz = lz/(double)(_zNum-1);
    683 
    684     TRACE("lx:%lf ly:%lf lz:%lf dmin:%lf dx:%lf dy:%lf dz:%lf", lx, ly, lz, dmin, dx, dy, dz);
    685 
    686     size_t n = _nComponents * _xNum * _yNum * _zNum;
    687     _values = (float *)realloc(_values, sizeof(float) * n);
    688     memset(_values, 0, sizeof(float) * n);
    689 
    690     // Generate the uniformly sampled rectangle that we need for a volume
    691     float *destPtr = _values;
    692     for (size_t i = 0; i < _zNum; i++) {
    693         double z;
    694 
    695         z = _zMin + (i * dx);
    696         for (size_t j = 0; j < _yNum; j++) {
    697             double y;
    698                
    699             y = _yMin + (j * dy);
    700             for (size_t k = 0; k < _xNum; k++) {
    701                 double x;
    702 
    703                 x = _xMin + (k * dz);
    704                 destPtr[0] = xfield.value(x, y, z);
    705                 destPtr[1] = yfield.value(x, y, z);
    706                 destPtr[2] = zfield.value(x, y, z);
    707             }
    708         }
    709     }
    710     _nValues = _xNum * _yNum * _zNum * _nComponents;
    711     return true;
    712 }
    713 
    714633void
    715634Rappture::Unirect3d::getVectorRange()
  • branches/blt4/packages/vizservers/nanovis/Unirect.h

    r3892 r3958  
    229229    bool convert(Unirect2d *dataPtr);
    230230
    231     bool resample(Rappture::Outcome &context, size_t nSamples = 30);
    232 
    233231    bool isInitialized()
    234232    {
     
    247245    float _zValueMin, _zValueMax;
    248246    double _magMin, _magMax;                /* Range of magnitudes of vector
    249                                          * data. */
     247                                             * data. */
    250248    char *_xUnits;
    251249    char *_yUnits;
  • branches/blt4/packages/vizservers/nanovis/VelocityArrowsSlice.cpp

    r3892 r3958  
    6565    _queryVelocityFP.loadFragmentProgram("queryvelocity.cg");
    6666
    67     _particleShader.loadVertexProgram("velocityslicevp.cg");
    68     _particleShader.loadFragmentProgram("velocityslicefp.cg");
     67    // Delay loading of shaders only required for glyph style rendering
     68    if (_renderMode == GLYPHS) {
     69        _particleShader.loadVertexProgram("velocityslicevp.cg");
     70        _particleShader.loadFragmentProgram("velocityslicefp.cg");
     71    }
    6972
    7073    createRenderTarget();
     
    362365                    continue;
    363366                }
    364                 if (length > 1.0e-6) {
     367                if (length > 0.0) {
    365368                    Vector3f vnorm = vel.normalize();
    366369                    Vector3f rotationAxis = refVec.cross(vnorm);
     
    414417        glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
    415418
     419        // FIXME: This vertex shader won't compile with ARB_vertex_program,
     420        // so it should use GLSL
     421        if (!_particleShader.isVertexProgramLoaded()) {
     422            _particleShader.loadVertexProgram("velocityslicevp.cg");
     423        }
     424        if (!_particleShader.isFragmentProgramLoaded()) {
     425            _particleShader.loadFragmentProgram("velocityslicefp.cg");
     426        }
     427
    416428        _particleShader.bind();
    417429        _particleShader.setVPTextureParameter("vfield", _vectorFieldGraphicsID);
     
    458470    Vector3f bmin, bmax;
    459471    volume->getBounds(bmin, bmax);
    460     _origin = bmin;
     472    _origin.set(bmin.x, bmin.y, bmin.z);
    461473    _scale.set(bmax.x-bmin.x, bmax.y-bmin.y, bmax.z-bmin.z);
    462474
  • branches/blt4/packages/vizservers/nanovis/Volume.cpp

    r3892 r3958  
    3131double Volume::valueMax = 1.0;
    3232
    33 Volume::Volume(int w, int h, int d,
    34                int n, float *data,
    35                double v0, double v1, double nonZeroMin) :
     33Volume::Volume(int width, int height, int depth,
     34               int numComponents, float *data,
     35               double vmin, double vmax, double nonZeroMin) :
    3636    _id(0),
    37     _width(w),
    38     _height(h),
    39     _depth(d),
     37    _width(width),
     38    _height(height),
     39    _depth(depth),
    4040    _transferFunc(NULL),
    4141    _ambient(0.6f),
     
    4646    _opacityScale(0.5f),
    4747    _data(NULL),
    48     _numComponents(n),
     48    _numComponents(numComponents),
    4949    _nonZeroMin(nonZeroMin),
     50    _cutplanesVisible(true),
    5051    _tex(NULL),
    5152    _position(0,0,0),
     
    6263    _outlineColor[0] = _outlineColor[1] = _outlineColor[2] = 1.0f;
    6364
    64     _tex = new Texture3D(_width, _height, _depth, GL_FLOAT, GL_LINEAR, n);
     65    _tex = new Texture3D(_width, _height, _depth, GL_FLOAT, GL_LINEAR, _numComponents);
    6566    int fcount = _width * _height * _depth * _numComponents;
    6667    _data = new float[fcount];
     
    7071    _id = _tex->id();
    7172
    72     wAxis.setRange(v0, v1);
     73    wAxis.setRange(vmin, vmax);
    7374
    7475    //Add cut planes. We create 3 default cut planes facing x, y, z directions.
     
    9091}
    9192
    92 void Volume::setData(float *data, double v0, double v1, double nonZeroMin)
     93void Volume::setData(float *data, double vmin, double vmax, double nonZeroMin)
    9394{
    9495    int fcount = _width * _height * _depth * _numComponents;
    9596    memcpy(_data, data, fcount * sizeof(float));
    9697    _tex->update(_data);
    97     wAxis.setRange(v0, v1);
     98    wAxis.setRange(vmin, vmax);
    9899    _nonZeroMin = nonZeroMin;
    99100    updatePending = true;
  • branches/blt4/packages/vizservers/nanovis/Volume.h

    r3892 r3958  
    125125    }
    126126
    127     void setData(float *data, double v0, double v1, double nonZeroMin);
     127    void setData(float *data, double vmin, double vmax, double nonZeroMin);
    128128
    129129    const float *data() const
     
    154154
    155155    void disableCutplane(int index);
     156
     157    void cutplanesVisible(bool state)
     158    {
     159        _cutplanesVisible = state;
     160    }
     161
     162    bool cutplanesVisible() const
     163    {
     164        return _cutplanesVisible;
     165    }
    156166
    157167    void setCutplanePosition(int index, float location);
     
    387397    double _nonZeroMin;
    388398
     399    bool _cutplanesVisible;
    389400    std::vector<CutPlane> _plane; ///< cut planes
    390401
  • branches/blt4/packages/vizservers/nanovis/VolumeRenderer.cpp

    r3892 r3958  
    281281
    282282        for (int j = 0; j < volume->getCutplaneCount(); j++) {
    283             if (!volume->isCutplaneEnabled(j)) {
     283            if (!volume->cutplanesVisible() || !volume->isCutplaneEnabled(j)) {
    284284                continue;
    285285            }
  • branches/blt4/packages/vizservers/nanovis/VtkReader.cpp

    r3892 r3958  
    1616#include "ReaderCommon.h"
    1717
     18#include "config.h"
    1819#include "nanovis.h"
    1920#include "VtkReader.h"
  • branches/blt4/packages/vizservers/nanovis/ZincBlendeVolume.cpp

    r3892 r3958  
    2424using namespace vrmath;
    2525
    26 ZincBlendeVolume::ZincBlendeVolume(int w, int h, int d, int n,
     26ZincBlendeVolume::ZincBlendeVolume(int width, int height, int depth,
     27                                   int numComponents,
    2728                                   float *dataVolumeA, float *dataVolumeB,
    28                                    double v0, double v1, double non_zeromin,
     29                                   double vmin, double vmax, double nonZeroMin,
    2930                                   const Vector3f& cellSz) :
    30     Volume(w, h, d, n, dataVolumeA, v0, v1, non_zeromin),
     31    Volume(width, height, depth, numComponents, dataVolumeA, vmin, vmax, nonZeroMin),
    3132    cellSize(cellSz)
    3233{
     
    3435    _volumeType = ZINCBLENDE;
    3536
    36     //store member tex initialize in Volume() as zincblende_tex[0]
     37    //store member tex initialize in Volume() as zincblendeTex[0]
    3738    assert(_tex);
    3839    zincblendeTex[0] = _tex;
    3940
    4041    //now add another tex as zincblende_tex[1]
    41     Texture3D *secondTex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n);
     42    Texture3D *secondTex = new Texture3D(width, height, depth, GL_FLOAT, GL_LINEAR, numComponents);
    4243    assert(secondTex);
    4344    secondTex->initialize(dataVolumeB);
  • branches/blt4/packages/vizservers/nanovis/ZincBlendeVolume.h

    r3892 r3958  
    2323    ZincBlendeVolume(int width, int height, int depth, int numComponents,
    2424                     float *dataVolumeA, float *dataVolumeB,
    25                      double vmin, double vmax, double non_zeromin,
     25                     double vmin, double vmax, double nonZeroMin,
    2626                     const vrmath::Vector3f& cellSize);
    2727
  • branches/blt4/packages/vizservers/nanovis/config.h

    r3892 r3958  
    3838
    3939/*
     40 * If defined, use ARB_vertex_program and ARB_fragment_program as Cg
     41 * profile target, otherwise NV_vertex_program3 and NV_fragment_program2
     42 * are required
     43 */
     44//#define USE_ARB_PROGRAMS
     45
     46/*
    4047 * Keep statistics
    4148 */
  • branches/blt4/packages/vizservers/nanovis/dxReader.cpp

    r3892 r3958  
    211211    }
    212212
    213     TRACE("found nx=%d ny=%d nxy=%d nz=%d\ndx=%f dy=%f dz=%f\nx0=%f y0=%f z0=%f",
     213    TRACE("found nx=%d ny=%d nxy=%d nz=%d\ndx=%g dy=%g dz=%g\nx0=%g y0=%g z0=%g",
    214214          nx, ny, nxy, nz, dx, dy, dz, x0, y0, z0);
    215215
  • branches/blt4/packages/vizservers/nanovis/nanovis.cpp

    r3892 r3958  
    504504    }
    505505#endif
    506     // FIXME: should use ARB programs or (preferably) a GLSL profile for portability
     506    // FIXME: should use GLSL for portability
     507#ifdef USE_ARB_PROGRAMS
     508    if (!GLEW_ARB_vertex_program ||
     509        !GLEW_ARB_fragment_program) {
     510        ERROR("ARB_vertex_program and ARB_fragment_program extensions are required");
     511        return false;
     512    }
     513#else
    507514    if (!GLEW_NV_vertex_program3 ||
    508515        !GLEW_NV_fragment_program2) {
     
    510517        return false;
    511518    }
     519#endif
    512520
    513521    if (!FilePath::getInstance()->setPath(path)) {
     
    611619}
    612620
     621/**
     622 * \brief Called when new volumes are added to update ranges
     623 */
    613624void
    614625NanoVis::setVolumeRanges()
     
    636647}
    637648
     649/**
     650 * \brief Called when new heightmaps are added to update ranges
     651 */
    638652void
    639653NanoVis::setHeightmapRanges()
     
    668682NanoVis::collectBounds(bool onlyVisible)
    669683{
    670     if (Flow::updatePending) {
    671         mapFlows();
    672     }
    673 
    674684    sceneBounds.makeEmpty();
    675685
     
    698708    }
    699709
    700     {
     710    for (FlowHashmap::iterator itr = flowTable.begin();
     711         itr != flowTable.end(); ++itr) {
     712        Flow *flow = itr->second;
     713
    701714        BBox bbox;
    702         getFlowBounds(bbox.min, bbox.max, onlyVisible);
     715        flow->getBounds(bbox.min, bbox.max, onlyVisible);
    703716        sceneBounds.extend(bbox);
    704717    }
     
    714727    }
    715728
     729#if 0
    716730    if (!onlyVisible || grid->isVisible()) {
    717731        BBox bbox;
     
    719733        sceneBounds.extend(bbox);
    720734    }
     735#endif
    721736
    722737    if (sceneBounds.isEmpty()) {
     
    802817}
    803818
     819/**
     820 * \brief Called when new flows are added to update ranges
     821 */
    804822bool
    805 NanoVis::mapFlows()
     823NanoVis::setFlowRanges()
    806824{
    807825    TRACE("Enter");
     
    817835         itr != flowTable.end(); ++itr) {
    818836        Flow *flow = itr->second;
    819         double min, max;
    820837        if (!flow->isDataLoaded()) {
    821838            continue;
    822839        }
    823         Rappture::Unirect3d *data = flow->data();
    824         min = data->magMin();
    825         max = data->magMax();
    826         if (min < Flow::magMin) {
    827             Flow::magMin = min;
     840        double range[2];
     841        flow->getVectorRange(range);
     842        if (range[0] < Flow::magMin) {
     843            Flow::magMin = range[0];
    828844        }
    829         if (max > Flow::magMax) {
    830             Flow::magMax = max;
     845        if (range[1] > Flow::magMax) {
     846            Flow::magMax = range[1];
    831847        }
    832848    }
     
    846862            flow->initializeParticles();
    847863        }
    848         if (!flow->scaleVectorField()) {
    849             return false;
    850         }
    851864    }
    852865
    853866    Flow::updatePending = false;
    854867    return true;
    855 }
    856 
    857 void
    858 NanoVis::getFlowBounds(Vector3f& min,
    859                        Vector3f& max,
    860                        bool onlyVisible)
    861 {
    862     TRACE("Enter");
    863 
    864     BBox allBounds;
    865     for (FlowHashmap::iterator itr = flowTable.begin();
    866          itr != flowTable.end(); ++itr) {
    867         BBox bbox;
    868         itr->second->getBounds(bbox.min, bbox.max, onlyVisible);
    869         allBounds.extend(bbox);
    870     }
    871 
    872     min = allBounds.min;
    873     max = allBounds.max;
    874868}
    875869
     
    918912
    919913    if (Flow::updatePending) {
    920         mapFlows();
     914        setFlowRanges();
    921915    }
    922916    if (HeightMap::updatePending) {
  • branches/blt4/packages/vizservers/nanovis/nanovis.h

    r3892 r3958  
    123123    static void setVolumeRanges();
    124124    static void setHeightmapRanges();
    125     static bool mapFlows();
     125    static bool setFlowRanges();
    126126
    127127    static Flow *getFlow(const char *name);
     
    129129    static void deleteFlows(Tcl_Interp *interp);
    130130    static void deleteFlow(const char *name);
    131     static void getFlowBounds(vrmath::Vector3f& min,
    132                               vrmath::Vector3f& max,
    133                               bool onlyVisible = false);
     131
    134132    static void renderFlows();
    135133    static void resetFlows();
  • branches/blt4/packages/vizservers/nanovis/util/Fonts.cpp

    r3892 r3958  
    9393    glLoadIdentity();
    9494
     95#if 0
     96    glDisable(GL_BLEND);
     97    glEnable(GL_DEPTH_TEST);
     98#else
    9599    glEnable(GL_BLEND);
    96100    glDisable(GL_DEPTH_TEST);
     101#endif
    97102}
    98103
     
    223228            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    224229            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
     230            glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    225231            glBindTexture(GL_TEXTURE_2D, 0);
    226232
  • branches/blt4/packages/vizservers/nanovis/vrmath/include/vrmath/Vector2f.h

    r3892 r3958  
    4040    void set(const Vector2f& v);
    4141
    42     float dot() const;
     42    double dot() const;
    4343
    4444    double length() const;
     
    6767}
    6868
    69 inline float Vector2f::dot() const
     69inline double Vector2f::dot() const
    7070{
    7171    return (x * x + y * y);
  • branches/blt4/packages/vizservers/nanovis/vrmath/include/vrmath/Vector3f.h

    r3892 r3958  
    5858    Vector3f scale(const Vector3f& scale) const;
    5959
    60     Vector3f scale(float scale) const;
     60    Vector3f scale(double scale) const;
    6161
    6262    bool operator==(const Vector3f& v) const;
     
    6767
    6868    // scalar ops
    69     Vector3f operator+(float scalar) const;
    70     Vector3f operator-(float scalar) const;
    71     Vector3f operator*(float scalar) const;
    72     Vector3f operator/(float scalar) const;
    73     Vector3f& operator*=(float scalar);
     69    Vector3f operator+(double scalar) const;
     70    Vector3f operator-(double scalar) const;
     71    Vector3f operator*(double scalar) const;
     72    Vector3f operator/(double scalar) const;
     73    Vector3f& operator*=(double scalar);
    7474
    7575    // vector ops
     
    113113}
    114114
    115 inline Vector3f Vector3f::operator+(float scalar) const
     115inline Vector3f Vector3f::operator+(double scalar) const
    116116{
    117117    return Vector3f(x + scalar, y + scalar, z + scalar);
    118118}
    119119
    120 inline Vector3f Vector3f::operator-(float scalar) const
     120inline Vector3f Vector3f::operator-(double scalar) const
    121121{
    122122    return Vector3f(x - scalar, y - scalar, z - scalar);
    123123}
    124124
    125 inline Vector3f Vector3f::operator*(float scalar) const
     125inline Vector3f Vector3f::operator*(double scalar) const
    126126{
    127127    return Vector3f(x * scalar, y * scalar, z * scalar);
    128128}
    129129
    130 inline Vector3f Vector3f::operator/(float scalar) const
     130inline Vector3f Vector3f::operator/(double scalar) const
    131131{
    132132    return Vector3f(x / scalar, y / scalar, z / scalar);
    133133}
    134134
    135 inline Vector3f& Vector3f::operator*=(float scalar)
     135inline Vector3f& Vector3f::operator*=(double scalar)
    136136{
    137137    x *= scalar;
     
    168168
    169169#if 0
    170 inline Vector3f operator*(float scale, const Vector3f& value)
     170inline Vector3f operator*(double scale, const Vector3f& value)
    171171{
    172172    return Vector3f(value.x * scale, value.y * scale, value.z * scale);
     
    231231inline Vector3f Vector3f::normalize() const
    232232{
    233     float len = length();
    234     if (len > 1.0e-6) {
     233    double len = length();
     234    if (len > 0.0) {
    235235        return Vector3f(x / len, y / len, z / len);
    236236    } else {
     
    239239}
    240240
    241 inline Vector3f Vector3f::scale(float scale) const
     241inline Vector3f Vector3f::scale(double scale) const
    242242{
    243243    return Vector3f(x * scale, y * scale, z * scale);
  • branches/blt4/packages/vizservers/nanovis/vrmath/include/vrmath/Vector4f.h

    r3892 r3958  
    6666    }
    6767
    68     Vector4f operator*(float op2) const
     68    Vector4f operator*(double op2) const
    6969    {
    7070        return Vector4f(x * op2, y * op2, z * op2, w * op2);
    7171    }
    7272
    73     Vector4f operator/(float op2) const
     73    Vector4f operator/(double op2) const
    7474    {
    7575        return Vector4f(x / op2, y / op2, z / op2, w / op2);
     
    7878    void divideByW();
    7979
    80     float dot(const Vector4f& vec) const;
     80    double dot(const Vector4f& vec) const;
    8181
    8282    union {
     
    122122}
    123123
    124 inline float Vector4f::dot(const Vector4f& v) const
     124inline double Vector4f::dot(const Vector4f& v) const
    125125{
    126     return (x * v.x + y * v.y + z * v.z + w * v.w);
     126    return ((double)x * v.x + (double)y * v.y + (double)z * v.z + (double)w * v.w);
    127127}
    128128
  • branches/blt4/packages/vizservers/vtkvis/DataSet.cpp

    r3892 r3958  
    164164        return false;
    165165
    166     if (vtkUnstructuredGrid::SafeDownCast(_dataSet) != NULL) {
     166    if (vtkUnstructuredGrid::SafeDownCast(_dataSet) != NULL && !isCloud()) {
    167167        vtkSmartPointer<vtkExtractUnstructuredGrid> filter = vtkSmartPointer<vtkExtractUnstructuredGrid>::New();
    168168#ifdef USE_VTK6
  • branches/blt4/packages/vizservers/vtkvis/Makefile.in

    r3892 r3958  
    147147                Molecule.cpp \
    148148                Outline.cpp \
     149                Parallelepiped.cpp \
    149150                PolyData.cpp \
    150151                Polygon.cpp \
     
    230231Molecule.o: Molecule.h MoleculeData.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h
    231232Outline.o: Outline.h GraphicsObject.h DataSet.h Trace.h
     233Parallelepiped.o: Parallelepiped.h Shape.h GraphicsObject.h DataSet.h Renderer.h Trace.h
    232234PolyData.o: PolyData.h GraphicsObject.h DataSet.h Renderer.h Trace.h
    233235Polygon.o: Polygon.h Shape.h GraphicsObject.h DataSet.h Renderer.h Trace.h
     
    235237PseudoColor.o: PseudoColor.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h
    236238ReadBuffer.o: ReadBuffer.h Trace.h
    237 Renderer.o: Renderer.h RendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h Math.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h Image.h LIC.h Line.h Molecule.h Outline.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Text3D.h Volume.h Warp.h ColorMap.h Trace.h
    238 RendererCmd.o: Renderer.h RendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h Image.h LIC.h Line.h Molecule.h Outline.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Text3D.h Volume.h Warp.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h
    239 RendererGraphicsObjs.o: Renderer.h RendererGraphicsObjs.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h Image.h LIC.h Line.h Molecule.h Outline.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Text3D.h Volume.h Warp.h ColorMap.h Trace.h
     239Renderer.o: Renderer.h RendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h Math.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h Image.h LIC.h Line.h Molecule.h Outline.h Parallelepiped.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Text3D.h Volume.h Warp.h ColorMap.h Trace.h
     240RendererCmd.o: Renderer.h RendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h Image.h LIC.h Line.h Molecule.h Outline.h Parallelepiped.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Text3D.h Volume.h Warp.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h
     241RendererGraphicsObjs.o: Renderer.h RendererGraphicsObjs.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h Image.h LIC.h Line.h Molecule.h Outline.h Parallelepiped.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Text3D.h Volume.h Warp.h ColorMap.h Trace.h
    240242RenderServer.o: RenderServer.h RendererCmd.h Renderer.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h ReadBuffer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h
    241243ResponseQueue.o: ResponseQueue.h Trace.h
  • branches/blt4/packages/vizservers/vtkvis/RenderServer.h

    r3892 r3958  
    1616class Renderer;
    1717
    18 #define VTKVIS_VERSION_STRING "1.5"
     18#define VTKVIS_VERSION_STRING "1.6"
    1919
    2020#define MSECS_ELAPSED(t1, t2) \
  • branches/blt4/packages/vizservers/vtkvis/Renderer.cpp

    r3892 r3958  
    197197    deleteAllGraphicsObjects<Molecule>();
    198198    deleteAllGraphicsObjects<Outline>();
     199    deleteAllGraphicsObjects<Parallelepiped>();
    199200    deleteAllGraphicsObjects<PolyData>();
    200201    deleteAllGraphicsObjects<Polygon>();
     
    382383    bool needRangeUpdate = false;
    383384    do {
    384         if (strcmp(itr->second->getActiveScalarsName(), scalarName) != 0) {
     385        const char *name = itr->second->getActiveScalarsName();
     386        if (name == NULL || (strcmp(name, scalarName) != 0)) {
    385387            if (!itr->second->setActiveScalars(scalarName)) {
    386388                ret = false;
     
    24362438    setGraphicsObjectAspect<Molecule>(aspectRatio);
    24372439    setGraphicsObjectAspect<Outline>(aspectRatio);
     2440    setGraphicsObjectAspect<Parallelepiped>(aspectRatio);
    24382441    setGraphicsObjectAspect<PolyData>(aspectRatio);
    24392442    setGraphicsObjectAspect<Polygon>(aspectRatio);
     
    33573360    mergeGraphicsObjectBounds<Molecule>(bounds, onlyVisible);
    33583361    mergeGraphicsObjectBounds<Outline>(bounds, onlyVisible);
     3362    mergeGraphicsObjectBounds<Parallelepiped>(bounds, onlyVisible);
    33593363    mergeGraphicsObjectBounds<PolyData>(bounds, onlyVisible);
    33603364    mergeGraphicsObjectBounds<Polygon>(bounds, onlyVisible);
     
    34293433    mergeGraphicsObjectUnscaledBounds<Outline>(bounds, onlyVisible);
    34303434    mergeGraphicsObjectUnscaledBounds<PolyData>(bounds, onlyVisible);
     3435    mergeGraphicsObjectUnscaledBounds<Parallelepiped>(bounds, onlyVisible);
    34313436    mergeGraphicsObjectUnscaledBounds<Polygon>(bounds, onlyVisible);
    34323437    mergeGraphicsObjectUnscaledBounds<PseudoColor>(bounds, onlyVisible);
     
    45774582    setGraphicsObjectClippingPlanes<Molecule>(_activeClipPlanes);
    45784583    setGraphicsObjectClippingPlanes<Outline>(_activeClipPlanes);
     4584    setGraphicsObjectClippingPlanes<Parallelepiped>(_activeClipPlanes);
    45794585    setGraphicsObjectClippingPlanes<PolyData>(_activeClipPlanes);
    45804586    setGraphicsObjectClippingPlanes<Polygon>(_activeClipPlanes);
  • branches/blt4/packages/vizservers/vtkvis/Renderer.h

    r3892 r3958  
    4545#include "Molecule.h"
    4646#include "Outline.h"
     47#include "Parallelepiped.h"
    4748#include "PolyData.h"
    4849#include "Polygon.h"
     
    809810                              const char *name, double range[2] = NULL);
    810811
    811     // N-sided Regular Polygons
    812 
    813     bool addPolygon(const DataSetId& id, int numSides, double center[3], double normal[3], double radius);
     812    // Parallelepipeds
     813
     814    bool addParallelepiped(const DataSetId& id, double vec1[3], double vec2[3], double vec3[3],
     815                           bool flipNormals = false);
    814816
    815817    // PolyData meshes
     
    826828                              DataSet::DataAttributeType type,
    827829                              const char *name, double range[2] = NULL);
     830
     831    // N-sided Regular Polygons
     832
     833    bool addPolygon(const DataSetId& id, int numSides, double center[3], double normal[3], double radius);
    828834
    829835    // Color-mapped surfaces
     
    975981    typedef std::tr1::unordered_map<DataSetId, Molecule *> MoleculeHashmap;
    976982    typedef std::tr1::unordered_map<DataSetId, Outline *> OutlineHashmap;
     983    typedef std::tr1::unordered_map<DataSetId, Parallelepiped *> ParallelepipedHashmap;
    977984    typedef std::tr1::unordered_map<DataSetId, PolyData *> PolyDataHashmap;
    978985    typedef std::tr1::unordered_map<DataSetId, Polygon *> PolygonHashmap;
     
    11141121    MoleculeHashmap _molecules;
    11151122    OutlineHashmap _outlines;
     1123    ParallelepipedHashmap _parallelepipeds;
    11161124    PolyDataHashmap _polyDatas;
    11171125    PolygonHashmap _polygons;
  • branches/blt4/packages/vizservers/vtkvis/RendererCmd.cpp

    r3892 r3958  
    13171317{
    13181318    const char *title = Tcl_GetString(objv[3]);
    1319     if (strlen(title) > 30) {
     1319    if (strlen(title) > 60) {
    13201320        Tcl_AppendResult(interp, "axis name \"", title,
    13211321                         "\" is too long", (char*)NULL);
     
    16011601{
    16021602    const char *units = Tcl_GetString(objv[3]);
    1603     if (strlen(units) > 10) {
     1603    if (strlen(units) > 20) {
    16041604        Tcl_AppendResult(interp, "axis units name \"", units,
    16051605                         "\" is too long", (char*)NULL);
     
    85598559
    85608560static int
     8561ParallelepipedAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8562                    Tcl_Obj *const *objv)
     8563{
     8564    double vec1[3], vec2[3], vec3[3];
     8565    if (Tcl_GetDoubleFromObj(interp, objv[2], &vec1[0]) != TCL_OK ||
     8566        Tcl_GetDoubleFromObj(interp, objv[3], &vec1[1]) != TCL_OK ||
     8567        Tcl_GetDoubleFromObj(interp, objv[4], &vec1[2]) != TCL_OK ||
     8568        Tcl_GetDoubleFromObj(interp, objv[5], &vec2[0]) != TCL_OK ||
     8569        Tcl_GetDoubleFromObj(interp, objv[6], &vec2[1]) != TCL_OK ||
     8570        Tcl_GetDoubleFromObj(interp, objv[7], &vec2[2]) != TCL_OK ||
     8571        Tcl_GetDoubleFromObj(interp, objv[8], &vec3[0]) != TCL_OK ||
     8572        Tcl_GetDoubleFromObj(interp, objv[9], &vec3[1]) != TCL_OK ||
     8573        Tcl_GetDoubleFromObj(interp, objv[10], &vec3[2]) != TCL_OK) {
     8574        return TCL_ERROR;
     8575    }
     8576    const char *name = Tcl_GetString(objv[11]);
     8577    if (!g_renderer->addParallelepiped(name, vec1, vec2, vec3)) {
     8578        Tcl_AppendResult(interp, "Failed to create parallelepiped", (char*)NULL);
     8579        return TCL_ERROR;
     8580    }
     8581    return TCL_OK;
     8582}
     8583
     8584static int
     8585ParallelepipedDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8586                       Tcl_Obj *const *objv)
     8587{
     8588    if (objc == 3) {
     8589        const char *name = Tcl_GetString(objv[2]);
     8590        g_renderer->deleteGraphicsObject<Parallelepiped>(name);
     8591    } else {
     8592        g_renderer->deleteGraphicsObject<Parallelepiped>("all");
     8593    }
     8594    return TCL_OK;
     8595}
     8596
     8597static int
     8598ParallelepipedColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8599                      Tcl_Obj *const *objv)
     8600{
     8601    float color[3];
     8602    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     8603        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     8604        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     8605        return TCL_ERROR;
     8606    }
     8607    if (objc == 6) {
     8608        const char *name = Tcl_GetString(objv[5]);
     8609        g_renderer->setGraphicsObjectColor<Parallelepiped>(name, color);
     8610    } else {
     8611        g_renderer->setGraphicsObjectColor<Parallelepiped>("all", color);
     8612    }
     8613    return TCL_OK;
     8614}
     8615
     8616static int
     8617ParallelepipedCullingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8618                        Tcl_Obj *const *objv)
     8619{
     8620    bool state;
     8621    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8622        return TCL_ERROR;
     8623    }
     8624    if (objc == 4) {
     8625        const char *name = Tcl_GetString(objv[3]);
     8626        g_renderer->setGraphicsObjectCulling<Parallelepiped>(name, state);
     8627    } else {
     8628        g_renderer->setGraphicsObjectCulling<Parallelepiped>("all", state);
     8629    }
     8630    return TCL_OK;
     8631}
     8632
     8633static int
     8634ParallelepipedEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8635                               Tcl_Obj *const *objv)
     8636{
     8637    bool state;
     8638    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8639        return TCL_ERROR;
     8640    }
     8641    if (objc == 4) {
     8642        const char *name = Tcl_GetString(objv[3]);
     8643        g_renderer->setGraphicsObjectEdgeVisibility<Parallelepiped>(name, state);
     8644    } else {
     8645        g_renderer->setGraphicsObjectEdgeVisibility<Parallelepiped>("all", state);
     8646    }
     8647    return TCL_OK;
     8648}
     8649
     8650static int
     8651ParallelepipedFlipNormalsOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8652                            Tcl_Obj *const *objv)
     8653{
     8654    bool state;
     8655    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8656        return TCL_ERROR;
     8657    }
     8658    if (objc == 4) {
     8659        const char *name = Tcl_GetString(objv[3]);
     8660        g_renderer->setGraphicsObjectFlipNormals<Parallelepiped>(name, state);
     8661    } else {
     8662        g_renderer->setGraphicsObjectFlipNormals<Parallelepiped>("all", state);
     8663    }
     8664    return TCL_OK;
     8665}
     8666
     8667static int
     8668ParallelepipedLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8669                         Tcl_Obj *const *objv)
     8670{
     8671    bool state;
     8672    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8673        return TCL_ERROR;
     8674    }
     8675    if (objc == 4) {
     8676        const char *name = Tcl_GetString(objv[3]);
     8677        g_renderer->setGraphicsObjectLighting<Parallelepiped>(name, state);
     8678    } else {
     8679        g_renderer->setGraphicsObjectLighting<Parallelepiped>("all", state);
     8680    }
     8681    return TCL_OK;
     8682}
     8683
     8684static int
     8685ParallelepipedLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8686                          Tcl_Obj *const *objv)
     8687{
     8688    float color[3];
     8689    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     8690        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     8691        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     8692        return TCL_ERROR;
     8693    }
     8694    if (objc == 6) {
     8695        const char *name = Tcl_GetString(objv[5]);
     8696        g_renderer->setGraphicsObjectEdgeColor<Parallelepiped>(name, color);
     8697    } else {
     8698        g_renderer->setGraphicsObjectEdgeColor<Parallelepiped>("all", color);
     8699    }
     8700    return TCL_OK;
     8701}
     8702
     8703static int
     8704ParallelepipedLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8705                          Tcl_Obj *const *objv)
     8706{
     8707    float width;
     8708    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     8709        return TCL_ERROR;
     8710    }
     8711    if (objc == 4) {
     8712        const char *name = Tcl_GetString(objv[3]);
     8713        g_renderer->setGraphicsObjectEdgeWidth<Parallelepiped>(name, width);
     8714    } else {
     8715        g_renderer->setGraphicsObjectEdgeWidth<Parallelepiped>("all", width);
     8716    }
     8717    return TCL_OK;
     8718}
     8719
     8720static int
     8721ParallelepipedMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8722                         Tcl_Obj *const *objv)
     8723{
     8724    double ambient, diffuse, specCoeff, specPower;
     8725    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     8726        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     8727        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     8728        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     8729        return TCL_ERROR;
     8730    }
     8731
     8732    if (objc == 7) {
     8733        const char *name = Tcl_GetString(objv[6]);
     8734        g_renderer->setGraphicsObjectAmbient<Parallelepiped>(name, ambient);
     8735        g_renderer->setGraphicsObjectDiffuse<Parallelepiped>(name, diffuse);
     8736        g_renderer->setGraphicsObjectSpecular<Parallelepiped>(name, specCoeff, specPower);
     8737    } else {
     8738        g_renderer->setGraphicsObjectAmbient<Parallelepiped>("all", ambient);
     8739        g_renderer->setGraphicsObjectDiffuse<Parallelepiped>("all", diffuse);
     8740        g_renderer->setGraphicsObjectSpecular<Parallelepiped>("all", specCoeff, specPower);
     8741    }
     8742    return TCL_OK;
     8743}
     8744
     8745static int
     8746ParallelepipedOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8747                        Tcl_Obj *const *objv)
     8748{
     8749    double opacity;
     8750    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     8751        return TCL_ERROR;
     8752    }
     8753    if (objc == 4) {
     8754        const char *name = Tcl_GetString(objv[3]);
     8755        g_renderer->setGraphicsObjectOpacity<Parallelepiped>(name, opacity);
     8756    } else {
     8757        g_renderer->setGraphicsObjectOpacity<Parallelepiped>("all", opacity);
     8758    }
     8759    return TCL_OK;
     8760}
     8761
     8762static int
     8763ParallelepipedOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8764                       Tcl_Obj *const *objv)
     8765{
     8766    double quat[4];
     8767    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     8768        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     8769        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     8770        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     8771        return TCL_ERROR;
     8772    }
     8773    if (objc == 7) {
     8774        const char *name = Tcl_GetString(objv[6]);
     8775        g_renderer->setGraphicsObjectOrientation<Parallelepiped>(name, quat);
     8776    } else {
     8777        g_renderer->setGraphicsObjectOrientation<Parallelepiped>("all", quat);
     8778    }
     8779    return TCL_OK;
     8780}
     8781
     8782static int
     8783ParallelepipedOriginOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8784                       Tcl_Obj *const *objv)
     8785{
     8786    double origin[3];
     8787    if (Tcl_GetDoubleFromObj(interp, objv[2], &origin[0]) != TCL_OK ||
     8788        Tcl_GetDoubleFromObj(interp, objv[3], &origin[1]) != TCL_OK ||
     8789        Tcl_GetDoubleFromObj(interp, objv[4], &origin[2]) != TCL_OK) {
     8790        return TCL_ERROR;
     8791    }
     8792    if (objc == 6) {
     8793        const char *name = Tcl_GetString(objv[5]);
     8794        g_renderer->setGraphicsObjectOrigin<Parallelepiped>(name, origin);
     8795    } else {
     8796        g_renderer->setGraphicsObjectOrigin<Parallelepiped>("all", origin);
     8797    }
     8798    return TCL_OK;
     8799}
     8800
     8801static int
     8802ParallelepipedPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8803                         Tcl_Obj *const *objv)
     8804{
     8805    double pos[3];
     8806    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     8807        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     8808        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     8809        return TCL_ERROR;
     8810    }
     8811    if (objc == 6) {
     8812        const char *name = Tcl_GetString(objv[5]);
     8813        g_renderer->setGraphicsObjectPosition<Parallelepiped>(name, pos);
     8814    } else {
     8815        g_renderer->setGraphicsObjectPosition<Parallelepiped>("all", pos);
     8816    }
     8817    return TCL_OK;
     8818}
     8819
     8820static int
     8821ParallelepipedScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8822                      Tcl_Obj *const *objv)
     8823{
     8824    double scale[3];
     8825    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     8826        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     8827        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     8828        return TCL_ERROR;
     8829    }
     8830    if (objc == 6) {
     8831        const char *name = Tcl_GetString(objv[5]);
     8832        g_renderer->setGraphicsObjectScale<Parallelepiped>(name, scale);
     8833    } else {
     8834        g_renderer->setGraphicsObjectScale<Parallelepiped>("all", scale);
     8835    }
     8836    return TCL_OK;
     8837}
     8838
     8839static int
     8840ParallelepipedShadingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8841                        Tcl_Obj *const *objv)
     8842{
     8843    GraphicsObject::ShadingModel shadeModel;
     8844    const char *str = Tcl_GetString(objv[2]);
     8845    if (str[0] == 'f' && strcmp(str, "flat") == 0) {
     8846        shadeModel = GraphicsObject::SHADE_FLAT;
     8847    } else if (str[0] == 's' && strcmp(str, "smooth") == 0) {
     8848        shadeModel = GraphicsObject::SHADE_GOURAUD;
     8849    } else {
     8850         Tcl_AppendResult(interp, "bad shading option \"", str,
     8851                         "\": should be one of: 'flat', 'smooth'", (char*)NULL);
     8852        return TCL_ERROR;
     8853    }
     8854    if (objc == 4) {
     8855        const char *name = Tcl_GetString(objv[3]);
     8856        g_renderer->setGraphicsObjectShadingModel<Parallelepiped>(name, shadeModel);
     8857    } else {
     8858        g_renderer->setGraphicsObjectShadingModel<Parallelepiped>("all", shadeModel);
     8859    }
     8860    return TCL_OK;
     8861}
     8862
     8863static int
     8864ParallelepipedVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8865                        Tcl_Obj *const *objv)
     8866{
     8867    bool state;
     8868    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8869        return TCL_ERROR;
     8870    }
     8871    if (objc == 4) {
     8872        const char *name = Tcl_GetString(objv[3]);
     8873        g_renderer->setGraphicsObjectVisibility<Parallelepiped>(name, state);
     8874    } else {
     8875        g_renderer->setGraphicsObjectVisibility<Parallelepiped>("all", state);
     8876    }
     8877    return TCL_OK;
     8878}
     8879
     8880static int
     8881ParallelepipedWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8882                          Tcl_Obj *const *objv)
     8883{
     8884    bool state;
     8885    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8886        return TCL_ERROR;
     8887    }
     8888    if (objc == 4) {
     8889        const char *name = Tcl_GetString(objv[3]);
     8890        g_renderer->setGraphicsObjectWireframe<Parallelepiped>(name, state);
     8891    } else {
     8892        g_renderer->setGraphicsObjectWireframe<Parallelepiped>("all", state);
     8893    }
     8894    return TCL_OK;
     8895}
     8896
     8897static Rappture::CmdSpec parallelepipedOps[] = {
     8898    {"add",       1, ParallelepipedAddOp, 12, 12, "v0x v0y v0z v1x v1y v1z v2x v2y v2z name"},
     8899    {"color",     2, ParallelepipedColorOp, 5, 6, "r g b ?name?"},
     8900    {"culling",   2, ParallelepipedCullingOp, 3, 4, "bool ?name?"},
     8901    {"delete",    1, ParallelepipedDeleteOp, 2, 3, "?name?"},
     8902    {"edges",     1, ParallelepipedEdgeVisibilityOp, 3, 4, "bool ?name?"},
     8903    {"flipnorms", 1, ParallelepipedFlipNormalsOp, 3, 4, "bool ?name?"},
     8904    {"lighting",  3, ParallelepipedLightingOp, 3, 4, "bool ?name?"},
     8905    {"linecolor", 5, ParallelepipedLineColorOp, 5, 6, "r g b ?name?"},
     8906    {"linewidth", 5, ParallelepipedLineWidthOp, 3, 4, "width ?name?"},
     8907    {"material",  1, ParallelepipedMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     8908    {"opacity",   2, ParallelepipedOpacityOp, 3, 4, "value ?name?"},
     8909    {"orient",    4, ParallelepipedOrientOp, 6, 7, "qw qx qy qz ?name?"},
     8910    {"origin",    4, ParallelepipedOriginOp, 5, 6, "x y z ?name?"},
     8911    {"pos",       1, ParallelepipedPositionOp, 5, 6, "x y z ?name?"},
     8912    {"scale",     2, ParallelepipedScaleOp, 5, 6, "sx sy sz ?name?"},
     8913    {"shading",   2, ParallelepipedShadingOp, 3, 4, "val ?name?"},
     8914    {"visible",   1, ParallelepipedVisibleOp, 3, 4, "bool ?name?"},
     8915    {"wireframe", 1, ParallelepipedWireframeOp, 3, 4, "bool ?name?"}
     8916};
     8917static int nParallelepipedOps = NumCmdSpecs(parallelepipedOps);
     8918
     8919static int
     8920ParallelepipedCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     8921       Tcl_Obj *const *objv)
     8922{
     8923    Tcl_ObjCmdProc *proc;
     8924
     8925    proc = Rappture::GetOpFromObj(interp, nParallelepipedOps, parallelepipedOps,
     8926                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     8927    if (proc == NULL) {
     8928        return TCL_ERROR;
     8929    }
     8930    return (*proc) (clientData, interp, objc, objv);
     8931}
     8932
     8933static int
    85618934PolyDataAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    85628935              Tcl_Obj *const *objv)
     
    1222812601{
    1222912602    Tcl_MakeSafe(interp);
    12230     Tcl_CreateObjCommand(interp, "arc",         ArcCmd,         clientData, NULL);
    12231     Tcl_CreateObjCommand(interp, "arrow",       ArrowCmd,       clientData, NULL);
    12232     Tcl_CreateObjCommand(interp, "axis",        AxisCmd,        clientData, NULL);
    12233     Tcl_CreateObjCommand(interp, "box",         BoxCmd,         clientData, NULL);
    12234     Tcl_CreateObjCommand(interp, "camera",      CameraCmd,      clientData, NULL);
    12235     Tcl_CreateObjCommand(interp, "clientinfo",  ClientInfoCmd,  clientData, NULL);
    12236     Tcl_CreateObjCommand(interp, "colormap",    ColorMapCmd,    clientData, NULL);
    12237     Tcl_CreateObjCommand(interp, "cone",        ConeCmd,        clientData, NULL);
    12238     Tcl_CreateObjCommand(interp, "contour2d",   Contour2DCmd,   clientData, NULL);
    12239     Tcl_CreateObjCommand(interp, "contour3d",   Contour3DCmd,   clientData, NULL);
    12240     Tcl_CreateObjCommand(interp, "cutplane",    CutplaneCmd,    clientData, NULL);
    12241     Tcl_CreateObjCommand(interp, "cylinder",    CylinderCmd,    clientData, NULL);
    12242     Tcl_CreateObjCommand(interp, "dataset",     DataSetCmd,     clientData, NULL);
    12243     Tcl_CreateObjCommand(interp, "disk",        DiskCmd,        clientData, NULL);
    12244     Tcl_CreateObjCommand(interp, "glyphs",      GlyphsCmd,      clientData, NULL);
    12245     Tcl_CreateObjCommand(interp, "group",       GroupCmd,       clientData, NULL);
    12246     Tcl_CreateObjCommand(interp, "heightmap",   HeightMapCmd,   clientData, NULL);
    12247     Tcl_CreateObjCommand(interp, "image",       ImageCmd,       clientData, NULL);
    12248     Tcl_CreateObjCommand(interp, "imgflush",    ImageFlushCmd,  clientData, NULL);
    12249     Tcl_CreateObjCommand(interp, "legend",      LegendCmd,      clientData, NULL);
    12250     Tcl_CreateObjCommand(interp, "legend2",     LegendSimpleCmd,clientData, NULL);
    12251     Tcl_CreateObjCommand(interp, "lic",         LICCmd,         clientData, NULL);
    12252     Tcl_CreateObjCommand(interp, "line",        LineCmd,        clientData, NULL);
    12253     Tcl_CreateObjCommand(interp, "molecule",    MoleculeCmd,    clientData, NULL);
    12254     Tcl_CreateObjCommand(interp, "outline",     OutlineCmd,     clientData, NULL);
    12255     Tcl_CreateObjCommand(interp, "polydata",    PolyDataCmd,    clientData, NULL);
    12256     Tcl_CreateObjCommand(interp, "polygon",     PolygonCmd,     clientData, NULL);
    12257     Tcl_CreateObjCommand(interp, "pseudocolor", PseudoColorCmd, clientData, NULL);
    12258     Tcl_CreateObjCommand(interp, "renderer",    RendererCmd,    clientData, NULL);
    12259     Tcl_CreateObjCommand(interp, "screen",      ScreenCmd,      clientData, NULL);
    12260     Tcl_CreateObjCommand(interp, "sphere",      SphereCmd,      clientData, NULL);
    12261     Tcl_CreateObjCommand(interp, "streamlines", StreamlinesCmd, clientData, NULL);
    12262     Tcl_CreateObjCommand(interp, "text3d",      Text3DCmd,      clientData, NULL);
    12263     Tcl_CreateObjCommand(interp, "volume",      VolumeCmd,      clientData, NULL);
    12264     Tcl_CreateObjCommand(interp, "warp",        WarpCmd,        clientData, NULL);
     12603    Tcl_CreateObjCommand(interp, "arc",            ArcCmd,            clientData, NULL);
     12604    Tcl_CreateObjCommand(interp, "arrow",          ArrowCmd,          clientData, NULL);
     12605    Tcl_CreateObjCommand(interp, "axis",           AxisCmd,           clientData, NULL);
     12606    Tcl_CreateObjCommand(interp, "box",            BoxCmd,            clientData, NULL);
     12607    Tcl_CreateObjCommand(interp, "camera",         CameraCmd,         clientData, NULL);
     12608    Tcl_CreateObjCommand(interp, "clientinfo",     ClientInfoCmd,     clientData, NULL);
     12609    Tcl_CreateObjCommand(interp, "colormap",       ColorMapCmd,       clientData, NULL);
     12610    Tcl_CreateObjCommand(interp, "cone",           ConeCmd,           clientData, NULL);
     12611    Tcl_CreateObjCommand(interp, "contour2d",      Contour2DCmd,      clientData, NULL);
     12612    Tcl_CreateObjCommand(interp, "contour3d",      Contour3DCmd,      clientData, NULL);
     12613    Tcl_CreateObjCommand(interp, "cutplane",       CutplaneCmd,       clientData, NULL);
     12614    Tcl_CreateObjCommand(interp, "cylinder",       CylinderCmd,       clientData, NULL);
     12615    Tcl_CreateObjCommand(interp, "dataset",        DataSetCmd,        clientData, NULL);
     12616    Tcl_CreateObjCommand(interp, "disk",           DiskCmd,           clientData, NULL);
     12617    Tcl_CreateObjCommand(interp, "glyphs",         GlyphsCmd,         clientData, NULL);
     12618    Tcl_CreateObjCommand(interp, "group",          GroupCmd,          clientData, NULL);
     12619    Tcl_CreateObjCommand(interp, "heightmap",      HeightMapCmd,      clientData, NULL);
     12620    Tcl_CreateObjCommand(interp, "image",          ImageCmd,          clientData, NULL);
     12621    Tcl_CreateObjCommand(interp, "imgflush",       ImageFlushCmd,     clientData, NULL);
     12622    Tcl_CreateObjCommand(interp, "legend",         LegendCmd,         clientData, NULL);
     12623    Tcl_CreateObjCommand(interp, "legend2",        LegendSimpleCmd,   clientData, NULL);
     12624    Tcl_CreateObjCommand(interp, "lic",            LICCmd,            clientData, NULL);
     12625    Tcl_CreateObjCommand(interp, "line",           LineCmd,           clientData, NULL);
     12626    Tcl_CreateObjCommand(interp, "molecule",       MoleculeCmd,       clientData, NULL);
     12627    Tcl_CreateObjCommand(interp, "outline",        OutlineCmd,        clientData, NULL);
     12628    Tcl_CreateObjCommand(interp, "parallelepiped", ParallelepipedCmd, clientData, NULL);
     12629    Tcl_CreateObjCommand(interp, "polydata",       PolyDataCmd,       clientData, NULL);
     12630    Tcl_CreateObjCommand(interp, "polygon",        PolygonCmd,        clientData, NULL);
     12631    Tcl_CreateObjCommand(interp, "pseudocolor",    PseudoColorCmd,    clientData, NULL);
     12632    Tcl_CreateObjCommand(interp, "renderer",       RendererCmd,       clientData, NULL);
     12633    Tcl_CreateObjCommand(interp, "screen",         ScreenCmd,         clientData, NULL);
     12634    Tcl_CreateObjCommand(interp, "sphere",         SphereCmd,         clientData, NULL);
     12635    Tcl_CreateObjCommand(interp, "streamlines",    StreamlinesCmd,    clientData, NULL);
     12636    Tcl_CreateObjCommand(interp, "text3d",         Text3DCmd,         clientData, NULL);
     12637    Tcl_CreateObjCommand(interp, "volume",         VolumeCmd,         clientData, NULL);
     12638    Tcl_CreateObjCommand(interp, "warp",           WarpCmd,           clientData, NULL);
    1226512639}
    1226612640
     
    1229512669    Tcl_DeleteCommand(interp, "molecule");
    1229612670    Tcl_DeleteCommand(interp, "outline");
     12671    Tcl_DeleteCommand(interp, "parallelepiped");
    1229712672    Tcl_DeleteCommand(interp, "polydata");
    1229812673    Tcl_DeleteCommand(interp, "polygon");
  • branches/blt4/packages/vizservers/vtkvis/RendererGraphicsObjs.cpp

    r3892 r3958  
    2828#include "Line.h"
    2929#include "Molecule.h"
     30#include "Parallelepiped.h"
    3031#include "PolyData.h"
    3132#include "PseudoColor.h"
     
    123124Renderer::getGraphicsObjectHashmap<Outline>()
    124125{ return _outlines; }
     126
     127template<>
     128Renderer::ParallelepipedHashmap &
     129Renderer::getGraphicsObjectHashmap<Parallelepiped>()
     130{ return _parallelepipeds; }
    125131
    126132template<>
     
    173179template Group *Renderer::getGraphicsObject(const DataSetId&);
    174180template Line *Renderer::getGraphicsObject(const DataSetId&);
     181template Parallelepiped *Renderer::getGraphicsObject(const DataSetId&);
    175182template Polygon *Renderer::getGraphicsObject(const DataSetId&);
    176183template Sphere *Renderer::getGraphicsObject(const DataSetId&);
     
    287294    }
    288295    if ((gobj = getGraphicsObject<Line>(id)) != NULL) {
     296        return gobj;
     297    }
     298    if ((gobj = getGraphicsObject<Parallelepiped>(id)) != NULL) {
    289299        return gobj;
    290300    }
     
    29382948
    29392949/**
     2950 * \brief Create a new Parallelepiped and associate it with an ID
     2951 */
     2952bool Renderer::addParallelepiped(const DataSetId& id,
     2953                                 double vec1[3], double vec2[3], double vec3[3],
     2954                                 bool flipNormals)
     2955{
     2956    Parallelepiped *gobj;
     2957    if ((gobj = getGraphicsObject<Parallelepiped>(id)) != NULL) {
     2958        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     2959        deleteGraphicsObject<Parallelepiped>(id);
     2960    }
     2961
     2962    gobj = new Parallelepiped();
     2963 
     2964    gobj->setDataSet(NULL, this);
     2965
     2966    if (gobj->getProp() == NULL &&
     2967        gobj->getOverlayProp() == NULL) {
     2968        delete gobj;
     2969        return false;
     2970    } else {
     2971        if (gobj->getProp())
     2972            _renderer->AddViewProp(gobj->getProp());
     2973        if (gobj->getOverlayProp())
     2974            _renderer->AddViewProp(gobj->getOverlayProp());
     2975    }
     2976
     2977    gobj->setVectors(vec1, vec2, vec3);
     2978    if (flipNormals)
     2979        gobj->flipNormals(flipNormals);
     2980
     2981    getGraphicsObjectHashmap<Parallelepiped>()[id] = gobj;
     2982
     2983    sceneBoundsChanged();
     2984    _needsRedraw = true;
     2985    return true;
     2986}
     2987
     2988/**
    29402989 * \brief Create a new n-sided regular Polygon and associate it with an ID
    29412990 */
  • branches/blt4/packages/vizservers/vtkvis/Volume.cpp

    r3892 r3958  
    1414#include <vtkGPUVolumeRayCastMapper.h>
    1515#include <vtkVolumeTextureMapper3D.h>
     16#include <vtkRectilinearGrid.h>
     17#include <vtkStructuredGrid.h>
    1618#include <vtkUnstructuredGrid.h>
    1719#include <vtkPolyData.h>
     
    121123#endif
    122124        vtkVolumeMapper::SafeDownCast(_volumeMapper)->SetBlendModeToComposite();
    123     } else if (_dataSet->isCloud()) {
    124         // DataSet is a 3D point cloud
     125    } else if (_dataSet->isCloud() ||
     126               vtkUnstructuredGrid::SafeDownCast(ds) == NULL) {
     127        // DataSet is a 3D point cloud, rectilinear grid or structured grid
    125128        vtkSmartPointer<vtkGaussianSplatter> splatter = vtkSmartPointer<vtkGaussianSplatter>::New();
    126129#ifdef USE_VTK6
     
    131134        int dims[3];
    132135        dims[0] = dims[1] = dims[2] = 64;
    133         TRACE("Generating volume with dims (%d,%d,%d) from point cloud",
    134               dims[0], dims[1], dims[2]);
     136        if (vtkStructuredGrid::SafeDownCast(ds) != NULL) {
     137            vtkStructuredGrid::SafeDownCast(ds)->GetDimensions(dims);
     138        } else if (vtkRectilinearGrid::SafeDownCast(ds) != NULL) {
     139            vtkRectilinearGrid::SafeDownCast(ds)->GetDimensions(dims);
     140        }
     141        TRACE("Generating volume with dims (%d,%d,%d) from %d points",
     142              dims[0], dims[1], dims[2], ds->GetNumberOfPoints());
    135143        splatter->SetSampleDimensions(dims);
    136144        splatter->Update();
     
    144152        _volumeMapper->SetInputConnection(splatter->GetOutputPort());
    145153        vtkVolumeMapper::SafeDownCast(_volumeMapper)->SetBlendModeToComposite();
    146     } else if (vtkUnstructuredGrid::SafeDownCast(ds) != NULL) {
     154    } else {
    147155        // Unstructured grid with cells (not a cloud)
    148156        vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::SafeDownCast(ds);
     157        assert(ugrid != NULL);
    149158        // DataSet is unstructured grid
    150159        // Only works if cells are all tetrahedra
     
    177186        vtkUnstructuredGridVolumeMapper::SafeDownCast(_volumeMapper)->
    178187            SetBlendModeToComposite();
    179     } else {
    180         ERROR("Unsupported DataSet type: %s", _dataSet->getVtkType());
    181         _dataSet = NULL;
    182         return;
    183188    }
    184189
  • branches/blt4/packages/vizservers/vtkvis/protocol.txt

    r3892 r3958  
    685685outline scale <sx> <sy> <sz> <?datasetName?>
    686686outline visible <bool> <?datasetName?>
     687
     688parallelepiped add <v0x> <v0y> <v0z> <v1x> <v1y> <v1z> <v2x> <v2y> <v2z> <name>
     689               Specify parallelepiped using 3 basis vectors.  The 3 vectors should
     690               be given in order to create a right-handed coordinate system, i.e.
     691               (v0 cross v1) dot v2 should be positive.
     692parallelepiped color <r> <g> <b> <?name?>
     693parallelepiped culling <bool> <?name?>
     694parallelepiped delete <?name?>
     695parallelepiped edges <bool> <?name?>
     696parallelepiped flipnorm <bool> <?name?>
     697parallelepiped lighting <bool> <?name?>
     698parallelepiped linecolor <r> <g> <b> <?name?>
     699parallelepiped linewidth <val> <?name?>
     700parallelepiped material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     701parallelepiped opacity <val> <?name?>
     702parallelepiped orient <qw> <qx> <qy> <qz> <?name?>
     703parallelepiped origin <x> <y> <z> <?name?>
     704parallelepiped pos <x> <y> <z> <?name?>
     705parallelepiped scale <sx> <sy> <sz> <?name?>
     706parallelepiped shading <val> <?name?>
     707               val = flat|smooth
     708parallelepiped visible <bool> <?name?>
     709parallelepiped wireframe <bool> <?name?>
    687710
    688711polydata add <?datasetName?>
Note: See TracChangeset for help on using the changeset viewer.