# Can't get polyhedron to render in VTK 6 with Qt

**URL:** https://discourse.vtk.org/t/cant-get-polyhedron-to-render-in-vtk-6-with-qt/3052
**Category:** Support
**Created:** [April 14, 2020, 6:52pm UTC](https://discourse.vtk.org/t/cant-get-polyhedron-to-render-in-vtk-6-with-qt/3052 "2020-04-14T18:52:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![stephanie](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/3ab097/32.png) [@stephanie](https://discourse.vtk.org/u/stephanie)
#### Post date: [April 14, 2020, 6:52pm UTC](https://discourse.vtk.org/t/cant-get-polyhedron-to-render-in-vtk-6-with-qt/3052/1 "2020-04-14T18:52:03Z")

</div>

I am having trouble rendering a weirdly-shaped polyhedron in VTK 6 with Qt. I am able to construct it, but when I try to add the actors to the renderers and render the entire image, it segfaults on the call to Render(). My function is as follows: (this is to display an object representing the frustum of a camera I am using for tracking).

```
void QtCDA_GUI_VolumeVerification::displayFrustumObject()
{
  int numberOfVertices = 12;
  int numberOfFaces = 10;
  int numberOfFaceVertices = 4;

  vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
  points->InsertNextPoint( 350,350,-920);
  points->InsertNextPoint( 350,-350,-920);
  points->InsertNextPoint(-350,-350,-920);
  points->InsertNextPoint(-350,350,-920);
  points->InsertNextPoint( 570,473.5,-1920);
  points->InsertNextPoint( 570,-473.5,-1920);
  points->InsertNextPoint( -570,-473.5,-1920);
  points->InsertNextPoint(-570,473.5,-1920);
  points->InsertNextPoint(570,538,-2200);
  points->InsertNextPoint( 570,-538,-2200);
  points->InsertNextPoint( -570,-538,-2200);
  points->InsertNextPoint(-570,538,-2200);

  vtkIdType frustumPointsIds[12] =
  {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

  vtkIdType frustumFace[10][4] = {
  {0, 3, 2, 1},
  {0, 1, 5, 4},
  {0, 4, 7, 3},
  {1, 2, 6, 5},
  {6, 2, 3, 7},
  {4, 5, 9, 8},
  {4, 8, 11, 7},
  {5, 6, 10, 9},
  {6, 7, 11, 10},
  {8, 9, 10, 11}
  };

  vtkSmartPointer<vtkCellArray> frustumFaces =
vtkSmartPointer<vtkCellArray>::New();
  for (int i = 0; i < numberOfFaces; i++)
  {
    frustumFaces->InsertNextCell(numberOfFaceVertices, frustumFace[i]);
  }

  vtkSmartPointer<vtkUnstructuredGrid> uGrid =
vtkSmartPointer<vtkUnstructuredGrid>::New();
  uGrid->SetPoints(points);
  uGrid->InsertNextCell(VTK_POLYHEDRON,
      numberOfVertices, frustumPointsIds,
    numberOfFaces, frustumFaces->GetPointer());

vtkSmartPointer<vtkDataSetMapper> frustumMapper = vtkSmartPointer<vtkDataSetMapper>::New();
frustumMapper->SetInputData(uGrid);
vtkSmartPointer<vtkActor> frustumActor = vtkSmartPointer<vtkActor>::New();
frustumActor->SetMapper(frustumMapper);
frustumActor->GetProperty()->SetColor(1, 0, 0);
frustumActor->GetProperty()->SetOpacity(0.1);
// m_leftRenderer->AddActor(frustumActor);
// m_rightRenderer->AddActor(frustumActor);
}

```

When I uncomment the last two lines, the program segfaults and crashes. I followed the Polyhedron example here ([https://vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Cell3DDemonstration](https://vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Cell3DDemonstration)) to construct this.

I re-ordered the order of the vertices on each face to be counter-clockwise, but I am adding the faces in no particular order.

Thanks for the help!

Stephanie
