[vtkusers] vtkContourFilter issue
David Doria
daviddoria+vtk at gmail.com
Wed Dec 9 09:42:35 EST 2009
I create an ImageData:
vtkSmartPointer<vtkImageData> grid = vtkSmartPointer<vtkImageData>::New();
grid->SetOrigin(xmin, ymin, zmin);
grid->SetExtent(0, this->NumberOfCellsX-1, 0, this->NumberOfCellsY-1,
0, this->NumberOfCellsZ-1); //same as grid->SetDimensions(10, 10, 10);
grid->SetSpacing((xmax-xmin)/static_cast<double>(this->NumberOfCellsX),
(ymax-ymin)/static_cast<double>(this->NumberOfCellsY),
(zmax-zmin)/static_cast<double>(this->NumberOfCellsZ));
Then I set a value at each point:
for (int z = 0; z < dims[2]; z++)
{
for (int y = 0; y < dims[1]; y++)
{
for (int x = 0; x < dims[0]; x++)
{
//compute d ....
grid->SetScalarComponentFromDouble(x,y,z,0,d);
}
}
}
Then I want to extract the 0 isosurface of this scalar field.
I tried to do:
vtkSmartPointer<vtkContourFilter> contourFilter =
vtkSmartPointer<vtkContourFilter>::New();
contourFilter->SetInput(grid);
vtkPolyData* surface = contourFilter->GetOutput();
but the result has 0 points and 0 cells. Have I done something wrong
with constructing the ImageData? Or using the ContourFilter?
Thanks,
David
More information about the vtkusers
mailing list