volmetrics

changeset 18:4e02e18e70ef

quick backup - shaders 4 transfer function preview
author Eleni Maria Stea <elene.mst@gmail.com>
date Mon, 24 Mar 2014 23:28:08 +0200
parents 0f4fff558737
children 09896653017e
files convert.sh data/kardia.vol preview.f.glsl preview.v.glsl src/main.cc
diffstat 3 files changed, 126 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/convert.sh	Mon Mar 24 23:28:08 2014 +0200
     1.3 @@ -0,0 +1,6 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +for i in *.dcm; do
     1.7 +    name=`basename $i .dcm`
     1.8 +    convert $i $name.png
     1.9 +done
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/data/kardia.vol	Mon Mar 24 23:28:08 2014 +0200
     2.3 @@ -0,0 +1,81 @@
     2.4 +VOLUME
     2.5 +zaspect = 1
     2.6 +
     2.7 +SLICES
     2.8 +
     2.9 +/home/eleni/code/med/test1/data/magix/IM-0001-0001.png
    2.10 +/home/eleni/code/med/test1/data/magix/IM-0001-0002.png
    2.11 +/home/eleni/code/med/test1/data/magix/IM-0001-0003.png
    2.12 +/home/eleni/code/med/test1/data/magix/IM-0001-0004.png
    2.13 +/home/eleni/code/med/test1/data/magix/IM-0001-0005.png
    2.14 +/home/eleni/code/med/test1/data/magix/IM-0001-0006.png
    2.15 +/home/eleni/code/med/test1/data/magix/IM-0001-0007.png
    2.16 +/home/eleni/code/med/test1/data/magix/IM-0001-0008.png
    2.17 +/home/eleni/code/med/test1/data/magix/IM-0001-0009.png
    2.18 +/home/eleni/code/med/test1/data/magix/IM-0001-0010.png
    2.19 +/home/eleni/code/med/test1/data/magix/IM-0001-0011.png
    2.20 +/home/eleni/code/med/test1/data/magix/IM-0001-0012.png
    2.21 +/home/eleni/code/med/test1/data/magix/IM-0001-0013.png
    2.22 +/home/eleni/code/med/test1/data/magix/IM-0001-0014.png
    2.23 +/home/eleni/code/med/test1/data/magix/IM-0001-0015.png
    2.24 +/home/eleni/code/med/test1/data/magix/IM-0001-0016.png
    2.25 +/home/eleni/code/med/test1/data/magix/IM-0001-0017.png
    2.26 +/home/eleni/code/med/test1/data/magix/IM-0001-0018.png
    2.27 +/home/eleni/code/med/test1/data/magix/IM-0001-0019.png
    2.28 +/home/eleni/code/med/test1/data/magix/IM-0001-0020.png
    2.29 +/home/eleni/code/med/test1/data/magix/IM-0001-0021.png
    2.30 +/home/eleni/code/med/test1/data/magix/IM-0001-0022.png
    2.31 +/home/eleni/code/med/test1/data/magix/IM-0001-0023.png
    2.32 +/home/eleni/code/med/test1/data/magix/IM-0001-0024.png
    2.33 +/home/eleni/code/med/test1/data/magix/IM-0001-0025.png
    2.34 +/home/eleni/code/med/test1/data/magix/IM-0001-0026.png
    2.35 +/home/eleni/code/med/test1/data/magix/IM-0001-0027.png
    2.36 +/home/eleni/code/med/test1/data/magix/IM-0001-0028.png
    2.37 +/home/eleni/code/med/test1/data/magix/IM-0001-0029.png
    2.38 +/home/eleni/code/med/test1/data/magix/IM-0001-0030.png
    2.39 +/home/eleni/code/med/test1/data/magix/IM-0001-0031.png
    2.40 +/home/eleni/code/med/test1/data/magix/IM-0001-0032.png
    2.41 +/home/eleni/code/med/test1/data/magix/IM-0001-0033.png
    2.42 +/home/eleni/code/med/test1/data/magix/IM-0001-0034.png
    2.43 +/home/eleni/code/med/test1/data/magix/IM-0001-0035.png
    2.44 +/home/eleni/code/med/test1/data/magix/IM-0001-0036.png
    2.45 +/home/eleni/code/med/test1/data/magix/IM-0001-0037.png
    2.46 +/home/eleni/code/med/test1/data/magix/IM-0001-0038.png
    2.47 +/home/eleni/code/med/test1/data/magix/IM-0001-0039.png
    2.48 +/home/eleni/code/med/test1/data/magix/IM-0001-0040.png
    2.49 +/home/eleni/code/med/test1/data/magix/IM-0001-0041.png
    2.50 +/home/eleni/code/med/test1/data/magix/IM-0001-0042.png
    2.51 +/home/eleni/code/med/test1/data/magix/IM-0001-0043.png
    2.52 +/home/eleni/code/med/test1/data/magix/IM-0001-0044.png
    2.53 +/home/eleni/code/med/test1/data/magix/IM-0001-0045.png
    2.54 +/home/eleni/code/med/test1/data/magix/IM-0001-0046.png
    2.55 +/home/eleni/code/med/test1/data/magix/IM-0001-0047.png
    2.56 +/home/eleni/code/med/test1/data/magix/IM-0001-0048.png
    2.57 +/home/eleni/code/med/test1/data/magix/IM-0001-0049.png
    2.58 +/home/eleni/code/med/test1/data/magix/IM-0001-0050.png
    2.59 +/home/eleni/code/med/test1/data/magix/IM-0001-0051.png
    2.60 +/home/eleni/code/med/test1/data/magix/IM-0001-0052.png
    2.61 +/home/eleni/code/med/test1/data/magix/IM-0001-0053.png
    2.62 +/home/eleni/code/med/test1/data/magix/IM-0001-0054.png
    2.63 +/home/eleni/code/med/test1/data/magix/IM-0001-0055.png
    2.64 +/home/eleni/code/med/test1/data/magix/IM-0001-0056.png
    2.65 +/home/eleni/code/med/test1/data/magix/IM-0001-0057.png
    2.66 +/home/eleni/code/med/test1/data/magix/IM-0001-0058.png
    2.67 +/home/eleni/code/med/test1/data/magix/IM-0001-0059.png
    2.68 +/home/eleni/code/med/test1/data/magix/IM-0001-0060.png
    2.69 +/home/eleni/code/med/test1/data/magix/IM-0001-0061.png
    2.70 +/home/eleni/code/med/test1/data/magix/IM-0001-0062.png
    2.71 +/home/eleni/code/med/test1/data/magix/IM-0001-0063.png
    2.72 +/home/eleni/code/med/test1/data/magix/IM-0001-0064.png
    2.73 +/home/eleni/code/med/test1/data/magix/IM-0001-0065.png
    2.74 +/home/eleni/code/med/test1/data/magix/IM-0001-0066.png
    2.75 +/home/eleni/code/med/test1/data/magix/IM-0001-0067.png
    2.76 +/home/eleni/code/med/test1/data/magix/IM-0001-0068.png
    2.77 +/home/eleni/code/med/test1/data/magix/IM-0001-0069.png
    2.78 +/home/eleni/code/med/test1/data/magix/IM-0001-0070.png
    2.79 +/home/eleni/code/med/test1/data/magix/IM-0001-0071.png
    2.80 +/home/eleni/code/med/test1/data/magix/IM-0001-0072.png
    2.81 +/home/eleni/code/med/test1/data/magix/IM-0001-0073.png
    2.82 +/home/eleni/code/med/test1/data/magix/IM-0001-0074.png
    2.83 +/home/eleni/code/med/test1/data/magix/IM-0001-0075.png
    2.84 +/home/eleni/code/med/test1/data/magix/IM-0001-0076.png
     3.1 --- a/src/main.cc	Mon Mar 03 23:12:13 2014 +0200
     3.2 +++ b/src/main.cc	Mon Mar 24 23:28:08 2014 +0200
     3.3 @@ -19,15 +19,15 @@
     3.4  static void keyboard_up(unsigned char key, int x, int y);
     3.5  static void mouse(int button, int state, int x, int y);
     3.6  static void motion(int x, int y);
     3.7 -
     3.8  static bool init_xfer(void);
     3.9  static void display_xfer(void);
    3.10  static void reshape_xfer(int x, int y);
    3.11  static void mouse_xfer(int button, int state, int x, int y);
    3.12  static void motion_xfer(int x, int y);
    3.13 -//todo keyb esc
    3.14 +static void volume_preview ();
    3.15  
    3.16  static int mainwin_id, xferwin_id;
    3.17 +//todo keyb esc
    3.18  
    3.19  static int win_xsz, win_ysz;
    3.20  static float cam_phi, cam_theta, cam_dist = 6;
    3.21 @@ -171,6 +171,42 @@
    3.22  	return ui;
    3.23  }
    3.24  
    3.25 +static void volume_preview ()
    3.26 +{
    3.27 +	float aspect = win_xsz / win_ysz;
    3.28 +	float z = 0.0;
    3.29 +
    3.30 +	glDisable(GL_LIGHTING);
    3.31 +
    3.32 +	glMatrixMode(GL_MODELVIEW);
    3.33 +	glPushMatrix();
    3.34 +	glLoadIdentity();
    3.35 +
    3.36 +	glMatrixMode(GL_PROJECTION);
    3.37 +	glPushMatrix();
    3.38 +	glLoadIdentity();
    3.39 +	glOrtho(-aspect, aspect, -1.0, 1.0, -1.0, 1.0);
    3.40 +
    3.41 +	glBindTexture(GL_TEXTURE_3D, vol->get_texture());
    3.42 +	glEnable(GL_TEXTURE_3D);
    3.43 +	glBegin(GL_QUADS);
    3.44 +	glColor3f(1.0, 0.0, 0.0);
    3.45 +	glTexCoord3f(0, 0, z); glVertex3f(-1.0, 1.0, 0.0);
    3.46 +	glTexCoord3f(0, 1, z); glVertex3f(-1.0, 0.5, 0.0);
    3.47 +	glTexCoord3f(1, 1, z); glVertex3f(-0.5, 0.5, 0.0);
    3.48 +	glTexCoord3f(1, 0, z); glVertex3f(-0.5, 1.0, 0.0);
    3.49 +	glEnd();
    3.50 +	glDisable(GL_TEXTURE_3D);
    3.51 +
    3.52 +	glMatrixMode(GL_PROJECTION);
    3.53 +	glPopMatrix();
    3.54 +
    3.55 +	glMatrixMode(GL_MODELVIEW);
    3.56 +	glPopMatrix();
    3.57 +
    3.58 +	glEnable(GL_LIGHTING);
    3.59 +}
    3.60 +
    3.61  static void display(void)
    3.62  {
    3.63  	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    3.64 @@ -201,7 +237,7 @@
    3.65  	}
    3.66  	mesh->draw();
    3.67  
    3.68 -	//TODO: draw threshold
    3.69 +	volume_preview();
    3.70  	glutSwapBuffers();
    3.71  	assert(glGetError() == GL_NO_ERROR);
    3.72  }