Commit 7693d37a authored by Francois Bertel's avatar Francois Bertel

BUG:Fixed direct call to Render on the vtkRenderer which is strictly forbidden...

BUG:Fixed direct call to Render on the vtkRenderer which is strictly forbidden as the vtkRenderer. Notably, vtkRenderer relies on values initialized by the vtkRenderWindow. In the case of Example Medical3.cxx, as Renderer() was called on the vtkRenderer before any internal initialization of the vtkRenderWindow it resulted in the use of uninitialized variable. Thanks valgrind for catching this.
parent 1a889574
......@@ -51,8 +51,7 @@ int main (int argc, char *argv[])
// mouse- and keyboard-based interaction with the data within the
// render window.
//
vtkSmartPointer<vtkRenderer> aRenderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderer> aRenderer = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin =
vtkSmartPointer<vtkRenderWindow>::New();
renWin->AddRenderer(aRenderer);
......@@ -60,6 +59,11 @@ int main (int argc, char *argv[])
vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
// Set a background color for the renderer and set the size of the
// render window (expressed in pixels).
aRenderer->SetBackground(.2, .3, .4);
renWin->SetSize(640, 480);
// The following reader is used to read a series of 2D slices (images)
// that compose the volume. The slice dimensions are set, and the
// pixel spacing. The data Endianness must also be specified. The
......@@ -276,17 +280,14 @@ int main (int argc, char *argv[])
// An initial camera view is created. The Dolly() method moves
// the camera towards the FocalPoint, thereby enlarging the image.
aRenderer->SetActiveCamera(aCamera);
cout << "Render\n";
aRenderer->Render();
cout << "ResetCamera\n";
// Calling Render() directly on a vtkRenderer is strictly forbidden.
// Only calling Render() on the vtkRenderWindow is a valid call.
renWin->Render();
aRenderer->ResetCamera ();
aCamera->Dolly(1.5);
// Set a background color for the renderer and set the size of the
// render window (expressed in pixels).
aRenderer->SetBackground(.2, .3, .4);
renWin->SetSize(640, 480);
// Note that when camera movement occurs (as it does in the Dolly()
// method), the clipping planes often need adjusting. Clipping planes
// consist of two planes: near and far along the view direction. The
......
......@@ -222,8 +222,10 @@ public:
virtual double GetTimeFactor();
// Description:
// CALLED BY vtkRenderWindow ONLY. End-user pass your way and call
// vtkRenderWindow::Render().
// Create an image. This is a superclass method which will in turn
// call the DeviceRender method of Subclasses of vtkRenderer
// call the DeviceRender method of Subclasses of vtkRenderer.
virtual void Render();
// Description:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment