[vtkusers] Is this a bug in vtk?

lee ricky rickyhust at gmail.com
Fri Apr 21 07:59:30 EDT 2006


 Hello Everyone!

I have tested the Marching cubes and Raycasting algorithms with series BMP
files:
          ring1.bmp ring2.bmp....ring9.bmp    (8 bit ,428*354)
the first picture is a white ring  in the center of the picture with black
background
( "ring1.bmp", the other 8 pictures are the same to the first one)

In the Attachment:
"vtkContourFilter_result.JPG" is the result of surface rendering with
vtkContourFilter
"vtkMarchingCubes_result.JPG"is the result of surface rendering with
vtkMarchingCubes
"raycasting_result.JPG" is the result of volume rendering with
vtkVolumeRayCastCompositeFunction

the result of surface rendering with vtkContourFilter is right, but the
others is not the result It should be.

I uses the vtkBMPReader to read the BMP files,
It seems that vtk supports BMP file format not very good?
Looking forward to your reply!

Thanks in advance!

ricky
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060421/10f1fe45/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ring1.rar
Type: application/octet-stream
Size: 2534 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060421/10f1fe45/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkContourFilter_result.JPG
Type: image/jpeg
Size: 8745 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060421/10f1fe45/attachment.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkMarchingCubes_result.JPG
Type: image/jpeg
Size: 13832 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060421/10f1fe45/attachment-0001.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raycasting_result.JPG
Type: image/jpeg
Size: 13878 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060421/10f1fe45/attachment-0002.jpeg>
-------------- next part --------------
//raycasting test
//
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkBMPReader.h"
#include "vtkPiecewiseFunction.h"
#include "vtkColorTransferFunction.h"
#include "vtkVolumeProperty.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkVolume.h"

#include "vtkStructuredPointsReader.h"

int main (int argc, char **argv)
{
	vtkRenderer *aRenderer = vtkRenderer::New();
	vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(aRenderer);
	vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);
	
	
	vtkBMPReader *reader = vtkBMPReader::New();
	reader->SetFilePrefix ("E:/ring-vtk-data/ring");
	reader->SetDataExtent(0,427,0,353,1,9);//rotate it! you will see the ring in the scene.
	
	reader->SetFilePattern ("%s%d.bmp");
	reader->SetDataByteOrderToLittleEndian();
	reader->SetDataSpacing (1.0, 1.0, 0.8);
	reader->Update();

	vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New();
	opacityTransferFunction->AddPoint(100,0.0);
	opacityTransferFunction->AddPoint(200,0.8);

	vtkColorTransferFunction *colorTransferFunction = vtkColorTransferFunction::New();
	colorTransferFunction->AddRGBPoint(100.0,0.0,0.0,0.0);
	colorTransferFunction->AddRGBPoint(200.0,0.8,0.8,0.8);
	
	vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
	volumeProperty->SetColor(colorTransferFunction);
	volumeProperty->SetScalarOpacity(opacityTransferFunction);
	volumeProperty->ShadeOn();
	volumeProperty->SetInterpolationTypeToLinear();

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

	vtkVolume *volume = vtkVolume::New();
	volume->SetMapper(volumeMapper);
	volume->SetProperty(volumeProperty);

	aRenderer->AddVolume(volume);

	aRenderer->SetBackground(1,1,1);
	renWin->SetSize(800, 600);
	iren->Initialize();
	iren->Start();

	reader->Delete();
	opacityTransferFunction->Delete();
	colorTransferFunction->Delete();
	volumeProperty->Delete();
	volumeMapper->Delete();
	volume->Delete();
	compositeFunction->Delete();
	iren->Delete();
	renWin->Delete();
	aRenderer->Delete();
	
	return 0;
}


More information about the vtkusers mailing list