18 #include <vtkCellArray.h>
19 #include <vtkCellData.h>
20 #include <vtkInformation.h>
21 #include <vtkInformationVector.h>
22 #include <vtkObjectFactory.h>
23 #include <vtkPolyData.h>
24 #include <vtkProperty.h>
25 #include <vtkSmartPointer.h>
26 #include <vtkStreamingDemandDrivenPipeline.h>
27 #include <vtkTriangle.h>
39 this->SetNumberOfInputPorts(0);
44 vtkProps->SetColor(
c[0] / 255.0,
c[1] / 255.0,
c[2] / 255.0);
45 vtkProps->SetEdgeVisibility(0);
50 this->Superclass::PrintSelf(os, indent);
57 os << indent <<
"== VtkSurfacesSource =="
62 vtkInformationVector** inputVector,
63 vtkInformationVector* outputVector)
74 const std::vector<GeoLib::Point*>* surfacePoints =
75 (*_surfaces)[0]->getPointVec();
76 std::size_t nPoints = surfacePoints->size();
78 vtkSmartPointer<vtkInformation> outInfo =
79 outputVector->GetInformationObject(0);
80 vtkSmartPointer<vtkPolyData> output =
81 vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
82 if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) >
88 vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New();
89 newPoints->SetNumberOfPoints(nPoints);
91 vtkSmartPointer<vtkCellArray> newPolygons =
92 vtkSmartPointer<vtkCellArray>::New();
95 vtkSmartPointer<vtkIntArray> sfcIDs = vtkSmartPointer<vtkIntArray>::New();
96 sfcIDs->SetNumberOfComponents(1);
97 sfcIDs->SetName(
"SurfaceIDs");
99 for (std::size_t i = 0; i < nPoints; ++i)
101 const double* coords =
102 const_cast<double*
>((*surfacePoints)[i]->getCoords());
103 newPoints->SetPoint(i, coords);
109 const std::size_t nTriangles = surface->getNumberOfTriangles();
111 for (std::size_t i = 0; i < nTriangles; ++i)
113 vtkTriangle* new_tri = vtkTriangle::New();
114 new_tri->GetPointIds()->SetNumberOfIds(3);
117 for (std::size_t j = 0; j < 3; ++j)
119 new_tri->GetPointIds()->SetId(j, ((*triangle)[j]));
121 newPolygons->InsertNextCell(new_tri);
122 sfcIDs->InsertNextValue(count);
128 output->SetPoints(newPoints);
129 output->SetPolys(newPolygons);
130 output->GetCellData()->AddArray(sfcIDs);
131 output->GetCellData()->SetActiveAttribute(
"SurfaceIDs",
132 vtkDataSetAttributes::SCALARS);
140 vtkInformationVector** ,
141 vtkInformationVector* )
149 (*_algorithmUserProperties)[
name] = value;
Definition of the Color class.
vtkStandardNewMacro(VtkSurfacesSource)
Definition of the VtkSurfacesSource class.
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
vtkProperty * GetProperties() const
Returns the vtk properties.
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.
VTK source object for the visualisation of surfaces. Technically, surfaces are displayed as triangula...
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
void PrintSelf(ostream &os, vtkIndent indent) override
Prints its data on a stream.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Computes the polygonal data object.
const std::vector< GeoLib::Surface * > * _surfaces
The surfaces to visualize.
void SetUserProperty(QString name, QVariant value) override
Generates random colors for each surface.
std::array< unsigned char, 4 > Color
Color getRandomColor()
Returns a random RGB colour.