U:/visualisierung/VolumeVis/src/main.cpp File Reference

#include <windows.h>
#include <stdlib.h>
#include <io.h>
#include <iostream>
#include <string.h>
#include <glew.h>
#include <il.h>
#include <math.h>
#include <GL/glui.h>
#include <GL/glut.h>
#include "Volume.h"
#include "TransferFunction.h"
#include "Timer.h"
#include "Vector.h"

Defines

#define WINDOW_WIDTH   768
#define WINDOW_HEIGHT   768
#define RENDER_SLICE_X   0
#define RENDER_SLICE_Y   1
#define RENDER_SLICE_Z   2
#define RENDER_VOLUME_ACCUMULATE   3
#define RENDER_VOLUME_MIP   4
#define RENDER_VOLUME_AVERAGE   5
#define MODE_INIT   0
#define MODE_RENDER   1
#define MODE_LOADING_DATA   2

Functions

void glutDisplay ()
void updateDisplay (int)
void renderSlice ()
void renderVolume ()
void renderColorBox ()
void renderCameraInfo ()
void renderTF ()
void init ()
void initGLUIControls (GLUI *glui)
int initGL (int argc, char *argv[])
void glutIdle ()
void processMouse (int pButton, int pState, int pX, int pY)
void processMouseMotion (int pX, int pY)
void selectRenderMode (int)
void setPerspective ()
void setOrthogonal ()
void cameraZoomVolume (int)
void updateVolumeRendering (int)
void cameraChange (int)
void loadDataFile (int)
const int GetNextPowerOfTwo (const int iNumber)
void updateSliceTextures ()
void updateTFData ()
void chooseColor (int)
void loadSetting (int)
void saveSetting (int)
void updateSettingFileNames ()
void loadSettingFileNames ()
void saveSettingFileNames ()
void inputSettingFileName (int)
int getNumPRSteps (int startStepSize)
int getNextPRStepSize (int oldPRstepSize)
int main (int argc, char *argv[])

Variables

int HIST_X = 30
int HIST_Y = 500
int HIST_W = WINDOW_WIDTH / 2 - 2*HIST_X
int HIST_H = 200
int TRANSFUNC_BLOCKSIZE = 5
int INTCOL_X = HIST_X
int INTCOL_Y = HIST_Y + HIST_H + 30
int INTCOL_W = WINDOW_WIDTH / 2 - 2*INTCOL_X
int INTCOL_H = 30
int GRAD_X = WINDOW_WIDTH / 2 + HIST_X
int GRAD_Y = HIST_Y
int GRAD_W = HIST_W
int GRAD_H = HIST_H
vector< string > volumeNames
vector< string > fileNames
vector< string > settingFileNames
unsigned int I2CTexture = 0
unsigned int G2OTexture = 0
unsigned int sliceTexture = 0
Volume volume
TransferFunction transFunc
Timer timer
int mode = MODE_INIT
int renderMode = RENDER_SLICE_X
int selectedVolumeFile = 3
int selectedSettingFile = 0
string settingFileName
float cameraRotation [16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }
float cameraZoom = 1
float lightRotation [16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }
VectorlightPos
float lightAmbient
int selectedI2O = -1
int selectedG2O = -1
float lastMouseClick = -1
float histScale = 1
float stepSize = 1.0f
float clipXmin = 0
float clipXmax = 1
float clipYmin = 0
float clipYmax = 1
float clipZmin = 0
float clipZmax = 1
float * I2OData = new float[1024]
float * I2CData = new float[1024*3]
float * G2OData = new float[1024]
unsigned char * FrontBuffer = new unsigned char[WINDOW_WIDTH * WINDOW_HEIGHT * 4]
unsigned char * BackBuffer = new unsigned char[WINDOW_WIDTH * WINDOW_HEIGHT * 3]
unsigned char * ResultBuffer = new unsigned char[WINDOW_WIDTH * WINDOW_HEIGHT * 3]
bool doRenderVolume = false
bool doRenderCameraInfo = true
int doLoadSaveCameraSettings = 1
int doLoadSaveTFSettings = 1
int doLoadSaveOptionsSettings = 1
int doLoadSaveLightSettings = 1
int doLoadSaveClippingSettings = 1
int doShowTFPreview = 1
int doEnableLights = 1
int doEnableAdaptStepSize = 1
int doEnableTrilinearInterpolation = 1
int doEnablePreshading = 1
int doEnableProgressiveRefinement = 1
GLUI_Scrollbar * ui_sliceX
GLUI_Scrollbar * ui_sliceY
GLUI_Scrollbar * ui_sliceZ
GLUI_Scrollbar * ui_histScale
GLUI_Translation * ui_camZoom
GLUI_Listbox * ui_settingFiles
GLUI_EditText * ui_settingFileName
GLUI_Rotation * ui_camRotation
GLUI_Translation * ui_camTranslation
GLUI_Rotation * ui_lightRotation
GLUI_Scrollbar * ui_clipXmin
GLUI_Scrollbar * ui_clipXmax
GLUI_Scrollbar * ui_clipYmin
GLUI_Scrollbar * ui_clipYmax
GLUI_Scrollbar * ui_clipZmin
GLUI_Scrollbar * ui_clipZmax
GLUI_Checkbox * ui_enableLights
GLUI_Checkbox * ui_enableAdaptStepSize
GLUI_Checkbox * ui_enableTrilinearInterpolation
GLUI_Checkbox * ui_enablePreshading
GLUI_Checkbox * ui_enableProgressiveRefinement
GLUI_Spinner * ui_stepSize

