[vtkusers] vtkClipPolyData Bug/Feature

Erik Sobel erik.sobel at alphatech.com
Thu Apr 12 13:32:42 EDT 2001


I noticed some strange behavior with the vtkClipPolyData filter - it's 
either a bug or a feature...

The problem is... if you have N scalars in your input data and you use the 
filter you would expect to get N or fewer scalars out.

In fact, you can very easily get MORE scalars out than you put in.  Even 
more confusing, is that the value of the scalars which pass through the 
filter are not exactly the same as the input scalars.

Is the filter clipping and then interpolating?

If you are clipping using an implicit function you might be able to turn 
off the interpolation using a method you wish was named InterpolationOn/Off 
but, in the time honored VTK tradition, is actually called 
SetGenerateClipScalars  - but, you can't use this method when clipping 
based on input scalars.

Here's a little example.
------------------------------------------------------------------------------------
	vtkSphereSource sphere
		sphere Update

	set num_pts [[sphere GetOutput] GetNumberOfPoints]

	vtkScalars scalars
		scalars SetNumberOfScalars $num_pts
		for {set i 0} {$i < $num_pts} {incr i} {scalars SetScalar $i [expr $i % 2]}

	[[sphere GetOutput] GetPointData] SetScalars scalars

	vtkClipPolyData clipper
		clipper SetInput [sphere GetOutput]
		clipper GenerateClipScalarsOff
		clipper SetValue 0.5
		clipper Update

	set num_scalars [[[[sphere GetOutput] GetPointData] GetScalars] 
GetNumberOfScalars]
	set clip_pts [[clipper GetOutput] GetNumberOfPoints]
	set clip_scalars [[[[clipper GetOutput] GetPointData] GetScalars] 
GetNumberOfScalars]

	puts "The sphere has $num_pts pts and $num_scalars scalars"
	puts "The clipper has $clip_pts pts and $clip_scalars scalars"
	puts "scalar num	source scalar	clipped scalar (threshold = [clipper 
GetValue])"
	for {set i 0} {$i < $num_scalars} {incr i} {
		puts "$i		[scalars GetScalar $i]		[[[[clipper GetOutput] GetPointData] 
GetScalars] GetScalar $i]"
	}
----------------------------------------------------------------------------------------------------





More information about the vtkusers mailing list