Changeset 883 for trunk/vizservers
- Timestamp:
- Feb 13, 2008, 7:27:28 PM (17 years ago)
- Location:
- trunk/vizservers/nanovis
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/dxReader.cpp
r870 r883 38 38 #include "ZincBlendeVolume.h" 39 39 #include "NvZincBlendeReconstructor.h" 40 #include "GradientFilter.h" 40 41 41 42 //#define _LOCAL_ZINC_TEST_ 43 float* merge(float* scalar, float* gradient, int size) 44 { 45 float* data = (float*) malloc(sizeof(float) * 4 * size); 46 47 Vector3* g = (Vector3*) gradient; 48 49 int ngen = 0, sindex = 0; 50 for (sindex = 0; sindex <size; ++sindex) 51 { 52 data[ngen++] = scalar[sindex]; 53 data[ngen++] = g[sindex].x; 54 data[ngen++] = g[sindex].y; 55 data[ngen++] = g[sindex].z; 56 } 57 return data; 58 } 59 60 void normalizeScalar(float* fdata, int count, float min, float max) 61 { 62 float v = max - min; 63 if (v != 0.0f) 64 { 65 for (int i = 0; i < count; ++i) 66 fdata[i] = fdata[i] / v; 67 } 68 } 69 70 float* computeGradient(float* fdata, int width, int height, int depth, float min, float max) 71 { 72 float* gradients = (float *)malloc(width * height * depth * 3 * sizeof(float)); 73 float* tempGradients = (float *)malloc(width * height * depth * 3 * sizeof(float)); 74 int sizes[3] = { width, height, depth }; 75 computeGradients(tempGradients, fdata, sizes, DATRAW_FLOAT); 76 filterGradients(tempGradients, sizes); 77 quantizeGradients(tempGradients, gradients, sizes, DATRAW_FLOAT); 78 normalizeScalar(fdata, width * height * depth, min, max); 79 float* data = merge(fdata, gradients, width * height * depth); 80 81 return data; 82 } 42 83 43 84 /* … … 746 787 #endif 747 788 789 float *cdata = new float[nx*ny*nz]; 790 int ngen = 0; 791 double nzero_min = 0.0; 792 for (int iz=0; iz < nz; iz++) { 793 double zval = z0 + iz*dmin; 794 for (int iy=0; iy < ny; iy++) { 795 double yval = y0 + iy*dmin; 796 for (int ix=0; ix < nx; ix++) 797 { 798 double xval = x0 + ix*dmin; 799 double v = field.value(xval,yval,zval); 800 801 if (v != 0.0f && v < nzero_min) 802 { 803 nzero_min = v; 804 } 805 806 // scale all values [0-1], -1 => out of bounds 807 v = (isnan(v)) ? -1.0 : v; 808 809 cdata[ngen] = v; 810 ++ngen; 811 } 812 } 813 } 814 815 float* data = computeGradient(cdata, nx, ny, nz, field.valueMin(), field.valueMax()); 816 817 // Compute the gradient of this data. BE CAREFUL: center 818 /* 748 819 float *data = new float[4*nx*ny*nz]; 749 820 … … 815 886 } 816 887 } 888 */ 817 889 818 890 NanoVis::load_volume(index, nx, ny, nz, 4, data,
Note: See TracChangeset
for help on using the changeset viewer.