Changeset 434


Ignore:
Timestamp:
May 9, 2006 2:55:08 PM (15 years ago)
Author:
mmc
Message:

Added separate controls for outline enable/disable/color, and volume
data enable/disable.

Location:
trunk/gui/vizservers/nanovis
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/vizservers/nanovis/Color.cpp

    r379 r434  
    1818
    1919#include "Color.h"
     20#include "define.h"
    2021
    21 Color::Color(){
     22Color::Color() {
    2223        R=G=B=0.0;
    2324        next=0;
    2425}
    2526
    26 Color::Color(double r, double g, double b){
     27Color::Color(double r, double g, double b) {
    2728        R=r;
    2829        G=g;
    2930        B=b;
    3031        next=0;
     32}
     33
     34Color::Color(const Color& c)
     35 : R(c.R), G(c.G), B(c.B), next(c.next)
     36{
     37}
     38
     39Color&
     40Color::operator=(const Color& c)
     41{
     42    R = c.R;
     43    G = c.G;
     44    B = c.B;
     45    next = c.next;
     46    return *this;
    3147}
    3248
  • trunk/gui/vizservers/nanovis/Color.h

    r379 r434  
    3434        Color();
    3535        Color(double r, double g, double b);
     36        Color(const Color& c);
     37        Color& operator=(const Color& c);
     38        ~Color();
    3639
    3740        void LimitColors(); //Limits the color to be in range of 0.0 and 1.0
     
    3942        friend Color operator*(double k, Color &other);
    4043        Color operator+(Color &other);
    41         ~Color();
    42         float r, g, b, a;
    4344};
    4445
  • trunk/gui/vizservers/nanovis/Makefile

    r431 r434  
    1515NANOSCALESRC = ./nanoscale
    1616
    17 LIB_NANOVIS = -ltcl8.4 -L/opt/render/lib -lGL -lglut -lglui -lGLEW -lCg -lCgGL -pthread -lstdc++
     17LIB_NANOVIS = -ltcl8.3 -L/opt/render/lib -lGL -lglut -lglui -lGLEW -lCg -lCgGL -pthread -lstdc++
    1818LIB_CLIENT = -L/opt/render/lib -lGL -lglut -pthread -lstdc++
    19 INCLUDES = -I../src2/core -I/opt/render/include -I/autohome/u76/qiaow/Cg/usr/include
     19INCLUDES = -I../../src2/core -I/opt/render/include -I/autohome/u76/qiaow/Cg/usr/include
    2020CFLAG = -g -c $(INCLUDES)
    2121
     
    2626
    2727nanovis: $(OBJ_NANOVIS)
    28         gcc -g -o nanovis $(OBJ_NANOVIS) $(LIB_NANOVIS) ../src2/core/*.o
     28        gcc -g -o nanovis $(OBJ_NANOVIS) $(LIB_NANOVIS) ../../src2/core/*.o
    2929
    3030ColorGradient.o: Color.o $(TFSRC)/ColorGradient.cpp
  • trunk/gui/vizservers/nanovis/Volume.cpp

    r431 r434  
    2727        n_components(n),
    2828        enabled(true),
    29         n_slice(256), //defualt value
    30         specular(6.), //defualt value
    31         diffuse(3.), //defualt value
    32         opacity_scale(10.) //defualt value
     29        n_slice(256), // default value
     30        specular(6.), // default value
     31        diffuse(3.), // default value
     32        opacity_scale(10.), // default value
     33        data_enabled(true), // default value
     34        outline_enabled(true), // default value
     35        outline_color(1.,1.,1.) // default value
    3336{
    3437
     
    113116void Volume::set_diffuse(float d) { diffuse = d; }
    114117void Volume::set_opacity_scale(float s) { opacity_scale = s; }
     118
     119void Volume::enable_data() { data_enabled = true; }
     120void Volume::disable_data() { data_enabled = false; }
     121bool Volume::data_is_enabled() { return data_enabled; }
     122
     123void Volume::enable_outline() { outline_enabled = true; }
     124void Volume::disable_outline() { outline_enabled = false; }
     125bool Volume::outline_is_enabled() { return outline_enabled; }
     126void Volume::set_outline_color(float *rgb) {
     127    outline_color = Color(rgb[0],rgb[1],rgb[2]);
     128}
     129void Volume::get_outline_color(float *rgb) {
     130    outline_color.GetRGB(rgb);
     131}
  • trunk/gui/vizservers/nanovis/Volume.h

    r431 r434  
    2020
    2121#include "define.h"
     22#include "Color.h"
    2223#include "Texture3D.h"
    2324#include "Vector3.h"
     
    4849        float opacity_scale;    //The scale multiplied to the opacity assigned by the transfer function.
    4950                                //Rule of thumb: higher opacity_scale the object is to appear like plastic
     51
     52        bool data_enabled;      // show/hide cloud of volume data
     53
     54        bool outline_enabled;   // show/hide outline around volume
     55        Color outline_color;    // color for outline around volume
    5056
    5157public:
     
    102108        void set_opacity_scale(float s);
    103109
     110        void enable_data();
     111        void disable_data();
     112        bool data_is_enabled();
     113
     114        void enable_outline();
     115        void disable_outline();
     116        bool outline_is_enabled();
     117        void set_outline_color(float* rgb);
     118        void get_outline_color(float* rgb);
    104119};
    105120
  • trunk/gui/vizservers/nanovis/VolumeRenderer.cpp

    r432 r434  
    157157
    158158    //draw volume bounding box with translation (the correct location in space)
    159     draw_bounding_box(x0, y0, z0, x0+1, y0+1, z0+1, 0.8, 0.1, 0.1, 1.5);
     159    if (volume[i]->outline_is_enabled()) {
     160        float olcolor[3];
     161        volume[i]->get_outline_color(olcolor);
     162        draw_bounding_box(x0, y0, z0, x0+1, y0+1, z0+1,
     163            (double)olcolor[0], (double)olcolor[1], (double)olcolor[2],
     164            1.5);
     165    }
    160166    glPopMatrix();
    161167
     
    167173    //compute actual rendering slices
    168174    float z_step = fabs(zNear-zFar)/n_slices;           
    169     int n_actual_slices = (int)(fabs(zNear-zFar)/z_step + 1);
    170 
    171     //if no cloud
    172     //n_actual_slices = 0;
    173    
     175    int n_actual_slices;
     176
     177    if (volume[i]->data_is_enabled()) {
     178        n_actual_slices = (int)(fabs(zNear-zFar)/z_step + 1);
     179        polys[cur_vol] = new ConvexPolygon*[n_actual_slices];
     180    } else {
     181        n_actual_slices = 0;
     182        polys[cur_vol] = NULL;
     183    }
    174184    actual_slices[cur_vol] = n_actual_slices;
    175     polys[cur_vol] = new ConvexPolygon*[n_actual_slices];
    176 
    177     //if no cloud
    178     //polys[cur_vol] = NULL;
    179 
    180     float slice_z;
    181185
    182186    Vector4 vert1 = (Vector4(-10, -10, -0.5, 1));
     
    268272   
    269273    //transform slices and store them
     274    float slice_z;
    270275    for (int i=0; i<n_actual_slices; i++){
    271276      slice_z = zFar + i * z_step;      //back to front
  • trunk/gui/vizservers/nanovis/config.h

    r431 r434  
    1616
    1717#define NV40      //Uncomment if using 6 series card. By default we assume older card the 5xxx series
    18 //#define XINETD  //enable render server
     18#define XINETD  //enable render server
    1919//#define EVENTLOG  //enable event logging
    2020//#define DO_RLE  //do run length compression
  • trunk/gui/vizservers/nanovis/define.h

    r406 r434  
    5454   }
    5555
     56// use this to send debug messages back to the client
     57void debug(char *message);
     58void debug(char *message, double v1);
     59void debug(char *message, double v1, double v2);
     60void debug(char *message, double v1, double v2, double v3);
    5661
    5762#endif
  • trunk/gui/vizservers/nanovis/nanovis.cpp

    r432 r434  
    4141Camera* cam;
    4242
    43 bool volume_mode = false; //if true nanovis renders volumes in 3D, if not renders 2D plane
     43//if true nanovis renders volumes in 3D, if not renders 2D plane
     44bool volume_mode = true;
    4445
    4546// color table for built-in transfer function editor
     
    120121static int CutplaneCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    121122static int ClearCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    122 static int ScreenResizeCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
     123static int ScreenCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    123124static int TransferFunctionNewCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    124125static int TransferFunctionUpdateCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
     126static int VolumeCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    125127static int VolumeNewCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    126128static int VolumeLinkCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    127129static int VolumeMoveCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    128130static int VolumeEnableCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    129 static int OutlineCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    130131static int RefreshCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    131 static int Switch2D3DCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    132132static int PlaneNewCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    133133static int PlaneLinkCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    134134static int PlaneEnableCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    135135
    136 static int DecodeAxis _ANSI_ARGS_((Tcl_Interp *interp, char *str, int *valPtr));
     136static int GetAxis _ANSI_ARGS_((Tcl_Interp *interp, char *str, int *valPtr));
     137static int GetColor _ANSI_ARGS_((Tcl_Interp *interp, char *str, float *rgbPtr));
    137138
    138139/*
     
    262263
    263264        int axis;
    264         if (DecodeAxis(interp, (char*)argv[3], &axis) != TCL_OK) {
     265        if (GetAxis(interp, argv[3], &axis) != TCL_OK) {
    265266            return TCL_ERROR;
    266267        }
     
    305306            return TCL_ERROR;
    306307        }
     308        // keep this just inside the volume so it doesn't disappear
     309        if (relval < 0.01) { relval = 0.01; }
     310        if (relval > 0.99) { relval = 0.99; }
    307311
    308312        int axis;
    309         if (DecodeAxis(interp, (char*)argv[3], &axis) != TCL_OK) {
     313        if (GetAxis(interp, argv[3], &axis) != TCL_OK) {
    310314            return TCL_ERROR;
    311315        }
     
    337341}
    338342
    339 /*
    340  * ----------------------------------------------------------------------
    341  * FUNCTION: DecodeAxis()
    342  *
    343  * Used internally to decode an axis value from a string ("x", "y",
    344  * or "z") to its index (0, 1, or 2).  Returns TCL_OK if successful,
    345  * along with a value in valPtr.  Otherwise, it returns TCL_ERROR
    346  * and an error message in the interpreter.
    347  * ----------------------------------------------------------------------
    348  */
    349 static int
    350 DecodeAxis(Tcl_Interp *interp, char *str, int *valPtr)
    351 {
    352     if (strcmp(str,"x") == 0) {
    353         *valPtr = 0;
    354         return TCL_OK;
    355     }
    356     else if (strcmp(str,"y") == 0) {
    357         *valPtr = 1;
    358         return TCL_OK;
    359     }
    360     else if (strcmp(str,"z") == 0) {
    361         *valPtr = 2;
    362         return TCL_OK;
    363     }
    364     Tcl_AppendResult(interp, "bad axis \"", str,
    365         "\": should be x, y, or z", (char*)NULL);
    366     return TCL_ERROR;
    367 }
    368 
    369343void resize_offscreen_buffer(int w, int h);
    370344
    371345//change screen size
    372346static int
    373 ScreenResizeCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])
     347ScreenCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])
    374348{
    375349
     
    470444  live_obj_y = y;
    471445  live_obj_z = z;
     446}
     447
     448/*
     449 * ----------------------------------------------------------------------
     450 * CLIENT COMMAND:
     451 *   volume outline state on|off ?<volumeId> ...?
     452 *   volume outline color on|off ?<volumeId> ...?
     453 *   volume data state on|off ?<volumeId> ...?
     454 *
     455 * Clients send these commands to manipulate the volumes.
     456 * ----------------------------------------------------------------------
     457 */
     458static int
     459VolumeCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])
     460{
     461        if (argc < 2) {
     462                Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     463                        " option arg arg...\"", (char*)NULL);
     464                return TCL_ERROR;
     465    }
     466
     467    char c = *argv[1];
     468        if (c == 'o' && strcmp(argv[1],"outline") == 0) {
     469        if (argc < 3) {
     470                    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     471                            argv[1], " option ?arg arg...?\"", (char*)NULL);
     472                    return TCL_ERROR;
     473        }
     474        c = *argv[2];
     475        if (c == 's' && strcmp(argv[2],"state") == 0) {
     476            if (argc < 3) {
     477                Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     478                    argv[1], " state on|off ?volume ...? \"", (char*)NULL);
     479                return TCL_ERROR;
     480            }
     481
     482            int state;
     483            if (Tcl_GetBoolean(interp, argv[3], &state) != TCL_OK) {
     484                return TCL_ERROR;
     485            }
     486
     487            int ivol;
     488            if (argc < 5) {
     489                for (ivol=0; ivol < n_volumes; ivol++) {
     490                    if (state) {
     491                        volume[ivol]->enable_outline();
     492                    } else {
     493                        volume[ivol]->disable_outline();
     494                    }
     495                }
     496            } else {
     497                for (int n=4; n < argc; n++) {
     498                    if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) {
     499                        return TCL_ERROR;
     500                    }
     501                    if (ivol < 0 || ivol > n_volumes) {
     502                        Tcl_AppendResult(interp, "bad volume index \"", argv[n],
     503                            "\": out of range", (char*)NULL);
     504                        return TCL_ERROR;
     505                    }
     506                    if (state) {
     507                        volume[ivol]->enable_outline();
     508                    } else {
     509                        volume[ivol]->disable_outline();
     510                    }
     511                }
     512            }
     513            return TCL_OK;
     514        }
     515        else if (c == 'c' && strcmp(argv[2],"color") == 0) {
     516            if (argc < 3) {
     517                Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     518                    argv[1], " color {R G B} ?volume ...? \"", (char*)NULL);
     519                return TCL_ERROR;
     520            }
     521
     522            float rgb[3];
     523            if (GetColor(interp, argv[3], rgb) != TCL_OK) {
     524                return TCL_ERROR;
     525            }
     526
     527            int ivol;
     528            if (argc < 5) {
     529                for (ivol=0; ivol < n_volumes; ivol++) {
     530                    volume[ivol]->set_outline_color(rgb);
     531                }
     532            } else {
     533                for (int n=4; n < argc; n++) {
     534                    if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) {
     535                        return TCL_ERROR;
     536                    }
     537                    if (ivol < 0 || ivol > n_volumes) {
     538                        Tcl_AppendResult(interp, "bad volume index \"", argv[n],
     539                            "\": out of range", (char*)NULL);
     540                        return TCL_ERROR;
     541                    }
     542                    volume[ivol]->set_outline_color(rgb);
     543                }
     544            }
     545            return TCL_OK;
     546        }
     547
     548        Tcl_AppendResult(interp, "bad option \"", argv[2],
     549            "\": should be color or state", (char*)NULL);
     550        return TCL_ERROR;
     551    }
     552        else if (c == 's' && strcmp(argv[1],"state") == 0) {
     553        if (argc < 3) {
     554                    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     555                            " state on|off ?volume ...?\"", (char*)NULL);
     556                    return TCL_ERROR;
     557        }
     558
     559        int state;
     560            if (Tcl_GetBoolean(interp, argv[2], &state) != TCL_OK) {
     561                    return TCL_ERROR;
     562            }
     563
     564        int ivol;
     565        for (int n=3; n < argc; n++) {
     566                if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) {
     567                        return TCL_ERROR;
     568                }
     569            if (state) {
     570                volume[ivol]->enable_data();
     571            } else {
     572                volume[ivol]->disable_data();
     573            }
     574        }
     575        return TCL_OK;
     576    }
     577
     578    Tcl_AppendResult(interp, "bad option \"", argv[1],
     579        "\": should be state", (char*)NULL);
     580    return TCL_ERROR;
    472581}
    473582
     
    626735}
    627736
    628 
    629 //Switch:
    630 //arg[1] = 0 : 3D rendering
    631 //arg[1] !=0 : 2D rendering
     737/*
     738 * ----------------------------------------------------------------------
     739 * FUNCTION: GetAxis()
     740 *
     741 * Used internally to decode an axis value from a string ("x", "y",
     742 * or "z") to its index (0, 1, or 2).  Returns TCL_OK if successful,
     743 * along with a value in valPtr.  Otherwise, it returns TCL_ERROR
     744 * and an error message in the interpreter.
     745 * ----------------------------------------------------------------------
     746 */
    632747static int
    633 Switch2D3DCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])
     748GetAxis(Tcl_Interp *interp, char *str, int *valPtr)
    634749{
    635   fprintf(stderr, "switch 2D 3D rendering modes cmd\n");
    636 
    637   double mode;
    638 
    639   if (argc != 2) {
    640     Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    641                 " mode\"", (char*)NULL);
     750    if (strcmp(str,"x") == 0) {
     751        *valPtr = 0;
     752        return TCL_OK;
     753    }
     754    else if (strcmp(str,"y") == 0) {
     755        *valPtr = 1;
     756        return TCL_OK;
     757    }
     758    else if (strcmp(str,"z") == 0) {
     759        *valPtr = 2;
     760        return TCL_OK;
     761    }
     762    Tcl_AppendResult(interp, "bad axis \"", str,
     763        "\": should be x, y, or z", (char*)NULL);
    642764    return TCL_ERROR;
    643   }
    644   if (Tcl_GetDouble(interp, argv[1], &mode) != TCL_OK) {
    645         return TCL_ERROR;
    646   }
    647 
    648   if(mode==0)
    649     volume_mode = true;
    650   else
    651     volume_mode = false;
    652 
    653   return TCL_OK;
     765}
     766
     767/*
     768 * ----------------------------------------------------------------------
     769 * FUNCTION: GetColor()
     770 *
     771 * Used internally to decode a color value from a string ("R G B")
     772 * as a list of three numbers 0-1.  Returns TCL_OK if successful,
     773 * along with RGB values in valPtr.  Otherwise, it returns TCL_ERROR
     774 * and an error message in the interpreter.
     775 * ----------------------------------------------------------------------
     776 */
     777static int
     778GetColor(Tcl_Interp *interp, char *str, float *rgbPtr)
     779{
     780    int rgbc;
     781    char **rgbv;
     782    if (Tcl_SplitList(interp, str, &rgbc, &rgbv) != TCL_OK) {
     783        return TCL_ERROR;
     784    }
     785    if (rgbc != 3) {
     786        Tcl_AppendResult(interp, "bad color \"", str,
     787            "\": should be {R G B} as double values 0-1", (char*)NULL);
     788        return TCL_ERROR;
     789    }
     790
     791    double rval, gval, bval;
     792    if (Tcl_GetDouble(interp, rgbv[0], &rval) != TCL_OK) {
     793        Tcl_Free((char*)rgbv);
     794        return TCL_ERROR;
     795    }
     796    if (Tcl_GetDouble(interp, rgbv[1], &gval) != TCL_OK) {
     797        Tcl_Free((char*)rgbv);
     798        return TCL_ERROR;
     799    }
     800    if (Tcl_GetDouble(interp, rgbv[2], &bval) != TCL_OK) {
     801        Tcl_Free((char*)rgbv);
     802        return TCL_ERROR;
     803    }
     804    Tcl_Free((char*)rgbv);
     805
     806    rgbPtr[0] = (float)rval;
     807    rgbPtr[1] = (float)gval;
     808    rgbPtr[2] = (float)bval;
     809
     810    return TCL_OK;
     811}
     812
     813/*
     814 * ----------------------------------------------------------------------
     815 * USAGE: debug("string", ...)
     816 *
     817 * Use this anywhere within the package to send a debug message
     818 * back to the client.  The string can have % fields as used by
     819 * the printf() package.  Any remaining arguments are treated as
     820 * field substitutions on that.
     821 * ----------------------------------------------------------------------
     822 */
     823void
     824debug(char *str)
     825{
     826    write(0, str, strlen(str));
     827}
     828
     829void
     830debug(char *str, double v1)
     831{
     832    char buffer[512];
     833    sprintf(buffer, str, v1);
     834    write(0, buffer, strlen(buffer));
     835}
     836
     837void
     838debug(char *str, double v1, double v2)
     839{
     840    char buffer[512];
     841    sprintf(buffer, str, v1, v2);
     842    write(0, buffer, strlen(buffer));
     843}
     844
     845void
     846debug(char *str, double v1, double v2, double v3)
     847{
     848    char buffer[512];
     849    sprintf(buffer, str, v1, v2, v3);
     850    write(0, buffer, strlen(buffer));
    654851}
    655852
     
    742939  return TCL_OK;
    743940}
    744 
    745941
    746942
     
    12011397  volume[index] = new Volume(0.f, 0.f, 0.f, width, height, depth, 1.,  n_component, data);
    12021398  assert(volume[index]!=0);
     1399
     1400  if (n_volumes <= index) {
     1401    n_volumes = index+1;
     1402  }
    12031403}
    12041404
     
    13011501  if (screen_buffer) {
    13021502      delete[] screen_buffer;
    1303       screen_buffer = 0;
     1503      screen_buffer = NULL;
    13041504  }
    13051505  screen_buffer = new unsigned char[4*win_width*win_height];
    1306   assert(screen_buffer!=0);
     1506  assert(screen_buffer != NULL);
    13071507
    13081508  //delete the current render buffer resources
     
    14751675   if (screen_buffer) {
    14761676       delete[] screen_buffer;
    1477        screen_buffer = 0;
     1677       screen_buffer = NULL;
    14781678   }
    14791679   screen_buffer = new unsigned char[4*win_width*win_height];
    1480    assert(screen_buffer!=0);
     1680   assert(screen_buffer != NULL);
    14811681
    14821682   //create the camera with default setting
     
    15631763
    15641764void initTcl(){
    1565   interp = Tcl_CreateInterp();
    1566   Tcl_MakeSafe(interp);
    1567 
    1568   //set camera (viewing)
    1569   Tcl_CreateCommand(interp, "camera", CameraCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL);
    1570 
    1571   Tcl_CreateCommand(interp, "cutplane", CutplaneCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL);
    1572 
    1573   //resize the width and height of render screen
    1574   Tcl_CreateCommand(interp, "screen", ScreenResizeCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL);
     1765    interp = Tcl_CreateInterp();
     1766    Tcl_MakeSafe(interp);
     1767
     1768    // manipulate the viewpoint
     1769    Tcl_CreateCommand(interp, "camera", CameraCmd,
     1770        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     1771
     1772    // turn on/off cut planes in x/y/z directions
     1773    Tcl_CreateCommand(interp, "cutplane", CutplaneCmd,
     1774        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     1775
     1776    // change the size of the screen (size of picture generated)
     1777    Tcl_CreateCommand(interp, "screen", ScreenCmd,
     1778        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     1779
     1780    // manipulate volume data
     1781    Tcl_CreateCommand(interp, "volume", VolumeCmd,
     1782        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    15751783
    15761784  //create new transfer function
     
    15781786  //update an existing transfer function
    15791787  Tcl_CreateCommand(interp, "tf_update", TransferFunctionUpdateCmd, (ClientData)0, (Tcl_CmdDeleteProc*)NULL);
     1788
    15801789
    15811790  //create new volume
     
    16061815  glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);
    16071816  assert(glGetError()==0);
    1608  
    1609   /*
    1610   //debug: check from the back of screen_buffer to see how far ReadPixel went
    1611   fprintf(stderr, "%d %d:", win_width, win_height);
    1612   for(int i=5*win_width*win_height-1; i>=0; i--){
    1613     if(screen_buffer[i] != 253){
    1614       fprintf(stderr, "%d\n", i);
    1615       i=0;
    1616     }
    1617   }
    1618   */
    1619  
    1620   /*
    1621   for(int i=0; i<win_width*win_height; i++){
    1622     if(screen_buffer[3*i]!=0 || screen_buffer[3*i+1]!=0 || screen_buffer[3*i+2]!=0)
    1623       fprintf(stderr, "(%d %d %d) ", screen_buffer[3*i], screen_buffer[3*i+1],  screen_buffer[3*i+2]);
    1624   }
    1625   */
    16261817}
    16271818
     
    16861877    data = tmp;
    16871878
    1688     if(Tcl_Eval(interp, (char*)data.c_str()) != TCL_OK) {
    1689       //error to log file...
    1690       printf("Tcl error: %s\n", Tcl_GetStringResult(interp));
     1879    if (Tcl_Eval(interp, (char*)data.c_str()) != TCL_OK) {
     1880      std::ostringstream errmsg;
     1881      errmsg << "ERROR: " << Tcl_GetStringResult(interp) << std::endl;
     1882      write(0, errmsg.str().c_str(), errmsg.str().size());
    16911883      return;
    16921884    }
Note: See TracChangeset for help on using the changeset viewer.