18#include <vtkCellArray.h>
19#include <vtkCellData.h>
20#include <vtkDoubleArray.h>
21#include <vtkInformation.h>
22#include <vtkInformationVector.h>
24#include <vtkPointData.h>
26#include <vtkPolyData.h>
27#include <vtkProperty.h>
28#include <vtkSmartPointer.h>
29#include <vtkStreamingDemandDrivenPipeline.h>
33#include "vtkObjectFactory.h"
40 this->SetNumberOfInputPorts(0);
43 GetProperties()->SetColor(c[0] / 255.0, c[1] / 255.0, c[2] / 255.0);
48 this->Superclass::PrintSelf(os, indent);
55 os << indent <<
"== VtkStationSource =="
61 os << indent <<
"Station " << i <<
" (" << (*station)[0] <<
", "
62 << (*station)[1] <<
", " << (*station)[2] <<
")\n";
69 vtkInformationVector** inputVector,
70 vtkInformationVector* outputVector)
79 std::size_t nStations =
_stations->size();
85 bool useStationValues(
false);
88 for (std::size_t i = 1; i < nStations; i++)
93 useStationValues =
true;
100 vtkSmartPointer<vtkInformation> outInfo =
101 outputVector->GetInformationObject(0);
102 vtkSmartPointer<vtkPolyData> output =
103 vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
105 vtkSmartPointer<vtkPoints> newStations = vtkSmartPointer<vtkPoints>::New();
106 vtkSmartPointer<vtkCellArray> newVerts =
107 vtkSmartPointer<vtkCellArray>::New();
108 newVerts->Allocate(nStations);
110 vtkSmartPointer<vtkCellArray> newLines;
114 newLines = vtkSmartPointer<vtkCellArray>::New();
117 if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) >
123 vtkSmartPointer<vtkIntArray> station_ids =
124 vtkSmartPointer<vtkIntArray>::New();
125 station_ids->SetNumberOfComponents(1);
126 station_ids->SetName(
"SiteIDs");
128 vtkSmartPointer<vtkDoubleArray> station_values =
129 vtkSmartPointer<vtkDoubleArray>::New();
130 station_values->SetNumberOfComponents(1);
131 station_values->SetName(
"StationValue");
133 vtkSmartPointer<vtkIntArray> strat_ids =
134 vtkSmartPointer<vtkIntArray>::New();
135 strat_ids->SetNumberOfComponents(1);
136 strat_ids->SetName(
"Stratigraphies");
138 std::size_t lastMaxIndex(0);
139 std::size_t site_count(0);
144 vtkIdType sid = newStations->InsertNextPoint(station->data());
145 station_ids->InsertNextValue(site_count);
146 if (useStationValues)
148 station_values->InsertNextValue(
154 newVerts->InsertNextCell(1, &sid);
158 std::vector<GeoLib::Point*> profile =
160 std::vector<std::string> soilNames =
162 const std::size_t nLayers = profile.size();
164 for (std::size_t i = 1; i < nLayers; i++)
166 newStations->InsertNextPoint(profile[i]->data());
167 station_ids->InsertNextValue(site_count);
168 newLines->InsertNextCell(2);
169 newLines->InsertCellPoint(
171 newLines->InsertCellPoint(
174 if (useStationValues)
176 station_values->InsertNextValue(
186 output->SetPoints(newStations);
190 output->SetVerts(newVerts);
191 output->GetCellData()->AddArray(station_ids);
192 output->GetCellData()->SetActiveAttribute(
193 "SiteIDs", vtkDataSetAttributes::SCALARS);
197 output->SetLines(newLines);
199 output->GetCellData()->AddArray(strat_ids);
200 output->GetCellData()->SetActiveAttribute(
201 "Stratigraphies", vtkDataSetAttributes::SCALARS);
203 if (useStationValues)
205 output->GetPointData()->AddArray(station_values);
214 vtkInformationVector** ,
215 vtkInformationVector* )
228 vtkIdType max_key(0);
231 if (name == it.first)
235 if (it.second > max_key)
241 vtkIdType new_index = (
_id_map.empty()) ? 0 : (max_key + 1);
242 INFO(
"Key '{:s}' has been assigned index {:d}.", name, new_index);
243 _id_map.insert(std::pair<std::string, vtkIdType>(name, new_index));
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the StationBorehole class.
vtkStandardNewMacro(VtkStationSource)
Definition of the VtkStationSource class.
A borehole as a geometric object.
A Station (observation site) is basically a Point with some additional information.
double getStationValue() const
Returns the specific value for this station.
vtkProperty * GetProperties() const
Returns the vtk properties.
VTK source object for the visualisation of station data (including boreholes)
std::size_t GetIndexByName(std::string const &name)
void SetUserProperty(QString name, QVariant value) override
Sets a user property. This should be implemented by subclasses.
std::map< std::string, vtkIdType > _id_map
const std::vector< GeoLib::Point * > * _stations
The stations to visualize.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Computes the polygonal data object.
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
void PrintSelf(ostream &os, vtkIndent indent) override
Prints its data on a stream.
std::array< unsigned char, 4 > Color
Color getRandomColor()
Returns a random RGB colour.