Changeset 4819 for nanovis/branches/1.1/Command.cpp
- Timestamp:
- Dec 6, 2014 7:16:39 PM (7 years ago)
- Location:
- nanovis/branches/1.1
- Files:
-
- 2 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);
Note: See TracChangeset
for help on using the changeset viewer.