00001 #include "stdafx.h" 00002 #include "transfunc.h" 00003 00004 Transfunc::Transfunc() 00005 { 00006 opacitymap = new float[4096]; 00007 colormap = new rgb[4096]; 00008 for(int i = 0; i < 4096; i++) 00009 { 00010 opacitymap[i] = 0.0; 00011 colormap[i].r = 0; 00012 colormap[i].g = 0; 00013 colormap[i].b = 0; 00014 } 00015 } 00016 00017 00018 Transfunc::Transfunc(const Transfunc &trans) { 00019 if (!colormap) 00020 colormap = new rgb[4096]; 00021 if (!opacitymap) 00022 opacitymap = new float[4096]; 00023 00024 00025 for (int i = 0; i < 4096; i++) { 00026 colormap[i] = trans.colormap[i]; 00027 opacitymap[i] = trans.opacitymap[i]; 00028 } 00029 } 00030 00031 00032 Transfunc::~Transfunc() 00033 { 00034 if(colormap != NULL) { 00035 delete[] colormap; 00036 colormap = NULL; 00037 } 00038 if(opacitymap != NULL) { 00039 delete[] opacitymap; 00040 opacitymap = NULL; 00041 } 00042 } 00043 00044 rgb 00045 Transfunc::GetDensityColor(int dens) 00046 { 00047 if (dens > 4095) 00048 dens = 4095; 00049 00050 return colormap[dens]; 00051 } 00052 00053 bool 00054 Transfunc::SetDensityColor(int dens, rgb col) 00055 { 00056 colormap[dens].r = col.r; 00057 colormap[dens].g = col.g; 00058 colormap[dens].b = col.b; 00059 return true; 00060 } 00061 00062 float 00063 Transfunc::GetOpacity(int dens) 00064 { 00065 if (dens > 4095) 00066 dens = 4095; 00067 00068 if (dens < 0) 00069 dens = 0; 00070 00071 return opacitymap[dens]; 00072 } 00073 00074 bool 00075 Transfunc::SetOpacity(int dens, float opac) 00076 { 00077 opacitymap[dens] = opac; 00078 return true; 00079 }