Ignore:
Timestamp:
Sep 24, 2008, 10:03:52 AM (16 years ago)
Author:
gah
Message:

added stats counters

File:
1 edited

Legend:

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

    r1156 r1161  
    104104
    105105// Tcl interpreter for incoming messages
    106 static Tcl_Interp *interp;
    107 static Tcl_DString cmdbuffer;
    108106
    109107// default transfer function
     
    453451                return TCL_ERROR;
    454452            }
    455             if (index < NanoVis::volume.size() && NanoVis::volume[index] != NULL) {
     453            if (NanoVis::volume[index] != NULL) {
    456454                vectorPtr->push_back(index);
    457455            }
     
    19141912}
    19151913
    1916 
    19171914static int
    19181915HeightMapDataFollowsOp(ClientData cdata, Tcl_Interp *interp, int objc,
     
    21162113    return TCL_OK;
    21172114}
     2115
    21182116
    21192117static int
     
    24752473    float xMin, yMin, xMax, yMax;
    24762474    float *zValues;
     2475    const char *xUnits, *yUnits, *zUnits;
    24772476
    24782477    if ((objc & 0x01) == 0) {
     
    24852484    xNum = yNum = zNum = 0;
    24862485    xMin = yMin = xMax = yMax = 0.0f;
     2486    xUnits = yUnits = zUnits = NULL;
    24872487    int i;
    24882488    for (i = 1; i < objc; i += 2) {
    24892489        const char *string;
     2490        char c;
    24902491
    24912492        string = Tcl_GetString(objv[i]);
    2492         if (strcmp(string, "xmin") == 0) {
    2493             if (GetFloatFromObj(interp, objv[i+1], &xMin) != TCL_OK) {
    2494                 return TCL_ERROR;
    2495             }
    2496         } else if (strcmp(string, "xmax") == 0) {
    2497             if (GetFloatFromObj(interp, objv[i+1], &xMax) != TCL_OK) {
    2498                 return TCL_ERROR;
    2499             }
    2500         } else if (strcmp(string, "xnum") == 0) {
    2501             if (Tcl_GetIntFromObj(interp, objv[i+1], &xNum) != TCL_OK) {
    2502                 return TCL_ERROR;
    2503             }
    2504             if (xNum <= 0) {
    2505                 Tcl_AppendResult(interp, "bad xnum value: must be > 0",
    2506                                  (char *)NULL);
    2507                 return TCL_ERROR;
    2508             }
    2509         } else if (strcmp(string, "ymin") == 0) {
     2493        c = string[0];
     2494        if ((c == 'x') && (strcmp(string, "xmin") == 0)) {
     2495            if (GetFloatFromObj(interp, objv[i+1], &xMin) != TCL_OK) {
     2496                return TCL_ERROR;
     2497            }
     2498        } else if ((c == 'x') && (strcmp(string, "xmax") == 0)) {
     2499            if (GetFloatFromObj(interp, objv[i+1], &xMax) != TCL_OK) {
     2500                return TCL_ERROR;
     2501            }
     2502        } else if ((c == 'x') && (strcmp(string, "xnum") == 0)) {
     2503            if (Tcl_GetIntFromObj(interp, objv[i+1], &xNum) != TCL_OK) {
     2504                return TCL_ERROR;
     2505            }
     2506            if (xNum <= 0) {
     2507                Tcl_AppendResult(interp, "bad xnum value: must be > 0",
     2508                                 (char *)NULL);
     2509                return TCL_ERROR;
     2510            }
     2511        } else if ((c == 'x') && (strcmp(string, "xunits") == 0)) {
     2512            xUnits = Tcl_GetString(objv[i+1]);
     2513        } else if ((c == 'y') && (strcmp(string, "ymin") == 0)) {
    25102514            if (GetFloatFromObj(interp, objv[i+1], &yMin) != TCL_OK) {
    25112515                return TCL_ERROR;
    25122516            }
    2513         } else if (strcmp(string, "ymax") == 0) {
     2517        } else if ((c == 'y') && (strcmp(string, "ymax") == 0)) {
    25142518            if (GetFloatFromObj(interp, objv[i+1], &yMax) != TCL_OK) {
    25152519                return TCL_ERROR;
    25162520            }
    2517         } else if (strcmp(string, "ynum") == 0) {
     2521        } else if ((c == 'y') && (strcmp(string, "ynum") == 0)) {
    25182522            if (Tcl_GetIntFromObj(interp, objv[i+1], &yNum) != TCL_OK) {
    25192523                return TCL_ERROR;
     
    25242528                return TCL_ERROR;
    25252529            }
    2526         } else if (strcmp(string, "zvalues") == 0) {
     2530        } else if ((c == 'y') && (strcmp(string, "yunits") == 0)) {
     2531            yUnits = Tcl_GetString(objv[i+1]);
     2532        } else if ((c == 'z') && (strcmp(string, "zvalues") == 0)) {
    25272533            Tcl_Obj **zObj;
    25282534
     
    25372543                }
    25382544            }
     2545        } else if ((c == 'z') && (strcmp(string, "zunits") == 0)) {
     2546            zUnits = Tcl_GetString(objv[i+1]);
    25392547        } else {
    25402548            Tcl_AppendResult(interp, "unknown key \"", string,
    2541                 "\": should be xmin, xmax, xnum, ymin, ymax, ynum, or zvalues",
     2549                "\": should be xmin, xmax, xnum, xunits, ymin, ymax, ynum, yunits, zvalues, or zunits",
    25422550                (char *)NULL);
    25432551            return TCL_ERROR;
     
    25562564    hmPtr = new HeightMap();
    25572565
     2566    // Must set units before the heights.
     2567    hmPtr->xAxis.units(xUnits);
     2568    hmPtr->yAxis.units(yUnits);
     2569    hmPtr->zAxis.units(zUnits);
     2570    hmPtr->wAxis.units(yUnits);
    25582571    hmPtr->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, zValues);
    25592572    hmPtr->setColorMap(NanoVis::get_transfunc("default"));
     
    25652578
    25662579
    2567 void
     2580Tcl_Interp *
    25682581initTcl()
    25692582{
     2583
    25702584    /*
    25712585     * Ideally the connection is authenticated by nanoscale.  I still like the
     
    25752589     * a test harness through the interpreter for nanovis.
    25762590     */
     2591    Tcl_Interp *interp;
    25772592    interp = Tcl_CreateInterp();
    25782593    Tcl_MakeSafe(interp);
    2579 
    2580     Tcl_DStringInit(&cmdbuffer);
    25812594
    25822595    Tcl_CreateObjCommand(interp, "axis",        AxisCmd,        NULL, NULL);
     
    26022615        fprintf(NanoVis::logfile, Tcl_GetStringResult(interp));
    26032616    }
    2604 }
    2605 
    2606 
    2607 void
    2608 xinetd_listen()
    2609 {
    2610     int flags = fcntl(0, F_GETFL, 0);
    2611     fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
    2612 
    2613     int status = TCL_OK;
    2614     int npass = 0;
    2615 
    2616     //
    2617     //  Read and execute as many commands as we can from stdin...
    2618     //
    2619     while (status == TCL_OK) {
    2620         //
    2621         //  Read the next command from the buffer.  First time through we
    2622         //  block here and wait if necessary until a command comes in.
    2623         //
    2624         //  BE CAREFUL: Read only one command, up to a newline.  The "volume
    2625         //  data follows" command needs to be able to read the data
    2626         //  immediately following the command, and we shouldn't consume it
    2627         //  here.
    2628         //
    2629         while (1) {
    2630             int c = fgetc(NanoVis::stdin);
    2631             char ch;
    2632             if (c <= 0) {
    2633                 if (npass == 0) {
    2634                     exit(0);  // EOF -- we're done!
    2635                 } else {
    2636                     break;
    2637                 }
    2638             }
    2639             ch = (char)c;
    2640             Tcl_DStringAppend(&cmdbuffer, &ch, 1);
    2641 
    2642             if (ch=='\n' && Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer))) {
    2643                 break;
    2644             }
    2645         }
    2646         // no command? then we're done for now
    2647         if (Tcl_DStringLength(&cmdbuffer) == 0) {
    2648             break;
    2649         }
    2650 
    2651         // back to original flags during command evaluation...
    2652         fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
    2653         if (debug_flag) {
    2654             fprintf(NanoVis::logfile, "%s\n", Tcl_DStringValue(&cmdbuffer));
    2655         }
    2656         status = Tcl_Eval(interp, Tcl_DStringValue(&cmdbuffer));
    2657         Tcl_DStringSetLength(&cmdbuffer, 0);
    2658 
    2659         // non-blocking for next read -- we might not get anything
    2660         fcntl(0, F_SETFL, flags | O_NONBLOCK);
    2661         npass++;
    2662     }
    2663     fcntl(0, F_SETFL, flags);
    2664 
    2665     if (status != TCL_OK) {
    2666         const char *string;
    2667         int nBytes;
    2668 
    2669         string = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &nBytes);
    2670         struct iovec iov[3];
    2671         iov[0].iov_base = (char *)"NanoVis Server Error: ";
    2672         iov[0].iov_len = strlen((char *)iov[0].iov_base);
    2673         iov[1].iov_base = (char *)string;
    2674         iov[1].iov_len = nBytes;
    2675         iov[2].iov_base = (char *)'\n';
    2676         iov[2].iov_len = 1;
    2677         writev(0, iov, 3);
    2678         return;
    2679     }
    2680 
    2681     //
    2682     // This is now in "FlowCmd()":
    2683     //  Generate the latest frame and send it back to the client
    2684     //
    2685     /*
    2686       if (NanoVis::licRenderer && NanoVis::licRenderer->isActivated())
    2687       {
    2688       NanoVis::licRenderer->convolve();
    2689       }
    2690 
    2691       if (NanoVis::particleRenderer && NanoVis::particleRenderer->isActivated())
    2692       {
    2693       NanoVis::particleRenderer->advect();
    2694       }
    2695     */
    2696 
    2697     NanoVis::update();
    2698 
    2699     NanoVis::offscreen_buffer_capture();  //enable offscreen render
    2700 
    2701     NanoVis::display();
     2617    return interp;
     2618}
     2619
     2620
     2621
     2622int
     2623NanoVis::render_2d_contour(HeightMap* heightmap, int width, int height)
     2624{
     2625    int old_width = win_width;
     2626    int old_height = win_height;
     2627
     2628    resize_offscreen_buffer(width, height);
     2629
     2630/* plane_render->set_screen_size(width, height);
     2631
     2632    // generate data for the legend
     2633    float data[512];
     2634    for (int i=0; i < 256; i++) {
     2635        data[i] = data[i+256] = (float)(i/255.0);
     2636    }
     2637    plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data);
     2638    int index = plane_render->add_plane(plane[0], tf);
     2639    plane_render->set_active_plane(index);
     2640
     2641    offscreen_buffer_capture();
     2642    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
     2643
     2644    //plane_render->render();
     2645    // INSOO : is going to implement here for the topview of the heightmap
     2646    heightmap->render(renderContext);
    27022647
    27032648    // INSOO
    2704 #ifdef XINETD
    2705     NanoVis::read_screen();
    2706     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    2707 #else
    2708     NanoVis::display_offscreen_buffer(); //display the final rendering on screen
    2709     NanoVis::read_screen();
    2710     glutSwapBuffers();
    2711 #endif
    2712 
    2713 #if DO_RLE
    2714     do_rle();
    2715     int sizes[2] = {  offsets_size*sizeof(offsets[0]), rle_size };
    2716     fprintf(stderr, "Writing %d,%d\n", sizes[0], sizes[1]); fflush(stderr);
    2717     write(0, &sizes, sizeof(sizes));
    2718     write(0, offsets, offsets_size*sizeof(offsets[0]));
    2719     write(0, rle, rle_size);    //unsigned byte
    2720 #else
    2721     NanoVis::ppm_write("nv>image -bytes");
    2722 #endif
    2723 }
    2724 
     2649    glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);
     2650    //glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, screen_buffer); // INSOO's
     2651*/
     2652
     2653
     2654    // HELP ME
     2655    // GEORGE
     2656    // I am not sure what I should do
     2657    //char prefix[200];
     2658    //sprintf(prefix, "nv>height_top_view %s %g %g", volArg, min, max);
     2659    //ppm_write(prefix);
     2660    //write(0, "\n", 1);
     2661   
     2662
     2663
     2664
     2665    //plane_render->remove_plane(index);
     2666   
     2667    resize_offscreen_buffer(old_width, old_height);
     2668
     2669    return TCL_OK;
     2670}
     2671
Note: See TracChangeset for help on using the changeset viewer.