[vtkusers] help with vtkImageStencil and STLWriter

samo sandra.moritz at gmx.de
Tue Jan 9 04:36:38 EST 2007



Hello together 

I use vtkImageStencil to cut a piece out of a vtkPolyData. This all works
fine, except that I would like to use the piece as a real 3D object in
another program later on. This does not work. 

This is my code so far:

vtkPolyDataToImageStencil* p2i = vtkPolyDataToImageStencil::New();
	vtkPolyData* polyData = (vtkPolyData*)(stlActor->GetMapper()->GetInput());
	vtkTransformPolyDataFilter* polyTrafo = vtkTransformPolyDataFilter::New();
	polyTrafo->SetInput(polyData);
	polyTrafo->SetTransform(m_ImplantTransform);
	p2i->SetInput(polyTrafo->GetOutput());
	vtkImageStencil* stencil = vtkImageStencil::New();
	stencil->SetInput(m_MetaVolumeReader->GetOutput());
	stencil->SetStencil(p2i->GetOutput());
	stencil->ReverseStencilOff();
	stencil->SetBackgroundValue(0.0);
	stencil->Update();
	

	vtkMarchingCubes* cubes = vtkMarchingCubes::New();
	vtkImageData* image = vtkImageData::New();
	image = stencil->GetOutput();
	cubes->SetInput(stencil->GetOutput());
	cubes->SetValue(0,1000);
	cubes->ComputeScalarsOff();
	cubes->Update();

	vtkPolyDataMapper* vtkmapper = vtkPolyDataMapper::New();
	vtkmapper->SetInput(cubes->GetOutput());

	vtkActor* act = vtkActor::New();
	act->SetMapper(vtkmapper);

	RendererDetail->AddProp(act);
	
	RenderWindowDetail->Render();

//------------------------------------------------------------------------------------

	vtkSTLWriter* stlWriter = vtkSTLWriter::New();
	stlWriter->SetFileName("CreatedImplantStencil_1.stl");
	stlWriter->SetInput(act->GetMapper()->GetInput());
	stlWriter->Write();
	stlWriter->Update(); 

My question now is, how can I create a real 3d object out of the cutted
piece? My piece does not have any borders yet. How can I create a closed
object? Please help me!

Thanks a lot
Samo



-- 
View this message in context: http://www.nabble.com/help-with-vtkImageStencil-and-STLWriter-tf2944724.html#a8234468
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list