<!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.2900.2180" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Verdana><FONT size=2>Hi all ,</FONT></FONT></DIV>
<DIV><FONT face=Verdana size=2>I have questions about transferring 3D model
from vtk to itk.</FONT></DIV>
<DIV><FONT face=Verdana size=2>In fact,I want to draw a tube in vtk, and then
transfer it into itk,thus I can use raycasting to project it into an image.But
the first step does not work,which means I cannot transfer the tube I draw into
itk.Can anybody help me?Thanks a lot!!!</FONT></DIV>
<DIV><FONT face=Verdana size=2></FONT> </DIV>
<DIV><FONT face=Verdana size=2>Vivian</FONT></DIV>
<DIV><FONT face=Verdana size=2></FONT> </DIV>
<DIV><FONT face=Verdana><FONT size=2>Here are my code:</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2></FONT></FONT> </DIV>
<DIV><FONT face=Verdana><FONT size=2>
//--------------------VTK pipeline-----------------------</FONT></DIV>
<DIV><FONT size=2>vtkLineSource* line3D =
vtkLineSource::New();<BR> line3D->SetPoint1(0,0,0);<BR> line3D->SetPoint2(100,100,100); <BR> line3D->Update();</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> vtkTubeFilter* LineTube =
vtkTubeFilter::New();<BR> LineTube->SetInput(line3D->GetOutput());<BR> LineTube->SetNumberOfSides(8);<BR> LineTube->SetRadius(2);</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>vtkImageData* image =
vtkImageData::New();<BR> image->SetOrigin(0,0,0);<BR> image->SetSpacing(0.2,0.2,0.2);<BR> image->SetDimensions(50,50,50);<BR> image->SetScalarTypeToUnsignedChar();//double
to unsighned
Char<BR> image->AllocateScalars();<BR> image->Update();<BR> for
(int n=0; n<image->GetNumberOfPoints();
n++){<BR> image->GetPointData()->GetScalars()->SetTuple1(n,
127);<BR> }</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> vtkPolyDataToImageStencil * dataToStencil =
vtkPolyDataToImageStencil::New(); </FONT></DIV>
<DIV><FONT
size=2> dataToStencil->SetInput(LineTube->GetOutput());</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> vtkImageStencil* stencil =
vtkImageStencil::New();<BR> stencil->SetInput(image);<BR> stencil->SetStencil(dataToStencil->GetOutput());<BR> stencil->ReverseStencilOff();<BR> stencil->SetBackgroundValue(0); <BR> stencil->Update();</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>//
----------------VTK-ITK-------------------------</FONT></DIV>
<DIV><FONT size=2>vtkImageExport* vtkExporter =
vtkImageExport::New();<BR> vtkExporter ->SetInput (lum->
GetOutput());</FONT></DIV>
<DIV><FONT size=2><BR> typedef itk::Image<unsigned char, 3>
ImageType;<BR> typedef itk::VTKImageImport<ImageType>
ImageImportType; <BR> ImageImportType::Pointer itkImporter =
ImageImportType::New(); </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> ConnectPipelines(vtkExporter, itkImporter); //it's
code comes from connectPipelines in VTKUtility.h
in </FONT></DIV>
<DIV><FONT
size=2>
// insightApplication</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> //--------------------ITK
pipeline-----------------------<BR> typedef
itk::RescaleIntensityImageFilter< ImageType, ImageType >
rescalefilterType;<BR> rescalefilterType::Pointer itkrescaler =
rescalefilterType::New(); <BR> itkrescaler->SetInput(itkImporter->GetOutput());<BR> itkrescaler->SetOutputMinimum(0);<BR> itkrescaler->SetOutputMaximum(65535);</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV> <FONT size=2>typedef itk::ImageFileWriter< ImageType >
WriterType;<BR> WriterType::Pointer writer =
WriterType::New();</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> typedef itk::VTKImageIO
ImageIOType;<BR> ImageIOType::Pointer vtkIO =
ImageIOType::New();</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT
size=2> writer->SetFileName(".\tubelineOutput.vtk");<BR> writer->SetInput(itkrescaler->GetOutput());
</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT
size=2> vtkIO->SetFileTypeToASCII();<BR> writer->SetImageIO(
vtkIO );</FONT></DIV><FONT size=2>
<DIV><BR> writer->Update();</DIV>
<DIV> </DIV>
<DIV>...<BR></DIV></FONT>
<DIV align=left><FONT size=2>
<HR style="WIDTH: 122px; HEIGHT: 2px" SIZE=2>
</FONT></DIV>
<DIV><FONT color=#c0c0c0><FONT size=2>fyy5581</FONT></DIV>
<DIV><FONT size=2>2006-09-12</FONT></FONT></DIV></FONT></BODY></HTML>