Changeset 2841 for trunk/packages/vizservers
- Timestamp:
- Mar 10, 2012, 11:31:26 PM (13 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Makefile.in
r2837 r2841 97 97 $(RP_INC_SPEC) 98 98 99 USE_POINTSET_RENDERER = #yes 100 99 101 CC = @CC@ 100 102 CXX = @CXX@ … … 102 104 EXTRA_CFLAGS = -Wall 103 105 DEFINES = 106 ifdef USE_POINTSET_RENDERER 107 DEFINES +=-DUSE_POINTSET_RENDERER 108 endif 104 109 CXX_SWITCHES = $(CFLAGS) $(EXTRA_CFLAGS) $(DEFINES) $(INCLUDES) 105 110 -
trunk/packages/vizservers/nanovis/R2/include/R2/R2.h
r2827 r2841 3 3 #define R2_H 4 4 5 #include <GL/glew.h>6 #include <GL/gl.h>7 5 #include <math.h> 8 6 #include <string.h> 9 7 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> 23 10 24 11 #ifndef PI -
trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h
r2827 r2841 9 9 class R2FilePath 10 10 { 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 */ 11 public: 32 12 R2FilePath(); 33 13 34 14 /** 35 15 * @brief find a file whose name is fileName and return its full path … … 37 17 * @return return full path of the file, but if not found, return "" 38 18 */ 39 const char *getPath(const char *fileName);40 19 const char *getPath(const char *fileName); 20 41 21 /** 42 22 * @brief set default data paths … … 44 24 */ 45 25 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 56 30 static R2FilePath* getInstance(); 31 32 private: 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; 57 44 }; 58 45 59 #endif // __R2_FILE_PATH_H__46 #endif 60 47 -
trunk/packages/vizservers/nanovis/R2/include/R2/R2Fonts.h
r2827 r2841 3 3 #define R2_FONTS_H 4 4 5 #include <vector> 6 5 7 #include <R2/R2.h> 6 8 #include <R2/R2Object.h> 7 9 #include <R2/R2string.h> 8 #include <vector>9 10 10 11 class R2Fonts : public R2Object … … 12 13 struct R2FontAttributes { 13 14 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 20 21 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; 28 28 }; 29 29 R2CharInfo _chars[256]; … … 32 32 typedef std::vector<R2FontAttributes> R2FontVector; 33 33 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 */ 34 public: 35 R2Fonts(); 36 37 /// set projection to orthographic 59 38 void begin(); 60 61 /** 62 * @brief reset projection matrix 63 */ 39 40 /// reset projection matrix 64 41 void end(); 65 66 /** 67 * @brief initialize R2FontAttributes 68 */ 42 43 /// initialize R2FontAttributes 69 44 void initializeFont(R2FontAttributes& attr); 70 45 71 46 /** 72 47 * @brief load font data 73 48 */ 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 62 private: 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; 107 72 }; 108 73 109 inline R2int32R2Fonts::getFontHeight() const74 inline int R2Fonts::getFontHeight() const 110 75 { 111 76 return _fonts[_fontIndex]._fontHeight; 112 77 } 113 78 114 #endif // __R2_FONT_H__79 #endif 115 80 -
trunk/packages/vizservers/nanovis/R2/include/R2/R2Object.h
r2798 r2841 1 1 /* -*- 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 4 4 5 5 #include <R2/R2.h> 6 6 7 class R2Object { 8 /** 9 * @brief reference count 10 */ 11 R2int32 _refCount; 7 class R2Object 8 { 9 public: 10 R2Object(); 12 11 13 public : 14 R2Object(); 15 protected : 12 int getRef(); 13 int ref(); 14 void unref(); 15 16 protected: 16 17 virtual ~R2Object(); 17 18 18 public : 19 R2int32 getRef(); 20 R2int32 ref(); 21 void unref(); 19 private: 20 /// reference count 21 int _refCount; 22 22 }; 23 23 24 inline R2int32R2Object::getRef()24 inline int R2Object::getRef() 25 25 { 26 26 return _refCount; 27 27 } 28 28 29 inline R2int32R2Object::ref()29 inline int R2Object::ref() 30 30 { 31 31 return ++_refCount; … … 40 40 } 41 41 42 43 42 #endif 44 43 -
trunk/packages/vizservers/nanovis/R2/include/R2/R2string.h
r2798 r2841 1 1 /* -*- 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 4 4 5 5 #include <R2/R2.h> 6 6 7 class R2string { 8 R2char* _string; 9 R2int32 _length; 7 class R2string 8 { 9 public: 10 R2string(); 10 11 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 17 16 ~R2string(); 18 17 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*(); 24 19 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 34 private: 35 void set(const char *string, int length); 36 37 char *_string; 38 int _length; 28 39 }; 29 40 30 41 inline R2string::operator char*() 31 42 { 32 43 return _string; 33 44 } 34 45 35 46 inline R2string::operator const char* () const 36 47 { 37 48 return _string; 38 49 } 39 50 40 inline R2int32R2string::getLength() const51 inline int R2string::getLength() const 41 52 { 42 53 return _length; 43 54 } 44 55 45 inline void R2string::set(const R2char* string, R2int32length)56 inline void R2string::set(const char* string, int length) 46 57 { 47 if (_string){48 49 50 58 if (_string) { 59 delete [] _string; 60 _string = NULL; 61 } 51 62 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 } 59 68 } 60 69 61 inline R2bool operator==(const R2string& string1, const char* string2)70 inline bool operator==(const R2string& string1, const char* string2) 62 71 { 63 72 return (!strcmp(string1._string, string2)); 64 73 } 65 74 66 #endif // __R2_STRING_H__75 #endif 67 76 -
trunk/packages/vizservers/nanovis/R2/include/R2/graphics/R2VertexBuffer.h
r2827 r2841 5 5 class R2VertexBuffer 6 6 { 7 unsigned int _graphicObjectID;8 int _byteSize;9 int _vertexCount;10 11 7 public: 12 void *_data;13 14 8 enum { 15 9 POSITION3 = 0x01, … … 19 13 }; 20 14 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 22 18 ~R2VertexBuffer(); 23 19 24 20 unsigned int getGraphicObjectID() const; 25 21 26 void updateBuffer(void* data); 22 void updateBuffer(void *data); 23 27 24 int getVertexCount() const; 25 26 void *_data; 27 28 private: 29 unsigned int _graphicObjectID; 30 int _byteSize; 31 int _vertexCount; 28 32 }; 29 33 30 34 inline int R2VertexBuffer::getVertexCount() const 31 35 { 32 36 return _vertexCount; 33 37 } 34 38 35 39 inline unsigned int R2VertexBuffer::getGraphicObjectID() const 36 40 { 37 41 return _graphicObjectID; 38 42 } 39 43 -
trunk/packages/vizservers/nanovis/R2/src/Makefile.in
r2094 r2841 25 25 VPATH = $(srcdir) 26 26 27 INCLUDES = -I$(srcdir)/../include 27 INCLUDES = -I$(srcdir)/../include -I$(srcdir)/../.. 28 28 29 29 CFLAGS = @CFLAGS@ -
trunk/packages/vizservers/nanovis/R2/src/R2FilePath.cpp
r2798 r2841 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <R2/R2FilePath.h>3 2 #include <string.h> 4 3 #ifdef _WIN32 … … 10 9 #include <unistd.h> 11 10 11 #include <R2/R2FilePath.h> 12 13 #include "Trace.h" 14 12 15 R2string R2FilePath::_curDirectory; 13 16 R2FilePath R2FilePath::_instance; 14 17 15 char seps[] 18 char seps[] = ":"; 16 19 17 20 R2FilePath::R2FilePath() 18 21 { 19 22 char buff[BUFSIZ+2]; 20 #ifdef WIN3223 #ifdef _WIN32 21 24 _getcwd(buff, 255); 22 25 #else 23 26 if (getcwd(buff, BUFSIZ) == NULL) { 24 fprintf(stderr,"can't get current working directory\n");27 ERROR("can't get current working directory\n"); 25 28 } 26 29 #endif … … 37 40 38 41 if (filePath == NULL) { 39 42 return false; 40 43 } 41 44 _pathList.clear(); … … 44 47 strcpy(buff, filePath); 45 48 for (p = strtok(buff, seps); p != NULL; p = strtok(NULL, seps)) { 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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 } 65 68 } 66 69 return true; 67 70 } 68 71 69 R2FilePath* R2FilePath::getInstance() 72 R2FilePath * 73 R2FilePath::getInstance() 70 74 { 71 75 return &_instance; … … 80 84 int nameLength = strlen(fileName); 81 85 for (iter = _pathList.begin(); iter != _pathList.end(); ++iter) { 82 86 char *path; 83 87 84 85 86 87 88 89 90 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; 91 95 } 92 96 return NULL; … … 100 104 strcpy(buff, argv[0]); 101 105 for (int i = strlen(buff) - 1; i >= 0; --i) { 102 103 104 105 106 106 if (buff[i] == '\\' || buff[i] == '/') { 107 buff[i] = '/'; 108 buff[i + 1] = '\0'; 109 break; 110 } 107 111 } 108 112 _curDirectory = buff; -
trunk/packages/vizservers/nanovis/R2/src/R2Fonts.cpp
r2840 r2841 26 26 27 27 void 28 R2Fonts::setFont(const char *fontName)28 R2Fonts::setFont(const char *fontName) 29 29 { 30 30 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 41 void 42 R2Fonts::addFont(const char *fontName, const char *fontFileName) 44 43 { 45 44 R2FontAttributes sFont; … … 51 50 52 51 void 53 R2Fonts::draw(const char *pString, ...) const52 R2Fonts::draw(const char *pString, ...) const 54 53 { 55 54 va_list vlArgs; 56 55 char szVargsBuffer[1024]; 57 56 58 57 va_start(vlArgs, pString); 59 58 vsprintf(szVargsBuffer, pString, vlArgs); 60 59 61 60 if (_fontIndex != -1) { 62 61 int length = strlen(szVargsBuffer); 63 62 64 63 glListBase(_fonts[_fontIndex]._displayLists); 65 64 glCallLists(length, GL_UNSIGNED_BYTE, … … 73 72 glEnable(GL_TEXTURE_2D); 74 73 glBindTexture(GL_TEXTURE_2D, _fonts[_fontIndex]. _fontTextureID); 75 74 76 75 glPushAttrib(GL_TRANSFORM_BIT | GL_ENABLE_BIT); 77 76 glMatrixMode(GL_PROJECTION); 78 77 glPushMatrix(); 79 78 80 79 glLoadIdentity( ); 81 80 gluOrtho2D(0.0f, _screenWidth, _screenHeight, 0.0f); 82 81 83 82 glMatrixMode(GL_MODELVIEW); 84 83 glPushMatrix( ); … … 109 108 attr._displayLists = glGenLists(256); 110 109 111 R2int32index;110 int index; 112 111 for (index = 0; index < 256; ++index) { 113 112 R2FontAttributes::R2CharInfo& charInfo = attr._chars[index]; … … 135 134 } 136 135 137 R2bool138 R2Fonts::loadFont(const char * fontName, const char*fontFileName,136 bool 137 R2Fonts::loadFont(const char *fontName, const char *fontFileName, 139 138 R2FontAttributes& sFont) 140 139 { 141 R2bool bSuccess = false;140 bool bSuccess = false; 142 141 143 142 const char *path = R2FilePath::getInstance()->getPath(fontFileName); 144 143 if (path == NULL) { 145 144 return false; 146 145 } 147 146 std::ifstream fsInput(path, std::ios::binary); … … 194 193 if (!fsInput.eof() && !fsInput.fail()) { 195 194 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); 198 197 199 198 // we've only read the luminance values, but we need a luminance + 200 199 // alpha buffer, so we make a new buffer and duplicate the 201 200 // 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; 204 203 for (unsigned int i = 0; i < uiArea; ++i) { 205 204 *pMap++ = pRawMap[i]; … … 234 233 235 234 void 236 R2Fonts::resize( R2int32 width, R2int32height)235 R2Fonts::resize(int width, int height) 237 236 { 238 237 _screenWidth = width; -
trunk/packages/vizservers/nanovis/R2/src/R2Geometry.cpp
r2840 r2841 5 5 #include <R2/graphics/R2Geometry.h> 6 6 7 R2Geometry::R2Geometry(int primitive, R2VertexBuffer *vertexBuffer,8 R2IndexBuffer *indexBuffer) :7 R2Geometry::R2Geometry(int primitive, R2VertexBuffer *vertexBuffer, 8 R2IndexBuffer *indexBuffer) : 9 9 _vertexBuffer(vertexBuffer), 10 10 _colorBuffer(0), … … 14 14 } 15 15 16 R2Geometry::R2Geometry(int primitive, R2VertexBuffer *vertexBuffer,17 R2VertexBuffer * colorBuffer, R2IndexBuffer*indexBuffer) :16 R2Geometry::R2Geometry(int primitive, R2VertexBuffer *vertexBuffer, 17 R2VertexBuffer *colorBuffer, R2IndexBuffer *indexBuffer) : 18 18 _vertexBuffer(vertexBuffer), 19 19 _colorBuffer(colorBuffer), … … 22 22 { 23 23 } 24 25 24 26 25 R2Geometry::~R2Geometry() … … 36 35 glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer->getGraphicObjectID()); 37 36 glVertexPointer(3, GL_FLOAT, 0, 0); 38 37 39 38 if (_colorBuffer) { 40 39 glEnableClientState(GL_COLOR_ARRAY); … … 45 44 } 46 45 glBindBuffer(GL_ARRAY_BUFFER, 0); 47 46 48 47 if (_indexBuffer) { 49 48 glDrawElements(GL_QUADS, _indexBuffer->getIndexCount(), GL_UNSIGNED_INT, … … 53 52 glDrawArrays(_primitiveType, 0, _vertexBuffer->getVertexCount()); 54 53 } 55 54 56 55 glDisableClientState(GL_VERTEX_ARRAY); 57 56 if (_colorBuffer) { -
trunk/packages/vizservers/nanovis/R2/src/R2IndexBuffer.cpp
r2840 r2841 5 5 #include <R2/graphics/R2IndexBuffer.h> 6 6 7 R2IndexBuffer::R2IndexBuffer(int indexCount, int* data, bool copy) 8 :_indexCount(indexCount)7 R2IndexBuffer::R2IndexBuffer(int indexCount, int* data, bool copy) : 8 _indexCount(indexCount) 9 9 { 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 } 19 16 } 20 21 17 22 18 R2IndexBuffer::~R2IndexBuffer() 23 19 { 24 if (_data) 25 { 26 free(_data); 27 } 20 if (_data) { 21 free(_data); 22 } 28 23 } -
trunk/packages/vizservers/nanovis/R2/src/R2VertexBuffer.cpp
r2840 r2841 8 8 #include <R2/graphics/R2VertexBuffer.h> 9 9 10 R2VertexBuffer::R2VertexBuffer(int type, int vertexCount, int byteSize, void* data, bool copy) 11 : _graphicObjectID(0), _byteSize(byteSize), _vertexCount(vertexCount) 10 R2VertexBuffer::R2VertexBuffer(int type, int vertexCount, 11 int byteSize, void *data, bool copy) : 12 _graphicObjectID(0), _byteSize(byteSize), _vertexCount(vertexCount) 12 13 { 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 } 21 19 22 23 20 glGenBuffers(1, &_graphicObjectID); 21 glBindBuffer(GL_ARRAY_BUFFER, _graphicObjectID); 24 22 glBufferData(GL_ARRAY_BUFFER, 25 26 27 23 _byteSize, 24 data, 25 GL_STATIC_DRAW); 28 26 glBindBuffer(GL_ARRAY_BUFFER, 0); 29 27 } … … 31 29 R2VertexBuffer::~R2VertexBuffer() 32 30 { 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 } 42 37 } -
trunk/packages/vizservers/nanovis/R2/src/R2string.cpp
r2840 r2841 10 10 } 11 11 12 R2string::R2string(const char* str) : _string(NULL), _length(0) 12 R2string::R2string(const char* str) : 13 _string(NULL), _length(0) 13 14 { 14 15 if (str != NULL) { 15 set(str, ( R2int32)strlen(str));16 set(str, (int)strlen(str)); 16 17 } 17 18 } 18 19 19 R2string::R2string(const R2string& string) : _string(NULL) 20 R2string::R2string(const R2string& string) : 21 _string(NULL) 20 22 { 21 23 set(string._string, string._length); … … 45 47 R2string ret; 46 48 ret._length = string1._length + string2._length; 47 ret._string = new R2char[ret._length + 1];49 ret._string = new char[ret._length + 1]; 48 50 49 51 strcpy(ret._string, string1._string); … … 58 60 R2string ret; 59 61 ret._length = string1._length + strlen(string2); 60 ret._string = new R2char[ret._length + 1];62 ret._string = new char[ret._length + 1]; 61 63 62 64 strcpy(ret._string, string1._string); -
trunk/packages/vizservers/nanovis/Trace.h
r2822 r2841 5 5 #include <GL/glew.h> 6 6 #include <syslog.h> 7 8 #include "config.h" 7 9 8 10 #define MAKE_STRING(x) #x -
trunk/packages/vizservers/nanovis/config.h
r2836 r2841 15 15 */ 16 16 17 #ifndef __CONFIG_H__18 #define __CONFIG_H__17 #ifndef CONFIG_H__ 18 #define CONFIG_H__ 19 19 20 20 #define NV40 /* Uncomment if using 6 series … … 25 25 //#define DO_RLE /* Do run length compression. */ 26 26 27 /* 28 * Controls if debug trace logging is enabled 29 */ 30 //#define WANT_TRACE 31 27 32 /* 28 33 * The following define controls whether new prototype features are to be … … 32 37 */ 33 38 #define PROTOTYPE 0 34 35 //#define USE_POINTSET_RENDERER36 39 37 40 /* -
trunk/packages/vizservers/nanovis/imgLoaders/Makefile.in
r951 r2841 24 24 VPATH = $(srcdir) 25 25 26 INCLUDES = -I$(srcdir) 26 INCLUDES = -I$(srcdir) -I$(srcdir)/.. 27 27 28 28 CFLAGS = @CFLAGS@ -
trunk/packages/vizservers/nanovis/vr3d/Makefile.in
r2094 r2841 25 25 VPATH = $(srcdir) 26 26 27 INCLUDES = -I$(srcdir)/include 27 INCLUDES = -I$(srcdir)/include -I$(srcdir)/.. 28 28 29 29 CFLAGS = @CFLAGS@ -
trunk/packages/vizservers/nanovis/vrmath/Makefile.in
r2094 r2841 25 25 VPATH = $(srcdir) 26 26 27 INCLUDES = -I$(srcdir)/include 27 INCLUDES = -I$(srcdir)/include -I$(srcdir)/.. 28 28 29 29 CFLAGS = @CFLAGS@ -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrBBox.h
r2840 r2841 7 7 #include <vrmath/vrMatrix4x4f.h> 8 8 9 class LmExportvrBBox9 class vrBBox 10 10 { 11 11 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrBPlane.h
r2840 r2841 14 14 #include <vrmath/vrLineSegment.h> 15 15 16 class LmExportvrBPlane16 class vrBPlane 17 17 { 18 18 public: 19 19 void makePts(const vrVector3f& pt1, const vrVector3f& pt2, const vrVector3f& pt3); 20 20 21 void makeNormalPt(const vrVector3f& norm, const vrVector3f& pos); 22 21 23 bool intersect(const vrLineSegment &seg, float &d) const; 24 22 25 float distance(const vrVector3f& point) const; 26 23 27 vrVector3f crossPoint(const vrVector3f& point) const; 24 28 -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrColor4f.h
r2840 r2841 5 5 #include <vrmath/vrLinmath.h> 6 6 7 class LmExportvrColor4f7 class vrColor4f 8 8 { 9 9 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrLineSegment.h
r2840 r2841 14 14 #include <vrmath/vrMatrix4x4f.h> 15 15 16 class LmExportvrLineSegment16 class vrLineSegment 17 17 { 18 18 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrLinmath.h
r2840 r2841 3 3 #define VRLINMATH_H 4 4 5 #ifdef _WIN326 //#include <windows.h>7 8 #ifdef LINMATHDLLEXPORT9 #define LmExport __declspec(dllexport)10 #define EXPIMP_TEMPLATE11 #else12 #define LmExport __declspec(dllimport)13 # define EXPIMP_TEMPLATE extern14 #endif15 16 #else17 #define LmExport18 #endif19 20 21 5 class vrVector3f; 22 6 23 extern vrVector3f LmExportvrCalcuNormal(const vrVector3f& v1, const vrVector3f& v2, const vrVector3f& v3);7 extern vrVector3f vrCalcuNormal(const vrVector3f& v1, const vrVector3f& v2, const vrVector3f& v3); 24 8 25 9 #ifdef __cplusplus … … 27 11 #endif 28 12 29 int LmExportvrUnproject(float winx, float winy, float winz,13 int vrUnproject(float winx, float winy, float winz, 30 14 const float modelMatrix[16], 31 15 const float projMatrix[16], … … 33 17 float *objx, float *objy, float *objz); 34 18 35 void LmExportvrPerspective(float fovy, float aspect, float zNear, float zFar, float* matrix);19 void vrPerspective(float fovy, float aspect, float zNear, float zFar, float* matrix); 36 20 37 21 #ifdef __cplusplus -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrMatrix4x4f.h
r2840 r2841 8 8 #include <memory.h> 9 9 10 class LmExportvrMatrix4x4f10 class vrMatrix4x4f 11 11 { 12 12 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrPlane.h
r2840 r2841 15 15 #include <vrmath/vrVector3f.h> 16 16 17 class LmExportvrPlane17 class vrPlane 18 18 { 19 19 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrPlane2.h
r2840 r2841 13 13 #include <vrmath/vrLineSegment.h> 14 14 15 class LmExportvrPlane215 class vrPlane2 16 16 { 17 17 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrProjection.h
r2840 r2841 7 7 #endif 8 8 9 LmExportint9 int 10 10 unproject(float winx, float winy, float winz, 11 11 const float modelMatrix[16], … … 14 14 float *objx, float *objy, float *objz); 15 15 16 LmExportvoid16 void 17 17 perspective(float fovy, float aspect, float zNear, float zFar, float *matrix); 18 18 -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrQuaternion.h
r2840 r2841 13 13 class vrRotation; 14 14 15 class LmExportvrQuaternion15 class vrQuaternion 16 16 { 17 17 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrRotation.h
r2840 r2841 8 8 class vrQuaternion; 9 9 10 class LmExportvrRotation10 class vrRotation 11 11 { 12 12 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrVector2f.h
r2840 r2841 8 8 #include <cmath> 9 9 10 class LmExportvrVector2f10 class vrVector2f 11 11 { 12 12 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrVector3f.h
r2840 r2841 10 10 class vrMatrix4x4f; 11 11 12 class LmExportvrVector3f12 class vrVector3f 13 13 { 14 14 public: -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrVector4f.h
r2840 r2841 9 9 class vrMatrix4x4f; 10 10 11 class LmExportvrVector4f11 class vrVector4f 12 12 { 13 13 public: -
trunk/packages/vizservers/nanovis/vrutil/Makefile.in
r2094 r2841 25 25 VPATH = $(srcdir) 26 26 27 INCLUDES = -I$(srcdir)/include 27 INCLUDES = -I$(srcdir)/include -I$(srcdir)/.. 28 28 29 29 CFLAGS = @CFLAGS@ -
trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrColorBrewer.h
r2798 r2841 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #pragma once 2 #ifndef VRCOLORBREWER_H 3 #define VRCOLORBREWER_H 3 4 4 5 #include <string> 6 5 7 #include <vrutil/vrUtil.h> 6 8 7 class VrUtilExport CBColor { 9 class CBColor 10 { 8 11 public : 9 12 float r, g, b; 10 13 }; 11 14 15 class vrColorBrewer 16 { 17 public: 18 vrColorBrewer(); 12 19 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]); 20 21 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; 28 31 }; 29 32 33 #endif 34 -
trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrColorBrewerFactory.h
r2798 r2841 1 1 /* -*- 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 7 4 8 5 #include <vector> 9 6 #include <string> 10 7 11 #define COLOR_SCHEME_START 3 8 #include <vrutil/vrUtil.h> 9 10 #define COLOR_SCHEME_START 3 12 11 #define COLOR_SCHEME_SEQ_END 9 13 12 #define COLOR_SCHEME_DIV_END 11 14 13 15 class vrColorBrewerFactory { 16 std::vector<vrColorBrewer*> colorList; 17 18 vrColorBrewer* _currentColorBrewer; 14 class vrColorBrewer; 19 15 20 static vrColorBrewerFactory* _instance; 21 protected : 22 vrColorBrewerFactory(); 23 public : 24 static vrColorBrewerFactory* getInstance(); 16 class vrColorBrewerFactory 17 { 18 public: 19 void loadColorBrewerList(); 25 20 26 public : 27 void loadColorBrewerList(); 28 int getColorMapCount() const; 21 int getColorMapCount() const; 29 22 30 vrColorBrewer*getColorMap(int id);23 vrColorBrewer *getColorMap(int id); 31 24 32 vrColorBrewer* chooseColorScheme(const std::string& scheme, int size); 25 vrColorBrewer *chooseColorScheme(const std::string& scheme, int size); 26 27 static vrColorBrewerFactory* getInstance(); 28 29 protected: 30 vrColorBrewerFactory(); 31 32 private: 33 std::vector<vrColorBrewer *> colorList; 34 vrColorBrewer *_currentColorBrewer; 35 36 static vrColorBrewerFactory *_instance; 33 37 }; 34 38 35 39 inline vrColorBrewer* vrColorBrewerFactory::getColorMap(int id) 36 40 { 37 41 return colorList[id]; 38 42 } 39 43 40 44 inline int vrColorBrewerFactory::getColorMapCount() const 41 45 { 42 46 return (int) colorList.size(); 43 47 } 48 49 #endif -
trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrFilePath.h
r2798 r2841 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #pragma once 2 #ifndef VRFILEPATH_H 3 #define VRFILEPATH_H 3 4 4 5 #include <vrutil/vrUtil.h> … … 6 7 #include <list> 7 8 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); 9 class vrFilePath 10 { 11 public: 12 vrFilePath(); 48 13 49 14 /** 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 "" 51 18 */ 52 void setWorkingDirectory(int argc, const char** argv); 53 public : 19 std::string getPath(const char *fileName); 54 20 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); 59 26 27 void setWorkingDirectory(int argc, const char **argv); 28 29 /// get vrFilePath instance 30 static vrFilePath* getInstance(); 31 32 private: 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; 60 44 }; 61 45 62 46 #endif -
trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrLock.h
r2798 r2841 1 1 /* -*- 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> 3 6 4 7 #include <vrutil/vrUtil.h> 5 8 6 #ifndef IPHONE 9 class vrLock 10 { 11 public: 12 vrLock(); 13 ~vrLock(); 7 14 8 #include <pthread.h> 15 void lock(); 16 void unlock(); 9 17 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(); 18 private: 19 pthread_mutex_t _mutex; 20 pthread_mutexattr_t _attr; 20 21 }; 21 22 22 23 inline void vrLock::lock() 23 24 { 24 25 pthread_mutex_lock(&_mutex); 25 26 } 26 27 27 28 inline void vrLock::unlock() 28 29 { 29 30 pthread_mutex_unlock(&_mutex); 30 31 } 31 32 -
trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrStringParser.h
r2798 r2841 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #pragma once 2 #ifndef VRSTRINGPARSER_H 3 #define VRSTRINGPARSER_H 3 4 4 5 #include <string> 5 6 #include <iostream> 7 6 8 #include <vrutil/vrUtil.h> 7 9 8 class VrUtilExport vrStringParser {9 std::string _whitechars; 10 std::istream& _stream; 11 char _buff[256];10 class vrStringParser 11 { 12 public: 13 vrStringParser(std::istream& stream); 12 14 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(); 20 16 17 void ungetToken(); 18 19 bool isWhiteChar(char ch); 20 21 void setWhiteCharacters(const std::string& whitechars); 22 23 char *getBuffer(); 24 25 private: 26 std::string _whitechars; 27 std::istream& _stream; 28 char _buff[256]; 21 29 }; 22 30 23 inline char *vrStringParser::getBuffer()31 inline char *vrStringParser::getBuffer() 24 32 { 25 33 return _buff; 26 34 } 27 35 28 36 inline void vrStringParser::setWhiteCharacters(const std::string& whitechars) 29 37 { 30 38 _whitechars = whitechars; 31 39 } 32 40 33 41 inline bool vrStringParser::isWhiteChar(char ch) 34 42 { 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 } 39 46 40 47 return false; 41 48 } 42 49 50 #endif 51 -
trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrThread.h
r2798 r2841 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #pragma once 2 #ifndef VRTHREAD_H 3 #define VRTHREAD_H 3 4 4 #ifndef IPHONE5 6 #ifdef WIN327 #include <pthread/pthread.h>8 #else9 5 #include <pthread.h> 10 #endif11 6 12 7 #include <vrutil/vrUtil.h> 13 8 14 class VrUtilExport vrThread {15 pthread_t _thread; 16 pthread_attr_t _attr; 17 int _threadID;9 class vrThread 10 { 11 public: 12 vrThread(); 18 13 19 public : 20 vrThread(); 21 virtual ~vrThread(); 14 virtual ~vrThread(); 22 15 23 private : 24 static void* threadMain(void* data); 25 public : 26 void initialize(); 16 void initialize(); 27 17 28 public : 29 virtual void run(); 18 virtual void run(); 19 20 private: 21 static void *threadMain(void *data); 22 23 pthread_t _thread; 24 pthread_attr_t _attr; 25 int _threadID; 30 26 }; 31 27 -
trunk/packages/vizservers/nanovis/vrutil/include/vrutil/vrUtil.h
r2798 r2841 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #pragma once 2 #ifndef VRUTIL_H 3 #define VRUTIL_H 3 4 4 #ifdef WIN325 #pragma pointers_to_members(full_generality, single_inheritance)6 5 #endif 7 8 #ifdef _WIN329 //#include <windows.h>10 11 #ifdef VRUTILDLLEXPORT12 # define VrUtilExport __declspec(dllexport)13 #else14 # define VrUtilExport __declspec(dllimport)15 #endif16 17 #else18 # define VrUtilExport19 #endif20 -
trunk/packages/vizservers/nanovis/vrutil/vrFilePath.cpp
r2798 r2841 3 3 4 4 #ifdef _WIN32 5 #pragma warning (disable : 4996)5 #pragma warning (disable : 4996) 6 6 #endif 7 7 … … 17 17 vrFilePath vrFilePath::_instance; 18 18 19 static char seps[] 19 static char seps[] = ";"; 20 20 vrFilePath::vrFilePath() 21 21 { 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 } 28 27 #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 } 33 31 #endif 34 32 35 36 37 33 size_t length = strlen(buff); 34 buff[length] = '/'; 35 buff[length + 1] = '\0'; 38 36 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; 45 42 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 } 55 50 56 57 58 59 51 strcpy(buff, path); 52 strcpy(buff + strlen(path), "/resources/"); 53 _pathList.push_back(buff); 54 } 60 55 } 61 56 62 57 void vrFilePath::setPath(const std::string& filePath) 63 58 { 64 59 char buff[255]; 65 60 66 61 _pathList.clear(); 67 62 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 } 78 71 72 strcpy(buff + strlen(path), "/resources/"); 73 _pathList.push_back(buff); 74 } 79 75 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 ); 83 79 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 } 120 99 } 121 100 122 vrFilePath *vrFilePath::getInstance()101 vrFilePath *vrFilePath::getInstance() 123 102 { 124 103 return &_instance; 125 104 } 126 105 127 106 std::string vrFilePath::getPath(const char* fileName) 128 107 { 129 130 FILE*file;108 std::string path; 109 FILE *file; 131 110 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 } 140 117 #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 } 145 140 #endif 146 141 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; 171 143 } 172 144 173 void vrFilePath::setWorkingDirectory(int argc, const char **argv)145 void vrFilePath::setWorkingDirectory(int argc, const char **argv) 174 146 { 175 147 char buff[255]; 176 148 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] == '/') { 181 151 buff[i] = '/'; 182 152 buff[i + 1] = '\0'; … … 185 155 } 186 156 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; 193 162 } 194 -
trunk/packages/vizservers/nanovis/vrutil/vrStringParser.cpp
r2798 r2841 2 2 #include <vrutil/vrStringParser.h> 3 3 4 vrStringParser::vrStringParser(std::istream& stream) 5 :_stream(stream)4 vrStringParser::vrStringParser(std::istream& stream) : 5 _stream(stream) 6 6 { 7 7 } … … 9 9 int vrStringParser::getToken() 10 10 { 11 12 13 11 int index = 0; 12 char ch = 0; 13 if (_stream.eof()) return 0; 14 14 15 while(!_stream.eof() && isWhiteChar(ch = _stream.get()));16 15 while (!_stream.eof() && isWhiteChar(ch = _stream.get())); 16 if (ch == 0 || isWhiteChar(ch)) return 0; 17 17 18 19 20 18 do { 19 _buff[index++] = ch; 20 } while (!_stream.eof() && !isWhiteChar(ch = _stream.get())); 21 21 22 22 _buff[index] = 0; 23 23 24 24 return index; 25 25 }
Note: See TracChangeset
for help on using the changeset viewer.