# Access to intermediate points \`vtkContourRepresentation\`

**URL:** <https://discourse.vtk.org/t/access-to-intermediate-points-vtkcontourrepresentation/11755>\
**Category:** Development\
**Created:** [June 18, 2023, 4:55pm UTC](https://discourse.vtk.org/t/access-to-intermediate-points-vtkcontourrepresentation/11755 "2023-06-18T16:55:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)\
**Post date:** [June 18, 2023, 4:55pm UTC](https://discourse.vtk.org/t/access-to-intermediate-points-vtkcontourrepresentation/11755/1 "2023-06-18T16:55:49Z")

</div>

I working with the family of `vtkContourWidget` specifically to define trajectories on surfaces of organs. I decided to inherit the representation to expose the intermediate points and create an observer which defines orientations along the contour.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/9/97c77b7e73c81bcb65894c2741811241e07fa38f.png)

Is there a reason why it is not possible to GetIntermediatePointsAsPolyData()? Would it be an idea to add such a method?

Thanks in advance  
Jens

---

<div class="post-metadata">

**Author:** ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)\
**Post date:** [June 18, 2023, 7:37pm UTC](https://discourse.vtk.org/t/access-to-intermediate-points-vtkcontourrepresentation/11755/2 "2023-06-18T19:37:30Z")

</div>

It is as simple as adding this function to `vtkOrientedGlyphContourRepresentation`. Would this be okay to add?

```auto
//------------------------------------------------------------------------------
void vtkOrientedGlyphContourRepresentationEx::GetIntermediatePolyData(vtkPolyData* poly)
{
  poly->Initialize();
  int count = this->GetNumberOfNodes();

  if (count == 0)
  {
    return;
  }

  vtkNew<vtkPoints> points;
  vtkNew<vtkCellArray> lines;

  int i, j;
  vtkIdType index = 0;

  count = 0;
  for (i = 0; i < this->GetNumberOfNodes(); i++)
  {
    count += this->GetNumberOfIntermediatePoints(i);
  }

  points->SetNumberOfPoints(count);

  vtkIdType numLines;

  if (this->ClosedLoop && count > 0)
  {
    numLines = count + 1;
  }
  else
  {
    numLines = count;
  }

  if (numLines > 0)
  {
    vtkIdType* lineIndices = new vtkIdType[numLines];

    double pos[3];
    for (i = 0; i < this->GetNumberOfNodes(); i++)
    {
      int numIntermediatePoints = this->GetNumberOfIntermediatePoints(i);

      for (j = 0; j < numIntermediatePoints; j++)
      {
        Superclass::GetIntermediatePointWorldPosition(i, j, pos);
        points->InsertPoint(index, pos);
        if (index < numLines)
        {
          lineIndices[index] = index;
        }
        index++;
      }
    }

    if (Superclass::ClosedLoop)
    {
      lineIndices[index] = 0;
    }

    lines->InsertNextCell(numLines, lineIndices);
    delete[] lineIndices;
  }

  poly->SetPoints(points);
  poly->SetLines(lines);
}

```