Define Documentation

#define MODE_INIT   0

State variable for mode (initiating everything)

#define MODE_LOADING_DATA   2

State variable for mode (loading new data file, no rendering)

#define MODE_RENDER   1

State variable for mode (render slices or volume)

#define RENDER_SLICE_X   0

State variable for render mode (slicing in X direction)

#define RENDER_SLICE_Y   1

State variable for render mode (slicing in Y direction)

#define RENDER_SLICE_Z   2

State variable for render mode (slicing in Z direction)

#define RENDER_VOLUME_ACCUMULATE   3

State variable for render mode (volume rendering, with accumulation as compositing method)

#define RENDER_VOLUME_AVERAGE   5

State variable for render mode (volume rendering, with averaging as compositing method)

#define RENDER_VOLUME_MIP   4

State variable for render mode (volume rendering, with maximum intensity projection as compositing method)

#define WINDOW_HEIGHT   768

Height of the render window

#define WINDOW_WIDTH   768

Width of the render window


Function Documentation

void cameraChange ( int   ) 

The camera (e.g. rotation, zoom) changed, so the wireframe has to be rendered.

Parameters:
not used! just has to be an int so it can be used as callback function for glui

void cameraZoomVolume ( int   ) 

The camera zoom factor is changed an if needed the window perspective updated.

Parameters:
not used! just has to be an int so it can be used as callback function for glui

void chooseColor ( int   ) 

The user wants to select an other color for on of the tranferfunction control points.

Parameters:
not used! just has to be an int so it can be used as callback function for glui

const int GetNextPowerOfTwo ( const int  iNumber  ) 

Generates the next power of two of a given number.

Parameters:
iNumber the number the next power of two has to be generated
Returns:
next power of two

int getNextPRStepSize ( int  oldPRstepSize  ) 

Calculates the next step size for progressive refinement.

Parameters:
oldPRstepSize old progressive refinement step size
Returns:
next step size

int getNumPRSteps ( int  startStepSize  ) 

Returns the number of progressive refinement steps.

Parameters:
startStepSize The first step size (which is usually the window width or window height)
Returns:
number of steps

void glutDisplay (  ) 

Main display function, calls render-functions which will be needed.

void glutIdle (  ) 

The glut idle function, which has nothing to do.

void init (  ) 

Initiates non-render and non-ui stuff.

int initGL ( int  argc,
char *  argv[] 
)

Initates the render window an other render stuff.

Parameters:
argc number of arguments in argv
argv list of cfommand line arguments
Returns:
EXIT_FAILURE if init failed or EXIT_SUCCESS else.

void initGLUIControls ( GLUI *  glui  ) 

Initiates UI controls.

Parameters:
glui the UI window

void inputSettingFileName ( int   ) 

Name of selected setting file is set into the file name text box

Parameters:
not used! just has to be an int so it can be used as callback function for glui

void loadDataFile ( int   ) 

Load a new volume data file.

Parameters:
not used! just has to be an int so it can be used as callback function for glui

void loadSetting ( int   ) 

Load volume render settings from files.

Parameters:
not used! just has to be an int so it can be used as callback function for glui

void loadSettingFileNames (  ) 

Load the setting file names out of a file.

