[vtkusers] Re: Re: newbie question : vtkPlanes to represent a cube
Goodwin Lawlor
goodwin.lawlor at ucd.ie
Mon Oct 11 17:00:38 EDT 2004
Hi Jim,
> ERROR: In /home/jim/VTK/VTK/Filtering/vtkImplicitDataSet.cxx, line 78
> vtkImplicitDataSet (0x829ae88): Can't evaluate dataset!
This filter needs the input to have a set a scalars, presumably representing
a distance function.
> But if I don't try to display the actor, I
> don't get any error (which may be normal since I don't yet fully
> understand how VTK works).
That's because the pipeline hasn't been asked to execute by the renderer.
I had another look at the first method you tried using vtkPlanes... There is
some unusual behavior here that I dont have time to go through but you can
play with this code... contour values of -0.75 work but values >-0.75 crash
the contour filter. Looking at the input data to the contour as an image is
looks like vtkPlanes has trouble evaluating the function where it is
equidistant from 3 planes. I am not sure you had the point values correct
either:
package require vtk
vtkPoints points
points SetNumberOfPoints 6
points SetPoint 0 1 0 0
points SetPoint 1 -1 0 0
points SetPoint 2 0 1 0
points SetPoint 3 0 -1 0
points SetPoint 4 0 0 1
points SetPoint 5 0 0 -1
vtkFloatArray norms
norms SetNumberOfComponents 3
norms SetNumberOfTuples 6
norms SetTuple3 0 1 0 0
norms SetTuple3 1 -1 0 0
norms SetTuple3 2 0 1 0
norms SetTuple3 3 0 -1 0
norms SetTuple3 4 0 0 1
norms SetTuple3 5 0 0 -1
vtkPlanes planes
planes SetPoints points
planes SetNormals norms
vtkSampleFunction sample
sample SetImplicitFunction planes
sample SetModelBounds 2 -2 2 -2 2 -2
sample SetSampleDimensions 40 40 40
sample Update
vtkImageViewer viewer
viewer SetInput [sample GetOutput]
viewer SetColorWindow 2
viewer SetColorLevel 0
viewer SetZSlice 2
viewer Render
scale .s -command cb
pack .s
proc cb {var} {
viewer SetZSlice $var
viewer Render
}
vtkContourFilter contour
contour SetInput [sample GetOutput]
contour SetValue 0 -0.75
vtkPolyDataMapper mapper
mapper SetInput [contour GetOutput]
vtkActor actor
actor SetMapper mapper
[actor GetProperty] SetRepresentationToWireframe
vtkRenderer ren
ren AddActor actor
vtkRenderWindow renwin
renwin AddRenderer ren
vtkRenderWindowInteractor iren
iren SetRenderWindow renwin
iren AddObserver UserEvent {console show}
iren Initialize
More information about the vtkusers
mailing list