#include <raycaster.h>
| Public Methods | |
| Raycaster () | |
| ~Raycaster () | |
| bool | SetViewingCondition (VECTOR lightpos, Color background, float ambient, float diffuse, float specular, int highlight) | 
| virtual bool | Initialize (int width, int height, float steplength, Data *data, Transfunc *tf) | 
| virtual bool | Raycast () | 
| bool | SetTreshold (int treshold) | 
| bool | SetRaytype (int type) | 
| bool | SetRendermode (int rendermode) | 
| bool | SetPreCalcGradients (bool pc) | 
| bool | Zoom (float zoom) | 
| void | SetWidth (int width) | 
| void | SetHeight (int height) | 
| void | SetStepLength (float steplength) | 
| void | SetAmbient (float ambient) | 
| void | SetDiffuse (float diffuse) | 
| void | SetSpecular (float specular) | 
| void | SetHighlight (int highlight) | 
| void | SetLightpos (VECTOR lightpos) | 
| void | SetLight (bool light) | 
| void | SetBackgroundColor (unsigned char r, unsigned char g, unsigned char b) | 
| void | SetDensRange (int mindens, int maxdens) | 
| virtual bool | RotateX (float alpha) | 
| virtual bool | RotateY (float alpha) | 
| virtual bool | RotateZ (float alpha) | 
| bool | Render (int width, int height) | 
| rgb * | GetScreenShotImage (int &width, int &height) | 
| Public Attributes | |
| int | m_dOwnType | 
| Protected Methods | |
| bool | SetViewingMatrix () | 
| Protected Attributes | |
| bool | ready | 
| bool | m_light | 
| VECTOR | m_lightpos | 
| float | m_ambient | 
| float | m_diffuse | 
| float | m_steplength | 
| float | m_specular | 
| int | m_treshold | 
| int | m_highlight | 
| int | m_width | 
| int | m_height | 
| Matrix4x4 * | m_viewingtoworld | 
| Matrix4x4 * | m_viewingtoworld_inv | 
| int | m_raytype | 
| int | m_rendermode | 
| rgb * | m_image | 
| Data * | m_data | 
| Transfunc * | m_tf | 
| Color | m_background | 
| bool | m_precalc | 
| float | m_zoom | 
| float | m_stepX | 
| float | m_stepY | 
| VECTOR | m_xdir | 
| VECTOR | m_ydir | 
| int | m_dMinDens | 
| int | m_dMaxDens | 
| 
 | 
| raycaster.cpp implementiert den Raycaster der für jeden Bildpunkt einen Strahl initialisiert und die von dem Strahl berechnete Farbe im Bild speichert Definition at line 11 of file raycaster.cpp. References m_ambient, m_data, m_diffuse, m_dMaxDens, m_dMinDens, m_dOwnType, m_height, m_highlight, m_image, m_light, m_lightpos, m_precalc, m_raytype, m_rendermode, m_specular, m_stepX, m_stepY, m_tf, m_treshold, m_viewingtoworld, m_width, m_xdir, m_ydir, m_zoom, NN, RAYCASTER, ready, and STANDARD. 
 00011                      {
00012         ready = false;
00013         
00014         m_specular = 0.2f;
00015         m_highlight = 8;
00016         m_lightpos = VECTOR(300,300,300);
00017         m_light = false;
00018         m_image = NULL;
00019         m_ambient = 0.2f;
00020         m_diffuse = 0.2f;
00021         m_height = 0;
00022         m_width = 0;
00023         m_viewingtoworld = NULL;
00024         m_stepX = 1.0;
00025         m_stepY = 1.0;
00026         m_data = NULL;
00027         m_tf = NULL;
00028         m_xdir = VECTOR(1,0,0);
00029         m_ydir = VECTOR(0,1,0);
00030         m_treshold = 1500;
00031         m_rendermode = STANDARD;
00032         m_raytype = NN;
00033         m_precalc = false;
00034         m_zoom = 1.0;
00035 
00036         m_dOwnType = RAYCASTER;
00037 
00038         m_dMaxDens = 4095;
00039         m_dMinDens = 0;
00040 }
 | 
| 
 | 
