Ignore:
Timestamp:
Apr 16, 2012 12:14:03 PM (12 years ago)
Author:
ldelgass
Message:

Remove vrutil library. Was only used for FilePath? that already exists in
R2 library (may need some fixing for windows portability though). Make
R2FilePath::getPath return a std::string so users can allocate a std::string
on the stack and not worry about deleting the string buffer returned. Also,
use std::string in R2Fonts to avoid leaking font names. Remove R2string as
it is now replaced by std::strings.

Location:
trunk/packages/vizservers
Files:
3 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/configure

    r2886 r2972  
    1626716267
    1626816268
    16269 ac_config_files="$ac_config_files Makefile nanoscale/Makefile nanoscale/renderservers.tcl nanovis/Makefile nanovis/newmat11/Makefile nanovis/R2/src/Makefile nanovis/vrutil/Makefile nanovis/vrmath/Makefile nanovis/imgLoaders/Makefile nanovis/transfer-function/Makefile pymolproxy/Makefile vtkvis/Doxyfile vtkvis/Makefile start_viz.sh start_nanoscale.sh"
     16269ac_config_files="$ac_config_files Makefile nanoscale/Makefile nanoscale/renderservers.tcl nanovis/Makefile nanovis/newmat11/Makefile nanovis/R2/src/Makefile nanovis/vrmath/Makefile nanovis/imgLoaders/Makefile nanovis/transfer-function/Makefile pymolproxy/Makefile vtkvis/Doxyfile vtkvis/Makefile start_viz.sh start_nanoscale.sh"
    1627016270
    1627116271cat >confcache <<\_ACEOF
     
    1687316873    "nanovis/newmat11/Makefile") CONFIG_FILES="$CONFIG_FILES nanovis/newmat11/Makefile" ;;
    1687416874    "nanovis/R2/src/Makefile") CONFIG_FILES="$CONFIG_FILES nanovis/R2/src/Makefile" ;;
    16875     "nanovis/vrutil/Makefile") CONFIG_FILES="$CONFIG_FILES nanovis/vrutil/Makefile" ;;
    1687616875    "nanovis/vrmath/Makefile") CONFIG_FILES="$CONFIG_FILES nanovis/vrmath/Makefile" ;;
    1687716876    "nanovis/imgLoaders/Makefile") CONFIG_FILES="$CONFIG_FILES nanovis/imgLoaders/Makefile" ;;
  • trunk/packages/vizservers/configure.in

    r2886 r2972  
    399399   nanovis/newmat11/Makefile \
    400400   nanovis/R2/src/Makefile \
    401    nanovis/vrutil/Makefile \
    402401   nanovis/vrmath/Makefile \
    403402   nanovis/imgLoaders/Makefile \
  • trunk/packages/vizservers/nanovis/Axis.h

    r2953 r2972  
    44
    55#include <stdlib.h>
     6#include <string.h>
    67
    78#include <cmath>
  • trunk/packages/vizservers/nanovis/Makefile.in

    r2967 r2972  
    4444VRMATH_LIB      = $(VRMATH_DIR)/vrmath.a
    4545VRMATH_LIB_SPEC = $(VRMATH_LIB)
    46 VRUTIL_DIR      = ./vrutil
    47 VRUTIL_INC_SPEC = -I$(srcdir)/$(VRUTIL_DIR)/include
    48 VRUTIL_LIB      = $(VRUTIL_DIR)/vrutil.a
    49 VRUTIL_LIB_SPEC = $(VRUTIL_LIB)
    5046R2_DIR          = ./R2
    5147R2_INC_SPEC     = -I$(srcdir)/$(R2_DIR)/include
     
    6965                $(MAT_LIB_SPEC) \
    7066                $(VRMATH_LIB_SPEC) \
    71                 $(VRUTIL_LIB_SPEC) \
    7267                $(TCL_LIB_SPEC) \
    7368                $(CG_LIB_SPEC) \
     
    8479                $(MAT_INC_SPEC) \
    8580                $(VRMATH_INC_SPEC) \
    86                 $(VRUTIL_INC_SPEC) \
    8781                $(TCL_INC_SPEC) \
    8882                $(FF_INC_SPEC) \
     
    202196endif
    203197
    204 .PHONY: all install install-resources install-shaders install-nanovis clean distclean newmat11 R2 imgloaders vrmath vrutil transfer-function
    205 
    206 all: newmat11 R2 imgloaders vrmath vrutil nanovis
     198.PHONY: all install install-resources install-shaders install-nanovis clean distclean newmat11 R2 imgloaders vrmath transfer-function
     199
     200all: newmat11 R2 imgloaders vrmath nanovis
    207201
    208202install: install-nanovis install-resources install-shaders
     
    211205R2:                     $(R2_LIB)
    212206vrmath:                 $(VRMATH_LIB)
    213 vrutil:                 $(VRUTIL_LIB)
    214207imgloaders:             $(IMG_LIB)
    215208
     
    220213        $(MAKE) -C $(VRMATH_DIR) all
    221214
    222 $(VRUTIL_LIB):
    223         $(MAKE) -C $(VRUTIL_DIR) all
    224 
    225215$(R2_LIB):
    226216        $(MAKE) -C $(R2_DIR)/src all
     
    229219        $(MAKE) -C $(IMG_DIR) all
    230220
    231 nanovis: $(MAT_LIB) $(R2_LIB) $(IMG_LIB) $(VRMATH_LIB) $(VRUTIL_LIB) $(OBJS)
     221nanovis: $(MAT_LIB) $(R2_LIB) $(IMG_LIB) $(VRMATH_LIB) $(OBJS)
    232222        $(CXX) $(CXX_SWITCHES) -o $@ $^ $(LIBS)
    233223
     
    268258        $(MAKE) -C $(MAT_DIR) clean
    269259        $(MAKE) -C $(VRMATH_DIR) clean
    270         $(MAKE) -C $(VRUTIL_DIR) clean
    271260        $(MAKE) -C $(R2_DIR)/src clean
    272261        $(MAKE) -C $(IMG_DIR) clean
     
    276265        $(MAKE) -C $(MAT_DIR) distclean
    277266        $(MAKE) -C $(VRMATH_DIR) distclean
    278         $(MAKE) -C $(VRUTIL_DIR) distclean
    279267        $(MAKE) -C $(R2_DIR)/src distclean
    280268        $(MAKE) -C $(IMG_DIR) distclean
  • trunk/packages/vizservers/nanovis/NvShader.cpp

    r2971 r2972  
    5252                              CGprofile profile, const char *entryPoint)
    5353{
    54     const char *path = R2FilePath::getInstance()->getPath(fileName);
    55     if (path == NULL) {
     54    std::string path = R2FilePath::getInstance()->getPath(fileName);
     55    if (path.empty()) {
    5656        ERROR("can't find program \"%s\"\n", fileName);
    5757    }
    58     TRACE("cg program compiling: %s\n", path);
     58    TRACE("cg program compiling: %s\n", path.c_str());
    5959    CGprogram program;
    60     program = cgCreateProgramFromFile(context, CG_SOURCE, path, profile,
     60    program = cgCreateProgramFromFile(context, CG_SOURCE, path.c_str(), profile,
    6161                                      entryPoint, NULL);
    6262    cgGLLoadProgram(program);
     
    6565        ERROR("Error message: %s\n", cgGetLastListing(context));
    6666    }
    67     TRACE("successfully compiled program: %s\n", path);
    68     delete [] path;
     67    TRACE("successfully compiled program: %s\n", path.c_str());
    6968    return program;
    7069}
  • trunk/packages/vizservers/nanovis/ParticleSystem.cpp

    r2964 r2972  
    1111#include <Cg/cgGL.h>
    1212
    13 #include <vrutil/vrFilePath.h>
     13#include <R2/R2FilePath.h>
     14
    1415#include <Image.h>
    1516#include <ImageLoader.h>
     
    8384            if (tail != -1) {
    8485                sprintf(buff, fileNameFormat, curIndex);
    85                 //std::string path = vrFilePath::getInstance()->getPath(buff);
     86                //std::string path = R2FilePath::getInstance()->getPath(buff);
    8687#ifdef WANT_TRACE
    8788                float t = clock() /(float) CLOCKS_PER_SEC;
     
    284285    }
    285286
    286     std::string path = vrFilePath::getInstance()->getPath("arrows.bmp");
     287    std::string path = R2FilePath::getInstance()->getPath("arrows.bmp");
    287288
    288289    if (!path.empty()) {
     
    418419    _context = NvShader::getCgContext();
    419420
    420     std::string path = vrFilePath::getInstance()->getPath("distance.cg");
     421    std::string path = R2FilePath::getInstance()->getPath("distance.cg");
    421422    _distanceInitFP = 
    422423        cgCreateProgramFromFile(_context, CG_SOURCE, path.c_str(),
     
    435436    cgGLLoadProgram(_distanceSortLookupFP);
    436437
    437     path = vrFilePath::getInstance()->getPath("mergesort.cg");
     438    path = R2FilePath::getInstance()->getPath("mergesort.cg");
    438439    _sortRecursionFP =
    439440        cgCreateProgramFromFile(_context, CG_SOURCE, path.c_str(),
     
    453454    _seStepParam = cgGetNamedParameter(_sortEndFP, "step");
    454455
    455     path = vrFilePath::getInstance()->getPath("passthrough.cg");
     456    path = R2FilePath::getInstance()->getPath("passthrough.cg");
    456457    _passthroughFP =
    457458        cgCreateProgramFromFile(_context, CG_SOURCE, path.c_str(),
     
    462463    _biasParam = cgGetNamedParameter(_passthroughFP, "bias");
    463464
    464     path = vrFilePath::getInstance()->getPath("moveparticles.cg");
     465    path = R2FilePath::getInstance()->getPath("moveparticles.cg");
    465466    _moveParticlesFP =
    466467        cgCreateProgramFromFile(_context, CG_SOURCE, path.c_str(),
     
    474475    _mpScale= cgGetNamedParameter(_moveParticlesFP, "scale");
    475476
    476     path = vrFilePath::getInstance()->getPath("particlevp.cg");
     477    path = R2FilePath::getInstance()->getPath("particlevp.cg");
    477478    _particleVP =
    478479        cgCreateProgramFromFile(_context, CG_SOURCE, path.c_str(),
     
    484485    _mvCurrentTimeParam =  cgGetNamedParameter(_particleVP, "currentTime");
    485486
    486     path = vrFilePath::getInstance()->getPath("particlefp.cg");
     487    path = R2FilePath::getInstance()->getPath("particlefp.cg");
    487488    _particleFP =
    488489        cgCreateProgramFromFile(_context, CG_SOURCE, path.c_str(),
     
    491492    _vectorParticleParam = cgGetNamedParameter(_particleVP, "vfield");
    492493
    493     path = vrFilePath::getInstance()->getPath("moveparticles.cg");
     494    path = R2FilePath::getInstance()->getPath("moveparticles.cg");
    494495    _initParticlePosFP =
    495496        cgCreateProgramFromFile(_context, CG_SOURCE, path.c_str(),
     
    16031604            if (_drawBBoxEnabled) drawUnitBox();
    16041605            glColor3f(1, 1, 1);
     1606
    16051607            glDepthMask(GL_FALSE);
    16061608            glEnable(GL_BLEND);
     
    16091611            glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    16101612#else
    1611             glEnable(GL_ALPHA_TEST);
    1612             //glAlphaFunc(GL_GEQUAL, 0.5);
    16131613            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    16141614#endif
     1615            glEnable(GL_ALPHA_TEST);
     1616            glAlphaFunc(GL_GREATER, 0.6);
     1617
    16151618            glEnable(GL_POINT_SPRITE_ARB);
    16161619            glPointSize(_pointSize);
     
    16191622
    16201623#ifndef TEST
    1621             _arrows->activate(); //_arrows->bind(0);
     1624            _arrows->activate();
    16221625            glEnable(GL_TEXTURE_2D);
    1623             //glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );
    1624             glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 0.0f );
    1625 
    1626             glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 1.0f);
    1627             glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, 100.0f);
    1628             glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
     1626            glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 0.0f);
     1627
     1628            glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 1.0f);
     1629            glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, 100.0f);
     1630            glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
    16291631
    16301632            cgGLBindProgram(_particleVP);
  • trunk/packages/vizservers/nanovis/ParticleSystemFactory.cpp

    r2822 r2972  
    55#include <expat.h>
    66
    7 #include <vrutil/vrFilePath.h>
     7#include <R2/R2FilePath.h>
    88
    99#include "ParticleSystemFactory.h"
     
    144144        char buff[256];
    145145        sprintf(buff, fileName.c_str(), startIndex);
    146         std::string path = vrFilePath::getInstance()->getPath(buff);
     146        std::string path = R2FilePath::getInstance()->getPath(buff);
    147147        if (path.size()) {
    148148            std::string dir;
     
    169169        }
    170170    } else {
    171         std::string path = vrFilePath::getInstance()->getPath(fileName.c_str());
     171        std::string path = R2FilePath::getInstance()->getPath(fileName.c_str());
    172172        _newParticleSystem =
    173173            new ParticleSystem(width, height, path.c_str(),
  • trunk/packages/vizservers/nanovis/PointSetRenderer.cpp

    r2953 r2972  
    1717{
    1818    _shader = new PointShader();
    19     const char *path = R2FilePath::getInstance()->getPath("particle2.bmp");
    20     if (path == NULL) {
    21         ERROR("pointset file not found - %s\n", path);
     19    std::string path = R2FilePath::getInstance()->getPath("particle2.bmp");
     20    if (path.empty()) {
     21        ERROR("Particle image not found\n");
    2222        return;
    2323    }
    2424
    2525    ImageLoader *loader = ImageLoaderFactory::getInstance()->createLoader("bmp");
    26     Image *image = loader->load(path, Image::IMG_RGBA);
    27     delete [] path;
     26    Image *image = loader->load(path.c_str(), Image::IMG_RGBA);
    2827    unsigned char *bytes = (unsigned char *)image->getImageBuffer();
    2928    if (bytes) {
     
    4039                                      4, image->getImageBuffer());
    4140    } else {
    42         ERROR("fail to load image [%s]\n", "particle2.bmp");
     41        ERROR("Failed to load particle image\n");
    4342    }
    4443
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h

    r2877 r2972  
    44
    55#include <list>
    6 
    7 #include <R2/R2string.h>
     6#include <string>
    87
    98class R2FilePath
     
    1716     * @return return full path of the file, but if not found, return ""
    1817     */
    19     const char *getPath(const char *fileName);
     18    std::string getPath(const char *fileName);
    2019
    2120    /**
     
    3130
    3231private:
    33     typedef std::list<R2string> R2stringList;
    34     typedef std::list<R2string>::iterator R2stringListIter;
     32    typedef std::list<std::string> StringList;
     33    typedef std::list<std::string>::iterator StringListIter;
    3534
    3635    /// application directory
    37     static R2string _curDirectory;
     36    static std::string _curDirectory;
    3837
    3938    /// R2FilePath instance
     
    4140
    4241    /// all default file paths
    43     R2stringList _pathList;
     42    StringList _pathList;
    4443};
    4544
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2Fonts.h

    r2841 r2972  
    44
    55#include <vector>
     6#include <string>
    67
    78#include <R2/R2.h>
    89#include <R2/R2Object.h>
    9 #include <R2/R2string.h>
    1010
    1111class R2Fonts : public R2Object
    1212{
    1313    struct R2FontAttributes {
    14         char *_fontName;
     14        std::string _fontName;
    1515        int _textureWidth;
    1616        int _textureHeight;
     
    2929        R2CharInfo _chars[256];
    3030    };
    31    
     31
    3232    typedef std::vector<R2FontAttributes>  R2FontVector;
    3333
  • trunk/packages/vizservers/nanovis/R2/src/Makefile.in

    r2896 r2972  
    4444                R2IndexBuffer.o \
    4545                R2Object.o \
    46                 R2VertexBuffer.o \
    47                 R2string.o
     46                R2VertexBuffer.o
    4847
    4948R2LIB           = R2.a
  • trunk/packages/vizservers/nanovis/R2/src/R2FilePath.cpp

    r2857 r2972  
    1313#include "Trace.h"
    1414
    15 R2string R2FilePath::_curDirectory;
     15std::string R2FilePath::_curDirectory;
    1616R2FilePath R2FilePath::_instance;
    1717
    18 char seps[] = ":";
     18static char seps[] = ":";
    1919
    2020R2FilePath::R2FilePath()
     
    2222    char buff[BUFSIZ+2];
    2323#ifdef _WIN32
    24     _getcwd(buff, 255);
     24    _getcwd(buff, sizeof(buff)-1);
    2525#else
    26     if (getcwd(buff, BUFSIZ) == NULL) {
     26    if (getcwd(buff, sizeof(buff)-1) == NULL) {
    2727        ERROR("can't get current working directory\n");
    2828    }
     
    3737R2FilePath::setPath(const char *filePath)
    3838{
    39     char buff[255];
     39    char buff[256];
    4040
    4141    if (filePath == NULL) {
     
    5555        if (*p == '/') {
    5656            if (*last == '/' || *last == '\\') {
    57                 _pathList.push_back(R2string(p));
     57                _pathList.push_back(std::string(p));
    5858            } else {
    59                 _pathList.push_back(R2string(p) + "/");
     59                _pathList.push_back(std::string(p) + "/");
    6060            }
    6161        } else {
    6262            if (*last == '/' || *last == '\\') {
    63                 _pathList.push_back(_curDirectory + R2string(p));
     63                _pathList.push_back(_curDirectory + std::string(p));
    6464            } else {
    65                 _pathList.push_back(_curDirectory + R2string(p) + "/");
     65                _pathList.push_back(_curDirectory + std::string(p) + "/");
    6666            }
    6767        }
     
    7676}
    7777
    78 const char *
     78std::string
    7979R2FilePath::getPath(const char* fileName)
    8080{
    81     R2string path;
     81    std::string path;
    8282
    83     R2stringListIter iter;
    84     int nameLength = strlen(fileName);
    85     for (iter = _pathList.begin(); iter != _pathList.end(); ++iter) {
    86         char *path;
     83    for (StringListIter iter = _pathList.begin();
     84         iter != _pathList.end(); ++iter) {
     85        path = *iter + std::string(fileName);
    8786
    88         path = new char[strlen((char *)(*iter)) + 1 + nameLength + 1];
    89         //sprintf(path, "%s/%s", (char *)(*iter), fileName);
    90         sprintf(path, "%s%s", (char *)(*iter), fileName);
    91         if (access(path, R_OK) == 0) {
     87        if (access(path.c_str(), R_OK) == 0) {
    9288            return path;
     89        } else {
     90            path = "";
    9391        }
    94         delete [] path;
    9592    }
    96     return NULL;
     93    return path;
    9794}
    9895
    9996void
    100 R2FilePath::setWorkingDirectory(int argc, const char** argv)
     97R2FilePath::setWorkingDirectory(int argc, const char **argv)
    10198{
    102     char buff[255];
     99    char buff[256];
    103100
    104101    strcpy(buff, argv[0]);
    105102    for (int i = strlen(buff) - 1; i >= 0; --i) {
    106103        if (buff[i] == '\\' || buff[i] == '/') {
    107             buff[i] = '/'; 
    108             buff[i + 1] = '\0'; 
     104            buff[i] = '/';
     105            buff[i + 1] = '\0';
    109106            break;
    110107        }
  • trunk/packages/vizservers/nanovis/R2/src/R2Fonts.cpp

    r2953 r2972  
    3434        unsigned int i;
    3535        for (i = 0; i < _fonts.size(); ++i) {
    36             if (strcmp(_fonts[i]._fontName, fontName) == 0) {
     36            if (strcmp(_fonts[i]._fontName.c_str(), fontName) == 0) {
    3737                _fontIndex = i;
    3838                break;
     
    142142    bool bSuccess = false;
    143143
    144     const char *path = R2FilePath::getInstance()->getPath(fontFileName);
    145     if (path == NULL) {
     144    std::string path = R2FilePath::getInstance()->getPath(fontFileName);
     145    if (path.empty()) {
    146146        return false;
    147147    }
    148     std::ifstream fsInput(path, std::ios::binary);
     148    std::ifstream fsInput(path.c_str(), std::ios::binary);
    149149    if (fsInput) {
    150         sFont._fontName = new char [strlen(fontName)+1];
    151         strcpy(sFont._fontName, fontName);
     150        sFont._fontName = fontName;
    152151
    153152        // make sure this file is the correct type by checking the header
     
    230229        fsInput.close();
    231230    }
    232     delete [] path;
    233231    return bSuccess;
    234232}
  • trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp

    r2964 r2972  
    6262    createRenderTarget();
    6363
    64     const char *path = R2FilePath::getInstance()->getPath("arrows.bmp");
    65     if (path != NULL) {
     64    std::string path = R2FilePath::getInstance()->getPath("arrows.bmp");
     65    if (!path.empty()) {
    6666        ImageLoader *loader = ImageLoaderFactory::getInstance()->createLoader("bmp");
    6767        if (loader != NULL) {
    68             Image *image = loader->load(path, Image::IMG_RGBA);
    69             delete [] path;
     68            Image *image = loader->load(path.c_str(), Image::IMG_RGBA);
    7069            if (image != NULL) {
    7170                unsigned char *bytes = (unsigned char *)image->getImageBuffer();
     
    7978                delete image;
    8079            } else {
    81                 ERROR("Failed to load image: arrows.bmp\n");
     80                ERROR("Failed to load arrows image\n");
    8281            }
    8382            delete loader;
    8483        } else {
    85             delete [] path;
    86             ERROR("Couldn't find loader for arrows.bmp\n");
     84            ERROR("Couldn't find loader for arrows image\n");
    8785        }
    8886    } else {
    89         ERROR("Couldn't find path to arrows.bmp\n");
     87        ERROR("Couldn't find arrows image\n");
    9088    }
    9189
  • trunk/packages/vizservers/nanovis/VolumeRenderer.cpp

    r2932 r2972  
    1919#include <sys/time.h>
    2020
     21#include <vector>
     22
    2123#include <GL/glew.h>
    2224#include <GL/glut.h>
     
    2426#include <tcl.h>
    2527
    26 #include <vector>
    27 
    28 #include <R2/R2string.h>
    2928#include <R2/R2FilePath.h>
    3029
     
    4544    initShaders();
    4645
    47     const char *path = R2FilePath::getInstance()->getPath("Font.bmp");
    48     if (path == NULL) {
     46    std::string path = R2FilePath::getInstance()->getPath("Font.bmp");
     47    if (path.empty()) {
    4948        ERROR("can't find Font.bmp\n");
    50         assert(path != NULL);
    51     }
    52     initFont(path);
    53     delete [] path;
     49        assert(!path.empty());
     50    }
     51    initFont(path.c_str());
    5452    _volumeInterpolator = new VolumeInterpolator();
    5553}
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r2962 r2972  
    4747#include <R2/R2FilePath.h>
    4848#include <R2/R2Fonts.h>
    49 
    50 #include <vrutil/vrFilePath.h>
    5149
    5250#include <BMPImageLoaderImpl.h>
     
    781779        doExit(1);
    782780    }
    783 
    784     vrFilePath::getInstance()->setPath(path);
    785781
    786782    ImageLoaderFactory::getInstance()->addLoaderImpl("bmp", new BMPImageLoaderImpl());
     
    23592355
    23602356    R2FilePath::getInstance()->setWorkingDirectory(argc, (const char**) argv);
    2361     vrFilePath::getInstance()->setWorkingDirectory(argc, (const char**) argv);
    23622357
    23632358#ifdef XINETD
Note: See TracChangeset for help on using the changeset viewer.