38 this->Superclass::PrintSelf(os, indent);
47 os << indent <<
"== Polyline =="
49 int numPoints = polyline->getNumberOfPoints();
50 for (
int i = 0; i < numPoints; i++)
53 os << indent <<
"Point " << i <<
" (" << point[0] <<
", "
54 << point[1] <<
", " << point[2] <<
")\n";
60 vtkInformationVector** inputVector,
61 vtkInformationVector* outputVector)
72 ERR(
"VtkPolylineSource::RequestData(): Size of polyline vector is 0");
76 vtkSmartPointer<vtkInformation> outInfo =
77 outputVector->GetInformationObject(0);
78 vtkSmartPointer<vtkPolyData> output =
79 vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
81 vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New();
82 vtkSmartPointer<vtkCellArray> newLines =
83 vtkSmartPointer<vtkCellArray>::New();
88 if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) >
94 vtkSmartPointer<vtkIntArray> plyIDs = vtkSmartPointer<vtkIntArray>::New();
95 plyIDs->SetNumberOfComponents(1);
96 plyIDs->SetName(
"PolylineIDs");
98 unsigned lastMaxIndex(0);
99 const std::size_t nPolylines(
_polylines->size());
100 for (std::size_t j = 0; j < nPolylines; j++)
102 const int numPoints = (*_polylines)[j]->getNumberOfPoints();
103 const bool isClosed = (*_polylines)[j]->isClosed();
106 const int numVerts = (isClosed) ? numPoints - 1 : numPoints;
107 for (
int i = 0; i < numVerts; i++)
110 const double* coords = point->
data();
111 newPoints->InsertNextPoint(coords);
115 newLines->InsertNextCell(numPoints);
116 plyIDs->InsertNextValue(j);
117 for (
int i = 0; i < numVerts; i++)
119 newLines->InsertCellPoint(i + lastMaxIndex);
124 newLines->InsertCellPoint(lastMaxIndex);
127 lastMaxIndex += numVerts;
130 output->SetPoints(newPoints);
131 output->SetLines(newLines);
132 output->GetCellData()->AddArray(plyIDs);
133 output->GetCellData()->SetActiveAttribute(
"PolylineIDs",
134 vtkDataSetAttributes::SCALARS);