- Timestamp:
- Mar 7, 2012 2:01:55 PM (12 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 1 deleted
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/ContourLineFilter.cpp
r2798 r2827 5 5 */ 6 6 7 #include <string>8 #include "ContourLineFilter.h"9 #include <R2/graphics/R2VertexBuffer.h>10 7 #include <stdlib.h> 11 8 #include <memory.h> 12 #include "Vector4.h" 13 #include "Vector3.h" 9 10 #include <string> 11 12 #include <R2/graphics/R2VertexBuffer.h> 13 14 #include "ContourLineFilter.h" 14 15 15 16 ContourLineFilter::ContourLineFilter() -
trunk/packages/vizservers/nanovis/ContourLineFilter.h
r2798 r2827 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef _CONTOURFILTER_H_ 3 #define _CONTOURFILTER_H_ 2 #ifndef CONTOURLINEFILTER_H 3 #define CONTOURLINEFILTER_H 4 5 #include <list> 6 7 #include <R2/graphics/R2Geometry.h> 4 8 5 9 #include "Vector3.h" 6 10 #include "Vector4.h" 7 #include "TypeDefs.h"8 #include <R2/graphics/R2Geometry.h>9 #include <list>10 11 11 class ContourLineFilter { 12 public : 13 class ContourLine { 14 public : 12 class ContourLineFilter 13 { 14 public: 15 class ContourLine 16 { 17 public: 15 18 float _value; 16 19 std::list<Vector3> _points; 17 public : 20 18 21 ContourLine(float value); 19 20 private : 21 bool isValueWithIn(float v1, float v2) { 22 23 /** 24 * @brief 25 * @ret Returns the number of points 26 */ 27 int createLine(int width, int height, Vector3 *vertices, bool top); 28 int createLine(int width, int height, Vector4 *vertices, bool top); 29 30 private: 31 bool isValueWithIn(float v1, float v2) 32 { 22 33 return ((_value >= v1 && _value <= v2) || 23 34 (_value >= v2 && _value <= v1)); 24 35 } 25 void getContourPoint(int vertexIndex1, int vertexIndex2, Vector3* vertices, int width, bool top); 26 void getContourPoint(int vertexIndex1, int vertexIndex2, Vector4* vertices, int width, bool top); 27 public : 28 /** 29 * @brief 30 * @ret Returns the number of points 31 */ 32 int createLine(int width, int height, Vector3* vertices, bool top); 33 int createLine(int width, int height, Vector4* vertices, bool top); 36 void getContourPoint(int vertexIndex1, int vertexIndex2, Vector3 *vertices, int width, bool top); 37 void getContourPoint(int vertexIndex1, int vertexIndex2, Vector4 *vertices, int width, bool top); 34 38 }; 35 36 typedef std::list<ContourLine*> ContourLineList; 37 38 private : 39 ContourLineList _lines; 40 Vector3Array* _colorMap; 41 bool _top; 42 public : 39 40 typedef std::list<ContourLine *> ContourLineList; 41 43 42 ContourLineFilter(); 44 45 private : 46 void clear(); 47 48 public : 49 R2Geometry* create(float min, float max, int linecount, Vector3* vertices, int width, int height); 50 R2Geometry* create(float min, float max, int linecount, Vector4* vertices, int width, int height); 51 void setColorMap(Vector3Array* colorMap); 43 44 R2Geometry *create(float min, float max, int linecount, Vector3 *vertices, int width, int height); 45 R2Geometry *create(float min, float max, int linecount, Vector4 *vertices, int width, int height); 46 47 void setColorMap(Vector3Array *colorMap); 52 48 53 49 void setHeightTop(bool top) … … 55 51 _top = top; 56 52 } 53 54 private: 55 void clear(); 56 57 ContourLineList _lines; 58 Vector3Array *_colorMap; 59 bool _top; 57 60 }; 58 61 -
trunk/packages/vizservers/nanovis/DataLoader.cpp
r2798 r2827 5 5 #include <stdlib.h> 6 6 #include <math.h> 7 #include <Trace.h> 7 8 #include "Trace.h" 8 9 9 10 inline void endian_swap(unsigned int& x) … … 15 16 } 16 17 17 18 18 char buff[255]; 19 void getLine(FILE *&fp)19 void getLine(FILE *fp) 20 20 { 21 21 char ch; … … 30 30 } 31 31 32 void * LoadDx(const char* fname, int& width, int& height, int&depth, float& min, float& max, float& nonzero_min,33 float& axisScaleX, float& axisScaleY, float& axisScaleZ) 34 { 35 std::string path = fname; 36 37 if (path.size() == 0) 38 { 39 ERROR("file not found[%s]\n", path.c_str()); 40 return NULL;41 } 42 43 FILE* fp = fopen(path.c_str(), "rb"); 44 if (fp == NULL) 45 46 47 48 49 50 51 52 53 54 55 56 32 void *LoadDx(const char *fname, 33 int& width, int& height, int& depth, 34 float& min, float& max, float& nonzero_min, 35 float& axisScaleX, float& axisScaleY, float& axisScaleZ) 36 { 37 std::string path = fname; 38 39 if (path.size() == 0) { 40 ERROR("file not found[%s]\n", path.c_str()); 41 return NULL; 42 } 43 44 FILE *fp = fopen(path.c_str(), "rb"); 45 if (fp == NULL) { 46 ERROR("file not found %s\n", path.c_str()); 47 return NULL; 48 } 49 50 int index; 51 do { 52 getLine(fp); 53 } while (memcmp(buff, "object", 6)); 54 55 float origin_x, origin_y, origin_z; 56 double delta_x, delta_y, delta_z; 57 57 double temp; 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 getLine(fp); 73 58 char str[5][20]; 59 60 //object 1 class gridpositions counts 5 5 5 61 sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4], &width, &depth, &height); 62 63 //origin 0 0 0 64 getLine(fp); 65 sscanf(buff, "%s%f%f%f", str[0], &(origin_x), &(origin_y), &(origin_z)); 66 67 // delta 0.5431 0 0 68 getLine(fp); 69 sscanf(buff, "%s%lf%lf%lf", str[0], &(delta_x), &temp, &temp); 70 71 // delta 0 0.5431 0 72 getLine(fp); 73 sscanf(buff, "%s%lf%lf%lf", str[0], &temp, &(delta_y), &temp); 74 74 75 // delta 0 0 0.5431 76 getLine(fp); 77 sscanf(buff, "%s%lf%lf%lf", str[0], &temp, &temp, &(delta_z)); 78 79 getLine(fp); 80 getLine(fp); 81 getLine(fp); 82 getLine(fp); 83 84 min = nonzero_min = 1e27f; 85 max = -1e27f; 86 87 float* data = 0; 88 int d, h, w; 89 float scalar; 90 index = 0; 91 92 if (width < height) 93 { 94 int size = width * height * depth; 95 data = (float*) malloc(size * sizeof(float)); 96 memset(data, 0, sizeof(float) * size); 97 98 99 for (w = 0; w < width; ++w) // x 100 for (d = 0; d < depth; ++d) //z 101 { 102 for (h = 0; h < width; ++h) // y 103 { 104 scalar = atof(fgets(buff, 255, fp)); 105 data[h * width + d * width * width + w] = scalar; 106 if (scalar < min) min = scalar; 107 if (scalar != 0.0f && nonzero_min > scalar) nonzero_min = scalar; 108 if (scalar > max) max = scalar; 109 } 110 for (;h < height; ++h) 111 { 112 scalar = atof(fgets(buff, 255, fp)); 113 } 114 } 115 116 height = width; 117 118 119 120 121 } 122 else if (width > height) 123 { 124 int size = width * width * width; 125 data = (float*) malloc(size * sizeof(float)); 126 memset(data, 0, sizeof(float) * size); 127 for (w = 0; w < width; ++w) // x 128 for (d = 0; d < depth; ++d) //z 129 for (h = 0; h < height; ++h) // y 130 { 131 scalar = atof(fgets(buff, 255, fp)); 132 data[h * width + d * width * width + w] = scalar; 133 if (scalar < min) min = scalar; 134 if (scalar != 0.0f && nonzero_min > scalar) nonzero_min = scalar; 135 if (scalar > max) max = scalar; 136 } 137 138 height = width; 139 140 141 142 143 } 144 else 145 { 146 int size = width * height * depth; 147 data = (float*) malloc(size * sizeof(float)); 148 149 for (w = 0; w < width; ++w) // x 150 for (d = 0; d < depth; ++d) //z 151 for (h = 0; h < height; ++h) // y 152 { 153 scalar = atof(fgets(buff, 255, fp)); 154 data[h * width + d * width * height + w] = scalar; 155 if (scalar < min) min = scalar; 156 if (scalar != 0.0f && nonzero_min > scalar) nonzero_min = scalar; 157 if (scalar > max) max = scalar; 158 } 159 } 160 161 axisScaleX = origin_x + width * delta_x; 162 axisScaleY = origin_y + height * delta_y; 163 axisScaleZ = origin_z + depth * delta_z; 164 165 fclose(fp); 166 167 return data; 168 } 169 170 void* LoadFlowDx(const char* fname, int& width, int& height, int&depth, float& min, float& max, float& nonzero_min, 171 float& axisScaleX, float& axisScaleY, float& axisScaleZ) 172 { 173 std::string path = fname; 174 175 if (path.size() == 0) 176 { 177 ERROR("file not found[%s]\n", path.c_str()); 178 return NULL; 179 } 180 181 FILE* fp = fopen(path.c_str(), "rb"); 182 if (fp == NULL) 183 { 184 ERROR("file not found %s\n", path.c_str()); 185 return NULL; 186 } 187 188 int index; 189 do { 190 getLine(fp); 191 } while (memcmp(buff, "object", 6)); 192 193 double origin_x, origin_y, origin_z; 194 double delta_x, delta_y, delta_z; 75 // delta 0 0 0.5431 76 getLine(fp); 77 sscanf(buff, "%s%lf%lf%lf", str[0], &temp, &temp, &(delta_z)); 78 79 getLine(fp); 80 getLine(fp); 81 getLine(fp); 82 getLine(fp); 83 84 min = nonzero_min = 1e27f; 85 max = -1e27f; 86 87 float *data = 0; 88 int d, h, w; 89 float scalar; 90 index = 0; 91 92 if (width < height) { 93 int size = width * height * depth; 94 data = (float *) malloc(size * sizeof(float)); 95 memset(data, 0, sizeof(float) * size); 96 97 98 for (w = 0; w < width; ++w) {// x 99 for (d = 0; d < depth; ++d) { //z 100 for (h = 0; h < width; ++h) { // y 101 scalar = atof(fgets(buff, 255, fp)); 102 data[h * width + d * width * width + w] = scalar; 103 if (scalar < min) min = scalar; 104 if (scalar != 0.0f && nonzero_min > scalar) nonzero_min = scalar; 105 if (scalar > max) max = scalar; 106 } 107 for (;h < height; ++h) { 108 scalar = atof(fgets(buff, 255, fp)); 109 } 110 } 111 } 112 113 height = width; 114 } else if (width > height) { 115 int size = width * width * width; 116 data = (float *) malloc(size * sizeof(float)); 117 memset(data, 0, sizeof(float) * size); 118 for (w = 0; w < width; ++w) { // x 119 for (d = 0; d < depth; ++d) { //z 120 for (h = 0; h < height; ++h) { // y 121 scalar = atof(fgets(buff, 255, fp)); 122 data[h * width + d * width * width + w] = scalar; 123 if (scalar < min) min = scalar; 124 if (scalar != 0.0f && nonzero_min > scalar) nonzero_min = scalar; 125 if (scalar > max) max = scalar; 126 } 127 } 128 } 129 130 height = width; 131 } else { 132 int size = width * height * depth; 133 data = (float *) malloc(size * sizeof(float)); 134 135 for (w = 0; w < width; ++w) { // x 136 for (d = 0; d < depth; ++d) { //z 137 for (h = 0; h < height; ++h) { // y 138 scalar = atof(fgets(buff, 255, fp)); 139 data[h * width + d * width * height + w] = scalar; 140 if (scalar < min) min = scalar; 141 if (scalar != 0.0f && nonzero_min > scalar) nonzero_min = scalar; 142 if (scalar > max) max = scalar; 143 } 144 } 145 } 146 } 147 148 axisScaleX = origin_x + width * delta_x; 149 axisScaleY = origin_y + height * delta_y; 150 axisScaleZ = origin_z + depth * delta_z; 151 152 fclose(fp); 153 154 return data; 155 } 156 157 void *LoadFlowDx(const char *fname, 158 int& width, int& height, int& depth, 159 float& min, float& max, float& nonzero_min, 160 float& axisScaleX, float& axisScaleY, float& axisScaleZ) 161 { 162 std::string path = fname; 163 164 if (path.size() == 0) { 165 ERROR("file not found[%s]\n", path.c_str()); 166 return NULL; 167 } 168 169 FILE *fp = fopen(path.c_str(), "rb"); 170 if (fp == NULL) { 171 ERROR("file not found %s\n", path.c_str()); 172 return NULL; 173 } 174 175 int index; 176 do { 177 getLine(fp); 178 } while (memcmp(buff, "object", 6)); 179 180 double origin_x, origin_y, origin_z; 181 double delta_x, delta_y, delta_z; 195 182 double temp; 196 197 198 199 200 201 202 203 204 205 206 207 208 183 char str[5][20]; 184 185 //object 1 class gridpositions counts 5 5 5 186 sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4], &width, &height, &depth); 187 188 getLine(fp); 189 sscanf(buff, "%s%lg%lg%lg", str[0], &(origin_x), &(origin_y), &(origin_z)); 190 191 getLine(fp); 192 sscanf(buff, "%s%lg%lg%lg", str[0], &(delta_x), &temp, &temp); 193 194 getLine(fp); 195 sscanf(buff, "%s%lg%lg%lg", str[0], &temp, &(delta_y), &temp); 209 196 210 getLine(fp); 211 sscanf(buff, "%s%lf%lf%lf", str[0], &temp, &temp, &(delta_z)); 212 213 getLine(fp); 214 getLine(fp); 215 216 min = nonzero_min = 1e27f; 217 max = -1e27f; 218 219 float* data = 0; 220 int d, h, w; 221 index = 0; 222 223 224 int size = width * height * depth; 225 data = (float*) malloc(size * sizeof(float) * 4); 226 float* ptr = data; 227 double x, y, z, length; 228 char* ret = 0; 229 230 for (w = 0; w < width; ++w) // x 231 for (h = 0; h < height; ++h) // y 232 for (d = 0; d < depth; ++d) //z 233 { 234 ret = fgets(buff, 255, fp); 235 sscanf(buff, "%lg%lg%lg", &x, &y, &z); 236 ptr = data + (d * width * height + h * width + w) * 4; 237 length = sqrt(x*x+y*y+z*z); 238 *ptr = length; ptr++; 239 *ptr = x; ptr++; 240 *ptr = y; ptr++; 241 *ptr = z; 242 243 if (length < min) min = length; 244 if (length != 0.0f && nonzero_min > length) nonzero_min = length; 245 if (length > max) 246 { 247 //TRACE("max %lf %lf %fl\n", x, y, z); 248 max = length; 249 } 250 } 251 252 ptr = data; 253 for (int i = 0; i < size; ++i) 254 { 255 *ptr = *ptr / max; ++ptr; 256 *ptr = (*ptr / (2.0*max)) + 0.5; ++ptr; 257 *ptr = (*ptr / (2.0 * max)) + 0.5; ++ptr; 258 *ptr = (*ptr / (2.0 * max)) + 0.5; ++ptr; 259 } 260 axisScaleX = width * delta_x; 261 axisScaleY = height * delta_y; 262 axisScaleZ = depth * delta_z; 263 264 fclose(fp); 265 266 TRACE("width %d, height %d, depth %d, min %f, max %f, scaleX %f, scaleY %f, scaleZ %f\n", 267 width, height, depth, min, max, axisScaleX, axisScaleY, axisScaleZ); 268 return data; 269 } 270 271 void* LoadProcessedFlowRaw(const char* fname, int width, int height, int depth, float min, float max, float& axisScaleX, float& axisScaleY, float& axisScaleZ) 272 { 273 std::string path = fname; 274 275 if (fname == 0) 276 { 277 ERROR("file name is null\n"); 278 return NULL; 279 } 280 281 FILE* fp = fopen(fname, "rb"); 282 if (fp == NULL) 283 { 284 ERROR("file not found %s\n", fname); 285 return NULL; 286 } 287 288 int size = width * height * depth; 289 float* srcdata = (float*) malloc(size * sizeof(float) * 4); 290 fread(srcdata, size * 4 * sizeof(float), 1, fp); 291 fclose(fp); 292 293 axisScaleX = width; 294 axisScaleY = height; 295 axisScaleZ = depth; 296 297 return srcdata; 298 } 299 300 void LoadProcessedFlowRaw(const char* fname, int width, int height, int depth, float* data) 301 { 302 std::string path = fname; 303 304 if (fname == 0) 305 { 306 ERROR("file name is null\n"); 307 return; 308 } 309 310 FILE* fp = fopen(fname, "rb"); 311 if (fp == NULL) 312 { 313 ERROR("file not found %s\n", fname); 314 return; 315 } 316 317 int size = width * height * depth; 318 fread(data, size * 4 * sizeof(float), 1, fp); 319 fclose(fp); 320 } 321 322 323 void* LoadFlowRaw(const char* fname, int width, int height, int depth, float& min, float& max, float& nonzero_min, 324 float& axisScaleX, float& axisScaleY, float& axisScaleZ, int skipByte, bool bigEndian) 325 { 326 std::string path = fname; 327 328 if (path.size() == 0) 329 { 330 ERROR("file not found[%s]\n", path.c_str()); 331 return NULL; 332 } 333 334 FILE* fp = fopen(path.c_str(), "rb"); 335 if (fp == NULL) 336 { 337 ERROR("file not found %s\n", path.c_str()); 338 return NULL; 339 } 340 341 342 343 min = nonzero_min = 1e27f; 344 max = -1e27f; 345 346 float* srcdata = 0; 347 float* data = 0; 348 int d, h, w; 349 int index = 0; 350 351 int size = width * height * depth; 352 srcdata = (float*) malloc(size * sizeof(float) * 3); 353 memset(srcdata, 0, size * sizeof(float) * 3); 354 if (skipByte != 0) fread(srcdata, skipByte, 1, fp); 355 fread(srcdata, size * 3 * sizeof(float), 1, fp); 356 fclose(fp); 357 358 if (bigEndian) { 359 unsigned int* dd = (unsigned int*) srcdata; 360 for (int i = 0; i < size * 3; ++i) 361 { 362 endian_swap(dd[i]); 363 } 364 } 365 366 367 data = (float*) malloc(size * sizeof(float) * 4); 368 memset(data, 0, size * sizeof(float) * 4); 369 370 float* ptr = data; 371 double x, y, z, length; 372 373 for (d = 0; d < depth; ++d) //z 374 for (h = 0; h < height; ++h) // y 375 for (w = 0; w < width; ++w, index +=3) // x 376 { 377 x = srcdata[index]; 378 y = srcdata[index + 1]; 379 z = srcdata[index + 2]; 380 ptr = data + (d * width * height + h * width + w) * 4; 381 length = sqrt(x*x+y*y+z*z); 382 *ptr = length; ptr++; 383 *ptr = x; ptr++; 384 *ptr = y; ptr++; 385 *ptr = z; 386 387 if (length < min) min = length; 388 if (length != 0.0f && nonzero_min > length) nonzero_min = length; 389 if (length > max) 390 { 391 TRACE("max %lf %lf %fl\n", x, y, z); 392 max = length; 393 } 394 } 395 396 ptr = data; 397 for (int i = 0; i < size; ++i) 398 { 399 *ptr = *ptr / max; ++ptr; 400 *ptr = (*ptr / (2.0*max)) + 0.5; ++ptr; 401 *ptr = (*ptr / (2.0 * max)) + 0.5; ++ptr; 402 *ptr = (*ptr / (2.0 * max)) + 0.5; ++ptr; 403 } 404 axisScaleX = width; 405 axisScaleY = height; 406 axisScaleZ = depth; 407 408 fclose(fp); 409 410 TRACE("width %d, height %d, depth %d, min %f, max %f, scaleX %f, scaleY %f, scaleZ %f\n", 411 width, height, depth, min, max, axisScaleX, axisScaleY, axisScaleZ); 412 return data; 413 } 414 415 197 getLine(fp); 198 sscanf(buff, "%s%lf%lf%lf", str[0], &temp, &temp, &(delta_z)); 199 200 getLine(fp); 201 getLine(fp); 202 203 min = nonzero_min = 1e27f; 204 max = -1e27f; 205 206 float *data = 0; 207 int d, h, w; 208 index = 0; 209 210 int size = width * height * depth; 211 data = (float *) malloc(size * sizeof(float) * 4); 212 float *ptr = data; 213 double x, y, z, length; 214 char *ret = 0; 215 216 for (w = 0; w < width; ++w) { // x 217 for (h = 0; h < height; ++h) { // y 218 for (d = 0; d < depth; ++d) { //z 219 ret = fgets(buff, 255, fp); 220 sscanf(buff, "%lg%lg%lg", &x, &y, &z); 221 ptr = data + (d * width * height + h * width + w) * 4; 222 length = sqrt(x*x+y*y+z*z); 223 *ptr = length; ptr++; 224 *ptr = x; ptr++; 225 *ptr = y; ptr++; 226 *ptr = z; 227 228 if (length < min) min = length; 229 if (length != 0.0f && nonzero_min > length) nonzero_min = length; 230 if (length > max) { 231 //TRACE("max %lf %lf %fl\n", x, y, z); 232 max = length; 233 } 234 } 235 } 236 } 237 238 ptr = data; 239 for (int i = 0; i < size; ++i) { 240 *ptr = *ptr / max; ++ptr; 241 *ptr = (*ptr / (2.0*max)) + 0.5; ++ptr; 242 *ptr = (*ptr / (2.0 * max)) + 0.5; ++ptr; 243 *ptr = (*ptr / (2.0 * max)) + 0.5; ++ptr; 244 } 245 axisScaleX = width * delta_x; 246 axisScaleY = height * delta_y; 247 axisScaleZ = depth * delta_z; 248 249 fclose(fp); 250 251 TRACE("width %d, height %d, depth %d, min %f, max %f, scaleX %f, scaleY %f, scaleZ %f\n", 252 width, height, depth, min, max, axisScaleX, axisScaleY, axisScaleZ); 253 return data; 254 } 255 256 void *LoadProcessedFlowRaw(const char *fname, 257 int width, int height, int depth, 258 float min, float max, 259 float& axisScaleX, float& axisScaleY, float& axisScaleZ) 260 { 261 std::string path = fname; 262 263 if (fname == 0) { 264 ERROR("file name is null\n"); 265 return NULL; 266 } 267 268 FILE *fp = fopen(fname, "rb"); 269 if (fp == NULL) { 270 ERROR("file not found %s\n", fname); 271 return NULL; 272 } 273 274 int size = width * height * depth; 275 float *srcdata = (float *) malloc(size * sizeof(float) * 4); 276 fread(srcdata, size * 4 * sizeof(float), 1, fp); 277 fclose(fp); 278 279 axisScaleX = width; 280 axisScaleY = height; 281 axisScaleZ = depth; 282 283 return srcdata; 284 } 285 286 void LoadProcessedFlowRaw(const char *fname, 287 int width, int height, int depth, 288 float *data) 289 { 290 std::string path = fname; 291 292 if (fname == 0) { 293 ERROR("file name is null\n"); 294 return; 295 } 296 297 FILE *fp = fopen(fname, "rb"); 298 if (fp == NULL) { 299 ERROR("file not found %s\n", fname); 300 return; 301 } 302 303 int size = width * height * depth; 304 fread(data, size * 4 * sizeof(float), 1, fp); 305 fclose(fp); 306 } 307 308 void *LoadFlowRaw(const char *fname, int width, int height, int depth, 309 float& min, float& max, float& nonzero_min, 310 float& axisScaleX, float& axisScaleY, float& axisScaleZ, 311 int skipByte, bool bigEndian) 312 { 313 std::string path = fname; 314 315 if (path.size() == 0) { 316 ERROR("file not found[%s]\n", path.c_str()); 317 return NULL; 318 } 319 320 FILE *fp = fopen(path.c_str(), "rb"); 321 if (fp == NULL) { 322 ERROR("file not found %s\n", path.c_str()); 323 return NULL; 324 } 325 326 min = nonzero_min = 1e27f; 327 max = -1e27f; 328 329 float *srcdata = 0; 330 float *data = 0; 331 int d, h, w; 332 int index = 0; 333 334 int size = width * height * depth; 335 srcdata = (float *) malloc(size * sizeof(float) * 3); 336 memset(srcdata, 0, size * sizeof(float) * 3); 337 if (skipByte != 0) fread(srcdata, skipByte, 1, fp); 338 fread(srcdata, size * 3 * sizeof(float), 1, fp); 339 fclose(fp); 340 341 if (bigEndian) { 342 unsigned int *dd = (unsigned int *) srcdata; 343 for (int i = 0; i < size * 3; ++i) { 344 endian_swap(dd[i]); 345 } 346 } 347 348 data = (float *) malloc(size * sizeof(float) * 4); 349 memset(data, 0, size * sizeof(float) * 4); 350 351 float *ptr = data; 352 double x, y, z, length; 353 354 for (d = 0; d < depth; ++d) { //z 355 for (h = 0; h < height; ++h) { // y 356 for (w = 0; w < width; ++w, index +=3) { // x 357 x = srcdata[index]; 358 y = srcdata[index + 1]; 359 z = srcdata[index + 2]; 360 ptr = data + (d * width * height + h * width + w) * 4; 361 length = sqrt(x*x+y*y+z*z); 362 *ptr = length; ptr++; 363 *ptr = x; ptr++; 364 *ptr = y; ptr++; 365 *ptr = z; 366 367 if (length < min) min = length; 368 if (length != 0.0f && nonzero_min > length) nonzero_min = length; 369 if (length > max) { 370 TRACE("max %lf %lf %fl\n", x, y, z); 371 max = length; 372 } 373 } 374 } 375 } 376 377 ptr = data; 378 for (int i = 0; i < size; ++i) { 379 *ptr = *ptr / max; ++ptr; 380 *ptr = (*ptr / (2.0*max)) + 0.5; ++ptr; 381 *ptr = (*ptr / (2.0 * max)) + 0.5; ++ptr; 382 *ptr = (*ptr / (2.0 * max)) + 0.5; ++ptr; 383 } 384 axisScaleX = width; 385 axisScaleY = height; 386 axisScaleZ = depth; 387 388 fclose(fp); 389 390 TRACE("width %d, height %d, depth %d, min %f, max %f, scaleX %f, scaleY %f, scaleZ %f\n", 391 width, height, depth, min, max, axisScaleX, axisScaleY, axisScaleZ); 392 return data; 393 } -
trunk/packages/vizservers/nanovis/HeightMap.cpp
r2812 r2827 12 12 #include "HeightMap.h" 13 13 #include "ContourLineFilter.h" 14 #include "TypeDefs.h"15 14 #include "Texture1D.h" 16 15 #include "R2/R2FilePath.h" -
trunk/packages/vizservers/nanovis/R2/include/R2/R2.h
r2798 r2827 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __R2_H__3 #define __R2_H__2 #ifndef R2_H 3 #define R2_H 4 4 5 5 #include <GL/glew.h> … … 64 64 extern void R2Exit(); 65 65 66 #endif // __R2_H__66 #endif 67 67 -
trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h
r2798 r2827 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __R2_FILE_PATH_H__3 #define __R2_FILE_PATH_H__2 #ifndef R2_FILE_PATH_H 3 #define R2_FILE_PATH_H 4 4 5 5 #include <list> 6 6 7 #include <R2/R2string.h> 7 8 8 class R2FilePath { 9 class R2FilePath 10 { 9 11 typedef std::list<R2string> R2stringList; 10 12 typedef std::list<R2string>::iterator R2stringListIter; -
trunk/packages/vizservers/nanovis/R2/include/R2/R2Fonts.h
r2798 r2827 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __R2_FONTS_H__3 #define __R2_FONTS_H__2 #ifndef R2_FONTS_H 3 #define R2_FONTS_H 4 4 5 5 #include <R2/R2.h> … … 8 8 #include <vector> 9 9 10 class R2Fonts : public R2Object {11 10 class R2Fonts : public R2Object 11 { 12 12 struct R2FontAttributes { 13 13 char *_fontName; -
trunk/packages/vizservers/nanovis/R2/include/R2/graphics/R2Geometry.h
r2798 r2827 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef _R2_GEOMETRY_H_3 #define _R2_GEOMETRY_H_2 #ifndef R2_GEOMETRY_H 3 #define R2_GEOMETRY_H 4 4 5 #include <GL/gl .h>5 #include <GL/glew.h> 6 6 #include <R2/graphics/R2VertexBuffer.h> 7 7 #include <R2/graphics/R2IndexBuffer.h> 8 8 9 class R2Geometry { 9 class R2Geometry 10 { 10 11 public : 11 12 enum { … … 17 18 }; 18 19 19 private :20 R2VertexBuffer* _vertexBuffer;21 R2VertexBuffer* _colorBuffer;22 R2IndexBuffer* _indexBuffer;23 int _primitiveType;24 25 20 public : 26 21 R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, … … 29 24 R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer); 30 25 ~R2Geometry(); 31 32 public : 26 33 27 void render(); 28 29 private : 30 R2VertexBuffer *_vertexBuffer; 31 R2VertexBuffer *_colorBuffer; 32 R2IndexBuffer *_indexBuffer; 33 int _primitiveType; 34 34 }; 35 35 -
trunk/packages/vizservers/nanovis/R2/include/R2/graphics/R2IndexBuffer.h
r2798 r2827 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef _R2_INDEX_BUFFER_H_3 #define _R2_INDEX_BUFFER_H_2 #ifndef R2_INDEX_BUFFER_H 3 #define R2_INDEX_BUFFER_H 4 4 5 class R2IndexBuffer { 6 int _indexCount; 7 int* _data; 8 public : 9 R2IndexBuffer(int indexCount, int* data, bool copy = true); 10 ~R2IndexBuffer(); 11 public : 12 int getIndexCount() const; 13 const int* getData() const; 5 class R2IndexBuffer 6 { 7 int _indexCount; 8 int *_data; 9 10 public: 11 R2IndexBuffer(int indexCount, int* data, bool copy = true); 12 ~R2IndexBuffer(); 13 14 int getIndexCount() const; 15 const int* getData() const; 14 16 }; 15 17 16 18 inline int R2IndexBuffer::getIndexCount() const 17 19 { 18 20 return _indexCount; 19 21 } 20 22 21 23 inline const int* R2IndexBuffer::getData() const 22 24 { 23 25 return _data; 24 26 } 25 27 26 #endif //28 #endif -
trunk/packages/vizservers/nanovis/R2/include/R2/graphics/R2VertexBuffer.h
r2798 r2827 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef _R2_VERTEXBUFFER_H_3 #define _R2_VERTEXBUFFER_H_2 #ifndef R2_VERTEXBUFFER_H 3 #define R2_VERTEXBUFFER_H 4 4 5 class R2VertexBuffer { 6 unsigned int _graphicObjectID; 7 int _byteSize; 8 int _vertexCount; 9 public : 10 void* _data; 11 public : 12 enum { 13 POSITION3 = 0x01, 14 NORMAL3 = 0x02, 15 COLOR3 = 0x04, 16 COLOR4 = 0x08 17 }; 5 class R2VertexBuffer 6 { 7 unsigned int _graphicObjectID; 8 int _byteSize; 9 int _vertexCount; 18 10 19 public : 20 R2VertexBuffer(int type, int vertexCount, int byteSize, void* data, bool copy = true); 21 ~R2VertexBuffer(); 11 public: 12 void *_data; 22 13 23 public : 24 unsigned int getGraphicObjectID() const; 14 enum { 15 POSITION3 = 0x01, 16 NORMAL3 = 0x02, 17 COLOR3 = 0x04, 18 COLOR4 = 0x08 19 }; 25 20 26 void updateBuffer(void* data); 27 int getVertexCount() const; 21 R2VertexBuffer(int type, int vertexCount, int byteSize, void* data, bool copy = true); 22 ~R2VertexBuffer(); 23 24 unsigned int getGraphicObjectID() const; 25 26 void updateBuffer(void* data); 27 int getVertexCount() const; 28 28 }; 29 29 … … 38 38 } 39 39 40 #endif //40 #endif -
trunk/packages/vizservers/nanovis/Unirect.cpp
r2809 r2827 2 2 #include <float.h> 3 3 #include <tcl.h> 4 #include <Unirect.h> 5 #include "RpField1D.h" 6 #include "RpFieldRect3D.h" 4 5 #include <RpField1D.h> 6 #include <RpFieldRect3D.h> 7 8 #include "Unirect.h" 7 9 #include "Trace.h" 8 10 -
trunk/packages/vizservers/nanovis/Vector3.h
r2822 r2827 14 14 * ====================================================================== 15 15 */ 16 #ifndef _VECTOR3_H_17 #define _VECTOR3_H_16 #ifndef VECTOR3_H 17 #define VECTOR3_H 18 18 19 #include <math.h> 19 #include <math.h> 20 21 #include <vector> 22 20 23 #include "Mat4x4.h" 21 24 … … 140 143 void transform(const Vector3& v, const Mat4x4& mat) 141 144 { 142 const float *m = mat.m;145 const float *m = mat.m; 143 146 x = m[0] * v.x + m[4] * v.y + m[8] * v.z + m[12]; 144 147 y = m[1] * v.x + m[5] * v.y + m[9] * v.z + m[13]; … … 167 170 }; 168 171 172 typedef std::vector<Vector3> Vector3Array; 173 169 174 #endif -
trunk/packages/vizservers/nanovis/Vector4.h
r2822 r2827 14 14 * ====================================================================== 15 15 */ 16 #ifndef _VECTOR4_H_ 17 #define _VECTOR4_H_ 16 #ifndef VECTOR4_H 17 #define VECTOR4_H 18 19 #include <vector> 18 20 19 21 #include "Trace.h" … … 74 76 }; 75 77 78 typedef std::vector<Vector4> Vector4Array; 79 76 80 #endif -
trunk/packages/vizservers/nanovis/ZincBlendeVolume.cpp
r2798 r2827 19 19 #include "ZincBlendeVolume.h" 20 20 21 22 21 ZincBlendeVolume::ZincBlendeVolume(float x, float y, float z, 23 int w, int h, int d, float s, int n, 24 float* dataVolumeA, float* dataVolumeB, 25 double v0, double v1, double non_zeromin, const Vector3& cellSize) 26 : Volume(x, y, z, w, h, d, s, n, dataVolumeA, v0, v1, non_zeromin), cell_size(cellSize) 22 int w, int h, int d, float s, int n, 23 float* dataVolumeA, float* dataVolumeB, 24 double v0, double v1, double non_zeromin, 25 const Vector3& cellSize) : 26 Volume(x, y, z, w, h, d, s, n, dataVolumeA, v0, v1, non_zeromin), 27 cell_size(cellSize) 27 28 { 28 29 //label it as zincblende … … 34 35 35 36 //now add another tex as zincblende_tex[1] 36 Texture3D* secondTex = 0; 37 secondTex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n); 37 Texture3D* secondTex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n); 38 38 assert(secondTex); 39 39 secondTex->initialize(dataVolumeB); 40 40 41 41 zincblende_tex[1] = secondTex; 42 42 } 43 44 43 45 44 ZincBlendeVolume::~ZincBlendeVolume() … … 51 50 delete zincblende_tex[1]; 52 51 } 53 54 -
trunk/packages/vizservers/nanovis/config.h
r2798 r2827 36 36 #define NEW_FLOW_ENGINE 1 37 37 38 //#define USE_POINTSET_RENDERER 39 38 40 /* 39 41 * The following define controls whether new load_volume_stream or -
trunk/packages/vizservers/nanovis/nanovis.cpp
r2822 r2827 38 38 #include <unistd.h> 39 39 40 #ifdef USE_POINTSET_RENDERER 40 41 #include "PointSetRenderer.h" 41 42 #include "PointSet.h" 43 #endif 44 42 45 #include <NvLIC.h> 43 46 #include <Trace.h> … … 108 111 Tcl_HashTable NanoVis::heightmapTable; 109 112 VolumeRenderer* NanoVis::vol_renderer = NULL; 113 #ifdef USE_POINTSET_RENDERER 110 114 PointSetRenderer* NanoVis::pointset_renderer = NULL; 111 115 std::vector<PointSet*> NanoVis::pointSet; 116 #endif 112 117 PlaneRenderer* NanoVis::plane_render = NULL; 113 118 Texture2D* NanoVis::plane[10]; … … 696 701 CGerror lastError = cgGetError(); 697 702 698 if (lastError) {703 if (lastError) { 699 704 TRACE("\n---------------------------------------------------\n"); 700 705 TRACE("%s\n\n", cgGetErrorString(lastError)); … … 756 761 grid->setFont(fonts); 757 762 758 #ifdef notdef763 #ifdef USE_POINTSET_RENDERER 759 764 pointset_renderer = new PointSetRenderer(); 760 765 #endif … … 1652 1657 perf->disable(); 1653 1658 } 1654 1659 TRACE("in display: render heightmap\n"); 1655 1660 perf->reset(); 1656 1661 CHECK_FRAMEBUFFER_STATUS(); … … 2116 2121 fcntl(0, F_SETFL, flags | O_NONBLOCK); 2117 2122 isComplete = false; 2118 2119 2123 nCommands++; 2124 CHECK_FRAMEBUFFER_STATUS(); 2120 2125 } 2121 2126 } … … 2186 2191 char *newPath; 2187 2192 struct timeval tv; 2193 2188 2194 newPath = NULL; 2189 2195 path = NULL; -
trunk/packages/vizservers/nanovis/socket/ClientSocket.cpp
r2798 r2827 16 16 #include "ClientSocket.h" 17 17 #include "SocketException.h" 18 19 18 20 19 ClientSocket::ClientSocket ( std::string host, int port ) -
trunk/packages/vizservers/nanovis/socket/ClientSocket.h
r2798 r2827 19 19 #include "Socket.h" 20 20 21 22 21 class ClientSocket : private Socket 23 22 { -
trunk/packages/vizservers/nanovis/socket/RenderClient.cpp
r2798 r2827 15 15 */ 16 16 #include <GL/freeglut.h> 17 #include "RenderClient.h"18 17 #include <stdlib.h> 19 18 #include <sstream> … … 23 22 #include <assert.h> 24 23 25 #include "../Event.h" 24 #include "RenderClient.h" 25 #include "Event.h" 26 26 27 27 using namespace std; … … 29 29 Event* event[5000]; 30 30 int cur_event = 0; 31 32 31 33 32 int width, height; -
trunk/packages/vizservers/nanovis/socket/RenderClient.h
r2798 r2827 17 17 #define _RENDER_CLIENT_H_ 18 18 19 #include "ClientSocket.h"20 #include "SocketException.h"21 19 #include <iostream> 22 20 #include <string> 23 21 22 #include "ClientSocket.h" 23 #include "SocketException.h" 24 24 25 25 class RenderClient{ -
trunk/packages/vizservers/nanovis/socket/RenderServer.cpp
r2798 r2827 15 15 */ 16 16 #include "RenderServer.h" 17 18 17 19 18 RenderServer::RenderServer(){} -
trunk/packages/vizservers/nanovis/socket/RenderServer.h
r2798 r2827 17 17 #define _RENDER_SERVER_H_ 18 18 19 #include <string> 20 19 21 #include "ServerSocket.h" 20 22 #include "SocketException.h" 21 #include <string>22 23 23 24 24 class RenderServer{ -
trunk/packages/vizservers/nanovis/socket/ServerSocket.cpp
r2798 r2827 16 16 #include "ServerSocket.h" 17 17 #include "SocketException.h" 18 19 18 20 19 ServerSocket::ServerSocket ( int port ) -
trunk/packages/vizservers/nanovis/socket/ServerSocket.h
r2798 r2827 18 18 19 19 #include "Socket.h" 20 21 20 22 21 class ServerSocket : private Socket
Note: See TracChangeset
for help on using the changeset viewer.