Changeset 3568


Ignore:
Timestamp:
Mar 25, 2013, 2:39:16 AM (7 years ago)
Author:
ldelgass
Message:

Fix crash on getting transfer function name, remove unused plane command.

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

Legend:

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

    r3567 r3568  
    5656#include "CmdProc.h"
    5757#include "Trace.h"
    58 #ifdef PLANE_CMD
    59 #include "PlaneRenderer.h"
    60 #endif
    6158#ifdef USE_POINTSET_RENDERER
    6259#include "PointSet.h"
     
    118115static Tcl_ObjCmdProc GridCmd;
    119116static Tcl_ObjCmdProc LegendCmd;
    120 #ifdef PLANE_CMD
    121 static Tcl_ObjCmdProc PlaneCmd;
    122 #endif
    123117static Tcl_ObjCmdProc ScreenCmd;
    124118static Tcl_ObjCmdProc SnapshotCmd;
     
    16181612    }
    16191613    std::vector<Volume *>::iterator iter;
    1620     for (iter = ivol.begin(); iter != ivol.end(); iter++) {
     1614    for (iter = ivol.begin(); iter != ivol.end(); ++iter) {
    16211615        TRACE("setting %s with transfer function %s", (*iter)->name(),
    16221616               tf->name());
     
    21522146    return TCL_OK;
    21532147}
    2154 
    2155 #ifdef PLANE_CMD
    2156 static int
    2157 PlaneAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    2158            Tcl_Obj *const *objv)
    2159 {
    2160     TRACE("load plane for 2D visualization command");
    2161 
    2162     int index, w, h;
    2163     if (objc != 4) {
    2164         Tcl_AppendResult(interp, "wrong # args: should be \"",
    2165             Tcl_GetString(objv[0]), " plane_index w h \"", (char*)NULL);
    2166         return TCL_ERROR;
    2167     }
    2168     if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) {
    2169         return TCL_ERROR;
    2170     }
    2171     if (index >= NanoVis::numPlanes) {
    2172         Tcl_AppendResult(interp, "Invalid plane_index", (char*)NULL);
    2173         return TCL_ERROR;
    2174     }
    2175     if (Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK) {
    2176         return TCL_ERROR;
    2177     }
    2178     if (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK) {
    2179         return TCL_ERROR;
    2180     }
    2181 
    2182     //Now read w*h*4 bytes. The server expects the plane to be a stream of
    2183     //floats
    2184     char *tmp = new char[int(w*h*sizeof(float))];
    2185     if (tmp == NULL) {
    2186         Tcl_AppendResult(interp, "can't allocate stream data", (char *)NULL);
    2187         return TCL_ERROR;
    2188     }
    2189     bzero(tmp, w*h*4);
    2190     int status = read(fileno(NanoVis::stdin), tmp, w*h*sizeof(float));
    2191     if (status <= 0) {
    2192         delete[] tmp;
    2193         Tcl_AppendResult(interp, "Failed to read image data for plane", (char*)NULL);
    2194         return TCL_ERROR;
    2195     }
    2196     NanoVis::plane[index] = new Texture2D(w, h, GL_FLOAT, GL_LINEAR, 1, (float*)tmp);
    2197     delete[] tmp;
    2198     return TCL_OK;
    2199 }
    2200 
    2201 static int
    2202 PlaneLinkOp(ClientData clientData, Tcl_Interp *interp, int objc,
    2203             Tcl_Obj *const *objv)
    2204 {
    2205     TRACE("link the plane to the 2D renderer command");
    2206 
    2207     int plane_index;
    2208 
    2209     if (objc != 3) {
    2210         Tcl_AppendResult(interp, "wrong # args: should be \"",
    2211             Tcl_GetString(objv[0]), " plane_index transfunc_name \"", (char*)NULL);
    2212         return TCL_ERROR;
    2213     }
    2214     if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) {
    2215         return TCL_ERROR;
    2216     }
    2217     if (plane_index >= NanoVis::numPlanes) {
    2218         Tcl_AppendResult(interp, "Invalid plane_index", (char*)NULL);
    2219         return TCL_ERROR;
    2220     }
    2221     NanoVis::planeRenderer->addPlane(NanoVis::plane[plane_index],
    2222                                      NanoVis::getTransfunc(Tcl_GetString(objv[2])));
    2223     return TCL_OK;
    2224 }
    2225 
    2226 //Enable a 2D plane for render
    2227 //The plane_index is the index mantained in the 2D plane renderer
    2228 static int
    2229 PlaneEnableOp(ClientData clientData, Tcl_Interp *interp, int objc,
    2230               Tcl_Obj *const *objv)
    2231 {
    2232     TRACE("enable a plane so the 2D renderer can render it command");
    2233 
    2234     if (objc != 3) {
    2235         Tcl_AppendResult(interp, "wrong # args: should be \"",
    2236             Tcl_GetString(objv[0]), " plane_index mode \"", (char*)NULL);
    2237         return TCL_ERROR;
    2238     }
    2239     int plane_index;
    2240     if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) {
    2241         return TCL_ERROR;
    2242     }
    2243     if (plane_index >= NanoVis::numPlanes) {
    2244         Tcl_AppendResult(interp, "Invalid plane_index", (char*)NULL);
    2245         return TCL_ERROR;
    2246     } else if (plane_index < 0) {
    2247         plane_index = -1;
    2248     }
    2249 
    2250     NanoVis::planeRenderer->setActivePlane(plane_index);
    2251     return TCL_OK;
    2252 }
    2253 
    2254 static Rappture::CmdSpec planeOps[] = {
    2255     {"active",     2, PlaneEnableOp,    3, 3, "planeIdx",},
    2256     {"add",        2, PlaneAddOp,       5, 5, "planeIdx width height",},
    2257     {"link",       1, PlaneLinkOp,      4, 4, "planeIdx transfunc_name",},
    2258 };
    2259 static int nPlaneOps = NumCmdSpecs(planeOps);
    2260 
    2261 static int
    2262 PlaneCmd(ClientData clientData, Tcl_Interp *interp, int objc,
    2263          Tcl_Obj *const *objv)
    2264 {
    2265     Tcl_ObjCmdProc *proc;
    2266 
    2267     proc = Rappture::GetOpFromObj(interp, nPlaneOps, planeOps,
    2268                                   Rappture::CMDSPEC_ARG1, objc, objv, 0);
    2269     if (proc == NULL) {
    2270         return TCL_ERROR;
    2271     }
    2272     return (*proc) (clientData, interp, objc, objv);
    2273 }
    2274 
    2275 #endif /*PLANE_CMD*/
    22762148
    22772149/*
     
    23412213    Tcl_CreateObjCommand(interp, "heightmap",   HeightMapCmd,   NULL, NULL);
    23422214    Tcl_CreateObjCommand(interp, "legend",      LegendCmd,      NULL, NULL);
    2343 #ifdef PLANE_CMD
    2344     Tcl_CreateObjCommand(interp, "plane",       PlaneCmd,       NULL, NULL);
    2345 #endif
    23462215    Tcl_CreateObjCommand(interp, "screen",      ScreenCmd,      NULL, NULL);
    23472216    Tcl_CreateObjCommand(interp, "snapshot",    SnapshotCmd,    NULL, NULL);
  • trunk/packages/vizservers/nanovis/FlowBox.h

    r3567 r3568  
    4040    }
    4141
    42     bool visible()
     42    bool visible() const
    4343    {
    4444        return !_sv.isHidden;
  • trunk/packages/vizservers/nanovis/FlowParticles.h

    r3567 r3568  
    4242    }
    4343
    44     bool visible()
     44    bool visible() const
    4545    {
    4646        return !_sv.isHidden;
  • trunk/packages/vizservers/nanovis/TransferFunction.cpp

    r3502 r3568  
    2424using namespace vrmath;
    2525
    26 TransferFunction::TransferFunction(int size, float *data)
     26TransferFunction::TransferFunction(const char *name, int size, float *data) :
     27    _name(name)
    2728{
    2829    // _size : # of slot, 4 : rgba
  • trunk/packages/vizservers/nanovis/TransferFunction.h

    r3502 r3568  
    1717#define TRANSFER_FUNCTION_H
    1818
     19#include <string>
     20
    1921#include <vrmath/Vector3f.h>
    2022
     
    2426{
    2527public:
    26     TransferFunction(int size, float *data);
     28    TransferFunction(const char *name, int size, float *data);
    2729
    2830    void update(float *data);
     
    5759    const char *name() const
    5860    {
    59         return _name;
    60     }
    61 
    62     void name(const char *name)
    63     {
    64         _name = name;
     61        return _name.c_str();
    6562    }
    6663
     
    7774    float *_data;
    7875    Texture1D *_tex;    ///< the texture storing the colors
    79     const char *_name;
     76    std::string _name;
    8077    GLuint _id;         ///< OpenGL texture identifier
    8178};
  • trunk/packages/vizservers/nanovis/config.h

    r3522 r3568  
    5858//#define FILTER_GRADIENTS
    5959
    60 /*
    61  * Controls whether the plane* commands are registered in the
    62  * interpreter. [Are these commands still required?]
    63  */
    64 //#define PLANE_CMD
    65 
    6660#endif
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r3567 r3568  
    152152NvLIC *NanoVis::licRenderer = NULL;
    153153PlaneRenderer *NanoVis::planeRenderer = NULL;
    154 #ifdef PLANE_CMD
    155 // pointers to 2D planes, currently handle up 10
    156 int NanoVis::numPlanes = 10;
    157 Texture2D *NanoVis::plane[10];
    158 #endif
    159154#ifdef USE_POINTSET_RENDERER
    160155PointSetRenderer *NanoVis::pointSetRenderer = NULL;
     
    206201        delete colorTableRenderer;
    207202    }
    208 #ifdef PLANE_CMD
    209     for (int i = 0; i < numPlanes; i++) {
    210         TRACE("Deleting plane[%d]", i);
    211         delete plane[i];
    212     }
    213 #endif
    214203    if (legendTexture != NULL) {
    215204        TRACE("Deleting legendTexture");
     
    620609    TransferFunctionHashmap::iterator itr = tfTable.find(id);
    621610    if (itr == tfTable.end()) {
    622         ERROR("No transfer function named \"%s\" found", id.c_str());
     611        TRACE("No transfer function named \"%s\" found", id.c_str());
    623612        return NULL;
    624613    } else {
     
    635624    if (tf == NULL) {
    636625        TRACE("Creating new transfer function \"%s\"", id.c_str());
    637         tf = new TransferFunction(n, data);
     626        tf = new TransferFunction(id.c_str(), n, data);
    638627        tfTable[id] = tf;
    639628    } else {
  • trunk/packages/vizservers/nanovis/nanovis.h

    r3567 r3568  
    198198    static NvLIC *licRenderer;
    199199    static PlaneRenderer *planeRenderer;
    200 #if PLANE_CMD
    201     static int numPlanes;
    202     static Texture2D *plane[]; ///< Pointers to 2D planes
    203 #endif
     200
    204201#ifdef USE_POINTSET_RENDERER
    205202    static PointSetRenderer *pointSetRenderer;
  • trunk/packages/vizservers/nanovis/protocol-nanovis.txt

    r3567 r3568  
    173173   Set orientation of volumes
    174174
    175 
    176 --- Colormaped Plane (if PLANE_CMD is defined in config.h) ---
    177 plane active <planeIdx>
    178       Set the active plane [0,9], or -1 to disable
    179       Plane must first be added and linked
    180 plane add <planeIdx> <width> <height>
    181       followed by image data: w * h floats on stdin
    182       planeIdx: [0,9]
    183 plane link <planeIdx> <transfunc name>
    184       Enable a plane for rendering using the given transfer
    185       function.  Plane must first be added.
    186 --- End Colormaped Plane (if PLANE_CMD is defined in config.h) ---
    187 
    188175================================================================================
    189176Replies:
Note: See TracChangeset for help on using the changeset viewer.