How to create vtk heptagonal prism (7 faces with 4 vertices and 2 faces with 7 vertices)
<p>In <code>vtk</code> you can add up to a hexagonal prism cell to a <code>vtkUnstructuredGrid</code> with <code>InsertNextCell (int type, vtkIdType npts, vtkIdType *ptIds)</code>. This is nice but I would like to include a <strong>heptagonal</strong> and <strong>octagonal</strong> prism into a <code>vtkUnstructuredGrid</code>. The cell type is not defined in vtk...</p>

<p>Just to clear some doubts I am working with <code>c#</code> but a <code>c++</code> or <code>python</code> example would be enough to translate it to <code>c#</code>.</p>

<p>Back to the issue, I first copied and slightly modified the code <a href="http://www.vtk.org/Wiki/VTK/Examples/CSharp/GeometricObjects/Tetrahedron" rel="nofollow noreferrer">in this example</a> to get a voxel (8 points and celltype = 11)</p>

<pre><code>            vtkPoints points = vtkPoints.New();
            points.InsertNextPoint(-1.0, -1.0, -1.0);
            points.InsertNextPoint(1.0, -1.0, -1.0);
            points.InsertNextPoint(1.0, 1.0, -1.0);
            points.InsertNextPoint(-1.0, 1.0, -1.0);
            points.InsertNextPoint(-1.0, -1.0, 1.0);
            points.InsertNextPoint(1.0, -1.0, 1.0);
            points.InsertNextPoint(1.0, 1.0, 1.0);
            points.InsertNextPoint(-1.0, 1.0, 1.0);
            vtkUnstructuredGrid unstructuredGrid1 = vtkUnstructuredGrid.New();
            unstructuredGrid1.SetPoints(points);
            int[] ptIds = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
            IntPtr ptIdsPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * 8);
            Marshal.Copy(ptIds, 0, ptIdsPointer, 8);
            unstructuredGrid1.InsertNextCell(11, 8, ptIdsPointer);
            Marshal.FreeHGlobal(ptIdsPointer);
            // Create a mapper and actor
            vtkDataSetMapper mapper = vtkDataSetMapper.New();
                  mapper.SetInputConnection(unstructuredGrid1.GetProducerPort());

            vtkActor actor = vtkActor.New();
            actor.SetMapper(mapper);
            actor.GetProperty().SetColor(1, 0, 0);
            actor.GetProperty().SetPointSize(3);
            actor.GetProperty().SetOpacity(1);
            actor.GetProperty().SetLineWidth(2);
            actor.GetProperty().EdgeVisibilityOn();
            Renderer3D.AddActor(actor);
</code></pre>

<p>That shows correctly a voxel getting:<a href="https://i.stack.imgur.com/QdUE6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QdUE6.png" alt="enter image description here"></a></p>

<p>but as I want a heptahedron I was trying to adapt the idea using <code>VTK_POLYHEDRON</code>, changing the line that tells the type pf cell to add to unstructuredgrid</p>

<pre><code>            unstructuredGrid1.InsertNextCell(11, 8, ptIdsPointer);
</code></pre>

<p>to (42 stands for <code>VTK_POLYHEDRON</code>, 11 stands for <code>VTK_VOXEL</code>) and <strong>points = 14</strong></p>

<pre><code>            unstructuredGrid1.InsertNextCell(42, 14, ptIdsPointer);
</code></pre>

<p>like <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Polyhedron" rel="nofollow noreferrer">this example</a>. I triedsomething like c++ but I do not get any result</p>

<pre><code>int numberOfVertices = 14;
int numberOfFaces = 9; //how to tell heptagonal prism has 2 faces with 7 vertices and 7 with 4 vertices?
int numberOfFaceVertices = 4;
vtkIdType heptagonPointsIds[14] =  
    {0, 1,  2,  3,  4,  5,  6
     7,  8, 9, 10, 11, 12,13};

//points that only change in z
vtkSmartPointer&lt;vtkPoints&gt; points =  vtkSmartPointer&lt;vtkPoints&gt;::New();
        points-&gt;InsertNextPoint(454.6, 678.534, 1.1009301757813); //id 0
        points-&gt;InsertNextPoint(454.6, 678.545, 1.1500146484375);//id 1
        points-&gt;InsertNextPoint(454.6, 678.556, 1.2255187988281);//id 2
        points-&gt;InsertNextPoint(455.1, 678.556, 1.6478076171875);//id 3
        points-&gt;InsertNextPoint(455.1, 678.534, 1.7926538085938);//id 4
        points-&gt;InsertNextPoint(455.1, 678.545, 1.7166479492188);//id 5
        points-&gt;InsertNextPoint(454.85, 678.534, 1.0092297363281);//id 6

        points-&gt;InsertNextPoint(454.6, 678.534, 5.1009301757813);//id 7
        points-&gt;InsertNextPoint(454.6, 678.545, 5.1500146484375);//id 8
        points-&gt;InsertNextPoint(454.6, 678.556, 5.2255187988281);//id 9
        points-&gt;InsertNextPoint(455.1, 678.556, 5.6478076171875);//id 10
        points-&gt;InsertNextPoint(455.1, 678.534, 5.7926538085938);//id 11
        points-&gt;InsertNextPoint(455.1, 678.545, 5.7166479492188);//id 12
        points-&gt;InsertNextPoint(454.85, 678.534, 5.0092297363281);//id13    
vtkIdType heptagonPrismFace[9][4] = {
      {0, 1, 7, 8},
      {1, 2, 8, 9},
      {2, 3, 9, 10},
      {3, 4, 10, 11},
      {4, 5, 11, 12},
      {5, 6, 12, 13},
      {6, 1, 13, 8},
      //last two faces how to tel they should be 0 1 2 3 4 5 6 and  7 8 9 10 11 12 13 ?
      {0, 1, 2, 3},
      {7, 8, 9, 10},
      };

  vtkSmartPointer&lt;vtkCellArray&gt; heptagonFaces=
    vtkSmartPointer&lt;vtkCellArray&gt;::New();
  for (int i = 0; i &lt; numberOfFaces; i++)
    {
    heptagonFaces-&gt;InsertNextCell(numberOfFaceVertices, heptagonPrismFace[i]);
    }

  vtkSmartPointer&lt;vtkUnstructuredGrid&gt; uGrid = vtkSmartPointer&lt;vtkUnstructuredGrid&gt;::New();
  uGrid-&gt;InsertNextCell(VTK_POLYHEDRON,
          numberOfVertices, heptagonPointsIds,
        numberOfFaces, heptagonFaces-&gt;GetPointer());
  uGrid-&gt;SetPoints(points);

vtkSmartPointer&lt;vtkDataSetMapper&gt; mapper =     vtkSmartPointer&lt;vtkDataSetMapper&gt;::New();
  mapper-&gt;SetInputConnection(uGrid-&gt;GetProducerPort());


  //add actor to render and stuff...
</code></pre>

<p>How would I get something like image: <a href="https://i.stack.imgur.com/GCEdW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GCEdW.png" alt="enter image description here"></a></p>