int main ( int  argc,
char *  argv[] 
)

main function which starts the programm.

Parameters:
argc number of arguments in argv
list of command line arguments
Returns:
EXIT_FAILURE if starting failed, EXIT_SUCCESS else (after programm finished);

void processMouse ( int  pButton,
int  pState,
int  x,
int  y 
)

Processes mouse clicks in the render window.

Parameters:
pButton the button that has been clicked
pState has the button just been pressed or released? (mouse down or mouse up)
x x Position of the mouse cursor
y y Position of the mouse cursor

void processMouseMotion ( int  x,
int  y 
)

Processes mouse movement over the render window.

Parameters:
x x Position of the mouse cursor
y y Position of the mouse cursor

void renderCameraInfo (  ) 

Renders the camera info (position, rotation, zoom and light) so the user sees where the camera is positioned.

void renderColorBox (  ) 

Renders the bounding box of the volume, x-/y-/z-coordinates are represented as RGB colors.

void renderSlice (  ) 

Render a volume slice.

void renderTF (  ) 

Render the transferfunction and volume date histrograms

void renderVolume (  ) 

Renders the volume.

void saveSetting ( int   ) 

Save volume render settings into files.

Parameters:
not used! just has to be an int so it can be used as callback function for glui

void saveSettingFileNames (  ) 

Save the setting file names in a file.

void selectRenderMode ( int   ) 

Selects another render mode an changes projection.

Parameters:
not used! just has to be an int so it can be used as callback function for glui

void setOrthogonal (  ) 

Sets a ortogonal projection (will be used for slicing and rendering of the transferfunction)

void setPerspective (  ) 

Sets a perspective projection (will be used for volume rendering).

void updateDisplay ( int   ) 

The display will be updated (this is used if an ui control is used that changes something in the render window)

Parameters:
not used! just has to be an int so it can be used as callback function for glui

void updateSettingFileNames (  ) 

Updates the setting file list.

void updateSliceTextures (  ) 

The 3D texture data for slicing is updated (and created at startup).

void updateTFData (  ) 

Transferfunction data has be changed, so textures have to be updated.

void updateVolumeRendering ( int   ) 

The user wants to render the volume.

Parameters:
not used! just has to be an int so it can be used as callback function for glui


Variable Documentation

unsigned char* BackBuffer = new unsigned char[WINDOW_WIDTH * WINDOW_HEIGHT * 3]

buffer for back faces of color box (end points of rays)

float cameraRotation[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }

rotation of the camera

float cameraZoom = 1

zoom factor of the camera

float clipXmax = 1

maximum x coordinate used for rendering

float clipXmin = 0

minimum x coordinate used for rendering

float clipYmax = 1

maximum y coordinate used for rendering

float clipYmin = 0

minimum y coordinate used for rendering

float clipZmax = 1

maximum z coordinate used for rendering

float clipZmin = 0

minimum z coordinate used for rendering

int doEnableAdaptStepSize = 1

enable adaptive step size for volume rendering?

int doEnableLights = 1

enable lights for volume rendering?

int doEnablePreshading = 1

enable preshading for volume rendering?

int doEnableProgressiveRefinement = 1

enable progressive refinement for volume rendering?

int doEnableTrilinearInterpolation = 1

enable trilinear interpolation for volume rendering?

int doLoadSaveCameraSettings = 1

shall camera settings be loaded/saved

int doLoadSaveClippingSettings = 1

shall clipping settings be loaded/saved

int doLoadSaveLightSettings = 1

shall light settings be loaded/saved

int doLoadSaveOptionsSettings = 1

shall option settings be loaded/saved

int doLoadSaveTFSettings = 1

shall transfer function settings be loaded/saved

bool doRenderCameraInfo = true

shall the camera info be rendered

bool doRenderVolume = false

shall the volume be rendered

int doShowTFPreview = 1

shall the transfer function be rendered?

vector<string> fileNames

list of volume files (filenames)

unsigned char* FrontBuffer = new unsigned char[WINDOW_WIDTH * WINDOW_HEIGHT * 4]

buffer for front faces of color box (start points of rays)

float* G2OData = new float[1024]

gradient->opacity data of transferfunction, used for volume rendering

unsigned int G2OTexture = 0

texture for gradient->opacity part of the transferfunction

int GRAD_H = HIST_H

height of the gradient histogram

int GRAD_W = HIST_W

width of the gradient histogram

