Changeset 2822 for trunk/packages/vizservers
- Timestamp:
- Mar 7, 2012, 12:21:30 PM (13 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 2 deleted
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Axis.h
r2798 r2822 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef _AXIS_H3 #define _AXIS_H2 #ifndef AXIS_H 3 #define AXIS_H 4 4 5 5 #include "Chain.h" … … 7 7 class Axis; 8 8 9 class NaN { 9 class NaN 10 { 10 11 private: 11 double x_;12 double _x; 12 13 public: 13 NaN(void) { 14 NaN() 15 { 14 16 union DoubleValue { 15 17 unsigned int words[2]; 16 18 double value; 17 19 } result; 18 20 19 21 #ifdef WORDS_BIGENDIAN 20 22 result.words[0] = 0x7ff80000; … … 24 26 result.words[1] = 0x7ff80000; 25 27 #endif 26 x_ = result.value; 27 } 28 operator const double() { 29 return x_; 28 _x = result.value; 29 } 30 31 operator double() const 32 { 33 return _x; 30 34 } 31 35 }; … … 143 147 void Append (float x) { 144 148 chain_.Append(GetClientData(x)); 145 } 149 } 146 150 void SetValues(double initial, double step, unsigned int nSteps) { 147 151 initial_ = initial, step_ = step, nSteps_ = nSteps; … … 346 350 }; 347 351 348 #endif /*_AXIS_H*/352 #endif -
trunk/packages/vizservers/nanovis/AxisRange.h
r2798 r2822 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef _AXIS_RANGE_H3 #define _AXIS_RANGE_H2 #ifndef AXIS_RANGE_H 3 #define AXIS_RANGE_H 4 4 5 5 #include <string.h> … … 50 50 }; 51 51 52 #endif /*_AXIS_RANGE_H*/52 #endif -
trunk/packages/vizservers/nanovis/BucketSort.h
r2798 r2822 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __BUCKETSORT_H_3 #define __BUCKETSORT_H_2 #ifndef BUCKETSORT_H 3 #define BUCKETSORT_H 4 4 5 5 #include <vector> … … 13 13 class ClusterList { 14 14 public : 15 16 15 Cluster* data; 16 ClusterList* next; 17 17 public : 18 ClusterList(Cluster* d, ClusterList* n) 19 :data(d), next(n)20 18 ClusterList(Cluster *d, ClusterList *n) : 19 data(d), next(n) 20 {} 21 21 22 ClusterList() 23 :data(0), next(0)24 22 ClusterList() : 23 data(0), next(0) 24 {} 25 25 26 27 28 29 26 ~ClusterList() 27 { 28 //if (next) delete next; 29 } 30 30 }; 31 31 32 32 class BucketSort { 33 ClusterList**_buffer;34 35 33 ClusterList **_buffer; 34 int _size; 35 int _count; 36 36 37 int _memChuckSize; 38 bool _memChunckUsedFlag; 39 ClusterList* _memChunck; 40 41 float _invMaxLength; 42 private : 43 //void _sort(Cluster* cluster, const Matrix4& cameraMat, int level); 44 void _sort(Cluster* cluster, const Mat4x4& cameraMat, int level); 45 public : 46 BucketSort(int maxSize) 47 { 48 _size = maxSize; 49 _buffer = new ClusterList*[maxSize]; 50 memset(_buffer, 0, _size * sizeof(ClusterList*)); 37 int _memChuckSize; 38 bool _memChunckUsedFlag; 39 ClusterList *_memChunck; 51 40 52 _memChuckSize = 1000000; 53 _memChunck = new ClusterList[_memChuckSize]; 41 float _invMaxLength; 42 private: 43 void _sort(Cluster *cluster, const Mat4x4& cameraMat, int level); 44 public: 45 BucketSort(int maxSize) 46 { 47 _size = maxSize; 48 _buffer = new ClusterList*[maxSize]; 49 memset(_buffer, 0, _size * sizeof(ClusterList*)); 54 50 55 _invMaxLength = 1.0f / 4.0f;56 } 51 _memChuckSize = 1000000; 52 _memChunck = new ClusterList[_memChuckSize]; 57 53 58 ~BucketSort() 59 { 60 delete [] _buffer; 61 delete [] _memChunck; 62 } 54 _invMaxLength = 1.0f / 4.0f; 55 } 63 56 64 int getSize() const { return _size; } 65 int getSortedItemCount() const { return _count; } 66 void init(); 67 //void sort(ClusterAccel* cluster, const Matrix4& cameraMat, float maxLength); 68 //void sort(ClusterAccel* cluster, const Matrix4& cameraMat, int level); 69 void sort(ClusterAccel* cluster, const Mat4x4& cameraMat, int level); 70 void addBucket(Cluster* cluster, float ratio); 71 ClusterList** getBucket() { return _buffer; } 57 ~BucketSort() 58 { 59 delete [] _buffer; 60 delete [] _memChunck; 61 } 62 63 int getSize() const 64 { return _size; } 65 66 int getSortedItemCount() const 67 { return _count; } 68 69 void init(); 70 71 void sort(ClusterAccel* cluster, const Mat4x4& cameraMat, int level); 72 73 void addBucket(Cluster* cluster, float ratio); 74 75 ClusterList **getBucket() 76 { return _buffer; } 72 77 }; 73 78 -
trunk/packages/vizservers/nanovis/Command.cpp
r2821 r2822 56 56 #include "nanovis.h" 57 57 #include "CmdProc.h" 58 #include "Nv.h"59 58 #include "PointSetRenderer.h" 60 59 #include "PointSet.h" -
trunk/packages/vizservers/nanovis/ConvexPolygon.cpp
r2798 r2822 14 14 * ====================================================================== 15 15 */ 16 #include <assert.h> 17 18 #include <GL/gl.h> 19 16 20 #include "ConvexPolygon.h" 17 21 #include "Trace.h" 18 #include <GL/gl.h> 19 #include <assert.h> 20 21 ConvexPolygon::ConvexPolygon(){} 22 23 ConvexPolygon::ConvexPolygon(VertexVector newvertices){ 22 23 ConvexPolygon::ConvexPolygon(VertexVector newvertices) 24 { 24 25 vertices.insert(vertices.begin(), newvertices.begin(), newvertices.end()); 25 26 } … … 34 35 // http://astronomy.swin.edu.au/pbourke/geometry/planeline/ 35 36 bool 36 findIntersection(Vector4 p1, Vector4 p2, Vector4 plane, Vector4 &ret){ 37 findIntersection(const Vector4& pt1, const Vector4& pt2, const Vector4& plane, Vector4& ret) 38 { 37 39 float a = plane.x; 38 40 float b = plane.y; … … 40 42 float d = plane.w; 41 43 42 p1.perspective_devide(); 44 Vector4 p1 = pt1; 45 p1.perspective_divide(); 43 46 float x1 = p1.x; 44 47 float y1 = p1.y; 45 48 float z1 = p1.z; 46 49 47 p2.perspective_devide(); 50 Vector4 p2 = pt2; 51 p2.perspective_divide(); 48 52 float x2 = p2.x; 49 53 float y2 = p2.y; … … 57 61 ERROR("Unexpected code path: ConvexPolygon.cpp\n"); 58 62 if (uNumer == 0){ 59 for (int i = 0; i < 4; i++) 60 ret < p1; 63 ret = p1; 61 64 return true; 62 65 } … … 72 75 } 73 76 74 void 75 ConvexPolygon::transform(Mat4x4 mat){ 77 void 78 ConvexPolygon::transform(const Mat4x4& mat) 79 { 76 80 VertexVector tmp = vertices; 77 81 vertices.clear(); … … 83 87 } 84 88 85 86 void 87 ConvexPolygon::translate(Vector4 shift){89 void 90 ConvexPolygon::translate(const Vector4& shift) 91 { 88 92 VertexVector tmp = vertices; 89 93 vertices.clear(); … … 95 99 } 96 100 97 void 98 ConvexPolygon::clip(Plane &clipPlane, bool copy_to_texcoord) { 101 void 102 ConvexPolygon::clip(Plane& clipPlane, bool copy_to_texcoord) 103 { 99 104 if (vertices.size() == 0) { 100 105 //ERROR("ConvexPolygon: polygon has no vertices\n"); … … 149 154 clippedVerts.end()); 150 155 151 if (copy_to_texcoord)156 if (copy_to_texcoord) 152 157 copy_vertices_to_texcoords(); 153 158 } 154 159 155 void 156 ConvexPolygon::copy_vertices_to_texcoords(){ 157 if(texcoords.size()>0) 160 void 161 ConvexPolygon::copy_vertices_to_texcoords() 162 { 163 if (texcoords.size() > 0) 158 164 texcoords.clear(); 159 165 160 for (unsigned int i =0; i<vertices.size(); i++) {166 for (unsigned int i = 0; i < vertices.size(); i++) { 161 167 texcoords.push_back(vertices[i]); 162 168 } 163 169 } 164 170 165 void 166 ConvexPolygon::Emit(bool use_texture) 171 void 172 ConvexPolygon::Emit(bool use_texture) 167 173 { 168 174 if (vertices.size() >= 3) { 169 for (unsigned int i = 0; i <vertices.size(); i++) {175 for (unsigned int i = 0; i < vertices.size(); i++) { 170 176 if(use_texture) { 171 177 glTexCoord4fv((float *)&(texcoords[i])); … … 177 183 } 178 184 179 180 185 void 181 ConvexPolygon::Emit(bool use_texture, Vector3& shift,Vector3& scale)186 ConvexPolygon::Emit(bool use_texture, const Vector3& shift, const Vector3& scale) 182 187 { 183 188 if (vertices.size() >= 3) { 184 for (unsigned int i = 0; i <vertices.size(); i++) {185 if (use_texture) {189 for (unsigned int i = 0; i < vertices.size(); i++) { 190 if (use_texture) { 186 191 glTexCoord4fv((float *)&(vertices[i])); 187 192 } -
trunk/packages/vizservers/nanovis/ConvexPolygon.h
r2798 r2822 17 17 #define _CONVEX_POLYGON_H_ 18 18 19 #include <assert.h> 20 #include <vector> 21 19 22 #include "Vector4.h" 20 23 #include "Plane.h" 21 #include <assert.h>22 #include <vector>23 24 24 25 typedef std::vector<Vector4> VertexVector; 25 26 typedef std::vector<Vector4> TexVector; 26 27 27 class ConvexPolygon { 28 class ConvexPolygon 29 { 28 30 public: 29 31 VertexVector vertices; 30 32 TexVector texcoords; 31 33 int volume_id; //which volume this polygon slice belongs to 32 33 ConvexPolygon(); 34 35 ConvexPolygon() 36 {} 37 34 38 ConvexPolygon(VertexVector vertices); 35 36 void transform(Mat4x4 mat); 37 void translate(Vector4 shift); 38 39 40 void transform(const Mat4x4& mat); 41 42 void translate(const Vector4& shift); 43 39 44 // Clips the polygon, retaining the portion where ax + by + cz + d >= 0 40 void clip(Plane &clipPlane, bool copy_to_texcoords); 45 void clip(Plane& clipPlane, bool copy_to_texcoords); 46 41 47 void Emit(bool use_texture); 42 void Emit(bool use_texture, Vector3& shift, Vector3& scale); 48 49 void Emit(bool use_texture, const Vector3& shift, const Vector3& scale); 50 43 51 void copy_vertices_to_texcoords(); 44 52 45 void set_id(int v_id) { 46 volume_id = v_id; 47 }; 48 void append_vertex(Vector4 vert) { 49 vertices.push_back(vert); 53 void set_id(int v_id) 54 { 55 volume_id = v_id; 50 56 } 51 void insert_vertex(unsigned int index, Vector4 vert) { 52 assert(index<vertices.size()); 53 vertices.insert(vertices.begin() + index, vert); 57 58 void append_vertex(const Vector4& vert) 59 { 60 vertices.push_back(vert); 54 61 } 55 bool is_retained(Vector4 point, Vector4 plane) { 56 return ((point * plane) >= 0); 62 63 void insert_vertex(unsigned int index, const Vector4& vert) 64 { 65 assert(index<vertices.size()); 66 vertices.insert(vertices.begin() + index, vert); 67 } 68 69 bool is_retained(const Vector4& point, const Vector4& plane) 70 { 71 return ((point * plane) >= 0); 57 72 } 58 73 }; -
trunk/packages/vizservers/nanovis/EventPlayer.cpp
r2800 r2822 25 25 26 26 #include "clientlib.h" 27 #include " ../Event.h"27 #include "Event.h" 28 28 29 29 Event* event[300]; … … 41 41 void display() 42 42 { 43 //paste to screen44 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);45 glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);46 glFlush();47 glutSwapBuffers();48 return;43 //paste to screen 44 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 45 glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer); 46 glFlush(); 47 glutSwapBuffers(); 48 return; 49 49 } 50 50 */ 51 51 52 53 52 void key(unsigned char key, int x, int y) 54 53 { 55 switch (key) 56 { 57 case 'q': 58 exit(0); 59 break; 60 default: 61 return; 62 } 63 } 64 54 switch (key) { 55 case 'q': 56 exit(0); 57 break; 58 default: 59 return; 60 } 61 } 65 62 66 63 /* … … 69 66 void idle(void) 70 67 { 71 //send requests72 73 if (cur_event >= sizeof(event)/sizeof(event[0])) {74 float ave = interval_sum / (cur_event-1);75 float fps = 1/ave;76 TRACE("Average frame time = %.6f\n", ave);77 TRACE("Frames per second = %f\n", fps);78 exit(0);79 }80 81 Event*cur = event[cur_event];82 std::stringstream msgstream;83 std::string msg;84 85 switch(cur->type){68 //send requests 69 70 if (cur_event >= (int)(sizeof(event)/sizeof(event[0]))) { 71 float ave = interval_sum / (cur_event-1); 72 float fps = 1/ave; 73 TRACE("Average frame time = %.6f\n", ave); 74 TRACE("Frames per second = %f\n", fps); 75 exit(0); 76 } 77 78 Event *cur = event[cur_event]; 79 std::stringstream msgstream; 80 std::string msg; 81 82 switch (cur->type){ 86 83 case 0: //rotate 87 msgstream << "camera " << cur->parameter[0] << " " 88 << cur->parameter[1] << " " 89 << cur->parameter[2] << " " << endl; 90 break; 91 84 msgstream << "camera " << cur->parameter[0] << " " 85 << cur->parameter[1] << " " 86 << cur->parameter[2] << " " << endl; 87 break; 92 88 case 1: //move 93 msgstream << "move " << cur->parameter[0] << " " 94 << cur->parameter[1] << " " 95 << cur->parameter[2] << " " << endl; 96 break; 97 89 msgstream << "move " << cur->parameter[0] << " " 90 << cur->parameter[1] << " " 91 << cur->parameter[2] << " " << endl; 92 break; 98 93 case 2: //other 99 msgstream << "refresh " << cur->parameter[0] << " " 100 << cur->parameter[1] << " " 101 << cur->parameter[2] << " " << endl; 102 break; 103 94 msgstream << "refresh " << cur->parameter[0] << " " 95 << cur->parameter[1] << " " 96 << cur->parameter[2] << " " << endl; 97 break; 104 98 default: 105 return;106 }107 108 msg = msgstream.str();109 110 //sleep a little111 struct timespec ts;112 ts.tv_sec = 0;113 ts.tv_nsec = cur->msec*1000000000;114 nanosleep(&ts, 0);99 return; 100 } 101 102 msg = msgstream.str(); 103 104 //sleep a little 105 struct timespec ts; 106 ts.tv_sec = 0; 107 ts.tv_nsec = cur->msec*1000000000; 108 nanosleep(&ts, 0); 115 109 116 //start timer117 struct timeval clock;118 gettimeofday(&clock, NULL);119 double start_time = clock.tv_sec + clock.tv_usec/1000000.0;120 121 //send msg122 //TRACE("Writing message %04d to server: '%s'\n", cur_event, msg.c_str());123 int status = write(socket_fd, msg.c_str(), strlen(msg.c_str()));124 if (status <= 0) {125 perror("socket write");126 return;127 }110 //start timer 111 struct timeval clock; 112 gettimeofday(&clock, NULL); 113 double start_time = clock.tv_sec + clock.tv_usec/1000000.0; 114 115 //send msg 116 //TRACE("Writing message %04d to server: '%s'\n", cur_event, msg.c_str()); 117 int status = write(socket_fd, msg.c_str(), strlen(msg.c_str())); 118 if (status <= 0) { 119 perror("socket write"); 120 return; 121 } 128 122 129 123 #if DO_RLE 130 int sizes[2];131 status = read(socket_fd, &sizes, sizeof(sizes));132 TRACE("Reading %d,%d bytes\n", sizes[0], sizes[1]);133 int len = sizes[0] + sizes[1];124 int sizes[2]; 125 status = read(socket_fd, &sizes, sizeof(sizes)); 126 TRACE("Reading %d,%d bytes\n", sizes[0], sizes[1]); 127 int len = sizes[0] + sizes[1]; 134 128 #else 135 int len = width * height * 3;129 int len = width * height * 3; 136 130 #endif 137 131 138 //receive screen update 139 int remain = len; 140 char* ptr = screen_buffer; 141 while(remain>0){ 142 status = read(socket_fd, ptr, remain); 143 if(status <= 0) { 144 perror("socket read"); 145 return; 146 } 147 else { 148 remain -= status; 149 ptr += status; 150 } 151 } 152 153 //TRACE("Read message to server.\n"); 154 155 //end timer 156 gettimeofday(&clock, NULL); 157 double end_time = clock.tv_sec + clock.tv_usec/1000000.0; 158 159 double time_interval = end_time - start_time; 160 161 if (cur_event != 0) { 162 interval_sum += time_interval; 163 } 164 cur_event++; 165 166 TRACE("% 6d %.6f\n", len, time_interval); 167 } 168 132 //receive screen update 133 int remain = len; 134 char* ptr = screen_buffer; 135 while (remain > 0) { 136 status = read(socket_fd, ptr, remain); 137 if (status <= 0) { 138 perror("socket read"); 139 return; 140 } else { 141 remain -= status; 142 ptr += status; 143 } 144 } 145 146 //TRACE("Read message to server.\n"); 147 148 //end timer 149 gettimeofday(&clock, NULL); 150 double end_time = clock.tv_sec + clock.tv_usec/1000000.0; 151 152 double time_interval = end_time - start_time; 153 154 if (cur_event != 0) { 155 interval_sum += time_interval; 156 } 157 cur_event++; 158 159 TRACE("% 6d %.6f\n", len, time_interval); 160 } 169 161 170 162 int init_client(char* host, char* port, char* file){ 171 163 172 //load the event file173 FILE* fd = fopen(file, "r");174 175 //load events176 for(int i=0; i<sizeof(event)/sizeof(event[0]); i++){177 int type;178 float param[3];179 double interval;180 fscanf(fd, "%d %f %f %f %g\n", &type, param, param+1, param+2, &interval);181 event[i] = new Event(type, param, interval);182 TRACE("%d %f %f %f\n", type, param[0], param[1], param[2]);183 }184 fclose(fd);185 186 socket_fd = connect_renderer(host, atoi(port), 100);187 if (socket_fd == -1) {188 ERROR("Could not connect to a server.\n");189 return 1;190 }191 192 return 0;164 //load the event file 165 FILE* fd = fopen(file, "r"); 166 167 //load events 168 for (int i = 0; i < (int)(sizeof(event)/sizeof(event[0])); i++) { 169 int type; 170 float param[3]; 171 double interval; 172 fscanf(fd, "%d %f %f %f %lf\n", &type, param, param+1, param+2, &interval); 173 event[i] = new Event(type, param, interval); 174 TRACE("%d %f %f %f\n", type, param[0], param[1], param[2]); 175 } 176 fclose(fd); 177 178 socket_fd = connect_renderer(host, atoi(port), 100); 179 if (socket_fd == -1) { 180 ERROR("Could not connect to a server.\n"); 181 return 1; 182 } 183 184 return 0; 193 185 } 194 186 … … 205 197 { 206 198 //parameters: host and port and event file 207 if(argc!=4) help(argv[0]); 199 if (argc != 4) 200 help(argv[0]); 208 201 209 202 assert(init_client(argv[1], argv[2], argv[3])==0); 210 203 211 /* 212 glutInit(&argc, argv); 213 glutInitWindowSize(width,height); 214 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); 215 216 glutCreateWindow("Client"); 217 218 glutDisplayFunc(display); 219 glutKeyboardFunc(key); 220 glutIdleFunc(idle); 221 222 glClearColor(0.,0.,0.,0.); 223 glutMainLoop(); 224 */ 225 while(1) idle(); 204 /* 205 glutInit(&argc, argv); 206 glutInitWindowSize(width,height); 207 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); 208 209 glutCreateWindow("Client"); 210 211 glutDisplayFunc(display); 212 glutKeyboardFunc(key); 213 glutIdleFunc(idle); 214 215 glClearColor(0.,0.,0.,0.); 216 glutMainLoop(); 217 */ 218 while (1) 219 idle(); 226 220 227 221 return 0; 228 222 } 229 -
trunk/packages/vizservers/nanovis/FlowCmd.cpp
r2810 r2822 25 25 #include "nanovis.h" 26 26 #include "CmdProc.h" 27 #include "Nv.h"28 27 29 28 #include "NvLIC.h" -
trunk/packages/vizservers/nanovis/Makefile.in
r2820 r2822 101 101 CXX = @CXX@ 102 102 CFLAGS = @CFLAGS@ 103 EXTRA_CFLAGS = -Wall 103 EXTRA_CFLAGS = -Wall -Wextra 104 104 DEFINES = 105 105 CXX_SWITCHES = $(CFLAGS) $(EXTRA_CFLAGS) $(DEFINES) $(INCLUDES) … … 121 121 HeightMap.o \ 122 122 Mat4x4.o \ 123 Nv.o \124 123 NvCamera.o \ 125 124 NvColorTableRenderer.o \ … … 282 281 $(MAKE) -C $(R2_DIR)/src clean 283 282 $(MAKE) -C $(IMG_DIR) clean 284 $(RM) nanovis client $(OBJS)283 $(RM) nanovis client *.o 285 284 286 285 distclean: clean … … 300 299 Command.o: Command.cpp 301 300 ContourLineFilter.o: ContourLineFilter.cpp ContourLineFilter.h 302 ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h 301 ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h Vector4.h Mat4x4.h Plane.h 303 302 DataLoader.o: DataLoader.cpp 304 303 Event.o: Event.cpp Event.h 305 FlowCmd.o: FlowCmd.cpp FlowCmd.h Switch.h Trace.h TransferFunction.h nanovis.h CmdProc.h Nv .h NvLIC.h Unirect.h304 FlowCmd.o: FlowCmd.cpp FlowCmd.h Switch.h Trace.h TransferFunction.h nanovis.h CmdProc.h NvLIC.h Unirect.h 306 305 GradientFilter.o: GradientFilter.cpp GradientFilter.h 307 306 Grid.o: Grid.cpp Grid.h 308 307 HeightMap.o: HeightMap.cpp HeightMap.h 309 308 Mat4x4.o: Mat4x4.cpp Mat4x4.h 310 Nv.o: Nv.cpp Nv.h NvShader.h NvParticleRenderer.h NvColorTableRenderer.h NvEventLog.h VolumeRenderer.h PointSetRenderer.h311 309 NvCamera.o: NvCamera.cpp NvCamera.h 312 310 NvColorTableRenderer.o: NvColorTableRenderer.cpp NvColorTableRenderer.h … … 330 328 PCASplit.o: PCASplit.cpp PCASplit.h 331 329 PerfQuery.o: PerfQuery.cpp PerfQuery.h 332 Plane.o: Plane.cpp Plane.h 330 Plane.o: Plane.cpp Plane.h Vector4.h Mat4x4.h 333 331 PlaneRenderer.o: PlaneRenderer.cpp PlaneRenderer.h 334 332 PointSet.o: PointSet.cpp PointSet.h … … 353 351 VolumeRenderer.o: VolumeRenderer.cpp VolumeRenderer.h 354 352 ZincBlendeVolume.o: ZincBlendeVolume.cpp ZincBlendeVolume.h $(AUXSRC) 355 dxReader.o: dxReader.cpp dxReaderCommon.h Nv.hnanovis.h Unirect.h ZincBlendeVolume.h NvZincBlendeReconstructor.h353 dxReader.o: dxReader.cpp dxReaderCommon.h nanovis.h Unirect.h ZincBlendeVolume.h NvZincBlendeReconstructor.h 356 354 dxReaderCommon.o: dxReaderCommon.cpp dxReaderCommon.h GradientFilter.h Vector3.h 357 355 nanovis.o: nanovis.cpp nanovis.h $(AUXSRC) -
trunk/packages/vizservers/nanovis/Mat4x4.cpp
r2798 r2822 14 14 * ====================================================================== 15 15 */ 16 #include <math.h> 17 16 18 #include "Mat4x4.h" 17 #include <math.h>18 #include <stdio.h>19 #include <assert.h>20 19 21 Mat4x4::Mat4x4(float *vals) { 22 int i; 23 for (i=0;i<16;i++) 24 m[i] = vals[i]; 20 Mat4x4::Mat4x4(float *vals) 21 { 22 for (int i = 0; i < 16; i++) { 23 m[i] = vals[i]; 24 } 25 25 } 26 26 27 void 28 Mat4x4::print(){ 29 TRACE("\n%f %f %f %f\n", m[0], m[1], m[2], m[3]); 27 void 28 Mat4x4::print() const 29 { 30 TRACE("%f %f %f %f\n", m[0], m[1], m[2], m[3]); 30 31 TRACE("%f %f %f %f\n", m[4], m[5], m[6], m[7]); 31 32 TRACE("%f %f %f %f\n", m[8], m[9], m[10], m[11]); 32 TRACE("%f %f %f %f\n \n", m[12], m[13], m[14], m[15]);33 TRACE("%f %f %f %f\n", m[12], m[13], m[14], m[15]); 33 34 } 34 35 35 Mat4x4 36 Mat4x4::inverse(){ 36 Mat4x4 37 Mat4x4::inverse() const 38 { 37 39 Mat4x4 p; 38 40 39 41 float m00 = m[0], m01 = m[4], m02 = m[8], m03 = m[12]; 40 42 float m10 = m[1], m11 = m[5], m12 = m[9], m13 = m[13]; … … 51 53 float cof02 = det33(m13, m10, m11, m23, m20, m21, m33, m30, m31); 52 54 float cof03 = -det33(m10, m11, m12, m20, m21, m22, m30, m31, m32); 53 55 54 56 float cof10 = -det33(m21, m22, m23, m31, m32, m33, m01, m02, m03); 55 57 float cof11 = det33(m22, m23, m20, m32, m33, m30, m02, m03, m00); 56 58 float cof12 = -det33(m23, m20, m21, m33, m30, m31, m03, m00, m01); 57 59 float cof13 = det33(m20, m21, m22, m30, m31, m32, m00, m01, m02); 58 60 59 61 float cof20 = det33(m31, m32, m33, m01, m02, m03, m11, m12, m13); 60 62 float cof21 = -det33(m32, m33, m30, m02, m03, m00, m12, m13, m10); 61 63 float cof22 = det33(m33, m30, m31, m03, m00, m01, m13, m10, m11); 62 64 float cof23 = -det33(m30, m31, m32, m00, m01, m02, m10, m11, m12); 63 65 64 66 float cof30 = -det33(m01, m02, m03, m11, m12, m13, m21, m22, m23); 65 67 float cof31 = det33(m02, m03, m00, m12, m13, m10, m22, m23, m20); … … 103 105 p.m[14] = cof32 * inv0; 104 106 p.m[15]= cof33 * inv0; 105 107 106 108 return p; 107 109 } 108 110 109 Vector4 110 Mat4x4::multiply_row_vector(Vector4 v){ 111 Vector4 112 Mat4x4::multiply_row_vector(const Vector4& v) const 113 { 111 114 Vector4 ret; 112 115 ret.x = (m[0] * v.x) + (m[1] * v.y) + (m[2] * v.z) + (m[3] * v.w); … … 117 120 } 118 121 119 Vector4 120 Mat4x4::transform(Vector4 v){ 122 Vector4 123 Mat4x4::transform(const Vector4& v) const 124 { 121 125 Vector4 ret; 122 126 ret.x = v.x*m[0]+v.y*m[4]+v.z*m[8]+v.w*m[12]; … … 128 132 129 133 Mat4x4 130 Mat4x4::operator *(Mat4x4 mat){ 134 Mat4x4::operator *(const Mat4x4& mat) const 135 { 131 136 Mat4x4 ret; 132 137 … … 154 159 } 155 160 156 Mat4x4 157 Mat4x4::transpose(){ 161 Mat4x4 162 Mat4x4::transpose() const 163 { 158 164 Mat4x4 ret; 159 for (int i=0; i<4; i++){160 for(int j=0; j<4; j++){161 162 165 for (int i = 0; i < 4; i++) { 166 for (int j = 0; j < 4; j++) { 167 ret.m[j+4*i] = this->m[i+4*j]; 168 } 163 169 } 164 170 return ret; 165 171 } 166 167 -
trunk/packages/vizservers/nanovis/Mat4x4.h
r2798 r2822 19 19 #include "Vector4.h" 20 20 21 class Mat4x4 21 class Mat4x4 22 22 { 23 24 23 public: 25 24 float m[16]; //row by row 26 Mat4x4() { 27 /*empty*/ 28 }; 25 26 Mat4x4() 27 {} 28 29 29 Mat4x4(float *vals); 30 30 31 void print(void); 32 Mat4x4 inverse(void); 33 Mat4x4 transpose(void); 34 Vector4 multiply_row_vector(Vector4 v); 35 Vector4 transform(Vector4 v); 36 Mat4x4 operator*(Mat4x4 op); 31 void print() const; 32 33 Mat4x4 inverse() const; 34 35 Mat4x4 transpose() const; 36 37 Vector4 multiply_row_vector(const Vector4& v) const; 38 39 Vector4 transform(const Vector4& v) const; 40 41 Mat4x4 operator*(const Mat4x4& op) const; 37 42 }; 38 43 -
trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.cpp
r2798 r2822 6 6 #include "ZincBlendeVolume.h" 7 7 8 9 //#define _LOADER_DEBUG_ 10 11 NvZincBlendeReconstructor* NvZincBlendeReconstructor::_instance = NULL; 8 NvZincBlendeReconstructor *NvZincBlendeReconstructor::_instance = NULL; 12 9 13 10 NvZincBlendeReconstructor::NvZincBlendeReconstructor() … … 19 16 } 20 17 21 NvZincBlendeReconstructor* NvZincBlendeReconstructor::getInstance() 22 { 23 if (_instance == NULL) 24 { 18 NvZincBlendeReconstructor *NvZincBlendeReconstructor::getInstance() 19 { 20 if (_instance == NULL) { 25 21 return (_instance = new NvZincBlendeReconstructor()); 26 22 } … … 29 25 } 30 26 31 ZincBlendeVolume * NvZincBlendeReconstructor::loadFromFile(const char*fileName)27 ZincBlendeVolume *NvZincBlendeReconstructor::loadFromFile(const char *fileName) 32 28 { 33 29 Vector3 origin, delta; … … 36 32 stream.open(fileName, std::ios::binary); 37 33 38 ZincBlendeVolume *volume = loadFromStream(stream);34 ZincBlendeVolume *volume = loadFromStream(stream); 39 35 40 36 stream.close(); … … 43 39 } 44 40 45 ZincBlendeVolume *NvZincBlendeReconstructor::loadFromStream(std::istream& stream)46 { 47 ZincBlendeVolume * volume = 0;41 ZincBlendeVolume *NvZincBlendeReconstructor::loadFromStream(std::istream& stream) 42 { 43 ZincBlendeVolume *volume = NULL; 48 44 Vector3 origin, delta; 49 45 int width = 0, height = 0, depth = 0; 50 void *data = NULL;46 void *data = NULL; 51 47 int version = 1; 52 48 … … 54 50 do { 55 51 getLine(stream); 56 if (buff[0] == '#') 57 { 52 if (buff[0] == '#') { 58 53 continue; 59 } 60 else if (strstr((const char*) buff, "object") != 0) 61 { 62 #ifdef _LOADER_DEBUG_ 54 } else if (strstr((const char*) buff, "object") != 0) { 63 55 TRACE("VERSION 1\n"); 64 #endif 65 version = 1; 66 break; 67 } 68 else if (strstr(buff, "record format") != 0) 69 { 70 #ifdef _LOADER_DEBUG_ 56 version = 1; 57 break; 58 } else if (strstr(buff, "record format") != 0) { 71 59 TRACE("VERSION 2\n"); 72 #endif 73 version = 2; 74 break; 75 } 76 } while(1); 77 60 version = 2; 61 break; 62 } 63 } while (1); 78 64 79 65 if (version == 1) { 80 66 float dummy; 81 67 82 sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4], &width, &height, &depth);68 sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4], &width, &height, &depth); 83 69 getLine(stream); 84 70 sscanf(buff, "%s%f%f%f", str[0], &(origin.x), &(origin.y), &(origin.z)); … … 91 77 do { 92 78 getLine(stream); 93 } while (strcmp(buff, "<\\HDR>") != 0);79 } while (strcmp(buff, "<\\HDR>") != 0); 94 80 95 81 width = width / 4; … … 98 84 //data = new double[width * height * depth * 8 * 4]; 99 85 data = malloc(width * height * depth * 8 * 4 * sizeof(double)); 100 86 // 8 atom per cell, 4 double (x, y, z, and probability) per atom 101 87 try { 102 stream.read((char*) data, width * height * depth * 8 * 4 * sizeof(double)); 103 } 104 catch (...) 105 { 106 TRACE("ERROR\n"); 88 stream.read((char *)data, width * height * depth * 8 * 4 * sizeof(double)); 89 } catch (...) { 90 ERROR("Caught exception trying to read stream\n"); 107 91 } 108 92 … … 110 94 111 95 free(data); 112 } 113 else if (version == 2) 114 { 115 const char* pt; 96 } else if (version == 2) { 97 const char *pt; 116 98 int datacount; 117 99 double emptyvalue; 118 100 do { 119 101 getLine(stream); 120 if ((pt = strstr(buff, "delta")) != 0) 121 { 102 if ((pt = strstr(buff, "delta")) != 0) { 122 103 sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z)); 123 104 #ifdef _LOADER_DEBUG_ 124 105 TRACE("delta : %f %f %f\n", delta.x, delta.y, delta.z); 125 106 #endif 107 } else if ((pt = strstr(buff, "datacount")) != 0) { 108 sscanf(pt, "%s%d", str[0], &datacount); 109 #ifdef _LOADER_DEBUG_ 110 TRACE("datacount = %d\n", datacount); 111 #endif 112 } else if ((pt = strstr(buff, "datatype")) != 0) { 113 sscanf(pt, "%s%s", str[0], str[1]); 114 if (strcmp(str[1], "double64")) { 115 } 116 } else if ((pt = strstr(buff, "count")) != 0) { 117 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth); 118 #ifdef _LOADER_DEBUG_ 119 TRACE("width height depth %d %d %d\n", width, height, depth); 120 #endif 121 } else if ((pt = strstr(buff, "emptymark")) != 0) { 122 sscanf(pt, "%s%lf", str[0], &emptyvalue); 123 #ifdef _LOADER_DEBUG_ 124 TRACE("emptyvalue %lf\n", emptyvalue); 125 #endif 126 } else if ((pt = strstr(buff, "emprymark")) != 0) { 127 sscanf(pt, "%s%lf", str[0], &emptyvalue); 128 #ifdef _LOADER_DEBUG_ 129 TRACE("emptyvalue %lf\n", emptyvalue); 130 #endif 126 131 } 127 else if ((pt = strstr(buff, "datacount")) != 0) 128 { 129 sscanf(pt, "%s%d", str[0], &datacount); 130 #ifdef _LOADER_DEBUG_ 131 TRACE("datacount = %d\n", datacount); 132 #endif 133 } 134 else if ((pt = strstr(buff, "datatype")) != 0) 135 { 136 sscanf(pt, "%s%s", str[0], str[1]); 137 if (strcmp(str[1], "double64")) 138 { 139 } 140 } 141 else if ((pt = strstr(buff, "count")) != 0) 142 { 143 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth); 144 #ifdef _LOADER_DEBUG_ 145 TRACE("width height depth %d %d %d\n", width, height, depth); 146 #endif 147 } 148 else if ((pt = strstr(buff, "emptymark")) != 0) 149 { 150 sscanf(pt, "%s%lf", str[0], &emptyvalue); 151 #ifdef _LOADER_DEBUG_ 152 TRACE("empryvalue %lf\n", emptyvalue); 153 #endif 154 } 155 else if ((pt = strstr(buff, "emprymark")) != 0) 156 { 157 sscanf(pt, "%s%lf", str[0], &emptyvalue); 158 #ifdef _LOADER_DEBUG_ 159 TRACE("emptyvalue %lf\n", emptyvalue); 160 #endif 161 } 162 } while(strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0); 132 } while (strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0); 163 133 164 134 data = malloc(width * height * depth * 8 * 4 * sizeof(double)); 165 135 memset(data, 0, width * height * depth * 8 * 4 * sizeof(double)); 166 stream.read((char *) data, width * height * depth * 8 * 4 * sizeof(double));136 stream.read((char *) data, width * height * depth * 8 * 4 * sizeof(double)); 167 137 168 138 volume = buildUp(origin, delta, width, height, depth, datacount, emptyvalue, data); … … 186 156 // ,i.e. four atoms are mapped into RGBA component of one texel 187 157 //return ((int) (indexZ - 1)+ (int) (indexX - 1) * width + (int) (indexY - 1) * width * height) * 4; 188 return ((int) (indexX - 1)+ (int) (indexY - 1) * width + (int)(indexZ - 1) * width * height) * 4;158 return ((int)(indexX - 1) + (int)(indexY - 1) * width + (int)(indexZ - 1) * width * height) * 4; 189 159 } 190 160 }; 191 161 192 193 template<class T> 194 inline T _NvMax2(T a, T b) { return ((a >= b)? a : b); } 195 196 template<class T> 197 inline T _NvMin2(T a, T b) { return ((a >= b)? a : b); } 198 199 template<class T> 200 inline T _NvMax3(T a, T b, T c) { return ((a >= b)? ((a >= c) ? a : c) : ((b >= c)? b : c)); } 201 202 template<class T> 203 inline T _NvMin3(T a, T b, T c) { return ((a <= b)? ((a <= c) ? a : c) : ((b <= c)? b : c)); } 204 205 template<class T> 206 inline T _NvMax9(T* a, T curMax) { return _NvMax3(_NvMax3(a[0], a[1], a[2]), _NvMax3(a[3], a[4], a[5]), _NvMax3(a[6], a[7], curMax)); } 207 208 template<class T> 209 inline T _NvMin9(T* a, T curMax) { return _NvMin3(_NvMax3(a[0], a[1], a[2]), _NvMin3(a[3], a[4], a[5]), _NvMin3(a[6], a[7], curMax)); } 210 211 template<class T> 212 inline T _NvMax4(T* a) { return _NvMax2(_NvMax2(a[0], a[1]), _NvMax2(a[2], a[3])); } 213 214 template<class T> 215 inline T _NvMin4(T* a) { return _NvMin2(_NvMin2(a[0], a[1]), _NvMin2(a[2], a[3])); } 216 217 218 ZincBlendeVolume* 162 template<class T> 163 inline T _NvMax2(T a, T b) 164 { return ((a >= b)? a : b); } 165 166 template<class T> 167 inline T _NvMin2(T a, T b) 168 { return ((a >= b)? a : b); } 169 170 template<class T> 171 inline T _NvMax3(T a, T b, T c) 172 { return ((a >= b)? ((a >= c) ? a : c) : ((b >= c)? b : c)); } 173 174 template<class T> 175 inline T _NvMin3(T a, T b, T c) 176 { return ((a <= b)? ((a <= c) ? a : c) : ((b <= c)? b : c)); } 177 178 template<class T> 179 inline T _NvMax9(T* a, T curMax) 180 { return _NvMax3(_NvMax3(a[0], a[1], a[2]), _NvMax3(a[3], a[4], a[5]), _NvMax3(a[6], a[7], curMax)); } 181 182 template<class T> 183 inline T _NvMin9(T* a, T curMax) 184 { return _NvMin3(_NvMax3(a[0], a[1], a[2]), _NvMin3(a[3], a[4], a[5]), _NvMin3(a[6], a[7], curMax)); } 185 186 template<class T> 187 inline T _NvMax4(T* a) 188 { return _NvMax2(_NvMax2(a[0], a[1]), _NvMax2(a[2], a[3])); } 189 190 template<class T> 191 inline T _NvMin4(T* a) 192 { return _NvMin2(_NvMin2(a[0], a[1]), _NvMin2(a[2], a[3])); } 193 194 ZincBlendeVolume * 219 195 NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta, 220 221 { 222 ZincBlendeVolume *zincBlendeVolume = NULL;196 int width, int height, int depth, void* data) 197 { 198 ZincBlendeVolume *zincBlendeVolume = NULL; 223 199 224 200 float *fourAnionVolume, *fourCationVolume; … … 227 203 fourCationVolume = new float[cellCount * sizeof(float) * 4]; 228 204 229 _NvAtomInfo * srcPtr = (_NvAtomInfo*)data;205 _NvAtomInfo *srcPtr = (_NvAtomInfo *)data; 230 206 231 207 float vmin, vmax, nzero_min; 232 float *component4A, *component4B;208 float *component4A, *component4B; 233 209 int index; 234 210 … … 236 212 vmin = vmax = srcPtr->atom; 237 213 238 int i; 239 for (i = 0; i < cellCount; ++i) 240 { 214 for (int i = 0; i < cellCount; ++i) { 241 215 index = srcPtr->getIndex(width, height); 242 216 … … 248 222 component4B = fourCationVolume + index; 249 223 250 component4A[0] = (float) 251 component4A[1] = (float) 252 component4A[2] = (float) 253 component4A[3] = (float) 224 component4A[0] = (float)srcPtr->atom; srcPtr++; 225 component4A[1] = (float)srcPtr->atom; srcPtr++; 226 component4A[2] = (float)srcPtr->atom; srcPtr++; 227 component4A[3] = (float)srcPtr->atom; srcPtr++; 254 228 255 component4B[0] = (float) 256 component4B[1] = (float) 257 component4B[2] = (float) 258 component4B[3] = (float) 229 component4B[0] = (float)srcPtr->atom; srcPtr++; 230 component4B[1] = (float)srcPtr->atom; srcPtr++; 231 component4B[2] = (float)srcPtr->atom; srcPtr++; 232 component4B[3] = (float)srcPtr->atom; srcPtr++; 259 233 260 234 vmax = _NvMax3(_NvMax4(component4A), _NvMax4(component4B), vmax); 261 235 vmin = _NvMin3(_NvMin4(component4A), _NvMin4(component4B), vmin); 262 236 263 if (vmin != 0.0 && vmin < nzero_min) 264 { 265 nzero_min = vmin; 237 if (vmin != 0.0 && vmin < nzero_min) { 238 nzero_min = vmin; 266 239 } 267 240 } 268 241 269 242 double dv = vmax - vmin; 270 if (vmax != 0.0f) 271 { 272 for (i=0; i < cellCount; ++i) 273 { 243 if (vmax != 0.0f) { 244 for (int i = 0; i < cellCount; ++i) { 274 245 fourAnionVolume[i] = (fourAnionVolume[i] - vmin)/ dv; 275 246 fourCationVolume[i] = (fourCationVolume[i] - vmin) / dv; … … 290 261 } 291 262 292 ZincBlendeVolume* NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta, int width, int height, int depth, int datacount, double emptyvalue, void* data) 293 { 294 ZincBlendeVolume* zincBlendeVolume = NULL; 263 ZincBlendeVolume * 264 NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta, 265 int width, int height, int depth, 266 int datacount, double emptyvalue, void* data) 267 { 268 ZincBlendeVolume *zincBlendeVolume = NULL; 295 269 float *fourAnionVolume, *fourCationVolume; 296 270 int size = width * height * depth * 4; … … 301 275 memset(fourCationVolume, 0, size * sizeof(float)); 302 276 303 _NvAtomInfo * srcPtr = (_NvAtomInfo*) data;304 305 float *component4A, *component4B;277 _NvAtomInfo *srcPtr = (_NvAtomInfo *) data; 278 279 float *component4A, *component4B; 306 280 float vmin, vmax, nzero_min; 307 281 int index; 308 282 nzero_min = 1e23f; 309 283 vmin = vmax = srcPtr->atom; 310 int i; 311 for (i = 0; i < datacount; ++i) 312 { 313 284 for (int i = 0; i < datacount; ++i) { 314 285 index = srcPtr->getIndex(width, height); 315 286 … … 342 313 vmin = _NvMin3(_NvMin4(component4A), _NvMin4(component4B), vmin); 343 314 344 if (vmin != 0.0 && vmin < nzero_min) 345 { 315 if (vmin != 0.0 && vmin < nzero_min) { 346 316 nzero_min = vmin; 347 317 } 348 349 318 } 350 319 351 320 double dv = vmax - vmin; 352 if (vmax != 0.0f) 353 { 354 for (i=0; i < datacount; ++i) 355 { 321 if (vmax != 0.0f) { 322 for (int i = 0; i < datacount; ++i) { 356 323 fourAnionVolume[i] = (fourAnionVolume[i] - vmin)/ dv; 357 324 fourCationVolume[i] = (fourCationVolume[i] - vmin) / dv; … … 380 347 if (ch == '\n') break; 381 348 buff[index++] = ch; 382 if (ch == '>') 383 { 349 if (ch == '>') { 384 350 if (buff[1] == '\\') 385 351 break; … … 394 360 } 395 361 396 ZincBlendeVolume* NvZincBlendeReconstructor::loadFromMemory(void* dataBlock) 397 { 398 ZincBlendeVolume* volume = 0; 362 ZincBlendeVolume * 363 NvZincBlendeReconstructor::loadFromMemory(void *dataBlock) 364 { 365 ZincBlendeVolume *volume = NULL; 399 366 Vector3 origin, delta; 400 367 int width = 0, height = 0, depth = 0; 401 void *data = NULL;368 void *data = NULL; 402 369 int version = 1; 403 370 404 unsigned char * stream = (unsigned char*)dataBlock;371 unsigned char *stream = (unsigned char *)dataBlock; 405 372 char str[5][20]; 406 373 do { 407 374 getLine(stream); 408 if (buff[0] == '#') 409 { 375 if (buff[0] == '#') { 410 376 continue; 411 } 412 else if (strstr((const char*) buff, "object") != 0) 413 { 377 } else if (strstr((const char *)buff, "object") != 0) { 414 378 TRACE("VERSION 1\n"); 415 version = 1; 416 break; 417 } 418 else if (strstr(buff, "record format") != 0) 419 { 379 version = 1; 380 break; 381 } else if (strstr(buff, "record format") != 0) { 420 382 TRACE("VERSION 2\n"); 421 version = 2; 422 break; 423 } 424 } while(1); 425 426 427 if (version == 1) 428 { 383 version = 2; 384 break; 385 } 386 } while (1); 387 388 if (version == 1) { 429 389 float dummy; 430 390 … … 440 400 do { 441 401 getLine(stream); 442 } while (strcmp(buff, "<\\HDR>") != 0);402 } while (strcmp(buff, "<\\HDR>") != 0); 443 403 444 404 width = width / 4; … … 446 406 depth = depth / 4; 447 407 data = malloc(width * height * depth * 8 * 4 * sizeof(double)); 448 // 8 atom per cell, 4 double (x, y, z, and probability) per atom 449 try { 450 memcpy(data, stream, width * height * depth * 8 * 4 * sizeof(double)); 451 } 452 catch (...) 453 { 454 TRACE("ERROR\n"); 455 } 408 // 8 atom per cell, 4 double (x, y, z, and probability) per atom 409 memcpy(data, stream, width * height * depth * 8 * 4 * sizeof(double)); 456 410 457 411 volume = buildUp(origin, delta, width, height, depth, data); 458 412 459 413 free(data); 460 } 461 else if (version == 2) 462 { 463 const char* pt; 414 } else if (version == 2) { 415 const char *pt; 464 416 int datacount = -1; 465 417 double emptyvalue; 466 418 do { 467 419 getLine(stream); 468 if ((pt = strstr(buff, "delta")) != 0) 469 { 420 if ((pt = strstr(buff, "delta")) != 0) { 470 421 sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z)); 471 422 #ifdef _LOADER_DEBUG_ 472 423 TRACE("delta : %f %f %f\n", delta.x, delta.y, delta.z); 473 424 #endif 474 } 475 else if ((pt = strstr(buff, "datacount")) != 0) 476 { 425 } else if ((pt = strstr(buff, "datacount")) != 0) { 477 426 sscanf(pt, "%s%d", str[0], &datacount); 478 427 TRACE("datacount = %d\n", datacount); 428 } else if ((pt = strstr(buff, "datatype")) != 0) { 429 sscanf(pt, "%s%s", str[0], str[1]); 430 if (strcmp(str[1], "double64")) { 431 } 432 } else if ((pt = strstr(buff, "count")) != 0) { 433 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth); 434 #ifdef _LOADER_DEBUG_ 435 TRACE("width height depth %d %d %d\n", width, height, depth); 436 #endif 437 } else if ((pt = strstr(buff, "emptymark")) != 0) { 438 sscanf(pt, "%s%lf", str[0], &emptyvalue); 439 #ifdef _LOADER_DEBUG_ 440 TRACE("emptyvalue %lf\n", emptyvalue); 441 #endif 442 } else if ((pt = strstr(buff, "emprymark")) != 0) { 443 sscanf(pt, "%s%lf", str[0], &emptyvalue); 444 #ifdef _LOADER_DEBUG_ 445 TRACE("emptyvalue %lf\n", emptyvalue); 446 #endif 479 447 } 480 else if ((pt = strstr(buff, "datatype")) != 0) 481 { 482 sscanf(pt, "%s%s", str[0], str[1]); 483 if (strcmp(str[1], "double64")) 484 { 485 } 486 } 487 else if ((pt = strstr(buff, "count")) != 0) 488 { 489 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth); 490 #ifdef _LOADER_DEBUG_ 491 TRACE("width height depth %d %d %d\n", width, height, depth); 492 #endif 493 } 494 else if ((pt = strstr(buff, "emptymark")) != 0) 495 { 496 sscanf(pt, "%s%lf", str[0], &emptyvalue); 497 #ifdef _LOADER_DEBUG_ 498 TRACE("empryvalue %lf\n", emptyvalue); 499 #endif 500 } 501 else if ((pt = strstr(buff, "emprymark")) != 0) 502 { 503 sscanf(pt, "%s%lf", str[0], &emptyvalue); 504 #ifdef _LOADER_DEBUG_ 505 TRACE("emptyvalue %lf\n", emptyvalue); 506 #endif 507 } 508 } while(strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0); 448 } while (strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0); 509 449 510 450 if (datacount == -1) datacount = width * height * depth; … … 530 470 if (ch == '\n') break; 531 471 buff[index++] = ch; 532 if (ch == '>') 533 { 472 if (ch == '>') { 534 473 if (buff[1] == '\\') 535 474 break; -
trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.h
r2798 r2822 14 14 * ====================================================================== 15 15 */ 16 17 16 #ifndef __NV_ZINC_BLENDE_RECONSTRUCTOR_H__ 18 17 #define __NV_ZINC_BLENDE_RECONSTRUCTOR_H__ … … 27 26 class ZincBlendeVolume; 28 27 29 class NvZincBlendeReconstructor { 28 class NvZincBlendeReconstructor 29 { 30 30 char buff[255]; 31 31 … … 34 34 */ 35 35 static NvZincBlendeReconstructor* _instance; 36 private 36 private: 37 37 /** 38 38 * @brief Constructor … … 45 45 ~NvZincBlendeReconstructor(); 46 46 47 public 47 public: 48 48 /** 49 49 * @brief Return a singleton instance … … 51 51 static NvZincBlendeReconstructor* getInstance(); 52 52 53 private 53 private: 54 54 /** 55 55 * @brief Get a line from file. It is used for reading header because header is written in ascii. … … 58 58 void getLine(std::istream& stream); 59 59 void getLine(unsigned char*& stream); 60 61 public 60 61 public: 62 62 /** 63 63 * @brief Load Zinc blende binary volume data and create ZincBlendeVolume with the file 64 64 * @param fileName Zinc blende file name, which data is generated by NEMO-3D 65 65 */ 66 ZincBlendeVolume *loadFromFile(const char* fileName);66 ZincBlendeVolume *loadFromFile(const char* fileName); 67 67 68 68 /** … … 70 70 * @param data Zinc blende binary volume data, which data is generated by NEMO-3D and transferred from nanoscale 71 71 */ 72 ZincBlendeVolume *loadFromStream(std::istream& stream);73 ZincBlendeVolume * loadFromMemory(void*dataBlock);72 ZincBlendeVolume *loadFromStream(std::istream& stream); 73 ZincBlendeVolume *loadFromMemory(void *dataBlock); 74 74 75 75 /** … … 82 82 * @param data the memory block of output data of NEMO-3D 83 83 */ 84 ZincBlendeVolume* buildUp(const Vector3& origin, const Vector3& delta, int width, int height, int depth, void* data); 85 ZincBlendeVolume* buildUp(const Vector3& origin, const Vector3& delta, int width, int height, int depth, int datacount, double emptyvalue, void* data); 84 ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta, 85 int width, int height, int depth, void *data); 86 ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta, 87 int width, int height, int depth, 88 int datacount, double emptyvalue, void *data); 86 89 }; 87 90 88 91 #endif 89 -
trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.cpp
r2798 r2822 3 3 #include <string.h> 4 4 #include "global.h" 5 #include "Nv.h"6 5 #include "NvZincBlendeVolumeShader.h" 7 6 -
trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h
r2798 r2822 3 3 #define __NV_ZINCBLENDE_SHADER_H__ 4 4 5 #include "Nv.h"6 5 #include "ZincBlendeVolume.h" 7 6 #include "NvVolumeShader.h" -
trunk/packages/vizservers/nanovis/PCASplit.cpp
r2798 r2822 141 141 } 142 142 if (count != i) { 143 TRACE("ERROR\n");143 ERROR("Problem walking clusterList: count: %d, i: %d\n", count, i); 144 144 } 145 145 return clusterBlock; -
trunk/packages/vizservers/nanovis/ParticleSystemFactory.cpp
r2818 r2822 150 150 if (index == -1) { 151 151 index = path.rfind('\\'); 152 if (index == -1) 152 if (index == -1) { 153 153 TRACE("file not found\n"); 154 } 154 155 } 155 156 -
trunk/packages/vizservers/nanovis/PerfQuery.h
r2798 r2822 16 16 * ====================================================================== 17 17 */ 18 19 18 #ifndef _PERFQUERY_H_ 20 19 #define _PERFQUERY_H_ 21 20 22 21 #include <stdio.h> 23 #include "Trace.h" 22 24 23 #include <GL/glew.h> 25 24 25 #include "Trace.h" 26 26 #include "define.h" 27 27 … … 32 32 glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB, 33 33 &bitsSupported); 34 if (bitsSupported == 0) {35 INFO("occlusion query not supported!\n");34 if (bitsSupported == 0) { 35 TRACE("occlusion query not supported!\n"); 36 36 return false; 37 37 } else { 38 INFO("Occlusion query with %d bits supported\n", bitsSupported);38 TRACE("Occlusion query with %d bits supported\n", bitsSupported); 39 39 return true; 40 40 } … … 43 43 class PerfQuery 44 44 { 45 46 45 public: 47 46 GLuint id; … … 51 50 ~PerfQuery(); 52 51 53 void enable( void); //start counting how many pixels are rendered54 void disable( void); //stop counting52 void enable(); //start counting how many pixels are rendered 53 void disable(); //stop counting 55 54 56 void reset(void) { 55 void reset() 56 { 57 57 pixel = 0; 58 58 } 59 int get_pixel_count(void) { 59 60 int get_pixel_count() 61 { 60 62 return pixel; //return current pixel count 61 63 } 62 64 }; 63 65 64 65 66 66 #endif 67 67 -
trunk/packages/vizservers/nanovis/Plane.cpp
r2798 r2822 15 15 */ 16 16 #include <assert.h> 17 17 18 #include "Plane.h" 18 19 19 Plane::Plane(float _a, float _b, float _c, float _d) {20 this->a = _a;21 this->b = _b;22 this->c = _c;23 this->d = _d;24 20 Plane::Plane(float _a, float _b, float _c, float _d) : 21 a(_a), 22 b(_b), 23 c(_c), 24 d(_d) 25 { 25 26 assert(a != 0 || b != 0 || c != 0); 26 27 } 27 28 28 Plane::Plane(float coeffs[4]) { 29 Plane::Plane(float coeffs[4]) 30 { 29 31 a = coeffs[0]; 30 32 b = coeffs[1]; … … 35 37 } 36 38 37 38 void 39 Plane::transform(Mat4x4 mat){39 void 40 Plane::transform(const Mat4x4& mat) 41 { 40 42 Vector4 coeffs(a, b, c, d); 41 43 … … 48 50 } 49 51 50 void 51 Plane::get_point(Vector3 &point){ 52 if (a != 0) { 53 point.x = -d/a; 54 point.y = 0; 55 point.z = 0; 52 void 53 Plane::get_point(Vector3& point) 54 { 55 if (a != 0) { 56 point.x = -d/a; 57 point.y = 0; 58 point.z = 0; 56 59 } else if (b != 0) { 57 58 59 60 point.y = -d/b; 61 point.x = 0; 62 point.z = 0; 60 63 } else if (c != 0) { 61 62 63 64 } else {65 64 point.z = -d /c; 65 point.y = 0; 66 point.x = 0; 67 } else { 68 assert(false); 66 69 } 67 70 } -
trunk/packages/vizservers/nanovis/Plane.h
r2798 r2822 20 20 #include "Mat4x4.h" 21 21 22 class Plane { 22 class Plane 23 { 23 24 float a, b, c, d; 24 25 public: 25 26 26 27 Plane(float a, float b, float c, float d); 28 27 29 Plane(float coeffs[4]); 28 Plane(void) { 29 /*empty*/ 30 }; 31 32 void get_point(Vector3 &point); 30 31 Plane() 32 {} 33 34 void get_point(Vector3& point); 35 33 36 //bool clips(float point[3]) const { return !retains(point); } 34 37 35 void transform(Mat4x4 mat); 36 void transform(float *m) { 37 Mat4x4 mat(m); 38 transform(mat); 38 void transform(const Mat4x4& mat); 39 40 void transform(float *m) 41 { 42 Mat4x4 mat(m); 43 transform(mat); 39 44 } 40 bool retains(Vector3 point) { 45 46 bool retains(const Vector3& point) const 47 { 41 48 return ((a*point.x + b*point.y + c*point.z + d) >= 0); 42 49 } 43 Vector4 get_coeffs(void) { 44 return Vector4(a, b, c, d); 50 51 Vector4 get_coeffs() const 52 { 53 return Vector4(a, b, c, d); 45 54 } 46 void set_coeffs(float a_val, float b_val, float c_val, float d_val) { 47 a = a_val, b = b_val, c = c_val, d = d_val; 55 56 void set_coeffs(float a_val, float b_val, float c_val, float d_val) 57 { 58 a = a_val, b = b_val, c = c_val, d = d_val; 48 59 } 49 void get_normal(Vector3 &normal) { 50 normal.x = a; 51 normal.y = b; 52 normal.z = c; 60 61 void get_normal(Vector3& normal) const 62 { 63 normal.x = a; 64 normal.y = b; 65 normal.z = c; 53 66 } 54 67 }; -
trunk/packages/vizservers/nanovis/PlaneRenderer.cpp
r2800 r2822 19 19 #include "Trace.h" 20 20 21 PlaneRenderer::PlaneRenderer(CGcontext _context, int _width, int _height) :21 PlaneRenderer::PlaneRenderer(CGcontext _context, int _width, int _height) : 22 22 active_plane(-1), 23 23 n_planes(0), -
trunk/packages/vizservers/nanovis/PlaneRenderer.h
r2800 r2822 19 19 #include <GL/glew.h> 20 20 #include <Cg/cgGL.h> 21 #include <GL/glut.h> 21 22 22 #include <math.h> 23 23 #include <stdio.h> … … 26 26 #include <vector> 27 27 28 #include "define.h"29 28 #include "global.h" 30 29 #include "TransferFunction.h" -
trunk/packages/vizservers/nanovis/PointSetRenderer.cpp
r2798 r2822 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include "Nv.h" 3 #include <GL/gl.h> 4 #include "PointSetRenderer.h" 5 #include <PCASplit.h> 2 #include <GL/glew.h> 3 6 4 #include <Image.h> 7 5 #include <ImageLoaderFactory.h> 8 6 #include <ImageLoader.h> 9 #include <stdio.h>10 7 #include <R2/R2FilePath.h> 8 9 #include "PointSetRenderer.h" 10 #include "PCASplit.h" 11 11 12 12 #define USE_TEXTURE -
trunk/packages/vizservers/nanovis/PointShader.h
r2798 r2822 3 3 #define __POINTSHADER_H__ 4 4 5 #include "Nv.h"6 5 #include "NvShader.h" 7 6 #include "Texture3D.h" -
trunk/packages/vizservers/nanovis/ScreenSnapper.cpp
r2798 r2822 36 36 n_channels_per_pixel = channel_per_pixel; 37 37 38 if (type == GL_FLOAT)38 if (type == GL_FLOAT) 39 39 data = new float[w*h*channel_per_pixel]; 40 else if (type == GL_UNSIGNED_BYTE)40 else if (type == GL_UNSIGNED_BYTE) 41 41 data = new unsigned char[w*h*channel_per_pixel]; 42 42 43 assert(data !=0);43 assert(data != 0); 44 44 reset(0); //reset data 45 45 } … … 47 47 ScreenSnapper::~ScreenSnapper() 48 48 { 49 if (data_type == GL_FLOAT)49 if (data_type == GL_FLOAT) 50 50 delete[] (float*)data; 51 51 else if(data_type == GL_UNSIGNED_BYTE) … … 61 61 elemSize = sizeof(float); 62 62 break; 63 64 63 case GL_UNSIGNED_BYTE: 65 64 elemSize = sizeof(unsigned char); 66 65 break; 67 68 66 default: 69 67 assert(0); … … 78 76 ScreenSnapper::capture() 79 77 { 80 if (data_type == GL_FLOAT){81 if (n_channels_per_pixel==3)78 if (data_type == GL_FLOAT) { 79 if (n_channels_per_pixel == 3) 82 80 glReadPixels(0, 0, width, height, GL_RGB, GL_FLOAT, data); 83 else if (n_channels_per_pixel==4)81 else if (n_channels_per_pixel == 4) 84 82 glReadPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, data); 85 } 86 else if(data_type == GL_UNSIGNED_BYTE){ 87 if(n_channels_per_pixel==3) 83 } else if (data_type == GL_UNSIGNED_BYTE) { 84 if (n_channels_per_pixel == 3) 88 85 glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data); 89 else if (n_channels_per_pixel==4)86 else if (n_channels_per_pixel == 4) 90 87 glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); 91 88 } 92 assert(glGetError() ==0);89 assert(glGetError() == 0); 93 90 } 94 91 95 void 92 void 96 93 ScreenSnapper::print() 97 94 { 98 for (int i=0; i<width*height; i++){99 if (data_type == GL_FLOAT){100 if (n_channels_per_pixel==3)95 for (int i = 0; i < width*height; i++) { 96 if (data_type == GL_FLOAT) { 97 if (n_channels_per_pixel == 3) { 101 98 TRACE("(%f %f %f) ", ((float*)data)[3*i], 102 103 else if(n_channels_per_pixel==4)99 ((float*)data)[3*i+1], ((float*)data)[3*i+2]); 100 } else if (n_channels_per_pixel==4) { 104 101 TRACE("(%f %f %f %f) ", ((float*)data)[4*i], 105 102 ((float*)data)[4*i+1], 106 103 ((float*)data)[4*i+2], 107 108 }109 else if(data_type == GL_UNSIGNED_BYTE){110 if (n_channels_per_pixel==3)104 ((float*)data)[4*i+3]); 105 } 106 } else if (data_type == GL_UNSIGNED_BYTE) { 107 if (n_channels_per_pixel==3) { 111 108 TRACE("(%d %d %d) ", 112 113 114 115 else if(n_channels_per_pixel==4)109 ((unsigned char*)data)[3*i], 110 ((unsigned char*)data)[3*i+1], 111 ((unsigned char*)data)[3*i+2]); 112 } else if (n_channels_per_pixel == 4) { 116 113 TRACE("(%d %d %d %d) ", 117 ((unsigned char*)data)[4*i], 118 ((unsigned char*)data)[4*i+1], 119 ((unsigned char*)data)[4*i+2], 120 ((unsigned char*)data)[4*i+3]); 114 ((unsigned char*)data)[4*i], 115 ((unsigned char*)data)[4*i+1], 116 ((unsigned char*)data)[4*i+2], 117 ((unsigned char*)data)[4*i+3]); 118 } 121 119 } 122 120 } -
trunk/packages/vizservers/nanovis/Sphere.cpp
r2798 r2822 16 16 17 17 #include "Sphere.h" 18 #include <stdio.h>19 18 20 19 Sphere::Sphere(float x, float y, float z, … … 22 21 float _radius, 23 22 int _stack, 24 int _slice) :23 int _slice) : 25 24 Renderable(Vector3(x, y, z)), 26 25 radius(_radius), … … 32 31 } 33 32 34 Sphere::~Sphere() {35 /*empty*/ 33 Sphere::~Sphere() 34 { 36 35 } 37 36 … … 39 38 Sphere::render() 40 39 { 41 /*empty*/42 40 } 43 41 -
trunk/packages/vizservers/nanovis/Sphere.h
r2798 r2822 18 18 #define _SPHERE_H_ 19 19 20 #include <GL/glew.h> 21 #include <GL/glu.h> 22 20 23 #include "Trace.h" 21 #include <GL/glut.h>22 24 23 25 #include "Color.h" 24 26 #include "Renderable.h" 25 27 26 class Sphere : public Renderable {27 28 class Sphere : public Renderable 29 { 28 30 public: 29 31 float radius; … … 32 34 int slice; 33 35 34 ~Sphere();35 36 Sphere(float x, float y, float z, float r, float g, float b, float _radius, 36 37 int _stack, int _slice); 38 39 virtual ~Sphere(); 40 37 41 void set_vertical_res(int _stack); 38 42 void set_horizontal_res(int _slice); -
trunk/packages/vizservers/nanovis/Trace.cpp
r2798 r2822 6 6 7 7 #include <GL/glew.h> 8 #include <GL/glut.h> 8 9 9 #include <syslog.h> 10 10 … … 36 36 s++; 37 37 } 38 length = snprintf(message, MSG_LEN, " nanovis (%d)%s: %s:%d ",39 getpid(), syslogLevels[priority],s, lineNum);38 length = snprintf(message, MSG_LEN, "%s: %s:%d ", 39 syslogLevels[priority], s, lineNum); 40 40 length += vsnprintf(message + length, MSG_LEN - length, fmt, lst); 41 41 message[MSG_LEN] = '\0'; -
trunk/packages/vizservers/nanovis/Trace.h
r2798 r2822 4 4 5 5 #include <GL/glew.h> 6 #include <GL/glut.h>7 6 #include <syslog.h> 8 7 -
trunk/packages/vizservers/nanovis/Unirect.h
r2798 r2822 2 2 #ifndef _UNIRECT_H 3 3 #define _UNIRECT_H 4 5 #include <float.h> 6 4 7 #include <rappture.h> 8 5 9 #include "Trace.h" 6 10 -
trunk/packages/vizservers/nanovis/Vector3.h
r2798 r2822 17 17 #define _VECTOR3_H_ 18 18 19 /*20 * FIXME: The files that explicitly use the "rot*", "length", "distance", or21 * "normalize" methods, should include the following headers. Don't do it22 * here.23 */24 19 #include <math.h> 25 20 #include "Mat4x4.h" 26 21 27 class Vector3{ 28 private: 29 float radians(float degree) const { 30 return (M_PI * degree) / 180.0; 31 } 22 class Vector3 23 { 32 24 public: 33 25 float x, y, z; 34 Vector3(void) { 35 /*empty*/ 26 27 Vector3() 28 {} 29 30 Vector3(float x_val, float y_val, float z_val) 31 { 32 set(x_val, y_val, z_val); 36 33 } 37 Vector3(float x_val, float y_val, float z_val) { 38 set(x_val, y_val, z_val); 34 35 void set(float x_val, float y_val, float z_val) 36 { 37 x = x_val, y = y_val, z = z_val; 39 38 } 40 Vector3 operator +(float scalar) { 41 return Vector3(x + scalar, y + scalar, z + scalar); 39 40 void print() const 41 { 42 TRACE("(x:%f, y:%f, z:%f)\n", x, y, z); 42 43 } 43 Vector3 operator -(float scalar) { 44 return Vector3(x - scalar, y - scalar, z - scalar); 44 45 Vector3 operator +(float scalar) const 46 { 47 return Vector3(x + scalar, y + scalar, z + scalar); 45 48 } 46 Vector3 operator *(float scalar) { 47 return Vector3(x * scalar, y * scalar, z * scalar); 49 50 Vector3 operator -(float scalar) const 51 { 52 return Vector3(x - scalar, y - scalar, z - scalar); 48 53 } 49 Vector3 operator /(float scalar) { 50 return Vector3(x / scalar, y / scalar, z / scalar); 54 55 Vector3 operator *(float scalar) const 56 { 57 return Vector3(x * scalar, y * scalar, z * scalar); 51 58 } 52 Vector3 operator +(Vector3 &op2) { 53 return Vector3(x + op2.x, y + op2.y, z + op2.z); 59 60 Vector3 operator /(float scalar) const 61 { 62 return Vector3(x / scalar, y / scalar, z / scalar); 54 63 } 55 Vector3 operator -(Vector3 &op2) { 56 return Vector3(x - op2.x, y - op2.y, z - op2.z); 64 65 Vector3 operator +(const Vector3& op2) const 66 { 67 return Vector3(x + op2.x, y + op2.y, z + op2.z); 57 68 } 58 float operator *(const Vector3 &op2){ 59 return x*op2.x + y*op2.y + z*op2.z; 69 70 Vector3 operator -(const Vector3& op2) const 71 { 72 return Vector3(x - op2.x, y - op2.y, z - op2.z); 60 73 } 61 float dot(const Vector3& vec) const { 62 return x*vec.x + y*vec.y + z*vec.z; 74 75 float dot(const Vector3& op2) const 76 { 77 return x*op2.x + y*op2.y + z*op2.z; 63 78 } 64 bool equal(Vector3 &op2) { 65 return (x==op2.x) && (y==op2.y) && (z==op2.z); 79 80 float operator *(const Vector3& op2) const 81 { 82 return dot(op2); 66 83 } 67 Vector3 cross(Vector3 op2) { 68 return Vector3(y*op2.z - z*op2.y, z*op2.x - x*op2.z, x*op2.y - y*op2.x); 84 85 Vector3 cross(const Vector3& op2) const 86 { 87 return Vector3(y*op2.z - z*op2.y, z*op2.x - x*op2.z, x*op2.y - y*op2.x); 69 88 } 70 void operator<(Vector3 &op2) { 71 set(op2.x, op2.y, op2.z); 89 90 Vector3 operator ^(const Vector3& op2) const 91 { 92 return cross(op2); 72 93 } 73 Vector3 operator ^(Vector3 &op2) { 74 return cross(op2); 94 95 Vector3 normalize() const 96 { 97 float len = length(); 98 return Vector3(x / len, y / len, z / len); 75 99 } 76 Vector3 normalize(void) { 77 float len = length(); 78 return Vector3(x / len, y / len, z / len); 100 101 Vector3 rot_x(float degree) const 102 { 103 float rad = radians(degree); 104 return Vector3(x, 105 y*cos(rad) - z*sin(rad), 106 y*sin(rad) + z*cos(rad)); 79 107 } 80 Vector3 rot_x(float degree) { 81 float rad = radians(degree); 82 return Vector3(x, 83 y*cos(rad) - z*sin(rad), 84 y*sin(rad) + z*cos(rad)); 108 109 Vector3 rot_y(float degree) const 110 { 111 float rad = radians(degree); 112 return Vector3(x*cos(rad) + z*sin(rad), 113 y, 114 -x*sin(rad) + z*cos(rad)); 85 115 } 86 Vector3 rot_y(float degree) { 87 float rad = radians(degree); 88 return Vector3(x*cos(rad) + z*sin(rad), 89 y, 90 -x*sin(rad) + z*cos(rad)); 116 117 Vector3 rot_z(float degree) const 118 { 119 float rad = radians(degree); 120 return Vector3(x*cos(rad) - y*sin(rad), 121 x*sin(rad) + y*cos(rad), 122 z); 91 123 } 92 Vector3 rot_z(float degree) { 93 float rad = radians(degree); 94 return Vector3(x*cos(rad) - y*sin(rad), 95 x*sin(rad) + y*cos(rad), 96 z); 124 125 float distance(const Vector3& v) const 126 { 127 return sqrtf(distanceSquare(v)); 97 128 } 98 void set(float x_val, float y_val, float z_val) { 99 x = x_val, y = y_val, z = z_val; 129 130 float distanceSquare(const Vector3& v) const 131 { 132 return (x-v.x)*(x-v.x) + (y-v.y)*(y-v.y) + (z-v.z)*(z-v.z); 100 133 } 101 void print(void){ 102 TRACE("(x:%f, y:%f, z:%f)\n", x, y, z); 134 135 float distanceSquare(float vx, float vy, float vz) const 136 { 137 return (x-vx)*(x-vx) + (y-vy)*(y-vy) + (z-vz)*(z-vz); 103 138 } 104 float distance(Vector3 &v) const { 105 return sqrtf(distanceSquare(v)); 106 } 107 float distanceSquare(Vector3 &v) const { 108 return (x-v.x)*(x-v.x) + (y-v.y)*(y-v.y) + (z-v.z)*(z-v.z); 109 } 110 float distanceSquare(float vx, float vy, float vz) const { 111 return (x-vx)*(x-vx) + (y-vy)*(y-vy) + (z-vz)*(z-vz); 112 } 113 void transform(const Vector3& v, const Mat4x4& mat) { 139 140 void transform(const Vector3& v, const Mat4x4& mat) 141 { 114 142 const float* m = mat.m; 115 143 x = m[0] * v.x + m[4] * v.y + m[8] * v.z + m[12]; … … 117 145 z = m[2] * v.x + m[6] * v.y + m[10] * v.z + m[14]; 118 146 } 119 float length(void) const { 120 return sqrt(x*x + y*y + z*z); 147 148 float length() const 149 { 150 return sqrt(x*x + y*y + z*z); 121 151 } 122 152 123 Vector3 scale(const Vector3& scale) 153 Vector3 scale(const Vector3& scale) const 124 154 { 125 155 Vector3 v; … … 130 160 } 131 161 132 friend Vector3 operator+(const Vector3& value1, const Vector3& value2); 133 134 162 private: 163 float radians(float degree) const 164 { 165 return (M_PI * degree) / 180.0; 166 } 135 167 }; 136 168 137 inline Vector3 operator+(const Vector3& value1, const Vector3& value2)138 {139 return Vector3(value1.x + value2.x, value1.y + value2.y, value1.z + value2.z);140 }141 142 169 #endif -
trunk/packages/vizservers/nanovis/Vector4.h
r2798 r2822 17 17 #define _VECTOR4_H_ 18 18 19 #include <stdio.h> 20 #include <Trace.h> 19 #include "Trace.h" 21 20 22 21 class Vector4 … … 25 24 float x, y, z, w; 26 25 27 Vector4(void) { 28 /*empty*/ 29 } 30 Vector4(float x_val, float y_val, float z_val, float w_val) { 31 set(x_val, y_val, z_val, w_val); 32 } 33 void perspective_devide(void) { 34 /* Divide vector by w */ 35 x /= w, y /= w, z /= w, w = 1.; 26 Vector4() 27 {} 28 29 Vector4(float x_val, float y_val, float z_val, float w_val) 30 { 31 set(x_val, y_val, z_val, w_val); 36 32 } 37 33 38 void print(void) { 39 TRACE("Vector4: (%.3f, %.3f, %.3f, %.3f)\n", x, y, z, w); 34 void set(float x_val, float y_val, float z_val, float w_val) 35 { 36 x = x_val, y = y_val, z = z_val, w = w_val; 40 37 } 41 38 42 Vector4 operator +(Vector4 &op2){ 43 return Vector4(x + op2.x, y + op2.y, z + op2.z, w + op2.w); 39 void perspective_divide() 40 { 41 /* Divide vector by w */ 42 x /= w, y /= w, z /= w, w = 1.; 44 43 } 45 44 46 Vector4 operator -(Vector4 &op2){ 47 return Vector4(x - op2.x, y - op2.y, z - op2.z, w - op2.w); 45 void print() const 46 { 47 TRACE("Vector4: (%.3f, %.3f, %.3f, %.3f)\n", x, y, z, w); 48 48 } 49 49 50 float operator *(Vector4 &op2) { 51 return (x * op2.x) + (y * op2.y) + (z * op2.z) + (w * op2.w); 50 Vector4 operator +(const Vector4& op2) const 51 { 52 return Vector4(x + op2.x, y + op2.y, z + op2.z, w + op2.w); 52 53 } 53 54 54 Vector4 operator *(float op2){ 55 return Vector4(x * op2, y * op2, z * op2, w * op2); 55 Vector4 operator -(const Vector4& op2) const 56 { 57 return Vector4(x - op2.x, y - op2.y, z - op2.z, w - op2.w); 56 58 } 57 59 58 Vector4 operator /(float op2) { 59 return Vector4(x / op2, y / op2, z / op2, w / op2); 60 float operator *(const Vector4& op2) const 61 { 62 return (x * op2.x) + (y * op2.y) + (z * op2.z) + (w * op2.w); 60 63 } 61 64 62 void operator <(Vector4 &op2) { 63 set(op2.x, op2.y, op2.z, op2.w); 65 Vector4 operator *(float op2) const 66 { 67 return Vector4(x * op2, y * op2, z * op2, w * op2); 64 68 } 65 void set(float x_val, float y_val, float z_val, float w_val) { 66 x = x_val, y = y_val, z = z_val, w = w_val; 69 70 Vector4 operator /(float op2) const 71 { 72 return Vector4(x / op2, y / op2, z / op2, w / op2); 67 73 } 68 74 }; -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp
r2818 r2822 22 22 #ifdef USE_NANOVIS_LIB 23 23 #include "global.h" 24 #include "Nv.h"25 24 #include "R2/R2FilePath.h" 26 25 #endif -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h
r2818 r2822 150 150 _enabled = enabled; 151 151 } 152 bool enabled( void) const152 bool enabled() const 153 153 { 154 154 return _enabled; -
trunk/packages/vizservers/nanovis/VolumeRenderer.cpp
r2804 r2822 14 14 * ====================================================================== 15 15 */ 16 16 #include <stdlib.h> 17 17 #include <assert.h> 18 18 #include <time.h> 19 19 #include <sys/time.h> 20 20 21 #include <GL/glew.h> 22 #include <GL/glut.h> 23 24 #include <tcl.h> 25 26 #include <vector> 27 21 28 #include <R2/R2string.h> 22 29 #include <R2/R2FilePath.h> 23 30 24 31 #include "nanovis.h" 25 26 32 #include "VolumeRenderer.h" 27 #include "VolumeInterpolator.h" 33 #include "ConvexPolygon.h" 34 28 35 #include "NvStdVertexShader.h" 29 36 #include "Trace.h" … … 40 47 const char *path = R2FilePath::getInstance()->getPath("Font.bmp"); 41 48 if (path == NULL) { 42 43 49 ERROR("can't find Font.bmp\n"); 50 assert(path != NULL); 44 51 } 45 52 init_font(path); … … 57 64 58 65 //initialize the volume shaders 59 void VolumeRenderer::init_shaders() {60 61 //standard vertex program62 _stdVertexShader = new NvStdVertexShader();63 64 //volume rendering shader: one cubic volume65 _regularVolumeShader = new NvRegularVolumeShader();66 67 //volume rendering shader: one zincblende orbital volume.68 //This shader renders one orbital of the simulation.69 //A sim has S, P, D, SS orbitals. thus a full rendering requires 4 zincblende orbital volumes.70 //A zincblende orbital volume is decomposed into 2 "interlocking" cubic 4-component volumes and passed to the shader.71 //We render each orbital with a independent transfer functions then blend the result.72 //73 //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on74 //S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering.75 _zincBlendeShader = new NvZincBlendeVolumeShader();66 void VolumeRenderer::init_shaders() 67 { 68 //standard vertex program 69 _stdVertexShader = new NvStdVertexShader(); 70 71 //volume rendering shader: one cubic volume 72 _regularVolumeShader = new NvRegularVolumeShader(); 73 74 //volume rendering shader: one zincblende orbital volume. 75 //This shader renders one orbital of the simulation. 76 //A sim has S, P, D, SS orbitals. thus a full rendering requires 4 zincblende orbital volumes. 77 //A zincblende orbital volume is decomposed into 2 "interlocking" cubic 4-component volumes and passed to the shader. 78 //We render each orbital with a independent transfer functions then blend the result. 79 // 80 //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on 81 //S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering. 82 _zincBlendeShader = new NvZincBlendeVolumeShader(); 76 83 } 77 84 … … 80 87 int volume_id; 81 88 int slice_id; 89 82 90 SortElement(float _z, int _v, int _s) : 83 91 z(_z), volume_id(_v), slice_id(_s) 84 92 {} 85 93 }; 86 94 87 int slice_sort(const void* a, const void* b){ 88 if((*((SortElement*)a)).z > (*((SortElement*)b)).z) 95 int slice_sort(const void* a, const void* b) 96 { 97 if ((*((SortElement*)a)).z > (*((SortElement*)b)).z) 89 98 return 1; 90 99 else … … 549 558 } 550 559 } 551 552 560 void VolumeRenderer::deactivate_volume_shader() 553 561 { … … 557 565 } 558 566 559 void VolumeRenderer::get_near_far_z(Mat4x4 mv, double &zNear, double &zFar) 560 { 561 double x0 = 0; 562 double y0 = 0; 563 double z0 = 0; 564 double x1 = 1; 565 double y1 = 1; 566 double z1 = 1; 567 568 double zMin, zMax; 569 zMin = 10000; 570 zMax = -10000; 571 572 double vertex[8][4]; 573 574 vertex[0][0]=x0; vertex[0][1]=y0; vertex[0][2]=z0; vertex[0][3]=1.0; 575 vertex[1][0]=x1; vertex[1][1]=y0; vertex[1][2]=z0; vertex[1][3]=1.0; 576 vertex[2][0]=x0; vertex[2][1]=y1; vertex[2][2]=z0; vertex[2][3]=1.0; 577 vertex[3][0]=x0; vertex[3][1]=y0; vertex[3][2]=z1; vertex[3][3]=1.0; 578 vertex[4][0]=x1; vertex[4][1]=y1; vertex[4][2]=z0; vertex[4][3]=1.0; 579 vertex[5][0]=x1; vertex[5][1]=y0; vertex[5][2]=z1; vertex[5][3]=1.0; 580 vertex[6][0]=x0; vertex[6][1]=y1; vertex[6][2]=z1; vertex[6][3]=1.0; 581 vertex[7][0]=x1; vertex[7][1]=y1; vertex[7][2]=z1; vertex[7][3]=1.0; 582 583 for (int i = 0; i < 8; i++) { 584 Vector4 tmp = mv.transform(Vector4(vertex[i][0], vertex[i][1], vertex[i][2], vertex[i][3])); 585 tmp.perspective_devide(); 586 vertex[i][2] = tmp.z; 587 if (vertex[i][2]<zMin) zMin = vertex[i][2]; 588 if (vertex[i][2]>zMax) zMax = vertex[i][2]; 589 } 590 591 zNear = zMax; 592 zFar = zMin; 593 } 594 595 void VolumeRenderer::set_slice_mode(bool val) { slice_mode = val; } 596 void VolumeRenderer::set_volume_mode(bool val) { volume_mode = val; } 597 void VolumeRenderer::switch_slice_mode() { slice_mode = (!slice_mode); } 598 void VolumeRenderer::switch_volume_mode() { volume_mode = (!volume_mode); } 567 void VolumeRenderer::get_near_far_z(const Mat4x4& mv, double& zNear, double& zFar) 568 { 569 double x0 = 0; 570 double y0 = 0; 571 double z0 = 0; 572 double x1 = 1; 573 double y1 = 1; 574 double z1 = 1; 575 576 double zMin, zMax; 577 zMin = 10000; 578 zMax = -10000; 579 580 double vertex[8][4]; 581 582 vertex[0][0]=x0; vertex[0][1]=y0; vertex[0][2]=z0; vertex[0][3]=1.0; 583 vertex[1][0]=x1; vertex[1][1]=y0; vertex[1][2]=z0; vertex[1][3]=1.0; 584 vertex[2][0]=x0; vertex[2][1]=y1; vertex[2][2]=z0; vertex[2][3]=1.0; 585 vertex[3][0]=x0; vertex[3][1]=y0; vertex[3][2]=z1; vertex[3][3]=1.0; 586 vertex[4][0]=x1; vertex[4][1]=y1; vertex[4][2]=z0; vertex[4][3]=1.0; 587 vertex[5][0]=x1; vertex[5][1]=y0; vertex[5][2]=z1; vertex[5][3]=1.0; 588 vertex[6][0]=x0; vertex[6][1]=y1; vertex[6][2]=z1; vertex[6][3]=1.0; 589 vertex[7][0]=x1; vertex[7][1]=y1; vertex[7][2]=z1; vertex[7][3]=1.0; 590 591 for (int i = 0; i < 8; i++) { 592 Vector4 tmp = mv.transform(Vector4(vertex[i][0], vertex[i][1], vertex[i][2], vertex[i][3])); 593 tmp.perspective_divide(); 594 vertex[i][2] = tmp.z; 595 if (vertex[i][2] < zMin) zMin = vertex[i][2]; 596 if (vertex[i][2] > zMax) zMax = vertex[i][2]; 597 } 598 599 zNear = zMax; 600 zFar = zMin; 601 } 599 602 600 603 bool … … 759 762 glPushMatrix(); 760 763 761 glTranslatef(.5*vol->aspect_ratio_width, vol->aspect_ratio_height, 764 glTranslatef(.5*vol->aspect_ratio_width, vol->aspect_ratio_height, 762 765 -0.1*vol->aspect_ratio_depth); 763 766 glRotatef(180, 0, 0, 1); … … 765 768 766 769 glScalef(0.0008, 0.0008, 0.0008); 767 for (int i=0; i<length; i++){770 for (int i = 0; i < length; i++) { 768 771 glutStrokeCharacter(GLUT_STROKE_ROMAN, vol->label[0].c_str()[i]); 769 772 glTranslatef(0.04, 0., 0.); … … 777 780 glRotatef(90, 0, 1, 0); 778 781 glRotatef(90, 0, 0, 1); 779 782 780 783 glScalef(0.0008, 0.0008, 0.0008); 781 for (int i=0; i<length; i++){784 for (int i = 0; i < length; i++) { 782 785 glutStrokeCharacter(GLUT_STROKE_ROMAN, vol->label[1].c_str()[i]); 783 786 glTranslatef(0.04, 0., 0.); … … 792 795 793 796 glScalef(0.0008, 0.0008, 0.0008); 794 for (int i=0; i<length; i++){797 for (int i = 0; i < length; i++) { 795 798 glutStrokeCharacter(GLUT_STROKE_ROMAN, vol->label[2].c_str()[i]); 796 799 glTranslatef(0.04, 0., 0.); … … 811 814 cy = (float) (loop / 16) / 16.0f; 812 815 glNewList(font_base + loop, GL_COMPILE); 813 814 815 816 817 818 819 820 821 822 823 816 glBegin(GL_QUADS); 817 glTexCoord2f(cx, 1 - cy - 0.0625f); 818 glVertex3f(0, 0, 0); 819 glTexCoord2f(cx + 0.0625f, 1 - cy - 0.0625f); 820 glVertex3f(0.04, 0, 0); 821 glTexCoord2f(cx + 0.0625f, 1 - cy); 822 glVertex3f(0.04, 0.04, 0); 823 glTexCoord2f(cx, 1 - cy); 824 glVertex3f(0, 0.04, 0); 825 glEnd(); 826 glTranslated(0.04, 0, 0); 824 827 glEndList(); 825 828 } … … 830 833 { 831 834 if (set > 1) { 832 set=1;835 set = 1; 833 836 } 834 837 glBindTexture(GL_TEXTURE_2D, font_texture); -
trunk/packages/vizservers/nanovis/VolumeRenderer.h
r2798 r2822 20 20 #include <GL/glew.h> 21 21 #include <Cg/cgGL.h> 22 #include <GL/glut.h>23 #include <math.h>24 #include <stdio.h>25 #include <assert.h>26 #include <float.h>27 #include <vector>28 22 29 #include "define.h"30 #include "global.h"31 #include "ConvexPolygon.h"32 #include "TransferFunction.h"33 23 #include "Mat4x4.h" 34 24 #include "Volume.h" 35 #include "ZincBlendeVolume.h" 36 #include "PerfQuery.h" 25 #include "VolumeInterpolator.h" 37 26 #include "NvRegularVolumeShader.h" 38 27 #include "NvZincBlendeVolumeShader.h" 39 28 #include "NvStdVertexShader.h" 40 #include "VolumeInterpolator.h"41 29 42 class VolumeRenderer { 30 class VolumeRenderer 31 { 43 32 friend class NanoVis; 33 44 34 private: 45 35 VolumeInterpolator* _volumeInterpolator; … … 68 58 */ 69 59 NvZincBlendeVolumeShader* _zincBlendeShader; 70 60 71 61 /** 72 62 * standard vertex shader 73 63 */ 74 64 NvStdVertexShader* _stdVertexShader; 75 65 76 66 //standard vertex shader parameters 77 67 CGprogram m_vert_std_vprog; … … 82 72 83 73 void init_shaders(); 74 84 75 void activate_volume_shader(Volume* vol, bool slice_mode); 76 85 77 void deactivate_volume_shader(); 78 86 79 //draw bounding box 87 80 void draw_bounding_box(float x0, float y0, float z0, … … 89 82 float r, float g, float b, float line_width); 90 83 91 void get_near_far_z(Mat4x4 mv, double &zNear, double &zFar); 84 void get_near_far_z(const Mat4x4& mv, double& zNear, double& zFar); 85 92 86 bool init_font(const char* filename); 87 93 88 void glPrint(char* string, int set); //there are two sets of font in the 94 89 //texture. 0, 1 90 95 91 void draw_label(Volume* vol); //draw label using bitmap texture 96 92 // the texture. 93 97 94 void build_font(); // Register the location of each alphabet in 98 95 99 96 public: 100 97 VolumeRenderer(); 98 101 99 ~VolumeRenderer(); 102 100 103 101 void render_all(); //render all enabled volumes; 102 104 103 void specular(float val); 104 105 105 void diffuse(float val); 106 void set_slice_mode(bool val); //control independently.107 void set_volume_mode(bool val);108 void switch_slice_mode(); //switch_cutplane_mode109 void switch_volume_mode();110 106 111 void clearAnimatedVolumeInfo(void) { 112 _volumeInterpolator->clearAll(); 107 void set_slice_mode(bool val) //control independently. 108 { 109 slice_mode = val; 113 110 } 114 void addAnimatedVolume(Volume* volume) { 115 _volumeInterpolator->addVolume(volume); 111 112 void set_volume_mode(bool val) 113 { 114 volume_mode = val; 116 115 } 117 void startVolumeAnimation(void) { 118 _volumeInterpolator->start(); 116 117 void switch_slice_mode() //switch_cutplane_mode 118 { 119 slice_mode = (!slice_mode); 119 120 } 120 void stopVolumeAnimation(void) { 121 122 void switch_volume_mode() 123 { 124 volume_mode = (!volume_mode); 125 } 126 127 void clearAnimatedVolumeInfo() 128 { 129 _volumeInterpolator->clearAll(); 130 } 131 132 void addAnimatedVolume(Volume* volume) 133 { 134 _volumeInterpolator->addVolume(volume); 135 } 136 137 void startVolumeAnimation() 138 { 139 _volumeInterpolator->start(); 140 } 141 142 void stopVolumeAnimation() 143 { 121 144 _volumeInterpolator->stop(); 122 145 } 123 VolumeInterpolator* getVolumeInterpolator(void) { 146 147 VolumeInterpolator* getVolumeInterpolator() 148 { 124 149 return _volumeInterpolator; 125 150 } -
trunk/packages/vizservers/nanovis/define.h
r2806 r2822 24 24 GLenum status; \ 25 25 status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); \ 26 TRACE("%x\n", status); \27 26 switch(status) { \ 28 27 case GL_FRAMEBUFFER_COMPLETE_EXT: \ -
trunk/packages/vizservers/nanovis/dxReader.cpp
r2798 r2822 30 30 #include <sys/types.h> 31 31 #include <unistd.h> 32 33 #include "Nv.h"34 32 35 33 #include "nanovis.h" -
trunk/packages/vizservers/nanovis/dxReader2.cpp
r2798 r2822 11 11 12 12 // nanovis headers 13 #include "Nv.h"14 13 #include "nanovis.h" 15 14 -
trunk/packages/vizservers/nanovis/global.h
r2806 r2822 16 16 #include <GL/glew.h> 17 17 #include <Cg/cgGL.h> 18 18 19 #include <Trace.h> 19 #include <stdio.h>20 20 21 21 inline void … … 34 34 system_info() 35 35 { 36 INFO("-----------------------------------------------------------\n");37 INFO("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),36 TRACE("-----------------------------------------------------------\n"); 37 TRACE("OpenGL driver: %s %s\n", glGetString(GL_VENDOR), 38 38 glGetString(GL_VERSION)); 39 INFO("Graphics hardware: %s\n", glGetString(GL_RENDERER));40 INFO("-----------------------------------------------------------\n");39 TRACE("Graphics hardware: %s\n", glGetString(GL_RENDERER)); 40 TRACE("-----------------------------------------------------------\n"); 41 41 } 42 42 -
trunk/packages/vizservers/nanovis/nanovis.cpp
r2820 r2822 38 38 #include <unistd.h> 39 39 40 #include "Nv.h"41 40 #include "PointSetRenderer.h" 42 41 #include "PointSet.h" … … 347 346 TRACE("in DoExit\n"); 348 347 removeAllData(); 349 NvExit(); 348 349 #ifdef EVENTLOG 350 NvExitEventLog(); 351 #endif 352 353 #ifdef XINETD 354 NvExitService(); 355 #endif 356 350 357 #if KEEPSTATS 351 358 WriteStats("nanovis", code); … … 384 391 int result; 385 392 386 TRACE(" in ExecuteCommand(%s)\n", Tcl_DStringValue(dsPtr));393 TRACE("command: '%s'", Tcl_DStringValue(dsPtr)); 387 394 388 395 gettimeofday(&tv, NULL); … … 703 710 { 704 711 // print system information 705 TRACE("-----------------------------------------------------------\n"); 706 TRACE("OpenGL driver: %s %s\n", glGetString(GL_VENDOR), 707 glGetString(GL_VERSION)); 708 TRACE("Graphics hardware: %s\n", glGetString(GL_RENDERER)); 709 TRACE("-----------------------------------------------------------\n"); 712 system_info(); 713 710 714 if (path == NULL) { 711 715 ERROR("No path defined for shaders or resources\n"); … … 2094 2098 ch = (char)c; 2095 2099 Tcl_DStringAppend(&cmdbuffer, &ch, 1); 2096 TRACE("in xinetd_listen: checking buffer=%s\n",2097 Tcl_DStringValue(&cmdbuffer));2098 2100 if (ch == '\n') { 2099 2101 isComplete = Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer)); … … 2191 2193 fflush(stdout); 2192 2194 2193 /* openlog("nanovis", LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER); */2195 openlog("nanovis", LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER); 2194 2196 gettimeofday(&tv, NULL); 2195 2197 stats.start = tv; -
trunk/packages/vizservers/nanovis/nanovis.h
r2818 r2822 45 45 #include "define.h" 46 46 #include "global.h" 47 47 48 #include "NvCamera.h" 48 49 #include "ConvexPolygon.h" … … 64 65 #include "HeightMap.h" 65 66 #include "Grid.h" 67 #include "VolumeRenderer.h" 66 68 #include "VelocityArrowsSlice.h" 67 69 … … 81 83 struct Vector2 { 82 84 float x, y; 83 float mag(void) { 85 float mag() 86 { 84 87 return sqrt(x*x+y*y); 85 88 } 86 89 }; 87 90 88 struct RegGrid2 {91 struct RegGrid2 { 89 92 int width, height; 90 93 Vector2* field; 91 94 92 RegGrid2(int w, int h){ 95 RegGrid2(int w, int h) 96 { 93 97 width = w; 94 98 height = h; … … 96 100 } 97 101 98 void put(Vector2& v, int x ,int y) { 102 void put(Vector2& v, int x ,int y) 103 { 99 104 field[x+y*width] = v; 100 105 } 101 106 102 Vector2& get(int x, int y) { 107 Vector2& get(int x, int y) 108 { 103 109 return field[x+y*width]; 104 110 } … … 109 115 class FlowIterator; 110 116 111 class NanoVis { 117 class NanoVis 118 { 112 119 //frame buffer for final rendering 113 120 static GLuint final_fbo, final_color_tex, final_depth_rb; 114 public: 121 115 122 public: 116 123 static VolumeRenderer* vol_renderer; … … 158 165 static Tcl_DString cmdbuffer; 159 166 160 public :161 167 static TransferFunction* get_transfunc(const char *name); 162 168 static TransferFunction* DefineTransferFunction(const char *name, … … 203 209 static FILE *stdin, *logfile, *recfile; 204 210 205 static void read_screen(void) { 211 static void read_screen() 212 { 206 213 glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE, 207 screen_buffer); 208 } 209 static void offscreen_buffer_capture(void) { 214 screen_buffer); 215 } 216 static void offscreen_buffer_capture() 217 { 210 218 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo); 211 219 } -
trunk/packages/vizservers/nanovis/socket/Socket.cpp
r2798 r2822 14 14 * ====================================================================== 15 15 */ 16 #include "Socket.h"17 #include "string.h"18 16 #include <string.h> 19 17 #include <errno.h> 20 18 #include <fcntl.h> 19 20 #include "Socket.h" 21 21 22 22 ssize_t writen(int fd, void *vptr, size_t n) ;
Note: See TracChangeset
for help on using the changeset viewer.