<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1498" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>hello:</FONT></DIV>
<DIV><FONT size=2> I am a newer for vtk. My
programe is to render head. But it isnot appear.</FONT></DIV>
<DIV><FONT size=2>this is my code.</FONT></DIV>
<DIV><FONT size=2>#include "vtkRenderer.h"<BR>#include
"vtkRenderWindow.h"<BR>#include "vtkRenderWindowInteractor.h"<BR>#include
"vtkVolume16Reader.h"<BR>#include
"vtkVolumeRayCastCompositeFunction.h"<BR>#include
"vtkVolumeRayCastMapper.h"<BR>#include
"vtkVolumeRayCastCompositeFunction.h"<BR>#include
"vtkPiecewiseFunction.h"<BR>#include "vtkColorTransferFunction.h"<BR>#include
"vtkVolumeProperty.h"<BR>#include "vtkVolume.h"<BR>#include
"vtkOutlineFilter.h"<BR>#include "vtkPolyDataMapper.h"<BR>#include
"vtkActor.h"<BR>#include "vtkCamera.h"<BR>#include "vtkProperty.h"<BR>#include
"vtkInteractorStyleTrackballCamera.h"<BR>#include "vtkImageData.h"<BR>#include
"vtkPointData.h"<BR>#include "vtkCellData.h"<BR>#include
"vtkDataSetAttributes.h"<BR>#include
"vtkVolumeRayCastMIPFunction.h"</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2></FONT> </DIV><FONT size=2>
<DIV><BR>int main (int argc, char **argv)<BR>{<BR> /*if (argc <
2)<BR> {<BR> cout <<
"Usage: " << argv[0] << " DATADIR/headsq/quarter " <<
endl;<BR> return 1;<BR> }*/<BR></DIV>
<DIV>vtkVolume16Reader *v16 = vtkVolume16Reader::New();<BR>
v16->SetDataDimensions(64,64);<BR>
v16->SetDataByteOrderToLittleEndian();</DIV>
<DIV> v16->SetFilePrefix
("E:/DATADIR/headsq/quarter");<BR> v16->SetImageRange(1,
93);<BR> // v16->SetDataSpacing (3.2, 3.2,
1.5);<BR> v16->SetDataSpacing (3.2, 3.2,
1.5);<BR> //v16->ReleaseDataFlagOn();<BR> //v16->SetDataMask(0x7fff);<BR> v16->Update();</DIV>
<DIV> </DIV>
<DIV><BR>vtkImageData *imageData =
vtkImageData::New();<BR> imageData->SetDimensions(64,64,93);<BR> imageData->SetSpacing(3.2,
3.2,
1.5);<BR> imageData->SetOrigin(0.0,0.0,0.0);<BR> imageData->SetScalarTypeToUnsignedChar();<BR> imageData->SetNumberOfScalarComponents(1);<BR> imageData->AllocateScalars();//Allocate
the vtkScalars object associated with this object</DIV>
<DIV> imageData->GetPointData()->CopyAllOn();//return pointer to this
dataset's point data THIS METHOD IS
THREAD <BR> imageData->GetPointData()->CopyScalarsOn();//Turn on
copying of all data</DIV>
<DIV> </DIV>
<DIV>/*for (int i=0; i<64*64*93;
i++)<BR>{<BR> imageData->GetPointData()->CopyData(
v16->GetOutput()->GetPointData(), i,<BR>i );<BR>} //Copy the attribute
data from one id to another<BR>*/<BR>unsigned char *ptr2 =(unsigned char *)
v16->GetOutput()->GetScalarPointer();<BR>unsigned char *ptr =(unsigned
char *) imageData->GetScalarPointer();</DIV>
<DIV> </DIV>
<DIV>for (int i=0; i<64*64*93 ; i++)<BR>{<BR> *ptr =
*ptr2;<BR> ptr++;<BR> ptr2++;<BR>}// Copy the attribute data from one
id to another</DIV>
<DIV> </DIV>
<DIV>vtkVolumeRayCastCompositeFunction *compositeFunction
=vtkVolumeRayCastCompositeFunction::New();//a ray function that can be used
within a vtkVolumeRayCastMapper.<BR>//vtkVolumeRayCastMIPFunction
*compositeFunction =
vtkVolumeRayCastMIPFunction::New();<BR>vtkVolumeRayCastMapper *volumeMapper =
vtkVolumeRayCastMapper::New();<BR>
volumeMapper->SetInput(imageData);<BR>
//volumeMapper->SetInput(v16); //testing
<BR> volumeMapper->SetVolumeRayCastFunction(compositeFunction);<BR> //volumeMapper->CroppingOn();//Turn
On/Off orthogonal
cropping<BR> //volumeMapper->SetCroppingRegionPlanes(60,100,60,100,60,100);//
Set/Get the Cropping Region
Planes<BR> //volumeMapper->SetCroppingRegionFlags(0x7ffffdf);<BR>// Set
the flags for the cropping regions</DIV>
<DIV> </DIV>
<DIV>vtkPiecewiseFunction *tfun = vtkPiecewiseFunction::New();//Defines a
piecewise linear function
mapping<BR> <BR>
tfun->AddPoint(20.0,0.0);<BR>
tfun->AddPoint(80.0,0.1);<BR>
tfun->AddPoint(101.0,0.4);<BR>
tfun->AddPoint(105.0,0.5);<BR>
tfun->AddPoint(155.0,0.8);<BR>
//tfun->AddPoint(255,1.0);</DIV>
<DIV> </DIV>
<DIV>vtkColorTransferFunction *ctfun =
vtkColorTransferFunction::New();<BR> <BR>
ctfun->AddRGBPoint(40.0, 0.0, 0.0, 0.0);<BR>
ctfun->AddRGBPoint(60.0, 0.9, 0.2, 0.3);<BR>
ctfun->AddRGBPoint(80.0, 0.81, 2.7, 0.1);<BR>
ctfun->AddRGBPoint(90.0, 0.2, 0.2, 0.2);<BR>
ctfun->AddRGBPoint(105.0, 1.0, 0.0, 0.0);<BR>
ctfun->AddRGBPoint(106.0, 1.0, 1.0, 1.0);<BR>
</DIV>
<DIV>vtkVolumeProperty *volumeProperty =
vtkVolumeProperty::New();<BR>
volumeProperty->SetColor(ctfun);<BR>
volumeProperty->SetScalarOpacity(tfun);<BR>
volumeProperty->SetInterpolationTypeToLinear();<BR> //volumeProperty->SetInterpolationTypeToNearest();<BR>
// volumeProperty->SetCompositeMethodToClassifyFirst();<BR>
volumeProperty->ShadeOn();//Set/Get the shading of a volume</DIV>
<DIV> </DIV>
<DIV><BR>vtkVolume *newvol = vtkVolume::New();<BR>
newvol->SetMapper(volumeMapper);<BR>
newvol->SetProperty(volumeProperty);</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>vtkOutlineFilter *outline = vtkOutlineFilter::New();<BR>
outline->SetInput((vtkDataSet *) v16->GetOutput());<BR>
//outline->SetInput((vtkDataSet *) imageData->GetOutput());//testing</DIV>
<DIV> </DIV>
<DIV>vtkPolyDataMapper *outlineMapper =
vtkPolyDataMapper::New();<BR>
outlineMapper->SetInput(outline->GetOutput());</DIV>
<DIV> </DIV>
<DIV>vtkActor *outlineActor = vtkActor::New();<BR>
outlineActor->SetMapper(outlineMapper);<BR>
outlineActor->GetProperty()->SetColor(1,1,1);</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>vtkCamera *Camera = vtkCamera::New();<BR>
Camera->SetViewUp (0, 0, -1);<BR> Camera->SetPosition
(140, 600, -100);<BR> Camera->SetFocalPoint (100, 100,
75);<BR>
Camera->ComputeViewPlaneNormal();<BR> </DIV>
<DIV> </DIV>
<DIV>vtkRenderer *ren = vtkRenderer::New();<BR>
ren->AddActor(outlineActor);<BR>
ren->AddVolume(newvol);<BR>
ren->SetBackground(0,0,0);<BR>
ren->SetActiveCamera(Camera);</DIV>
<DIV> </DIV>
<DIV><BR>vtkRenderWindow *renWin = vtkRenderWindow::New();<BR>
renWin->AddRenderer(ren);<BR>
renWin->SetSize(640,480);<BR> </DIV>
<DIV> </DIV>
<DIV>vtkInteractorStyleTrackballCamera *style
=<BR>vtkInteractorStyleTrackballCamera::New();</DIV>
<DIV> </DIV>
<DIV>vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New();<BR>
iren->SetRenderWindow(renWin);<BR>
iren->SetInteractorStyle(style);<BR>
iren->Initialize();<BR> iren->Start();</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><BR> v16->Delete();<BR>
compositeFunction->Delete();<BR>
volumeMapper->Delete();<BR>
tfun->Delete();<BR>
ctfun->Delete();<BR>
volumeProperty->Delete();<BR>
newvol->Delete();<BR>
outline->Delete();<BR>
outlineMapper->Delete();<BR>
outlineActor->Delete();<BR>
Camera->Delete();<BR>
ren->Delete();<BR>
renWin->Delete();<BR>
iren->Delete();<BR> style->Delete();</DIV>
<DIV> </DIV>
<DIV> return 0;<BR>}<BR></FONT></DIV></BODY></HTML>