[vtkusers] Problem with

Isaac Gerg isaacgerg at psu.edu
Fri Aug 6 11:03:51 EDT 2004





--
Information Fusion Division
  Image Processing / GIS
Penn State Applied Research Laboratory
http://www.personal.psu.edu/idg101/

Hi all,
  I am attempting to render a volume created from grayscale bitmap
images. I have created 5 images of the attached file number 1.bmp
through 5.bmp. I use the code below to attempt to display them but get
wacky results.

The image is not centered correctly, and none of the coloring or opacity
seems to work Correctly.

Any help deeply appreciated.

Best Regards,
Isaac Gerg



	// Create the standard renderer, render window and interactor
	vtkRenderer* ren = vtkRenderer::New();
	vtkRenderWindow* renWin = vtkRenderWindow::New();
	renWin->AddRenderer(ren);
	vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New();
	iren->SetRenderWindow(renWin);

	vtkBMPReader* reader = vtkBMPReader::New();
	reader->SetFilePrefix ("C:\\USData\\3d\\rgb\\");
	reader->SetFilePattern("%s\\%d.bmp");
	reader->SetDataExtent(0, 0, 0, 0, 1, 5);


	vtkPiecewiseFunction* opacityTransferFunction =
vtkPiecewiseFunction::New();
	opacityTransferFunction->AddPoint(60, 0.0);
	opacityTransferFunction->AddPoint(61, 1.0);
	opacityTransferFunction->AddPoint(70, 1.0);
	opacityTransferFunction->AddPoint(71, 0.0);
	opacityTransferFunction->AddPoint(250, 0.0);
	opacityTransferFunction->AddPoint(251, 0.2);


	vtkColorTransferFunction* colorTransferFunction =
vtkColorTransferFunction::New();
	colorTransferFunction->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
	colorTransferFunction->AddRGBPoint(60.0, 0.0, 0.0, 0.0);
	colorTransferFunction->AddRGBPoint(61.0, 1.0, 0.0, 0.0);
	colorTransferFunction->AddRGBPoint(70.0, 1.0, 0.0, 0.0);
	colorTransferFunction->AddRGBPoint(71.0, 0.0, 0.0, 0.0);

	// The property describes how the data will look
	vtkVolumeProperty* volumeProperty = vtkVolumeProperty::New();
	volumeProperty->SetColor(colorTransferFunction);
	volumeProperty->SetScalarOpacity(opacityTransferFunction);

	
	vtkOutlineFilter *outlineData = vtkOutlineFilter::New();
		outlineData->SetInput
		(
			(vtkDataSet *) reader->GetOutput()
		);
	vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
		mapOutline->SetInput(outlineData->GetOutput());

	// Draws bounding box.
	vtkActor *outline = vtkActor::New();
		outline->SetMapper(mapOutline);
		outline->GetProperty()->SetColor(0,0,0);

	vtkVolumeRayCastCompositeFunction* compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
	vtkVolumeRayCastMapper* volumeMapper =
vtkVolumeRayCastMapper::New();
	volumeMapper->SetVolumeRayCastFunction(compositeFunction);
	volumeMapper->SetInput(reader->GetOutput());


	
	// The volume holds the mapper and the property and
	// can be used to position/orient the volume
	vtkVolume* volume = vtkVolume::New();
	volume->SetMapper(volumeMapper);
	volume->SetProperty(volumeProperty);
	
	//ren->AddProp(volume);
	
	ren->AddVolume(volume);
	ren->AddActor(outline);
	ren->SetBackground(1, 1, 1);
	renWin->SetSize(640, 480);
	renWin->Render();
	
		
	iren->Initialize();
	renWin->Render();
	iren->Start();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.ZIP
Type: application/octet-stream
Size: 1990 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040806/fe9547f8/attachment.obj>


More information about the vtkusers mailing list