Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

transfunc.cpp

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

Generated on Thu Jan 30 21:35:43 2003 for 3DVis by doxygen1.3-rc2