[vtkusers] Creating a 3D surface mesh from a stack of contours
Joel Schaerer
joelthelion at laposte.net
Thu Apr 30 08:12:22 EDT 2009
Thanks a lot to all of you for all of your answers!
Here's a piece of working code for future reference:
vtkAppendPolyData * app = vtkAppendPolyData::New();
for (std::vector<vtkPolyData*>::iterator i = roi.contours.begin(); i !=
roi.contours.end(); i++)
app->AddInput(*i);
vtkPolyDataWriter* w=vtkPolyDataWriter::New();
vtkLinearExtrusionFilter * extrude=vtkLinearExtrusionFilter::New();
extrude->SetInput(app->GetOutput());
extrude->SetVector(0, 0, 3); //3 is the Z spacing between contours
extrude->CappingOn();
extrude->Update();
vtkPolyDataToImageStencil* sts=vtkPolyDataToImageStencil::New();
vtkImageStencil* stencil=vtkImageStencil::New();
sts->SetInput(extrude->GetOutput());
sts->SetInformationInput(input_image);
sts->Update();
stencil->SetStencil(sts->GetOutput());
stencil->SetInput(input_image);
vtkSmartPointer<vtkMarchingCubes> marching =
vtkSmartPointer<vtkMarchingCubes>::New();
marching->SetInput(stencil->GetOutput());
marching->SetValue(0,0.5);
marching->Update();
roi.contours is a std::vector of vtkPolyDatas with one 2D contour in each of
them.
joel
Dean Inglis wrote:
>
> Hi Joel,
>
>
>
> use vtkLinearExtrusionFilter on your polyline to
>
> make it into a thin ribbon/surface
>
> before passing it on to vtkPolyDataToImageStecil.
>
> See VTK/Examples/GUI/Tcl/ImageTracerWidget.tcl
>
> as an example. You could also look at ITK's
>
> itkAntiAliasBinaryImageFilter. There is
>
> an example of how to use it here:
>
> http://www.itk.org/ITK/applications/AntiAliasBinaryImageFilterExample.html
>
>
>
> Dean
>
>
>
>
--
View this message in context: http://www.nabble.com/Creating-a-3D-surface-mesh-from-a-stack-of-contours-tp23293256p23315037.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list