[vtkusers] Color of isosurface

Dale "Luke" Peterson hazelnusse at gmail.com
Mon Jul 2 12:52:16 EDT 2012


I subclassed vtkImplicit function and implemented EvaluateFunction()
and EvaluateGradient().  I then use vtkSampleFunction,
vtkContourFilter, vtkPolyDataMapper, and vtkActor and add the actor to
a renderer.  I am only interested in one iso-surface, the zero
iso-surface, and in the past it always displayed in red.  Something
changed (likely in my code) but I can't figure out what, and the the
surface renders only in black.  I have tried calling
GetProperty()->SetColor() on the actor but this has no effect.  I also
tried dropping in example code for the vtkSphereSource which shows up
blue, as in the tutorial.  Based on this, I'm guessing that there is
something going on with vtkSampleFunction, vtkContourFilter, or
vtkPolyDataMapper, but I can't figure out what.

I am doing all of this in my own subclassed QVTKWidget, and the color
used to work fine.  I also have a minimal example of the surface that
doesn't use QVTKWidget and it shows the surface in red.  Perhaps there
is something strange going on in Qt?

Any ideas on what might be going on?

The relevant code I have in the constructor of my QVTKWidget subclass is:

  configurationSurface = vtkSmartPointer<vtkHolonomicConstraint>::New();
  sample = vtkSmartPointer<vtkSampleFunction>::New();
  sample->SetSampleDimensions(50, 50, 50);
  sample->SetImplicitFunction(configurationSurface);
  // Create the 0 isosurface
  contour = vtkSmartPointer<vtkContourFilter>::New();
  contour->SetInputConnection(sample->GetOutputPort());
  contour->GenerateValues(1, 0.0, 0.0);
  contour->Update();

  // Map the contours to graphical primitives
  contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
  contourMapper->SetInputConnection(contour->GetOutputPort());

  // Create an actor for the contours
  contourActor = vtkActor::New();
  contourActor->SetMapper(contourMapper);

  // Has no effect: still shows up as black.
  contourActor->GetProperty()->SetColor(0,0,1);

Thanks,
Luke


-- 
“People call me a perfectionist, but I'm not. I'm a rightist. I do
something until it's right, and then I move on to the next thing.”
― James Cameron



More information about the vtkusers mailing list