| 
 Definition at line 42 of file raycaster.cpp. References m_image, and m_viewingtoworld. 
 00042                       {
00043         if(m_image != NULL) delete m_image;
00044         if(m_viewingtoworld != NULL) delete m_viewingtoworld;
00045         m_image = NULL;
00046         m_viewingtoworld = NULL;
00047 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 77 of file raycaster.h. Referenced by CMy3dvisView::OnFileSaveImage(), and CVolumeDialog::OnShowWindow(). 
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 78 of file raycaster.cpp. References m_data, m_height, m_steplength, m_tf, and m_width. 
 00078                                                                                         {
00079         m_data = data;
00080         m_tf = tf;
00081         m_width = width;
00082         m_height = height;
00083         m_steplength = steplength;
00084         return true;
00085 }
 | 
| 
 | 
| 
 Definition at line 105 of file raycaster.cpp. References Ray::CastNext(), FH, Ray::GetCurrentColor(), Data::GetXDim(), Data::GetYDim(), Data::GetZDim(), Ray::Initialize(), m_data, m_height, m_image, m_raytype, m_viewingtoworld_inv, m_width, m_xdir, m_ydir, MI, NN, Plane::normal, ready, Ray::Reset(), Ray::SetDensRange(), Ray::SetLight(), Ray::SetPosDir(), Data::SetPreCalc(), Ray::SetViewingCondition(), STANDARD, Color::toRGB(), Matrix4x4::translate(), TRI, VECTOR::x, XRAY, VECTOR::y, and VECTOR::z. Referenced by volumebar::OnButtonRenderVolume(). 
 00105                    {
00106 
00107         CWnd* pFrame = AfxGetMainWnd();
00108 
00109 
00110         m_data->SetPreCalc(m_precalc);
00111         m_image = new rgb[m_width*m_height];
00112         
00113         int maxX = m_data->GetXDim();
00114         int maxY = m_data->GetYDim();
00115         int maxZ = m_data->GetZDim();
00116 
00117         VECTOR pos =  VECTOR(0,0,0);
00118         Matrix4x4 trans;
00119         trans.translate(VECTOR(-maxX/2,-maxY/2,-maxZ/2));
00120         pos = trans * pos;
00121         pos = *m_viewingtoworld_inv * pos;
00122         trans.translate(VECTOR(maxX/2,maxY/2,maxZ/2));
00123         pos = trans*pos;
00124         VECTOR backup = pos;
00125 
00126         VECTOR normal = VECTOR(0,0,0)-pos;
00127         if(normal.x == 0 && normal.y == 0 && normal.z == 0)
00128                 normal.z = 1.0;
00129 
00130         Plane *viewingplane = new Plane(normal,pos);
00131         m_xdir = *m_viewingtoworld_inv * m_xdir;
00132         m_ydir = *m_viewingtoworld_inv * m_ydir;
00133         
00134         int loadSize = (m_height * m_width) / 100;
00135         int counter = loadSize / 100;
00136         int progPos = 0;
00137 
00138 
00139 
00140         Ray *r;
00141         switch (m_rendermode) {
00142                 case STANDARD:
00143                         if (m_raytype == NN)
00144                                 r = new Ray();
00145                         else if (m_raytype == TRI)
00146                                 r = new Trilinear();
00147                         break;
00148                 case FH:
00149                         if (m_raytype == NN) {
00150                                 r = new FirstHitNN();
00151                                 ((FirstHitNN *)r)->SetTreshold(m_treshold);
00152                         }
00153                         else if (m_raytype == TRI) {
00154                                 r = new FirstHitTRI();
00155                                 ((FirstHitTRI *)r)->SetTreshold(m_treshold);
00156                         }
00157                         break;
00158                 case MI:
00159                         if (m_raytype == NN)
00160                                 r = new MaxIntensityNN();
00161                         else if (m_raytype == TRI)
00162                                 r = new MaxIntensityTRI();
00163                         break;
00164                 case XRAY:
00165                         if (m_raytype == NN)
00166                                 r = new XRayNN();
00167                         else if (m_raytype == TRI)
00168                                 r = new XRayTRI();
00169                         
00170                         r->SetDensRange(m_dMinDens, m_dMaxDens);
00171                         break;
00172         }
00173 
00174         r->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00175         r->Initialize(m_background,m_background,m_steplength,viewingplane,m_data,m_tf);
00176         r->SetLight(m_light);
00177 
00178         for(int j = 0; j < m_height; j++) {
00179                 for(int i = 0; i < m_width; i++) {
00180                         r->Reset();
00181                         r->SetPosDir(pos, viewingplane->normal);
00182                         r->CastNext();
00183                         m_image[j * m_width + i] = r->GetCurrentColor().toRGB();
00184 
00185                         pos += m_xdir;
00186 
00187                         if ((counter-- <= 0) && (progPos < 100)) {
00188                                 counter = loadSize;
00189                                 pFrame->SendMessage(MYWM_PROGRESS, progPos++);
00190                         }
00191 
00192 
00193                 } // inner for
00194                 pos = backup;
00195                 pos += j*m_ydir;
00196 
00197                 pFrame->SendMessage(MYWM_PROGRESS, 0);
00198         
00199         }
00200 
00201         
00202 
00203         if (r)
00204                 delete r;
00205         
00206         ready = true;
00207         return true;
00208 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 62 of file raycaster.cpp. References m_height, m_width, and ready. Referenced by CMy3dvisView::RenderScene(). 
 00062                                        {
00063 
00064         int m_x = width / 2 - m_width / 2;
00065         int m_y = height / 2 - m_height / 2;
00066 
00067 
00068         if (!ready)
00069                 return false;
00070 
00071         glRasterPos2i(m_x, m_y);
00072         glPixelStorei(GL_UNPACK_ALIGNMENT,1);
00073         glDrawPixels(m_width, m_height, GL_RGB, GL_UNSIGNED_BYTE, m_image);
00074         return true;
00075 }
 | 
| 
 | 
| 
 Definition at line 243 of file raycaster.cpp. References m_viewingtoworld, m_viewingtoworld_inv, Matrix4x4::mul(), and Matrix4x4::rotateX(). Referenced by CVolumeDialog::OnButtonXPlus(). 
 00243                               {
00244         Matrix4x4 rotmat1;
00245         Matrix4x4 rotmat2;
00246         rotmat1.rotateX(alpha);
00247         rotmat2.rotateX(-alpha);
00248         
00249         *m_viewingtoworld = m_viewingtoworld->mul(rotmat1);
00250         *m_viewingtoworld_inv = m_viewingtoworld_inv->mul(rotmat2);
00251         return true;
00252 }
 | 
| 
 | 
| 
 Definition at line 255 of file raycaster.cpp. References m_viewingtoworld, m_viewingtoworld_inv, Matrix4x4::mul(), and Matrix4x4::rotateY(). 
 00255                               {
00256         Matrix4x4 rotmat1;
00257         Matrix4x4 rotmat2;
00258         rotmat1.rotateY(alpha);
00259         rotmat2.rotateY(-alpha);
00260         
00261         *m_viewingtoworld = m_viewingtoworld->mul(rotmat1);
00262         *m_viewingtoworld_inv = m_viewingtoworld_inv->mul(rotmat2);
00263         return true;
00264 }
 | 
| 
 | 
| 
 Definition at line 267 of file raycaster.cpp. References m_viewingtoworld, m_viewingtoworld_inv, Matrix4x4::mul(), and Matrix4x4::rotateZ(). 
 00267                               {
00268         Matrix4x4 rotmat1;
00269         Matrix4x4 rotmat2;
00270         rotmat1.rotateZ(alpha);
00271         rotmat2.rotateZ(-alpha);
00272         
00273         *m_viewingtoworld = m_viewingtoworld->mul(rotmat1);
00274         *m_viewingtoworld_inv = m_viewingtoworld_inv->mul(rotmat2);
00275         return true;
00276 }
 | 
| 
 | 
| 
 Definition at line 59 of file raycaster.h. Referenced by CVolumeDialog::OnChangeEditAmbient(). 
 00059 { m_ambient = ambient; };
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 65 of file raycaster.h. Referenced by CVolumeDialog::OnButtonBgcolor(). 
 00065                                                                                    {
00066                                                                                                                 m_background = Color(r, g, b); };
 | 
| 
 | ||||||||||||
| 
 Definition at line 68 of file raycaster.h. Referenced by CVolumeDialog::OnChangeEditXrayMax(), and CVolumeDialog::OnChangeEditXrayMin(). 
 00068 { m_dMinDens = mindens; m_dMaxDens = maxdens; };
 | 
| 
 | 
| 
 Definition at line 60 of file raycaster.h. Referenced by CVolumeDialog::OnChangeEditDiffuse(). 
 00060 { m_diffuse = diffuse; };
 | 
| 
 | 
| 
 Definition at line 56 of file raycaster.h. Referenced by CVolumeDialog::OnChangeEditHeight(). 
 00056 { m_height = height; };
 | 
| 
 | 
| 
 Definition at line 62 of file raycaster.h. Referenced by CVolumeDialog::OnChangeEditHighlight(). 
 00062 {m_highlight = highlight;};
 | 
| 
 | 
| 
 Definition at line 64 of file raycaster.h. Referenced by CVolumeDialog::OnCheckLight(), and CVolumeDialog::OnRadioStandard(). 
 00064 {m_light = light;};
 | 
| 
 | 
| 
 Definition at line 63 of file raycaster.h. Referenced by CVolumeDialog::OnChangeEditLightposX(), CVolumeDialog::OnChangeEditLightposY(), and CVolumeDialog::OnChangeEditLightposZ(). 
 00063 { m_lightpos = lightpos;};
 | 
| 
 | 
| 
 Definition at line 52 of file raycaster.h. 
 00052 { m_precalc = pc; return true;};
 | 
| 
 | 
| 
 Definition at line 50 of file raycaster.h. Referenced by volumebar::OnRadioVolumeNn(), and volumebar::OnRadioVolumeTri(). 
 00050 { m_raytype = type; return true;};
 | 
| 
 | 
| 
 Definition at line 51 of file raycaster.h. Referenced by CVolumeDialog::OnRadioFirsthit(), CVolumeDialog::OnRadioMip(), CVolumeDialog::OnRadioStandard(), and CVolumeDialog::OnRadioXray(). 
 00051 { m_rendermode = rendermode; return true;};
 | 
| 
 | 
| 
 Definition at line 61 of file raycaster.h. Referenced by CVolumeDialog::OnChangeEditSpecular(). 
 00061 { m_specular = specular;};
 | 
| 
 | 
| 
 Definition at line 57 of file raycaster.h. 
 00057 { m_steplength = steplength; };
 | 
| 
 | 
| 
 Definition at line 49 of file raycaster.h. Referenced by CVolumeDialog::OnChangeEditFhThreshold(). 
 00049 { m_treshold = treshold; return true;};
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 50 of file raycaster.cpp. References m_ambient, m_background, m_diffuse, m_highlight, m_lightpos, and m_specular. 
 00050                                                                                                                              {
00051         m_ambient = ambient;
00052         m_diffuse = diffuse;
00053         m_background = background;
00054         m_specular = specular;
00055         m_highlight = highlight;
00056         m_lightpos = lightpos;
00057         return true;
00058 }
 | 
| 
 | 
| 
 Definition at line 227 of file raycaster.cpp. References Matrix4x4::identity(), m_stepX, m_stepY, m_viewingtoworld, m_viewingtoworld_inv, m_xdir, and m_ydir. Referenced by Zoom(). 
 00227                             {
00228         VECTOR zaxis = VECTOR(0,0,1);
00229         m_viewingtoworld = new Matrix4x4();
00230         m_viewingtoworld->identity();
00231         m_viewingtoworld_inv = new Matrix4x4();
00232         m_viewingtoworld_inv->identity();
00233         m_xdir = VECTOR(1,0,0);
00234         m_ydir = VECTOR(0,1,0);
00235 
00236         m_xdir = m_stepX * m_xdir;
00237         m_ydir = m_stepY * m_ydir;
00238 
00239         return true;
00240 }
 | 
| 
 | 
| 
 Definition at line 55 of file raycaster.h. Referenced by CVolumeDialog::OnChangeEditWidth(). 
 00055 { m_width = width; };
 | 
| 
 | 
| 
 Definition at line 212 of file raycaster.cpp. References Data::GetXDim(), Data::GetYDim(), Data::GetZDim(), m_data, m_height, m_stepX, m_stepY, m_width, m_zoom, and SetViewingMatrix(). Referenced by CVolumeDialog::OnChangeEditZoom(). 
 00212                           {
00213         int maxX = m_data->GetXDim()-1;
00214         int maxY = m_data->GetYDim()-1;
00215         int maxZ = m_data->GetZDim()-1;
00216         m_zoom = zoom;
00217         float maxlength = sqrtf(powf((float)maxX,2.0)+powf((float)maxY,2.0)+powf((float)maxZ,2.0));
00218         m_stepX = (1/m_zoom)*maxlength/(m_width-1);
00219         m_stepY = (1/m_zoom)*maxlength/(m_height-1);
00220 
00221         SetViewingMatrix();
00222         return true;
00223 }
 | 
| 
 | 
| 
 Definition at line 24 of file raycaster.h. Referenced by Raycaster(), and SetViewingCondition(). | 
| 
 | 
| 
 Definition at line 32 of file raycaster.h. Referenced by SetViewingCondition(). | 
| 
 | 
| 
 Definition at line 30 of file raycaster.h. Referenced by Initialize(), Raycast(), Raycaster(), and Zoom(). | 
| 
 | 
| 
 Definition at line 24 of file raycaster.h. Referenced by Raycaster(), and SetViewingCondition(). | 
| 
 | 
| 
 Definition at line 38 of file raycaster.h. Referenced by Raycaster(). | 
| 
 | 
| 
 Definition at line 38 of file raycaster.h. Referenced by Raycaster(). | 
| 
 | 
| 
 Definition at line 75 of file raycaster.h. Referenced by Raycaster(). | 
| 
 | 
| 
 Definition at line 26 of file raycaster.h. Referenced by Initialize(), Raycast(), Raycaster(), Render(), and Zoom(). | 
| 
 | 
| 
 Definition at line 25 of file raycaster.h. Referenced by Raycaster(), and SetViewingCondition(). | 
| 
 | 
| 
 Definition at line 29 of file raycaster.h. Referenced by Raycast(), Raycaster(), and ~Raycaster(). | 
| 
 | 
| 
 Definition at line 21 of file raycaster.h. Referenced by Raycaster(). | 
| 
 | 
| 
 Definition at line 22 of file raycaster.h. Referenced by Raycaster(), and SetViewingCondition(). | 
| 
 | 
| 
 Definition at line 33 of file raycaster.h. Referenced by Raycaster(). | 
| 
 | 
| 
 Definition at line 28 of file raycaster.h. Referenced by Raycast(), and Raycaster(). | 
| 
 | 
| 
 Definition at line 28 of file raycaster.h. Referenced by Raycaster(). | 
| 
 | 
| 
 Definition at line 24 of file raycaster.h. Referenced by Raycaster(), and SetViewingCondition(). | 
| 
 | 
| 
 Definition at line 24 of file raycaster.h. Referenced by Initialize(). | 
| 
 | 
| 
 Definition at line 35 of file raycaster.h. Referenced by Raycaster(), SetViewingMatrix(), and Zoom(). | 
| 
 | 
| 
 Definition at line 35 of file raycaster.h. Referenced by Raycaster(), SetViewingMatrix(), and Zoom(). | 
| 
 | 
| 
 Definition at line 31 of file raycaster.h. Referenced by Initialize(), and Raycaster(). | 
| 
 | 
| 
 Definition at line 25 of file raycaster.h. Referenced by Raycaster(). | 
| 
 | 
| 
 Definition at line 27 of file raycaster.h. Referenced by Raycaster(), RotateX(), RotateY(), RotateZ(), SetViewingMatrix(), and ~Raycaster(). | 
| 
 | 
| 
 Definition at line 27 of file raycaster.h. Referenced by Raycast(), RotateX(), RotateY(), RotateZ(), and SetViewingMatrix(). | 
| 
 | 
| 
 Definition at line 26 of file raycaster.h. Referenced by Initialize(), Raycast(), Raycaster(), Render(), and Zoom(). | 
| 
 | 
| 
 Definition at line 36 of file raycaster.h. Referenced by Raycast(), Raycaster(), and SetViewingMatrix(). | 
| 
 | 
| 
 Definition at line 36 of file raycaster.h. Referenced by Raycast(), Raycaster(), and SetViewingMatrix(). | 
| 
 | 
| 
 Definition at line 34 of file raycaster.h. Referenced by Raycaster(), and Zoom(). | 
| 
 | 
| 
 Definition at line 20 of file raycaster.h. Referenced by Raycast(), Raycaster(), and Render(). | 
 1.3-rc2
1.3-rc2