Ignore:
Timestamp:
Mar 10, 2012 11:31:26 PM (12 years ago)
Author:
ldelgass
Message:

Misc. cleanups. Make libs look in nanovis src dir for includes, so that libs
can use Trace.h. Trace.h now includes config.h, so the WANT_TRACE define can
be placed there. The Makefile now has the flag for enabling the pointset
code, since it also switches which objects are compiled.

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

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Makefile.in

    r2837 r2841  
    9797                $(RP_INC_SPEC)
    9898
     99USE_POINTSET_RENDERER = #yes
     100
    99101CC              = @CC@
    100102CXX             = @CXX@
     
    102104EXTRA_CFLAGS    = -Wall
    103105DEFINES         =
     106ifdef USE_POINTSET_RENDERER
     107DEFINES         +=-DUSE_POINTSET_RENDERER
     108endif
    104109CXX_SWITCHES    = $(CFLAGS) $(EXTRA_CFLAGS) $(DEFINES) $(INCLUDES)
    105110
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2.h

    r2827 r2841  
    33#define R2_H
    44
    5 #include <GL/glew.h>
    6 #include <GL/gl.h>
    75#include <math.h>
    86#include <string.h>
    97
    10 
    11 typedef bool            R2bool;
    12 
    13 typedef float           R2float;
    14 typedef double R2double;
    15 typedef char            R2int8;
    16 typedef char            R2char;
    17 typedef unsigned char   R2uint8;
    18 typedef short           R2int16;
    19 typedef unsigned short  R2uint16;
    20 typedef int             R2int32;
    21 typedef unsigned int    R2uint32;
    22 typedef void            R2void;
     8#include <GL/glew.h>
     9#include <GL/gl.h>
    2310
    2411#ifndef PI
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h

    r2827 r2841  
    99class R2FilePath
    1010{
    11     typedef std::list<R2string> R2stringList;
    12     typedef std::list<R2string>::iterator R2stringListIter;
    13    
    14     /**
    15      * @brief application directory
    16      */
    17     static R2string _curDirectory;
    18    
    19     /**
    20      * @brief R2FilePath instance
    21      */
    22     static R2FilePath _instance;
    23    
    24     /**
    25      * @brief all default file paths
    26      */
    27     R2stringList _pathList;
    28 public :
    29     /**
    30      * @brief constructor
    31      */
     11public:
    3212    R2FilePath();
    33    
     13
    3414    /**
    3515     * @brief find a file whose name is fileName and return its full path
     
    3717     * @return return full path of the file, but if not found, return ""
    3818     */
    39     const char *getPath(const char* fileName);
    40    
     19    const char *getPath(const char *fileName);
     20
    4121    /**
    4222     * @brief set default data paths
     
    4424     */
    4525    bool setPath(const char *path);
    46    
    47     /**
    48      *
    49      */
    50     void setWorkingDirectory(int argc, const char** argv);
    51 public :
    52    
    53     /**
    54      * @brief get R2FilePath instance
    55      */
     26
     27    void setWorkingDirectory(int argc, const char **argv);
     28
     29    /// get R2FilePath instance
    5630    static R2FilePath* getInstance();
     31
     32private:
     33    typedef std::list<R2string> R2stringList;
     34    typedef std::list<R2string>::iterator R2stringListIter;
     35
     36    /// application directory
     37    static R2string _curDirectory;
     38
     39    /// R2FilePath instance
     40    static R2FilePath _instance;
     41
     42    /// all default file paths
     43    R2stringList _pathList;
    5744};
    5845
    59 #endif // __R2_FILE_PATH_H__
     46#endif
    6047
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2Fonts.h

    r2827 r2841  
    33#define R2_FONTS_H
    44
     5#include <vector>
     6
    57#include <R2/R2.h>
    68#include <R2/R2Object.h>
    79#include <R2/R2string.h>
    8 #include <vector>
    910
    1011class R2Fonts : public R2Object
     
    1213    struct R2FontAttributes {
    1314        char *_fontName;
    14         R2int32 _textureWidth;
    15         R2int32 _textureHeight;
    16         R2int32 _fontHeight;
    17         R2uint32 _fontTextureID;
    18         R2uint32 _displayLists;
    19        
     15        int _textureWidth;
     16        int _textureHeight;
     17        int _fontHeight;
     18        unsigned int _fontTextureID;
     19        unsigned int _displayLists;
     20
    2021        struct R2CharInfo {
    21             R2float _left;
    22             R2float _right;
    23             R2float _top;
    24             R2float _bottom;
    25             R2bool _valid;
    26             R2float _width;
    27            
     22            float _left;
     23            float _right;
     24            float _top;
     25            float _bottom;
     26            bool _valid;
     27            float _width;
    2828        };
    2929        R2CharInfo _chars[256];
     
    3232    typedef std::vector<R2FontAttributes>  R2FontVector;
    3333
    34     R2FontVector        _fonts;
    35    
    36     /**
    37      * @brief current font index
    38      */
    39     R2int32 _fontIndex;
    40    
    41     /**
    42      * @brief screen width
    43      */
    44     R2int32 _screenWidth;
    45    
    46     /**
    47      * @brief screen height
    48      */
    49     R2int32 _screenHeight;
    50    
    51 private :
    52     ~R2Fonts();
    53    
    54     //private :
    55 public :
    56     /**
    57      * @brief set projection to orthographic
    58      */
     34public:
     35    R2Fonts();
     36
     37    /// set projection to orthographic
    5938    void begin();
    60    
    61     /**
    62      * @brief reset projection matrix
    63      */
     39
     40    /// reset projection matrix
    6441    void end();
    65    
    66     /**
    67      * @brief initialize R2FontAttributes
    68      */
     42
     43    /// initialize R2FontAttributes
    6944    void initializeFont(R2FontAttributes& attr);
    70    
     45
    7146    /**
    7247     * @brief load font data
    7348     */
    74     R2bool loadFont(const char* fontName, const char* fontFileName, R2FontAttributes& sFont);
    75    
    76 public :
    77     /**
    78      * @brief constructor
    79      */
    80     R2Fonts();
    81    
    82     /**
    83      * @brief
    84      */
    85     void addFont(const char* fontName, const char* fontFileName);
    86    
    87     /**
    88      * @brief
    89      */
    90     void setFont(const char* fontName);
    91    
    92     /**
    93      *
    94      */
    95     void draw(const char* pString, ...) const;
    96    
    97     /**
    98      *
    99      */
    100     void resize(R2int32 width, R2int32 height);
    101    
    102     /**
    103      * @brief return font height
    104      */
    105     R2int32 getFontHeight() const;
    106    
     49    bool loadFont(const char *fontName, const char *fontFileName, R2FontAttributes& sFont);
     50
     51    void addFont(const char *fontName, const char *fontFileName);
     52
     53    void setFont(const char *fontName);
     54
     55    void draw(const char *pString, ...) const;
     56
     57    void resize(int width, int height);
     58
     59    /// return font height
     60    int getFontHeight() const;
     61
     62private:
     63    ~R2Fonts();
     64
     65    R2FontVector _fonts;
     66    /// current font index
     67    int _fontIndex;
     68    // screen width
     69    int _screenWidth;
     70    /// screen height
     71    int _screenHeight;
    10772};
    10873
    109 inline R2int32 R2Fonts::getFontHeight() const
     74inline int R2Fonts::getFontHeight() const
    11075{
    11176    return _fonts[_fontIndex]._fontHeight;
    11277}
    11378
    114 #endif // __R2_FONT_H__
     79#endif
    11580
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2Object.h

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef __R2_OBJECT_H__
    3 #define __R2_OBJECT_H__
     2#ifndef R2_OBJECT_H
     3#define R2_OBJECT_H
    44
    55#include <R2/R2.h>
    66
    7 class R2Object {
    8     /**
    9      * @brief reference count
    10      */
    11     R2int32 _refCount;
     7class R2Object
     8{
     9public:
     10    R2Object();
    1211
    13 public :
    14     R2Object();
    15 protected :
     12    int getRef();
     13    int ref();
     14    void unref();
     15
     16protected:
    1617    virtual ~R2Object();
    1718
    18 public :
    19     R2int32 getRef();
    20     R2int32 ref();
    21     void unref();
     19private:
     20    /// reference count
     21    int _refCount;
    2222};
    2323
    24 inline R2int32 R2Object::getRef()
     24inline int R2Object::getRef()
    2525{
    2626    return _refCount;
    2727}
    2828
    29 inline R2int32 R2Object::ref()
     29inline int R2Object::ref()
    3030{
    3131    return ++_refCount;
     
    4040}
    4141
    42 
    4342#endif
    4443
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2string.h

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef __R2_STRING_H__
    3 #define __R2_STRING_H__
     2#ifndef R2_STRING_H
     3#define R2_STRING_H
    44
    55#include <R2/R2.h>
    66
    7 class R2string {
    8         R2char*         _string;
    9         R2int32         _length;
     7class R2string
     8{
     9public:
     10    R2string();
    1011
    11 private :
    12         void set(const R2char* string, R2int32 length);
    13 public :
    14         R2string();
    15         R2string(const char* str);
    16         R2string(const R2string& string);
     12    R2string(const char *str);
     13
     14    R2string(const R2string& string);
     15
    1716    ~R2string();
    1817
    19         operator char*();
    20         operator const char* () const;
    21         R2string& operator=(const R2string& string);
    22         R2string& operator=(const char* string);
    23         R2int32 getLength() const;
     18    operator char*();
    2419
    25         friend R2string operator+(const R2string& string1, const R2string& string2);
    26         friend R2string operator+(const R2string& string1, const char* string2);
    27         friend R2bool operator==(const R2string& string1, const char* string2);
     20    operator const char*() const;
     21
     22    R2string& operator=(const R2string& string);
     23
     24    R2string& operator=(const char* string);
     25
     26    int getLength() const;
     27
     28    friend R2string operator+(const R2string& string1, const R2string& string2);
     29
     30    friend R2string operator+(const R2string& string1, const char* string2);
     31
     32    friend bool operator==(const R2string& string1, const char* string2);
     33
     34private:
     35    void set(const char *string, int length);
     36
     37    char *_string;
     38    int _length;
    2839};
    2940
    3041inline R2string::operator char*()
    3142{
    32         return _string;
     43    return _string;
    3344}
    3445
    3546inline R2string::operator const char* () const
    3647{
    37         return _string;
     48    return _string;
    3849}
    3950
    40 inline R2int32 R2string::getLength() const
     51inline int R2string::getLength() const
    4152{
    42         return _length;
     53    return _length;
    4354}
    4455
    45 inline void R2string::set(const R2char* string, R2int32 length)
     56inline void R2string::set(const char* string, int length)
    4657{
    47         if (_string) {
    48                 delete [] _string;
    49                 _string = NULL;
    50         }
     58    if (_string) {
     59        delete [] _string;
     60        _string = NULL;
     61    }
    5162
    52         _length = length;
    53         if (_length)
    54         {
    55                 _string = new R2char[length + 1];
    56                 strcpy(_string, string);
    57         }
    58 
     63    _length = length;
     64    if (_length) {
     65        _string = new char[length + 1];
     66        strcpy(_string, string);
     67    }
    5968}
    6069
    61 inline R2bool operator==(const R2string& string1, const char* string2)
     70inline bool operator==(const R2string& string1, const char* string2)
    6271{
    63         return (!strcmp(string1._string, string2));
     72    return (!strcmp(string1._string, string2));
    6473}
    6574
    66 #endif // __R2_STRING_H__
     75#endif
    6776
  • trunk/packages/vizservers/nanovis/R2/include/R2/graphics/R2VertexBuffer.h

    r2827 r2841  
    55class R2VertexBuffer
    66{
    7     unsigned int _graphicObjectID;
    8     int _byteSize;
    9     int _vertexCount;
    10 
    117public:
    12     void *_data;
    13 
    148    enum {
    159        POSITION3 = 0x01,
     
    1913    };
    2014
    21     R2VertexBuffer(int type, int vertexCount, int byteSize, void* data, bool copy = true);
     15    R2VertexBuffer(int type, int vertexCount,
     16                   int byteSize, void *data, bool copy = true);
     17
    2218    ~R2VertexBuffer();
    2319
    2420    unsigned int getGraphicObjectID() const;
    2521
    26     void updateBuffer(void* data);
     22    void updateBuffer(void *data);
     23
    2724    int getVertexCount() const;
     25
     26    void *_data;
     27
     28private:
     29    unsigned int _graphicObjectID;
     30    int _byteSize;
     31    int _vertexCount;
    2832};
    2933
    3034inline int R2VertexBuffer::getVertexCount() const
    3135{
    32         return _vertexCount;
     36    return _vertexCount;
    3337}
    3438
    3539inline unsigned int R2VertexBuffer::getGraphicObjectID() const
    3640{
    37         return _graphicObjectID;
     41    return _graphicObjectID;
    3842}
    3943
  • trunk/packages/vizservers/nanovis/R2/src/Makefile.in

    r2094 r2841  
    2525VPATH           = $(srcdir)
    2626
    27 INCLUDES        = -I$(srcdir)/../include
     27INCLUDES        = -I$(srcdir)/../include  -I$(srcdir)/../..
    2828
    2929CFLAGS          = @CFLAGS@
  • trunk/packages/vizservers/nanovis/R2/src/R2FilePath.cpp

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include <R2/R2FilePath.h>
    32#include <string.h>
    43#ifdef _WIN32
     
    109#include <unistd.h>
    1110
     11#include <R2/R2FilePath.h>
     12
     13#include "Trace.h"
     14
    1215R2string R2FilePath::_curDirectory;
    1316R2FilePath R2FilePath::_instance;
    1417
    15 char seps[]   = ":";
     18char seps[] = ":";
    1619
    1720R2FilePath::R2FilePath()
    1821{
    1922    char buff[BUFSIZ+2];
    20 #ifdef WIN32
     23#ifdef _WIN32
    2124    _getcwd(buff, 255);
    2225#else
    2326    if (getcwd(buff, BUFSIZ) == NULL) {
    24         fprintf(stderr, "can't get current working directory\n");
     27        ERROR("can't get current working directory\n");
    2528    }
    2629#endif
     
    3740
    3841    if (filePath == NULL) {
    39         return false;
     42        return false;
    4043    }
    4144    _pathList.clear();
     
    4447    strcpy(buff, filePath);
    4548    for (p = strtok(buff, seps); p != NULL; p = strtok(NULL, seps)) {
    46         char *last;
    47         struct stat buf;
    48         if ((stat(p, &buf) != 0) || (!S_ISDIR(buf.st_mode))) {
    49             return false;
    50         }
    51         last = p + strlen(p) - 1;
    52         if (*p == '/') {
    53             if (*last == '/' || *last == '\\') {
    54                 _pathList.push_back(R2string(p));
    55             } else {
    56                 _pathList.push_back(R2string(p) + "/");
    57             }
    58         } else {
    59             if (*last == '/' || *last == '\\') {
    60                 _pathList.push_back(_curDirectory + R2string(p));
    61             } else {
    62                 _pathList.push_back(_curDirectory + R2string(p) + "/");
    63             }
    64         }
     49        char *last;
     50        struct stat buf;
     51        if ((stat(p, &buf) != 0) || (!S_ISDIR(buf.st_mode))) {
     52            return false;
     53        }
     54        last = p + strlen(p) - 1;
     55        if (*p == '/') {
     56            if (*last == '/' || *last == '\\') {
     57                _pathList.push_back(R2string(p));
     58            } else {
     59                _pathList.push_back(R2string(p) + "/");
     60            }
     61        } else {
     62            if (*last == '/' || *last == '\\') {
     63                _pathList.push_back(_curDirectory + R2string(p));
     64            } else {
     65                _pathList.push_back(_curDirectory + R2string(p) + "/");
     66            }
     67        }
    6568    }
    6669    return true;
    6770}
    6871
    69 R2FilePath* R2FilePath::getInstance()
     72R2FilePath *
     73R2FilePath::getInstance()
    7074{
    7175    return &_instance;
     
    8084    int nameLength = strlen(fileName);
    8185    for (iter = _pathList.begin(); iter != _pathList.end(); ++iter) {
    82         char *path;
     86        char *path;
    8387
    84         path = new char[strlen((char *)(*iter)) + 1 + nameLength + 1];
    85         //sprintf(path, "%s/%s", (char *)(*iter), fileName);
    86         sprintf(path, "%s%s", (char *)(*iter), fileName);
    87         if (access(path, R_OK) == 0) {
    88             return path;
    89         }
    90         delete [] path;
     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) {
     92            return path;
     93        }
     94        delete [] path;
    9195    }
    9296    return NULL;
     
    100104    strcpy(buff, argv[0]);
    101105    for (int i = strlen(buff) - 1; i >= 0; --i) {
    102         if (buff[i] == '\\' || buff[i] == '/') {
    103             buff[i] = '/';
    104             buff[i + 1] = '\0';
    105             break;
    106         }
     106        if (buff[i] == '\\' || buff[i] == '/') {
     107            buff[i] = '/';
     108            buff[i + 1] = '\0';
     109            break;
     110        }
    107111    }
    108112    _curDirectory = buff;
  • trunk/packages/vizservers/nanovis/R2/src/R2Fonts.cpp

    r2840 r2841  
    2626
    2727void
    28 R2Fonts::setFont(const char* fontName)
     28R2Fonts::setFont(const char *fontName)
    2929{
    3030    if (fontName != NULL) {
    31         unsigned int i;
    32         for (i = 0; i < _fonts.size(); ++i) {
    33             if (strcmp(_fonts[i]._fontName, fontName) == 0) {
    34                 _fontIndex = i;
    35                 break;
    36             }
    37         }
    38     }
    39 }
    40 
    41 
    42 void
    43 R2Fonts::addFont(const char* fontName, const char* fontFileName)
     31        unsigned int i;
     32        for (i = 0; i < _fonts.size(); ++i) {
     33            if (strcmp(_fonts[i]._fontName, fontName) == 0) {
     34                _fontIndex = i;
     35                break;
     36            }
     37        }
     38    }
     39}
     40
     41void
     42R2Fonts::addFont(const char *fontName, const char *fontFileName)
    4443{
    4544    R2FontAttributes sFont;
     
    5150
    5251void
    53 R2Fonts::draw(const char* pString, ...) const
     52R2Fonts::draw(const char *pString, ...) const
    5453{
    5554    va_list vlArgs;
    5655    char szVargsBuffer[1024];
    57    
     56
    5857    va_start(vlArgs, pString);
    5958    vsprintf(szVargsBuffer, pString, vlArgs);
    60    
     59
    6160    if (_fontIndex != -1) {
    6261        int length = strlen(szVargsBuffer);
    63        
     62
    6463        glListBase(_fonts[_fontIndex]._displayLists);
    6564        glCallLists(length, GL_UNSIGNED_BYTE,
     
    7372    glEnable(GL_TEXTURE_2D);
    7473    glBindTexture(GL_TEXTURE_2D, _fonts[_fontIndex]. _fontTextureID);
    75    
     74
    7675    glPushAttrib(GL_TRANSFORM_BIT | GL_ENABLE_BIT);
    7776    glMatrixMode(GL_PROJECTION);
    7877    glPushMatrix();
    79    
     78
    8079    glLoadIdentity( );
    8180    gluOrtho2D(0.0f, _screenWidth, _screenHeight, 0.0f);
    82    
     81
    8382    glMatrixMode(GL_MODELVIEW);
    8483    glPushMatrix( );
     
    109108    attr._displayLists = glGenLists(256);
    110109
    111     R2int32 index;
     110    int index;
    112111    for (index = 0; index < 256; ++index) {
    113112        R2FontAttributes::R2CharInfo& charInfo = attr._chars[index];
     
    135134}
    136135
    137 R2bool
    138 R2Fonts::loadFont(const char* fontName, const char* fontFileName,
     136bool
     137R2Fonts::loadFont(const char *fontName, const char *fontFileName,
    139138                  R2FontAttributes& sFont)
    140139{
    141     R2bool bSuccess = false;
     140    bool bSuccess = false;
    142141
    143142    const char *path = R2FilePath::getInstance()->getPath(fontFileName);
    144143    if (path == NULL) {
    145         return false;
     144        return false;
    146145    }
    147146    std::ifstream fsInput(path, std::ios::binary);
     
    194193        if (!fsInput.eof() && !fsInput.fail()) {
    195194            unsigned int uiArea = sFont._textureWidth * sFont._textureHeight;
    196             unsigned char* pRawMap = new unsigned char[uiArea];
    197             fsInput.read(reinterpret_cast<char*>(pRawMap), uiArea);
     195            unsigned char *pRawMap = new unsigned char[uiArea];
     196            fsInput.read(reinterpret_cast<char *>(pRawMap), uiArea);
    198197
    199198            // we've only read the luminance values, but we need a luminance +
    200199            // alpha buffer, so we make a new buffer and duplicate the
    201200            // luminance values
    202             unsigned char* pTexMap = new unsigned char[2 * uiArea];
    203             unsigned char* pMap = pTexMap;
     201            unsigned char *pTexMap = new unsigned char[2 * uiArea];
     202            unsigned char *pMap = pTexMap;
    204203            for (unsigned int i = 0; i < uiArea; ++i) {
    205204                *pMap++ = pRawMap[i];
     
    234233
    235234void
    236 R2Fonts::resize(R2int32 width, R2int32 height)
     235R2Fonts::resize(int width, int height)
    237236{
    238237    _screenWidth = width;
  • trunk/packages/vizservers/nanovis/R2/src/R2Geometry.cpp

    r2840 r2841  
    55#include <R2/graphics/R2Geometry.h>
    66
    7 R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer,
    8                        R2IndexBuffer* indexBuffer) :
     7R2Geometry::R2Geometry(int primitive, R2VertexBuffer *vertexBuffer,
     8                       R2IndexBuffer *indexBuffer) :
    99    _vertexBuffer(vertexBuffer),
    1010    _colorBuffer(0),
     
    1414}
    1515
    16 R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer,
    17                        R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer) :
     16R2Geometry::R2Geometry(int primitive, R2VertexBuffer *vertexBuffer,
     17                       R2VertexBuffer *colorBuffer, R2IndexBuffer *indexBuffer) :
    1818    _vertexBuffer(vertexBuffer),
    1919    _colorBuffer(colorBuffer),
     
    2222{
    2323}
    24 
    2524
    2625R2Geometry::~R2Geometry()
     
    3635    glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer->getGraphicObjectID());
    3736    glVertexPointer(3, GL_FLOAT, 0, 0);
    38    
     37
    3938    if (_colorBuffer) {
    4039        glEnableClientState(GL_COLOR_ARRAY);
     
    4544    }
    4645    glBindBuffer(GL_ARRAY_BUFFER, 0);
    47    
     46
    4847    if (_indexBuffer) {
    4948        glDrawElements(GL_QUADS, _indexBuffer->getIndexCount(), GL_UNSIGNED_INT,
     
    5352        glDrawArrays(_primitiveType, 0, _vertexBuffer->getVertexCount());
    5453    }
    55    
     54
    5655    glDisableClientState(GL_VERTEX_ARRAY);
    5756    if (_colorBuffer) {
  • trunk/packages/vizservers/nanovis/R2/src/R2IndexBuffer.cpp

    r2840 r2841  
    55#include <R2/graphics/R2IndexBuffer.h>
    66
    7 R2IndexBuffer::R2IndexBuffer(int indexCount, int* data, bool copy)
    8 : _indexCount(indexCount)
     7R2IndexBuffer::R2IndexBuffer(int indexCount, int* data, bool copy) :
     8    _indexCount(indexCount)
    99{
    10         if (copy)
    11         {
    12                 _data = (int*) malloc(sizeof(int) * indexCount);
    13                 memcpy(_data, data, sizeof(int) * indexCount);
    14         }
    15         else
    16         {
    17                 _data = data;
    18         }
     10    if (copy) {
     11        _data = (int*)malloc(sizeof(int) * indexCount);
     12        memcpy(_data, data, sizeof(int) * indexCount);
     13    } else {
     14        _data = data;
     15    }
    1916}
    20 
    2117
    2218R2IndexBuffer::~R2IndexBuffer()
    2319{
    24         if (_data)
    25         {
    26                 free(_data);
    27         }
     20    if (_data) {
     21        free(_data);
     22    }
    2823}
  • trunk/packages/vizservers/nanovis/R2/src/R2VertexBuffer.cpp

    r2840 r2841  
    88#include <R2/graphics/R2VertexBuffer.h>
    99
    10 R2VertexBuffer::R2VertexBuffer(int type, int vertexCount, int byteSize, void* data, bool copy)
    11 : _graphicObjectID(0), _byteSize(byteSize), _vertexCount(vertexCount)
     10R2VertexBuffer::R2VertexBuffer(int type, int vertexCount,
     11                               int byteSize, void *data, bool copy) :
     12    _graphicObjectID(0), _byteSize(byteSize), _vertexCount(vertexCount)
    1213{
    13         if (copy)
    14         {
    15                 _data = (void*) malloc(byteSize);
    16         }
    17         else
    18         {
    19                 _data = data;
    20         }
     14    if (copy) {
     15        _data = (void*) malloc(byteSize);
     16    } else {
     17        _data = data;
     18    }
    2119
    22         glGenBuffers(1, &_graphicObjectID);
    23         glBindBuffer(GL_ARRAY_BUFFER, _graphicObjectID);
     20    glGenBuffers(1, &_graphicObjectID);
     21    glBindBuffer(GL_ARRAY_BUFFER, _graphicObjectID);
    2422    glBufferData(GL_ARRAY_BUFFER,
    25                   _byteSize,
    26                   data,
    27                   GL_STATIC_DRAW);
     23                 _byteSize,
     24                 data,
     25                 GL_STATIC_DRAW);
    2826    glBindBuffer(GL_ARRAY_BUFFER, 0);
    2927}
     
    3129R2VertexBuffer::~R2VertexBuffer()
    3230{
    33         if (_graphicObjectID != 0)
    34         {
    35                 glDeleteBuffers(1, &_graphicObjectID);
    36         }
    37 
    38         if (_data)
    39         {
    40                 free(_data);
    41         }
     31    if (_graphicObjectID != 0) {
     32        glDeleteBuffers(1, &_graphicObjectID);
     33    }
     34    if (_data) {
     35        free(_data);
     36    }
    4237}
  • trunk/packages/vizservers/nanovis/R2/src/R2string.cpp

    r2840 r2841  
    1010}
    1111
    12 R2string::R2string(const char* str) : _string(NULL), _length(0)
     12R2string::R2string(const char* str) :
     13    _string(NULL), _length(0)
    1314{
    1415    if (str != NULL) {
    15         set(str, (R2int32) strlen(str));
     16        set(str, (int)strlen(str));
    1617    }
    1718}
    1819
    19 R2string::R2string(const R2string& string) : _string(NULL)
     20R2string::R2string(const R2string& string) :
     21    _string(NULL)
    2022{
    2123    set(string._string, string._length);
     
    4547    R2string ret;
    4648    ret._length = string1._length + string2._length;
    47     ret._string = new R2char[ret._length + 1];
     49    ret._string = new char[ret._length + 1];
    4850   
    4951    strcpy(ret._string, string1._string);
     
    5860    R2string ret;
    5961    ret._length = string1._length + strlen(string2);
    60     ret._string = new R2char[ret._length + 1];
     62    ret._string = new char[ret._length + 1];
    6163   
    6264    strcpy(ret._string, string1._string);
  • trunk/packages/vizservers/nanovis/Trace.h

    r2822 r2841  
    55#include <GL/glew.h>
    66#include <syslog.h>
     7
     8#include "config.h"
    79
    810#define MAKE_STRING(x) #x
  • trunk/packages/vizservers/nanovis/config.h

    r2836 r2841  
    1515 */
    1616
    17 #ifndef __CONFIG_H__
    18 #define __CONFIG_H__
     17#ifndef CONFIG_H__
     18#define CONFIG_H__
    1919
    2020#define NV40                            /* Uncomment if using 6 series
     
    2525//#define DO_RLE                        /* Do run length compression. */
    2626
     27/*
     28 * Controls if debug trace logging is enabled
     29 */
     30//#define WANT_TRACE
     31
    2732/*
    2833 * The following define controls whether new prototype features are to be
     
    3237 */
    3338#define PROTOTYPE               0
    34 
    35 //#define USE_POINTSET_RENDERER
    3639
    3740/*
  • trunk/packages/vizservers/nanovis/imgLoaders/Makefile.in

    r951 r2841  
    2424VPATH           = $(srcdir)
    2525
    26 INCLUDES        = -I$(srcdir)
     26INCLUDES        = -I$(srcdir) -I$(srcdir)/..
    2727
    2828CFLAGS          = @CFLAGS@
  • trunk/packages/vizservers/nanovis/vr3d/Makefile.in

    r2094 r2841  
    2525VPATH           = $(srcdir)
    2626
    27 INCLUDES        = -I$(srcdir)/include
     27INCLUDES        = -I$(srcdir)/include -I$(srcdir)/..
    2828
    2929CFLAGS          = @CFLAGS@
  • trunk/packages/vizservers/nanovis/vrmath/Makefile.in

    r2094 r2841  
    2525VPATH           = $(srcdir)
    2626
    27 INCLUDES        = -I$(srcdir)/include
     27INCLUDES        = -I$(srcdir)/include -I$(srcdir)/..
    2828
    2929CFLAGS          = @CFLAGS@
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrBBox.h

    r2840 r2841  
    77#include <vrmath/vrMatrix4x4f.h>
    88
    9 class LmExport vrBBox
     9class vrBBox
    1010{
    1111public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrBPlane.h

    r2840 r2841  
    1414#include <vrmath/vrLineSegment.h>
    1515
    16 class LmExport vrBPlane
     16class vrBPlane
    1717{
    1818public:
    1919    void makePts(const vrVector3f& pt1, const vrVector3f& pt2, const vrVector3f& pt3);
     20
    2021    void makeNormalPt(const vrVector3f& norm, const vrVector3f& pos);
     22
    2123    bool intersect(const vrLineSegment &seg, float &d) const;
     24
    2225    float distance(const vrVector3f& point) const;
     26
    2327    vrVector3f crossPoint(const vrVector3f& point) const;
    2428
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrColor4f.h

    r2840 r2841  
    55#include <vrmath/vrLinmath.h>
    66
    7 class LmExport vrColor4f
     7class vrColor4f
    88{
    99public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrLineSegment.h

    r2840 r2841  
    1414#include <vrmath/vrMatrix4x4f.h>
    1515
    16 class LmExport vrLineSegment
     16class vrLineSegment
    1717{
    1818public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrLinmath.h

    r2840 r2841  
    33#define VRLINMATH_H
    44
    5 #ifdef _WIN32
    6 //#include <windows.h>
    7 
    8 #ifdef LINMATHDLLEXPORT
    9 #define LmExport __declspec(dllexport)
    10 #define EXPIMP_TEMPLATE
    11 #else
    12 #define LmExport __declspec(dllimport)
    13 #   define EXPIMP_TEMPLATE extern
    14 #endif
    15 
    16 #else
    17 #define LmExport   
    18 #endif
    19 
    20 
    215class vrVector3f;
    226
    23 extern vrVector3f LmExport vrCalcuNormal(const vrVector3f& v1, const vrVector3f& v2, const vrVector3f& v3);
     7extern vrVector3f vrCalcuNormal(const vrVector3f& v1, const vrVector3f& v2, const vrVector3f& v3);
    248
    259#ifdef __cplusplus
     
    2711#endif
    2812
    29 int LmExport vrUnproject(float winx, float winy, float winz,
     13int vrUnproject(float winx, float winy, float winz,
    3014                const float modelMatrix[16],
    3115                const float projMatrix[16],
     
    3317                float *objx, float *objy, float *objz);
    3418
    35 void LmExport vrPerspective(float fovy, float aspect, float zNear, float zFar, float* matrix);
     19void vrPerspective(float fovy, float aspect, float zNear, float zFar, float* matrix);
    3620
    3721#ifdef __cplusplus
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrMatrix4x4f.h

    r2840 r2841  
    88#include <memory.h>
    99
    10 class LmExport vrMatrix4x4f
     10class vrMatrix4x4f
    1111{
    1212public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrPlane.h

    r2840 r2841  
    1515#include <vrmath/vrVector3f.h>
    1616
    17 class LmExport vrPlane
     17class vrPlane
    1818{
    1919public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrPlane2.h

    r2840 r2841  
    1313#include <vrmath/vrLineSegment.h>
    1414
    15 class LmExport vrPlane2
     15class vrPlane2
    1616{
    1717public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrProjection.h

    r2840 r2841  
    77#endif
    88
    9 LmExport int
     9int
    1010unproject(float winx, float winy, float winz,
    1111          const float modelMatrix[16],
     
    1414          float *objx, float *objy, float *objz);
    1515
    16 LmExport void
     16void
    1717perspective(float fovy, float aspect, float zNear, float zFar, float *matrix);
    1818
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrQuaternion.h

    r2840 r2841  
    1313class vrRotation;
    1414
    15 class LmExport vrQuaternion
     15class vrQuaternion
    1616{
    1717public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrRotation.h

    r2840 r2841  
    88class vrQuaternion;
    99
    10 class LmExport vrRotation
     10class vrRotation
    1111{
    1212public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrVector2f.h

    r2840 r2841  
    88#include <cmath>
    99
    10 class LmExport vrVector2f
     10class vrVector2f
    1111{
    1212public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrVector3f.h

    r2840 r2841  
    1010class vrMatrix4x4f;
    1111
    12 class LmExport vrVector3f
     12class vrVector3f
    1313{
    1414public:
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrVector4f.h

    r2840 r2841  
    99class vrMatrix4x4f;
    1010
    11 class LmExport vrVector4f
     11class vrVector4f
    1212{
    1313public:
  • trunk/packages/vizservers/nanovis/vrutil/Makefile.in

    r2094 r2841  
    2525VPATH           = $(srcdir)
    2626
    27 INCLUDES        = -I$(srcdir)/include
     27INCLUDES        = -I$(srcdir)/include -I$(srcdir)/..
    2828
    2929CFLAGS          = @CFLAGS@
  • trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrColorBrewer.h

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #pragma once
     2#ifndef VRCOLORBREWER_H
     3#define VRCOLORBREWER_H
    34
    45#include <string>
     6
    57#include <vrutil/vrUtil.h>
    68
    7 class VrUtilExport CBColor {
     9class CBColor
     10{
    811public :
    9         float r, g, b;
     12    float r, g, b;
    1013};
    1114
     15class vrColorBrewer
     16{
     17public:
     18    vrColorBrewer();
    1219
    13 class VrUtilExport vrColorBrewer {
    14 public:
    15         CBColor *colorScheme;
    16         float* colorKey;
    17         float* defaultOpacity;
    18         int size;
    19         std::string label;
     20    vrColorBrewer(int size, char label[20]);
    2021
    21 public:
    22         vrColorBrewer();
    23         vrColorBrewer(int size, char label[20]);
    24         ~vrColorBrewer(void);
    25        
    26 public :
    27         void setColor(int index, float r, float g, float b);
     22    ~vrColorBrewer();
     23
     24    void setColor(int index, float r, float g, float b);
     25
     26    CBColor *colorScheme;
     27    float* colorKey;
     28    float* defaultOpacity;
     29    int size;
     30    std::string label;
    2831};
    2932
     33#endif
     34
  • trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrColorBrewerFactory.h

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #pragma once
    3 
    4 #include <vrutil/vrUtil.h>
    5 
    6 class vrColorBrewer;
     2#ifndef VRCOLORBREWERFACTORY_H
     3#define VRCOLORBREWERFACTORY_H
    74
    85#include <vector>
    96#include <string>
    107
    11 #define COLOR_SCHEME_START    3
     8#include <vrutil/vrUtil.h>
     9
     10#define COLOR_SCHEME_START      3
    1211#define COLOR_SCHEME_SEQ_END    9
    1312#define COLOR_SCHEME_DIV_END    11
    1413
    15 class vrColorBrewerFactory {
    16         std::vector<vrColorBrewer*> colorList;
    17        
    18         vrColorBrewer* _currentColorBrewer;
     14class vrColorBrewer;
    1915
    20         static vrColorBrewerFactory* _instance;
    21 protected :
    22         vrColorBrewerFactory();
    23 public :
    24         static vrColorBrewerFactory* getInstance();
     16class vrColorBrewerFactory
     17{
     18public:
     19    void loadColorBrewerList();
    2520
    26 public :
    27         void loadColorBrewerList();
    28         int getColorMapCount() const;
     21    int getColorMapCount() const;
    2922
    30         vrColorBrewer* getColorMap(int id);
     23    vrColorBrewer *getColorMap(int id);
    3124
    32         vrColorBrewer* chooseColorScheme(const std::string& scheme, int size);
     25    vrColorBrewer *chooseColorScheme(const std::string& scheme, int size);
     26
     27    static vrColorBrewerFactory* getInstance();
     28
     29protected:
     30    vrColorBrewerFactory();
     31
     32private:
     33    std::vector<vrColorBrewer *> colorList;
     34    vrColorBrewer *_currentColorBrewer;
     35
     36    static vrColorBrewerFactory *_instance;
    3337};
    3438
    3539inline vrColorBrewer* vrColorBrewerFactory::getColorMap(int id)
    3640{
    37         return colorList[id];
     41    return colorList[id];
    3842}
    3943
    4044inline int vrColorBrewerFactory::getColorMapCount() const
    4145{
    42         return (int) colorList.size();
     46    return (int) colorList.size();
    4347}
     48
     49#endif
  • trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrFilePath.h

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #pragma once
     2#ifndef VRFILEPATH_H
     3#define VRFILEPATH_H
    34
    45#include <vrutil/vrUtil.h>
     
    67#include <list>
    78
    8 #ifdef WIN32
    9 #pragma warning ( disable : 4251)
    10 #endif
    11 
    12 class VrUtilExport vrFilePath {
    13         typedef std::list<std::string> StringList;
    14         typedef std::list<std::string>::iterator StringListIter;
    15 
    16         /**
    17          * @brief application directory
    18          */
    19         static std::string _curDirectory;
    20 
    21         /**
    22          * @brief vrFilePath instance
    23          */
    24         static vrFilePath _instance;
    25 
    26         /**
    27          * @brief all default file paths
    28          */
    29         StringList _pathList;
    30 public :
    31         /**
    32          * @brief constructor
    33          */
    34         vrFilePath();
    35 
    36         /**
    37          * @brief find a file whose name is fileName and return its full path
    38          * @param fileName a file name
    39          * @return return full path of the file, but if not found, return ""
    40          */
    41         std::string getPath(const char* fileName);
    42 
    43         /**
    44          * @brief set default data paths
    45          * @param filePath all default paths separated by colon(:)
    46          */
    47         void setPath(const std::string& filePath);
     9class vrFilePath
     10{
     11public:
     12    vrFilePath();
    4813
    4914    /**
    50      *
     15     * @brief find a file whose name is fileName and return its full path
     16     * @param fileName a file name
     17     * @return return full path of the file, but if not found, return ""
    5118     */
    52     void setWorkingDirectory(int argc, const char** argv);
    53 public :
     19    std::string getPath(const char *fileName);
    5420
    55         /**
    56          * @brief get vrFilePath instance
    57          */
    58         static vrFilePath* getInstance();
     21    /**
     22     * @brief set default data paths
     23     * @param filePath all default paths separated by colon(:)
     24     */
     25    void setPath(const std::string& filePath);
    5926
     27    void setWorkingDirectory(int argc, const char **argv);
     28
     29    /// get vrFilePath instance
     30    static vrFilePath* getInstance();
     31
     32private:
     33    typedef std::list<std::string> StringList;
     34    typedef std::list<std::string>::iterator StringListIter;
     35
     36    /// application directory
     37    static std::string _curDirectory;
     38
     39    /// vrFilePath instance
     40    static vrFilePath _instance;
     41
     42    /// all default file paths
     43    StringList _pathList;
    6044};
    6145
    62 
     46#endif
  • trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrLock.h

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #pragma once
     2#ifndef VRLOCK_H
     3#define VRLOCK_H
     4
     5#include <pthread.h>
    36
    47#include <vrutil/vrUtil.h>
    58
    6 #ifndef IPHONE
     9class vrLock
     10{
     11public:
     12    vrLock();
     13    ~vrLock();
    714
    8 #include <pthread.h>
     15    void lock();
     16    void unlock();
    917
    10 class VrUtilExport vrLock {
    11         pthread_mutex_t _mutex;
    12         pthread_mutexattr_t _attr;
    13 public :
    14         vrLock();
    15         ~vrLock();
    16 
    17 public :
    18         void lock();
    19         void unlock();
     18private:
     19    pthread_mutex_t _mutex;
     20    pthread_mutexattr_t _attr;
    2021};
    2122
    2223inline void vrLock::lock()
    2324{
    24           pthread_mutex_lock(&_mutex);
     25    pthread_mutex_lock(&_mutex);
    2526}
    2627
    2728inline void vrLock::unlock()
    2829{
    29           pthread_mutex_unlock(&_mutex);
     30    pthread_mutex_unlock(&_mutex);
    3031}
    3132
  • trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrStringParser.h

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #pragma once
     2#ifndef VRSTRINGPARSER_H
     3#define VRSTRINGPARSER_H
    34
    45#include <string>
    56#include <iostream>
     7
    68#include <vrutil/vrUtil.h>
    79
    8 class VrUtilExport vrStringParser {
    9         std::string _whitechars;
    10         std::istream& _stream;
    11         char _buff[256];
     10class vrStringParser
     11{
     12public:
     13    vrStringParser(std::istream& stream);
    1214
    13 public :
    14         vrStringParser(std::istream& stream);
    15         int getToken();
    16         void ungetToken();
    17         bool isWhiteChar(char ch);
    18         void setWhiteCharacters(const std::string& whitechars);
    19         char* getBuffer();
     15    int getToken();
    2016
     17    void ungetToken();
     18
     19    bool isWhiteChar(char ch);
     20
     21    void setWhiteCharacters(const std::string& whitechars);
     22
     23    char *getBuffer();
     24
     25private:
     26    std::string _whitechars;
     27    std::istream& _stream;
     28    char _buff[256];
    2129};
    2230
    23 inline char* vrStringParser::getBuffer()
     31inline char *vrStringParser::getBuffer()
    2432{
    25         return _buff;
     33    return _buff;
    2634}
    2735
    2836inline void vrStringParser::setWhiteCharacters(const std::string& whitechars)
    2937{
    30         _whitechars = whitechars;
     38    _whitechars = whitechars;
    3139}
    3240
    3341inline bool vrStringParser::isWhiteChar(char ch)
    3442{
    35         for (size_t i = 0; i < _whitechars.size(); ++i)
    36         {
    37                 if (ch == _whitechars[i]) return true;
    38         }
     43    for (size_t i = 0; i < _whitechars.size(); ++i) {
     44        if (ch == _whitechars[i]) return true;
     45    }
    3946
    40         return false;
     47    return false;
    4148}
    4249
     50#endif
     51
  • trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrThread.h

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #pragma once
     2#ifndef VRTHREAD_H
     3#define VRTHREAD_H
    34
    4 #ifndef IPHONE
    5 
    6 #ifdef WIN32
    7 #include <pthread/pthread.h>
    8 #else
    95#include <pthread.h>
    10 #endif
    116
    127#include <vrutil/vrUtil.h>
    138
    14 class VrUtilExport vrThread {
    15         pthread_t _thread;
    16         pthread_attr_t _attr;
    17         int _threadID;
     9class vrThread
     10{
     11public:
     12    vrThread();
    1813
    19 public :
    20         vrThread();
    21         virtual ~vrThread();
     14    virtual ~vrThread();
    2215
    23 private :
    24         static void* threadMain(void* data);
    25 public :
    26         void initialize();
     16    void initialize();
    2717
    28 public :
    29         virtual void run();
     18    virtual void run();
     19
     20private:
     21    static void *threadMain(void *data);
     22
     23    pthread_t _thread;
     24    pthread_attr_t _attr;
     25    int _threadID;
    3026};
    3127
  • trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrUtil.h

    r2798 r2841  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #pragma once
     2#ifndef VRUTIL_H
     3#define VRUTIL_H
    34
    4 #ifdef WIN32
    5 #pragma pointers_to_members(full_generality, single_inheritance)
    65#endif
    7 
    8 #ifdef _WIN32
    9 //#include <windows.h>
    10 
    11 #ifdef VRUTILDLLEXPORT
    12 #       define VrUtilExport __declspec(dllexport)
    13 #else
    14 #       define VrUtilExport __declspec(dllimport)
    15 #endif
    16 
    17 #else
    18 #       define VrUtilExport
    19 #endif
    20 
  • trunk/packages/vizservers/nanovis/vrutil/vrFilePath.cpp

    r2798 r2841  
    33
    44#ifdef _WIN32
    5 #pragma warning  ( disable : 4996)
     5#pragma warning (disable : 4996)
    66#endif
    77
     
    1717vrFilePath vrFilePath::_instance;
    1818
    19 static char seps[]   = ";";
     19static char seps[]  = ";";
    2020vrFilePath::vrFilePath()
    2121{
    22         char buff[255];
    23 #ifdef WIN32
    24         if (_getcwd(buff, 255) == 0)
    25         {
    26                 printf("failed to get the current directory in vrFilePath::vrFilePath\n");
    27         }
     22    char buff[255];
     23#ifdef _WIN32
     24    if (_getcwd(buff, 255) == 0) {
     25        printf("failed to get the current directory in vrFilePath::vrFilePath\n");
     26    }
    2827#else
    29         if (getcwd(buff, 255) == 0)
    30         {
    31                 printf("failed to get the current directory in vrFilePath::vrFilePath\n");
    32         }
     28    if (getcwd(buff, 255) == 0) {
     29        printf("failed to get the current directory in vrFilePath::vrFilePath\n");
     30    }
    3331#endif
    3432
    35         size_t length = strlen(buff);
    36         buff[length] = '/';
    37         buff[length + 1] = '\0';
     33    size_t length = strlen(buff);
     34    buff[length] = '/';
     35    buff[length + 1] = '\0';
    3836
    39         unsigned int len = (unsigned int) strlen(buff);
    40         for (unsigned int i = 0; i < len; ++i)
    41         {
    42                 if (buff[i] == '\\') buff[i] = '/';
    43         }
    44         _curDirectory = buff;
     37    unsigned int len = (unsigned int) strlen(buff);
     38    for (unsigned int i = 0; i < len; ++i) {
     39        if (buff[i] == '\\') buff[i] = '/';
     40    }
     41    _curDirectory = buff;
    4542
    46         char * path;
    47         path = getenv("VR_ROOT_PATH");
    48         if (path)
    49         {
    50                 int len = (int) strlen(path);
    51                 for (int i = 0; i < len; ++i)
    52                 {
    53                         if (buff[i] == '\\') buff[i] = '/';
    54                 }
     43    char * path;
     44    path = getenv("VR_ROOT_PATH");
     45    if (path) {
     46        int len = (int) strlen(path);
     47        for (int i = 0; i < len; ++i) {
     48            if (buff[i] == '\\') buff[i] = '/';
     49        }
    5550
    56                 strcpy(buff, path);
    57                 strcpy(buff + strlen(path), "/resources/");
    58                 _pathList.push_back(buff);
    59         }
     51        strcpy(buff, path);
     52        strcpy(buff + strlen(path), "/resources/");
     53        _pathList.push_back(buff);
     54    }
    6055}
    6156
    6257void vrFilePath::setPath(const std::string& filePath)
    6358{
    64         char buff[255];
     59    char buff[255];
    6560
    66         _pathList.clear();
     61    _pathList.clear();
    6762
    68         char * path;
    69         path = getenv ("VR_ROOT_PATH");
    70         if (path)
    71         {
    72                 strcpy(buff, path);
    73                 int len = (int) strlen(path);
    74                 for (int i = 0; i < len; ++i)
    75                 {
    76                         if (buff[i] == '\\') buff[i] = '/';
    77                 }
     63    char * path;
     64    path = getenv("VR_ROOT_PATH");
     65    if (path) {
     66        strcpy(buff, path);
     67        int len = (int)strlen(path);
     68        for (int i = 0; i < len; ++i) {
     69            if (buff[i] == '\\') buff[i] = '/';
     70        }
    7871
     72        strcpy(buff + strlen(path), "/resources/");
     73        _pathList.push_back(buff);
     74    }
    7975
    80                 strcpy(buff + strlen(path), "/resources/");
    81                 _pathList.push_back(buff);
    82         }
     76    char *token;
     77    strcpy(buff, filePath.c_str());
     78    token = strtok(buff, seps );
    8379
    84         char *token;
    85         strcpy(buff, filePath.c_str());
    86         token = strtok(buff, seps );
    87 
    88         int lastIndex;
    89         while( token != NULL )
    90         {
    91                 lastIndex = (int) strlen(token) - 1;
    92                 //if (token[0] == '/' || token[1] == ';')
    93                 if (token[0] == '/' || ((lastIndex >= 1) && token[1] == ':'))
    94                 {
    95                         if (token[lastIndex] == '/' || token[lastIndex] == '\\')
    96                         {
    97                                 _pathList.push_back(std::string(token));
    98                         }
    99                         else
    100                         {
    101                                 _pathList.push_back(std::string(token) + "/");
    102                         }
    103                        
    104                 }
    105                 else
    106                 {
    107                         if (token[lastIndex] == '/' || token[lastIndex] == '\\')
    108                         {
    109                                 _pathList.push_back(_curDirectory + std::string(token));
    110                         }
    111                         else
    112                         {
    113                                 _pathList.push_back(_curDirectory + std::string(token) + "/");
    114                         }
    115 
    116                        
    117                 }
    118                 token = strtok( NULL, seps );
    119         }
     80    int lastIndex;
     81    while (token != NULL) {
     82        lastIndex = (int)strlen(token) - 1;
     83        //if (token[0] == '/' || token[1] == ';')
     84        if (token[0] == '/' || ((lastIndex >= 1) && token[1] == ':')) {
     85            if (token[lastIndex] == '/' || token[lastIndex] == '\\') {
     86                _pathList.push_back(std::string(token));
     87            } else {
     88                _pathList.push_back(std::string(token) + "/");
     89            }
     90        } else {
     91            if (token[lastIndex] == '/' || token[lastIndex] == '\\') {
     92                _pathList.push_back(_curDirectory + std::string(token));
     93            } else {
     94                _pathList.push_back(_curDirectory + std::string(token) + "/");
     95            }
     96        }
     97        token = strtok(NULL, seps);
     98    }
    12099}
    121100
    122 vrFilePath* vrFilePath::getInstance()
     101vrFilePath *vrFilePath::getInstance()
    123102{
    124         return &_instance;
     103    return &_instance;
    125104}
    126105
    127106std::string vrFilePath::getPath(const char* fileName)
    128107{
    129         std::string path;
    130         FILE* file;
     108    std::string path;
     109    FILE *file;
    131110
    132         StringListIter iter;
    133         for (iter = _pathList.begin(); iter != _pathList.end(); ++iter)
    134         {
    135 #ifdef WIN32
    136                 if (_chdir(iter->c_str()) == -1)
    137                 {
    138                         printf("error : change dir (%s)", iter->c_str());
    139                 }
     111    StringListIter iter;
     112    for (iter = _pathList.begin(); iter != _pathList.end(); ++iter) {
     113#ifdef _WIN32
     114        if (_chdir(iter->c_str()) == -1) {
     115            printf("error : change dir (%s)", iter->c_str());
     116        }
    140117#else
    141                 if (chdir(iter->c_str()) == -1)
    142                 {
    143                         printf("error : change dir (%s)", iter->c_str());
    144                 }
     118        if (chdir(iter->c_str()) == -1) {
     119            printf("error : change dir (%s)", iter->c_str());
     120        }
     121#endif
     122        if ((file = fopen(fileName, "rb")) != NULL) {
     123            fclose(file);
     124
     125            path = (*iter) + fileName;
     126
     127            printf("returned [%s]\n", path.c_str());
     128            break;
     129        }
     130    }
     131
     132#ifdef _WIN32
     133    if (_chdir(_curDirectory.c_str()) != -1) {
     134        printf("error : change dir (%s)", _curDirectory.c_str());
     135    }
     136#else
     137    if (chdir(_curDirectory.c_str()) != -1) {
     138        printf("error : change dir (%s)", _curDirectory.c_str());
     139    }
    145140#endif
    146141
    147                 if ((file = fopen(fileName, "rb")) != NULL)
    148                 {
    149                         fclose(file);
    150                        
    151                         path = (*iter) + fileName;
    152 
    153                         printf("returned [%s]\n", path.c_str());
    154                         break;
    155                 }
    156         }
    157 
    158 #ifdef WIN32
    159         if (_chdir(_curDirectory.c_str()) != -1)
    160         {
    161                 printf("error : change dir (%s)", _curDirectory.c_str());
    162         }
    163 #else
    164         if (chdir(_curDirectory.c_str()) != -1)
    165         {
    166                 printf("error : change dir (%s)", _curDirectory.c_str());
    167         }
    168 #endif
    169 
    170         return path;
     142    return path;
    171143}
    172144
    173 void vrFilePath::setWorkingDirectory(int argc, const char** argv)
     145void vrFilePath::setWorkingDirectory(int argc, const char **argv)
    174146{
    175147    char buff[255];
    176148    strcpy(buff, argv[0]);
    177     for (int i = (int) strlen(buff) - 1; i >= 0; --i)
    178     {
    179         if (buff[i] == '\\' || buff[i] == '/')
    180         {
     149    for (int i = (int) strlen(buff) - 1; i >= 0; --i) {
     150        if (buff[i] == '\\' || buff[i] == '/') {
    181151            buff[i] = '/';
    182152            buff[i + 1] = '\0';
     
    185155    }
    186156
    187         int len = (int) strlen(buff);
    188         for (int i = 0; i < len; ++i)
    189         {
    190                 if (buff[i] == '\\') buff[i] = '/';
    191         }
    192         _curDirectory = buff;
     157    int len = (int)strlen(buff);
     158    for (int i = 0; i < len; ++i) {
     159        if (buff[i] == '\\') buff[i] = '/';
     160    }
     161    _curDirectory = buff;
    193162}
    194 
  • trunk/packages/vizservers/nanovis/vrutil/vrStringParser.cpp

    r2798 r2841  
    22#include <vrutil/vrStringParser.h>
    33
    4 vrStringParser::vrStringParser(std::istream& stream)
    5 : _stream(stream)
     4vrStringParser::vrStringParser(std::istream& stream) :
     5    _stream(stream)
    66{
    77}
     
    99int vrStringParser::getToken()
    1010{
    11         int index = 0;
    12         char ch = 0;
    13         if (_stream.eof()) return 0;
     11    int index = 0;
     12    char ch = 0;
     13    if (_stream.eof()) return 0;
    1414
    15         while(!_stream.eof() && isWhiteChar(ch = _stream.get()));
    16         if (ch == 0 || isWhiteChar(ch)) return 0;
     15    while (!_stream.eof() && isWhiteChar(ch = _stream.get()));
     16    if (ch == 0 || isWhiteChar(ch)) return 0;
    1717
    18         do {
    19                 _buff[index++] = ch;
    20         } while (!_stream.eof() && !isWhiteChar(ch = _stream.get()));
     18    do {
     19        _buff[index++] = ch;
     20    } while (!_stream.eof() && !isWhiteChar(ch = _stream.get()));
    2121
    22         _buff[index] = 0;
     22    _buff[index] = 0;
    2323
    24         return index;
     24    return index;
    2525}
Note: See TracChangeset for help on using the changeset viewer.