<div dir="ltr">Can you try replacing the vtkGeometryFilter with vtkDataSetSurfaceFilter? I suspect the vtkGeometryFilter doesn't handle polyhedral elements.<div><br></div><div>Utkarsh</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 22, 2015 at 1:13 AM tariq <<a href="mailto:tdinar@gmail.com">tdinar@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, I am a newbie to vtk, and I have been trying to visualize an unstructured<br>
grid with the aid of vtkGeometryFilter to convert a polyhedron<br>
(unStructuredGrid) into vtkPolyData. Then compute the Normals and use a<br>
Lookup table to plot the data. The one polyhedron in my code would not show<br>
up. The code is pasted below and I am all ears. Thanks. TQ.<br>
<br>
#include <vtkSmartPointer.h><br>
#include <vtkRenderer.h><br>
#include <vtkUnstructuredGrid.h><br>
#include <vtkPolyhedron.h><br>
#include <vtkCellArray.h><br>
#include <vtkPointData.h><br>
#include <vtkCellData.h><br>
#include <vtkIdList.h><br>
#include <vtkPoints.h><br>
#include <vtkDataArray.h><br>
#include <vtkConnectivityFilter.h><br>
#include <vtkGeometryFilter.h><br>
#include <vtkPolyDataMapper.h><br>
#include <vtkPolyDataNormals.h><br>
#include <vtkActor.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkLookupTable.h><br>
<br>
<br>
<br>
int main( int, char*[] )<br>
{<br>
// create polyhedron (cube)<br>
vtkIdType pointIds[8] = {0, 1, 2, 3, 4, 5, 6, 7};<br>
<br>
vtkSmartPointer<vtkPoints> points =<br>
vtkSmartPointer<vtkPoints>::New();<br>
points->InsertNextPoint(-1.0,-1.0,-1.0);<br>
points->InsertNextPoint( 1.0,-1.0,-1.0);<br>
points->InsertNextPoint( 1.0, 1.0,-1.0);<br>
points->InsertNextPoint(-1.0, 1.0,-1.0);<br>
points->InsertNextPoint(-1.0,-1.0, 1.0);<br>
points->InsertNextPoint( 1.0,-1.0, 1.0);<br>
points->InsertNextPoint( 1.0, 1.0, 1.0);<br>
points->InsertNextPoint(-1.0, 1.0, 1.0);<br>
<br>
vtkSmartPointer<vtkCellArray> faces =<br>
vtkSmartPointer<vtkCellArray>::New();<br>
vtkIdType face0[4] = {0, 3, 2, 1};<br>
vtkIdType face1[4] = {0, 4, 7, 3};<br>
vtkIdType face2[4] = {4, 5, 6, 7};<br>
vtkIdType face3[4] = {5, 1, 2, 6};<br>
vtkIdType face4[4] = {0, 1, 5, 4};<br>
vtkIdType face5[4] = {2, 3, 7, 6};<br>
<br>
faces->InsertNextCell(4, face0);<br>
faces->InsertNextCell(4, face1);<br>
faces->InsertNextCell(4, face2);<br>
faces->InsertNextCell(4, face3);<br>
faces->InsertNextCell(4, face4);<br>
faces->InsertNextCell(4, face5);<br>
<br>
vtkSmartPointer<vtkUnstructuredGrid> ugrid =<br>
vtkSmartPointer<vtkUnstructuredGrid>::New();<br>
ugrid->SetPoints(points);<br>
ugrid->InsertNextCell(<br>
VTK_POLYHEDRON, 8, pointIds,<br>
6, faces->GetPointer());<br>
// Extract poly data from unsturctured Grid<br>
<br>
vtkSmartPointer<vtkConnectivityFilter> Filter1=<br>
vtkSmartPointer<vtkConnectivityFilter>::New();<br>
<br>
Filter1->SetInputData(ugrid);<br>
Filter1->Update(0);<br>
<br>
vtkSmartPointer<vtkGeometryFilter> Filter2=<br>
vtkSmartPointer<vtkGeometryFilter>::New();<br>
<br>
<br>
Filter2->SetInputConnection(0,Filter1->GetOutputPort(0));<br>
Filter2->Update(0);<br>
<br>
// Calculate normals<br>
<br>
vtkSmartPointer<vtkPolyDataNormals> normals =<br>
vtkSmartPointer<vtkPolyDataNormals>::New();<br>
<br>
normals->SetFeatureAngle(60);<br>
<br>
normals->SetInputConnection(0,Filter2->GetOutputPort(0));<br>
<br>
normals->Update(0);<br>
<br>
//Setup lookup table<br>
vtkSmartPointer<vtkLookupTable> lut=<br>
vtkSmartPointer<vtkLookupTable>::New();<br>
<br>
lut->SetHueRange(0.0, 100);<br>
<br>
// initiate mapper<br>
<br>
vtkSmartPointer<vtkPolyDataMapper> mapper=<br>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
<br>
mapper->SetInputConnection(0,normals->GetOutputPort(0));<br>
mapper->SetLookupTable(lut);<br>
mapper->SetScalarRange(0.12, 0.6);<br>
<br>
<br>
vtkSmartPointer<vtkActor> actor=<br>
vtkSmartPointer<vtkActor>::New();<br>
<br>
// Initiate Actor<br>
<br>
actor->SetMapper(mapper);<br>
actor->SetPosition(0.0, 0.0, 0.0);<br>
<br>
// Create a renderer, render window, and interactor<br>
vtkSmartPointer<vtkRenderer> renderer =<br>
vtkSmartPointer<vtkRenderer>::New();<br>
renderer->ResetCamera();<br>
renderer->ResetCameraClippingRange();<br>
<br>
vtkSmartPointer<vtkRenderWindow> renderWindow =<br>
vtkSmartPointer<vtkRenderWindow>::New();<br>
<br>
renderWindow->AddRenderer(renderer);<br>
<br>
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>
vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
renderWindowInteractor->SetRenderWindow(renderWindow);<br>
<br>
// Add the actor to the scene<br>
renderer->AddActor(actor);<br>
renderer->SetBackground(.2, .3, .4);<br>
<br>
// Render and interact<br>
renderWindow->Render();<br>
renderWindowInteractor->Start();<br>
<br>
<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/tdinar-gmail-com-tp5733035.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/tdinar-gmail-com-tp5733035.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div>