Ignore:
Timestamp:
Aug 3, 2008, 11:49:26 PM (16 years ago)
Author:
dkearney
Message:

saving the world from tabs...one source file at a time

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

Legend:

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

    r1072 r1089  
    2828 *          lots of extra error checking code. (almost there)
    2929 *        o Convert GetVolumeIndices to GetVolumes.  Goal is to remove
    30  *          all references of Nanovis::volume[] from this file.  Don't 
    31  *          want to know how volumes are stored. Same for heightmaps. 
    32  *        o Rationalize volume id scheme. Right now it's the index in 
     30 *          all references of Nanovis::volume[] from this file.  Don't
     31 *          want to know how volumes are stored. Same for heightmaps.
     32 *        o Rationalize volume id scheme. Right now it's the index in
    3333 *          the vector. 1) Use a list instead of a vector. 2) carry
    3434 *          an id field that's a number that gets incremented each new volume.
     
    108108
    109109// default transfer function
    110 static const char def_transfunc[] = 
     110static const char def_transfunc[] =
    111111    "transfunc define default {\n\
    112112  0.0  1 1 1\n\
     
    152152
    153153static bool
    154 GetBooleanFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, bool *boolPtr) 
     154GetBooleanFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, bool *boolPtr)
    155155{
    156156    int value;
     
    176176
    177177static int
    178 GetCullMode(Tcl_Interp *interp, Tcl_Obj *objPtr, 
     178GetCullMode(Tcl_Interp *interp, Tcl_Obj *objPtr,
    179179            graphics::RenderContext::CullMode *modePtr)
    180180{
     
    187187        *modePtr = graphics::RenderContext::BACK;
    188188    } else {
    189         Tcl_AppendResult(interp, "invalid cull mode \"", string, 
     189        Tcl_AppendResult(interp, "invalid cull mode \"", string,
    190190                         "\": should be front, back, or none\"", (char *)NULL);
    191191        return TCL_ERROR;
     
    195195
    196196static int
    197 GetShadingModel(Tcl_Interp *interp, Tcl_Obj *objPtr, 
     197GetShadingModel(Tcl_Interp *interp, Tcl_Obj *objPtr,
    198198                graphics::RenderContext::ShadingModel *modelPtr)
    199199{
     
    205205        *modelPtr = graphics::RenderContext::SMOOTH;
    206206    } else {
    207         Tcl_AppendResult(interp, "bad shading model \"", string, 
     207        Tcl_AppendResult(interp, "bad shading model \"", string,
    208208                         "\": should be flat or smooth", (char *)NULL);
    209209        return TCL_ERROR;
     
    213213
    214214static int
    215 GetPolygonMode(Tcl_Interp *interp, Tcl_Obj *objPtr, 
     215GetPolygonMode(Tcl_Interp *interp, Tcl_Obj *objPtr,
    216216               graphics::RenderContext::PolygonMode *modePtr)
    217217{
     
    223223        *modePtr = graphics::RenderContext::FILL;
    224224    } else {
    225         Tcl_AppendResult(interp, "invalid polygon mode \"", string, 
     225        Tcl_AppendResult(interp, "invalid polygon mode \"", string,
    226226                         "\": should be wireframe or fill\"", (char *)NULL);
    227227        return TCL_ERROR;
     
    246246 */
    247247static HeightMap *
    248 CreateHeightMap(ClientData clientData, Tcl_Interp *interp, int objc, 
     248CreateHeightMap(ClientData clientData, Tcl_Interp *interp, int objc,
    249249                Tcl_Obj *const *objv)
    250250{
     
    253253
    254254    if (objc != 7) {
    255         Tcl_AppendResult(interp, 
     255        Tcl_AppendResult(interp,
    256256        "wrong # of values: should be xMin yMin xMax yMax xNum yNum heights",
    257257        (char *)NULL);
     
    259259    }
    260260    if ((GetFloatFromObj(interp, objv[0], &xMin) != TCL_OK) ||
    261         (GetFloatFromObj(interp, objv[1], &yMin) != TCL_OK) || 
     261        (GetFloatFromObj(interp, objv[1], &yMin) != TCL_OK) ||
    262262        (GetFloatFromObj(interp, objv[2], &xMax) != TCL_OK) ||
    263263        (GetFloatFromObj(interp, objv[3], &yMax) != TCL_OK) ||
     
    283283    heights = new float[nValues];
    284284    if (heights == NULL) {
    285         Tcl_AppendResult(interp, "can't allocate array of heights", 
     285        Tcl_AppendResult(interp, "can't allocate array of heights",
    286286                         (char *)NULL);
    287287        return NULL;
     
    320320    }
    321321    if (index < 0) {
    322         Tcl_AppendResult(interp, "can't have negative index \"", 
     322        Tcl_AppendResult(interp, "can't have negative index \"",
    323323                         Tcl_GetString(objPtr), "\"", (char*)NULL);
    324324        return TCL_ERROR;
     
    350350    hmPtr = NanoVis::heightMap[index];
    351351    if (hmPtr == NULL) {
    352         Tcl_AppendResult(interp, "no heightmap defined for index \"", 
     352        Tcl_AppendResult(interp, "no heightmap defined for index \"",
    353353                         Tcl_GetString(objPtr), "\"", (char*)NULL);
    354354        return TCL_ERROR;
     
    379379    }
    380380    if (index < 0) {
    381         Tcl_AppendResult(interp, "can't have negative index \"", 
     381        Tcl_AppendResult(interp, "can't have negative index \"",
    382382                         Tcl_GetString(objPtr), "\"", (char*)NULL);
    383383        return TCL_ERROR;
     
    415415    vol = NanoVis::volume[index];
    416416    if (vol == NULL) {
    417         Tcl_AppendResult(interp, "no volume defined for index \"", 
     417        Tcl_AppendResult(interp, "no volume defined for index \"",
    418418                         Tcl_GetString(objPtr), "\"", (char*)NULL);
    419419        return TCL_ERROR;
     
    660660        int nRead;
    661661
    662         chunk = (sizeof(buffer) < (unsigned int) nBytes) ? 
     662        chunk = (sizeof(buffer) < (unsigned int) nBytes) ?
    663663            sizeof(buffer) : nBytes;
    664664        nRead = fread(buffer, sizeof(char), chunk, stdin);
     
    707707{
    708708    double xangle, yangle, zangle;
    709     if ((Tcl_GetDoubleFromObj(interp, objv[2], &xangle) != TCL_OK) || 
     709    if ((Tcl_GetDoubleFromObj(interp, objv[2], &xangle) != TCL_OK) ||
    710710        (Tcl_GetDoubleFromObj(interp, objv[3], &yangle) != TCL_OK) ||
    711711        (Tcl_GetDoubleFromObj(interp, objv[4], &zangle) != TCL_OK)) {
     
    752752    Tcl_ObjCmdProc *proc;
    753753
    754     proc = Rappture::GetOpFromObj(interp, nCameraOps, cameraOps, 
     754    proc = Rappture::GetOpFromObj(interp, nCameraOps, cameraOps,
    755755                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    756756    if (proc == NULL) {
     
    762762/*ARGSUSED*/
    763763static int
    764 SnapshotCmd(ClientData cdata, Tcl_Interp *interp, int objc, 
     764SnapshotCmd(ClientData cdata, Tcl_Interp *interp, int objc,
    765765              Tcl_Obj *const *objv)
    766766{
     
    785785
    786786static int
    787 CutplanePositionOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     787CutplanePositionOp(ClientData cdata, Tcl_Interp *interp, int objc,
    788788                   Tcl_Obj *const *objv)
    789789{
     
    792792        return TCL_ERROR;
    793793    }
    794    
     794
    795795    // keep this just inside the volume so it doesn't disappear
    796     if (relval < 0.01f) { 
    797         relval = 0.01f; 
    798     } else if (relval > 0.99f) { 
    799         relval = 0.99f; 
    800     }
    801    
     796    if (relval < 0.01f) {
     797        relval = 0.01f;
     798    } else if (relval > 0.99f) {
     799        relval = 0.99f;
     800    }
     801
    802802    int axis;
    803803    if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) {
    804804        return TCL_ERROR;
    805805    }
    806    
     806
    807807    vector<Volume *> ivol;
    808808    if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
     
    817817
    818818static int
    819 CutplaneStateOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     819CutplaneStateOp(ClientData cdata, Tcl_Interp *interp, int objc,
    820820                Tcl_Obj *const *objv)
    821821{
     
    824824        return TCL_ERROR;
    825825    }
    826    
     826
    827827    int axis;
    828828    if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) {
    829829        return TCL_ERROR;
    830830    }
    831    
     831
    832832    vector<Volume *> ivol;
    833833    if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
     
    838838        for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    839839            (*iter)->enable_cutplane(axis);
    840         } 
     840        }
    841841    } else {
    842842        vector<Volume *>::iterator iter;
    843843        for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    844844            (*iter)->disable_cutplane(axis);
    845         } 
     845        }
    846846    }
    847847    return TCL_OK;
     
    870870 */
    871871static int
    872 CutplaneCmd(ClientData cdata, Tcl_Interp *interp, int objc, 
     872CutplaneCmd(ClientData cdata, Tcl_Interp *interp, int objc,
    873873            Tcl_Obj *const *objv)
    874874{
    875875    Tcl_ObjCmdProc *proc;
    876876
    877     proc = Rappture::GetOpFromObj(interp, nCutplaneOps, cutplaneOps, 
     877    proc = Rappture::GetOpFromObj(interp, nCutplaneOps, cutplaneOps,
    878878                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    879879    if (proc == NULL) {
     
    898898{
    899899    if (objc != 4) {
    900         Tcl_AppendResult(interp, "wrong # args: should be \"", 
     900        Tcl_AppendResult(interp, "wrong # args: should be \"",
    901901            Tcl_GetString(objv[0]), " volIndex width height\"", (char*)NULL);
    902902        return TCL_ERROR;
     
    910910    tf = NanoVis::vol_renderer->get_volume_shading(volPtr);
    911911    if (tf == NULL) {
    912         Tcl_AppendResult(interp, "no transfer function defined for volume \"", 
     912        Tcl_AppendResult(interp, "no transfer function defined for volume \"",
    913913                         Tcl_GetString(objv[1]), "\"", (char*)NULL);
    914914        return TCL_ERROR;
     
    942942{
    943943    if (objc != 3) {
    944         Tcl_AppendResult(interp, "wrong # args: should be \"", 
     944        Tcl_AppendResult(interp, "wrong # args: should be \"",
    945945                         Tcl_GetString(objv[0]), " width height\"", (char*)NULL);
    946946        return TCL_ERROR;
     
    967967 */
    968968static int
    969 TransfuncCmd(ClientData cdata, Tcl_Interp *interp, int objc, 
     969TransfuncCmd(ClientData cdata, Tcl_Interp *interp, int objc,
    970970             Tcl_Obj *const *objv)
    971971{
    972972    if (objc < 2) {
    973         Tcl_AppendResult(interp, "wrong # args: should be \"", 
     973        Tcl_AppendResult(interp, "wrong # args: should be \"",
    974974                Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL);
    975975        return TCL_ERROR;
     
    980980    if ((c == 'd') && (strcmp(string, "define") == 0)) {
    981981        if (objc != 5) {
    982             Tcl_AppendResult(interp, "wrong # args: should be \"", 
    983                 Tcl_GetString(objv[0]), " define name colorMap alphaMap\"", 
     982            Tcl_AppendResult(interp, "wrong # args: should be \"",
     983                Tcl_GetString(objv[0]), " define name colorMap alphaMap\"",
    984984                (char*)NULL);
    985985            return TCL_ERROR;
     
    10181018                }
    10191019                if ((q[j] < 0.0) || (q[j] > 1.0)) {
    1020                     Tcl_AppendResult(interp, "bad colormap value \"", 
    1021                         Tcl_GetString(cmapv[i+j]), 
     1020                    Tcl_AppendResult(interp, "bad colormap value \"",
     1021                        Tcl_GetString(cmapv[i+j]),
    10221022                        "\": should be in the range 0-1", (char*)NULL);
    10231023                    return TCL_ERROR;
     
    10371037                }
    10381038                if ((q[j] < 0.0) || (q[j] > 1.0)) {
    1039                     Tcl_AppendResult(interp, "bad alphamap value \"", 
     1039                    Tcl_AppendResult(interp, "bad alphamap value \"",
    10401040                        Tcl_GetString(wmapv[i+j]),
    10411041                        "\": should be in the range 0-1", (char*)NULL);
     
    10781078{
    10791079    if (objc != 2) {
    1080         Tcl_AppendResult(interp, "wrong # args: should be \"", 
     1080        Tcl_AppendResult(interp, "wrong # args: should be \"",
    10811081                         Tcl_GetString(objv[0]), " x|y|z|-x|-y|-z\"", (char*)NULL);
    10821082        return TCL_ERROR;
     
    10941094
    10951095static int
    1096 VolumeAnimationCaptureOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1096VolumeAnimationCaptureOp(ClientData cdata, Tcl_Interp *interp, int objc,
    10971097                         Tcl_Obj *const *objv)
    10981098{
     
    11021102    }
    11031103    VolumeInterpolator* interpolator;
    1104     interpolator = NanoVis::vol_renderer->getVolumeInterpolator(); 
     1104    interpolator = NanoVis::vol_renderer->getVolumeInterpolator();
    11051105    interpolator->start();
    11061106    if (interpolator->is_started()) {
     
    11081108        for (int frame_num = 0; frame_num < total; ++frame_num) {
    11091109            float fraction;
    1110            
     1110
    11111111            fraction = ((float)frame_num) / (total - 1);
    11121112            Trace("fraction : %f\n", fraction);
    11131113            //interpolator->update(((float)frame_num) / (total - 1));
    11141114            interpolator->update(fraction);
    1115            
     1115
    11161116            NanoVis::offscreen_buffer_capture();  //enable offscreen render
    1117            
     1117
    11181118            NanoVis::display();
    11191119            NanoVis::read_screen();
    1120            
     1120
    11211121            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    1122            
     1122
    11231123            NanoVis::bmp_write_to_file(frame_num, fileName);
    11241124        }
     
    11281128
    11291129static int
    1130 VolumeAnimationClearOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1130VolumeAnimationClearOp(ClientData cdata, Tcl_Interp *interp, int objc,
    11311131                       Tcl_Obj *const *objv)
    11321132{
     
    11361136
    11371137static int
    1138 VolumeAnimationStartOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1138VolumeAnimationStartOp(ClientData cdata, Tcl_Interp *interp, int objc,
    11391139                       Tcl_Obj *const *objv)
    11401140{
     
    11441144
    11451145static int
    1146 VolumeAnimationStopOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1146VolumeAnimationStopOp(ClientData cdata, Tcl_Interp *interp, int objc,
    11471147                      Tcl_Obj *const *objv)
    11481148{
     
    11521152
    11531153static int
    1154 VolumeAnimationVolumesOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1154VolumeAnimationVolumesOp(ClientData cdata, Tcl_Interp *interp, int objc,
    11551155                         Tcl_Obj *const *objv)
    11561156{
     
    11791179
    11801180static int
    1181 VolumeAnimationOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1181VolumeAnimationOp(ClientData cdata, Tcl_Interp *interp, int objc,
    11821182                  Tcl_Obj *const *objv)
    11831183{
    11841184    Tcl_ObjCmdProc *proc;
    11851185
    1186     proc = Rappture::GetOpFromObj(interp, nVolumeAnimationOps, volumeAnimationOps, 
     1186    proc = Rappture::GetOpFromObj(interp, nVolumeAnimationOps, volumeAnimationOps,
    11871187                                  Rappture::CMDSPEC_ARG2, objc, objv, 0);
    11881188    if (proc == NULL) {
     
    11941194
    11951195static int
    1196 VolumeDataFollowsOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1196VolumeDataFollowsOp(ClientData cdata, Tcl_Interp *interp, int objc,
    11971197                    Tcl_Obj *const *objv)
    11981198{
    11991199    printf("Data Loading\n");
    12001200    fflush(stdout);
    1201    
     1201
    12021202    int nbytes;
    12031203    if (Tcl_GetIntFromObj(interp, objv[3], &nbytes) != TCL_OK) {
    12041204        return TCL_ERROR;
    12051205    }
    1206    
     1206
    12071207    Rappture::Buffer buf;
    12081208    if (GetDataStream(interp, buf, nbytes) != TCL_OK) {
     
    12131213    memcpy(header, buf.bytes(), sizeof(char) * 5);
    12141214    header[5] = '\0';
    1215    
     1215
    12161216#if _LOCAL_ZINC_TEST_
    12171217    //FILE* fp = fopen("/home/nanohub/vrinside/nv/data/HOON/QDWL_100_100_50_strain_8000i.nd_zatom_12_1", "rb");
    12181218    FILE* fp;
    1219    
     1219
    12201220    fp = fopen("/home/nanohub/vrinside/nv/data/HOON/GaAs_AlGaAs_2QD_B4.nd_zc_1_wf", "rb");
    12211221    if (fp == NULL) {
     
    12321232    if (strcmp(header, "<HDR>") == 0) {
    12331233        Volume* vol = NULL;
    1234        
     1234
    12351235        printf("ZincBlende stream is in\n");
    12361236        fflush(stdout);
     
    12381238        //fdata.write(buf.bytes(),buf.size());
    12391239        //vol = NvZincBlendeReconstructor::getInstance()->loadFromStream(fdata);
    1240        
     1240
    12411241#if _LOCAL_ZINC_TEST_
    12421242        vol = NvZincBlendeReconstructor::getInstance()->loadFromMemory(b);
     
    13181318        NanoVis::volume[n]->disable_cutplane(1);
    13191319        NanoVis::volume[n]->disable_cutplane(2);
    1320        
     1320
    13211321        NanoVis::vol_renderer->add_volume(NanoVis::volume[n],
    13221322                                          NanoVis::get_transfunc("default"));
    13231323    }
    1324    
     1324
    13251325    {
    13261326        Volume *volPtr;
    13271327        char info[1024];
    1328        
     1328
    13291329        if (Volume::update_pending) {
    13301330            NanoVis::SetVolumeRanges();
    13311331        }
    13321332        volPtr = NanoVis::volume[n];
    1333         sprintf(info, "nv>data id %d min %g max %g vmin %g vmax %g\n", 
     1333        sprintf(info, "nv>data id %d min %g max %g vmin %g vmax %g\n",
    13341334                n, volPtr->wAxis.Min(), volPtr->wAxis.Max(),
    13351335                Volume::valueMin, Volume::valueMax);
     
    13401340
    13411341static int
    1342 VolumeDataStateOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1342VolumeDataStateOp(ClientData cdata, Tcl_Interp *interp, int objc,
    13431343                  Tcl_Obj *const *objv)
    13441344{
     
    13721372
    13731373static int
    1374 VolumeDataOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1374VolumeDataOp(ClientData cdata, Tcl_Interp *interp, int objc,
    13751375             Tcl_Obj *const *objv)
    13761376{
    13771377    Tcl_ObjCmdProc *proc;
    13781378
    1379     proc = Rappture::GetOpFromObj(interp, nVolumeDataOps, volumeDataOps, 
     1379    proc = Rappture::GetOpFromObj(interp, nVolumeDataOps, volumeDataOps,
    13801380                                  Rappture::CMDSPEC_ARG2, objc, objv, 0);
    13811381    if (proc == NULL) {
     
    13861386
    13871387static int
    1388 VolumeOutlineColorOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1388VolumeOutlineColorOp(ClientData cdata, Tcl_Interp *interp, int objc,
    13891389                     Tcl_Obj *const *objv)
    13901390{
     
    14051405
    14061406static int
    1407 VolumeOutlineStateOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1407VolumeOutlineStateOp(ClientData cdata, Tcl_Interp *interp, int objc,
    14081408                     Tcl_Obj *const *objv)
    14091409{
     
    14391439
    14401440static int
    1441 VolumeOutlineOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1441VolumeOutlineOp(ClientData cdata, Tcl_Interp *interp, int objc,
    14421442                Tcl_Obj *const *objv)
    14431443{
    14441444    Tcl_ObjCmdProc *proc;
    14451445
    1446     proc = Rappture::GetOpFromObj(interp, nVolumeOutlineOps, volumeOutlineOps, 
    1447         Rappture::CMDSPEC_ARG2, objc, objv, 0);
     1446    proc = Rappture::GetOpFromObj(interp, nVolumeOutlineOps, volumeOutlineOps,
     1447        Rappture::CMDSPEC_ARG2, objc, objv, 0);
    14481448    if (proc == NULL) {
    14491449        return TCL_ERROR;
     
    14531453
    14541454static int
    1455 VolumeShadingDiffuseOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1455VolumeShadingDiffuseOp(ClientData cdata, Tcl_Interp *interp, int objc,
    14561456                       Tcl_Obj *const *objv)
    14571457{
     
    14731473
    14741474static int
    1475 VolumeShadingIsosurfaceOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1475VolumeShadingIsosurfaceOp(ClientData cdata, Tcl_Interp *interp, int objc,
    14761476                          Tcl_Obj *const *objv)
    14771477{
     
    14921492
    14931493static int
    1494 VolumeShadingOpacityOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1494VolumeShadingOpacityOp(ClientData cdata, Tcl_Interp *interp, int objc,
    14951495                       Tcl_Obj *const *objv)
    14961496{
     
    15131513
    15141514static int
    1515 VolumeShadingSpecularOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1515VolumeShadingSpecularOp(ClientData cdata, Tcl_Interp *interp, int objc,
    15161516                        Tcl_Obj *const *objv)
    15171517{
     
    15321532
    15331533static int
    1534 VolumeShadingTransFuncOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1534VolumeShadingTransFuncOp(ClientData cdata, Tcl_Interp *interp, int objc,
    15351535                         Tcl_Obj *const *objv)
    15361536{
     
    15711571
    15721572static int
    1573 VolumeShadingOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1573VolumeShadingOp(ClientData cdata, Tcl_Interp *interp, int objc,
    15741574                Tcl_Obj *const *objv)
    15751575{
    15761576    Tcl_ObjCmdProc *proc;
    15771577
    1578     proc = Rappture::GetOpFromObj(interp, nVolumeShadingOps, volumeShadingOps, 
     1578    proc = Rappture::GetOpFromObj(interp, nVolumeShadingOps, volumeShadingOps,
    15791579        Rappture::CMDSPEC_ARG2, objc, objv, 0);
    15801580    if (proc == NULL) {
     
    15851585
    15861586static int
    1587 VolumeAxisOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1587VolumeAxisOp(ClientData cdata, Tcl_Interp *interp, int objc,
    15881588             Tcl_Obj *const *objv)
    15891589{
     
    16071607        }
    16081608    } else {
    1609         Tcl_AppendResult(interp, "bad option \"", string, 
     1609        Tcl_AppendResult(interp, "bad option \"", string,
    16101610                         "\": should be label", (char*)NULL);
    16111611        return TCL_ERROR;
     
    16151615
    16161616static int
    1617 VolumeStateOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1617VolumeStateOp(ClientData cdata, Tcl_Interp *interp, int objc,
    16181618              Tcl_Obj *const *objv)
    16191619{
     
    16411641
    16421642static int
    1643 VolumeTestOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1643VolumeTestOp(ClientData cdata, Tcl_Interp *interp, int objc,
    16441644             Tcl_Obj *const *objv)
    16451645{
     
    16811681    Tcl_ObjCmdProc *proc;
    16821682
    1683     proc = Rappture::GetOpFromObj(interp, nVolumeOps, volumeOps, 
     1683    proc = Rappture::GetOpFromObj(interp, nVolumeOps, volumeOps,
    16841684        Rappture::CMDSPEC_ARG1, objc, objv, 0);
    16851685    if (proc == NULL) {
     
    17031703    if ((c == 'v') && (strcmp(string, "vectorid") == 0)) {
    17041704        if (objc != 3) {
    1705             Tcl_AppendResult(interp, "wrong # args: should be \"", 
     1705            Tcl_AppendResult(interp, "wrong # args: should be \"",
    17061706                Tcl_GetString(objv[0]), " vectorid volume", (char *)NULL);
    17071707            return TCL_ERROR;
    17081708        }
    17091709        Volume *volPtr;
    1710         if (GetVolumeFromObj(interp, objv[2], &volPtr) != TCL_OK) { 
     1710        if (GetVolumeFromObj(interp, objv[2], &volPtr) != TCL_OK) {
    17111711            return TCL_ERROR;
    17121712        }
    17131713        if (NanoVis::particleRenderer != NULL) {
    1714             NanoVis::particleRenderer->setVectorField(volPtr->id, 1.0f, 
     1714            NanoVis::particleRenderer->setVectorField(volPtr->id, 1.0f,
    17151715                volPtr->height / (float)volPtr->width,
    17161716                volPtr->depth  / (float)volPtr->width,
     
    17391739    } else if ((c == 'p') && (strcmp(string, "particle") == 0)) {
    17401740        if (objc < 3) {
    1741             Tcl_AppendResult(interp, "wrong # args: should be \"", 
     1741            Tcl_AppendResult(interp, "wrong # args: should be \"",
    17421742                Tcl_GetString(objv[0]), " particle visible|slice|slicepos arg \"",
    17431743                (char*)NULL);
     
    17481748        if ((c == 'v') && (strcmp(string, "visible") == 0)) {
    17491749            if (objc != 4) {
    1750                 Tcl_AppendResult(interp, "wrong # args: should be \"", 
    1751                                  Tcl_GetString(objv[0]), " particle visible on|off\"", 
     1750                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1751                                 Tcl_GetString(objv[0]), " particle visible on|off\"",
    17521752                                 (char*)NULL);
    17531753                return TCL_ERROR;
     
    17601760        } else if ((c == 's') && (strcmp(string, "slice") == 0)) {
    17611761            if (objc != 4) {
    1762                 Tcl_AppendResult(interp, "wrong # args: should be \"", 
     1762                Tcl_AppendResult(interp, "wrong # args: should be \"",
    17631763                                 Tcl_GetString(objv[0]),
    17641764                                 " particle slice volume\"", (char*)NULL);
     
    17721772        } else if ((c == 's') && (strcmp(string, "slicepos") == 0)) {
    17731773            if (objc != 4) {
    1774                 Tcl_AppendResult(interp, "wrong # args: should be \"", 
    1775                                  Tcl_GetString(objv[0]), " particle slicepos value\"", 
     1774                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1775                                 Tcl_GetString(objv[0]), " particle slicepos value\"",
    17761776                                 (char*)NULL);
    17771777                return TCL_ERROR;
     
    17991799        } else {
    18001800            Tcl_AppendResult(interp, "unknown option \"", string,
    1801                 "\": should be \"", Tcl_GetString(objv[0]), 
     1801                "\": should be \"", Tcl_GetString(objv[0]),
    18021802                " visible, slice, or slicepos\"", (char *)NULL);
    18031803            return TCL_ERROR;
     
    18071807    } else if ((c == 'c') && (strcmp(string, "capture") == 0)) {
    18081808        if (objc > 4 || objc < 3) {
    1809             Tcl_AppendResult(interp, "wrong # args: should be \"", 
    1810                              Tcl_GetString(objv[0]), " capture numframes [directory]\"", 
     1809            Tcl_AppendResult(interp, "wrong # args: should be \"",
     1810                             Tcl_GetString(objv[0]), " capture numframes [directory]\"",
    18111811                             (char*)NULL);
    18121812            return TCL_ERROR;
     
    18281828        const char *fileName;
    18291829        fileName = (objc < 4) ? NULL : Tcl_GetString(objv[3]);
    1830         for (int frame_count = 0; frame_count < total_frame_count; 
     1830        for (int frame_count = 0; frame_count < total_frame_count;
    18311831             frame_count++) {
    1832            
     1832
    18331833            // Generate the latest frame and send it back to the client
    1834             if (NanoVis::licRenderer && 
     1834            if (NanoVis::licRenderer &&
    18351835                NanoVis::licRenderer->isActivated()) {
    1836                 NanoVis::licRenderer->convolve();               
    1837             }
    1838             if (NanoVis::particleRenderer && 
     1836                NanoVis::licRenderer->convolve();
     1837            }
     1838            if (NanoVis::particleRenderer &&
    18391839                NanoVis::particleRenderer->isActivated()) {
    18401840                NanoVis::particleRenderer->advect();
     
    18421842            NanoVis::offscreen_buffer_capture();  //enable offscreen render
    18431843            NanoVis::display();
    1844            
     1844
    18451845            //          printf("Read Screen for Writing to file...\n");
    1846            
     1846
    18471847            NanoVis::read_screen();
    18481848            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
     
    18511851        }
    18521852        Trace("FLOW end\n");
    1853         // put your code... 
     1853        // put your code...
    18541854        if (NanoVis::licRenderer) {
    18551855            NanoVis::licRenderer->deactivate();
     
    18611861    } else if ((c == 'd') && (strcmp(string, "data") == 0)) {
    18621862        if (objc < 3) {
    1863             Tcl_AppendResult(interp, "wrong # args: should be \"", 
     1863            Tcl_AppendResult(interp, "wrong # args: should be \"",
    18641864                Tcl_GetString(objv[0]), " data follows ?args?", (char *)NULL);
    18651865            return TCL_ERROR;
     
    18691869        if ((c == 'f') && (strcmp(string,"follows") == 0)) {
    18701870            if (objc != 4) {
    1871                 Tcl_AppendResult(interp, "wrong # args: should be \"", 
    1872                     Tcl_GetString(objv[0]), " data follows length", 
     1871                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1872                    Tcl_GetString(objv[0]), " data follows length",
    18731873                    (char *)NULL);
    18741874                return TCL_ERROR;
     
    19021902                volPtr->disable_cutplane(2);
    19031903
    1904                 NanoVis::vol_renderer->add_volume(volPtr, 
     1904                NanoVis::vol_renderer->add_volume(volPtr,
    19051905                        NanoVis::get_transfunc("default"));
    19061906            }
     
    19141914
    19151915static int
    1916 HeightMapDataFollowsOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1916HeightMapDataFollowsOp(ClientData cdata, Tcl_Interp *interp, int objc,
    19171917                       Tcl_Obj *const *objv)
    19181918{
    19191919    Rappture::Buffer buf;
    19201920    int nBytes;
    1921    
     1921
    19221922    if (Tcl_GetIntFromObj(interp, objv[3], &nBytes) != TCL_OK) {
    19231923        return TCL_ERROR;
     
    19371937
    19381938static int
    1939 HeightMapDataVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1939HeightMapDataVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc,
    19401940                       Tcl_Obj *const *objv)
    19411941{
     
    19611961static int nHeightMapDataOps = NumCmdSpecs(heightMapDataOps);
    19621962
    1963 static int 
    1964 HeightMapDataOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1963static int
     1964HeightMapDataOp(ClientData cdata, Tcl_Interp *interp, int objc,
    19651965                Tcl_Obj *const *objv)
    19661966{
    19671967    Tcl_ObjCmdProc *proc;
    19681968
    1969     proc = Rappture::GetOpFromObj(interp, nHeightMapDataOps, heightMapDataOps, 
     1969    proc = Rappture::GetOpFromObj(interp, nHeightMapDataOps, heightMapDataOps,
    19701970                                  Rappture::CMDSPEC_ARG2, objc, objv, 0);
    19711971    if (proc == NULL) {
     
    19771977
    19781978static int
    1979 HeightMapLineContourColorOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1979HeightMapLineContourColorOp(ClientData cdata, Tcl_Interp *interp, int objc,
    19801980                            Tcl_Obj *const *objv)
    19811981{
     
    19831983    if (GetColor(interp, objc - 3, objv + 3, rgb) != TCL_OK) {
    19841984        return TCL_ERROR;
    1985     }           
     1985    }
    19861986    vector<HeightMap *> imap;
    19871987    if (GetHeightMaps(interp, objc - 6, objv + 6, &imap) != TCL_OK) {
     
    19961996
    19971997static int
    1998 HeightMapLineContourVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     1998HeightMapLineContourVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc,
    19991999                              Tcl_Obj *const *objv)
    20002000{
     
    20212021
    20222022static int
    2023 HeightMapLineContourOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2023HeightMapLineContourOp(ClientData cdata, Tcl_Interp *interp, int objc,
    20242024                       Tcl_Obj *const *objv)
    20252025{
    20262026    Tcl_ObjCmdProc *proc;
    20272027
    2028     proc = Rappture::GetOpFromObj(interp, nHeightMapLineContourOps, 
     2028    proc = Rappture::GetOpFromObj(interp, nHeightMapLineContourOps,
    20292029        heightMapLineContourOps, Rappture::CMDSPEC_ARG2, objc, objv, 0);
    20302030    if (proc == NULL) {
     
    20352035
    20362036static int
    2037 HeightMapCullOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2037HeightMapCullOp(ClientData cdata, Tcl_Interp *interp, int objc,
    20382038                Tcl_Obj *const *objv)
    20392039{
     
    20472047
    20482048static int
    2049 HeightMapCreateOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2049HeightMapCreateOp(ClientData cdata, Tcl_Interp *interp, int objc,
    20502050                  Tcl_Obj *const *objv)
    20512051{
    20522052    HeightMap *hmPtr;
    2053    
     2053
    20542054    /* heightmap create xmin ymin xmax ymax xnum ynum values */
    20552055    hmPtr = CreateHeightMap(cdata, interp, objc - 2, objv + 2);
     
    20632063
    20642064static int
    2065 HeightMapLegendOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2065HeightMapLegendOp(ClientData cdata, Tcl_Interp *interp, int objc,
    20662066                  Tcl_Obj *const *objv)
    20672067{
     
    20732073    tf = hmPtr->getColorMap();
    20742074    if (tf == NULL) {
    2075         Tcl_AppendResult(interp, "no transfer function defined for heightmap \"", 
     2075        Tcl_AppendResult(interp, "no transfer function defined for heightmap \"",
    20762076                         Tcl_GetString(objv[2]), "\"", (char*)NULL);
    20772077        return TCL_ERROR;
    20782078    }
    20792079    int w, h;
    2080     if ((Tcl_GetIntFromObj(interp, objv[3], &w) != TCL_OK) || 
     2080    if ((Tcl_GetIntFromObj(interp, objv[3], &w) != TCL_OK) ||
    20812081        (Tcl_GetIntFromObj(interp, objv[4], &h) != TCL_OK)) {
    20822082        return TCL_ERROR;
     
    20852085        NanoVis::SetHeightmapRanges();
    20862086    }
    2087     NanoVis::render_legend(tf, HeightMap::valueMin, HeightMap::valueMax, w, h, 
     2087    NanoVis::render_legend(tf, HeightMap::valueMin, HeightMap::valueMax, w, h,
    20882088        "label");
    20892089    return TCL_OK;
     
    20912091
    20922092static int
    2093 HeightMapPolygonOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2093HeightMapPolygonOp(ClientData cdata, Tcl_Interp *interp, int objc,
    20942094                   Tcl_Obj *const *objv)
    20952095{
     
    21032103
    21042104static int
    2105 HeightMapShadingOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2105HeightMapShadingOp(ClientData cdata, Tcl_Interp *interp, int objc,
    21062106                 Tcl_Obj *const *objv)
    21072107{
     
    21152115
    21162116static int
    2117 HeightMapTestOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2117HeightMapTestOp(ClientData cdata, Tcl_Interp *interp, int objc,
    21182118                Tcl_Obj *const *objv)
    21192119{
     
    21242124    double mean = exp(0.0) / (sigma * sqrt(2.0));
    21252125    float* data = (float*) malloc(sizeof(float) * size);
    2126    
     2126
    21272127    float x;
    21282128    for (int i = 0; i < size; ++i) {
    21292129        x = - 10 + i%20;
    2130         data[i] = exp(- (x * x)/(2 * sigma * sigma)) / 
     2130        data[i] = exp(- (x * x)/(2 * sigma * sigma)) /
    21312131            (sigma * sqrt(2.0)) / mean * 2 + 1000;
    21322132    }
    2133    
     2133
    21342134    HeightMap* hmPtr = new HeightMap();
    21352135    float minx = 0.0f;
     
    21472147
    21482148static int
    2149 HeightMapTransFuncOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2149HeightMapTransFuncOp(ClientData cdata, Tcl_Interp *interp, int objc,
    21502150                     Tcl_Obj *const *objv)
    21512151{
     
    21712171
    21722172static Rappture::CmdSpec heightMapOps[] = {
    2173     {"create",       2, HeightMapCreateOp,      9, 9, 
     2173    {"create",       2, HeightMapCreateOp,      9, 9,
    21742174     "xmin ymin xmax ymax xnum ynum values",},
    21752175    {"cull",         2, HeightMapCullOp,        3, 3, "mode",},
     
    21842184static int nHeightMapOps = NumCmdSpecs(heightMapOps);
    21852185
    2186 static int 
     2186static int
    21872187HeightMapCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
    2188 { 
     2188{
    21892189    Tcl_ObjCmdProc *proc;
    21902190
    2191     proc = Rappture::GetOpFromObj(interp, nHeightMapOps, heightMapOps, 
     2191    proc = Rappture::GetOpFromObj(interp, nHeightMapOps, heightMapOps,
    21922192                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    21932193    if (proc == NULL) {
     
    21982198
    21992199static int
    2200 GridAxisColorOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2200GridAxisColorOp(ClientData cdata, Tcl_Interp *interp, int objc,
    22012201                Tcl_Obj *const *objv)
    22022202{
     
    22102210    if ((objc == 6) && (GetFloatFromObj(interp, objv[5], &a) != TCL_OK)) {
    22112211        return TCL_ERROR;
    2212     }           
     2212    }
    22132213    if (NanoVis::grid) {
    22142214        NanoVis::grid->setAxisColor(r, g, b, a);
     
    22282228        Axis *axisPtr;
    22292229
    2230         axisPtr = NULL;         /* Suppress compiler warning. */
     2230        axisPtr = NULL;     /* Suppress compiler warning. */
    22312231        switch (axis) {
    22322232        case 0: axisPtr = &NanoVis::grid->xAxis; break;
     
    22412241
    22422242static int
    2243 GridLineColorOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2243GridLineColorOp(ClientData cdata, Tcl_Interp *interp, int objc,
    22442244                Tcl_Obj *const *objv)
    22452245{
     
    22532253    if ((objc == 6) && (GetFloatFromObj(interp, objv[5], &a) != TCL_OK)) {
    22542254        return TCL_ERROR;
    2255     }           
     2255    }
    22562256    if (NanoVis::grid) {
    22572257        NanoVis::grid->setLineColor(r, g, b, a);
     
    22792279static int nGridOps = NumCmdSpecs(gridOps);
    22802280
    2281 static int 
     2281static int
    22822282GridCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
    2283 { 
     2283{
    22842284    Tcl_ObjCmdProc *proc;
    22852285
    2286     proc = Rappture::GetOpFromObj(interp, nGridOps, gridOps, 
    2287         Rappture::CMDSPEC_ARG1, objc, objv, 0);
     2286    proc = Rappture::GetOpFromObj(interp, nGridOps, gridOps,
     2287        Rappture::CMDSPEC_ARG1, objc, objv, 0);
    22882288    if (proc == NULL) {
    22892289        return TCL_ERROR;
     
    22922292}
    22932293
    2294 static int 
     2294static int
    22952295AxisCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
    22962296{
    22972297    if (objc < 2) {
    2298         Tcl_AppendResult(interp, "wrong # args: should be \"", 
     2298        Tcl_AppendResult(interp, "wrong # args: should be \"",
    22992299                Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL);
    23002300        return TCL_ERROR;
     
    23252325    if (objc != 4) {
    23262326        Tcl_AppendResult(interp, "wrong # args: should be \"",
    2327             Tcl_GetString(objv[0]), " plane_index w h \"", (char*)NULL);
     2327            Tcl_GetString(objv[0]), " plane_index w h \"", (char*)NULL);
    23282328        return TCL_ERROR;
    23292329    }
     
    23372337        return TCL_ERROR;
    23382338    }
    2339    
     2339
    23402340    //Now read w*h*4 bytes. The server expects the plane to be a stream of
    23412341    //floats
     
    23572357
    23582358
    2359 static int 
    2360 PlaneLinkOp(ClientData cdata, Tcl_Interp *interp, int objc, 
     2359static int
     2360PlaneLinkOp(ClientData cdata, Tcl_Interp *interp, int objc,
    23612361            Tcl_Obj *const *objv)
    23622362{
    23632363    fprintf(stderr, "link the plane to the 2D renderer command\n");
    2364    
     2364
    23652365    int plane_index, tf_index;
    2366    
     2366
     2367    if (objc != 3) {
     2368        Tcl_AppendResult(interp, "wrong # args: should be \"",
     2369            Tcl_GetString(objv[0]), " plane_index tf_index \"", (char*)NULL);
     2370        return TCL_ERROR;
     2371    }
     2372    if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) {
     2373        return TCL_ERROR;
     2374    }
     2375    if (Tcl_GetIntFromObj(interp, objv[2], &tf_index) != TCL_OK) {
     2376        return TCL_ERROR;
     2377    }
     2378    //plane_render->add_plane(plane[plane_index], tf[tf_index]);
     2379    return TCL_OK;
     2380}
     2381
     2382//Enable a 2D plane for render
     2383//The plane_index is the index mantained in the 2D plane renderer
     2384static int
     2385PlaneEnableOp(ClientData cdata, Tcl_Interp *interp, int objc,
     2386              Tcl_Obj *const *objv)
     2387{
     2388    fprintf(stderr,"enable a plane so the 2D renderer can render it command\n");
     2389
    23672390    if (objc != 3) {
    23682391        Tcl_AppendResult(interp, "wrong # args: should be \"",
    2369             Tcl_GetString(objv[0]), " plane_index tf_index \"", (char*)NULL);
    2370         return TCL_ERROR;
    2371     }
    2372     if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) {
    2373         return TCL_ERROR;
    2374     }
    2375     if (Tcl_GetIntFromObj(interp, objv[2], &tf_index) != TCL_OK) {
    2376         return TCL_ERROR;
    2377     }
    2378     //plane_render->add_plane(plane[plane_index], tf[tf_index]);
    2379     return TCL_OK;
    2380 }
    2381 
    2382 //Enable a 2D plane for render
    2383 //The plane_index is the index mantained in the 2D plane renderer
    2384 static int
    2385 PlaneEnableOp(ClientData cdata, Tcl_Interp *interp, int objc,
    2386               Tcl_Obj *const *objv)
    2387 {
    2388     fprintf(stderr,"enable a plane so the 2D renderer can render it command\n");
    2389    
    2390     if (objc != 3) {
    2391         Tcl_AppendResult(interp, "wrong # args: should be \"",
    2392             Tcl_GetString(objv[0]), " plane_index mode \"", (char*)NULL);
     2392            Tcl_GetString(objv[0]), " plane_index mode \"", (char*)NULL);
    23932393        return TCL_ERROR;
    23942394    }
     
    24202420    Tcl_ObjCmdProc *proc;
    24212421
    2422     proc = Rappture::GetOpFromObj(interp, nPlaneOps, planeOps, 
     2422    proc = Rappture::GetOpFromObj(interp, nPlaneOps, planeOps,
    24232423                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    24242424    if (proc == NULL) {
     
    24392439 * Ideally, the "unirect2d" proc would do a rundimentary parsing of the data
    24402440 * to verify the structure and then pass it to the appropiate Tcl command
    2441  * (heightmap, volume, etc). Our C command always creates a heightmap. 
     2441 * (heightmap, volume, etc). Our C command always creates a heightmap.
    24422442 */
    24432443static int
    2444 UniRect2dCmd(ClientData clientData, Tcl_Interp *interp, int objc, 
     2444UniRect2dCmd(ClientData clientData, Tcl_Interp *interp, int objc,
    24452445             Tcl_Obj *const *objv)
    2446 {   
     2446{
    24472447    int xNum, yNum, zNum;
    24482448    float xMin, yMin, xMax, yMax;
     
    24502450
    24512451    if ((objc & 0x01) == 0) {
    2452         Tcl_AppendResult(interp, Tcl_GetString(objv[0]), ": ", 
    2453                 "wrong number of arguments: should be key-value pairs", 
     2452        Tcl_AppendResult(interp, Tcl_GetString(objv[0]), ": ",
     2453                "wrong number of arguments: should be key-value pairs",
    24542454                (char *)NULL);
    24552455        return TCL_ERROR;
     
    25112511            }
    25122512        } else {
    2513             Tcl_AppendResult(interp, "unknown key \"", string, 
     2513            Tcl_AppendResult(interp, "unknown key \"", string,
    25142514                "\": should be xmin, xmax, xnum, ymin, ymax, ynum, or zvalues",
    25152515                (char *)NULL);
     
    25812581xinetd_listen()
    25822582{
    2583     int flags = fcntl(0, F_GETFL, 0); 
     2583    int flags = fcntl(0, F_GETFL, 0);
    25842584    fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
    25852585
     
    26332633
    26342634    if (status != TCL_OK) {
    2635         const char *string;
    2636         int nBytes;
    2637         string = Tcl_GetStringFromObj(Tcl_GetObjResult(_interp), &nBytes);
    2638 
    2639         struct iovec iov[3];
    2640         iov[0].iov_base = "NanoVis Server Error: ";
    2641         iov[0].iov_len = strlen(iov[0].iov_base);
    2642         iov[1].iov_base = string;
    2643         iov[1].iov_len = nBytes;
    2644         iov[2].iov_base = '\n';
    2645         iov[2].iov_len = 1;
    2646         writev(0, iov, 3);
     2635        const char *string;
     2636        int nBytes;
     2637        string = Tcl_GetStringFromObj(Tcl_GetObjResult(_interp), &nBytes);
     2638
     2639        struct iovec iov[3];
     2640        iov[0].iov_base = "NanoVis Server Error: ";
     2641        iov[0].iov_len = strlen(iov[0].iov_base);
     2642        iov[1].iov_base = string;
     2643        iov[1].iov_len = nBytes;
     2644        iov[2].iov_base = '\n';
     2645        iov[2].iov_len = 1;
     2646        writev(0, iov, 3);
    26472647        return;
    26482648    }
     
    26692669
    26702670    NanoVis::display();
    2671    
     2671
    26722672    // INSOO
    26732673#ifdef XINETD
    26742674    NanoVis::read_screen();
    2675     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
     2675    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    26762676#else
    26772677    NanoVis::display_offscreen_buffer(); //display the final rendering on screen
    26782678    NanoVis::read_screen();
    2679     glutSwapBuffers(); 
    2680 #endif   
     2679    glutSwapBuffers();
     2680#endif
    26812681
    26822682#if DO_RLE
    26832683    do_rle();
    2684     int sizes[2] = {  offsets_size*sizeof(offsets[0]), rle_size }; 
     2684    int sizes[2] = {  offsets_size*sizeof(offsets[0]), rle_size };
    26852685    fprintf(stderr, "Writing %d,%d\n", sizes[0], sizes[1]); fflush(stderr);
    26862686    write(0, &sizes, sizeof(sizes));
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r1028 r1089  
    7070#include <R2/R2Fonts.h>
    7171
    72 #define SIZEOF_BMP_HEADER       54
     72#define SIZEOF_BMP_HEADER   54
    7373
    7474extern void NvInitCG(); // in Shader.cpp
     
    120120
    121121// color table for built-in transfer function editor
    122 float color_table[256][4];     
     122float color_table[256][4];
    123123
    124124/*
     
    139139// in Command.cpp
    140140extern void xinetd_listen();
    141 extern void initTcl(); 
     141extern void initTcl();
    142142
    143143//ParticleSystem* psys;
     
    167167
    168168// Object rotation angles
    169 static float live_rot_x = 90.;         
     169static float live_rot_x = 90.;
    170170static float live_rot_y = 180.;
    171171static float live_rot_z = -135;
    172172
    173173// Object translation location from the origin
    174 static float live_obj_x = -0.0; 
     174static float live_obj_x = -0.0;
    175175static float live_obj_y = -0.0;
    176176static float live_obj_z = -2.5;
     
    183183static int right_last_x;
    184184static int right_last_y;
    185 static bool left_down = false;                                         
     185static bool left_down = false;
    186186static bool right_down = false;
    187187#endif /*XINETD*/
     
    190190// FLOW
    191191float NanoVis::lic_slice_x = 1.0f;
    192 float NanoVis::lic_slice_y = 0.0f; 
    193 float NanoVis::lic_slice_z = 0.5f; 
    194 int NanoVis::lic_axis = 2; 
     192float NanoVis::lic_slice_y = 0.0f;
     193float NanoVis::lic_slice_z = 0.5f;
     194int NanoVis::lic_axis = 2;
    195195
    196196/*
     
    258258
    259259//report errors related to CG shaders
    260 void 
     260void
    261261cgErrorCallback(void)
    262262{
     
    277277/* Load a 3D volume
    278278 * index: the index into the volume array, which stores pointers to 3D volume instances
    279  * data: pointer to an array of floats. 
    280  * n_component: the number of scalars for each space point. 
    281  *              All component scalars for a point are placed consequtively in data array 
     279 * data: pointer to an array of floats.
     280 * n_component: the number of scalars for each space point.
     281 *              All component scalars for a point are placed consequtively in data array
    282282 * width, height and depth: number of points in each dimension
    283283 */
    284284Volume *
    285 NanoVis::load_volume(int index, int width, int height, int depth, 
    286                      int n_component, float* data, double vmin, 
     285NanoVis::load_volume(int index, int width, int height, int depth,
     286                     int n_component, float* data, double vmin,
    287287                     double vmax, double nzero_min)
    288288{
     
    297297
    298298        if (vol->pointsetIndex != -1) {
    299             if (((unsigned  int) vol->pointsetIndex) < pointSet.size() && 
    300                 pointSet[vol->pointsetIndex] != NULL) {
     299            if (((unsigned  int) vol->pointsetIndex) < pointSet.size() &&
     300        pointSet[vol->pointsetIndex] != NULL) {
    301301                delete pointSet[vol->pointsetIndex];
    302302                pointSet[vol->pointsetIndex] = 0;
     
    306306    }
    307307    volume[index] = new Volume(0.f, 0.f, 0.f, width, height, depth, 1.,
    308         n_component, data, vmin, vmax, nzero_min);
     308        n_component, data, vmin, vmax, nzero_min);
    309309    return volume[index];
    310310}
     
    315315{
    316316    Tcl_HashEntry *hPtr;
    317    
     317
    318318    hPtr = Tcl_FindHashEntry(&tftable, name);
    319319    if (hPtr == NULL) {
     
    325325// Creates of updates a colormap 1D texture by name.
    326326TransferFunction*
    327 NanoVis::DefineTransferFunction(const char *name, size_t n, float *data) 
     327NanoVis::DefineTransferFunction(const char *name, size_t n, float *data)
    328328{
    329329    int isNew;
     
    333333    hPtr = Tcl_CreateHashEntry(&tftable, name, &isNew);
    334334    if (isNew) {
    335         tf = new TransferFunction(n, data);
    336         Tcl_SetHashValue(hPtr, (ClientData)tf);
     335        tf = new TransferFunction(n, data);
     336        Tcl_SetHashValue(hPtr, (ClientData)tf);
    337337    } else {
    338         /*
    339         * You can't delete the transfer function because many
    340         * objects may be holding its pointer.  We must update it.
    341         */
    342         tf = (TransferFunction *)Tcl_GetHashValue(hPtr);
    343         tf->update(n, data);
     338        /*
     339        * You can't delete the transfer function because many
     340        * objects may be holding its pointer.  We must update it.
     341        */
     342        tf = (TransferFunction *)Tcl_GetHashValue(hPtr);
     343        tf->update(n, data);
    344344    }
    345345    return tf;
     
    358358{
    359359    glutSetWindow(render_window);
    360    
     360
    361361    //fprintf(stderr, "tf update\n");
    362362    TransferFunction *tf = NanoVis::get_transfunc("default");
     
    364364        return;
    365365    }
    366    
     366
    367367    float data[256*4];
    368368    for(int i=0; i<256; i++) {
     
    373373        //fprintf(stderr, "(%f,%f,%f,%f) ", data[4*i+0], data[4*i+1], data[4*i+2], data[4*i+3]);
    374374    }
    375    
     375
    376376    tf->update(data);
    377    
     377
    378378#ifdef EVENTLOG
    379379    float param[3] = {0,0,0};
     
    384384}
    385385
    386 int 
     386int
    387387NanoVis::render_legend(
    388     TransferFunction *tf, 
    389     double min, double max, 
    390     int width, int height, 
     388    TransferFunction *tf,
     389    double min, double max,
     390    int width, int height,
    391391    const char* volArg)
    392392{
     
    426426
    427427//initialize frame buffer objects for offscreen rendering
    428 void 
     428void
    429429NanoVis::init_offscreen_buffer()
    430430{
     
    433433    glGenTextures(1, &final_color_tex);
    434434    glGenRenderbuffersEXT(1, &final_depth_rb);
    435    
     435
    436436    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);
    437    
     437
    438438    //initialize final color texture
    439439    glBindTexture(GL_TEXTURE_2D, final_color_tex);
     
    450450                              GL_COLOR_ATTACHMENT0_EXT,
    451451                              GL_TEXTURE_2D, final_color_tex, 0);
    452    
     452
    453453    // initialize final depth renderbuffer
    454454    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, final_depth_rb);
     
    458458                                 GL_DEPTH_ATTACHMENT_EXT,
    459459                                 GL_RENDERBUFFER_EXT, final_depth_rb);
    460    
     460
    461461    // Check framebuffer completeness at the end of initialization.
    462462    CHECK_FRAMEBUFFER_STATUS();
     
    472472    win_width = w;
    473473    win_height = h;
    474    
     474
    475475    if (fonts) {
    476476        fonts->resize(w, h);
    477477    }
    478    
     478
    479479    //fprintf(stderr, "screen_buffer size: %d\n", sizeof(screen_buffer));
    480480    printf("screen_buffer size: %d %d\n", w, h);
    481    
     481
    482482    if (screen_buffer) {
    483483        delete[] screen_buffer;
    484484        screen_buffer = NULL;
    485485    }
    486    
     486
    487487    screen_buffer = new unsigned char[4*win_width*win_height];
    488488    assert(screen_buffer != NULL);
    489    
     489
    490490    //delete the current render buffer resources
    491491    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);
    492492    glDeleteTextures(1, &final_color_tex);
    493493    glDeleteFramebuffersEXT(1, &final_fbo);
    494    
     494
    495495    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, final_depth_rb);
    496496    glDeleteRenderbuffersEXT(1, &final_depth_rb);
    497    
     497
    498498    //change the camera setting
    499499    cam->set_screen_size(0, 0, win_width, win_height);
    500500    plane_render->set_screen_size(win_width, win_height);
    501    
     501
    502502    //Reinitialize final fbo for final display
    503503    glGenFramebuffersEXT(1, &final_fbo);
     
    506506
    507507    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);
    508    
     508
    509509    //initialize final color texture
    510510    glBindTexture(GL_TEXTURE_2D, final_color_tex);
     
    521521                              GL_COLOR_ATTACHMENT0_EXT,
    522522                              GL_TEXTURE_2D, final_color_tex, 0);
    523        
     523
    524524    // initialize final depth renderbuffer
    525525    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, final_depth_rb);
     
    536536
    537537/*
    538  * FIXME: This routine is fairly expensive (60000 floating pt divides). 
    539  *        I've put an ifdef around the call to it so that the released
    540  *        builds don't include it.  Define PROTOTYPE to 1 in config.h
    541  *        to turn it back on.
     538 * FIXME: This routine is fairly expensive (60000 floating pt divides).
     539 *      I've put an ifdef around the call to it so that the released
     540 *      builds don't include it.  Define PROTOTYPE to 1 in config.h
     541 *      to turn it back on.
    542542 */
    543543void
     
    547547    int h = 200;
    548548    float* data = new float[w*h];
    549    
     549
    550550    //procedurally make a gradient plane
    551551    for(int j=0; j<h; j++){
     
    566566    int index;
    567567    //bool particle;
    568     for (int i=0; i<particleRenderer->psys_width; i++) { 
    569         for (int j=0; j<particleRenderer->psys_height; j++) { 
     568    for (int i=0; i<particleRenderer->psys_width; i++) {
     569        for (int j=0; j<particleRenderer->psys_height; j++) {
    570570            index = i + particleRenderer->psys_height*j;
    571571            //particle = rand() % 256 > 150;
     
    577577                data[4*index+1]= j/float(particleRenderer->psys_height);
    578578                data[4*index+2]= i/float(particleRenderer->psys_width);
    579                 data[4*index+3]= 30; //shorter life span, quicker iterations   
    580                 //data[4*index+3]= 1.0f; //shorter life span, quicker iterations       
     579                data[4*index+3]= 30; //shorter life span, quicker iterations
     580                //data[4*index+3]= 1.0f; //shorter life span, quicker iterations
    581581            }
    582582/*
     
    586586                data[4*index+1]= 0;
    587587                data[4*index+2]= 0;
    588                 data[4*index+3]= 0;     
     588                data[4*index+3]= 0;
    589589            }
    590590*/
     
    646646    color_table_renderer = new NvColorTableRenderer();
    647647    color_table_renderer->setFonts(fonts);
    648    
     648
    649649    particleRenderer = new NvParticleRenderer(NMESH, NMESH, g_context);
    650650
     
    661661
    662662/*----------------------------------------------------*/
    663 void 
    664 NanoVis::initGL(void) 
    665 { 
     663void
     664NanoVis::initGL(void)
     665{
    666666   //buffer to store data read from the screen
    667667   if (screen_buffer) {
     
    673673
    674674   //create the camera with default setting
    675    cam = new NvCamera(0, 0, win_width, win_height, 
     675   cam = new NvCamera(0, 0, win_width, win_height,
    676676                   live_obj_x, live_obj_y, live_obj_z,
    677677                   0., 0., 100.,
     
    694694   glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
    695695   glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
    696    glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);     
     696   glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
    697697   glLightfv(GL_LIGHT1, GL_DIFFUSE, green_light);
    698    glLightfv(GL_LIGHT1, GL_SPECULAR, white_light);     
     698   glLightfv(GL_LIGHT1, GL_SPECULAR, white_light);
    699699
    700700   // init table of transfer functions
     
    704704   if(check_query_support()){
    705705     //create queries to count number of rendered pixels
    706      perf = new PerfQuery(); 
     706     perf = new PerfQuery();
    707707   }
    708708
     
    734734#if PROTOTYPE
    735735   make_test_2D_data();
    736 #endif  /* PROTOTYPE */
     736#endif  /* PROTOTYPE */
    737737   plane_render->add_plane(plane[0], get_transfunc("default"));
    738738
     
    741741#ifdef notdef
    742742   init_particle_system();
    743    NanoVis::init_lic(); 
     743   NanoVis::init_lic();
    744744#endif
    745745}
     
    758758    rle_size = 0;
    759759    offsets_size = 0;
    760    
     760
    761761    int i=0;
    762762    while(i<len){
     
    769769            i = pos;
    770770        }
    771        
     771
    772772        else {
    773773            int pos;
     
    778778            i = pos;
    779779        }
    780        
     780
    781781    }
    782782}
     
    870870    char filename[100];
    871871    if (frame_number >= 0) {
    872         if (directory_name)
    873             sprintf(filename, "%s/image%03d.bmp", directory_name, frame_number);
    874         else
    875             sprintf(filename, "/tmp/flow_animation/image%03d.bmp", frame_number);
     872        if (directory_name)
     873            sprintf(filename, "%s/image%03d.bmp", directory_name, frame_number);
     874        else
     875            sprintf(filename, "/tmp/flow_animation/image%03d.bmp", frame_number);
    876876
    877877        printf("Writing %s\n", filename);
    878878        f = fopen(filename, "wb");
    879         if (f == 0) {
    880             Trace("cannot create file\n");
    881         }
     879        if (f == 0) {
     880            Trace("cannot create file\n");
     881        }
    882882    } else {
    883883        f = fopen("/tmp/image.bmp", "wb");
    884         if (f == 0) {
    885             Trace("cannot create file\n");
    886         }
     884        if (f == 0) {
     885            Trace("cannot create file\n");
     886        }
    887887    }
    888888    fwrite((void*) header, SIZEOF_BMP_HEADER, 1, f);
     
    968968 * ppm_write --
    969969 *
    970  *      Writes the screen image as PPM binary data to the nanovisviewer
    971  *      client.  The PPM binary format is very simple. 
     970 *  Writes the screen image as PPM binary data to the nanovisviewer
     971 *  client.  The PPM binary format is very simple.
    972972 *
    973  *              P6 w h 255\n
    974  *              3-byte RGB pixel data.
     973 *      P6 w h 255\n
     974 *      3-byte RGB pixel data.
    975975 *
    976  *      The nanovisviewer client (using the TkImg library) will do less work
    977  *      to unpack this format, as opposed to BMP or PNG.  (This doesn't
    978  *      eliminate the need to look into DXT compression performed on the GPU).
     976 *  The nanovisviewer client (using the TkImg library) will do less work
     977 *  to unpack this format, as opposed to BMP or PNG.  (This doesn't
     978 *  eliminate the need to look into DXT compression performed on the GPU).
    979979 *
    980980 *      Note that currently the image data from the screen is both row-padded
     
    10171017    unsigned char *srcRowPtr = screen_buffer;
    10181018    for (y = win_height + 1; y >= 2; y--) {
    1019         iov[y].iov_base = srcRowPtr;
    1020         iov[y].iov_len = rowLength;
    1021         srcRowPtr += bytesPerRow;
     1019        iov[y].iov_base = srcRowPtr;
     1020        iov[y].iov_len = rowLength;
     1021        srcRowPtr += bytesPerRow;
    10221022    }
    10231023    writev(0, iov, nRecs);
     
    10331033        for(int j=0; j<NMESH; j++){
    10341034            Vector2 v = grid.get(i, j);
    1035            
     1035
    10361036            int x1 = i*DM;
    10371037            int y1 = j*DM;
    1038            
     1038
    10391039            int x2 = x1 + v.x;
    10401040            int y2 = y1 + v.y;
    1041            
     1041
    10421042            glBegin(GL_LINES);
    10431043            glVertex2d(x1, y1);
     
    10511051
    10521052/*----------------------------------------------------*/
    1053 static void 
     1053static void
    10541054idle()
    10551055{
    10561056    glutSetWindow(render_window);
    1057  
     1057
    10581058#ifdef notdef
    10591059      struct timespec ts;
     
    10751075    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    10761076    glBindTexture(GL_TEXTURE_2D, final_color_tex);
    1077    
     1077
    10781078    glViewport(0, 0, win_width, win_height);
    10791079    glMatrixMode(GL_PROJECTION);
     
    10821082    glMatrixMode(GL_MODELVIEW);
    10831083    glLoadIdentity();
    1084    
     1084
    10851085    glColor3f(1.,1.,1.);                //MUST HAVE THIS LINE!!!
    10861086    glBegin(GL_QUADS);
    10871087    {
    1088         glTexCoord2f(0, 0); glVertex2f(0, 0);
    1089         glTexCoord2f(1, 0); glVertex2f(win_width, 0);
    1090         glTexCoord2f(1, 1); glVertex2f(win_width, win_height);
    1091         glTexCoord2f(0, 1); glVertex2f(0, win_height);
     1088        glTexCoord2f(0, 0); glVertex2f(0, 0);
     1089        glTexCoord2f(1, 0); glVertex2f(win_width, 0);
     1090        glTexCoord2f(1, 1); glVertex2f(win_width, win_height);
     1091        glTexCoord2f(0, 1); glVertex2f(0, win_height);
    10921092    }
    10931093    glEnd();
     
    11091109void soft_read_verts()
    11101110{
    1111     glReadPixels(0, 0, psys->psys_width, psys->psys_height, GL_RGB, GL_FLOAT, 
    1112                 vert);
     1111    glReadPixels(0, 0, psys->psys_width, psys->psys_height, GL_RGB, GL_FLOAT,
     1112        vert);
    11131113    //fprintf(stderr, "soft_read_vert");
    1114    
    1115     //cpu sort the distance 
     1114
     1115    //cpu sort the distance
    11161116    Particle* p;
    11171117    p = (Particle*)malloc(sizeof(Particle)*psys->psys_width*psys->psys_height);
     
    11201120        float y = vert[3*i+1];
    11211121        float z = vert[3*i+2];
    1122        
    1123         float dis = (x-live_obj_x)*(x-live_obj_x) + (y-live_obj_y)*(y-live_obj_y) + (z-live_obj_z)*(z-live_obj_z); 
     1122
     1123        float dis = (x-live_obj_x)*(x-live_obj_x) + (y-live_obj_y)*(y-live_obj_y) + (z-live_obj_z)*(z-live_obj_z);
    11241124        p[i].x = x;
    11251125        p[i].y = y;
     
    11271127        p[i].aux = dis;
    11281128    }
    1129    
     1129
    11301130    qsort(p, psys->psys_width * psys->psys_height, sizeof(Particle), particle_distance_sort);
    1131    
     1131
    11321132    for(int i=0; i<psys->psys_width * psys->psys_height; i++){
    11331133        vert[3*i] = p[i].x;
     
    11351135        vert[3*i+2] = p[i].z;
    11361136    }
    1137    
     1137
    11381138    free(p);
    11391139}
     
    11461146{
    11471147    glPushMatrix();
    1148    
     1148
    11491149    glEnable(GL_TEXTURE_2D);
    11501150    glBindTexture(GL_TEXTURE_RECTANGLE_NV, tex);
    1151    
     1151
    11521152    glViewport(0, 0, width, height);
    11531153    glMatrixMode(GL_PROJECTION);
     
    11561156    glMatrixMode(GL_MODELVIEW);
    11571157    glLoadIdentity();
    1158    
     1158
    11591159    cgGLBindProgram(m_passthru_fprog);
    11601160    cgGLEnableProfile(CG_PROFILE_FP30);
    1161    
     1161
    11621162    cgGLSetParameter4f(m_passthru_scale_param, 1.0, 1.0, 1.0, 1.0);
    11631163    cgGLSetParameter4f(m_passthru_bias_param, 0.0, 0.0, 0.0, 0.0);
    1164    
     1164
    11651165    draw_quad(width, height, width, height);
    11661166    cgGLDisableProfile(CG_PROFILE_FP30);
    1167    
     1167
    11681168    glPopMatrix();
    1169    
     1169
    11701170    //assert(glGetError()==0);
    11711171}
     
    11751175//draw vertices in the main memory
    11761176#ifdef notdef
    1177 void 
     1177void
    11781178soft_display_verts()
    11791179{
    11801180    glDisable(GL_TEXTURE_2D);
    11811181    glEnable(GL_BLEND);
    1182    
     1182
    11831183    glPointSize(0.5);
    11841184    glColor4f(0,0.8,0.8,0.6);
    11851185    glBegin(GL_POINTS);
    11861186    {
    1187         for(int i=0; i < psys->psys_width * psys->psys_height; i++){
    1188             glVertex3f(vert[3*i], vert[3*i+1], vert[3*i+2]);
    1189         }
     1187        for(int i=0; i < psys->psys_width * psys->psys_height; i++){
     1188            glVertex3f(vert[3*i], vert[3*i+1], vert[3*i+2]);
     1189        }
    11901190    }
    11911191    glEnd();
     
    11961196#if 0
    11971197//oddeven sort on GPU
    1198 void 
     1198void
    11991199sortstep()
    12001200{
    12011201    // perform one step of the current sorting algorithm
    1202    
     1202
    12031203#ifdef notdef
    12041204    // swap buffers
    12051205    int sourceBuffer = targetBuffer;
    1206     targetBuffer = (targetBuffer+1)%2;   
     1206    targetBuffer = (targetBuffer+1)%2;
    12071207    int pstage = (1<<stage);
    12081208    int ppass  = (1<<pass);
    12091209    int activeBitonicShader = 0;
    1210    
     1210
    12111211#ifdef _WIN32
    12121212    buffer->BindBuffer(wglTargets[sourceBuffer]);
     
    12251225    // switch on correct sorting shader
    12261226    oddevenMergeSort.bind();
    1227     glUniform3fARB(oddevenMergeSort.getUniformLocation("Param1"), float(pstage+pstage), 
     1227    glUniform3fARB(oddevenMergeSort.getUniformLocation("Param1"), float(pstage+pstage),
    12281228                   float(ppass%pstage), float((pstage+pstage)-(ppass%pstage)-1));
    1229     glUniform3fARB(oddevenMergeSort.getUniformLocation("Param2"), 
    1230                    float(psys_width), float(psys_height), float(ppass));
     1229    glUniform3fARB(oddevenMergeSort.getUniformLocation("Param2"),
     1230           float(psys_width), float(psys_height), float(ppass));
    12311231    glUniform1iARB(oddevenMergeSort.getUniformLocation("Data"), 0);
    12321232    staticdebugmsg("sort","stage "<<pstage<<" pass "<<ppass);
    1233    
     1233
    12341234    // This clear is not necessary for sort to function. But if we are in
    12351235    // interactive mode unused parts of the texture that are visible will look
     
    12371237#ifdef notdef
    12381238    if (!perfTest) glClear(GL_COLOR_BUFFER_BIT);
    1239    
     1239
    12401240    buffer->Bind();
    12411241    buffer->EnableTextureTarget();
    12421242#endif
    1243    
     1243
    12441244    // Initiate the sorting step on the GPU a full-screen quad
    12451245    glBegin(GL_QUADS);
    12461246    {
    12471247#ifdef notdef
    1248         glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f);
    1249         glVertex2f(-1.0f,-1.0f);
    1250         glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f);
    1251         glVertex2f(1.0f,-1.0f);
    1252         glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f);
    1253         glVertex2f(1.0f,1.0f);       
    1254         glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f);
    1255         glVertex2f(-1.0f,1.0f);   
    1256 #endif
    1257         glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f);
    1258         glVertex2f(0.,0.);       
    1259         glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f);
    1260         glVertex2f(float(psys_width), 0.);
    1261         glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f);
    1262         glVertex2f(float(psys_width), float(psys_height));   
    1263         glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f);
    1264         glVertex2f(0., float(psys_height));       
     1248        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f);
     1249        glVertex2f(-1.0f,-1.0f);
     1250        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f);
     1251        glVertex2f(1.0f,-1.0f);
     1252        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f);
     1253        glVertex2f(1.0f,1.0f);
     1254        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f);
     1255        glVertex2f(-1.0f,1.0f);
     1256#endif
     1257        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f);
     1258        glVertex2f(0.,0.);
     1259        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f);
     1260        glVertex2f(float(psys_width), 0.);
     1261        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f);
     1262        glVertex2f(float(psys_width), float(psys_height));
     1263        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f);
     1264        glVertex2f(0., float(psys_height));
    12651265    }
    12661266    glEnd();
     
    12811281    glDisable(GL_TEXTURE_2D);
    12821282    glEnable(GL_DEPTH_TEST);
    1283    
     1283
    12841284    //draw axes
    12851285    GLUquadric *obj;
    12861286
    12871287    obj = gluNewQuadric();
    1288    
     1288
    12891289    glDepthFunc(GL_LESS);
    12901290    glEnable(GL_COLOR_MATERIAL);
    12911291    glEnable(GL_DEPTH_TEST);
    12921292    glDisable(GL_BLEND);
    1293    
     1293
    12941294    int segments = 50;
    1295    
     1295
    12961296    glColor3f(0.8, 0.8, 0.8);
    12971297    glPushMatrix();
     
    13011301    glScalef(0.0005, 0.0005, 0.0005);
    13021302    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'x');
    1303     glPopMatrix();     
    1304    
     1303    glPopMatrix();
     1304
    13051305    glPushMatrix();
    13061306    glTranslatef(0., 0.4, 0.);
     
    13091309    glScalef(0.0005, 0.0005, 0.0005);
    13101310    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'y');
    1311     glPopMatrix();     
    1312    
     1311    glPopMatrix();
     1312
    13131313    glPushMatrix();
    13141314    glTranslatef(0., 0., 0.4);
     
    13171317    glScalef(0.0005, 0.0005, 0.0005);
    13181318    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'z');
    1319     glPopMatrix();     
    1320    
     1319    glPopMatrix();
     1320
    13211321    glEnable(GL_LIGHTING);
    13221322    glEnable(GL_LIGHT0);
    1323    
     1323
    13241324    //glColor3f(0.2, 0.2, 0.8);
    13251325    glPushMatrix();
    13261326    glutSolidSphere(0.02, segments, segments );
    13271327    glPopMatrix();
    1328    
     1328
    13291329    glPushMatrix();
    1330     glRotatef(-90, 1, 0, 0);   
     1330    glRotatef(-90, 1, 0, 0);
    13311331    gluCylinder(obj, 0.01, 0.01, 0.3, segments, segments);
    1332     glPopMatrix();     
    1333    
     1332    glPopMatrix();
     1333
    13341334    glPushMatrix();
    13351335    glTranslatef(0., 0.3, 0.);
    1336     glRotatef(-90, 1, 0, 0);   
     1336    glRotatef(-90, 1, 0, 0);
    13371337    gluCylinder(obj, 0.02, 0.0, 0.06, segments, segments);
    1338     glPopMatrix();     
    1339    
     1338    glPopMatrix();
     1339
    13401340    glPushMatrix();
    13411341    glRotatef(90, 0, 1, 0);
    13421342    gluCylinder(obj, 0.01, 0.01, 0.3, segments, segments);
    1343     glPopMatrix();     
    1344    
     1343    glPopMatrix();
     1344
    13451345    glPushMatrix();
    13461346    glTranslatef(0.3, 0., 0.);
    1347     glRotatef(90, 0, 1, 0);     
     1347    glRotatef(90, 0, 1, 0);
    13481348    gluCylinder(obj, 0.02, 0.0, 0.06, segments, segments);
    1349     glPopMatrix();     
    1350    
     1349    glPopMatrix();
     1350
    13511351    glPushMatrix();
    13521352    gluCylinder(obj, 0.01, 0.01, 0.3, segments, segments);
    1353     glPopMatrix();     
    1354    
     1353    glPopMatrix();
     1354
    13551355    glPushMatrix();
    13561356    glTranslatef(0., 0., 0.3);
    13571357    gluCylinder(obj, 0.02, 0.0, 0.06, segments, segments);
    1358     glPopMatrix();     
    1359    
     1358    glPopMatrix();
     1359
    13601360    glDisable(GL_LIGHTING);
    13611361    glDisable(GL_DEPTH_TEST);
    13621362    gluDeleteQuadric(obj);
    1363    
     1363
    13641364    glEnable(GL_TEXTURE_2D);
    13651365    glDisable(GL_DEPTH_TEST);
     
    13671367
    13681368#ifdef notdef
    1369 void 
     1369void
    13701370draw_axis()
    13711371{
    13721372    glDisable(GL_TEXTURE_2D);
    13731373    glEnable(GL_DEPTH_TEST);
    1374    
     1374
    13751375    //red x
    13761376    glColor3f(1,0,0);
     
    13811381    }
    13821382    glEnd();
    1383    
     1383
    13841384    //blue y
    13851385    glColor3f(0,0,1);
     
    13901390    }
    13911391    glEnd();
    1392    
     1392
    13931393    //green z
    13941394    glColor3f(0,1,0);
     
    13991399    }
    14001400    glEnd();
    1401    
     1401
    14021402    glEnable(GL_TEXTURE_2D);
    14031403    glDisable(GL_DEPTH_TEST);
     
    14121412        double elapsed_time;
    14131413
    1414         elapsed_time = clock.tv_sec + clock.tv_usec/1000000.0 -
    1415             vol_renderer->_volumeInterpolator->getStartTime();
    1416        
     1414        elapsed_time = clock.tv_sec + clock.tv_usec/1000000.0 -
     1415            vol_renderer->_volumeInterpolator->getStartTime();
     1416
    14171417        Trace("%lf %lf\n", elapsed_time, vol_renderer->_volumeInterpolator->getInterval());
    14181418        float fraction;
     
    14311431
    14321432void
    1433 NanoVis::SetVolumeRanges() 
     1433NanoVis::SetVolumeRanges()
    14341434{
    14351435    double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
    1436    
     1436
    14371437    xMin = yMin = zMin = wMin = DBL_MAX;
    14381438    xMax = yMax = zMax = wMax = -DBL_MAX;
    14391439    for (unsigned int i = 0; i < volume.size(); i++) {
    1440         Volume *volPtr;
    1441        
    1442         volPtr = volume[i];
    1443         if (volPtr == NULL) {
    1444             continue;
    1445         }
    1446         if (!volPtr->enabled) {
    1447             continue;
    1448         }
    1449         if (xMin > volPtr->xAxis.Min()) {
    1450             xMin = volPtr->xAxis.Min();
    1451         }
    1452         if (xMax < volPtr->xAxis.Max()) {
    1453             xMax = volPtr->xAxis.Max();
    1454         }
    1455         if (yMin > volPtr->yAxis.Min()) {
    1456             yMin = volPtr->yAxis.Min();
    1457         }
    1458         if (yMax < volPtr->yAxis.Max()) {
    1459             yMax = volPtr->yAxis.Max();
    1460         }
    1461         if (zMin > volPtr->zAxis.Min()) {
    1462             zMin = volPtr->zAxis.Min();
    1463         }
    1464         if (zMax < volPtr->zAxis.Max()) {
    1465             zMax = volPtr->zAxis.Max();
    1466         }
    1467         if (wMin > volPtr->wAxis.Min()) {
    1468             wMin = volPtr->wAxis.Min();
    1469         }
    1470         if (wMax < volPtr->wAxis.Max()) {
    1471             wMax = volPtr->wAxis.Max();
    1472         }
     1440        Volume *volPtr;
     1441
     1442        volPtr = volume[i];
     1443        if (volPtr == NULL) {
     1444            continue;
     1445        }
     1446        if (!volPtr->enabled) {
     1447            continue;
     1448        }
     1449        if (xMin > volPtr->xAxis.Min()) {
     1450            xMin = volPtr->xAxis.Min();
     1451        }
     1452        if (xMax < volPtr->xAxis.Max()) {
     1453            xMax = volPtr->xAxis.Max();
     1454        }
     1455        if (yMin > volPtr->yAxis.Min()) {
     1456            yMin = volPtr->yAxis.Min();
     1457        }
     1458        if (yMax < volPtr->yAxis.Max()) {
     1459            yMax = volPtr->yAxis.Max();
     1460        }
     1461        if (zMin > volPtr->zAxis.Min()) {
     1462            zMin = volPtr->zAxis.Min();
     1463        }
     1464        if (zMax < volPtr->zAxis.Max()) {
     1465            zMax = volPtr->zAxis.Max();
     1466        }
     1467        if (wMin > volPtr->wAxis.Min()) {
     1468            wMin = volPtr->wAxis.Min();
     1469        }
     1470        if (wMax < volPtr->wAxis.Max()) {
     1471            wMax = volPtr->wAxis.Max();
     1472        }
    14731473    }
    14741474    if ((xMin < DBL_MAX) && (xMax > -DBL_MAX)) {
    1475         grid->xAxis.SetScale(xMin, xMax);
     1475        grid->xAxis.SetScale(xMin, xMax);
    14761476    }
    14771477    if ((yMin < DBL_MAX) && (yMax > -DBL_MAX)) {
    1478         grid->yAxis.SetScale(yMin, yMax);
     1478        grid->yAxis.SetScale(yMin, yMax);
    14791479    }
    14801480    if ((zMin < DBL_MAX) && (zMax > -DBL_MAX)) {
    1481         grid->zAxis.SetScale(zMin, zMax);
     1481        grid->zAxis.SetScale(zMin, zMax);
    14821482    }
    14831483    if ((wMin < DBL_MAX) && (wMax > -DBL_MAX)) {
    1484         Volume::valueMin = wMin;
    1485         Volume::valueMax = wMax;
     1484        Volume::valueMin = wMin;
     1485        Volume::valueMax = wMax;
    14861486    }
    14871487    Volume::update_pending = false;
     
    14921492{
    14931493    double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
    1494    
     1494
    14951495    xMin = yMin = zMin = wMin = DBL_MAX;
    14961496    xMax = yMax = zMax = wMax = -DBL_MAX;
    14971497    for (unsigned int i = 0; i < heightMap.size(); i++) {
    1498         HeightMap *hmPtr;
    1499        
    1500         hmPtr = heightMap[i];
    1501         if (hmPtr == NULL) {
    1502             continue;
    1503         }
    1504         if (xMin > hmPtr->xAxis.Min()) {
    1505             xMin = hmPtr->xAxis.Min();
    1506         }
    1507         if (xMax < hmPtr->xAxis.Max()) {
    1508             xMax = hmPtr->xAxis.Max();
    1509         }
    1510         if (yMin > hmPtr->yAxis.Min()) {
    1511             yMin = hmPtr->yAxis.Min();
    1512         }
    1513         if (yMax < hmPtr->yAxis.Max()) {
    1514             yMax = hmPtr->yAxis.Max();
    1515         }
    1516         if (zMin > hmPtr->zAxis.Min()) {
    1517             zMin = hmPtr->zAxis.Min();
    1518         }
    1519         if (zMax < hmPtr->zAxis.Max()) {
    1520             zMax = hmPtr->zAxis.Max();
    1521         }
    1522         if (wMin > hmPtr->wAxis.Min()) {
    1523             wMin = hmPtr->wAxis.Min();
    1524         }
    1525         if (wMax < hmPtr->wAxis.Max()) {
    1526             wMax = hmPtr->wAxis.Max();
    1527         }
     1498        HeightMap *hmPtr;
     1499
     1500        hmPtr = heightMap[i];
     1501        if (hmPtr == NULL) {
     1502            continue;
     1503        }
     1504        if (xMin > hmPtr->xAxis.Min()) {
     1505            xMin = hmPtr->xAxis.Min();
     1506        }
     1507        if (xMax < hmPtr->xAxis.Max()) {
     1508            xMax = hmPtr->xAxis.Max();
     1509        }
     1510        if (yMin > hmPtr->yAxis.Min()) {
     1511            yMin = hmPtr->yAxis.Min();
     1512        }
     1513        if (yMax < hmPtr->yAxis.Max()) {
     1514            yMax = hmPtr->yAxis.Max();
     1515        }
     1516        if (zMin > hmPtr->zAxis.Min()) {
     1517            zMin = hmPtr->zAxis.Min();
     1518        }
     1519        if (zMax < hmPtr->zAxis.Max()) {
     1520            zMax = hmPtr->zAxis.Max();
     1521        }
     1522        if (wMin > hmPtr->wAxis.Min()) {
     1523            wMin = hmPtr->wAxis.Min();
     1524        }
     1525        if (wMax < hmPtr->wAxis.Max()) {
     1526            wMax = hmPtr->wAxis.Max();
     1527        }
    15281528    }
    15291529    if ((xMin < DBL_MAX) && (xMax > -DBL_MAX)) {
    1530         grid->xAxis.SetScale(xMin, xMax);
     1530        grid->xAxis.SetScale(xMin, xMax);
    15311531    }
    15321532    if ((yMin < DBL_MAX) && (yMax > -DBL_MAX)) {
    1533         grid->yAxis.SetScale(yMin, yMax);
     1533        grid->yAxis.SetScale(yMin, yMax);
    15341534    }
    15351535    if ((zMin < DBL_MAX) && (zMax > -DBL_MAX)) {
    1536         grid->zAxis.SetScale(zMin, zMax);
     1536        grid->zAxis.SetScale(zMin, zMax);
    15371537    }
    15381538    if ((wMin < DBL_MAX) && (wMax > -DBL_MAX)) {
    1539         HeightMap::valueMin = wMin;
    1540         HeightMap::valueMax = wMax;
     1539        HeightMap::valueMin = wMin;
     1540        HeightMap::valueMax = wMax;
    15411541    }
    15421542    HeightMap::update_pending = false;
     
    15441544
    15451545/*----------------------------------------------------*/
    1546 void 
     1546void
    15471547NanoVis::display()
    15481548{
    15491549    //assert(glGetError()==0);
    15501550    if (HeightMap::update_pending) {
    1551         SetHeightmapRanges();
     1551        SetHeightmapRanges();
    15521552    }
    15531553    if (Volume::update_pending) {
    1554         SetVolumeRanges();
     1554        SetVolumeRanges();
    15551555    }
    15561556    //start final rendering
     
    15641564        //camera setting activated
    15651565        cam->activate();
    1566        
     1566
    15671567        //set up the orientation of items in the scene.
    15681568        glPushMatrix();
     
    15761576            // this is the default
    15771577            break;
    1578            
     1578
    15791579        case 3:  // z
    15801580            glRotatef(-90, 1, 0, 0);
    15811581            glRotatef(-90, 0, 0, 1);
    15821582            break;
    1583            
     1583
    15841584        case -1:  // -x
    15851585            glRotatef(-90, 0, 0, 1);
    15861586            break;
    1587            
     1587
    15881588        case -2:  // -y
    15891589            glRotatef(180, 0, 0, 1);
    15901590            glRotatef(-90, 0, 1, 0);
    15911591            break;
    1592            
     1592
    15931593        case -3:  // -z
    15941594            glRotatef(90, 1, 0, 0);
    15951595            break;
    15961596        }
    1597        
     1597
    15981598        // TBD : This will be removed after being sure that all the functions work well.
    15991599        //glPushMatrix();
    1600        
     1600
    16011601        //now render things in the scene
    16021602        if (axis_on) {
     
    16171617        //fprintf(stderr, "particle pixels: %d\n", perf->get_pixel_count());
    16181618        //perf->reset();
    1619        
     1619
    16201620        //perf->enable();
    16211621        vol_renderer->render_all();
    16221622        //perf->disable();
    1623        
     1623
    16241624        for (unsigned int i = 0; i < heightMap.size(); ++i) {
    16251625            if (heightMap[i]->isVisible()) {
     
    16741674}
    16751675
    1676 void 
     1676void
    16771677NanoVis::update_rot(int delta_x, int delta_y)
    16781678{
    16791679    live_rot_x += delta_x;
    16801680    live_rot_y += delta_y;
    1681    
     1681
    16821682    if (live_rot_x > 360.0) {
    1683         live_rot_x -= 360.0;   
     1683        live_rot_x -= 360.0;
    16841684    } else if(live_rot_x < -360.0) {
    16851685        live_rot_x += 360.0;
    16861686    }
    16871687    if (live_rot_y > 360.0) {
    1688         live_rot_y -= 360.0;   
     1688        live_rot_y -= 360.0;
    16891689    } else if(live_rot_y < -360.0) {
    16901690        live_rot_y += 360.0;
     
    17721772   default:
    17731773       break;
    1774    }   
     1774   }
    17751775#ifdef EVENTLOG
    17761776   if(log){
     
    17861786NanoVis::motion(int x, int y)
    17871787{
    1788     int old_x, old_y;   
     1788    int old_x, old_y;
    17891789
    17901790    if(left_down){
    17911791        old_x = left_last_x;
    1792         old_y = left_last_y;   
     1792        old_y = left_last_y;
    17931793    } else if(right_down){
    17941794        old_x = right_last_x;
    1795         old_y = right_last_y;   
    1796     }
    1797    
     1795        old_y = right_last_y;
     1796    }
     1797
    17981798    int delta_x = x - old_x;
    17991799    int delta_y = y - old_y;
    1800    
     1800
    18011801    //more coarse event handling
    18021802    //if(abs(delta_x)<10 && abs(delta_y)<10)
    18031803    //return;
    1804    
     1804
    18051805    if(left_down){
    18061806        left_last_x = x;
    18071807        left_last_y = y;
    1808        
     1808
    18091809        update_rot(-delta_y, -delta_x);
    18101810    } else if (right_down){
    18111811        //fprintf(stderr, "right mouse motion (%d,%d)\n", x, y);
    1812        
     1812
    18131813        right_last_x = x;
    18141814        right_last_y = y;
    1815        
     1815
    18161816        update_trans(0, 0, delta_x);
    18171817    }
    1818    
     1818
    18191819#ifdef EVENTLOG
    18201820    float param[3] = {live_rot_x, live_rot_y, live_rot_z};
     
    18311831
    18321832#ifdef XINETD
    1833 void 
     1833void
    18341834init_service()
    18351835{
     
    18391839    dup2(fileno(xinetd_log), 2);
    18401840    dup2(2,1);
    1841    
    1842     //flush junk 
     1841
     1842    //flush junk
    18431843    fflush(stdout);
    18441844    fflush(stderr);
    18451845}
    18461846
    1847 void 
     1847void
    18481848end_service()
    18491849{
     
    18531853#endif  /*XINETD*/
    18541854
    1855 void 
    1856 init_event_log() 
     1855void
     1856init_event_log()
    18571857{
    18581858    event_log = fopen("event.txt", "w");
    18591859    assert(event_log!=0);
    1860    
     1860
    18611861    struct timeval time;
    18621862    gettimeofday(&time, NULL);
     
    18641864}
    18651865
    1866 void 
     1866void
    18671867end_event_log()
    18681868{
     
    18701870}
    18711871
    1872 double 
     1872double
    18731873get_time_interval()
    18741874{
     
    18761876    gettimeofday(&time, NULL);
    18771877    double new_time = time.tv_sec*1000. + time.tv_usec/1000.;
    1878    
     1878
    18791879    double interval = new_time - cur_time;
    18801880    cur_time = new_time;
    18811881    return interval;
    18821882}
    1883 #endif 
     1883#endif
    18841884
    18851885void removeAllData()
     
    18911891/*----------------------------------------------------*/
    18921892int
    1893 main(int argc, char** argv) 
     1893main(int argc, char** argv)
    18941894{
    18951895    char *path;
     
    19181918
    19191919    R2FilePath::getInstance()->setWorkingDirectory(argc, (const char**) argv);
    1920    
     1920
    19211921#ifdef XINETD
    19221922    signal(SIGPIPE,SIG_IGN);
    19231923    NvInitService();
    19241924#endif
    1925    
     1925
    19261926    glutInit(&argc, argv);
    19271927    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
    1928    
     1928
    19291929    glutInitWindowSize(NanoVis::win_width, NanoVis::win_height);
    1930    
     1930
    19311931    glutInitWindowPosition(10, 10);
    19321932    render_window = glutCreateWindow(argv[0]);
    19331933    glutDisplayFunc(NanoVis::display);
    1934    
     1934
    19351935#ifndef XINETD
    19361936    glutMouseFunc(NanoVis::mouse);
     
    19381938    glutKeyboardFunc(NanoVis::keyboard);
    19391939#endif
    1940    
     1940
    19411941    glutIdleFunc(idle);
    19421942    glutReshapeFunc(NanoVis::resize_offscreen_buffer);
    1943    
     1943
    19441944    NanoVis::init(path);
    19451945    NanoVis::initGL();
    19461946    initTcl();
    1947    
     1947
    19481948#ifdef EVENTLOG
    19491949    NvInitEventLog();
     
    19511951    //event loop
    19521952    glutMainLoop();
    1953    
     1953
    19541954    removeAllData();
    1955    
     1955
    19561956    NvExit();
    1957    
     1957
    19581958    return 0;
    19591959}
Note: See TracChangeset for help on using the changeset viewer.