int GRAD_X = WINDOW_WIDTH / 2 + HIST_X

x position of the gradient histogram

int GRAD_Y = HIST_Y

y position of the gradient histogram

int HIST_H = 200

height of the intensity histogram

int HIST_W = WINDOW_WIDTH / 2 - 2*HIST_X

width of the intensity histogram

int HIST_X = 30

x position of the intensity histogram

int HIST_Y = 500

y position of the intensity histogram

float histScale = 1

scale factor for histograms

float* I2CData = new float[1024*3]

intensity->color data of transferfunction, used for volume rendering

unsigned int I2CTexture = 0

texture for intensity->color part of the transferfunction

float* I2OData = new float[1024]

intensity->opacity data of transferfunction, used for volume rendering

int INTCOL_H = 30

height of the intensity color texture

int INTCOL_W = WINDOW_WIDTH / 2 - 2*INTCOL_X

width of the intensity color texture

int INTCOL_X = HIST_X

x position of the intensity color texture

int INTCOL_Y = HIST_Y + HIST_H + 30

y position of the intensity color texture

float lastMouseClick = -1

time the last mouse click happened (to check for double clicks)

float lightAmbient

ambient part of the light

Vector* lightPos

position of the light

float lightRotation[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }

rotation of the light

int mode = MODE_INIT

program mode

int renderMode = RENDER_SLICE_X

render mode (what shall be rendered)

unsigned char* ResultBuffer = new unsigned char[WINDOW_WIDTH * WINDOW_HEIGHT * 3]

buffer for result of volume rendering

int selectedG2O = -1

selected gradient->opacity control point (-1 if none selected)

int selectedI2O = -1

selected intensity->opacity control point (-1 if none selected)

int selectedSettingFile = 0

selected setting file used for saving/loading settings

int selectedVolumeFile = 3

selected volume file used for rendering

string settingFileName

name of the selected setting file

vector<string> settingFileNames

list of setting file names

unsigned int sliceTexture = 0

texture for slicing

float stepSize = 1.0f

step size used for volume rendering

Timer timer

timer used to measure time spans while rendering and mouse clicks

TransferFunction transFunc

the transferfunction used for rendering

int TRANSFUNC_BLOCKSIZE = 5

size of control point squares

GLUI_Rotation* ui_camRotation

ui control for camera rotation

GLUI_Translation* ui_camTranslation

ui control for camera translation

GLUI_Translation* ui_camZoom

ui control for camera zoom factor

GLUI_Scrollbar* ui_clipXmax

ui control for maximum x coordinate for volume rendering

GLUI_Scrollbar* ui_clipXmin

ui control for minimum x coordinate for volume rendering

GLUI_Scrollbar* ui_clipYmax

ui control for maximum y coordinate for volume rendering

GLUI_Scrollbar* ui_clipYmin

ui control for minimum y coordinate for volume rendering

GLUI_Scrollbar* ui_clipZmax

ui control for maximum z coordinate for volume rendering

GLUI_Scrollbar* ui_clipZmin

ui control for minimum z coordinate for volume rendering

GLUI_Checkbox* ui_enableAdaptStepSize

ui control for enabling adaptive step size for volume rendering

GLUI_Checkbox* ui_enableLights

ui control for enabling lights for volume rendering

GLUI_Checkbox* ui_enablePreshading

ui control for enabling preshading for volume rendering

GLUI_Checkbox* ui_enableProgressiveRefinement

ui control for enabling progressive refinement for volume rendering

GLUI_Checkbox* ui_enableTrilinearInterpolation

ui control for enabling trilinear interpolation for volume rendering

GLUI_Scrollbar* ui_histScale

ui control for histrogram scale factor

GLUI_Rotation* ui_lightRotation

ui control for light rotation

GLUI_EditText* ui_settingFileName

ui control for actual setting file name

GLUI_Listbox* ui_settingFiles

ui control for setting file list

GLUI_Scrollbar* ui_sliceX

ui control for slicing in x directin

GLUI_Scrollbar* ui_sliceY

ui control for slicing in y direction

GLUI_Scrollbar* ui_sliceZ

ui control for slicing in z direction

GLUI_Spinner* ui_stepSize

ui control for step size for volume rendering

Volume volume

volume with the data used for rendering

vector<string> volumeNames

list of volume files (human readable names)


Generated on Fri Nov 30 16:22:24 2007 for Volume Visualisation by  doxygen 1.5.4