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

AverageTRI Class Reference

#include <ray.h>

Inheritance diagram for AverageTRI:

FirstHitTRI Trilinear Ray List of all members.

Public Methods

 AverageTRI ()
 ~AverageTRI ()
bool CastNext ()

Constructor & Destructor Documentation

AverageTRI::AverageTRI   [inline]
 

Definition at line 137 of file ray.h.

00137 {};

AverageTRI::~AverageTRI   [inline]
 

Definition at line 138 of file ray.h.

00138 {};


Member Function Documentation

bool AverageTRI::CastNext   [virtual]
 

Reimplemented from FirstHitTRI.

Definition at line 584 of file ray.cpp.

References FirstHitTRI::GetDensity(), Transfunc::GetDensityColor(), Transfunc::GetOpacity(), VECTOR::length(), Ray::m_alpha, Ray::m_backgroundcolor, Ray::m_currentcolor, Ray::m_currentpos, Ray::m_data, Ray::m_direction, Ray::m_radius, Ray::m_startpoint, Ray::m_steplength, Ray::m_tf, Ray::mx, Ray::my, Ray::mz, ROUND, VECTOR::x, VECTOR::y, and VECTOR::z.

00584                      {
00585         if(m_data == NULL) return false;
00586         if(m_tf == NULL) return false;
00587         int sum = 0;
00588         int counter = 0;
00589         int step_count = 0;
00590         VECTOR distancetomidpoint = VECTOR(mx/2.0f,my/2.0f,mz/2.0f)-m_currentpos;
00591         int steps = (int)((distancetomidpoint.length() + m_radius)/m_steplength);
00592         bool first = true;
00593         do {
00594                 
00595                 if((m_currentpos.x >= 0.0)&&(m_currentpos.y >= 0.0)&&(m_currentpos.z >= 0.0)&&(m_currentpos.x < mx)&&(m_currentpos.y < my)&&(m_currentpos.z < mz)) {
00596                         if(first) {
00597                                 m_startpoint = VECTOR(m_currentpos.x,m_currentpos.y,m_currentpos.z);
00598                                 first = false;
00599                         }
00600                         float d = GetDensity(m_currentpos);
00601                         sum += (int)d;
00602                         counter++;
00603                         
00604                 }
00605                 m_currentpos += m_steplength*m_direction;
00606                 step_count++;
00607         }while(step_count <= steps);
00608         int density = ROUND(sum/counter);
00609         m_currentcolor = m_tf->GetDensityColor(density);
00610         m_alpha = m_tf->GetOpacity(density);
00611         if(density == 0) {
00612                 m_currentcolor = Color(0,0,0);
00613                 m_alpha = 1.0;
00614         }
00615         if(m_alpha < 1.0 ) {
00616                 m_currentcolor += m_backgroundcolor*(1.0f-m_alpha);
00617         }
00618         return true;
00619 }


The documentation for this class was generated from the following files:
Generated on Thu Jan 23 12:32:16 2003 by doxygen1.3-rc2