Changeset 2877 for trunk/packages


Ignore:
Timestamp:
Mar 23, 2012 1:31:05 AM (12 years ago)
Author:
ldelgass
Message:

Some minor refactoring, also add some more fine grained config.h defines
(e.g. replace NV40 define with feature defines). Add tests for some required
OpenGL extensions (should always check for extensions or base version before
calling entry points from the extension). Also, clamp diffuse and specular
values on input and warn when they are out of range.

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

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/CircularQueue.h

    r2798 r2877  
    103103* It is up to the caller to handle this case
    104104*
    105 * \param item_ return by reference the wanted item
    106105* \return whether operation was successful or not */
    107106template<typename Element, unsigned int Size>
  • trunk/packages/vizservers/nanovis/Command.cpp

    r2854 r2877  
    259259    hmPtr = new HeightMap();
    260260    hmPtr->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, heights);
    261     hmPtr->transferFunction(NanoVis::get_transfunc("default"));
     261    hmPtr->transferFunction(NanoVis::getTransfunc("default"));
    262262    hmPtr->setVisible(true);
    263263    hmPtr->setLineContourVisible(true);
     
    607607}
    608608
    609 
    610609static int
    611610CameraPanOp(ClientData clientData, Tcl_Interp *interp, int objc,
     
    675674    int w, h;
    676675
    677     w = NanoVis::win_width, h = NanoVis::win_height;
    678     NanoVis::resize_offscreen_buffer(2048, 2048);
     676    w = NanoVis::winWidth, h = NanoVis::winHeight;
     677    NanoVis::resizeOffscreenBuffer(2048, 2048);
    679678#ifdef notdef
    680     NanoVis::cam->set_screen_size(0, 0, NanoVis::win_width,NanoVis::win_height);
     679    NanoVis::cam->set_screen_size(0, 0, NanoVis::winWidth, NanoVis::winHeight);
    681680    NanoVis::cam->set_screen_size(30, 90, 2048 - 60, 2048 - 120);
    682681#endif
    683     NanoVis::offscreen_buffer_capture();  //enable offscreen render
     682    NanoVis::offscreenBufferCapture();  //enable offscreen render
    684683    NanoVis::display();
    685     NanoVis::read_screen();
     684    NanoVis::readScreen();
    686685#ifdef notdef
    687686    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    688687#endif
    689     NanoVis::ppm_write("nv>image -bytes %d -type print");
    690     NanoVis::resize_offscreen_buffer(w, h);
     688    NanoVis::ppmWrite("nv>image -bytes %d -type print");
     689    NanoVis::resizeOffscreenBuffer(w, h);
    691690    return TCL_OK;
    692691}
     
    719718    std::vector<Volume *>::iterator iter;
    720719    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    721         (*iter)->move_cutplane(axis, relval);
     720        (*iter)->moveCutplane(axis, relval);
    722721    }
    723722    return TCL_OK;
     
    748747        std::vector<Volume *>::iterator iter;
    749748        for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    750             (*iter)->enable_cutplane(axis);
     749            (*iter)->enableCutplane(axis);
    751750        }
    752751    } else {
    753752        std::vector<Volume *>::iterator iter;
    754753        for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    755             (*iter)->disable_cutplane(axis);
     754            (*iter)->disableCutplane(axis);
    756755        }
    757756    }
     
    818817    name = Tcl_GetString(objv[1]);
    819818    TransferFunction *tf;
    820     tf = NanoVis::get_transfunc(name);
     819    tf = NanoVis::getTransfunc(name);
    821820    if (tf == NULL) {
    822821        Tcl_AppendResult(interp, "unknown transfer function \"", name, "\"",
     
    829828        return TCL_ERROR;
    830829    }
    831     if (Volume::update_pending) {
    832         NanoVis::SetVolumeRanges();
    833     }
    834     NanoVis::render_legend(tf, Volume::valueMin, Volume::valueMax, w, h, name);
     830    if (Volume::updatePending) {
     831        NanoVis::setVolumeRanges();
     832    }
     833    NanoVis::renderLegend(tf, Volume::valueMin, Volume::valueMax, w, h, name);
    835834    return TCL_OK;
    836835}
     
    860859        return TCL_ERROR;
    861860    }
    862     NanoVis::resize_offscreen_buffer(w, h);
     861    NanoVis::resizeOffscreenBuffer(w, h);
    863862    return TCL_OK;
    864863}
     
    964963        }
    965964        // find or create this transfer function
    966         NanoVis::DefineTransferFunction(Tcl_GetString(objv[2]), nslots, data);
     965        NanoVis::defineTransferFunction(Tcl_GetString(objv[2]), nslots, data);
    967966    } else {
    968967        Tcl_AppendResult(interp, "bad option \"", string,
     
    10101009    }
    10111010    VolumeInterpolator* interpolator;
    1012     interpolator = NanoVis::vol_renderer->getVolumeInterpolator();
     1011    interpolator = NanoVis::volRenderer->getVolumeInterpolator();
    10131012    interpolator->start();
    1014     if (interpolator->is_started()) {
     1013    if (interpolator->isStarted()) {
    10151014        const char *fileName = (objc < 5) ? NULL : Tcl_GetString(objv[4]);
    10161015        for (int frame_num = 0; frame_num < total; ++frame_num) {
     
    10221021            interpolator->update(fraction);
    10231022
    1024             NanoVis::offscreen_buffer_capture();  //enable offscreen render
     1023            NanoVis::offscreenBufferCapture();  //enable offscreen render
    10251024
    10261025            NanoVis::display();
    1027             NanoVis::read_screen();
     1026            NanoVis::readScreen();
    10281027
    10291028            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    10301029
    1031             NanoVis::bmp_write_to_file(frame_num, fileName);
     1030            NanoVis::bmpWriteToFile(frame_num, fileName);
    10321031        }
    10331032    }
     
    10391038                       Tcl_Obj *const *objv)
    10401039{
    1041     NanoVis::vol_renderer->clearAnimatedVolumeInfo();
     1040    NanoVis::volRenderer->clearAnimatedVolumeInfo();
    10421041    return TCL_OK;
    10431042}
     
    10471046                       Tcl_Obj *const *objv)
    10481047{
    1049     NanoVis::vol_renderer->startVolumeAnimation();
     1048    NanoVis::volRenderer->startVolumeAnimation();
    10501049    return TCL_OK;
    10511050}
     
    10551054                      Tcl_Obj *const *objv)
    10561055{
    1057     NanoVis::vol_renderer->stopVolumeAnimation();
     1056    NanoVis::volRenderer->stopVolumeAnimation();
    10581057    return TCL_OK;
    10591058}
     
    10741073        Volume *volPtr;
    10751074        volPtr = (Volume *)Tcl_GetHashValue(hPtr);
    1076         NanoVis::vol_renderer->addAnimatedVolume(volPtr);
     1075        NanoVis::volRenderer->addAnimatedVolume(volPtr);
    10771076    }
    10781077    return TCL_OK;
     
    11901189    //
    11911190    if (volPtr != NULL) {
    1192         //volPtr->n_slices(512-n);
    1193         //volPtr->n_slices(256-n);
    1194         volPtr->disable_cutplane(0);
    1195         volPtr->disable_cutplane(1);
    1196         volPtr->disable_cutplane(2);
    1197         volPtr->transferFunction(NanoVis::get_transfunc("default"));
     1191        //volPtr->numSlices(512-n);
     1192        //volPtr->numSlices(256-n);
     1193        volPtr->disableCutplane(0);
     1194        volPtr->disableCutplane(1);
     1195        volPtr->disableCutplane(2);
     1196        volPtr->transferFunction(NanoVis::getTransfunc("default"));
    11981197        volPtr->visible(true);
    11991198
     
    12011200        ssize_t nWritten;
    12021201
    1203         if (Volume::update_pending) {
    1204             NanoVis::SetVolumeRanges();
     1202        if (Volume::updatePending) {
     1203            NanoVis::setVolumeRanges();
    12051204        }
    12061205
     
    12291228    std::vector<Volume *>::iterator iter;
    12301229    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1231         (*iter)->data_enabled(state);
     1230        (*iter)->dataEnabled(state);
    12321231    }
    12331232    return TCL_OK;
     
    12741273            return TCL_ERROR;
    12751274        }
    1276         NanoVis::remove_volume(volPtr);
    1277     }
    1278     NanoVis::EventuallyRedraw();
     1275        NanoVis::removeVolume(volPtr);
     1276    }
     1277    NanoVis::eventuallyRedraw();
    12791278    return TCL_OK;
    12801279}
     
    13451344    std::vector<Volume *>::iterator iter;
    13461345    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1347         (*iter)->set_outline_color(rgb);
     1346        (*iter)->setOutlineColor(rgb);
    13481347    }
    13491348    return TCL_OK;
     
    13991398        return TCL_ERROR;
    14001399    }
    1401 
     1400    if (diffuse < 0.0f || diffuse > 1.0f) {
     1401        WARN("Invalid diffuse coefficient requested: %g, should be [0,1]", diffuse);
     1402    }
    14021403    std::vector<Volume *> ivol;
    14031404    if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
     
    14461447    std::vector<Volume *>::iterator iter;
    14471448    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1448         (*iter)->opacity_scale(opacity);
     1449        (*iter)->opacityScale(opacity);
    14491450    }
    14501451    return TCL_OK;
     
    14581459    if (GetFloatFromObj(interp, objv[3], &specular) != TCL_OK) {
    14591460        return TCL_ERROR;
     1461    }
     1462    if (specular < 0.0f || specular > 128.0f) {
     1463        WARN("Invalid specular exponent requested: %g, should be [0,128]", specular);
    14601464    }
    14611465    std::vector<Volume *> ivol;
     
    14761480    TransferFunction *tfPtr;
    14771481    const char *name = Tcl_GetString(objv[3]);
    1478     tfPtr = NanoVis::get_transfunc(name);
     1482    tfPtr = NanoVis::getTransfunc(name);
    14791483    if (tfPtr == NULL) {
    14801484        Tcl_AppendResult(interp, "transfer function \"", name,
     
    14931497#ifdef USE_POINTSET_RENDERER
    14941498        // TBD..
    1495  //        if ((*iter)->pointsetIndex != -1) {
    1496 //             NanoVis::pointSet[(*iter)->pointsetIndex]->updateColor(tf->getData(), 256);
    1497 //         }
     1499        if ((*iter)->pointsetIndex != -1) {
     1500            NanoVis::pointSet[(*iter)->pointsetIndex]->updateColor(tfPtr->getData(), 256);
     1501        }
    14981502#endif
    14991503    }
     
    15441548        label = Tcl_GetString(objv[4]);
    15451549        for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1546             (*iter)->set_label(axis, label);
     1550            (*iter)->setLabel(axis, label);
    15471551        }
    15481552    } else {
     
    15841588        Volume *volPtr;
    15851589        volPtr = (Volume *)Tcl_GetHashValue(hPtr);
    1586         volPtr->data_enabled(false);
     1590        volPtr->dataEnabled(false);
    15871591        volPtr->visible(false);
    15881592    }
     
    16801684    hmPtr->setHeight(data.xMin(), data.yMin(), data.xMax(), data.yMax(),
    16811685                     data.xNum(), data.yNum(), data.transferValues());
    1682     hmPtr->transferFunction(NanoVis::get_transfunc("default"));
     1686    hmPtr->transferFunction(NanoVis::getTransfunc("default"));
    16831687    hmPtr->setVisible(true);
    16841688    hmPtr->setLineContourVisible(true);
    1685     NanoVis::EventuallyRedraw();
     1689    NanoVis::eventuallyRedraw();
    16861690    return TCL_OK;
    16871691}
     
    17031707        (*iter)->setVisible(visible);
    17041708    }
    1705     NanoVis::EventuallyRedraw();
     1709    NanoVis::eventuallyRedraw();
    17061710    return TCL_OK;
    17071711}
     
    17441748        (*iter)->setLineContourColor(rgb);
    17451749    }
    1746     NanoVis::EventuallyRedraw();
     1750    NanoVis::eventuallyRedraw();
    17471751    return TCL_OK;
    17481752}
     
    17641768        (*iter)->setLineContourVisible(visible);
    17651769    }
    1766     NanoVis::EventuallyRedraw();
     1770    NanoVis::eventuallyRedraw();
    17671771    return TCL_OK;
    17681772}
     
    17971801    }
    17981802    NanoVis::renderContext->setCullMode(mode);
    1799     NanoVis::EventuallyRedraw();
     1803    NanoVis::eventuallyRedraw();
    18001804    return TCL_OK;
    18011805}
     
    18231827    Tcl_SetHashValue(hPtr, hmPtr);
    18241828    Tcl_SetStringObj(Tcl_GetObjResult(interp), tag, -1);;
    1825     NanoVis::EventuallyRedraw();
     1829    NanoVis::eventuallyRedraw();
    18261830    TRACE("Number of heightmaps=%d\n", NanoVis::heightmapTable.numEntries);
    18271831    return TCL_OK;
     
    18501854        return TCL_ERROR;
    18511855    }
    1852     if (HeightMap::update_pending) {
    1853         NanoVis::SetHeightmapRanges();
    1854     }
    1855     NanoVis::render_legend(tfPtr, HeightMap::valueMin, HeightMap::valueMax,
    1856                 w, h, tag);
     1856    if (HeightMap::updatePending) {
     1857        NanoVis::setHeightmapRanges();
     1858    }
     1859    NanoVis::renderLegend(tfPtr, HeightMap::valueMin, HeightMap::valueMax,
     1860                          w, h, tag);
    18571861    return TCL_OK;
    18581862}
     
    18671871    }
    18681872    NanoVis::renderContext->setPolygonMode(mode);
    1869     NanoVis::EventuallyRedraw();
     1873    NanoVis::eventuallyRedraw();
    18701874    return TCL_OK;
    18711875}
     
    18801884    }
    18811885    NanoVis::renderContext->setShadingModel(model);
    1882     NanoVis::EventuallyRedraw();
     1886    NanoVis::eventuallyRedraw();
    18831887    return TCL_OK;
    18841888}
     
    18981902    // GEORGE
    18991903
    1900     NanoVis::render_2d_contour(heightmap, image_width, image_height);
    1901     NanoVis::EventuallyRedraw();
     1904    NanoVis::render2dContour(heightmap, image_width, image_height);
     1905    NanoVis::eventuallyRedraw();
    19021906    return TCL_OK;
    19031907}
     
    19291933    float maxy = 3.5f;
    19301934    hmPtr->setHeight(minx, miny, maxx, maxy, 20, 20, data);
    1931     hmPtr->transferFunction(NanoVis::get_transfunc("default"));
     1935    hmPtr->transferFunction(NanoVis::getTransfunc("default"));
    19321936    hmPtr->setVisible(true);
    19331937    hmPtr->setLineContourVisible(true);
     
    19451949    int image_height = 512;
    19461950
    1947     NanoVis::render_2d_contour(hmPtr, image_width, image_height);
     1951    NanoVis::render2dContour(hmPtr, image_width, image_height);
    19481952
    19491953    return TCL_OK;
     
    19571961    name = Tcl_GetString(objv[2]);
    19581962    TransferFunction *tfPtr;
    1959     tfPtr = NanoVis::get_transfunc(name);
     1963    tfPtr = NanoVis::getTransfunc(name);
    19601964    if (tfPtr == NULL) {
    19611965        Tcl_AppendResult(interp, "transfer function \"", name,
     
    19711975        (*iter)->transferFunction(tfPtr);
    19721976    }
    1973     NanoVis::EventuallyRedraw();
     1977    NanoVis::eventuallyRedraw();
    19741978    return TCL_OK;
    19751979}
     
    19921996        (*iter)->opacity(opacity);
    19931997    }
    1994     NanoVis::EventuallyRedraw();
     1998    NanoVis::eventuallyRedraw();
    19951999    return TCL_OK;
    19962000}
     
    21422146            return TCL_ERROR;
    21432147        }
    2144         NanoVis::axis_on = visible;
     2148        NanoVis::axisOn = visible;
    21452149    } else {
    21462150        Tcl_AppendResult(interp, "bad axis option \"", string,
  • trunk/packages/vizservers/nanovis/ContourLineFilter.h

    r2827 r2877  
    1616    {
    1717    public:
    18         float _value;
    19         std::list<Vector3> _points;
    20 
    2118        ContourLine(float value);
    2219
    2320        /**
    24          * @brief
    25          * @ret Returns the number of points
     21         * @return Returns the number of points
    2622         */
    2723        int createLine(int width, int height, Vector3 *vertices, bool top);
    2824        int createLine(int width, int height, Vector4 *vertices, bool top);
     25
     26        float _value;
     27        std::list<Vector3> _points;
    2928
    3029    private:
  • trunk/packages/vizservers/nanovis/ConvexPolygon.cpp

    r2870 r2877  
    100100
    101101void
    102 ConvexPolygon::clip(Plane& clipPlane, bool copy_to_texcoord)
     102ConvexPolygon::clip(Plane& clipPlane, bool copyToTexcoord)
    103103{
    104104    if (vertices.size() == 0) {
     
    123123    Vector4 plane = clipPlane.get_coeffs();
    124124
    125     bool prevRetained = is_retained(vertices[0], plane);
     125    bool prevRetained = isRetained(vertices[0], plane);
    126126    if (prevRetained)
    127127        clippedVerts.push_back(vertices[0]);
    128128
    129129    for (unsigned int i = 1; i < vertices.size(); i++) {
    130         bool retained = is_retained(vertices[i], plane);
     130        bool retained = isRetained(vertices[i], plane);
    131131        if (retained != prevRetained) {
    132132            bool found = findIntersection(vertices[i - 1], vertices[i],
     
    141141    }
    142142
    143     bool retained = is_retained(vertices[0], plane);
     143    bool retained = isRetained(vertices[0], plane);
    144144    if (retained != prevRetained) {
    145145        bool found = findIntersection(vertices[vertices.size() - 1],
     
    154154                    clippedVerts.end());
    155155
    156     if (copy_to_texcoord)
    157         copy_vertices_to_texcoords();
    158 }
    159 
    160 void
    161 ConvexPolygon::copy_vertices_to_texcoords()
     156    if (copyToTexcoord)
     157        copyVerticesToTexcoords();
     158}
     159
     160void
     161ConvexPolygon::copyVerticesToTexcoords()
    162162{
    163163    if (texcoords.size() > 0)
     
    170170
    171171void
    172 ConvexPolygon::Emit(bool use_texture)
     172ConvexPolygon::emit(bool useTexture)
    173173{
    174174    if (vertices.size() >= 3) {
    175175        for (unsigned int i = 0; i < vertices.size(); i++) {
    176             if (use_texture) {
     176            if (useTexture) {
    177177                glTexCoord4fv((float *)&(texcoords[i]));
    178178                //glTexCoord4fv((float *)&(vertices[i]));
     
    184184
    185185void
    186 ConvexPolygon::Emit(bool use_texture, const Vector3& shift, const Vector3& scale)
     186ConvexPolygon::emit(bool useTexture, const Vector3& shift, const Vector3& scale)
    187187{
    188188    if (vertices.size() >= 3) {
    189189        for (unsigned int i = 0; i < vertices.size(); i++) {
    190             if (use_texture) {
     190            if (useTexture) {
    191191                glTexCoord4fv((float *)&(vertices[i]));
    192192            }
  • trunk/packages/vizservers/nanovis/ConvexPolygon.h

    r2822 r2877  
    2929{
    3030public:
    31     VertexVector vertices;
    32     TexVector texcoords;
    33     int volume_id;      //which volume this polygon slice belongs to
    34 
    3531    ConvexPolygon()
    3632    {}
     
    4339
    4440    // Clips the polygon, retaining the portion where ax + by + cz + d >= 0
    45     void clip(Plane& clipPlane, bool copy_to_texcoords);
     41    void clip(Plane& clipPlane, bool copyToTexcoords);
    4642
    47     void Emit(bool use_texture);
     43    void emit(bool useTexture);
    4844
    49     void Emit(bool use_texture, const Vector3& shift, const Vector3& scale);
     45    void emit(bool useTexture, const Vector3& shift, const Vector3& scale);
    5046
    51     void copy_vertices_to_texcoords();
     47    void copyVerticesToTexcoords();
    5248
    53     void set_id(int v_id)
     49    void setId(int id)
    5450    {
    55         volume_id = v_id;
     51        volumeId = id;
    5652    }
    5753
    58     void append_vertex(const Vector4& vert)
     54    void appendVertex(const Vector4& vert)
    5955    {
    6056        vertices.push_back(vert);
    6157    }
    6258
    63     void insert_vertex(unsigned int index, const Vector4& vert)
     59    void insertVertex(unsigned int index, const Vector4& vert)
    6460    {
    65         assert(index<vertices.size());
     61        assert(index < vertices.size());
    6662        vertices.insert(vertices.begin() + index, vert);
    6763    }
    6864
    69     bool is_retained(const Vector4& point, const Vector4& plane)
     65    bool isRetained(const Vector4& point, const Vector4& plane)
    7066    {
    7167        return ((point * plane) >= 0); 
    7268    }
     69
     70    VertexVector vertices;
     71    TexVector texcoords;
     72    int volumeId;       //which volume this polygon slice belongs to
    7373};
    7474
  • trunk/packages/vizservers/nanovis/FlowCmd.cpp

    r2875 r2877  
    3434#include "Unirect.h"
    3535#include "VelocityArrowsSlice.h"
     36#include "Volume.h"
    3637
    3738#define RELPOS 0
     
    294295    memset(&_sv, 0, sizeof(FlowValues));
    295296    _sv.sliceVisible = 1;
    296     _sv.tfPtr = NanoVis::get_transfunc("default");
     297    _sv.tfPtr = NanoVis::getTransfunc("default");
    297298
    298299    Tcl_InitHashTable(&_particlesTable, TCL_STRING_KEYS);
     
    317318    }
    318319    if (_volPtr != NULL) {
    319         NanoVis::remove_volume(_volPtr);
     320        NanoVis::removeVolume(_volPtr);
    320321        _volPtr = NULL;
    321322    }
     
    530531    if (_volPtr != NULL) {
    531532        TRACE("from ScaleVectorField volId=%s\n", _volPtr->name());
    532         NanoVis::remove_volume(_volPtr);
     533        NanoVis::removeVolume(_volPtr);
    533534        _volPtr = NULL;
    534535    }
     
    575576        NanoVis::licRenderer->
    576577            setVectorField(_volPtr->id, loc,
    577                            1.0f / _volPtr->aspect_ratio_width,
    578                            1.0f / _volPtr->aspect_ratio_height,
    579                            1.0f / _volPtr->aspect_ratio_depth,
     578                           1.0f / _volPtr->aspectRatioWidth,
     579                           1.0f / _volPtr->aspectRatioHeight,
     580                           1.0f / _volPtr->aspectRatioDepth,
    580581                           _volPtr->wAxis.max());
    581582        SetCurrentPosition();
     
    589590                        //*(volPtr->get_location()),
    590591                        1.0f,
    591                         _volPtr->aspect_ratio_height / _volPtr->aspect_ratio_width,
    592                         _volPtr->aspect_ratio_depth / _volPtr->aspect_ratio_width
     592                        _volPtr->aspectRatioHeight / _volPtr->aspectRatioWidth,
     593                        _volPtr->aspectRatioDepth / _volPtr->aspectRatioWidth
    593594                        //,volPtr->wAxis.max()
    594595                        );
     
    657658    Volume *volPtr;
    658659
    659     volPtr = NanoVis::load_volume(_name, _dataPtr->xNum(), _dataPtr->yNum(),
    660                                   _dataPtr->zNum(), 4, data,
    661                                   NanoVis::magMin, NanoVis::magMax, 0);
     660    volPtr = NanoVis::loadVolume(_name, _dataPtr->xNum(), _dataPtr->yNum(),
     661                                 _dataPtr->zNum(), 4, data,
     662                                 NanoVis::magMin, NanoVis::magMax, 0);
    662663    volPtr->xAxis.SetRange(_dataPtr->xMin(), _dataPtr->xMax());
    663664    volPtr->yAxis.SetRange(_dataPtr->yMin(), _dataPtr->yMax());
     
    672673          NanoVis::magMin, NanoVis::magMax);
    673674    volPtr->setPhysicalBBox(physicalMin, physicalMax);
    674     //volPtr->set_n_slice(256 - _volIndex);
    675     // volPtr->set_n_slice(512- _volIndex);
    676     //volPtr->n_slices(256-n);
     675    //volPtr->numSlices(256 - _volIndex);
     676    //volPtr->numSlices(512 - _volIndex);
     677    //volPtr->numSlices(256 - n);
    677678    // TBD..
    678679    /* Don't set the slice number until we're are about to render the
    679680       volume. */
    680     volPtr->disable_cutplane(0);
    681     volPtr->disable_cutplane(1);
    682     volPtr->disable_cutplane(2);
     681    volPtr->disableCutplane(0);
     682    volPtr->disableCutplane(1);
     683    volPtr->disableCutplane(2);
    683684
    684685    /* Initialize the volume with the previously configured values. */
    685686    volPtr->transferFunction(_sv.tfPtr);
    686     volPtr->data_enabled(_sv.showVolume);
     687    volPtr->dataEnabled(_sv.showVolume);
    687688    volPtr->outline(_sv.showOutline);
    688     volPtr->opacity_scale(_sv.opacity);
     689    volPtr->opacityScale(_sv.opacity);
    689690    volPtr->specular(_sv.specular);
    690691    volPtr->diffuse(_sv.diffuse);
     
    695696    float dz0 = -0.5*volPtr->depth/volPtr->width;
    696697    volPtr->location(Vector3(dx0, dy0, dz0));
    697     Volume::update_pending = true;
     698    Volume::updatePending = true;
    698699    return volPtr;
    699700}
     
    765766    }
    766767    flowPtr->data(dataPtr);
    767     NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     768    NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
    768769    return TCL_OK;
    769770}
     
    857858        assert(nWritten == (ssize_t)strlen(info));
    858859    }
    859     NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     860    NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
    860861    return TCL_OK;
    861862}
     
    13311332    TransferFunction **funcPtrPtr = (TransferFunction **)(record + offset);
    13321333    TransferFunction *funcPtr;
    1333     funcPtr = NanoVis::get_transfunc(Tcl_GetString(objPtr));
     1334    funcPtr = NanoVis::getTransfunc(Tcl_GetString(objPtr));
    13341335    if (funcPtr == NULL) {
    13351336        Tcl_AppendResult(interp, "transfer function \"", Tcl_GetString(objPtr),
     
    13501351        return TCL_ERROR;
    13511352    }
    1352     NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     1353    NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
    13531354    return TCL_OK;
    13541355}
     
    13721373    }
    13731374    particlesPtr->Configure();
    1374     NanoVis::EventuallyRedraw();
     1375    NanoVis::eventuallyRedraw();
    13751376    Tcl_SetObjResult(interp, objv[3]);
    13761377    return TCL_OK;
     
    13911392    }
    13921393    particlesPtr->Configure();
    1393     NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     1394    NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
    13941395    return TCL_OK;
    13951396}
     
    14081409        }
    14091410    }
    1410     NanoVis::EventuallyRedraw();
     1411    NanoVis::eventuallyRedraw();
    14111412    return TCL_OK;
    14121413}
     
    14861487        return TCL_ERROR;
    14871488    }
    1488     NanoVis::EventuallyRedraw();
     1489    NanoVis::eventuallyRedraw();
    14891490    Tcl_SetObjResult(interp, objv[3]);
    14901491    return TCL_OK;
     
    15041505        }
    15051506    }
    1506     NanoVis::EventuallyRedraw();
     1507    NanoVis::eventuallyRedraw();
    15071508    return TCL_OK;
    15081509}
     
    15411542        return TCL_ERROR;
    15421543    }
    1543     NanoVis::EventuallyRedraw();
     1544    NanoVis::eventuallyRedraw();
    15441545    return TCL_OK;
    15451546}
     
    16131614        NanoVis::MapFlows();
    16141615    }
    1615     NanoVis::render_legend(tf, NanoVis::magMin, NanoVis::magMax, w, h, label);
     1616    NanoVis::renderLegend(tf, NanoVis::magMin, NanoVis::magMax, w, h, label);
    16161617    return TCL_OK;
    16171618}
     
    16811682    }
    16821683    Tcl_SetObjResult(interp, objv[2]);
    1683     NanoVis::EventuallyRedraw();
     1684    NanoVis::eventuallyRedraw();
    16841685    return TCL_OK;
    16851686}
     
    16991700        Tcl_DeleteCommand(interp, flowPtr->name());
    17001701    }
    1701     NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     1702    NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
    17021703    return TCL_OK;
    17031704}
     
    17461747        NanoVis::AdvectFlows();
    17471748    }
    1748     NanoVis::EventuallyRedraw();
     1749    NanoVis::eventuallyRedraw();
    17491750    return TCL_OK;
    17501751}
     
    17771778        NanoVis::MapFlows();
    17781779    }
    1779     NanoVis::EventuallyRedraw();
     1780    NanoVis::eventuallyRedraw();
    17801781    NanoVis::licRenderer->convolve();
    17811782    NanoVis::AdvectFlows();
     
    18801881    values.frameRate = 25.0f;                // Default frame rate 25 fps
    18811882    values.bitRate = 6000000;                // Default video bit rate.
    1882     values.width = NanoVis::win_width;
    1883     values.height = NanoVis::win_height;
     1883    values.width = NanoVis::winWidth;
     1884    values.height = NanoVis::winHeight;
    18841885    values.nFrames = 100;
    18851886    values.format = Rappture::AVTranslate::MPEG1;
     
    19071908    // Save the old dimensions of the offscreen buffer.
    19081909    int oldWidth, oldHeight;
    1909     oldWidth = NanoVis::win_width;
    1910     oldHeight = NanoVis::win_height;
     1910    oldWidth = NanoVis::winWidth;
     1911    oldHeight = NanoVis::winHeight;
    19111912
    19121913    TRACE("FLOW started\n");
     
    19261927    if ((values.width != oldWidth) || (values.height != oldHeight)) {
    19271928        // Resize to the requested size.
    1928         NanoVis::resize_offscreen_buffer(values.width, values.height);
     1929        NanoVis::resizeOffscreenBuffer(values.width, values.height);
    19291930    }
    19301931    // Now compute the line padding for the offscreen buffer.
     
    19461947        }
    19471948        NanoVis::AdvectFlows();
    1948         NanoVis::offscreen_buffer_capture();
     1949        NanoVis::offscreenBufferCapture();
    19491950        NanoVis::display();
    1950         NanoVis::read_screen();
     1951        NanoVis::readScreen();
    19511952        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    1952         movie.append(context, NanoVis::screen_buffer, pad);
     1953        movie.append(context, NanoVis::screenBuffer, pad);
    19531954    }
    19541955    movie.done(context);
     
    19711972    }
    19721973    if ((values.width != oldWidth) || (values.height != oldHeight)) {
    1973         NanoVis::resize_offscreen_buffer(oldWidth, oldHeight);
     1974        NanoVis::resizeOffscreenBuffer(oldWidth, oldHeight);
    19741975    }
    19751976    NanoVis::ResetFlows();
  • trunk/packages/vizservers/nanovis/GradientFilter.cpp

    r2870 r2877  
    1515
    1616static int g_numOfSlices[3] = { 256, 256, 256 };
    17 static void *g_volData = 0;
     17static void *g_volData = NULL;
    1818static float g_sliceDists[3];
    1919
     
    2323#define MAX(a,b) ((a) > (b) ? (a) : (b))
    2424#define MIN(a,b) ((a) < (b) ? (a) : (b))
    25 #define EPS 1e-5f
     25#define EPS 1e-6f
    2626
    2727#ifdef notused
     
    145145}
    146146
    147 void computeGradients(float *gradients, void* volData, int *sizes, DataType dataType)
     147void computeGradients(float *gradients, void *volData, int *sizes,
     148                      float *spacing, DataType dataType)
    148149{
    149150    ::g_volData = volData;
     
    152153    g_numOfSlices[2] = sizes[2];
    153154
    154     g_sliceDists[0] = 1.0f / sizes[0];
    155     g_sliceDists[1] = 1.0f / sizes[1];
    156     g_sliceDists[2] = 1.0f / sizes[2];
     155    g_sliceDists[0] = spacing[0];
     156    g_sliceDists[1] = spacing[1];
     157    g_sliceDists[2] = spacing[2];
    157158
    158159    int i, j, k, dir, di, vdi, idz, idy, idx;
  • trunk/packages/vizservers/nanovis/GradientFilter.h

    r2844 r2877  
    99} DataType;
    1010
    11 extern void computeGradients(float *gradients, void *volData, int *sizes, DataType dataType);
     11extern void computeGradients(float *gradients, void *volData,
     12                             int *sizes, float *spacing, DataType dataType);
    1213
    1314extern void filterGradients(float *gradients, int *sizes);
  • trunk/packages/vizservers/nanovis/HeightMap.cpp

    r2870 r2877  
    1919#include "RenderContext.h"
    2020
    21 bool HeightMap::update_pending = false;
     21bool HeightMap::updatePending = false;
    2222double HeightMap::valueMin = 0.0;
    2323double HeightMap::valueMax = 1.0;
     
    260260
    261261void
    262 HeightMap::setHeight(int xCount, int yCount, Vector3* heights)
     262HeightMap::setHeight(int xCount, int yCount, Vector3 *heights)
    263263{
    264264    _vertexCount = xCount * yCount;
    265265    reset();
    266    
    267     _heights = (float *)heights; 
     266
     267    _heights = (float *)heights;
    268268    float min, max;
    269269    min = heights[0].y, max = heights[0].y;
     
    287287    zAxis.SetRange(0.0, 1.0);
    288288    wAxis.SetRange(min, max);
    289     update_pending = true;
    290    
     289    updatePending = true;
     290
    291291    _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + min, _scale.y * 0.5);
    292292
     
    334334void
    335335HeightMap::setHeight(float xMin, float yMin, float xMax, float yMax,
    336                      int xNum, int yNum, float* heights)
     336                     int xNum, int yNum, float *heights)
    337337{
    338338    _vertexCount = xNum * yNum;
     
    376376    _scale.x = _scale.y = _scale.z = 1.0;
    377377
    378     update_pending = true;
     378    updatePending = true;
    379379
    380380    _centerPoint.set(0.5, 0.5, 0.5);
     
    420420}
    421421
    422 Vector3*
     422Vector3 *
    423423HeightMap::createHeightVertices(float xMin, float yMin, float xMax,
    424                                 float yMax, int xNum, int yNum, float* height)
     424                                float yMax, int xNum, int yNum, float *height)
    425425{
    426426    Vector3* vertices = new Vector3[xNum * yNum];
  • trunk/packages/vizservers/nanovis/HeightMap.h

    r2870 r2877  
    2020
    2121/**
    22  *@class HeightMap
    2322 *@brief Create a surface from height map and line contour of the generated surface
    2423 */
     
    123122
    124123    AxisRange xAxis, yAxis, zAxis, wAxis;
    125     static bool update_pending;
     124    static bool updatePending;
    126125    static double valueMin, valueMax;
    127126
  • trunk/packages/vizservers/nanovis/NvCamera.cpp

    r2854 r2877  
    1919#include <GL/glew.h>
    2020#include <GL/glu.h>
     21
     22#include <vrmath/vrQuaternion.h>
     23#include <vrmath/vrRotation.h>
     24#include <vrmath/vrMatrix4x4f.h>
    2125
    2226#include "NvCamera.h"
     
    6165    glLoadIdentity();
    6266
     67#ifndef OLD_CAMERA
     68    glTranslatef(-_location.x, -_location.y, -_location.z);
     69    glMultMatrixf((const GLfloat *)_cameraMatrix.get());
     70#else
     71
    6372    gluLookAt(_location.x, _location.y, _location.z,
    6473              _target.x, _target.y, _target.z,
    6574              0., 1., 0.);
    6675
    67     glRotated(_angle.x, 1., 0., 0.);
    68     glRotated(_angle.y, 0., 1., 0.);
    69     glRotated(_angle.z, 0., 0., 1.);
     76    if (_angle.x != 0.0f)
     77        glRotated(_angle.x, 1., 0., 0.);
     78    if (_angle.y != 0.0f)
     79        glRotated(_angle.y, 0., 1., 0.);
     80    if (_angle.z != 0.0f)
     81        glRotated(_angle.z, 0., 0., 1.);
     82#endif
    7083}
     84
     85void NvCamera::rotate(double *quat)
     86{
     87    vrQuaternion q(quat[0], quat[1], quat[2], quat[3]);
     88    vrRotation rot;
     89    rot.set(q);
     90    _cameraMatrix.makeRotation(rot);
     91    _cameraMatrix.transpose();
     92    _angle.set(0, 0, 0);
     93    TRACE("Set rotation to quat: %g %g %g %g\n",
     94          quat[0], quat[1], quat[2], quat[3]);
     95}
     96
     97void NvCamera::rotate(float angle_x, float angle_y, float angle_z)
     98{
     99#ifdef OLD_CAMERA
     100    _angle = Vector3(angle_x, angle_y, angle_z);
     101#else
     102    angle_x = -angle_x;
     103    angle_y = angle_y - 180.;
     104    _angle = Vector3(angle_x, angle_y, angle_z);
     105
     106    _cameraMatrix.makeRotation(1, 0, 0, deg2rad(_angle.x));
     107    vrMatrix4x4f mat;
     108    mat.makeRotation(0, 1, 0, deg2rad(_angle.y));
     109    _cameraMatrix.multiply(mat);
     110    mat.makeRotation(0, 0, 1, deg2rad(_angle.z));
     111    _cameraMatrix.multiply(mat);
     112    //_cameraMatrix.transpose();
     113#endif
     114    TRACE("Set rotation to angles: %g %g %g\n",
     115          _angle.x, _angle.y, _angle.z);
     116}
     117
     118void NvCamera::rotate(const Vector3& angle)
     119{
     120#ifdef OLD_CAMERA
     121    _angle = angle;
     122#else
     123    _angle.x = -angle.x;
     124    _angle.y = angle.y - 180.;
     125    _angle.z = angle.z;
     126
     127    _cameraMatrix.makeRotation(1, 0, 0, deg2rad(_angle.x));
     128    vrMatrix4x4f mat;
     129    mat.makeRotation(0, 1, 0, deg2rad(_angle.y));
     130    _cameraMatrix.multiply(mat);
     131    mat.makeRotation(0, 0, 1, deg2rad(_angle.z));
     132    _cameraMatrix.multiply(mat);
     133    //_cameraMatrix.transpose();
     134#endif
     135    TRACE("Set rotation to angles: %g %g %g\n",
     136          _angle.x, _angle.y, _angle.z);
     137}
  • trunk/packages/vizservers/nanovis/NvCamera.h

    r2854 r2877  
    1717#define CAMERA_H
    1818
     19#include <vrmath/vrMatrix4x4f.h>
     20
     21#include "config.h"
    1922#include "Vector3.h"
    2023
     
    2932    ~NvCamera()
    3033    {}
    31 
    3234
    3335    //move location of camera
     
    9395    }
    9496
    95     void rotate(float angle_x, float angle_y, float angle_z)
    96     {
    97         _angle = Vector3(angle_x, angle_y, angle_z);
    98     }
     97    void rotate(double *quat);
    9998
    100     void rotate(const Vector3& angle)
    101     {
    102         _angle = angle;
    103     }
     99    void rotate(float angle_x, float angle_y, float angle_z);
     100
     101    void rotate(const Vector3& angle);
    104102
    105103    Vector3 rotate() const
     
    117115
    118116    /**
    119      * \brief make the camera setting active, this has to be
     117     * \brief Make the camera setting active, this has to be
    120118     * called before drawing things
    121119     */
     
    133131    /// rotation angles of camera along x, y, z
    134132    Vector3 _angle;
     133
     134    vrMatrix4x4f _cameraMatrix;
     135
    135136    /// screen width
    136137    int _width;
  • trunk/packages/vizservers/nanovis/NvFlowVisRenderer.h

    r2870 r2877  
    5151    /**
    5252     * @brief Specify the axis of the index plane
    53      * @param index the index of the array of injection planes
    5453     */
    5554    void setPlaneAxis(const std::string& vfName, const std::string& name, int axis);
    5655
    5756    /**
    58      * @param pos : Specify the position of slice
     57     * @param pos Specify the position of slice
    5958     */
    6059    void setPlanePos(const std::string& vfName, const std::string& name, float pos);
  • trunk/packages/vizservers/nanovis/NvRegularVolumeShader.cpp

    r2870 r2877  
    4040    if (!sliceMode) {
    4141        cgGLSetParameter4f(_render_param_one_volume_param,
    42             volume->n_slices(),
    43             volume->opacity_scale(),
     42            volume->numSlices(),
     43            volume->opacityScale(),
    4444            volume->diffuse(),
    4545            volume->specular());
     
    4747        cgGLSetParameter4f(_render_param_one_volume_param,
    4848            0.,
    49             volume->opacity_scale(),
     49            volume->opacityScale(),
    5050            volume->diffuse(),
    5151            volume->specular());
  • trunk/packages/vizservers/nanovis/NvShader.cpp

    r2870 r2877  
    9999void NvShader::setErrorCallback(NvCgCallbackFunction callback)
    100100{
    101     TRACE("NvShader error callback: %p\n", callback);
     101    TRACE("NvShader setting error callback to: %p\n", callback);
    102102    cgSetErrorCallback(callback);
    103103}
  • trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.h

    r2844 r2877  
    3737    /**
    3838     * @brief Load Zinc blende binary volume data and create ZincBlendeVolume with the file
    39      * @param data Zinc blende binary volume data, which data is generated by NEMO-3D and transferred from nanoscale
     39     * @param stream Zinc blende binary volume data, which data is generated by NEMO-3D and transferred from nanoscale
    4040     */
    4141    ZincBlendeVolume *loadFromStream(std::istream& stream);
     
    7171    /**
    7272     * @brief Get a line from file. It is used for reading header because header is written in ascii.
    73      * @param fp A file pointer of data file
    7473     */
    7574    void getLine(std::istream& stream);
  • trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.cpp

    r2870 r2877  
    2626    _mviParam = cgGetNamedParameter(_cgFP, "modelViewInv");
    2727    _renderParam = cgGetNamedParameter(_cgFP, "renderParameters");
    28     _option_one_volume_param = cgGetNamedParameter(_cgFP, "options");
     28    _optionOneVolumeParam = cgGetNamedParameter(_cgFP, "options");
    2929}
    3030
     
    3535    cgGLSetTextureParameter(_tfParam, tfID);
    3636    cgGLSetParameter4f(_cellSizeParam,
    37                        vol->cell_size.x,
    38                        vol->cell_size.y,
    39                        vol->cell_size.z, 0.);
     37                       vol->cellSize.x,
     38                       vol->cellSize.y,
     39                       vol->cellSize.z, 0.);
    4040
    4141    if (!sliceMode) {
    4242        cgGLSetParameter4f(_renderParam,
    43                            vol->n_slices(),
    44                            vol->opacity_scale(),
     43                           vol->numSlices(),
     44                           vol->opacityScale(),
    4545                           vol->diffuse(),
    4646                           vol->specular());
     
    4848        cgGLSetParameter4f(_renderParam,
    4949                           0.,
    50                            vol->opacity_scale(),
     50                           vol->opacityScale(),
    5151                           vol->diffuse(),
    5252                           vol->specular());
    5353    }
    5454
    55     cgGLSetParameter4f(_option_one_volume_param,
     55    cgGLSetParameter4f(_optionOneVolumeParam,
    5656                       0.0f,
    5757                       volume->isosurface(),
     
    5959                       0.0f);
    6060
    61     cgGLSetTextureParameter(_volumeAParam, vol->zincblende_tex[0]->id());
    62     cgGLSetTextureParameter(_volumeBParam, vol->zincblende_tex[1]->id());
     61    cgGLSetTextureParameter(_volumeAParam, vol->zincblendeTex[0]->id());
     62    cgGLSetTextureParameter(_volumeBParam, vol->zincblendeTex[1]->id());
    6363    cgGLEnableTextureParameter(_volumeAParam);
    6464    cgGLEnableTextureParameter(_volumeBParam);
  • trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h

    r2859 r2877  
    2626    CGparameter _mviParam;
    2727    CGparameter _renderParam;
    28     CGparameter _option_one_volume_param;
     28    CGparameter _optionOneVolumeParam;
    2929};
    3030
  • trunk/packages/vizservers/nanovis/PerfQuery.cpp

    r2798 r2877  
    1414 * ======================================================================
    1515 */
     16#include <assert.h>
    1617
    17 #include <assert.h>
    1818#include "PerfQuery.h"
    1919
    20 
    21 PerfQuery::PerfQuery(){
    22   glGenQueriesARB(1, &id);
    23   pixel = 0;
     20PerfQuery::PerfQuery()
     21{
     22    glGenQueriesARB(1, &id);
     23    pixel = 0;
    2424}
    2525
    26 PerfQuery::~PerfQuery(){
    27   glDeleteQueriesARB(1, &id);
     26PerfQuery::~PerfQuery()
     27{
     28    glDeleteQueriesARB(1, &id);
    2829}
    2930
    3031//There can only be one active query at any given moment
    31 void PerfQuery::enable(){
    32   glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id);
     32void PerfQuery::enable()
     33{
     34    glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id);
    3335}
    3436
    35 void PerfQuery::disable(){
    36   glEndQueryARB(GL_SAMPLES_PASSED_ARB);
     37void PerfQuery::disable()
     38{
     39    glEndQueryARB(GL_SAMPLES_PASSED_ARB);
    3740
    38   GLuint count;
    39   glGetQueryObjectuivARB(id, GL_QUERY_RESULT_ARB, &count);
     41    GLuint count;
     42    glGetQueryObjectuivARB(id, GL_QUERY_RESULT_ARB, &count);
    4043
    41   //accumulate pixel count count
    42   pixel+=count;
     44    //accumulate pixel count count
     45    pixel += count;
    4346}
    44 
  • trunk/packages/vizservers/nanovis/PerfQuery.h

    r2870 r2877  
    1616 * ======================================================================
    1717 */
    18 #ifndef _PERFQUERY_H_
    19 #define _PERFQUERY_H_
     18#ifndef PERFQUERY_H
     19#define PERFQUERY_H
    2020
    2121#include <stdio.h>
     
    2525#include "Trace.h"
    2626
    27 //check if occlusion query is supported
    28 inline bool check_query_support()
    29 {
    30     int bitsSupported = -1;
    31     glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,
    32                     &bitsSupported);
    33     if (bitsSupported == 0) {
    34         TRACE("occlusion query not supported!\n");
    35         return false;
    36     } else {
    37         TRACE("Occlusion query with %d bits supported\n", bitsSupported);
    38         return true;
    39     }
    40 }
    41 
    4227class PerfQuery
    4328{
    4429public:
    45     GLuint id;
    46     int pixel;
    47    
    4830    PerfQuery();
    4931    ~PerfQuery();
    50    
     32
    5133    void enable();      //start counting how many pixels are rendered
    5234    void disable();     //stop counting
    5335
    5436    void reset()
    55     { 
    56         pixel = 0;
     37    {
     38        pixel = 0;
    5739    }
    5840
    59     int get_pixel_count()
     41    int getPixelCount()
    6042    {
    61         return pixel;           //return current pixel count
     43        return pixel;           //return current pixel count
    6244    }
     45
     46    static bool checkQuerySupport();
     47
     48    GLuint id;
     49    int pixel;
    6350};
    6451
     52//check if occlusion query is supported
     53inline bool PerfQuery::checkQuerySupport()
     54{
     55    if (!GLEW_ARB_occlusion_query) {
     56        TRACE("ARB_occlusion_query extension not supported\n");
     57        return false;
     58    }
     59    int bitsSupported = -1;
     60    glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,
     61                    &bitsSupported);
     62    if (bitsSupported == 0) {
     63        TRACE("occlusion query not supported!\n");
     64        return false;
     65    } else {
     66        TRACE("Occlusion query with %d bits supported\n", bitsSupported);
     67        return true;
     68    }
     69}
    6570#endif
    6671
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h

    r2857 r2877  
    2121    /**
    2222     * @brief set default data paths
    23      * @param filePath all default paths separated by colon(:)
     23     * @param path all default paths separated by colon(:)
    2424     */
    2525    bool setPath(const char *path);
  • trunk/packages/vizservers/nanovis/R2/src/R2Fonts.cpp

    r2870 r2877  
    166166                         sizeof(unsigned int));
    167167
    168             // read dimensions for each charactor in 256-char ASCII chart
     168            // read dimensions for each character in 256-char ASCII chart
    169169            for (int i = 0; i < 256; ++i) {
    170170                unsigned int uiSize = 0;
  • trunk/packages/vizservers/nanovis/README

    r226 r2877  
    3232     Nvidia CG Toolkit for GPU (Graphics Processing Unit) programming.
    3333       (See http://developer.nvidia.com/object/cg_toolkit.html)
    34      The OpenGL Wrangler Library for OpenGL extension management.
     34     The OpenGL Wrangler Library (>= 1.1.0) for OpenGL extension management.
    3535       (See http://glew.sourceforge.net/)
    3636     OpenGL Utility Toolkit (GLUT). Freeglut is an opensource GLUT replacement.
  • trunk/packages/vizservers/nanovis/Switch.h

    r2798 r2877  
    3838
    3939typedef int (SwitchParseProc)(ClientData clientData, Tcl_Interp *interp,
    40         const char *switchName, Tcl_Obj *valueObjPtr, char *record, int offset,
    41         int flags);
     40                              const char *switchName, Tcl_Obj *valueObjPtr,
     41                              char *record, int offset,
     42                              int flags);
     43
    4244typedef void (SwitchFreeProc)(char *record, int offset, int flags);
    4345
     
    122124
    123125extern int ParseSwitches(Tcl_Interp *interp, SwitchSpec *specPtr,
    124         int objc, Tcl_Obj *const *objv, void *rec, int flags);
     126                         int objc, Tcl_Obj *const *objv,
     127                         void *rec, int flags);
    125128
    126129extern void FreeSwitches(SwitchSpec *specs, void *rec, int flags);
  • trunk/packages/vizservers/nanovis/Texture2D.cpp

    r2857 r2877  
    7272void Texture2D::update(void *data)
    7373{
     74    static GLuint floatFormats[] = { -1, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB };
     75    static GLuint halfFloatFormats[] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
     76    static GLuint basicFormats[] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
     77
    7478    glBindTexture(GL_TEXTURE_2D, _id);
    7579
     
    8387
    8488    //to do: add handling to more formats
    85 #ifdef NV40
     89    GLuint *targetFormats;
     90#ifdef HAVE_FLOAT_TEXTURES
    8691    if (_type == GL_FLOAT) {
    87         GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
    88         GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    89         glTexImage2D(GL_TEXTURE_2D, 0, targetFormat[_numComponents], _width, _height, 0,
    90                      format[_numComponents], _type, data);
     92# ifdef USE_HALF_FLOAT
     93        targetFormats = halfFloatFormats;
     94# else
     95        targetFormats = floatFormats;
     96# endif
    9197    } else {
    9298#endif
    93         GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    94         glTexImage2D(GL_TEXTURE_2D, 0, format[_numComponents], _width, _height, 0,
    95                      format[_numComponents], _type, data);
    96 #ifdef NV40
     99        targetFormats = basicFormats;
     100#ifdef HAVE_FLOAT_TEXTURES
    97101    }
    98102#endif
     103
     104    glTexImage2D(GL_TEXTURE_2D, 0, targetFormats[_numComponents],
     105                 _width, _height, 0,
     106                 basicFormats[_numComponents], _type, data);
     107
    99108    assert(glGetError() == 0);
    100109}
  • trunk/packages/vizservers/nanovis/Texture3D.cpp

    r2857 r2877  
    8888void Texture3D::update(void *data)
    8989{
     90    static GLuint floatFormats[] = { -1, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB };
     91    static GLuint halfFloatFormats[] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
     92    static GLuint basicFormats[] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
     93
    9094    glBindTexture(GL_TEXTURE_3D, _id);
    9195
    92     //load texture with 16 bit half floating point precision if card is 6 series NV40
    93     //half float with linear interpolation is only supported by 6 series and up cards
    94     //If NV40 not defined, data is quantized to 8-bit from 32-bit.
    9596    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    9697
     
    103104
    104105    //to do: add handling to more formats
    105 #ifdef NV40
     106    GLuint *targetFormats;
     107#ifdef HAVE_FLOAT_TEXTURES
    106108    if (_type == GL_FLOAT) {
    107         GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
    108         GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    109         glTexImage3D(GL_TEXTURE_3D, 0, targetFormat[_numComponents],
    110                      _width, _height, _depth, 0,
    111                      format[_numComponents], _type, data);
     109# ifdef USE_HALF_FLOAT
     110        targetFormats = halfFloatFormats;
     111# else
     112        targetFormats = floatFormats;
     113# endif
    112114    } else {
    113115#endif
    114         GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    115         glTexImage3D(GL_TEXTURE_3D, 0, format[_numComponents],
    116                      _width, _height, _depth, 0,
    117                      format[_numComponents], _type, data);
    118 #ifdef NV40
     116        targetFormats = basicFormats;
     117#ifdef HAVE_FLOAT_TEXTURES
    119118    }
    120119#endif
     120
     121    glTexImage3D(GL_TEXTURE_3D, 0, targetFormats[_numComponents],
     122                 _width, _height, _depth, 0,
     123                 basicFormats[_numComponents], _type, data);
    121124
    122125    assert(glGetError()==0);
  • trunk/packages/vizservers/nanovis/Unirect.cpp

    r2843 r2877  
    675675    _yNum = (size_t)ceil(dy/dmin);
    676676    _zNum = (size_t)ceil(dz/dmin);
    677    
    678 #ifndef NV40
     677
     678#ifndef HAVE_NPOT_TEXTURES
    679679    // must be an even power of 2 for older cards
    680680    _xNum = (int)pow(2.0, ceil(log10((double)_xNum)/log10(2.0)));
  • trunk/packages/vizservers/nanovis/Vector3.h

    r2827 r2877  
    4444    {
    4545        TRACE("(x:%f, y:%f, z:%f)\n", x, y, z);
     46    }
     47
     48    Vector3 operator -() const
     49    {
     50        return Vector3(-x, -y, -z);
    4651    }
    4752
     
    99104    {
    100105        float len = length();
    101         return Vector3(x / len, y / len, z / len);
     106        if (len > 1.0e-6) {
     107            return Vector3(x / len, y / len, z / len);
     108        } else {
     109            return *this;
     110        }
    102111    }
    103112
  • trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp

    r2870 r2877  
    318318
    319319        //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * 0.5) * _screenHeight * 0.5);
    320         cgSetParameter1f(_mvTanHalfFOVParam, tan(30. * 0.5) * NanoVis::win_height * 0.5);
     320        cgSetParameter1f(_mvTanHalfFOVParam, tan(30. * 0.5) * NanoVis::winHeight * 0.5);
    321321
    322322        cgGLSetStateMatrixParameter(_mvpParticleParam,
  • trunk/packages/vizservers/nanovis/Volume.cpp

    r2857 r2877  
    2020#include "Trace.h"
    2121
    22 bool Volume::update_pending = false;
     22bool Volume::updatePending = false;
    2323double Volume::valueMin = 0.0;
    2424double Volume::valueMax = 1.0;
     
    2727               int w, int h, int d, float s,
    2828               int n, float *data,
    29                double v0, double v1, double nz_min) :
    30     aspect_ratio_width(1),
    31     aspect_ratio_height(1),
    32     aspect_ratio_depth(1),
     29               double v0, double v1, double nonZeroMin) :
     30    aspectRatioWidth(1),
     31    aspectRatioHeight(1),
     32    aspectRatioDepth(1),
    3333    id(0),
    3434    width(w),
     
    3838    pointsetIndex(-1),
    3939    _tfPtr(NULL),
    40     _specular(6.),              // default value
    41     _diffuse(3.),               // default value
    42     _opacity_scale(10.),        // default value
     40    _specular(6.),
     41    _diffuse(3.),
     42    _opacityScale(10.),
    4343    _name(NULL),
    4444    _data(NULL),
    45     _n_components(n),
    46     _nonzero_min(nz_min),
     45    _numComponents(n),
     46    _nonZeroMin(nonZeroMin),
    4747    _tex(NULL),
    4848    _location(x, y, z),
    49     _n_slices(512),             // default value
     49    _numSlices(512),
    5050    _enabled(true),
    51     _data_enabled(true),        // default value
    52     _outline_enabled(true),     // default value
    53     _outline_color(1., 1., 1.), // default value
    54     _volume_type(CUBIC),        // default is a cubic volume
    55     _iso_surface(0)
     51    _dataEnabled(true),
     52    _outlineEnabled(true),
     53    _outlineColor(1., 1., 1.),
     54    _volumeType(CUBIC),
     55    _isosurface(0)
    5656{
    5757    _tex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n);
    58     int fcount = width * height * depth * _n_components;
     58    int fcount = width * height * depth * _numComponents;
    5959    _data = new float[fcount];
    6060    if (data != NULL) {
     
    6464    } else {
    6565        TRACE("data is null\n");
    66         memset(_data, 0, sizeof(width * height * depth * _n_components *
     66        memset(_data, 0, sizeof(width * height * depth * _numComponents *
    6767                                sizeof(float)));
    6868        _tex->initialize(_data);
     
    7474
    7575    // VOLUME
    76     aspect_ratio_width  = s * _tex->aspectRatioWidth();
    77     aspect_ratio_height = s * _tex->aspectRatioHeight();
    78     aspect_ratio_depth =  s * _tex->aspectRatioDepth();
     76    aspectRatioWidth  = s * _tex->aspectRatioWidth();
     77    aspectRatioHeight = s * _tex->aspectRatioHeight();
     78    aspectRatioDepth =  s * _tex->aspectRatioDepth();
    7979
    8080    //Add cut planes. We create 3 default cut planes facing x, y, z directions.
    8181    //The default location of cut plane is in the middle of the data.
    8282    _plane.clear();
    83     add_cutplane(1, 0.5f);
    84     add_cutplane(2, 0.5f);
    85     add_cutplane(3, 0.5f);
     83    addCutplane(1, 0.5f);
     84    addCutplane(2, 0.5f);
     85    addCutplane(3, 0.5f);
    8686
    8787    //initialize the labels 
  • trunk/packages/vizservers/nanovis/Volume.h

    r2870 r2877  
    5555    Volume(float x, float y, float z,
    5656           int width, int height, int depth,
    57            float size, int n_component,
     57           float size, int numComponents,
    5858           float *data,
    5959           double vmin, double vmax,
    60            double nonzero_min);
     60           double nonZeroMin);
    6161
    6262    virtual ~Volume();
     
    8484    int isosurface() const
    8585    {
    86         return _iso_surface;
     86        return _isosurface;
    8787    }
    8888
    8989    void isosurface(int iso)
    9090    {
    91         _iso_surface = iso;
    92     }
    93 
    94     int n_components() const
    95     {
    96         return _n_components;
    97     }
    98 
    99     double nonzero_min() const
    100     {
    101         return _nonzero_min;
    102     }
    103 
    104     double range_nzero_min() const
    105     {
    106         return _nonzero_min;
    107     }
    108 
    109     int volume_type() const
    110     {
    111         return _volume_type;
     91        _isosurface = iso;
     92    }
     93
     94    int numComponents() const
     95    {
     96        return _numComponents;
     97    }
     98
     99    double nonZeroMin() const
     100    {
     101        return _nonZeroMin;
     102    }
     103
     104    int volumeType() const
     105    {
     106        return _volumeType;
    112107    }
    113108
     
    122117    }
    123118   
    124     int n_slices() const
    125     {
    126         return _n_slices;
    127     }
    128 
    129     void n_slices(int n)
    130     {
    131         _n_slices = n;
     119    int numSlices() const
     120    {
     121        return _numSlices;
     122    }
     123
     124    void numSlices(int n)
     125    {
     126        _numSlices = n;
    132127    }
    133128
    134129    /// set the drawing size of volume
    135     void set_size(float s);
     130    void setSize(float s);
    136131
    137132    // methods related to cutplanes
    138133    /// add a plane and returns its index
    139     int add_cutplane(int orientation, float location);
    140 
    141     void enable_cutplane(int index);
    142 
    143     void disable_cutplane(int index);
    144 
    145     void move_cutplane(int index, float location);
    146 
    147     CutPlane *get_cutplane(int index);
     134    int addCutplane(int orientation, float location);
     135
     136    void enableCutplane(int index);
     137
     138    void disableCutplane(int index);
     139
     140    void moveCutplane(int index, float location);
     141
     142    CutPlane *getCutplane(int index);
    148143
    149144    /// returns the number of cutplanes in the volume
    150     int get_cutplane_count();
     145    int getCutplaneCount();
    151146
    152147    /// check if a cutplane is enabled
    153     bool cutplane_is_enabled(int index) const;
     148    bool isCutplaneEnabled(int index) const;
    154149
    155150    // methods related to shading. These parameters are per volume
     151
     152    /// Get specular exponent
    156153    float specular() const
    157154    {
     
    159156    }
    160157
     158    /// Set specular exponent [0,128]
    161159    void specular(float value)
    162160    {
     161        if (value < 0.0f) value = 0.0f;
     162        if (value > 128.0f) value = 128.0f;
    163163        _specular = value;
    164164    }
    165165
     166    /// Get diffuse coefficient
    166167    float diffuse() const
    167168    {
     
    169170    }
    170171
     172    /// Set diffuse coefficient [0,1]
    171173    void diffuse(float value)
    172174    {
     175        if (value < 0.0f) value = 0.0f;
     176        if (value > 1.0f) value = 1.0f;
    173177        _diffuse = value;
    174178    }
    175179
    176     float opacity_scale() const
    177     {
    178         return _opacity_scale;
    179     }
    180 
    181     void opacity_scale(float value)
    182     {
    183         _opacity_scale = value;
    184     }
    185 
    186     void data_enabled(bool value)
    187     {
    188         _data_enabled = value;
    189     }
    190 
    191     bool data_enabled() const
    192     {
    193         return _data_enabled;
     180    float opacityScale() const
     181    {
     182        return _opacityScale;
     183    }
     184
     185    void opacityScale(float value)
     186    {
     187        _opacityScale = value;
     188    }
     189
     190    void dataEnabled(bool value)
     191    {
     192        _dataEnabled = value;
     193    }
     194
     195    bool dataEnabled() const
     196    {
     197        return _dataEnabled;
    194198    }
    195199
    196200    void outline(bool value)
    197201    {
    198         _outline_enabled = value;
     202        _outlineEnabled = value;
    199203    }
    200204
    201205    bool outline()
    202206    {
    203         return _outline_enabled;
     207        return _outlineEnabled;
    204208    }
    205209
     
    214218    }
    215219
    216     void set_outline_color(float *rgb);
    217 
    218     void get_outline_color(float *rgb);
    219    
     220    void setOutlineColor(float *rgb);
     221
     222    void getOutlineColor(float *rgb);
     223
    220224    /// change the label displayed on an axis
    221     void set_label(int axis, const char *txt);
     225    void setLabel(int axis, const char *txt);
    222226
    223227    void setPhysicalBBox(const Vector3& min, const Vector3& max);
     
    237241    }
    238242
    239     float aspect_ratio_width;
    240     float aspect_ratio_height;
    241     float aspect_ratio_depth;
     243    float aspectRatioWidth;
     244    float aspectRatioHeight;
     245    float aspectRatioDepth;
    242246
    243247    GLuint id;          ///< OpenGL textue identifier (==_tex->id)
     
    264268    std::string label[3]; ///< the labels along each axis 0:x, 1:y, 2:z
    265269
    266     static bool update_pending;
     270    static bool updatePending;
    267271    static double valueMin, valueMax;
    268272
     
    281285     * the object is to appear like plastic
    282286     */
    283     float _opacity_scale;
     287    float _opacityScale;
    284288
    285289    const char *_name;
    286     Vector3 _physical_min;
    287     Vector3 _physical_max;
     290    Vector3 _physicalMin;
     291    Vector3 _physicalMax;
    288292    float *_data;
    289293
    290     int _n_components;
    291 
    292     double _nonzero_min;
     294    int _numComponents;
     295
     296    double _nonZeroMin;
    293297
    294298    std::vector<CutPlane> _plane; ///< cut planes
     
    302306     * the better quality, lower speed.
    303307     */
    304     int _n_slices;
     308    int _numSlices;
    305309    bool _enabled;
    306     bool _data_enabled;         ///< show/hide cloud of volume data
    307     bool _outline_enabled;      ///< show/hide outline around volume
    308     Color _outline_color;       ///< color for outline around volume
    309     int _volume_type;           ///< cubic or zincblende
    310     int _iso_surface;
     310    bool _dataEnabled;          ///< show/hide cloud of volume data
     311    bool _outlineEnabled;       ///< show/hide outline around volume
     312    Color _outlineColor;        ///< color for outline around volume
     313    int _volumeType;            ///< cubic or zincblende
     314    int _isosurface;
    311315};
    312316
    313317inline int
    314 Volume::add_cutplane(int orientation, float location)
     318Volume::addCutplane(int orientation, float location)
    315319{
    316320    _plane.push_back(CutPlane(orientation, location));
     
    319323
    320324inline void
    321 Volume::enable_cutplane(int index)
     325Volume::enableCutplane(int index)
    322326{
    323327    //assert(index < plane.size());
     
    325329}
    326330inline void
    327 Volume::disable_cutplane(int index)
     331Volume::disableCutplane(int index)
    328332{
    329333    //assert(index < plane.size());
     
    332336
    333337inline void
    334 Volume::move_cutplane(int index, float location)
     338Volume::moveCutplane(int index, float location)
    335339{
    336340    //assert(index < plane.size());
     
    339343
    340344inline CutPlane *
    341 Volume::get_cutplane(int index)
     345Volume::getCutplane(int index)
    342346{
    343347    //assert(index < plane.size());
     
    346350
    347351inline int
    348 Volume::get_cutplane_count()
     352Volume::getCutplaneCount()
    349353{
    350354    return _plane.size();
     
    352356
    353357inline bool
    354 Volume::cutplane_is_enabled(int index) const
     358Volume::isCutplaneEnabled(int index) const
    355359{
    356360    //assert(index < plane.size());
     
    359363
    360364inline void
    361 Volume::set_size(float s)
     365Volume::setSize(float s)
    362366{
    363367    size = s;
    364     aspect_ratio_width  = s * _tex->aspectRatioWidth();
    365     aspect_ratio_height = s * _tex->aspectRatioHeight();
    366     aspect_ratio_depth  = s * _tex->aspectRatioDepth();
    367 }
    368 
    369 inline void
    370 Volume::set_outline_color(float *rgb)
    371 {
    372     _outline_color = Color(rgb[0], rgb[1], rgb[2]);
    373 }
    374 
    375 inline void
    376 Volume::get_outline_color(float *rgb)
    377 {
    378     _outline_color.getRGB(rgb);
    379 }
    380 
    381 inline void
    382 Volume::set_label(int axis, const char* txt)
     368    aspectRatioWidth  = s * _tex->aspectRatioWidth();
     369    aspectRatioHeight = s * _tex->aspectRatioHeight();
     370    aspectRatioDepth  = s * _tex->aspectRatioDepth();
     371}
     372
     373inline void
     374Volume::setOutlineColor(float *rgb)
     375{
     376    _outlineColor = Color(rgb[0], rgb[1], rgb[2]);
     377}
     378
     379inline void
     380Volume::getOutlineColor(float *rgb)
     381{
     382    _outlineColor.getRGB(rgb);
     383}
     384
     385inline void
     386Volume::setLabel(int axis, const char* txt)
    383387{
    384388    label[axis] = txt;
     
    388392Volume::setPhysicalBBox(const Vector3& min, const Vector3& max)
    389393{
    390     _physical_min = min;
    391     _physical_max = max;
     394    _physicalMin = min;
     395    _physicalMax = max;
    392396
    393397    /*
    394     aspect_ratio_width = size * 1;
    395     aspect_ratio_height = size * (max.y - min.y) / (max.x - min.x);
    396     aspect_ratio_depth = size* (max.z - min.z) / (max.x - min.x);
     398    aspectRatioWidth = size * 1;
     399    aspectRatioHeight = size * (max.y - min.y) / (max.x - min.x);
     400    aspectRatioDepth = size* (max.z - min.z) / (max.x - min.x);
    397401
    398402    location.x = -0.5;
    399     location.y = -0.5* aspect_ratio_height;
    400     location.z = -0.5* aspect_ratio_depth;
     403    location.y = -0.5* aspectRatioHeight;
     404    location.z = -0.5* aspectRatioDepth;
    401405    */
    402406}
     
    405409Volume::getPhysicalBBoxMin() const
    406410{
    407     return _physical_min;
     411    return _physicalMin;
    408412}
    409413
     
    411415Volume::getPhysicalBBoxMax() const
    412416{
    413     return _physical_max;
     417    return _physicalMax;
    414418}
    415419
  • trunk/packages/vizservers/nanovis/VolumeInterpolator.cpp

    r2853 r2877  
    1818    _numBytes(0),
    1919    _dataCount(0),
    20     _n_components(0),
     20    _numComponents(0),
    2121    _referenceOfVolume(0)
    2222{
     
    3434    struct timeval clock;
    3535    gettimeofday(&clock, NULL);
    36     _start_time = clock.tv_sec + clock.tv_usec/1000000.0;
     36    _startTime = clock.tv_sec + clock.tv_usec/1000000.0;
    3737    TRACE("End Start - VolumeInterpolator\n");
    3838}
     
    6868            *((Vector3*)(result + 1)) = normal;
    6969
    70             result += _n_components;
    71             data1 += _n_components;
    72             data2 += _n_components;
     70            result += _numComponents;
     71            data1 += _numComponents;
     72            data2 += _numComponents;
    7373        }
    7474
     
    125125            _volumes[0]->height != refPtr->height ||   
    126126            _volumes[0]->depth != refPtr->depth ||
    127             _volumes[0]->n_components() != refPtr->n_components()) {
     127            _volumes[0]->numComponents() != refPtr->numComponents()) {
    128128            TRACE("The volume should be the same width, height, number of components\n");
    129129            return;
     
    131131    } else {
    132132        _dataCount = refPtr->width * refPtr->height * refPtr->depth;
    133         _n_components = refPtr->n_components();
    134         _numBytes = _dataCount * _n_components * sizeof(float);
     133        _numComponents = refPtr->numComponents();
     134        _numBytes = _dataCount * _numComponents * sizeof(float);
    135135        Vector3 loc = refPtr->location();
    136136        _volume = new Volume(loc.x, loc.y, loc.z,
    137137                             refPtr->width, refPtr->height, refPtr->depth,
    138138                             refPtr->size,
    139                              refPtr->n_components(),
     139                             refPtr->numComponents(),
    140140                             refPtr->data(),
    141141                             refPtr->wAxis.min(),
    142142                             refPtr->wAxis.max(),
    143                              refPtr->nonzero_min());
     143                             refPtr->nonZeroMin());
    144144        /*
    145145        _referenceOfVolume = refPtr->dataID();
    146146        */
    147         _volume->n_slices(256-1);
    148         _volume->disable_cutplane(0);
    149         _volume->disable_cutplane(1);
    150         _volume->disable_cutplane(2);
     147        _volume->numSlices(256-1);
     148        _volume->disableCutplane(0);
     149        _volume->disableCutplane(1);
     150        _volume->disableCutplane(2);
    151151        _volume->visible(true);
    152         _volume->data_enabled(true);
     152        _volume->dataEnabled(true);
    153153        _volume->specular(refPtr->specular());
    154154        _volume->diffuse(refPtr->diffuse());
    155         _volume->opacity_scale(refPtr->opacity_scale());
     155        _volume->opacityScale(refPtr->opacityScale());
    156156        _volume->isosurface(0);
    157157        TRACE("VOL : location %f %f %f\n\tid : %s\n", loc.x, loc.y, loc.z,
  • trunk/packages/vizservers/nanovis/VolumeInterpolator.h

    r2853 r2877  
    2424    void computeKeys(float fraction, int count, float *interp, int *key1, int *key2);
    2525
    26     bool is_started() const;
     26    bool isStarted() const;
    2727
    2828    double getInterval() const;
     
    4343    unsigned int _numBytes;
    4444    unsigned int _dataCount;
    45     unsigned int _n_components;
     45    unsigned int _numComponents;
    4646    unsigned int _referenceOfVolume;
    47     double _start_time;
     47    double _startTime;
    4848};
    4949
    50 inline bool VolumeInterpolator::is_started() const
     50inline bool VolumeInterpolator::isStarted() const
    5151{
    5252    return _started;
     
    5555inline double VolumeInterpolator::getStartTime() const
    5656{
    57     return _start_time;
     57    return _startTime;
    5858}
    5959
  • trunk/packages/vizservers/nanovis/VolumeRenderer.cpp

    r2853 r2877  
    4040
    4141VolumeRenderer::VolumeRenderer() :
    42     slice_mode(false),
    43     volume_mode(true)
    44 {
    45     init_shaders();
     42    _sliceMode(false),
     43    _volumeMode(true)
     44{
     45    initShaders();
    4646
    4747    const char *path = R2FilePath::getInstance()->getPath("Font.bmp");
     
    5050        assert(path != NULL);
    5151    }
    52     init_font(path);
     52    initFont(path);
    5353    delete [] path;
    5454    _volumeInterpolator = new VolumeInterpolator();
     
    6464
    6565//initialize the volume shaders
    66 void VolumeRenderer::init_shaders()
     66void VolumeRenderer::initShaders()
    6767{
    6868    //standard vertex program
     
    8585struct SortElement {
    8686    float z;
    87     int volume_id;
    88     int slice_id;
     87    int volumeId;
     88    int sliceId;
    8989
    9090    SortElement(float _z, int _v, int _s) :
    91         z(_z), volume_id(_v), slice_id(_s)
     91        z(_z),
     92        volumeId(_v),
     93        sliceId(_s)
    9294    {}
    9395};
    9496
    95 int slice_sort(const void* a, const void* b)
     97static int sliceSort(const void *a, const void *b)
    9698{
    9799    if ((*((SortElement*)a)).z > (*((SortElement*)b)).z)
     
    102104
    103105void
    104 VolumeRenderer::render_all()
     106VolumeRenderer::renderAll()
    105107{
    106108    size_t total_rendered_slices = 0;
    107109
    108     if (_volumeInterpolator->is_started()) {
     110    if (_volumeInterpolator->isStarted()) {
    109111#ifdef notdef
    110112        ani_vol = _volumeInterpolator->getVolume();
     
    130132        // at all.
    131133        volumes.push_back(volPtr);
    132         volPtr->n_slices(256 - volumes.size());
     134        volPtr->numSlices(256 - volumes.size());
    133135    }
    134136
     
    144146        actual_slices[i] = 0;
    145147
    146         int n_slices = volPtr->n_slices();
     148        int n_slices = volPtr->numSlices();
    147149        if (volPtr->isosurface()) {
    148150            // double the number of slices
     
    174176        //get modelview matrix with no translation
    175177        glPushMatrix();
    176         glScalef(volPtr->aspect_ratio_width,
    177                  volPtr->aspect_ratio_height,
    178                  volPtr->aspect_ratio_depth);
     178        glScalef(volPtr->aspectRatioWidth,
     179                 volPtr->aspectRatioHeight,
     180                 volPtr->aspectRatioDepth);
    179181
    180182        glEnable(GL_DEPTH_TEST);
     
    191193        glPushMatrix();
    192194        glTranslatef(shift_4d.x, shift_4d.y, shift_4d.z);
    193         glScalef(volPtr->aspect_ratio_width,
    194                  volPtr->aspect_ratio_height,
    195                  volPtr->aspect_ratio_depth);
     195        glScalef(volPtr->aspectRatioWidth,
     196                 volPtr->aspectRatioHeight,
     197                 volPtr->aspectRatioDepth);
    196198        GLfloat mv_trans[16];
    197199        glGetFloatv(GL_MODELVIEW_MATRIX, mv_trans);
     
    204206        if (volPtr->outline()) {
    205207            float olcolor[3];
    206             volPtr->get_outline_color(olcolor);
    207             draw_bounding_box(x0, y0, z0, x0+1, y0+1, z0+1,
     208            volPtr->getOutlineColor(olcolor);
     209            drawBoundingBox(x0, y0, z0, x0+1, y0+1, z0+1,
    208210                (double)olcolor[0], (double)olcolor[1], (double)olcolor[2],
    209211                1.5);
     
    223225            volume_planes[j].transform(model_view_no_trans);
    224226        }
    225         get_near_far_z(mv_no_trans, zNear, zFar);
     227        getNearFarZ(mv_no_trans, zNear, zFar);
    226228
    227229        //compute actual rendering slices
     
    229231        size_t n_actual_slices;
    230232
    231         if (volPtr->data_enabled()) {
     233        if (volPtr->dataEnabled()) {
    232234            n_actual_slices = (int)(fabs(zNear-zFar)/z_step + 1);
    233235            polys[i] = new ConvexPolygon*[n_actual_slices];
     
    249251
    250252        ConvexPolygon static_poly;
    251         for (int j = 0; j < volPtr->get_cutplane_count(); j++) {
    252             if (!volPtr->cutplane_is_enabled(j)) {
     253        for (int j = 0; j < volPtr->getCutplaneCount(); j++) {
     254            if (!volPtr->isCutplaneEnabled(j)) {
    253255                continue;
    254256            }
    255             float offset = volPtr->get_cutplane(j)->offset;
    256             int axis = volPtr->get_cutplane(j)->orient;
     257            float offset = volPtr->getCutplane(j)->offset;
     258            int axis = volPtr->getCutplane(j)->orient;
    257259           
    258260            if (axis == 3) {
     
    284286            p->vertices.clear();
    285287
    286             p->append_vertex(vert1);
    287             p->append_vertex(vert2);
    288             p->append_vertex(vert3);
    289             p->append_vertex(vert4);
     288            p->appendVertex(vert1);
     289            p->appendVertex(vert2);
     290            p->appendVertex(vert3);
     291            p->appendVertex(vert4);
    290292
    291293            for (size_t k = 0; k < 6; k++) {
     
    297299
    298300            glPushMatrix();
    299             glScalef(volPtr->aspect_ratio_width,
    300                      volPtr->aspect_ratio_height,
    301                      volPtr->aspect_ratio_depth);
    302 
    303             activate_volume_shader(volPtr, true);
     301            glScalef(volPtr->aspectRatioWidth,
     302                     volPtr->aspectRatioHeight,
     303                     volPtr->aspectRatioDepth);
     304
     305            activateVolumeShader(volPtr, true);
    304306            glPopMatrix();
    305307
     
    308310
    309311            glBegin(GL_POLYGON);
    310             p->Emit(true);
     312            p->emit(true);
    311313            glEnd();
    312314            glDisable(GL_DEPTH_TEST);
    313315
    314             deactivate_volume_shader();
     316            deactivateVolumeShader();
    315317        } //done cutplanes
    316318
     
    334336
    335337            poly->vertices.clear();
    336             poly->set_id(i);
     338            poly->setId(i);
    337339
    338340            //Setting Z-coordinate
     
    342344            vert4.z = slice_z;
    343345
    344             poly->append_vertex(vert1);
    345             poly->append_vertex(vert2);
    346             poly->append_vertex(vert3);
    347             poly->append_vertex(vert4);
     346            poly->appendVertex(vert1);
     347            poly->appendVertex(vert2);
     348            poly->appendVertex(vert3);
     349            poly->appendVertex(vert4);
    348350
    349351            for (size_t k = 0; k < 6; k++) {
     
    377379
    378380    //sort them
    379     qsort(slices, total_rendered_slices, sizeof(SortElement), slice_sort);
     381    qsort(slices, total_rendered_slices, sizeof(SortElement), sliceSort);
    380382
    381383    //Now we are ready to render all the slices from back to front
     
    386388        Volume *volPtr = NULL;
    387389
    388         int volume_index = slices[i].volume_id;
    389         int slice_index = slices[i].slice_id;
     390        int volume_index = slices[i].volumeId;
     391        int slice_index = slices[i].sliceId;
    390392        ConvexPolygon *cur = polys[volume_index][slice_index];
    391393
     
    393395
    394396        glPushMatrix();
    395         glScalef(volPtr->aspect_ratio_width, volPtr->aspect_ratio_height,
    396                  volPtr->aspect_ratio_depth);
     397        glScalef(volPtr->aspectRatioWidth,
     398                 volPtr->aspectRatioHeight,
     399                 volPtr->aspectRatioDepth);
    397400
    398401#ifdef notdef
     
    400403               volPtr->name(), volPtr, slice_index, volume_index);
    401404#endif
    402         activate_volume_shader(volPtr, false);
     405        activateVolumeShader(volPtr, false);
    403406        glPopMatrix();
    404407
    405408        glBegin(GL_POLYGON);
    406         cur->Emit(true);
     409        cur->emit(true);
    407410        glEnd();
    408411
    409         deactivate_volume_shader();
     412        deactivateVolumeShader();
    410413    }
    411414
     
    428431
    429432void
    430 VolumeRenderer::draw_bounding_box(float x0, float y0, float z0,
    431                                   float x1, float y1, float z1,
    432                                   float r, float g, float b,
    433                                   float line_width)
     433VolumeRenderer::drawBoundingBox(float x0, float y0, float z0,
     434                                float x1, float y1, float z1,
     435                                float r, float g, float b,
     436                                float line_width)
    434437{
    435438    glPushMatrix();
     
    547550
    548551void
    549 VolumeRenderer::activate_volume_shader(Volume* volPtr, bool slice_mode)
     552VolumeRenderer::activateVolumeShader(Volume* volPtr, bool sliceMode)
    550553{
    551554    //vertex shader
    552555    _stdVertexShader->bind();
    553556    TransferFunction *tfPtr  = volPtr->transferFunction();
    554     if (volPtr->volume_type() == Volume::CUBIC) {
    555         _regularVolumeShader->bind(tfPtr->id(), volPtr, slice_mode);
    556     } else if (volPtr->volume_type() == Volume::ZINCBLENDE) {
    557         _zincBlendeShader->bind(tfPtr->id(), volPtr, slice_mode);
    558     }
    559 }
    560 void VolumeRenderer::deactivate_volume_shader()
     557    if (volPtr->volumeType() == Volume::CUBIC) {
     558        _regularVolumeShader->bind(tfPtr->id(), volPtr, sliceMode);
     559    } else if (volPtr->volumeType() == Volume::ZINCBLENDE) {
     560        _zincBlendeShader->bind(tfPtr->id(), volPtr, sliceMode);
     561    }
     562}
     563
     564void VolumeRenderer::deactivateVolumeShader()
    561565{
    562566    _stdVertexShader->unbind();
     
    565569}
    566570
    567 void VolumeRenderer::get_near_far_z(const Mat4x4& mv, double& zNear, double& zFar)
     571void VolumeRenderer::getNearFarZ(const Mat4x4& mv, double& zNear, double& zFar)
    568572{
    569573    double x0 = 0;
     
    602606
    603607bool
    604 VolumeRenderer::init_font(const char *filename)
     608VolumeRenderer::initFont(const char *filename)
    605609{
    606610    FILE *f;
     
    731735
    732736    //create opengl texture
    733     glGenTextures(1, &font_texture);
    734     glBindTexture(GL_TEXTURE_2D, font_texture);
     737    glGenTextures(1, &_fontTexture);
     738    glBindTexture(GL_TEXTURE_2D, _fontTexture);
    735739    //glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
    736740    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data_with_alpha);
     
    741745    free(data_with_alpha);
    742746
    743     build_font();
     747    buildFont();
    744748    return (glGetError()==0);
    745749
     
    750754
    751755void
    752 VolumeRenderer::draw_label(Volume* vol)
     756VolumeRenderer::drawLabel(Volume* vol)
    753757{
    754758    //glEnable(GL_TEXTURE_2D);
     
    762766    glPushMatrix();
    763767
    764     glTranslatef(.5*vol->aspect_ratio_width, vol->aspect_ratio_height,
    765                  -0.1*vol->aspect_ratio_depth);
     768    glTranslatef(.5 * vol->aspectRatioWidth,
     769                 vol->aspectRatioHeight,
     770                 -0.1 * vol->aspectRatioDepth);
    766771    glRotatef(180, 0, 0, 1);
    767772    glRotatef(90, 1, 0, 0);
     
    777782    length = vol->label[1].size();
    778783    glPushMatrix();
    779     glTranslatef(vol->aspect_ratio_width, 0.5*vol->aspect_ratio_height, -0.1*vol->aspect_ratio_depth);
     784    glTranslatef(vol->aspectRatioWidth,
     785                 0.5*vol->aspectRatioHeight,
     786                 -0.1*vol->aspectRatioDepth);
    780787    glRotatef(90, 0, 1, 0);
    781788    glRotatef(90, 0, 0, 1);
     
    791798    length = vol->label[2].size();
    792799    glPushMatrix();
    793     glTranslatef(0., 1.*vol->aspect_ratio_height, 0.5*vol->aspect_ratio_depth);
     800    glTranslatef(0.,
     801                 1. * vol->aspectRatioHeight,
     802                 0.5 * vol->aspectRatioDepth);
    794803    glRotatef(90, 0, 1, 0);
    795804
     
    805814
    806815void
    807 VolumeRenderer::build_font()
     816VolumeRenderer::buildFont()
    808817{
    809818    GLfloat cx, cy;         /* the character coordinates in our texture */
    810     font_base = glGenLists(256);
    811     glBindTexture(GL_TEXTURE_2D, font_texture);
     819    _fontBase = glGenLists(256);
     820    glBindTexture(GL_TEXTURE_2D, _fontTexture);
    812821    for (int loop = 0; loop < 256; loop++) {
    813822        cx = (float) (loop % 16) / 16.0f;
    814823        cy = (float) (loop / 16) / 16.0f;
    815         glNewList(font_base + loop, GL_COMPILE);
     824        glNewList(_fontBase + loop, GL_COMPILE);
    816825        glBegin(GL_QUADS);
    817826        glTexCoord2f(cx, 1 - cy - 0.0625f);
     
    835844        set = 1;
    836845    }
    837     glBindTexture(GL_TEXTURE_2D, font_texture);
    838     glListBase(font_base - 32 + (128 * set));
     846    glBindTexture(GL_TEXTURE_2D, _fontTexture);
     847    glListBase(_fontBase - 32 + (128 * set));
    839848    glCallLists(strlen(string), GL_BYTE, string);
    840849}
  • trunk/packages/vizservers/nanovis/VolumeRenderer.h

    r2853 r2877  
    3535
    3636    /// render all enabled volumes
    37     void render_all();
     37    void renderAll();
    3838
    3939    void specular(float val);
     
    4242
    4343    /// control independently
    44     void set_slice_mode(bool val)
     44    void setSliceMode(bool val)
    4545    {
    46         slice_mode = val;
     46        _sliceMode = val;
    4747    }
    4848
    49     void set_volume_mode(bool val)
     49    void setVolumeMode(bool val)
    5050    {
    51         volume_mode = val;
     51        _volumeMode = val;
    5252    }
    5353
    5454    /// switch_cutplane_mode
    55     void switch_slice_mode()
     55    void switchSliceMode()
    5656    {
    57         slice_mode = (!slice_mode);
     57        _sliceMode = (!_sliceMode);
    5858    }
    5959
    60     void switch_volume_mode()
     60    void switchVolumeMode()
    6161    {
    62         volume_mode = (!volume_mode);
     62        _volumeMode = (!_volumeMode);
    6363    }
    6464
     
    9191
    9292private:
    93     void init_shaders();
     93    void initShaders();
    9494
    95     void activate_volume_shader(Volume *vol, bool slice_mode);
     95    void activateVolumeShader(Volume *vol, bool slice_mode);
    9696
    97     void deactivate_volume_shader();
     97    void deactivateVolumeShader();
    9898
    99      void draw_bounding_box(float x0, float y0, float z0,
    100                             float x1, float y1, float z1,
    101                             float r, float g, float b, float line_width);
     99    void drawBoundingBox(float x0, float y0, float z0,
     100                         float x1, float y1, float z1,
     101                         float r, float g, float b, float line_width);
    102102
    103     void get_near_far_z(const Mat4x4& mv, double& zNear, double& zFar);
     103    void getNearFarZ(const Mat4x4& mv, double& zNear, double& zFar);
    104104
    105     bool init_font(const char *filename);
     105    bool initFont(const char *filename);
    106106
    107107    /// there are two sets of font in the texture. 0, 1
     
    109109
    110110    /// draw label using bitmap texture
    111     void draw_label(Volume *vol);
     111    void drawLabel(Volume *vol);
    112112
    113113    /// Register the location of each alphabet in
    114     void build_font();
     114    void buildFont();
    115115
    116116    VolumeInterpolator *_volumeInterpolator;
    117117
    118     bool slice_mode;  ///< enable cut planes
    119     bool volume_mode; ///< enable full volume rendering
     118    bool _sliceMode;  ///< enable cut planes
     119    bool _volumeMode; ///< enable full volume rendering
    120120
    121121    /**
     
    146146
    147147    //standard vertex shader parameters
    148     CGprogram m_vert_std_vprog;
    149     CGparameter m_mvp_vert_std_param;
    150     CGparameter m_mvi_vert_std_param;
    151     GLuint font_base;           // The base of the font display list.
    152     GLuint font_texture;        //the id of the font texture
     148    CGprogram _vertStdVprog;
     149    CGparameter _mvpVertStdParam;
     150    CGparameter _mviVertStdParam;
     151    GLuint _fontBase;      ///< The base of the font display list.
     152    GLuint _fontTexture;   ///< The id of the font texture
    153153};
    154154
  • trunk/packages/vizservers/nanovis/ZincBlendeVolume.cpp

    r2844 r2877  
    2424                                   float *dataVolumeA, float *dataVolumeB,
    2525                                   double v0, double v1, double non_zeromin,
    26                                    const Vector3& cellSize) :
     26                                   const Vector3& cellSz) :
    2727    Volume(x, y, z, w, h, d, s, n, dataVolumeA, v0, v1, non_zeromin),
    28     cell_size(cellSize)
     28    cellSize(cellSz)
    2929{
    3030    //label it as zincblende
    31     _volume_type = ZINCBLENDE;
     31    _volumeType = ZINCBLENDE;
    3232
    3333    //store member tex initialize in Volume() as zincblende_tex[0]
    3434    assert(_tex);
    35     zincblende_tex[0] = _tex;
     35    zincblendeTex[0] = _tex;
    3636
    3737    //now add another tex as zincblende_tex[1]
     
    4040    secondTex->initialize(dataVolumeB);
    4141
    42     zincblende_tex[1] = secondTex;
     42    zincblendeTex[1] = secondTex;
    4343}
    4444
     
    4848    //if (zincblende_tex[0])
    4949    //  delete zincblende_tex[0];
    50     if (zincblende_tex[1])
    51         delete zincblende_tex[1];
     50    if (zincblendeTex[1])
     51        delete zincblendeTex[1];
    5252}
  • trunk/packages/vizservers/nanovis/ZincBlendeVolume.h

    r2844 r2877  
    3030    virtual ~ZincBlendeVolume();
    3131
    32     Texture3D *zincblende_tex[2];       //the textures of two cubic volumes
    33     Vector3 cell_size;  //the cell size in texture space
     32    Texture3D *zincblendeTex[2]; //the textures of two cubic volumes
     33    Vector3 cellSize;   //the cell size in texture space
    3434};
    3535
  • trunk/packages/vizservers/nanovis/config.h

    r2841 r2877  
    1818#define CONFIG_H__
    1919
    20 #define NV40                            /* Uncomment if using 6 series
    21                                          * card. By default we assume older
    22                                          * card the 5xxx series */
     20/*
     21 * GeForce 6 series and above cards support non-power-of-two texture
     22 * dimensions.  If using a 5 series card, disable this define
     23 */
     24#define HAVE_NPOT_TEXTURES
     25
     26/*
     27 * GeForce 6 series and above cards support 16- or 32-bit float filtering
     28 * and blending.  If using a 5 series card, disable this define
     29 */
     30#define HAVE_FLOAT_TEXTURES
     31
     32/*
     33 * GeForce 8 series cards support 32-bit float filtering and blending.
     34 * If using a 6 or 7 series card, enable this define to use 16-bit float
     35 * textures and blending
     36 */
     37#define USE_HALF_FLOAT
     38
    2339#define XINETD                          /* Enable render server. */
    2440//#define EVENTLOG                      /* Enable event logging. */
    2541//#define DO_RLE                        /* Do run length compression. */
    2642
     43#define KEEPSTATS               1
     44
    2745/*
    2846 * Controls if debug trace logging is enabled
    2947 */
    30 //#define WANT_TRACE
     48#define WANT_TRACE
     49
     50//#define OLD_CAMERA
    3151
    3252/*
     
    3959
    4060/*
    41  * The following define controls whether new load_volume_stream or
    42  * load_volume_stream2 are used to load DX data.  The difference is that
    43  * load_volume_stream2 doesn't do any interpolation of the points to a coarser
    44  * mesh.  Right now, we're using load_volume_stream2 to make isosurfaces
    45  * work correctly. 
    46 
     61 * The following define controls whether the new or old load_volume_stream
     62 * implementation is used to load DX data. The difference is that the old
     63 * implementation doesn't do any interpolation of the points to a coarser
     64 * mesh.  Setting ISO_TEST to 1 will cause the old implementation to be
     65 * used, which makes isosurfaces work correctly (FIXME: is this still
     66 * true?)
     67 *
    4768 * [In the future, we'll use the OpenDX library reader and determine at
    4869 * runtime if mesh decimation is required]
    4970 */
    5071#define ISO_TEST                0
     72
     73/*
     74 * Determines if Sobel filter is applied to gradients when loading a
     75 * volume
     76 */
     77#define FILTER_GRADIENTS        1
    5178
    5279/*
  • trunk/packages/vizservers/nanovis/dxReader.cpp

    r2874 r2877  
    3535#include "dxReaderCommon.h"
    3636
     37#include "config.h"
    3738#include "nanovis.h"
    3839#include "Unirect.h"
     
    265266        dz = nz;
    266267
    267         volPtr = NanoVis::load_volume(tag, nx, ny, nz, 4, data,
    268                                       vmin, vmax, nzero_min);
     268        volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data,
     269                                     vmin, vmax, nzero_min);
    269270        volPtr->xAxis.SetRange(x0, x0 + (nx * dx));
    270271        volPtr->yAxis.SetRange(y0, y0 + (ny * dy));
    271272        volPtr->zAxis.SetRange(z0, z0 + (nz * dz));
    272273        volPtr->wAxis.SetRange(vmin, vmax);
    273         volPtr->update_pending = true;
     274        volPtr->updatePending = true;
    274275        delete [] data;
    275276    } else {
     
    319320        ny = (int)ceil(dy/dmin);
    320321        nz = (int)ceil(dz/dmin);
    321 #ifndef NV40
     322#ifndef HAVE_NPOT_TEXTURES
    322323        // must be an even power of 2 for older cards
    323324        nx = (int)pow(2.0, ceil(log10((double)nx)/log10(2.0)));
     
    358359        computeSimpleGradient(data, nx, ny, nz);
    359360
    360         volPtr = NanoVis::load_volume(tag, nx, ny, nz, 4, data,
    361                                       field.valueMin(), field.valueMax(),
    362                                       nzero_min);
     361        volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data,
     362                                     field.valueMin(), field.valueMax(),
     363                                     nzero_min);
    363364        volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis),
    364365                               field.rangeMax(Rappture::xaxis));
     
    368369                               field.rangeMax(Rappture::zaxis));
    369370        volPtr->wAxis.SetRange(field.valueMin(), field.valueMax());
    370         volPtr->update_pending = true;
     371        volPtr->updatePending = true;
    371372        delete [] data;
    372373    }
     
    590591        nz = (int)ceil(dz/dmin);
    591592
    592 #ifndef NV40
     593#ifndef HAVE_NPOT_TEXTURES
    593594        // must be an even power of 2 for older cards
    594595        nx = (int)pow(2.0, ceil(log10((double)nx)/log10(2.0)));
     
    597598#endif
    598599
    599 //#define _SOBEL_
    600 #ifdef _SOBEL_
     600#ifdef FILTER_GRADIENTS
    601601        const int step = 1;
    602602        float *cdata = new float[nx*ny*nz * step];
     
    668668              field.valueMin(), field.valueMax(), nzero_min);
    669669
    670         volPtr = NanoVis::load_volume(tag, nx, ny, nz, 4, data,
    671                                       field.valueMin(), field.valueMax(),
    672                                       nzero_min);
     670        volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data,
     671                                     field.valueMin(), field.valueMax(),
     672                                     nzero_min);
    673673        volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis),
    674674                               field.rangeMax(Rappture::xaxis));
     
    678678                               field.rangeMax(Rappture::zaxis));
    679679        volPtr->wAxis.SetRange(field.valueMin(), field.valueMax());
    680         volPtr->update_pending = true;
     680        volPtr->updatePending = true;
    681681        // TBD..
    682682#if 0 && defined(USE_POINTSET_RENDERER)
     
    735735        ny = (int)ceil(dy/dmin);
    736736        nz = (int)ceil(dz/dmin);
    737 #ifndef NV40
     737#ifndef HAVE_NPOT_TEXTURES
    738738        // must be an even power of 2 for older cards
    739739        nx = (int)pow(2.0, ceil(log10((double)nx)/log10(2.0)));
     
    774774        computeSimpleGradient(data, nx, ny, nz);
    775775
    776         volPtr = NanoVis::load_volume(tag, nx, ny, nz, 4, data,
    777                                       field.valueMin(), field.valueMax(),
    778                                       nzero_min);
     776        volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data,
     777                                     field.valueMin(), field.valueMax(),
     778                                     nzero_min);
    779779        volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis),
    780780                               field.rangeMax(Rappture::xaxis));
     
    784784                               field.rangeMax(Rappture::zaxis));
    785785        volPtr->wAxis.SetRange(field.valueMin(), field.valueMax());
    786         volPtr->update_pending = true;
     786        volPtr->updatePending = true;
    787787        // TBD..
    788788#if 0 && defined(USE_POINTSET_RENDERER)
  • trunk/packages/vizservers/nanovis/dxReader.h

    r2853 r2877  
    1414                   std::iostream& fin);
    1515
    16 extern Volume *
    17 load_volume_stream2(Rappture::Outcome& status, const char *tag,
    18                     std::iostream& fin);
    19 
    2016#endif
  • trunk/packages/vizservers/nanovis/dxReaderCommon.cpp

    r2874 r2877  
    1616    for (sindex = 0; sindex < size; ++sindex) {
    1717        data[ngen++] = scalar[sindex];
    18         data[ngen++] = g[sindex].x;
    19         data[ngen++] = g[sindex].y;
    20         data[ngen++] = g[sindex].z;
     18        data[ngen++] = 1.0 - g[sindex].x;
     19        data[ngen++] = 1.0 - g[sindex].y;
     20        data[ngen++] = 1.0 - g[sindex].z;
    2121    }
    2222    return data;
     
    2929    if (v != 0.0f) {
    3030        for (int i = 0; i < count; ++i) {
    31             fdata[i] = fdata[i] / v;
     31            if (fdata[i] != -1.0) {
     32                fdata[i] = (fdata[i] - min)/ v;
     33            }
    3234        }
    3335    }
    3436}
    3537
     38/**
     39 * \brief Compute Sobel filtered gradients for a 3D volume
     40 *
     41 * This technique is fairly expensive in terms of memory and
     42 * running time due to the filter extent.
     43 */
    3644float *
    37 computeGradient(float *fdata, int width, int height, int depth,
     45computeGradient(float *fdata,
     46                int width, int height, int depth,
     47                float dx, float dy, float dz,
    3848                float min, float max)
    3949{
     
    4353                                           sizeof(float));
    4454    int sizes[3] = { width, height, depth };
    45     computeGradients(tempGradients, fdata, sizes, DATRAW_FLOAT);
     55    float spacing[3] = { dx, dy, dz };
     56    computeGradients(tempGradients, fdata, sizes, spacing, DATRAW_FLOAT);
    4657    filterGradients(tempGradients, sizes);
    4758    quantizeGradients(tempGradients, gradients, sizes, DATRAW_FLOAT);
     
    5364}
    5465
     66/**
     67 * \brief Compute gradients for a 3D volume with cubic cells
     68 *
     69 * The gradients are estimated using the central difference
     70 * method.  This function assumes the data are normalized
     71 * to [0,1] with missing data/NaNs represented by a negative
     72 * value.
     73 *
     74 * \param data Data array with X the fastest running. There
     75 * should be 4 floats allocated for each node, with the
     76 * first float containing the scalar value.  The subsequent
     77 * 3 floats will be filled with the x,y,z components of the
     78 * gradient vector
     79 * \param nx The number of nodes in the X direction
     80 * \param ny The number of nodes in the Y direction
     81 * \param nz The number of nodes in the Z direction
     82 * \param dx The spacing (cell length) in the X direction
     83 * \param dy The spacing (cell length) in the Y direction
     84 * \param dz The spacing (cell length) in the Z direction
     85 */
    5586void
    56 computeSimpleGradient(float *data, int nx, int ny, int nz)
     87computeSimpleGradient(float *data, int nx, int ny, int nz,
     88                      float dx, float dy, float dz)
    5789{
     90    bool clampToEdge = true;
     91    double borderVal = 0.0;
     92
     93#define BORDER ((clampToEdge ? data[ngen] : borderVal))
     94
    5895    // Compute the gradient of this data.  BE CAREFUL: center
    5996    // calculation on each node to avoid skew in either direction.
     
    63100            for (int ix = 0; ix < nx; ix++) {
    64101                // gradient in x-direction
    65                 double valm1 = (ix == 0) ? 0.0 : data[ngen - 4];
    66                 double valp1 = (ix == nx-1) ? 0.0 : data[ngen + 4];
     102                double valm1 = (ix == 0) ? BORDER : data[ngen - 4];
     103                double valp1 = (ix == nx-1) ? BORDER : data[ngen + 4];
    67104                if (valm1 < 0.0 || valp1 < 0.0) {
    68105                    data[ngen+1] = 0.0;
    69106                } else {
    70                     data[ngen+1] = valp1-valm1; // assume dx=1
    71                     //data[ngen+1] = ((valp1-valm1) + 1.0) * 0.5; // assume dx=1 (ISO)
    72                 }
     107                    data[ngen+1] = -(valp1-valm1)/(2. * dx);
     108                 }
    73109
    74110                // gradient in y-direction
    75                 valm1 = (iy == 0) ? 0.0 : data[ngen - 4*nx];
    76                 valp1 = (iy == ny-1) ? 0.0 : data[ngen + 4*nx];
     111                valm1 = (iy == 0) ? BORDER : data[ngen - 4*nx];
     112                valp1 = (iy == ny-1) ? BORDER : data[ngen + 4*nx];
    77113                if (valm1 < 0.0 || valp1 < 0.0) {
    78114                    data[ngen+2] = 0.0;
    79115                } else {
    80                     data[ngen+2] = valp1-valm1; // assume dy=1
    81                     //data[ngen+2] = ((valp1-valm1) + 1.0) * 0.5; // assume dy=1 (ISO)
     116                    data[ngen+2] = -(valp1-valm1)/(2. * dy);
    82117                }
    83118
    84119                // gradient in z-direction
    85                 valm1 = (iz == 0) ? 0.0 : data[ngen - 4*nx*ny];
    86                 valp1 = (iz == nz-1) ? 0.0 : data[ngen + 4*nx*ny];
     120                valm1 = (iz == 0) ? BORDER : data[ngen - 4*nx*ny];
     121                valp1 = (iz == nz-1) ? BORDER : data[ngen + 4*nx*ny];
    87122                if (valm1 < 0.0 || valp1 < 0.0) {
    88123                    data[ngen+3] = 0.0;
    89124                } else {
    90                     data[ngen+3] = valp1-valm1; // assume dz=1
    91                     //data[ngen+3] = ((valp1-valm1) + 1.0) * 0.5; // assume dz=1 (ISO)
     125                    data[ngen+3] = -(valp1-valm1)/(2. * dz);
    92126                }
    93 
     127                // Normalize and scale/bias to [0,1] range
     128                // The volume shader will expand to [-1,1]
     129                double len = sqrt(data[ngen+1]*data[ngen+1] +
     130                                  data[ngen+2]*data[ngen+2] +
     131                                  data[ngen+3]*data[ngen+3]);
     132                if (len < 1.0e-6) {
     133                    data[ngen+1] = 0.0;
     134                    data[ngen+2] = 0.0;
     135                    data[ngen+3] = 0.0;
     136                } else {
     137                    data[ngen+1] = (data[ngen+1]/len + 1.0) * 0.5;
     138                    data[ngen+2] = (data[ngen+2]/len + 1.0) * 0.5;
     139                    data[ngen+3] = (data[ngen+3]/len + 1.0) * 0.5;
     140                }
    94141                ngen += 4;
    95142            }
    96143        }
    97144    }
     145
     146#undef BORDER
    98147}
  • trunk/packages/vizservers/nanovis/dxReaderCommon.h

    r2845 r2877  
    1010
    1111extern float *
    12 computeGradient(float *fdata, int width, int height, int depth,
     12computeGradient(float *fdata,
     13                int width, int height, int depth,
     14                float dx, float dy, float dz,
    1315                float min, float max);
    1416
    1517extern void
    16 computeSimpleGradient(float *data, int nx, int ny, int nz);
     18computeSimpleGradient(float *data, int nx, int ny, int nz,
     19                      float dx = 1.0f, float dy = 1.0f, float dz = 1.0f);
    1720
    1821#endif
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r2870 r2877  
    5656#include <GL/glut.h>
    5757
     58#include "config.h"
    5859#include "nanovis.h"
    5960#include "define.h"
     
    9697};
    9798
    98 #define KEEPSTATS       1
    99 
    10099#define CVT2SECS(x)  ((double)(x).tv_sec) + ((double)(x).tv_usec * 1.0e-6)
    101100
     
    120119Tcl_HashTable NanoVis::volumeTable;
    121120Tcl_HashTable NanoVis::heightmapTable;
    122 VolumeRenderer *NanoVis::vol_renderer = NULL;
     121VolumeRenderer *NanoVis::volRenderer = NULL;
    123122#ifdef USE_POINTSET_RENDERER
    124 PointSetRenderer *NanoVis::pointset_renderer = NULL;
     123PointSetRenderer *NanoVis::pointSetRenderer = NULL;
    125124std::vector<PointSet *> NanoVis::pointSet;
    126125#endif
    127126
    128 PlaneRenderer *NanoVis::plane_renderer = NULL;
     127PlaneRenderer *NanoVis::planeRenderer = NULL;
    129128#if PLANE_CMD
    130129// pointers to 2D planes, currently handle up 10
     
    132131#endif
    133132Texture2D *NanoVis::legendTexture = NULL;
    134 NvColorTableRenderer *NanoVis::color_table_renderer = NULL;
     133NvColorTableRenderer *NanoVis::colorTableRenderer = NULL;
    135134
    136135NvFlowVisRenderer *NanoVis::flowVisRenderer = NULL;
     
    145144FILE *NanoVis::recfile = NULL;
    146145
    147 bool NanoVis::axis_on = true;
    148 bool NanoVis::config_pending = false;
    149 bool NanoVis::debug_flag = false;
     146bool NanoVis::axisOn = true;
     147bool NanoVis::debugFlag = false;
    150148
    151149Tcl_Interp *NanoVis::interp;
     
    153151
    154152//frame buffer for final rendering
    155 GLuint NanoVis::_final_color_tex = 0;
    156 GLuint NanoVis::_final_depth_rb = 0;
    157 GLuint NanoVis::_final_fbo = 0;
    158 int NanoVis::render_window = 0;       /* GLUT handle for the render window */
    159 int NanoVis::win_width = NPIX;        /* Width of the render window */
    160 int NanoVis::win_height = NPIX;       /* Height of the render window */
    161 
    162 unsigned char* NanoVis::screen_buffer = NULL;
     153GLuint NanoVis::_finalColorTex = 0;
     154GLuint NanoVis::_finalDepthRb = 0;
     155GLuint NanoVis::_finalFbo = 0;
     156int NanoVis::renderWindow = 0;       /* GLUT handle for the render window */
     157int NanoVis::winWidth = NPIX;        /* Width of the render window */
     158int NanoVis::winHeight = NPIX;       /* Height of the render window */
     159
     160unsigned char* NanoVis::screenBuffer = NULL;
    163161
    164162unsigned int NanoVis::flags = 0;
     
    179177
    180178/* FIXME: This variable is always true. */
    181 bool volume_mode = true;
     179static bool volumeMode = true;
    182180
    183181// in Command.cpp
    184182extern Tcl_Interp *initTcl();
    185 
    186 float vert[NMESH*NMESH*3];              //particle positions in main memory
    187 float slice_vector[NMESH*NMESH*4];      //per slice vectors in main memory
    188183
    189184// maps transfunc name to TransferFunction object
     
    205200
    206201// Default camera location.
    207 const float def_eye_x = -0.0f;
    208 const float def_eye_y = -0.0f;
     202const float def_eye_x = 0.0f;
     203const float def_eye_y = 0.0f;
    209204const float def_eye_z = -2.5f;
    210205
     
    221216// Image based flow visualization slice location
    222217// FLOW
    223 float NanoVis::lic_slice_x = 0.5f;
    224 float NanoVis::lic_slice_y = 0.5f;
    225 float NanoVis::lic_slice_z = 0.5f;
    226 int NanoVis::lic_axis = 2; // z axis
    227 
    228 #define RM_VOLUME 1
    229 #define RM_POINT 2
    230 
    231 int renderMode = RM_VOLUME;
    232 
    233 void removeAllData()
     218float NanoVis::_licSliceX = 0.5f;
     219float NanoVis::_licSliceY = 0.5f;
     220float NanoVis::_licSliceZ = 0.5f;
     221int NanoVis::_licAxis = 2; // z axis
     222
     223static void
     224removeAllData()
    234225{
    235226    //
     
    237228
    238229void
    239 NanoVis::EventuallyRedraw(unsigned int flag)
     230NanoVis::eventuallyRedraw(unsigned int flag)
    240231{
    241232    if (flag) {
     
    251242
    252243static int
    253 WriteStats(const char *who, int code)
     244writeStats(const char *who, int code)
    254245{
    255246    double start, finish;
     
    351342
    352343static void
    353 DoExit(int code)
    354 {
    355     TRACE("in DoExit\n");
     344doExit(int code)
     345{
     346    TRACE("in doExit\n");
    356347    removeAllData();
    357348
     
    367358
    368359#if KEEPSTATS
    369     WriteStats("nanovis", code);
     360    writeStats("nanovis", code);
    370361#endif
    371362    closelog();
     
    374365
    375366static int
    376 ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr)
     367executeCommand(Tcl_Interp *interp, Tcl_DString *dsPtr)
    377368{
    378369    struct timeval tv;
     
    397388    stats.cmdTime += finish - start;
    398389    stats.nCommands++;
    399     TRACE("leaving ExecuteCommand status=%d\n", result);
     390    TRACE("leaving executeCommand status=%d\n", result);
    400391    return result;
    401392}
     
    428419}
    429420
    430 /* Load a 3D volume
    431  * index:       the index into the volume array, which stores pointers
    432  *              to 3D volume instances
    433  * data:        pointer to an array of floats.
    434  * n_component: the number of scalars for each space point. All component
    435  *              scalars for a point are placed consequtively in data array
    436  *              width, height and depth: number of points in each dimension
     421/** \brief Load a 3D volume
     422 *
     423 * \param n_component the number of scalars for each space point. All component
     424 * scalars for a point are placed consequtively in data array
     425 * width, height and depth: number of points in each dimension
     426 * \param data pointer to an array of floats.
    437427 */
    438428Volume *
    439 NanoVis::load_volume(const char *name, int width, int height, int depth,
    440                      int n_component, float* data, double vmin, double vmax,
    441                      double nzero_min)
     429NanoVis::loadVolume(const char *name, int width, int height, int depth,
     430                    int n_component, float *data, double vmin, double vmax,
     431                    double nzero_min)
    442432{
    443433    Tcl_HashEntry *hPtr;
     
    447437        WARN("volume \"%s\" already exists", name);
    448438        volPtr = (Volume *)Tcl_GetHashValue(hPtr);
    449         remove_volume(volPtr);
     439        removeVolume(volPtr);
    450440    }
    451441    int isNew;
     
    461451// Gets a colormap 1D texture by name.
    462452TransferFunction*
    463 NanoVis::get_transfunc(const char *name)
     453NanoVis::getTransfunc(const char *name)
    464454{
    465455    Tcl_HashEntry *hPtr;
     
    474464// Creates of updates a colormap 1D texture by name.
    475465TransferFunction*
    476 NanoVis::DefineTransferFunction(const char *name, size_t n, float *data)
     466NanoVis::defineTransferFunction(const char *name, size_t n, float *data)
    477467{
    478468    int isNew;
     
    497487
    498488int
    499 NanoVis::render_legend(TransferFunction *tf, double min, double max,
    500                        int width, int height, const char* volArg)
    501 {
    502     TRACE("in render_legend\n");
    503 
    504     int old_width = win_width;
    505     int old_height = win_height;
    506 
    507     plane_renderer->set_screen_size(width, height);
    508     resize_offscreen_buffer(width, height);
     489NanoVis::renderLegend(TransferFunction *tf, double min, double max,
     490                      int width, int height, const char* volArg)
     491{
     492    TRACE("in renderLegend\n");
     493
     494    int old_width = winWidth;
     495    int old_height = winHeight;
     496
     497    planeRenderer->set_screen_size(width, height);
     498    resizeOffscreenBuffer(width, height);
    509499
    510500    // generate data for the legend
     
    514504    }
    515505    legendTexture = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data);
    516     int index = plane_renderer->add_plane(legendTexture, tf);
    517     plane_renderer->set_active_plane(index);
    518 
    519     offscreen_buffer_capture();
     506    int index = planeRenderer->add_plane(legendTexture, tf);
     507    planeRenderer->set_active_plane(index);
     508
     509    offscreenBufferCapture();
    520510    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
    521     plane_renderer->render();
     511    planeRenderer->render();
    522512
    523513    // INSOO
    524     glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);
    525     //glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, screen_buffer); // INSOO's
     514    glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, screenBuffer);
     515    //glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, screenBuffer); // INSOO's
    526516
    527517    {
     
    531521        TRACE("ppm legend image");
    532522        sprintf(prefix, "nv>legend %s %g %g", volArg, min, max);
    533         ppm_write(prefix);
     523        ppmWrite(prefix);
    534524        nWritten = write(1, "\n", 1);
    535525        assert(nWritten == 1);
    536526    }
    537     plane_renderer->remove_plane(index);
    538     resize_offscreen_buffer(old_width, old_height);
    539 
    540     TRACE("leaving render_legend\n");
     527    planeRenderer->remove_plane(index);
     528    resizeOffscreenBuffer(old_width, old_height);
     529
     530    TRACE("leaving renderLegend\n");
    541531    delete legendTexture;
    542532    return TCL_OK;
     
    545535//initialize frame buffer objects for offscreen rendering
    546536void
    547 NanoVis::init_offscreen_buffer()
    548 {
    549     TRACE("in init_offscreen_buffer\n");
     537NanoVis::initOffscreenBuffer()
     538{
     539    TRACE("in initOffscreenBuffer\n");
    550540    // Initialize a fbo for final display.
    551     glGenFramebuffersEXT(1, &_final_fbo);
    552 
    553     glGenTextures(1, &_final_color_tex);
    554     glBindTexture(GL_TEXTURE_2D, _final_color_tex);
     541    glGenFramebuffersEXT(1, &_finalFbo);
     542
     543    glGenTextures(1, &_finalColorTex);
     544    glBindTexture(GL_TEXTURE_2D, _finalColorTex);
    555545
    556546    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    557547    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    558 #ifdef NV40
    559     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, win_width, win_height, 0,
     548#if defined(HAVE_FLOAT_TEXTURES) && defined(USE_HALF_FLOAT)
     549    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, winWidth, winHeight, 0,
     550                 GL_RGB, GL_INT, NULL);
     551#elif defined(HAVE_FLOAT_TEXTURES)
     552    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, winWidth, winHeight, 0,
    560553                 GL_RGB, GL_INT, NULL);
    561554#else
    562     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, win_width, win_height, 0,
     555    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, winWidth, winHeight, 0,
    563556                 GL_RGB, GL_INT, NULL);
    564557#endif
    565     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final_fbo);
    566     glGenRenderbuffersEXT(1, &_final_depth_rb);
    567     glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _final_depth_rb);
     558    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
     559    glGenRenderbuffersEXT(1, &_finalDepthRb);
     560    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _finalDepthRb);
    568561    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
    569                              win_width, win_height);
     562                             winWidth, winHeight);
    570563    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
    571                               GL_TEXTURE_2D, _final_color_tex, 0);
     564                              GL_TEXTURE_2D, _finalColorTex, 0);
    572565    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
    573                                  GL_RENDERBUFFER_EXT, _final_depth_rb);
     566                                 GL_RENDERBUFFER_EXT, _finalDepthRb);
    574567
    575568    GLenum status;
    576569    if (!CheckFBO(&status)) {
    577         PrintFBOStatus(status, "final_fbo");
    578             DoExit(3);
     570        PrintFBOStatus(status, "finalFbo");
     571        doExit(3);
    579572    }
    580573
     
    583576
    584577    //assert(glGetError()==0);
    585     TRACE("leaving init_offscreen_buffer\n");
     578    TRACE("leaving initOffscreenBuffer\n");
    586579}
    587580
    588581//resize the offscreen buffer
    589582void
    590 NanoVis::resize_offscreen_buffer(int w, int h)
    591 {
    592     TRACE("in resize_offscreen_buffer(%d, %d)\n", w, h);
    593     if ((w == win_width) && (h == win_height)) {
     583NanoVis::resizeOffscreenBuffer(int w, int h)
     584{
     585    TRACE("in resizeOffscreenBuffer(%d, %d)\n", w, h);
     586    if ((w == winWidth) && (h == winHeight)) {
    594587        return;
    595588    }
    596     win_width = w;
    597     win_height = h;
     589    winWidth = w;
     590    winHeight = h;
    598591
    599592    if (fonts) {
    600593        fonts->resize(w, h);
    601594    }
    602     TRACE("screen_buffer size: %d %d\n", w, h);
    603 
    604     if (screen_buffer != NULL) {
    605         delete [] screen_buffer;
    606         screen_buffer = NULL;
    607     }
    608 
    609     screen_buffer = new unsigned char[4*win_width*win_height];
    610     assert(screen_buffer != NULL);
     595    TRACE("screenBuffer size: %d %d\n", w, h);
     596
     597    if (screenBuffer != NULL) {
     598        delete [] screenBuffer;
     599        screenBuffer = NULL;
     600    }
     601
     602    screenBuffer = new unsigned char[4*winWidth*winHeight];
     603    assert(screenBuffer != NULL);
    611604   
    612605    //delete the current render buffer resources
    613     glDeleteTextures(1, &_final_color_tex);
    614     glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _final_depth_rb);
    615     glDeleteRenderbuffersEXT(1, &_final_depth_rb);
     606    glDeleteTextures(1, &_finalColorTex);
     607    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _finalDepthRb);
     608    glDeleteRenderbuffersEXT(1, &_finalDepthRb);
    616609
    617610    TRACE("before deleteframebuffers\n");
    618     glDeleteFramebuffersEXT(1, &_final_fbo);
     611    glDeleteFramebuffersEXT(1, &_finalFbo);
    619612
    620613    TRACE("reinitialize FBO\n");
    621614    //Reinitialize final fbo for final display
    622     glGenFramebuffersEXT(1, &_final_fbo);
    623 
    624     glGenTextures(1, &_final_color_tex);
    625     glBindTexture(GL_TEXTURE_2D, _final_color_tex);
     615    glGenFramebuffersEXT(1, &_finalFbo);
     616
     617    glGenTextures(1, &_finalColorTex);
     618    glBindTexture(GL_TEXTURE_2D, _finalColorTex);
    626619
    627620    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    628621    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    629 #ifdef NV40
    630     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, win_width, win_height, 0,
     622#if defined(HAVE_FLOAT_TEXTURES) && defined(USE_HALF_FLOAT)
     623    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, winWidth, winHeight, 0,
     624                 GL_RGB, GL_INT, NULL);
     625#elif defined(HAVE_FLOAT_TEXTURES)
     626    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, winWidth, winHeight, 0,
    631627                 GL_RGB, GL_INT, NULL);
    632628#else
    633     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, win_width, win_height, 0,
     629    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, winWidth, winHeight, 0,
    634630                 GL_RGB, GL_INT, NULL);
    635631#endif
    636632    TRACE("before bindframebuffer\n");
    637     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final_fbo);
     633    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
    638634    TRACE("after bindframebuffer\n");
    639     glGenRenderbuffersEXT(1, &_final_depth_rb);
    640     glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _final_depth_rb);
     635    glGenRenderbuffersEXT(1, &_finalDepthRb);
     636    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _finalDepthRb);
    641637    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
    642                              win_width, win_height);
     638                             winWidth, winHeight);
    643639    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
    644                               GL_TEXTURE_2D, _final_color_tex, 0);
     640                              GL_TEXTURE_2D, _finalColorTex, 0);
    645641    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
    646                                  GL_RENDERBUFFER_EXT, _final_depth_rb);
     642                                 GL_RENDERBUFFER_EXT, _finalDepthRb);
    647643
    648644    GLenum status;
    649645    if (!CheckFBO(&status)) {
    650         PrintFBOStatus(status, "final_fbo");
    651         DoExit(3);
     646        PrintFBOStatus(status, "finalFbo");
     647        doExit(3);
    652648    }
    653649
     
    655651    TRACE("change camera\n");
    656652    //change the camera setting
    657     cam->set_screen_size(0, 0, win_width, win_height);
    658     plane_renderer->set_screen_size(win_width, win_height);
    659 
    660     TRACE("leaving resize_offscreen_buffer(%d, %d)\n", w, h);
     653    cam->set_screen_size(0, 0, winWidth, winHeight);
     654    planeRenderer->set_screen_size(winWidth, winHeight);
     655
     656    TRACE("leaving resizeOffscreenBuffer(%d, %d)\n", w, h);
    661657}
    662658
     
    668664 *      to turn it back on.
    669665 */
    670 void
    671 make_test_2D_data()
     666static void
     667makeTest2DData()
    672668{
    673669    int w = 300;
     
    693689}
    694690
    695 void CgErrorCallback(void)
     691static
     692void cgErrorCallback(void)
    696693{
    697694    if (!NvShader::printErrorInfo()) {
    698695        TRACE("Cg error, exiting...\n");
    699         DoExit(-1);
     696        doExit(-1);
    700697    }
    701698}
     
    712709    if (path == NULL) {
    713710        ERROR("No path defined for shaders or resources\n");
    714         DoExit(1);
     711        doExit(1);
    715712    }
    716713    GLenum err = glewInit();
    717714    if (GLEW_OK != err) {
    718         ERROR("%s\n", glewGetErrorString(err));
    719         getchar();
    720         //assert(false);
     715        ERROR("Can't init GLEW: %s\n", glewGetErrorString(err));
     716        doExit(1);
    721717    }
    722718    TRACE("Using GLEW %s\n", glewGetString(GLEW_VERSION));
     719
     720    if (!GLEW_EXT_framebuffer_object) {
     721        ERROR("EXT_framebuffer_oject extension is required to run nanovis\n");
     722        doExit(1);
     723    }
     724#ifdef HAVE_NPOT_TEXTURES
     725    if (!GLEW_ARB_texture_non_power_of_two) {
     726        ERROR("GLEW_ARB_texture_non_power_of_two extension is required to run nanovis\n");
     727        doExit(1);
     728    }
     729#endif
     730#ifdef HAVE_FLOAT_TEXTURES
     731    if (!GLEW_ARB_texture_float ||
     732        !GLEW_ARB_color_buffer_float) {
     733        ERROR("ARB_texture_float and ARB_color_buffer_float extensions are required to run nanovis\n");
     734        doExit(1);
     735    }
     736#endif
    723737
    724738    if (!R2FilePath::getInstance()->setPath(path)) {
    725739        ERROR("can't set file path to %s\n", path);
    726         DoExit(1);
     740        doExit(1);
    727741    }
    728742
     
    732746
    733747    NvShader::initCg();
    734     NvShader::setErrorCallback(CgErrorCallback);
     748    NvShader::setErrorCallback(cgErrorCallback);
    735749
    736750    fonts = new R2Fonts();
     
    738752    fonts->setFont("verdana");
    739753
    740     color_table_renderer = new NvColorTableRenderer();
    741     color_table_renderer->setFonts(fonts);
     754    colorTableRenderer = new NvColorTableRenderer();
     755    colorTableRenderer->setFonts(fonts);
    742756
    743757    flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH);
     
    745759    NanoVis::velocityArrowsSlice = new VelocityArrowsSlice;
    746760
    747     licRenderer = new NvLIC(NMESH, NPIX, NPIX, lic_axis,
    748                             Vector3(lic_slice_x, lic_slice_y, lic_slice_z),
     761    licRenderer = new NvLIC(NMESH, NPIX, NPIX, _licAxis,
     762                            Vector3(_licSliceX, _licSliceY, _licSliceZ),
    749763                            NvShader::getCgContext());
    750764
     
    753767
    754768#ifdef USE_POINTSET_RENDERER
    755     pointset_renderer = new PointSetRenderer();
     769    pointSetRenderer = new PointSetRenderer();
    756770#endif
    757771}
     
    763777    TRACE("in initGL\n");
    764778    //buffer to store data read from the screen
    765     if (screen_buffer) {
    766         delete[] screen_buffer;
    767         screen_buffer = NULL;
    768     }
    769     screen_buffer = new unsigned char[4*win_width*win_height];
    770     assert(screen_buffer != NULL);
     779    if (screenBuffer) {
     780        delete[] screenBuffer;
     781        screenBuffer = NULL;
     782    }
     783    screenBuffer = new unsigned char[4*winWidth*winHeight];
     784    assert(screenBuffer != NULL);
    771785
    772786    //create the camera with default setting
    773     cam = new NvCamera(0, 0, win_width, win_height,
     787    cam = new NvCamera(0, 0, winWidth, winHeight,
    774788                       def_eye_x, def_eye_y, def_eye_z,          /* location. */
    775789                       def_target_x, def_target_y, def_target_z, /* target. */
     
    781795
    782796    glClearColor(0,0,0,1);
    783     //glClearColor(0.7,0.7,0.7,1);
    784797    glClear(GL_COLOR_BUFFER_BIT);
    785798
     
    801814
    802815    //check if performance query is supported
    803     if(check_query_support()){
     816    if (PerfQuery::checkQuerySupport()) {
    804817        //create queries to count number of rendered pixels
    805818        perf = new PerfQuery();
    806819    }
    807820
    808     init_offscreen_buffer();    //frame buffer object for offscreen rendering
     821    initOffscreenBuffer();    //frame buffer object for offscreen rendering
    809822
    810823    //create volume renderer and add volumes to it
    811     vol_renderer = new VolumeRenderer();
     824    volRenderer = new VolumeRenderer();
    812825
    813826    // create
     
    815828
    816829    //create a 2D plane renderer
    817     plane_renderer = new PlaneRenderer(win_width, win_height);
     830    planeRenderer = new PlaneRenderer(winWidth, winHeight);
    818831#if PROTOTYPE
    819832    make_test_2D_data();
    820     plane_renderer->add_plane(plane[0], get_transfunc("default"));
     833    planeRenderer->add_plane(plane[0], getTransfunc("default"));
    821834#endif
    822835
     
    828841#if DO_RLE
    829842char rle[512*512*3];
    830 int rle_size;
     843int rleSize;
    831844
    832845short offsets[512*512*3];
    833 int offsets_size;
    834 
    835 void
    836 do_rle()
    837 {
    838     int len = NanoVis::win_width*NanoVis::win_height*3;
    839     rle_size = 0;
    840     offsets_size = 0;
    841 
    842     int i=0;
    843     while(i<len){
    844         if (NanoVis::screen_buffer[i] == 0) {
     846int offsetsSize;
     847
     848static void
     849doRle()
     850{
     851    int len = NanoVis::winWidth*NanoVis::winHeight*3;
     852    rleSize = 0;
     853    offsetsSize = 0;
     854
     855    int i = 0;
     856    while (i < len) {
     857        if (NanoVis::screenBuffer[i] == 0) {
    845858            int pos = i+1;
    846             while ( (pos<len) && (NanoVis::screen_buffer[pos] == 0)) {
     859            while ( (pos < len) && (NanoVis::screenBuffer[pos] == 0)) {
    847860                pos++;
    848861            }
    849             offsets[offsets_size++] = -(pos - i);
     862            offsets[offsetsSize++] = -(pos - i);
    850863            i = pos;
    851864        }
     
    853866        else {
    854867            int pos;
    855             for (pos = i; (pos<len) && (NanoVis::screen_buffer[pos] != 0);pos++){
    856                 rle[rle_size++] = NanoVis::screen_buffer[pos];
     868            for (pos = i; (pos < len) && (NanoVis::screenBuffer[pos] != 0); pos++){
     869                rle[rleSize++] = NanoVis::screenBuffer[pos];
    857870            }
    858             offsets[offsets_size++] = (pos - i);
     871            offsets[offsetsSize++] = (pos - i);
    859872            i = pos;
    860873        }
     
    867880// Writes an integer value into the header data structure at pos
    868881static inline void
    869 bmp_header_add_int(unsigned char* header, int& pos, int data)
     882bmpHeaderAddInt(unsigned char* header, int& pos, int data)
    870883{
    871884#ifdef WORDS_BIGENDIAN
     
    885898// FOR DEBUGGING
    886899void
    887 NanoVis::bmp_write_to_file(int frame_number, const char *directory_name)
     900NanoVis::bmpWriteToFile(int frame_number, const char *directory_name)
    888901{
    889902    unsigned char header[SIZEOF_BMP_HEADER];
     
    895908    // on each scan line.  If need be, we add padding to each line.
    896909    int pad = 0;
    897     if ((3*win_width) % 4 > 0) {
    898         pad = 4 - ((3*win_width) % 4);
     910    if ((3*winWidth) % 4 > 0) {
     911        pad = 4 - ((3*winWidth) % 4);
    899912    }
    900913
    901914    // file size in bytes
    902     int fsize = (3*win_width+pad)*win_height + SIZEOF_BMP_HEADER;
    903     bmp_header_add_int(header, pos, fsize);
     915    int fsize = (3*winWidth+pad)*winHeight + SIZEOF_BMP_HEADER;
     916    bmpHeaderAddInt(header, pos, fsize);
    904917
    905918    // reserved value (must be 0)
    906     bmp_header_add_int(header, pos, 0);
     919    bmpHeaderAddInt(header, pos, 0);
    907920
    908921    // offset in bytes to start of bitmap data
    909     bmp_header_add_int(header, pos, SIZEOF_BMP_HEADER);
     922    bmpHeaderAddInt(header, pos, SIZEOF_BMP_HEADER);
    910923
    911924    // size of the BITMAPINFOHEADER
    912     bmp_header_add_int(header, pos, 40);
     925    bmpHeaderAddInt(header, pos, 40);
    913926
    914927    // width of the image in pixels
    915     bmp_header_add_int(header, pos, win_width);
     928    bmpHeaderAddInt(header, pos, winWidth);
    916929
    917930    // height of the image in pixels
    918     bmp_header_add_int(header, pos, win_height);
     931    bmpHeaderAddInt(header, pos, winHeight);
    919932
    920933    // 1 plane + (24 bits/pixel << 16)
    921     bmp_header_add_int(header, pos, 1572865);
     934    bmpHeaderAddInt(header, pos, 1572865);
    922935
    923936    // no compression
    924937    // size of image for compression
    925     bmp_header_add_int(header, pos, 0);
    926     bmp_header_add_int(header, pos, 0);
     938    bmpHeaderAddInt(header, pos, 0);
     939    bmpHeaderAddInt(header, pos, 0);
    927940
    928941    // x pixels per meter
    929942    // y pixels per meter
    930     bmp_header_add_int(header, pos, 0);
    931     bmp_header_add_int(header, pos, 0);
     943    bmpHeaderAddInt(header, pos, 0);
     944    bmpHeaderAddInt(header, pos, 0);
    932945
    933946    // number of colors used (0 = compute from bits/pixel)
    934947    // number of important colors (0 = all colors important)
    935     bmp_header_add_int(header, pos, 0);
    936     bmp_header_add_int(header, pos, 0);
     948    bmpHeaderAddInt(header, pos, 0);
     949    bmpHeaderAddInt(header, pos, 0);
    937950
    938951    // BE CAREFUL: BMP format wants BGR ordering for screen data
    939     unsigned char* scr = screen_buffer;
    940     for (int row=0; row < win_height; row++) {
    941         for (int col=0; col < win_width; col++) {
     952    unsigned char* scr = screenBuffer;
     953    for (int row=0; row < winHeight; row++) {
     954        for (int col=0; col < winWidth; col++) {
    942955            unsigned char tmp = scr[2];
    943956            scr[2] = scr[0];  // B
     
    970983        ERROR("can't write header: short write\n");
    971984    }
    972     if (fwrite(screen_buffer, (3*win_width+pad)*win_height, 1, f) != 1) {
     985    if (fwrite(screenBuffer, (3*winWidth+pad)*winHeight, 1, f) != 1) {
    973986        ERROR("can't write data: short write\n");
    974987    }
     
    977990
    978991void
    979 NanoVis::bmp_write(const char *prefix)
     992NanoVis::bmpWrite(const char *prefix)
    980993{
    981994    unsigned char header[SIZEOF_BMP_HEADER];
     
    986999    // on each scan line.  If need be, we add padding to each line.
    9871000    int pad = 0;
    988     if ((3*win_width) % 4 > 0) {
    989         pad = 4 - ((3*win_width) % 4);
     1001    if ((3*winWidth) % 4 > 0) {
     1002        pad = 4 - ((3*winWidth) % 4);
    9901003    }
    9911004    pad = 0;
    992     int fsize = (3*win_width+pad)*win_height + sizeof(header);
     1005    int fsize = (3*winWidth+pad)*winHeight + sizeof(header);
    9931006
    9941007    char string[200];
     
    10001013
    10011014    // file size in bytes
    1002     bmp_header_add_int(header, pos, fsize);
     1015    bmpHeaderAddInt(header, pos, fsize);
    10031016
    10041017    // reserved value (must be 0)
    1005     bmp_header_add_int(header, pos, 0);
     1018    bmpHeaderAddInt(header, pos, 0);
    10061019
    10071020    // offset in bytes to start of bitmap data
    1008     bmp_header_add_int(header, pos, SIZEOF_BMP_HEADER);
     1021    bmpHeaderAddInt(header, pos, SIZEOF_BMP_HEADER);
    10091022
    10101023    // size of the BITMAPINFOHEADER
    1011     bmp_header_add_int(header, pos, 40);
     1024    bmpHeaderAddInt(header, pos, 40);
    10121025
    10131026    // width of the image in pixels
    1014     bmp_header_add_int(header, pos, win_width);
     1027    bmpHeaderAddInt(header, pos, winWidth);
    10151028
    10161029    // height of the image in pixels
    1017     bmp_header_add_int(header, pos, win_height);
     1030    bmpHeaderAddInt(header, pos, winHeight);
    10181031
    10191032    // 1 plane + (24 bits/pixel << 16)
    1020     bmp_header_add_int(header, pos, 1572865);
     1033    bmpHeaderAddInt(header, pos, 1572865);
    10211034
    10221035    // no compression
    10231036    // size of image for compression
    1024     bmp_header_add_int(header, pos, 0);
    1025     bmp_header_add_int(header, pos, 0);
     1037    bmpHeaderAddInt(header, pos, 0);
     1038    bmpHeaderAddInt(header, pos, 0);
    10261039
    10271040    // x pixels per meter
    10281041    // y pixels per meter
    1029     bmp_header_add_int(header, pos, 0);
    1030     bmp_header_add_int(header, pos, 0);
     1042    bmpHeaderAddInt(header, pos, 0);
     1043    bmpHeaderAddInt(header, pos, 0);
    10311044
    10321045    // number of colors used (0 = compute from bits/pixel)
    10331046    // number of important colors (0 = all colors important)
    1034     bmp_header_add_int(header, pos, 0);
    1035     bmp_header_add_int(header, pos, 0);
     1047    bmpHeaderAddInt(header, pos, 0);
     1048    bmpHeaderAddInt(header, pos, 0);
    10361049
    10371050    // BE CAREFUL: BMP format wants BGR ordering for screen data
    1038     unsigned char* scr = screen_buffer;
    1039     for (int row=0; row < win_height; row++) {
    1040         for (int col=0; col < win_width; col++) {
     1051    unsigned char* scr = screenBuffer;
     1052    for (int row=0; row < winHeight; row++) {
     1053        for (int col=0; col < winWidth; col++) {
    10411054            unsigned char tmp = scr[2];
    10421055            scr[2] = scr[0];  // B
     
    10491062    nWritten = write(1, header, SIZEOF_BMP_HEADER);
    10501063    assert(nWritten == SIZEOF_BMP_HEADER);
    1051     nWritten = write(1, screen_buffer, (3*win_width+pad)*win_height);
    1052     assert(nWritten == (3*win_width+pad)*win_height);
     1064    nWritten = write(1, screenBuffer, (3*winWidth+pad)*winHeight);
     1065    assert(nWritten == (3*winWidth+pad)*winHeight);
    10531066    stats.nFrames++;
    1054     stats.nBytes += (3*win_width+pad)*win_height;
     1067    stats.nBytes += (3*winWidth+pad)*winHeight;
    10551068}
    10561069
    10571070/*
    1058  * ppm_write --
     1071 * ppmWrite --
    10591072 *
    10601073 *  Writes the screen image as PPM binary data to the nanovisviewer
     
    10741087 */
    10751088void
    1076 NanoVis::ppm_write(const char *prefix)
     1089NanoVis::ppmWrite(const char *prefix)
    10771090{
    10781091#define PPM_MAXVAL 255
    10791092    char header[200];
    10801093
    1081     TRACE("Enter ppm_write (%dx%d)\n", win_width, win_height);
     1094    TRACE("Enter ppmWrite (%dx%d)\n", winWidth, winHeight);
    10821095    // Generate the PPM binary file header
    1083     sprintf(header, "P6 %d %d %d\n", win_width, win_height, PPM_MAXVAL);
     1096    sprintf(header, "P6 %d %d %d\n", winWidth, winHeight, PPM_MAXVAL);
    10841097
    10851098    size_t header_length = strlen(header);
    1086     size_t data_length = win_width * win_height * 3;
     1099    size_t data_length = winWidth * winHeight * 3;
    10871100
    10881101    char command[200];
     
    10901103            (unsigned long)header_length + data_length);
    10911104
    1092     size_t wordsPerRow = (win_width * 24 + 31) / 32;
     1105    size_t wordsPerRow = (winWidth * 24 + 31) / 32;
    10931106    size_t bytesPerRow = wordsPerRow * 4;
    1094     size_t rowLength = win_width * 3;
    1095     size_t nRecs = win_height + 2;
     1107    size_t rowLength = winWidth * 3;
     1108    size_t nRecs = winHeight + 2;
    10961109
    10971110    struct iovec *iov;
     
    11071120    // Image data.
    11081121    int y;
    1109     unsigned char *srcRowPtr = screen_buffer;
    1110     for (y = win_height + 1; y >= 2; y--) {
     1122    unsigned char *srcRowPtr = screenBuffer;
     1123    for (y = winHeight + 1; y >= 2; y--) {
    11111124        iov[y].iov_base = srcRowPtr;
    11121125        iov[y].iov_len = rowLength;
     
    11181131    free(iov);
    11191132    stats.nFrames++;
    1120     stats.nBytes += (bytesPerRow * win_height);
    1121     TRACE("Leaving ppm_write (%dx%d)\n", win_width, win_height);
     1133    stats.nBytes += (bytesPerRow * winHeight);
     1134    TRACE("Leaving ppmWrite (%dx%d)\n", winWidth, winHeight);
    11221135}
    11231136
     
    11291142
    11301143      // Generate the PPM binary file header
    1131       sprintf(header, "P6 %d %d %d\n", win_width, win_height, PPM_MAXVAL);
     1144      sprintf(header, "P6 %d %d %d\n", winWidth, winHeight, PPM_MAXVAL);
    11321145
    11331146      size_t header_length = strlen(header);
    1134       size_t data_length = win_width * win_height * 3;
     1147      size_t data_length = winWidth * winHeight * 3;
    11351148
    11361149      char command[200];
     
    11391152    */
    11401153
    1141     //    size_t wordsPerRow = (win_width * 24 + 31) / 32;
     1154    //    size_t wordsPerRow = (winWidth * 24 + 31) / 32;
    11421155    //    size_t bytesPerRow = wordsPerRow * 4;
    1143     //    size_t rowLength = win_width * 3;
     1156    //    size_t rowLength = winWidth * 3;
    11441157    size_t nRecs = 2;
    11451158
     
    11601173    delete [] iov;
    11611174    // stats.nFrames++;
    1162     // stats.nBytes += (bytesPerRow * win_height);
     1175    // stats.nBytes += (bytesPerRow * winHeight);
    11631176}
    11641177
     
    11691182{
    11701183    TRACE("in idle()\n");
    1171     glutSetWindow(render_window);
     1184    glutSetWindow(renderWindow);
    11721185
    11731186#ifdef XINETD
    1174     xinetd_listen();
     1187    xinetdListen();
    11751188#else
    11761189    glutPostRedisplay();
     
    11801193
    11811194void
    1182 NanoVis::display_offscreen_buffer()
     1195NanoVis::displayOffscreenBuffer()
    11831196{
    11841197    TRACE("in display_offscreen_buffer\n");
    11851198    glEnable(GL_TEXTURE_2D);
    11861199    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    1187     glBindTexture(GL_TEXTURE_2D, _final_color_tex);
    1188 
    1189     glViewport(0, 0, win_width, win_height);
     1200    glBindTexture(GL_TEXTURE_2D, _finalColorTex);
     1201
     1202    glViewport(0, 0, winWidth, winHeight);
    11901203    glMatrixMode(GL_PROJECTION);
    11911204    glLoadIdentity();
    1192     gluOrtho2D(0, win_width, 0, win_height);
     1205    gluOrtho2D(0, winWidth, 0, winHeight);
    11931206    glMatrixMode(GL_MODELVIEW);
    11941207    glLoadIdentity();
     
    11981211    {
    11991212        glTexCoord2f(0, 0); glVertex2f(0, 0);
    1200         glTexCoord2f(1, 0); glVertex2f(win_width, 0);
    1201         glTexCoord2f(1, 1); glVertex2f(win_width, win_height);
    1202         glTexCoord2f(0, 1); glVertex2f(0, win_height);
     1213        glTexCoord2f(1, 0); glVertex2f(winWidth, 0);
     1214        glTexCoord2f(1, 1); glVertex2f(winWidth, winHeight);
     1215        glTexCoord2f(0, 1); glVertex2f(0, winHeight);
    12031216    }
    12041217    glEnd();
     
    12081221#if 0
    12091222//oddeven sort on GPU
    1210 void
     1223static void
    12111224sortstep()
    12121225{
     
    12871300#endif
    12881301
    1289 void
    1290 draw_3d_axis()
     1302static void
     1303draw3dAxis()
    12911304{
    12921305    glDisable(GL_TEXTURE_2D);
     
    13791392void NanoVis::update()
    13801393{
    1381     if (vol_renderer->_volumeInterpolator->is_started()) {
     1394    if (volRenderer->_volumeInterpolator->isStarted()) {
    13821395        struct timeval clock;
    13831396        gettimeofday(&clock, NULL);
     
    13851398
    13861399        elapsed_time = clock.tv_sec + clock.tv_usec/1000000.0 -
    1387             vol_renderer->_volumeInterpolator->getStartTime();
     1400            volRenderer->_volumeInterpolator->getStartTime();
    13881401
    13891402        TRACE("%lf %lf\n", elapsed_time,
    1390                vol_renderer->_volumeInterpolator->getInterval());
     1403               volRenderer->_volumeInterpolator->getInterval());
    13911404        float fraction;
    13921405        float f;
    13931406
    1394         f = fmod((float) elapsed_time, (float)vol_renderer->_volumeInterpolator->getInterval());
     1407        f = fmod((float) elapsed_time, (float)volRenderer->_volumeInterpolator->getInterval());
    13951408        if (f == 0.0) {
    13961409            fraction = 0.0f;
    13971410        } else {
    1398             fraction = f / vol_renderer->_volumeInterpolator->getInterval();
     1411            fraction = f / volRenderer->_volumeInterpolator->getInterval();
    13991412        }
    14001413        TRACE("fraction : %f\n", fraction);
    1401         vol_renderer->_volumeInterpolator->update(fraction);
     1414        volRenderer->_volumeInterpolator->update(fraction);
    14021415    }
    14031416}
    14041417
    14051418void
    1406 NanoVis::SetVolumeRanges()
     1419NanoVis::setVolumeRanges()
    14071420{
    14081421    double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
     
    14541467        Volume::valueMax = wMax;
    14551468    }
    1456     Volume::update_pending = false;
     1469    Volume::updatePending = false;
    14571470    TRACE("leaving SetVolumeRanges\n");
    14581471}
    14591472
    14601473void
    1461 NanoVis::SetHeightmapRanges()
     1474NanoVis::setHeightmapRanges()
    14621475{
    14631476    double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
    14641477
    1465     TRACE("in SetHeightmapRanges\n");
     1478    TRACE("in setHeightmapRanges\n");
    14661479    xMin = yMin = zMin = wMin = DBL_MAX;
    14671480    xMax = yMax = zMax = wMax = -DBL_MAX;
     
    15151528        hmPtr->MapToGrid(grid);
    15161529    }
    1517     HeightMap::update_pending = false;
    1518     TRACE("leaving SetHeightmapRanges\n");
     1530    HeightMap::updatePending = false;
     1531    TRACE("leaving setHeightmapRanges\n");
    15191532}
    15201533
     
    15371550    }
    15381551    //assert(glGetError()==0);
    1539     if (HeightMap::update_pending) {
    1540         SetHeightmapRanges();
    1541     }
    1542     if (Volume::update_pending) {
    1543         SetVolumeRanges();
     1552    if (HeightMap::updatePending) {
     1553        setHeightmapRanges();
     1554    }
     1555    if (Volume::updatePending) {
     1556        setVolumeRanges();
    15441557    }
    15451558    TRACE("in display: glClear\n");
     
    15471560    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
    15481561
    1549     if (volume_mode) {
    1550         TRACE("in display: volume_mode\n");
     1562    if (volumeMode) {
     1563        TRACE("in display: volumeMode\n");
    15511564        //3D rendering mode
    15521565        // TBD..
     
    15881601
    15891602        //now render things in the scene
    1590         if (axis_on) {
    1591             draw_3d_axis();
     1603        if (axisOn) {
     1604            draw3dAxis();
    15921605        }
    15931606        if (grid->isVisible()) {
     
    16171630
    16181631        //perf->enable();
    1619         vol_renderer->render_all();
     1632        volRenderer->renderAll();
    16201633        //perf->disable();
    16211634
     
    16371650        //2D rendering mode
    16381651        perf->enable();
    1639         plane_renderer->render();
     1652        planeRenderer->render();
    16401653        perf->disable();
    16411654    }
     
    16781691
    16791692void
    1680 NanoVis::update_rot(int delta_x, int delta_y)
     1693NanoVis::updateRot(int delta_x, int delta_y)
    16811694{
    16821695    Vector3 angle;
     
    17001713
    17011714void
    1702 NanoVis::update_trans(int delta_x, int delta_y, int delta_z)
     1715NanoVis::updateTrans(int delta_x, int delta_y, int delta_z)
    17031716{
    17041717    cam->x(cam->x() + delta_x * 0.03);
     
    17071720}
    17081721
     1722#ifdef notdef
     1723static
    17091724void addVectorField(const char* filename, const char* vf_name,
    17101725                    const char* plane_name1, const char* plane_name2,
     
    17191734        Volume *volPtr = NanoVis::volume[n];
    17201735        if (volPtr != NULL) {
    1721             volPtr->set_n_slice(256-n);
    1722             // volPtr->set_n_slice(512-n);
    1723             volPtr->disable_cutplane(0);
    1724             volPtr->disable_cutplane(1);
    1725             volPtr->disable_cutplane(2);
    1726             volPtr->transferFunction(NanoVis::get_transfunc("default"));
     1736            volPtr->numSlices(256-n);
     1737            // volPtr->numSlices(512-n);
     1738            volPtr->disableCutplane(0);
     1739            volPtr->disableCutplane(1);
     1740            volPtr->disableCutplane(2);
     1741            volPtr->transferFunction(NanoVis::getTransfunc("default"));
    17271742
    17281743            float dx0 = -0.5;
     
    17331748            volPtr->data(false);
    17341749            NanoVis::flowVisRenderer->addVectorField(vf_name, volPtr,
    1735                 *(volPtr->get_location()),
     1750                volPtr->location(),
    17361751                1.0f,
    17371752                volPtr->height / (float)volPtr->width,
     
    17591774                setVectorField(volPtr->id,
    17601775                               *(volPtr->get_location()),
    1761                                1.0f / volPtr->aspect_ratio_width,
    1762                                1.0f / volPtr->aspect_ratio_height,
    1763                                1.0f / volPtr->aspect_ratio_depth,
     1776                               1.0f / volPtr->aspectRatioWidth,
     1777                               1.0f / volPtr->aspectRatioHeight,
     1778                               1.0f / volPtr->aspectRatioDepth,
    17641779                               volPtr->wAxis.max());
    17651780        }
     
    17671782    //NanoVis::initParticle();
    17681783}
     1784#endif
    17691785
    17701786void
     
    17721788{
    17731789#ifdef EVENTLOG
    1774     if(log){
     1790    if (log) {
    17751791        float param[3];
    17761792        param[0] = cam->x();
     
    18071823                "}\n"
    18081824            };
     1825            Tcl_Eval(interp, cmd);
    18091826#ifdef notdef
    18101827            NanoVis::flowVisRenderer->active(false);
     
    18181835            char cmd[] = {
    18191836                "flow create flow1\n"
    1820                 "flow1 data file /home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/jwire/J-wire-vec.dx 3\n"
     1837                "flow1 data file data/flowvis_dx_files/jwire/J-wire-vec.dx 3\n"
    18211838                "flow1 particles add plane1 -color { 0 0 1 1 }\n"
    18221839                "flow1 particles add plane2 -color { 0 1 1 1 }\n"
     
    18241841            Tcl_Eval(interp, cmd);
    18251842#ifdef notdef
    1826             addVectorField("/home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/jwire/J-wire-vec.dx",
     1843            addVectorField("data/flowvis_dx_files/jwire/J-wire-vec.dx",
    18271844                           "vf_name2", "plane_name1", "plane_name2", Vector4(0, 0, 1, 1), Vector4(0, 1, 1, 1));
    18281845#endif
     
    18331850            char cmd[] = {
    18341851                "flow create flow2\n"
    1835                 "flow2 data file /home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx 3\n"
     1852                "flow2 data file data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx 3\n"
    18361853                "flow2 particles add plane1 -color { 1 0 0 1 }\n"
    18371854                "flow2 particles add plane2 -color { 1 1 0 1 }\n"
     
    18391856            Tcl_Eval(interp, cmd);
    18401857            TRACE("add vector field\n");
    1841             addVectorField("/home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx",
     1858#ifdef notdef
     1859            addVectorField("data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx",
    18421860                           "vf_name1", "plane_name1", "plane_name2", Vector4(1, 0, 0, 1), Vector4(1, 1, 0, 1));
     1861#endif
    18431862        }
    18441863        break;
     
    19942013        left_last_y = y;
    19952014
    1996         update_rot(-delta_y, -delta_x);
     2015        updateRot(-delta_y, -delta_x);
    19972016    } else if (right_down) {
    19982017        //TRACE("right mouse motion (%d,%d)\n", x, y);
     
    20012020        right_last_y = y;
    20022021
    2003         update_trans(0, 0, delta_x);
     2022        updateTrans(0, 0, delta_x);
    20042023    }
    20052024
     
    20462065
    20472066void
    2048 NanoVis::xinetd_listen(void)
     2067NanoVis::xinetdListen(void)
    20492068{
    20502069    NanoVis::flags &= ~REDRAW_PENDING;
    20512070
    2052     TRACE("Enter xinetd_listen\n");
     2071    TRACE("Enter xinetdListen\n");
    20532072
    20542073    int flags = fcntl(0, F_GETFL, 0);
     
    20712090        //  here.
    20722091        //
    2073         TRACE("in xinetd_listen: EOF=%d\n", feof(NanoVis::stdin));
     2092        TRACE("in xinetdListen: EOF=%d\n", feof(NanoVis::stdin));
    20742093        while (!feof(NanoVis::stdin)) {
    20752094            int c = fgetc(NanoVis::stdin);
     
    20792098                    break;
    20802099                }
    2081                 DoExit(100);
     2100                doExit(100);
    20822101            }
    20832102            ch = (char)c;
     
    20972116            // back to original flags during command evaluation...
    20982117            fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
    2099             status = ExecuteCommand(interp, &cmdbuffer);
     2118            status = executeCommand(interp, &cmdbuffer);
    21002119            // non-blocking for next read -- we might not get anything
    21012120            fcntl(0, F_SETFL, flags | O_NONBLOCK);
     
    21282147    }
    21292148    if (feof(NanoVis::stdin)) {
    2130         DoExit(90);
     2149        doExit(90);
    21312150    }
    21322151
    21332152    NanoVis::update();
    21342153
    2135     NanoVis::offscreen_buffer_capture();  //enable offscreen render
     2154    NanoVis::offscreenBufferCapture();  //enable offscreen render
    21362155
    21372156    NanoVis::display();
     
    21392158    // INSOO
    21402159#ifdef XINETD
    2141     NanoVis::read_screen();
     2160    NanoVis::readScreen();
    21422161    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    21432162#else
    2144     NanoVis::display_offscreen_buffer(); //display the final rendering on screen
    2145     NanoVis::read_screen();
     2163    NanoVis::displayOffscreenBuffer(); //display the final rendering on screen
     2164    NanoVis::readScreen();
    21462165    glutSwapBuffers();
    21472166#endif
    21482167
    21492168    if (feof(NanoVis::stdin)) {
    2150         DoExit(90);
     2169        doExit(90);
    21512170    }
    21522171#if DO_RLE
     
    21582177    write(1, rle, rle_size);    //unsigned byte
    21592178#else
    2160     NanoVis::ppm_write("\nnv>image -type image -bytes");
     2179    NanoVis::ppmWrite("\nnv>image -type image -bytes");
    21612180#endif
    21622181    TRACE("Leaving xinetd_listen OK\n");
     
    21872206    glutInit(&argc, argv);
    21882207    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
    2189     glutInitWindowSize(NanoVis::win_width, NanoVis::win_height);
     2208    glutInitWindowSize(NanoVis::winWidth, NanoVis::winHeight);
    21902209    glutInitWindowPosition(10, 10);
    2191     NanoVis::render_window = glutCreateWindow("nanovis");
     2210    NanoVis::renderWindow = glutCreateWindow("nanovis");
    21922211    glutIdleFunc(NanoVis::idle);
    21932212
     
    22002219#else
    22012220    glutDisplayFunc(NanoVis::display);
    2202     glutReshapeFunc(NanoVis::resize_offscreen_buffer);
     2221    glutReshapeFunc(NanoVis::resizeOffscreenBuffer);
    22032222#endif
    22042223
     
    22362255        case 3:
    22372256        case 'd':
    2238             NanoVis::debug_flag = true;
     2257            NanoVis::debugFlag = true;
    22392258            break;
    22402259        case 0:
     
    23202339    Tcl_DStringInit(&NanoVis::cmdbuffer);
    23212340    NanoVis::interp = initTcl();
    2322     NanoVis::resize_offscreen_buffer(NanoVis::win_width, NanoVis::win_height);
     2341    NanoVis::resizeOffscreenBuffer(NanoVis::winWidth, NanoVis::winHeight);
    23232342
    23242343    glutMainLoop();
    2325     DoExit(80);
     2344    doExit(80);
    23262345}
    23272346
    23282347int
    2329 NanoVis::render_2d_contour(HeightMap* heightmap, int width, int height)
    2330 {
    2331     int old_width = win_width;
    2332     int old_height = win_height;
    2333 
    2334     resize_offscreen_buffer(width, height);
     2348NanoVis::render2dContour(HeightMap* heightmap, int width, int height)
     2349{
     2350    int old_width = winWidth;
     2351    int old_height = winHeight;
     2352
     2353    resizeOffscreenBuffer(width, height);
    23352354
    23362355    /*
    2337       plane_renderer->set_screen_size(width, height);
     2356      planeRenderer->set_screen_size(width, height);
    23382357
    23392358      // generate data for the legend
     
    23432362      }
    23442363      plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data);
    2345       int index = plane_renderer->add_plane(plane[0], tf);
    2346       plane_renderer->set_active_plane(index);
    2347 
    2348       offscreen_buffer_capture();
     2364      int index = planeRenderer->add_plane(plane[0], tf);
     2365      planeRenderer->set_active_plane(index);
     2366
     2367      offscreenBufferCapture();
    23492368      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
    23502369
    2351       //plane_renderer->render();
     2370      //planeRenderer->render();
    23522371      // INSOO : is going to implement here for the topview of the heightmap
    23532372      heightmap->render(renderContext);
     
    23642383    //char prefix[200];
    23652384    //sprintf(prefix, "nv>height_top_view %s %g %g", volArg, min, max);
    2366     //ppm_write(prefix);
     2385    //ppmWrite(prefix);
    23672386    //write(1, "\n", 1);
    2368     //plane_renderer->remove_plane(index);
     2387    //planeRenderer->remove_plane(index);
    23692388
    23702389    // CURRENT
    2371     offscreen_buffer_capture();
     2390    offscreenBufferCapture();
    23722391    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
    23732392    //glEnable(GL_TEXTURE_2D);
     
    23752394    //heightmap->render_topview(renderContext, width, height);
    23762395    //NanoVis::display();
    2377     if (HeightMap::update_pending) {
    2378         SetHeightmapRanges();
     2396    if (HeightMap::updatePending) {
     2397        setHeightmapRanges();
    23792398    }
    23802399
     
    23832402    heightmap->render_topview(renderContext, width, height);
    23842403
    2385     NanoVis::read_screen();
     2404    NanoVis::readScreen();
    23862405    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    23872406
    23882407    // INSOO TEST CODE
    2389     bmp_write_to_file(1, "/tmp");
    2390 
    2391     resize_offscreen_buffer(old_width, old_height);
     2408    bmpWriteToFile(1, "/tmp");
     2409
     2410    resizeOffscreenBuffer(old_width, old_height);
    23922411
    23932412    return TCL_OK;
     
    23952414
    23962415void
    2397 NanoVis::remove_volume(Volume *volPtr)
     2416NanoVis::removeVolume(Volume *volPtr)
    23982417{
    23992418    Tcl_HashEntry *hPtr;
  • trunk/packages/vizservers/nanovis/nanovis.h

    r2870 r2877  
    7373
    7474    static void init(const char *path);
    75     static void xinetd_listen();
     75    static void xinetdListen();
    7676    static void initGL();
    77     static void init_offscreen_buffer();
    78     static void resize_offscreen_buffer(int w, int h);
     77    static void initOffscreenBuffer();
     78    static void resizeOffscreenBuffer(int w, int h);
    7979    static void resize(int w, int h);
    8080    static void render();
     
    8282    static void idle();
    8383    static void update();
    84     static void display_offscreen_buffer();
     84    static void displayOffscreenBuffer();
    8585    static void pan(float dx, float dy);
    8686    static void zoom(float z);
    8787
    88     static void EventuallyRedraw(unsigned int flag = 0);
    89 
    90     static void SetVolumeRanges();
    91     static void SetHeightmapRanges();
    92 
    93     static void init_lic();
     88    static void eventuallyRedraw(unsigned int flag = 0);
     89
     90    static void setVolumeRanges();
     91    static void setHeightmapRanges();
     92
    9493    static void initParticle();
    9594
    96     static void ppm_write(const char *prefix);
     95    static void ppmWrite(const char *prefix);
    9796    static void sendDataToClient(const char *command, const char *data,
    9897                                 size_t dlen);
    99     static void bmp_write(const char *prefix);
    100     static void bmp_write_to_file(int frame_number, const char* directory_name);
     98    static void bmpWrite(const char *prefix);
     99    static void bmpWriteToFile(int frame_number, const char* directory_name);
    101100 
    102     static TransferFunction *get_transfunc(const char *name);
    103     static TransferFunction *DefineTransferFunction(const char *name,
     101    static TransferFunction *getTransfunc(const char *name);
     102    static TransferFunction *defineTransferFunction(const char *name,
    104103                                                    size_t n, float *data);
    105104
    106     static int render_2d_contour(HeightMap *heightmap, int width, int height);
    107 
    108     static int render_legend(TransferFunction *tf, double min, double max,
    109                              int width, int height, const char *volArg);
    110 
    111     static Volume *load_volume(const char *tag, int width, int height,
    112                                int depth, int n, float* data, double vmin, double vmax,
    113                                double nzero_min);
    114     static void remove_volume(Volume *volPtr);
     105    static int render2dContour(HeightMap *heightmap, int width, int height);
     106
     107    static int renderLegend(TransferFunction *tf, double min, double max,
     108                            int width, int height, const char *volArg);
     109
     110    static Volume *loadVolume(const char *tag, int width, int height, int depth,
     111                              int n, float* data, double vmin, double vmax,
     112                              double nonZeroMin);
     113
     114    static void removeVolume(Volume *volPtr);
    115115
    116116#ifndef XINETD
     
    118118    static void mouse(int button, int state, int x, int y);
    119119    static void motion(int x, int y);
    120     static void update_rot(int delta_x, int delta_y);
    121     static void update_trans(int delta_x, int delta_y, int delta_z);
    122 #endif
    123 
    124     static void read_screen()
     120    static void updateRot(int delta_x, int delta_y);
     121    static void updateTrans(int delta_x, int delta_y, int delta_z);
     122#endif
     123
     124    static void readScreen()
    125125    {
    126         glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE,
    127                      screen_buffer);
     126        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
     127                     screenBuffer);
    128128    }
    129     static void offscreen_buffer_capture()
     129    static void offscreenBufferCapture()
    130130    {
    131         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final_fbo);
     131        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
    132132    }
    133133
     
    148148
    149149    static unsigned int flags;
    150     static bool debug_flag;
    151     static bool axis_on;
    152     static bool config_pending; // Indicates if the limits need to be recomputed.
    153     static int win_width;       //size of the render window
    154     static int win_height;      //size of the render window
    155     static int render_window;
    156     static unsigned char *screen_buffer;
     150    static bool debugFlag;
     151    static bool axisOn;
     152    static int winWidth;        //size of the render window
     153    static int winHeight;       //size of the render window
     154    static int renderWindow;
     155    static unsigned char *screenBuffer;
    157156    static Grid *grid;
    158157    static R2Fonts *fonts;
     
    169168    static float xOrigin, yOrigin, zOrigin;
    170169
    171     static VolumeRenderer *vol_renderer;
     170    static VolumeRenderer *volRenderer;
    172171    static NvFlowVisRenderer *flowVisRenderer;
    173172    static VelocityArrowsSlice *velocityArrowsSlice;
    174173    static NvLIC *licRenderer;
    175     static PlaneRenderer *plane_renderer;
     174    static PlaneRenderer *planeRenderer;
    176175#if PLANE_CMD
    177176    static Texture2D *plane[]; ///< Pointers to 2D planes
    178177#endif
    179178#ifdef USE_POINTSET_RENDERER
    180     static PointSetRenderer *pointset_renderer;
     179    static PointSetRenderer *pointSetRenderer;
    181180    static std::vector<PointSet *> pointSet;
    182181#endif
     
    184183    static Tcl_HashTable tfTable;
    185184    static Texture2D *legendTexture;
    186     static NvColorTableRenderer *color_table_renderer;
     185    static NvColorTableRenderer *colorTableRenderer;
    187186
    188187    static std::vector<HeightMap *> heightMap;
    189188    static Tcl_HashTable heightmapTable;
    190189
    191     static float lic_slice_x;
    192     static float lic_slice_y;
    193     static float lic_slice_z;
    194     static int lic_axis;        /* 0:x, 1:y, 2:z */
    195 
    196190    static Tcl_Interp *interp;
    197191    static Tcl_DString cmdbuffer;
    198192
    199193private:
     194    static float _licSliceX;
     195    static float _licSliceY;
     196    static float _licSliceZ;
     197    static int _licAxis;     /* 0:x, 1:y, 2:z */
     198
    200199    //frame buffer for final rendering
    201     static GLuint _final_fbo, _final_color_tex, _final_depth_rb;
     200    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
    202201};
    203202
  • trunk/packages/vizservers/nanovis/shaders/one_volume.cg

    r2852 r2877  
    1616/*
    1717 * render one volume
     18 *
     19 * renderParameters:
     20 *   x: number of slices
     21 *   y: opacity scale (1-21)
     22 *   z: diffuse coefficient
     23 *   w: specular exponent
     24 * options:
     25 *   y = isosurface flag (opacity scaling on/off)
    1826 */
    1927PixelOut main(v2f IN,
    2028              uniform sampler3D volume,
    2129              uniform sampler1D tf,
    22               //uniform sampler1D tf_cutplane,
    2330              uniform float4x4 modelViewInv,
    2431              uniform float4x4 modelView,
     
    3542    if (renderParameters.x < 0.5) {
    3643        //If single slice render, only flat shading, completely opaque.
    37         //color = tex1D(tf_cutplane, sample.x);
    3844        color.w = 1;
    39         //color.w = renderParameters.y*color.w/renderParameters.x;
    4045    } else {
    4146        //regular volume rendering, we do PHONG SHADING
    42         //lighting parameters
     47        //lighting parameters
     48#if 1
    4349        float3 normal;
    44         if (length(sample.yzw) > 0.0) {
    45             // INSOO (iso)
    46             //normal = sample.yzw * 2.0 - 1.0; //(iso)
    47             //normal = normalize(normal);
    48             normal = normalize(sample.yzw);
     50        float diffuse, specular;
     51        if (dot(sample.yzw, sample.yzw) < 5.0e-5) {
     52            diffuse = 0;
     53            specular = 0;
     54        } else {
     55            normal = normalize(sample.yzw * 2.0 - 1.0);
     56            float3 light_vector = normalize(IN.Light);
     57            float3 eye_vector = normalize(IN.EyeVector);
     58            float3 half_vector = normalize(eye_vector+light_vector);
     59
     60            //lighting computation
     61#ifndef LIGHT_TWO_SIDE
     62            float normal_dot_light = max(dot(normal, light_vector), 0);
     63            float normal_dot_half = max(dot(normal, half_vector), 0);
     64#else
     65            float normal_dot_light = dot(normal, light_vector);
     66            if (normal_dot_light < 0.0) {
     67                normal_dot_light = dot(-normal, light_vector);
     68            }
     69            float normal_dot_half = dot(normal, half_vector);
     70            if (normal_dot_half < 0.0) {
     71                normal_dot_half = dot(-normal, half_vector);
     72            }
     73#endif
     74            diffuse = normal_dot_light * renderParameters.z;
     75            //specular = pow(normal_dot_half, renderParameters.w)*(1-ambient-diffuse);
     76            if (diffuse > 1.0e-6)
     77                specular = pow(normal_dot_half, 90.)*0.3;
     78            else
     79                specular = 0.0;
    4980        }
    50 
    51         float3 light_vector = normalize(IN.Light);
    52         float3 eye_vector = normalize(IN.EyeVector);
    53         float3 half_vector = normalize(eye_vector+light_vector);
    54 
    55         //lighting computation
    56         float normal_dot_light = max(dot(normal, light_vector), 0);
    57         float normal_dot_half = max(dot(normal, half_vector), 0);
    58 
    59         // INSOO (iso)
    60         //float normal_dot_light = abs(dot(normal, light_vector));
    61         //float normal_dot_half = abs(dot(normal, half_vector));
    62 
    63         float ambient = 0.8;
    64 
    65         float diffuse = normal_dot_light * renderParameters.z;
    66 
    67         float specular = pow(normal_dot_half, renderParameters.w)*(1-ambient-diffuse);
     81        float ambient = max(.2, 1.0 - renderParameters.z);
    6882
    6983        float lighting = ambient + diffuse + specular;
    70         color.xyz = color.xyz * lighting;
     84        color.xyz = color.xyz * ambient + color.xyz * diffuse + float3(specular);
     85#else
     86        if (dot(sample.yzw, sample.yzw) < 5.0e-5) {
     87            color.xyz = float3(0);
     88        } else {
     89            color.xyz = normalize(sample.yzw);
     90        }
     91#endif
    7192
    7293        if (options.y < 0.5) {
    7394            //opacity is modulated by the number of total slices
    7495            //to avoid very opaque volume when number of slices is high
    75             color.w = renderParameters.y*color.w/renderParameters.x;
     96            // renderParameters.x = number of slices
     97            // renderParameters.y = opacity scale (1-21)
     98            color.w = color.w * 0.2 * renderParameters.y/renderParameters.x;
    7699
    77100            // INSOO (iso)
    78101            //opacity is modulated by the number of total slices
    79             //color.w = renderParameters.y*color.w/renderParameters.x * 0.2;
     102            //color.w = color.w * renderParameters.y/renderParameters.x * 0.2;
    80103        }
    81104    }
    82105
    83   OUT.Color = color;
     106  OUT.Color = min(max(color, 0.0), 1.0);
    84107
    85108  return OUT;
  • trunk/packages/vizservers/nanovis/shaders/particlefp.cg

    r2852 r2877  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include "particlemacro.h"
    32#include "particle_common.cg"
    43
  • trunk/packages/vizservers/nanovis/shaders/velocity.cg

    r2852 r2877  
    2121
    2222// Velocity change operations.
    23 #include "velocityOps.cg"
     23//#include "velocityOps.cg"
    2424
    2525// Uniform parameters influencing velocity.
     
    3232{
    3333    float3 gravity = float3(0, -.01, 0);
    34        
     34
    3535    float3 acceleration = gravity;
    3636
     
    7373    float3 velocity = (float3)texRECT(_VelocityTexture, _TexCoord);
    7474    float3 position = (float3)texRECT(_PositionTexture, _TexCoord);
    75        
     75
    7676    return float4(advanceVelocity(velocity, position, _TimeStep), 0);
    7777}
  • trunk/packages/vizservers/nanovis/shaders/velocityslicevp.cg

    r2857 r2877  
    5050    float4 posEye =  mul(modelview, posin);
    5151    //pointSize = tanHalfFOV / -posEye.z / 5;
    52     pointSize = tanHalfFOV / -posEye.z / 10; //j-wire
    53     //pointSize = 10 / -posEye.z;
     52    //pointSize = tanHalfFOV / -posEye.z / 10; //j-wire
     53    pointSize = 20; //0 / -posEye.z;
    5454
    5555    posout = mul(mvp, vec);
  • trunk/packages/vizservers/nanovis/shaders/vertex_std.cg

    r2852 r2877  
    2020    v2f OUT;
    2121
     22    // IN.Position is in eye coords
     23    float4 objPos = mul(modelViewInv, IN.Position);
     24    float4 eyePosObjSpace = mul(modelViewInv, float4(0,0,0,1));
     25
    2226    //clip space vertex position
    23     OUT.HPosition = mul(modelViewProjMatrix, mul(modelViewInv, IN.Position));
     27    //OUT.HPosition = mul(modelViewProjMatrix, mul(modelViewInv, IN.Position));
     28    OUT.HPosition = mul(modelViewProjMatrix, objPos);
    2429
    2530    //eye space texture coordinates
     
    2732
    2833    //world space eye position
    29     OUT.EyeVector = normalize(-IN.Position.xyz);
     34    //OUT.EyeVector = normalize(-IN.Position.xyz);
     35    OUT.EyeVector = normalize(eyePosObjSpace - objPos);
    3036
    3137    //world space light postion
    32     OUT.Light = normalize(float3(1,1,1)-IN.Position.xyz);
     38    //OUT.Light = normalize(float3(1,1,1)-IN.Position.xyz);
     39    OUT.Light = normalize(mul(modelViewInv, float4(1,1,1,1))-objPos);
    3340
    3441    return OUT;
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrBPlane.h

    r2841 r2877  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /** \class vrPlane vrPlane <R2/math/vrPlane.h>
    3  *  \brief plane
     2/** \class vrBPlane vrBPlane.h <vrmath/vrBPlane.h>
    43 *  \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu)
    54 *  \author PhD research assistants in PURPL at Purdue University 
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrLineSegment.h

    r2841 r2877  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /** \class vrPlane vrPlane <R2/math/vrPlane.h>
    3  *  \brief plane
     2/** \class vrLineSegment vrLineSegment.h <vrmath/vrLineSegment.h>
    43 *  \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu)
    54 *  \author PhD research assistants in PURPL at Purdue University 
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrMatrix4x4f.h

    r2844 r2877  
    2424    /**
    2525     * @brief make a translation matrix
    26      * @param translation translation
    2726     */
    2827    void makeTranslation(const vrVector3f& translation);
     
    3029    /**
    3130     * @brief make a translation matrix
    32      * @param x x position
    3331     */
    3432    void makeTranslation(float x, float y, float z);
     
    3634    /**
    3735     * @brief make a rotation matrix
    38      * @param rotation rotation
    3936     */
    4037    void makeRotation(const vrRotation& rotation);
     
    4239    /**
    4340     * @brief Make a rotation matrix
    44      * @param rotation rotation
    4541     */
    4642    void makeRotation(float x, float y, float z, float angle);
     
    5046    /**
    5147     * @brief make a scale matrix
    52      * @param scale scale
    5348     */
    5449    void makeScale(const vrVector3f& scale);
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrPlane.h

    r2841 r2877  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /** \class vrPlane vrPlane <R2/math/vrPlane.h>
    3  *  \brief plane
     2/** \class vrPlane vrPlane.h <vrmath/vrPlane.h>
    43 *  \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu)
    54 *  \author PhD research assistants in PURPL at Purdue University 
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrPlane2.h

    r2841 r2877  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /** \class vrPlane vrPlane <vrmath/vrPlane.h>
    3  *  \brief plane
     2/** \class vrPlane2 vrPlane2.h <vrmath/vrPlane2.h>
    43 *  \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu)
    54 *  \author PhD research assistants in PURPL at Purdue University 
     
    1716public:
    1817    void makePts(const vrVector3f& pt1, const vrVector3f& pt2, const vrVector3f& pt3);
     18
    1919    void makeNormalPt(const vrVector3f& norm, const vrVector3f& pos);
     20
    2021    bool intersect(const vrLineSegment &seg, float &d) const;
     22
    2123    float distance(const vrVector3f& point) const;
     24
    2225    vrVector3f crossPoint(const vrVector3f& point) const;
    2326
Note: See TracChangeset for help on using the changeset viewer.