[vtkusers] StreamTracer input Attribute

Kevin H. Hobbs hobbsk at ohiou.edu
Wed Dec 5 14:29:30 EST 2007


On Thu, 2007-11-29 at 21:04 -0500, Berk Geveci wrote:
> I do. vtkImageGradient by default produces a scalar attribute. The
> stream tracer does not know that you want it to use that array. You
> need to use a vtkAssignAttribute or use the SetInputArrayToProcess()
> method.
> 
> -berk

Why does vtkAssignAttribute work in TCL but not in C++?

The C++ example below produces an error, but TCL example below that
works.

The error:

	ERROR: In /home/kevin/kitware/VTK/Graphics/vtkStreamer.cxx, line 488
	vtkStreamLine (0x7c1480): No vector data defined!

A C++ code snippet from my application:

	
	// Calculate the gradient.
	vtkImageGradient * gradient = vtkImageGradient::New();
	gradient->SetDimensionality(3);
	gradient->SetInputConnection( vtk_import->GetOutputPort() );

	// Tell VTK we actually want to use the gradient.
	vtkAssignAttribute * aa = vtkAssignAttribute::New();
	aa->Assign( 
			vtkDataSetAttributes::SCALARS,
			vtkDataSetAttributes::VECTORS,
			vtkAssignAttribute::POINT_DATA );
	aa->SetInputConnection( gradient->GetOutputPort() );

	// Calculate the streamline.
	vtkStreamLine * stream = vtkStreamLine::New();
	stream->SetStepLength( image_spacing[2] );
	stream->SetStartPosition( p2 );
	stream->SetInputConnection( aa->GetOutputPort() );

	// For now just write.
	vtkXMLPolyDataWriter * stream_writer
		= vtkXMLPolyDataWriter::New();
	stream_writer->SetFileName( "tmp/stream.vtp" );
	stream_writer->SetInputConnection( 
			stream->GetOutputPort() );
	stream_writer->Update();

The TCL example that works fine:

	package require vtk

	# Create some image data
	vtkRTAnalyticSource image_source
	image_source Update
	
	# Calculate the gradient
	vtkImageGradient gradient
	gradient SetDimensionality 3
	gradient SetInputConnection [image_source GetOutputPort]
	gradient Update
	
	# Make the scalars the active vector
	vtkAssignAttribute aa
	aa Assign SCALARS VECTORS POINT_DATA
	aa SetInputConnection [gradient GetOutputPort]
	
	# Create streamer
	vtkStreamLine streamer
	streamer SetStepLength 0.1
	streamer SetInputConnection [aa GetOutputPort]
	streamer Update
	
	# write the streamline
	vtkXMLPolyDataWriter stream_writer
	stream_writer SetInputConnection [streamer GetOutputPort]
	stream_writer SetFileName "tmp/stream.vtp"
	stream_writer Write
	
	exit


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071205/cdbc6d43/attachment.pgp>


More information about the vtkusers mailing list