[vtkusers] Re: vtkContourFilter creates dark triangles when rotatingthe iso-surface

Goodwin Lawlor goodwin.lawlor at ucd.ie
Sun Nov 14 13:44:07 EST 2004


Hi Jichang,

Put a vtkPolyDataNormals filter between vtkContourFilter and
vtkPolyDataMapper. Use the ConsistencyOn method.

hth

Goodwin


"Jichang-Startech" <jichang at startechsoft.net> wrote in message
news:00b001c4ca19$91d40180$0300a8c0 at STARTECH1...
Hi, All.

We modified the example Contour2D.tcl to make it display 3D contour surface
only. It works fine, except some dark triangles appear around the OXY, OYZ,
or OXZ plane when rotating the iso-surface.

Do we need to do more steps to prevent such unpleasant appearance? Is it a
vtkContourFilter class problem or the vtkCamera problem?

Thank you for help in advance.

Jichang

See the image and our code bellow:
-----------------------------------------------------------------

--------------- tcl code ---------------------------------------------
#
# This example shows some normals of the surfaces could be in wrong
# direction, resulting dark triagles when rotating the iso-surface

# This example is made from modification of Contor2d.tcl.
#

package require vtk
package require vtkinteraction

# Quadric definition. This is a type of implicit function. Here the
# coefficients to the equations are set.
vtkQuadric quadric
  quadric SetCoefficients .5 1 .2 0 .1 0 0 .2 0 0

# The vtkSampleFunction uses the quadric function and evaluates function
# value over a regular lattice (i.e., a volume).
vtkSampleFunction sample
  sample SetSampleDimensions 64 64 30
  sample SetImplicitFunction quadric
  sample ComputeNormalsOn

# Here a single slice (i.e., image) is extracted from the volume. (Note: in
# actuality the VOI request causes the sample function to operate on just
the
# slice.)
#vtkExtractVOI extract
#  extract SetInput [sample GetOutput]
#  extract SetVOI 0 29 0 29 15 15
#  extract SetSampleRate 1 2 3

# The image is contoured to produce contour lines. Thirteen contour values
# ranging from (0,1.2) inclusive are produced.
vtkContourFilter contours
  contours SetInput [sample GetOutput]
  contours GenerateValues 5 0.3 0.8

# The contour lines are mapped to the graphics library.
vtkPolyDataMapper contMapper
  contMapper SetInput [contours GetOutput]
  contMapper SetScalarRange 0.0 1.2

vtkActor contActor
  contActor SetMapper contMapper

# Create outline an outline of the sampled data.
#vtkOutlineFilter outline
#  outline SetInput [sample GetOutput]

#vtkPolyDataMapper outlineMapper
#  outlineMapper SetInput [outline GetOutput]

#vtkActor outlineActor
#  outlineActor SetMapper outlineMapper
#  eval [outlineActor GetProperty] SetColor 0 0 0

# Create the renderer, render window, and interactor.
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

# Set the background color to white. Associate the actors with the
# renderer.
ren1 SetBackground 1 1 1
ren1 AddActor contActor
# ren1 AddActor outlineActor

# Zoom in a little bit. Associate the Tk interactor popup with a user
# keypress-u (the UserEvent).
[ren1 GetActiveCamera] Zoom 1.5
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize;

# Don't show the root Tk window "."
wm withdraw .





_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
&lt;http://www.vtk.org/Wiki/VTK_FAQ&gt;
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers






More information about the vtkusers mailing list