[vtkusers] VTK Rendering Pipeline

Stephen Furlani stephen.furlani at gmail.com
Fri Jul 23 08:33:02 EDT 2010


Hello,

I've uploaded an image of the issue:
http://smg.photobucket.com/albums/v177/maethalion/?action=view&current=Screenshot2010-07-23at81833AM.png 
http://img.photobucket.com/albums/v177/maethalion/Screenshot2010-07-23at81833AM.png  

The "volume" in the lower left is getting messed up.  What could cause this? 
It looks like it's reading from the wrong location in memory, or perhaps is
reading fewer bytes per pixel than it should.  I've tried using UnsignedChar
or UnsignedShort and they both look weird (just different weird).

Any help is appreciated.  I've pasted my pipeline below:

-Stephen Furlani

// Create Render Window, Renderer
		eq::Global::enterCarbon();
		eq::AGLWindow *eqWindow = 
static_cast<eq::AGLWindow*>(getWindow()->getOSWindow());
		WindowRef winref = eqWindow->getCarbonWindow();
		vtkRen = vtkRenderer::New();
		vtkWin = vtkCarbonEqualizerRenderWindow::New();
		eq::PixelViewport pvp = getPixelViewport();
		vtkWin->SetPosition(pvp.x,pvp.y);
		vtkWin->SetSize(pvp.w, pvp.h);
		vtkWin->SetRootWindow(winref);
		vtkWin->SetWindowId(HIViewGetRoot(winref));
		vtkWin->SetContextId(eqWindow->getAGLContext());
		
		vtkWin->AddRenderer(vtkRen);
		
		
		//Input
		dcmreader = vtkDICOMImageReader :: New();
		
		//Volume Rendering
		scale = vtkImageShiftScale :: New();
		volumeMapper = vtkVolumeRayCastMapper :: New();
		volumeProperty = vtkVolumeProperty :: New();
		colorTransferFunction = vtkColorTransferFunction :: New();
		opacityTransferFunction = vtkPiecewiseFunction :: New();
		volume = vtkVolume :: New();
		compFunc = vtkVolumeRayCastCompositeFunction :: New();
		//compFunc = vtkVolumeRayCastIsosurfaceFunction :: New();
		
		//Input
		dcmreader-> SetDirectoryName(dname);
		dcmreader-> Update();

		NSLog(@"Patient Name: %s", dcmreader->GetPatientName());

		
		//Volume Rendering
		scale-> SetInput (dcmreader -> GetOutput());
		scale-> SetOutputScalarTypeToUnsignedShort();

		// Color and Opacity
		colorTransferFunction-> RemoveAllPoints();
		opacityTransferFunction-> RemoveAllPoints();
		//opacityTransferFunction-> AddSegment(min, 0.0, max, 0.0);
		/*
		 opacityTransferFunction->AddPoint(0,0);
		 opacityTransferFunction->AddPoint(200,0.25);
		 opacityTransferFunction->AddPoint(400,.5);
		 opacityTransferFunction->AddPoint(1000,.75);
		 
		 
		 colorTransferFunction->AddRGBPoint(0, 0, 0.728, 0.728);
		 colorTransferFunction->AddRGBPoint(400, 0.25, 0.5, 0.5);
		 colorTransferFunction->AddRGBPoint(1000, 0.5 , 1, 1);
		 */
		
		colorTransferFunction->AddRGBPoint( -3024, 0, 0, 0, 0.5, 0.0 );
		colorTransferFunction->AddRGBPoint( -16, 0.73, 0.25, 0.30, 0.49, .61 );
		colorTransferFunction->AddRGBPoint( 641, .90, .82, .56, .5, 0.0 );
		colorTransferFunction->AddRGBPoint( 3071, 1, 1, 1, .5, 0.0 );
		
		opacityTransferFunction->AddPoint(-3024, 0, 0.5, 0.0 );
		opacityTransferFunction->AddPoint(-16, 0, .49, .61 );
		opacityTransferFunction->AddPoint(641, .72, .5, 0.0 );
		opacityTransferFunction->AddPoint(3071, .71, 0.5, 0.0);
		
		volumeMapper->SetBlendModeToComposite();
		volumeProperty->ShadeOn();
		volumeProperty->SetAmbient(0.1);
		volumeProperty->SetDiffuse(0.9);
		volumeProperty->SetSpecular(0.2);
		volumeProperty->SetSpecularPower(10.0);
		volumeProperty->SetScalarOpacityUnitDistance(0.8919);
		
		
		//Render
		volumeMapper-> SetInputConnection(scale->GetOutputPort());
		((vtkVolumeRayCastMapper *)volumeMapper)->
SetVolumeRayCastFunction(compFunc);
		
		volumeProperty-> SetColor(colorTransferFunction);
		volumeProperty-> SetScalarOpacity(opacityTransferFunction);
		
		/*
		 volumeProperty-> ShadeOn();
		 volumeProperty-> SetAmbient(0.5);
		 volumeProperty-> SetDiffuse(1.0);
		 volumeProperty-> SetInterpolationTypeToNearest();
		 //*/
		
		volume-> SetMapper(volumeMapper);
		volume-> SetProperty(volumeProperty);
		
		vtkRen->SetBackground(1, 1, 1);
		
		//Set the Display
		vtkRen-> GetRenderWindow();
		vtkRen-> AddVolume(volume);
		vtkRen-> ResetCamera();
		
		eq::Viewport vp = getView()->getViewport();
		double viewport[4] = {0.0,0.0,1.0,1.0}; // Only values for viewport that
work.  I want (.5,.5,.5,.5)
		vtkRen->SetViewport(viewport);
		
		vtkWin-> Render();
		
		eq::Global::leaveCarbon();
-- 
View this message in context: http://vtk.1045678.n5.nabble.com/VTK-Rendering-Pipeline-tp1842754p1843327.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list