[vtkusers] RectilinearGrid into vtkContourFilter
ThinkFlow
neto at caltech.edu
Wed Aug 28 15:45:36 EDT 2013
Hi,
I am trying to render the polydata that results after passing in a
vtkRectilinearGrid into vtkContourFilter. However, I keep getting a black
screen. There were a few questions like mine that were already answered, but
when I tried out those fixes, I still got a black screen. When I render the
vtkRectilinearGrid data by itself without passing it through
vtkContourFilter, it works.
vtkRectilinearGridReader *reader = vtkRectilinearGridReader::New();
reader->SetFileName(prefix_suffix);
reader->Update();
// Create a grid
vtkSmartPointer<vtkRectilinearGrid> grid = reader->GetOutput();
vtkContourFilter* contour = vtkContourFilter::New();
contour->SetInput(grid);
contour->SetNumberOfContours(3);
contour->ComputeNormalsOn();
contour->Update();
vtkPolyData *smoothed_polys = contour->GetOutput();
// calc cell normal
vtkPolyDataNormals *triangleCellNormals= vtkPolyDataNormals::New();
#if VTK_MAJOR_VERSION <= 5
triangleCellNormals->SetInput(smoothed_polys);
#else
triangleCellNormals->SetInputData(smoothed_polys);
#endif
triangleCellNormals->ComputeCellNormalsOn();
triangleCellNormals->ComputePointNormalsOff();
triangleCellNormals->ConsistencyOn();
triangleCellNormals->AutoOrientNormalsOn();
triangleCellNormals->Update(); // creates vtkPolyData
vtkPolyDataMapper* contourMapper = vtkPolyDataMapper::New();
contourMapper->SetInput(triangleCellNormals->GetOutput());
vtkActor* contourActor = vtkActor::New();
contourActor->SetMapper(contourMapper);
// Create a renderer, render window, and interactor
vtkRenderer* renderer = vtkRenderer::New();
vtkRenderWindow *renderWindow = vtkRenderWindow::New();
vtkRenderWindowInteractor *renderWindowInteractor =
vtkRenderWindowInteractor::New();
// Add the actors to the scene
renderWindow->AddRenderer(renderer);
renderWindowInteractor->SetRenderWindow(renderWindow);
renderer->AddActor(contourActor);
// Render and interact
renderWindow->Render();
renderWindowInteractor->Start();
Thanks,
Naoki
--
View this message in context: http://vtk.1045678.n5.nabble.com/RectilinearGrid-into-vtkContourFilter-tp5723107.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list