[vtkusers] Problem with vtkContourFilter with unstructured grid

bartolomei-luca at virgilio.it bartolomei-luca at virgilio.it
Mon Mar 5 05:23:28 EST 2018


Hello everyone!

I have a question about how to use the vtkContourFilter with an unstructured grid.

I have an unstructured grid where the values are stored at the center of the cells. So, before using the contour filter, I use the CellDataToPointData filter. The problem is that I do not see any output after using the contourFilter. I also tried to use vtkImplicitModeller to pre-process the grid, but the situation does not change.

The grid cells do contain values, since I can display them when I process for other tasks, but I did not manage to display isosurfaces.

Here it is my code:

// CELL TO POINT DATA

vtkSmartPointer<vtkCellDataToPointData> c2p {vtkSmartPointer<vtkCellDataToPointData>::New()};
c2p->SetInputData(grid); // grid is the unstructured grid I have created
c2p->Update();


// CONTOUR FILTER

vtkSmartPointer<vtkContourFilter> contourFilter =  vtkSmartPointer<vtkContourFilter>::New();
contourFilter->SetInputConnection(c2p->GetOutputPort());

contourFilter->GenerateValues(10, c2p->GetOutput()->GetScalarRange());
contourFilter->Modified();
contourFilter->Update();


// MAPPER

vtkSmartPointer<vtkPolyDataMapper> contourMapper {vtkSmartPointer<vtkPolyDataMapper>::New()};
contourMapper->SetInputConnection(contourFilter->GetOutputPort());
contourMapper->Update();


// VISUALIZATION

vtkSmartPointer<vtkActor> contourActor {vtkSmartPointer<vtkActor>::New()};
contourActor->SetMapper(contourMapper);

vtkSmartPointer<vtkRenderer> renderer {vtkSmartPointer<vtkRenderer>::New()};
contourActor->SetMapper(contourMapper);

renderer->AddActor(contourActor);


Do you have any suggestion?

Thanks a lot for the help!

Best,

Luca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180305/555775c7/attachment.html>


More information about the vtkusers mailing list