17 #include <vtkCellArray.h>
18 #include <vtkCellData.h>
19 #include <vtkInformation.h>
20 #include <vtkInformationVector.h>
21 #include <vtkObjectFactory.h>
22 #include <vtkPointData.h>
23 #include <vtkPoints.h>
24 #include <vtkPolyData.h>
25 #include <vtkProperty.h>
26 #include <vtkSmartPointer.h>
27 #include <vtkStreamingDemandDrivenPipeline.h>
37 this->SetNumberOfInputPorts(0);
45 this->Superclass::PrintSelf(os, indent);
52 os << indent <<
"== VtkPointsSource =="
58 os << indent <<
"Point " << i <<
" (" << (*point)[0] <<
", "
59 << (*point)[1] <<
", " << (*point)[2] <<
")\n";
65 vtkInformationVector** inputVector,
66 vtkInformationVector* outputVector)
75 int numPoints =
_points->size();
78 ERR(
"VtkPointsSource::RequestData(): Size of point vector is 0");
82 vtkSmartPointer<vtkInformation> outInfo =
83 outputVector->GetInformationObject(0);
84 vtkSmartPointer<vtkPolyData> output =
85 vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
87 vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New();
88 vtkSmartPointer<vtkCellArray> newVerts =
89 vtkSmartPointer<vtkCellArray>::New();
90 newPoints->SetNumberOfPoints(numPoints);
91 newVerts->Allocate(numPoints);
93 vtkSmartPointer<vtkIntArray> pointIDs = vtkSmartPointer<vtkIntArray>::New();
94 pointIDs->SetNumberOfComponents(1);
95 pointIDs->SetNumberOfValues(numPoints);
96 pointIDs->SetName(
"PointIDs");
98 if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) >
108 double coords[3] = {(*point)[0], (*point)[1], (*point)[2]};
109 newPoints->SetPoint(i, coords);
110 newVerts->InsertNextCell(1);
111 newVerts->InsertCellPoint(i);
113 pointIDs->SetValue(i, i);
117 output->SetPoints(newPoints);
118 output->SetVerts(newVerts);
119 output->GetCellData()->AddArray(pointIDs);
120 output->GetCellData()->SetActiveAttribute(
"PointIDs",
121 vtkDataSetAttributes::SCALARS);
127 vtkInformationVector** ,
128 vtkInformationVector* )
Definition of the Color class.
void ERR(char const *fmt, Args const &... args)
vtkStandardNewMacro(VtkPointsSource)
Definition of the VtkPointsSource class.
vtkProperty * GetProperties() const
Returns the vtk properties.
VtkPointsSource is a VTK source object for the visualization of point data. As a vtkPolyDataAlgorithm...
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Computes the polygonal data object.
void SetUserProperty(QString name, QVariant value) override
Sets a user property. This should be implemented by subclasses.
const std::vector< GeoLib::Point * > * _points
The points to visualize.
void PrintSelf(ostream &os, vtkIndent indent) override
Prints its data on a stream.
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
std::array< unsigned char, 4 > Color
Color getRandomColor()
Returns a random RGB colour.