[vtkusers] vtkContourFilter issue
Bill Lorensen
bill.lorensen at gmail.com
Wed Dec 9 10:04:33 EST 2009
You need to set the value to be extracted by the contour filter. You
also need to Update() the contour filter before requesting its output.
Or, did you just leave out those in your e-mail?
On Wed, Dec 9, 2009 at 9:42 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list