49 this->Superclass::PrintSelf(os, indent);
58 os << indent <<
"== Polyline =="
60 int numPoints = polyline->getNumberOfPoints();
61 for (
int i = 0; i < numPoints; i++)
64 os << indent <<
"Point " << i <<
" (" << point[0] <<
", "
65 << point[1] <<
", " << point[2] <<
")\n";
71 vtkInformationVector** inputVector,
72 vtkInformationVector* outputVector)
83 ERR(
"VtkPolylineSource::RequestData(): Size of polyline vector is 0");
87 vtkSmartPointer<vtkInformation> outInfo =
88 outputVector->GetInformationObject(0);
89 vtkSmartPointer<vtkPolyData> output =
90 vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
92 vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New();
93 vtkSmartPointer<vtkCellArray> newLines =
94 vtkSmartPointer<vtkCellArray>::New();
99 if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) >
105 vtkSmartPointer<vtkIntArray> plyIDs = vtkSmartPointer<vtkIntArray>::New();
106 plyIDs->SetNumberOfComponents(1);
107 plyIDs->SetName(
"PolylineIDs");
109 unsigned lastMaxIndex(0);
110 const std::size_t nPolylines(
_polylines->size());
111 for (std::size_t j = 0; j < nPolylines; j++)
113 const int numPoints = (*_polylines)[j]->getNumberOfPoints();
114 const bool isClosed = (*_polylines)[j]->isClosed();
117 const int numVerts = (isClosed) ? numPoints - 1 : numPoints;
118 for (
int i = 0; i < numVerts; i++)
121 const double* coords = point->
data();
122 newPoints->InsertNextPoint(coords);
126 newLines->InsertNextCell(numPoints);
127 plyIDs->InsertNextValue(j);
128 for (
int i = 0; i < numVerts; i++)
130 newLines->InsertCellPoint(i + lastMaxIndex);
135 newLines->InsertCellPoint(lastMaxIndex);
138 lastMaxIndex += numVerts;
141 output->SetPoints(newPoints);
142 output->SetLines(newLines);
143 output->GetCellData()->AddArray(plyIDs);
144 output->GetCellData()->SetActiveAttribute(
"PolylineIDs",
145 vtkDataSetAttributes::SCALARS);