[vtkusers] Generating lots of cutplanes dynamically

Martin Gardner mglistmail at totalise.co.uk
Mon Mar 17 12:13:15 EST 2003


Hi,

I want to generate lots of cut planes to slice up a volume of data. I 
have got two cutplanes marking the start and end points of the slicing 
and I want to slice this region with N cutplanes where N is specified at 
runtime.

This would be similar to volume rendering with 2d texture mapping as I 
want to generate and save images from the cutplanes.

How do I dynamically set up the cutplanes their mappers and actors and 
then insert them into the pipeline?  The snippet below is a first 
attempt at this but it doesn't work.

Any Ideas that could set me on the right track would be welcomed.

Cheers

Martin
---
mglistmail at totalise.co.uk

<code>
void vtkSurfDefWnd::ReDraw()
{
	this->renderer->GetProps()->RemoveAllItems();
	this->renderer->AddActor(cutSurfaceAssembly);
	this->renderer->AddActor(outlineActor);
	this->renWin->Render();
}

void vtkSurfDefWnd::GenerateCutSurfaces(int num_surfs)
{
	int i;

	float diff = m_pBack->GetOffset() - m_pFront->GetOffset();

	float inc = diff / (float) num_surfs;
	float start = 0.0f;
	float off = start;

	for(i=0;i<num_surfs;i++){
		off += inc;
		vtkActor *current = vtkActor::New();
		vtkCutPlane *cut = vtkCutPlane::New();
		vtkPolyDataMapper *cutMap = vtkPolyDataMapper::New();

		cut->SetOrigin(m_pFront->GetOrigin());
		cut->SetNormal(m_pFront->GetNormal());
		cut->SetOffset(off);
		cut->SetInput(pl3d->GetOutput());
		cutMap->SetInput(cut->GetOutput());
	 
cutMap->SetScalarRange(pl3d->GetOutput()->GetPointData()->GetScalars()->GetRange());
		current->SetMapper(cutMap);

		cutSurfaceAssembly->AddPart(current);

//		current->Delete();
//		cut->Delete();
//		cutMap->Delete();

	}
	ReDraw();
}

</code>




More information about the vtkusers mailing list