[vtkusers] (no subject)

Kevin Wright krw at viz-solutions.com
Tue May 14 12:50:06 EDT 2002


 > I have a PolyData object that was created
 > by a vtkMarchingCubes filter. I would
 > like to color this PolyData using the
 > scalars from a different scalar field
 > (from a vtkStructuredPoints). Does
 > anybody know a good way to do this?
 > vtkCutter, which seems like the logical
 > choice, only works on vtkImplicitFunctions,
 > and attempts to convert the PolyData
 > to a vtkImplicitFunction via a
 > vtkImplicitDataSet didn't work
 > (and spent a long time computing).

If you're using VTK 3.x then I think you'll have to set up two pointsets, 
one with the scalar that you're using for the marching cubes, and one with 
the scalar that you want to scalar map with.  Generate your polydata same 
as always, then use the output surface to probe (vtkProbeFilter) the second 
pointset.  I've never tried that, but I think that is the Kitware approved 
method.

If you're using VTK 4, then its a lot cleaner.  Just create a pointset with 
the scalar field set to the scalar required by the marching cubes filter, 
then apply the second scalar field to the same pointset using:

vtkStructuredGrid *sg;
vtkFloatArray *scalar2;
....
scalar2->SetName("Scalar2");
sg->GetPointData()->AddArray(scalar2);

Then, the second scalar can be mapped instead of the first by using the mapper:

mapper->SetScalarModeToUsePointFieldData();
mapper->ColorByArrayComponent("Scalar2",0);

That should do it for you.

Kevin.





More information about the vtkusers mailing list