<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><span>Heath,</span></div><div><br></div><div>vtkOutlineFilter will give you the outline, i.e. the bounding box for the mesh. To show the structured grid as a wireframe, simply do the following:</div><div><br></div><div>mapper->SetInputConnection(structuredGrid->GetProducerPort());<br> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();<br> actor->SetMapper(mapper);<br> actor->GetProperty()->SetRepresentationToWireframe();</div><div><br></div><div><br></div><div>The default representation is surface.<br></div><div><br></div><div>Also, under vtkStructuredGrid at http://www.vtk.org/Wiki/VTK/Examples/Cxx you will find few additional examples for visualizing structured grids.</div><div><br></div><div>--</div><div>Lubos Brieda</div><div>particleincell.com<br></div><br><div
style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Heath Johnson <heathbjohnson@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> vtkusers@vtk.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Friday, December 30, 2011 3:35 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> [vtkusers] Help changing view of structured grid<br> </font> <br>
I am getting started with vtk-5.6 and am trying to make a very simple<br>example problem with a structured grid which can be viewed in<br>different ways - outline of edges, wireframe of connected points, and<br>simply the points themselves. I started from the example problem<br>here:<br><br>http://www.vtk.org/Wiki/VTK/Examples/Cxx/StructuredGrid/VisualizeStructuredGrid<br><br>The code below displays the outline of the structured grid (using<br>vtkStructuredGridOutlineFilter) but I am unable to update the view to<br>show the wireframe or points. I can follow other examples which show<br>only the points or the wireframe, but I want to be able to change how<br>a structured grid is viewed. I know I am missing something about how<br>VTK works, but I cannot figure out how to do it correctly. Can<br>somebody please help?<br><br>------------------------------------<br>#include <vtkSmartPointer.h><br>#include
<vtkStructuredGrid.h><br>#include <vtkMath.h><br>#include <vtkPolyDataMapper.h><br>#include <vtkActor.h><br>#include <vtkRenderWindow.h><br>#include <vtkRenderer.h><br>#include <vtkProperty.h><br>#include <vtkRenderWindowInteractor.h><br>#include <vtkStructuredGridOutlineFilter.h><br><br>int main(int, char *[])<br>{<br> // Create a grid<br> vtkSmartPointer<vtkStructuredGrid> structuredGrid =<br> vtkSmartPointer<vtkStructuredGrid>::New();<br><br> vtkSmartPointer<vtkPoints> points =<br> vtkSmartPointer<vtkPoints>::New();<br> unsigned int numi = 3;<br> unsigned int numj = 5;<br> unsigned int numk = 4;<br><br> for(unsigned int k = 0; k < numk; k++)<br> {<br> for(unsigned int j = 0; j < numj; j++)<br> {<br> for(unsigned int i = 0; i < numi;
i++)<br> {<br> points->InsertNextPoint(i, j, k);<br> }<br> }<br> }<br><br> //specify the dimensions of the grid<br> structuredGrid->SetDimensions(numi, numj, numk);<br> structuredGrid->SetPoints(points);<br><br> std::cout << "There are " << structuredGrid->GetNumberOfPoints() <<<br>" points." << std::endl;<br> std::cout << "There are " << structuredGrid->GetNumberOfCells() << "<br>cells." << std::endl;<br><br> vtkSmartPointer<vtkStructuredGridOutlineFilter> outlineFilter =<br> vtkSmartPointer<vtkStructuredGridOutlineFilter>::New();<br> outlineFilter->SetInputConnection(structuredGrid->GetProducerPort());<br> outlineFilter->Update();<br><br> // Create a mapper and actor<br>
vtkSmartPointer<vtkPolyDataMapper> mapper =<br> vtkSmartPointer<vtkPolyDataMapper>::New();<br> mapper->SetInputConnection(outlineFilter->GetOutputPort());<br> vtkSmartPointer<vtkActor> actor =<br> vtkSmartPointer<vtkActor>::New();<br> actor->SetMapper(mapper);<br><br> // Visualize<br> vtkSmartPointer<vtkRenderer> renderer =<br> vtkSmartPointer<vtkRenderer>::New();<br> vtkSmartPointer<vtkRenderWindow> renderWindow =<br> vtkSmartPointer<vtkRenderWindow>::New();<br> renderWindow->AddRenderer(renderer);<br> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br> vtkSmartPointer<vtkRenderWindowInteractor>::New();<br> renderWindowInteractor->SetRenderWindow(renderWindow);<br><br> renderer->AddActor(actor);<br><br>
renderWindow->Render();<br><br> // --- Everything above is from the example.<br> // --- The commands below are what I am trying to do ---<br><br> // Change how structured grid is viewed<br><br> // -- View grid as wireframe between connected points<br> sleep(2);<br> std::cout << "Changing to surface representation" << std::endl;<br> actor->GetProperty()->SetRepresentationToSurface();<br> renderWindow->Render();<br><br> // View grid as points only<br> sleep(2);<br> std::cout << "Changing to points representation" << std::endl;<br> actor->GetProperty()->SetRepresentationToPoints();<br> renderWindow->Render();<br><br> renderWindowInteractor->Start();<br><br> return EXIT_SUCCESS;<br>}<br>------------------------------------<br>_______________________________________________<br>Powered by <a target="_blank"
href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<br><br>Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.vtk.org/mailman/listinfo/vtkusers<br><br><br> </div> </div> </div></body></html>