[vtkusers] Bug in vtkPolyDataToImageStencil?
Joel Schaerer
joelthelion at laposte.net
Mon May 4 10:06:40 EDT 2009
Hi all,
Following the advice people have given me in
http://www.nabble.com/Creating-a-3D-surface-mesh-from-a-stack-of-contours-td23293256.html
this thread, I'm trying to create a 3D mesh from a stack of contours using
vtkLinearExtrusionFilter, vtkPolyDataToImageStencil and vtkMarchingCubes.
It all seems to work quite well except for a very annoying bug, which is
that there are spurious white lines in the output of the binarizer. Minimal
code showing the problem with sample input and output data, as well as a
screenshot of the problem can be found here:
http://www.creatis.insa-lyon.fr/~schaerer/binarizer_bug.tar.bz2
The input are a polydata containing a closed polyline, and an empty image to
get the required spacing, origin, etc. for the output.
Is this a bug in vtk? Or am I missing something?
Thanks!
joel
PS: Here is the sample code:
#include <iostream>
#include <sstream>
#include <cassert>
#include <set>
#include <vtkPolyDataWriter.h>
#include <vtkPolyData.h>
#include <vtkLinearExtrusionFilter.h>
#include <vtkMetaImageWriter.h>
#include <vtkMetaImageReader.h>
#include <vtkImageData.h>
#include <vtkPolyDataToImageStencil.h>
#include <vtkPolyDataReader.h>
#include <vtkImageStencil.h>
#include <vtkSmartPointer.h>
int main(int argc,char * argv[])
{
vtkSmartPointer<vtkMetaImageReader>
imread=vtkSmartPointer<vtkMetaImageReader>::New();
imread->SetFileName("input.mhd");
imread->Update();
vtkSmartPointer<vtkPolyDataReader>
contour_reader=vtkSmartPointer<vtkPolyDataReader>::New();
contour_reader->SetFileName("input_contour.vtk");
contour_reader->Update();
vtkLinearExtrusionFilter * extrude=vtkLinearExtrusionFilter::New();
extrude->SetInput(contour_reader->GetOutput());
extrude->SetVector(0, 0, 3); //3 is the Z spacing between contours
//extrude->CappingOn(); //doesn't seem to be doing anything
extrude->Update();
vtkPolyDataToImageStencil* sts=vtkPolyDataToImageStencil::New();
vtkImageStencil* stencil=vtkImageStencil::New();
sts->SetInput(extrude->GetOutput());
sts->SetInformationInput(imread->GetOutput());
sts->Update();
stencil->SetStencil(sts->GetOutput());
stencil->SetInput(imread->GetOutput());
vtkSmartPointer<vtkMetaImageWriter>
binary_writer=vtkSmartPointer<vtkMetaImageWriter>::New();
binary_writer->SetInput(stencil->GetOutput());
binary_writer->SetFileName("binary_output.mhd");
binary_writer->Write();
extrude->Delete();
sts->Delete();
stencil->Delete();
return 0;
}
--
View this message in context: http://www.nabble.com/Bug-in-vtkPolyDataToImageStencil--tp23368312p23368312.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list