[vtkusers] vtkContourFilter issue
Francois Bertel
francois.bertel at kitware.com
Wed Dec 9 09:55:12 EST 2009
Hello,
Dimension is the number of points along an axis, not the number of cells.
Number of cells along an axis= (number of points along an axis)-1
numCells=dim-1
if the extent starts at 0 (ie point index 0), it stops at dim-1,
therefore it goes from 0 to numCells, not numCells-1
Fix that first and see how it goes.
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
>
--
François Bertel, PhD | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
| Clifton Park NY 12065, USA
More information about the vtkusers
mailing list