Changeset 4819 for nanovis/branches/1.1
- Timestamp:
- Dec 6, 2014 7:16:39 PM (9 years ago)
- Location:
- nanovis/branches/1.1
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
nanovis/branches/1.1
- Property svn:mergeinfo changed
/trunk/packages/vizservers/nanovis merged: 4067
- Property svn:mergeinfo changed
-
nanovis/branches/1.1/Command.cpp
r4818 r4819 38 38 #include <tcl.h> 39 39 40 #include <RpField1D.h>41 40 #include <RpEncode.h> 42 41 #include <RpOutcome.h> … … 981 980 982 981 // decode the data and store in a series of fields 983 Rappture::Field1D rFunc, gFunc, bFunc, aFunc;984 982 int cmapc, amapc, i; 985 983 Tcl_Obj **cmapv; … … 1003 1001 return TCL_ERROR; 1004 1002 } 1003 1004 int numColors = cmapc/4; 1005 float *colorKeys = new float[numColors]; 1006 Vector3f *colors = new Vector3f[numColors]; 1005 1007 for (i = 0; i < cmapc; i += 4) { 1006 1008 int j; … … 1018 1020 } 1019 1021 } 1020 rFunc.define(q[0], q[1]); 1021 gFunc.define(q[0], q[2]); 1022 bFunc.define(q[0], q[3]); 1023 } 1022 1023 colorKeys[i/4] = (float)q[0]; 1024 colors[i/4].set((float)q[1], (float)q[2], (float)q[3]); 1025 } 1026 int numAlphas = amapc/2; 1027 float *alphaKeys = new float[numAlphas]; 1028 float *alphas = new float[numAlphas]; 1024 1029 for (i=0; i < amapc; i += 2) { 1025 1030 double q[2]; … … 1037 1042 } 1038 1043 } 1039 aFunc.define(q[0], q[1]); 1044 alphaKeys[i/2] = (float)q[0]; 1045 alphas[i/2] = (float)q[1]; 1040 1046 } 1041 1047 // sample the given function into discrete slots … … 1043 1049 float data[4*nslots]; 1044 1050 for (i=0; i < nslots; i++) { 1045 double x = double(i)/(nslots-1); 1046 data[4*i] = rFunc.value(x); 1047 data[4*i+1] = gFunc.value(x); 1048 data[4*i+2] = bFunc.value(x); 1049 data[4*i+3] = aFunc.value(x); 1050 } 1051 float x = float(i)/(nslots-1); 1052 Vector3f color; 1053 float alpha; 1054 TransferFunction::sample(x, colorKeys, colors, numColors, &color); 1055 TransferFunction::sample(x, alphaKeys, alphas, numAlphas, &alpha); 1056 1057 data[4*i] = color.r; 1058 data[4*i+1] = color.g; 1059 data[4*i+2] = color.b; 1060 data[4*i+3] = alpha; 1061 } 1062 delete [] colorKeys; 1063 delete [] colors; 1064 delete [] alphaKeys; 1065 delete [] alphas; 1051 1066 // find or create this transfer function 1052 1067 NanoVis::defineTransferFunction(Tcl_GetString(objv[2]), nslots, data); -
nanovis/branches/1.1/TransferFunction.cpp
r3568 r4819 58 58 59 59 void 60 TransferFunction::sample(float fraction, float *key , int count, Vector3f *keyValue, Vector3f *ret)60 TransferFunction::sample(float fraction, float *keys, Vector3f *keyValues, int count, Vector3f *ret) 61 61 { 62 62 int limit = count - 1; 63 if (fraction <= key [0]) {64 *ret = keyValue [0];65 } else if (fraction >= key [limit]) {66 *ret = keyValue [limit];63 if (fraction <= keys[0]) { 64 *ret = keyValues[0]; 65 } else if (fraction >= keys[limit]) { 66 *ret = keyValues[limit]; 67 67 } else { 68 68 int n; 69 for (n = 0; n < limit; n++) {70 if (fraction >= key [n] && fraction < key[n+1]) break;69 for (n = 0; n < limit; n++) { 70 if (fraction >= keys[n] && fraction < keys[n+1]) break; 71 71 } 72 72 if (n >= limit) { 73 *ret = keyValue [limit];73 *ret = keyValues[limit]; 74 74 } else { 75 float inter = (fraction - key [n]) / (key[n + 1] - key[n]);76 ret->set(inter * (keyValue [n + 1].x - keyValue[n].x) + keyValue[n].x,77 inter * (keyValue [n + 1].y - keyValue[n].y) + keyValue[n].y,78 inter * (keyValue [n + 1].z - keyValue[n].z) + keyValue[n].z);75 float inter = (fraction - keys[n]) / (keys[n + 1] - keys[n]); 76 ret->set(inter * (keyValues[n + 1].x - keyValues[n].x) + keyValues[n].x, 77 inter * (keyValues[n + 1].y - keyValues[n].y) + keyValues[n].y, 78 inter * (keyValues[n + 1].z - keyValues[n].z) + keyValues[n].z); 79 79 } 80 80 } … … 82 82 83 83 void 84 TransferFunction::sample(float fraction, float *key , int count, float *keyValue, float *ret)84 TransferFunction::sample(float fraction, float *keys, float *keyValues, int count, float *ret) 85 85 { 86 86 int limit = count - 1; 87 if (fraction <= key [0]) {88 *ret = keyValue [0];89 } else if (fraction >= key [limit]) {90 *ret = keyValue [limit];87 if (fraction <= keys[0]) { 88 *ret = keyValues[0]; 89 } else if (fraction >= keys[limit]) { 90 *ret = keyValues[limit]; 91 91 } else { 92 92 int n; 93 for (n = 0; n < limit; n++) {94 if (fraction >= key [n] && fraction < key[n+1]) break;93 for (n = 0; n < limit; n++) { 94 if (fraction >= keys[n] && fraction < keys[n+1]) break; 95 95 } 96 96 if (n >= limit) { 97 *ret = keyValue [limit];97 *ret = keyValues[limit]; 98 98 } else { 99 float inter = (fraction - key [n]) / (key[n + 1] - key[n]);100 *ret = inter * (keyValue [n + 1] - keyValue[n]) + keyValue[n];99 float inter = (fraction - keys[n]) / (keys[n + 1] - keys[n]); 100 *ret = inter * (keyValues[n + 1] - keyValues[n]) + keyValues[n]; 101 101 } 102 102 } -
nanovis/branches/1.1/TransferFunction.h
r3568 r4819 62 62 } 63 63 64 static void sample(float fraction, float *key , int count, vrmath::Vector3f *keyValue, vrmath::Vector3f *ret);64 static void sample(float fraction, float *keys, vrmath::Vector3f *keyValues, int count, vrmath::Vector3f *ret); 65 65 66 static void sample(float fraction, float *key , int count, float *keyValue, float *ret);66 static void sample(float fraction, float *keys, float *keyValues, int count, float *ret); 67 67 68 68 protected :
Note: See TracChangeset
for help on using the changeset viewer.