[vtkusers] Help！ vtkFlRenderWindowInteractor problems...
wycken at msn.com
Wed Dec 22 14:17:12 EST 2004
I have a problem that I cannot fix in my following codes, would you please
In the following setion, I wrote a program that can redraw the windows using
the famous vtkFlRenderWindowInteractor class.
My problem is :
The first drawing of the volume is ok,and then if I move the volume a
little, after i push the redraw button of my program, I cannot operate or
move the volume,otherwise there will be a pop window showing an error, such
'con3.exe has encountered a problem and needs to close. We are sorry for
If I do nothing with the first drawing, and immediatly push the redraw
button, there is another error, such that "R6025--runtime error, pure
virtual function call"
By the way, the dataset I used is in the directory of data in vtk source
Looking forward to your help!
Here is my code:
// here we have all the usual VTK stuff that we need for our pipeline
// and here we have the famous vtkFlRenderWindowInteractor class
// and of course some fltk stuff
vtkFlRenderWindowInteractor *fl_vtk_window = NULL;
//main FLTK window
Fl_Window *main_window = NULL;
// this callback gets called when the main window is closed
// remember that one should NEVER delete() a vtkFlRenderWindowInteractor,
// since it's a vtk object. instead, its Delete() method should be used.
// so, in the callback of the containing window, you should either terminate
// your application (if that's applicable) or if you have a multi-window
// application, call ->Delete() on the vtkfl_vtk_window and then take care
// surrounding logic.
void main_window_callback(Fl_Widget *, void *)
// this is a callback for the Redraw button
void Redraw(Fl_Widget*, void*)
//error occurs when I click the left-button of mouse on the window.
* This will create a Fl_Window with an embedded vtkFlRWI, a label
* with some explanation and a quit button. The pointers that are
* passed are set correctly on return so that they can be used for
* further processing; in our case that means actually building and
* adding a VTK pipeline.
void create_window_with_rwi(vtkFlRenderWindowInteractor *&fl_vtk_window,
// set up main FLTK window
flw = new Fl_Window(820,820,title);
// and instantiate vtkFlRenderWindowInteractor (here it acts like a
// FLTK window, i.e. you could also instantiate it as child of a
// Fl_Group in a window)
fl_vtk_window = new vtkFlRenderWindowInteractor(5,5,820,780,NULL);
// this will result in a little message under the rendering
Fl_Box* box = new Fl_Box(5,800,815,820,
"3 = stereo, j = joystick, t = trackball, "
"w = wireframe, s = surface, p = pick; "
"you can also resize the window");
// we want a button with which the user can quit the application
Fl_Button* quit_button = new Fl_Button(400,790,70,35,"Redraw");
// we're done populating the flw
// if the main window gets resized, the vtk window should resize with it
int main( int argc, char *argv )
// let's create the FIRST window with a Cone thingy ===========
// these two steps are VERY IMPORTANT, you have to show() the fltk window
// containing the vtkFlRenderWindowInteractor, and then the
// vtkFlRenderWindowInteractor itself
// now we get to setup our VTK rendering pipeline
//if I replace VolumeRendering() with MarchingCubes(), a running occurs
// this is the standard way of "starting" a fltk application
int fl_ret = Fl::run();
// very huge NB: note that we ->Delete() the vtkFlRenderWindowInteractor
// once we do this, the rest of the vtk pipeline will really disappear
// and after we've done that, we can delete the main_window
//set the pipeline of vtk using marchingcubes algorithm
vtkRenderer *aRenderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
vtkRenderWindowInteractor *iren = fl_vtk_window;
vtkVolume16Reader *p_reader = vtkVolume16Reader::New();
p_reader->SetDataSpacing (3.2, 3.2, 1.5);
// An isosurface, or contour value of 500 is known to correspond to the
// skin of the patient. Once generated, a vtkPolyDataNormals filter is
// is used to create normals for smooth surface shading during rendering.
vtkContourFilter *skinExtractor = vtkContourFilter::New();
skinExtractor->SetInput(( vtkDataSet *) p_reader->GetOutput());
vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();
vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();
vtkActor *skin = vtkActor::New();
Express yourself instantly with MSN Messenger! Download today it's FREE!
More information about the vtkusers