Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Spectral/DatPnt.cpp

Go to the documentation of this file.
00001 // DatPnt.cpp: Implementierung der Klasse DatPnt.
00002 //
00004 
00005 #include "spectral.h"
00006 #include "DatPnt.h"
00007 #include "vuSampleRay.h"
00008 
00009 
00010 namespace ns_vu1112112 {
00011 using namespace ns_vu1112112;
00012 
00014 // Konstruktion/Destruktion
00016 
00017 DatPnt::DatPnt()
00018 {
00019         reset();
00020 }
00021 
00022 DatPnt::~DatPnt()
00023 {
00024         
00025 }
00026 
00027 void DatPnt::reset()
00028 {
00029         illum=0;
00030         flag =0;
00031 #ifndef DO_POST_CLASSIFICATION
00032         int i;
00033         for(i=0;i<MAT_NUM_MATERIALS;i++)
00034                 density[i]=0;
00035 #endif
00036 }
00037 
00038 void DatPnt::shade(vu1112112 &r)
00039 {
00040     //take dot product with the light direction and normalize by 128
00041         float ndotl = (float)(grad[0]*r.m_LightDir[0]+
00042                               grad[1]*r.m_LightDir[1]+
00043                               grad[2]*r.m_LightDir[2])/(1<<7);
00044         if(ndotl<0) ndotl=0;
00045         illum = ndotl*r.diffuse+r.brightness;
00046 
00047 // some mislead approach to weight influence of gradient lenght and intensity
00048 //      int v = len*4;
00049 //      if(v>255) v= 255;
00050 //      v=(data*v/255);
00051 //      v=(v+255)/2;
00052 
00053 }
00054 
00055 void DatPnt::classify(vu1112112 &r)
00056 {
00057 #ifndef DO_POST_CLASSIFICATION
00058         int m;
00059         for(m=0;m<r.nummat;m++)
00060         {
00061                 if (data>r.mat[m].low_th &&
00062                         data<=r.mat[m].high_th  )
00063                 {
00064                         int d =((r.mat[m].high_th + r.mat[m].low_th)>>1)-data;
00065                         density[m] = (.5f-(float)fabs((float) d/
00066                                                       (r.mat[m].high_th
00067                                                        -r.mat[m].low_th)))*2.f;
00068                 }               // maybe we apply other distributions here
00069                 else density[m] = 0.f;
00070         }
00071 #elif defined (USE_VUTFUNC)
00072 // do a minimum of pre-classification to determine visibility
00073 // use currently set transfer function
00074         ColourType emissive(r.m_TFunc[data]);
00075         
00076         float alpha = emissive.getAlpha();
00077         if(alpha < 0.001)
00078             setFlag(Invisible);
00079         else
00080             setFlag(Visible);
00081 #else
00082         setFlag(Visible);
00083 #endif
00084 }
00085 
00086 } // end of namespace

Generated on Wed Dec 15 21:20:28 2004 for vuVolume by  doxygen 1.3.9.1