# HG changeset patch # User John Tsiombikas # Date 1334027476 -10800 # Node ID 17d9dc2edc91098bd9820169671e93c655361a79 # Parent 981fef9aa1be9a92d6483dfad6758fcad1cecb0f first qt version diff -r 981fef9aa1be -r 17d9dc2edc91 Makefile --- a/Makefile Mon Apr 09 23:43:13 2012 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,228 +0,0 @@ -############################################################################# -# Makefile for building: qvolray -# Generated by qmake (2.01a) (Qt 4.7.4) on: Mon Apr 9 23:25:44 2012 -# Project: qvolray.pro -# Template: app -# Command: /usr/bin/qmake -o Makefile qvolray.pro -############################################################################# - -####### Compiler, tools and options - -CC = gcc -CXX = g++ -DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) -CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) -INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I. -Isrc -I/usr/X11R6/include -I. -LINK = g++ -LFLAGS = -Wl,-O1 -LIBS = $(SUBLIBS) -L/usr/lib -L/usr/X11R6/lib -lQtOpenGL -lQtGui -lQtCore -lGLU -lGL -lpthread -AR = ar cqs -RANLIB = -QMAKE = /usr/bin/qmake -TAR = tar -cf -COMPRESS = gzip -9f -COPY = cp -f -SED = sed -COPY_FILE = $(COPY) -COPY_DIR = $(COPY) -r -STRIP = strip -INSTALL_FILE = install -m 644 -p -INSTALL_DIR = $(COPY_DIR) -INSTALL_PROGRAM = install -m 755 -p -DEL_FILE = rm -f -SYMLINK = ln -f -s -DEL_DIR = rmdir -MOVE = mv -f -CHK_DIR_EXISTS= test -d -MKDIR = mkdir -p - -####### Output directory - -OBJECTS_DIR = ./ - -####### Files - -SOURCES = src/main.cc \ - src/sdr.c \ - src/volray.cc \ - src/volume.cc -OBJECTS = main.o \ - sdr.o \ - volray.o \ - volume.o -DIST = /usr/share/qt4/mkspecs/common/g++.conf \ - /usr/share/qt4/mkspecs/common/unix.conf \ - /usr/share/qt4/mkspecs/common/linux.conf \ - /usr/share/qt4/mkspecs/qconfig.pri \ - /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ - /usr/share/qt4/mkspecs/features/qt_functions.prf \ - /usr/share/qt4/mkspecs/features/qt_config.prf \ - /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ - /usr/share/qt4/mkspecs/features/default_pre.prf \ - /usr/share/qt4/mkspecs/features/release.prf \ - /usr/share/qt4/mkspecs/features/default_post.prf \ - /usr/share/qt4/mkspecs/features/warn_on.prf \ - /usr/share/qt4/mkspecs/features/qt.prf \ - /usr/share/qt4/mkspecs/features/unix/opengl.prf \ - /usr/share/qt4/mkspecs/features/unix/thread.prf \ - /usr/share/qt4/mkspecs/features/moc.prf \ - /usr/share/qt4/mkspecs/features/resources.prf \ - /usr/share/qt4/mkspecs/features/uic.prf \ - /usr/share/qt4/mkspecs/features/yacc.prf \ - /usr/share/qt4/mkspecs/features/lex.prf \ - /usr/share/qt4/mkspecs/features/include_source_dir.prf \ - qvolray.pro -QMAKE_TARGET = qvolray -DESTDIR = -TARGET = qvolray - -first: all -####### Implicit rules - -.SUFFIXES: .o .c .cpp .cc .cxx .C - -.cpp.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" - -.cc.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" - -.cxx.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" - -.C.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" - -.c.o: - $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" - -####### Build rules - -all: Makefile $(TARGET) - -$(TARGET): $(OBJECTS) - $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) - -Makefile: qvolray.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \ - /usr/share/qt4/mkspecs/common/unix.conf \ - /usr/share/qt4/mkspecs/common/linux.conf \ - /usr/share/qt4/mkspecs/qconfig.pri \ - /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ - /usr/share/qt4/mkspecs/features/qt_functions.prf \ - /usr/share/qt4/mkspecs/features/qt_config.prf \ - /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ - /usr/share/qt4/mkspecs/features/default_pre.prf \ - /usr/share/qt4/mkspecs/features/release.prf \ - /usr/share/qt4/mkspecs/features/default_post.prf \ - /usr/share/qt4/mkspecs/features/warn_on.prf \ - /usr/share/qt4/mkspecs/features/qt.prf \ - /usr/share/qt4/mkspecs/features/unix/opengl.prf \ - /usr/share/qt4/mkspecs/features/unix/thread.prf \ - /usr/share/qt4/mkspecs/features/moc.prf \ - /usr/share/qt4/mkspecs/features/resources.prf \ - /usr/share/qt4/mkspecs/features/uic.prf \ - /usr/share/qt4/mkspecs/features/yacc.prf \ - /usr/share/qt4/mkspecs/features/lex.prf \ - /usr/share/qt4/mkspecs/features/include_source_dir.prf \ - /usr/lib/libQtOpenGL.prl \ - /usr/lib/libQtGui.prl \ - /usr/lib/libQtCore.prl - $(QMAKE) -o Makefile qvolray.pro -/usr/share/qt4/mkspecs/common/g++.conf: -/usr/share/qt4/mkspecs/common/unix.conf: -/usr/share/qt4/mkspecs/common/linux.conf: -/usr/share/qt4/mkspecs/qconfig.pri: -/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: -/usr/share/qt4/mkspecs/features/qt_functions.prf: -/usr/share/qt4/mkspecs/features/qt_config.prf: -/usr/share/qt4/mkspecs/features/exclusive_builds.prf: -/usr/share/qt4/mkspecs/features/default_pre.prf: -/usr/share/qt4/mkspecs/features/release.prf: -/usr/share/qt4/mkspecs/features/default_post.prf: -/usr/share/qt4/mkspecs/features/warn_on.prf: -/usr/share/qt4/mkspecs/features/qt.prf: -/usr/share/qt4/mkspecs/features/unix/opengl.prf: -/usr/share/qt4/mkspecs/features/unix/thread.prf: -/usr/share/qt4/mkspecs/features/moc.prf: -/usr/share/qt4/mkspecs/features/resources.prf: -/usr/share/qt4/mkspecs/features/uic.prf: -/usr/share/qt4/mkspecs/features/yacc.prf: -/usr/share/qt4/mkspecs/features/lex.prf: -/usr/share/qt4/mkspecs/features/include_source_dir.prf: -/usr/lib/libQtOpenGL.prl: -/usr/lib/libQtGui.prl: -/usr/lib/libQtCore.prl: -qmake: FORCE - @$(QMAKE) -o Makefile qvolray.pro - -dist: - @$(CHK_DIR_EXISTS) .tmp/qvolray1.0.0 || $(MKDIR) .tmp/qvolray1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qvolray1.0.0/ && $(COPY_FILE) --parents src/sdr.h src/volray.h src/volume.h .tmp/qvolray1.0.0/ && $(COPY_FILE) --parents src/main.cc src/sdr.c src/volray.cc src/volume.cc .tmp/qvolray1.0.0/ && (cd `dirname .tmp/qvolray1.0.0` && $(TAR) qvolray1.0.0.tar qvolray1.0.0 && $(COMPRESS) qvolray1.0.0.tar) && $(MOVE) `dirname .tmp/qvolray1.0.0`/qvolray1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qvolray1.0.0 - - -clean:compiler_clean - -$(DEL_FILE) $(OBJECTS) - -$(DEL_FILE) *~ core *.core - - -####### Sub-libraries - -distclean: clean - -$(DEL_FILE) $(TARGET) - -$(DEL_FILE) Makefile - - -check: first - -mocclean: compiler_moc_header_clean compiler_moc_source_clean - -mocables: compiler_moc_header_make_all compiler_moc_source_make_all - -compiler_moc_header_make_all: -compiler_moc_header_clean: -compiler_rcc_make_all: -compiler_rcc_clean: -compiler_image_collection_make_all: qmake_image_collection.cpp -compiler_image_collection_clean: - -$(DEL_FILE) qmake_image_collection.cpp -compiler_moc_source_make_all: main.moc -compiler_moc_source_clean: - -$(DEL_FILE) main.moc -main.moc: src/volray.h \ - src/main.cc - /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) src/main.cc -o main.moc - -compiler_uic_make_all: -compiler_uic_clean: -compiler_yacc_decl_make_all: -compiler_yacc_decl_clean: -compiler_yacc_impl_make_all: -compiler_yacc_impl_clean: -compiler_lex_make_all: -compiler_lex_clean: -compiler_clean: compiler_moc_source_clean - -####### Compile - -main.o: src/main.cc src/volray.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o src/main.cc - -sdr.o: src/sdr.c src/sdr.h - $(CC) -c $(CFLAGS) $(INCPATH) -o sdr.o src/sdr.c - -volray.o: src/volray.cc src/sdr.h \ - src/volume.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o volray.o src/volray.cc - -volume.o: src/volume.cc src/volume.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o volume.o src/volume.cc - -####### Install - -install: FORCE - -uninstall: FORCE - -FORCE: - diff -r 981fef9aa1be -r 17d9dc2edc91 qvolray.pro --- a/qvolray.pro Mon Apr 09 23:43:13 2012 +0300 +++ b/qvolray.pro Tue Apr 10 06:11:16 2012 +0300 @@ -4,6 +4,9 @@ INCLUDEPATH += . src QT += opengl +QMAKE_CXXFLAGS += -std=c++0x +LIBS += -lGLEW -limago -lvmath + # Input -HEADERS += src/sdr.h src/volray.h src/volume.h -SOURCES += src/main.cc src/sdr.c src/volray.cc src/volume.cc +HEADERS += src/sdr.h src/volray.h src/volume.h src/ui.h +SOURCES += src/main.cc src/sdr.c src/volray.cc src/volume.cc src/ui.cc diff -r 981fef9aa1be -r 17d9dc2edc91 src/main.cc --- a/src/main.cc Mon Apr 09 23:43:13 2012 +0300 +++ b/src/main.cc Tue Apr 10 06:11:16 2012 +0300 @@ -1,51 +1,11 @@ #include -#include -#include -#include "volray.h" - -class GLView : public QGLWidget { -private: - Q_OBJECT; - - void initializeGL(); - void resizeGL(int xsz, int ysz); - void paintGL(); - -public: - GLView(QWidget *parent = 0); -}; - +#include "ui.h" int main(int argc, char **argv) { QApplication app(argc, argv); - QMainWindow win; - GLView glview(&win); + MainWindow gui; - win.show(); app.exec(); } - - -GLView::GLView(QWidget *parent) - : QGLWidget(parent) -{ -} - -void GLView::initializeGL() -{ - glClearColor(1, 0, 0, 1); - - volray_init(); -} - -void GLView::resizeGL(int xsz, int ysz) -{ - volray_resize(xsz, ysz); -} - -void GLView::paintGL() -{ - volray_draw(); -} diff -r 981fef9aa1be -r 17d9dc2edc91 src/sdr.c --- a/src/sdr.c Mon Apr 09 23:43:13 2012 +0300 +++ b/src/sdr.c Tue Apr 10 06:11:16 2012 +0300 @@ -249,13 +249,13 @@ #define BEGIN_UNIFORM_CODE \ int loc, curr_prog; \ glGetIntegerv(GL_CURRENT_PROGRAM, &curr_prog); \ - if(curr_prog != prog && bind_program(prog) == -1) { \ + if((unsigned int)curr_prog != prog && bind_program(prog) == -1) { \ return -1; \ } \ if((loc = glGetUniformLocation(prog, name)) != -1) #define END_UNIFORM_CODE \ - if(curr_prog != prog) { \ + if((unsigned int)curr_prog != prog) { \ bind_program(curr_prog); \ } \ return loc == -1 ? -1 : 0 @@ -313,13 +313,13 @@ int loc, curr_prog; glGetIntegerv(GL_CURRENT_PROGRAM, &curr_prog); - if(curr_prog != prog && bind_program(prog) == -1) { + if((unsigned int)curr_prog != prog && bind_program(prog) == -1) { return -1; } loc = glGetAttribLocation(prog, (char*)name); - if(curr_prog != prog) { + if((unsigned int)curr_prog != prog) { bind_program(curr_prog); } return loc; diff -r 981fef9aa1be -r 17d9dc2edc91 src/ui.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui.cc Tue Apr 10 06:11:16 2012 +0300 @@ -0,0 +1,129 @@ +#include +#include +#include +#include "ui.h" + +static GLView *glview; +static Volume *volume; + +MainWindow::MainWindow() +{ + setWindowTitle("Volume Renderer"); + + // OpenGL view + glview = new GLView; + setCentralWidget(glview); + + // actions + QAction *act_open = new QAction(qApp->style()->standardIcon(QStyle::SP_DialogOpenButton), "&Open...", this); + act_open->setStatusTip("Open a volume dataset"); + QObject::connect(act_open, SIGNAL(triggered()), this, SLOT(open_volume())); + + QAction *act_quit = new QAction("&Quit", this); + act_quit->setStatusTip("Quit"); + QObject::connect(act_quit, SIGNAL(triggered()), this, SLOT(close())); + + // menus + QMenu *mfile = menuBar()->addMenu("&File"); + mfile->addAction(act_open); + mfile->addAction(act_quit); + + // toolbars + QToolBar *tfile = addToolBar("&File"); + tfile->addAction(act_open); + + statusBar(); + show(); +} + +void MainWindow::open_volume() +{ + QString fname = QFileDialog::getOpenFileName(this, "Open volume dataset", QString(), "Volume descriptors (*.vol)"); + if(!fname.isNull()) { + Volume *vol = new Volume; + + if(vol->load(qPrintable(fname))) { + delete volume; + volume = vol; + volray_setvolume(vol); + post_redisplay(); + } else { + delete vol; + } + } +} + +void post_redisplay() +{ + glview->updateGL(); +} + + +GLView::GLView(QWidget *parent) + : QGLWidget(QGLFormat(QGL::DoubleBuffer), parent) +{ +} + +QSize GLView::minimumSizeHint() const +{ + return QSize(320, 200); +} + +QSize GLView::sizeHint() const +{ + return QSize(1280, 800); +} + +void GLView::initializeGL() +{ + if(!volray_init()) { + exit(0); + } + glClearColor(1, 0, 0, 1); +} + +void GLView::resizeGL(int xsz, int ysz) +{ + volray_resize(xsz, ysz); +} + +void GLView::paintGL() +{ + volray_draw(); +} + +static int button_number(Qt::MouseButton bn) +{ + switch(bn) { + case Qt::LeftButton: + return 0; + case Qt::MidButton: + return 1; + case Qt::RightButton: + return 2; + default: + break; + } + return -1; +} + +void GLView::mousePressEvent(QMouseEvent *ev) +{ + int bn = button_number(ev->button()); + if(bn >= 0) { + volray_mouse(bn, 1, ev->x(), ev->y()); + } +} + +void GLView::mouseReleaseEvent(QMouseEvent *ev) +{ + int bn = button_number(ev->button()); + if(bn >= 0) { + volray_mouse(bn, 0, ev->x(), ev->y()); + } +} + +void GLView::mouseMoveEvent(QMouseEvent *ev) +{ + volray_motion(ev->x(), ev->y()); +} diff -r 981fef9aa1be -r 17d9dc2edc91 src/ui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui.h Tue Apr 10 06:11:16 2012 +0300 @@ -0,0 +1,41 @@ +#ifndef UI_H_ +#define UI_H_ + +#include +#include +#include "volray.h" + +class GLView; + +class MainWindow : public QMainWindow { + Q_OBJECT +private slots: + void open_volume(); + +public: + MainWindow(); +}; + +class GLView : public QGLWidget { + Q_OBJECT + +protected: + void initializeGL(); + void resizeGL(int xsz, int ysz); + void paintGL(); + + void mousePressEvent(QMouseEvent *ev); + void mouseReleaseEvent(QMouseEvent *ev); + void mouseMoveEvent(QMouseEvent *ev); + +public: + GLView(QWidget *parent = 0); + + QSize minimumSizeHint() const; + QSize sizeHint() const; +}; + +void post_redisplay(); + + +#endif // UI_H_ diff -r 981fef9aa1be -r 17d9dc2edc91 src/volray.cc --- a/src/volray.cc Mon Apr 09 23:43:13 2012 +0300 +++ b/src/volray.cc Tue Apr 10 06:11:16 2012 +0300 @@ -13,6 +13,7 @@ #include #include "sdr.h" #include "volume.h" +#include "ui.h" #define XFER_MAP_SZ 512 @@ -36,7 +37,7 @@ static float cam_theta = 0, cam_phi = 0, cam_dist = 4.0; static float cam_x, cam_y, cam_z; -static vec2_t tex_scale; +static Vector2 tex_scale; static unsigned int vol_sdr, slice_sdr, ray_tex; static int win_xsz, win_ysz; static bool raytex_needs_recalc = true; @@ -48,7 +49,7 @@ static float cur_z = 0.0; static float ray_step = 0.01; -static Volume volume; +static const Volume *volume; bool volray_init() @@ -70,12 +71,14 @@ set_uniform_int(slice_sdr, "volume", 0); set_uniform_int(slice_sdr, "xfer_tex", 1); - if(!volume.load(fname)) { - return false; - } return true; } +void volray_setvolume(const Volume *vol) +{ + volume = vol; +} + void volray_draw(void) { /* recalculate primary ray texture if needed */ @@ -87,9 +90,13 @@ create_transfer_map(xfer_mean, xfer_sdev); } - render_volume(); - draw_slice(); - draw_xfer_func(); + glClear(GL_COLOR_BUFFER_BIT); + + if(volume) { + render_volume(); + draw_slice(); + draw_xfer_func(); + } assert(glGetError() == GL_NO_ERROR); } @@ -114,7 +121,7 @@ /* tex unit0: volume data 3D texture */ glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_3D, volume.get_texture()); + glBindTexture(GL_TEXTURE_3D, volume->get_texture()); glEnable(GL_TEXTURE_3D); /* tex unit1: primary rays in view space */ @@ -159,7 +166,7 @@ glTranslatef(-1, -1, 0); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_3D, volume.get_texture()); + glBindTexture(GL_TEXTURE_3D, volume->get_texture()); glEnable(GL_TEXTURE_3D); glActiveTexture(GL_TEXTURE1); @@ -209,11 +216,11 @@ glLineWidth(2.0); glBegin(GL_LINE_LOOP); - if(uimode == UIMODE_XFER) { + /*if(uimode == UIMODE_XFER) { glColor3f(1, 0, 0); - } else { + } else {*/ glColor3f(0, 0, 1); - } + //} glVertex2f(0, 0); glVertex2f(1, 0); glVertex2f(1, 1); @@ -243,12 +250,12 @@ case 'x': uimode = UIMODE_XFER; - glutPostRedisplay(); + post_redisplay(); break; case 'c': uimode = UIMODE_CURSOR; - glutPostRedisplay(); + post_redisplay(); break; default: @@ -262,14 +269,14 @@ case 'x': if(uimode == UIMODE_XFER) { uimode = UIMODE_DEFAULT; - glutPostRedisplay(); + post_redisplay(); } break; case 'c': if(uimode == UIMODE_CURSOR) { uimode = UIMODE_DEFAULT; - glutPostRedisplay(); + post_redisplay(); } break; @@ -277,25 +284,26 @@ break; } } +#endif static int bnstate[32]; static int prev_x, prev_y; -void mouse(int bn, int state, int x, int y) +void volray_mouse(int bn, int state, int x, int y) { - bnstate[bn - GLUT_LEFT_BUTTON] = state == GLUT_DOWN; + bnstate[bn] = state; prev_x = x; prev_y = y; } -void motion(int x, int y) +void volray_motion(int x, int y) { int dx = x - prev_x; int dy = y - prev_y; prev_x = x; prev_y = y; - switch(uimode) { + /*switch(uimode) { case UIMODE_XFER: if(dx || dy) { xfer_mean += dx / (float)win_xsz; @@ -305,7 +313,7 @@ xfer_sdev = xfer_sdev < 0.0 ? 0.0 : (xfer_sdev > 1.0 ? 1.0 : xfer_sdev); xfertex_needs_recalc = true; - glutPostRedisplay(); + post_redisplay(); } break; @@ -318,10 +326,10 @@ cur_z = 1.0; set_uniform_float(vol_sdr, "zclip", cur_z); - glutPostRedisplay(); + post_redisplay(); break; - default: + default:*/ /* view control */ if(bnstate[0]) { cam_theta += dx * 0.5; @@ -329,25 +337,24 @@ if(cam_phi <= -90) cam_phi = -89; if(cam_phi >= 90) cam_phi = 89; - - glutPostRedisplay(); + post_redisplay(); } if(bnstate[1]) { cam_x += dx * 0.025; cam_y += dy * 0.025; - glutPostRedisplay(); + post_redisplay(); } if(bnstate[2]) { cam_dist += dy * 0.025; if(cam_dist < 0.0) cam_dist = 0.0; - glutPostRedisplay(); + post_redisplay(); } - } + //} } - +#if 0 int parse_args(int argc, char **argv) { int i; diff -r 981fef9aa1be -r 17d9dc2edc91 src/volray.h --- a/src/volray.h Mon Apr 09 23:43:13 2012 +0300 +++ b/src/volray.h Tue Apr 10 06:11:16 2012 +0300 @@ -1,8 +1,14 @@ #ifndef VOLRAY_H_ #define VOLRAY_H_ +#include "volume.h" + bool volray_init(); +void volray_setvolume(const Volume *vol); void volray_resize(int xsz, int ysz); void volray_draw(); +void volray_mouse(int bn, int state, int x, int y); +void volray_motion(int x, int y); + #endif // VOLRAY_H_ diff -r 981fef9aa1be -r 17d9dc2edc91 src/volume.cc --- a/src/volume.cc Mon Apr 09 23:43:13 2012 +0300 +++ b/src/volume.cc Tue Apr 10 06:11:16 2012 +0300 @@ -44,14 +44,14 @@ /* load the first image to determine slice dimensions */ img_init(&img); - if(img_load(&img, slist.begin().name.c_str()) == -1) { - fprintf(stderr, "failed to load volume slice: %s\n", slist->name); + if(img_load(&img, slist.begin()->c_str()) == -1) { + fprintf(stderr, "failed to load volume slice: %s\n", slist.begin()->c_str()); return false; } sz[0] = img.width; sz[1] = img.height; - printf("volume dimensions: %dx%dx%d\n", img.width, img.height, vol->sz[2]); + printf("volume dimensions: %dx%dx%d\n", img.width, img.height, sz[2]); /* allocate the whole volume at once */ voxels = new float[sz[0] * sz[1] * sz[2] * 4]; @@ -63,15 +63,15 @@ int x, y, xsz, ysz; float *pixels, *src; - if(!(pixels = img_load_pixels(slice.name.c_str(), &xsz, &ysz, IMG_FMT_GREYF))) { - fprintf(stderr, "failed to load volume slice: %s\n", slice.name.c_str()); + if(!(pixels = (float*)img_load_pixels(slice.c_str(), &xsz, &ysz, IMG_FMT_GREYF))) { + fprintf(stderr, "failed to load volume slice: %s\n", slice.c_str()); delete [] voxels; return false; } if(xsz != sz[0] || ysz != sz[1]) { fprintf(stderr, "inconsistent dimensions for slice %s: %dx%d (%dx%d expected)\n", - slice.name.c_str(), xsz, ysz, sz[0], sz[1]); + slice.c_str(), xsz, ysz, sz[0], sz[1]); delete [] voxels; return false; } @@ -145,7 +145,7 @@ } } -bool read_voldesc(const char *fname, std::list *slist) const +bool Volume::read_voldesc(const char *fname, std::list *slist) { FILE *fp = 0; char buf[512], *slash, *prefix = ""; @@ -164,9 +164,9 @@ return false; } - if((slash = strrchr(fname, '/'))) { + if((slash = strrchr((char*)fname, '/'))) { int len = slash - fname + 1; - prefix = alloca(len + 1); + prefix = (char*)alloca(len + 1); memcpy(prefix, fname, len); prefix[len] = 0; } diff -r 981fef9aa1be -r 17d9dc2edc91 src/volume.h --- a/src/volume.h Mon Apr 09 23:43:13 2012 +0300 +++ b/src/volume.h Tue Apr 10 06:11:16 2012 +0300 @@ -10,7 +10,7 @@ float zaspect; unsigned int tex; - bool read_voldesc(const char *fname, std::list *slist) const; + bool read_voldesc(const char *fname, std::list *slist); public: Volume();