#include <ray.h>
Inheritance diagram for AverageNN:
Public Methods | |
AverageNN () | |
~AverageNN () | |
bool | CastNext () |
|
Definition at line 130 of file ray.h.
00130 {}; |
|
Definition at line 131 of file ray.h.
00131 {}; |
|
Reimplemented from Ray. Definition at line 547 of file ray.cpp. References Data::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.
00547 { 00548 if(m_data == NULL) return false; 00549 if(m_tf == NULL) return false; 00550 int sum = 0; 00551 int counter = 0; 00552 int step_count = 0; 00553 bool first = true; 00554 VECTOR distancetomidpoint = VECTOR(mx/2.0f,my/2.0f,mz/2.0f)-m_currentpos; 00555 int steps = (int)((distancetomidpoint.length() + m_radius)/m_steplength); 00556 do { 00557 00558 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)) { 00559 if(first) { 00560 m_startpoint = VECTOR(m_currentpos.x,m_currentpos.y,m_currentpos.z); 00561 first = false; 00562 } 00563 int d = m_data->GetDensity((int)ROUND(m_currentpos.x),(int)ROUND(m_currentpos.y),(int)ROUND(m_currentpos.z)); 00564 sum += d; 00565 counter++; 00566 } 00567 // calculate new position 00568 m_currentpos += m_steplength*m_direction; 00569 00570 step_count++; 00571 }while(step_count <= steps); 00572 int density = ROUND(sum/counter); 00573 m_currentcolor = m_tf->GetDensityColor(density); 00574 m_alpha = m_tf->GetOpacity(density); 00575 if(density == 0) { 00576 m_currentcolor = Color(0,0,0); 00577 m_alpha = 1.0; 00578 } 00579 if(m_alpha < 1.0 ) m_currentcolor += m_backgroundcolor*(1.0 - m_alpha); 00580 return true; 00581 } |