[vtkusers] Problem of vtkPolyDataToImageStencil

Yan Pingkun engp1734 at nus.edu.sg
Mon Mar 22 23:46:13 EST 2004


Hi Mathieu,

I read the materials before I wrote the codes. Actually, my program
segment is like this:

==============================================================
	vtkSphereSource* sphere = vtkSphereSource::New();
		sphere->SetPhiResolution(12);
		sphere->SetThetaResolution(12);
		sphere->SetCenter(48, 48, 48);
		sphere->SetRadius(5);

	vtkPolyDataToImageStencil* Poly2Stencil =
vtkPolyDataToImageStencil::New();
		Poly2Stencil->SetInput(sphere->GetOutput());

	vtkStructuredPointsReader*	vtkReader	=
vtkStructuredPointsReader::New();
	vtkReader->SetFileName("EmptyVolume96x96x96.vtk");

	vtkImageStencil* stencil = vtkImageStencil::New();
	stencil->SetStencil(Poly2Stencil->GetOutput());
	stencil->SetInput((vtkImageData*) vtkReader->GetOutput());
	stencil->SetBackgroundValue(255.0);
	stencil->ReverseStencilOff();
	stencil->Update();
	const vtkImageData* imgdata = stencil->GetOutput();
=====================================================================

The imgdata always has 0 dimensions and causes the program crash later.
Any problem with the code?

Regards,
Pingkun


-----Original Message-----
From: Mathieu Malaterre [mailto:mathieu.malaterre at kitware.com] 
Sent: Tuesday, March 23, 2004 6:44 AM
To: Yan Pingkun
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Problem of vtkPolyDataToImageStencil


Yan,

	Did you read the documentation of vtkPolyDataToImageStencil ? My
guess 
is that you are trying to display an image stencil. Please read :

http://www.vtk.org/doc/nightly/html/classvtkPolyDataToImageStencil.html

	And an example is always eaiser to understand:

http://vtk.org/cgi-bin/cvsweb.cgi/~checkout~/VTK/Hybrid/Testing/Tcl/Test
ImageStencilWithPolydata.tcl

HTH
Mathieu

Yan Pingkun wrote:
>  Hi all,
>  
> I'm using vtkPolyDataToImageStencil in my project. I run the TCL text
> program. It is OK except the recently reported bug.
>  
> But when I wrote program in C++, the filter can't work. My code is as
> follows:
>  
> ========================================================
>  vtkSphereSource* sphere = vtkSphereSource::New();  
> sphere->SetPhiResolution(12);  sphere->SetThetaResolution(12);
>  sphere->SetCenter(48, 48, 48);
>  sphere->SetRadius(5);
>  
>  vtkPolyDataToImageStencil* Poly2Stencil = 
> vtkPolyDataToImageStencil::New();  
> Poly2Stencil->SetInput(sphere->GetOutput());
>  Poly2Stencil->Update();
>  const vtkImageStencilData* stencilData = Poly2Stencil->GetOutput();
> ========================================================
>  
> When I debug the program, I found that the extent of stencilData is
> always -1, which causes the program crash.
> Anybody can help? I'm working under Windows XP with MSVC 6.
>  
> Thanks!
>  
> Regards,
> Pingkun






More information about the vtkusers mailing list