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.
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
It is as simple as adding this function to vtkOrientedGlyphContourRepresentation
. Would this be okay to add?
//------------------------------------------------------------------------------
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);
}