OGS
VtkStationSource Class Reference

Detailed Description

VTK source object for the visualisation of station data (including boreholes)

Definition at line 16 of file VtkStationSource.h.

#include <VtkStationSource.h>

Inheritance diagram for VtkStationSource:
[legend]
Collaboration diagram for VtkStationSource:
[legend]

Public Member Functions

 vtkTypeMacro (VtkStationSource, vtkPolyDataAlgorithm)
const std::map< std::string, DataHolderLib::Color > & getColorLookupTable () const
void setStations (const std::vector< GeoLib::Point * > *stations)
 Sets a predefined color lookup table for the colouring of borehole stratigraphies.
void PrintSelf (ostream &os, vtkIndent indent) override
 Prints its data on a stream.
void SetUserProperty (QString name, QVariant value) override
 Sets a user property. This should be implemented by subclasses.
Public Member Functions inherited from VtkAlgorithmProperties
 VtkAlgorithmProperties (QObject *parent=nullptr)
 Constructor (sets default values)
 ~VtkAlgorithmProperties () override
vtkProperty * GetProperties () const
 Returns the vtk properties.
vtkTexture * GetTexture ()
 Returns a texture (if one has been assigned).
void SetTexture (vtkTexture *t)
 Sets a texture for the VtkVisPipelineItem.
vtkLookupTable * GetLookupTable (const QString &array_name)
 Returns the colour lookup table (if one has been assigned).
void RemoveLookupTable (const QString &array_name)
 Removes the lookup table for the given scalar.
void SetLookUpTable (const QString &array_name, vtkLookupTable *lut)
 Sets a colour lookup table for the given scalar array of the VtkVisPipelineItem.
void SetLookUpTable (const QString &array_name, const QString &filename)
 Loads a predefined color lookup table from a file for the specified scalar array.
bool GetScalarVisibility () const
 Returns the scalar visibility.
void SetScalarVisibility (bool on)
 Sets the scalar visibility.
QString GetName () const
 Returns the name. This is set to the file path if it is a source algorithm.
void SetName (QString name)
 Sets the name.
bool IsRemovable () const
 Is this algorithm removable from the pipeline (view).
QMap< QString, QVariant > * GetAlgorithmUserProperties () const
 Returns a map of user properties.
QMap< QString, QList< QVariant > > * GetAlgorithmUserVectorProperties () const
 Returns a map of vector user properties.
QVariant GetUserProperty (QString name) const
 Returns the value of a user property.
virtual void SetUserVectorProperty (QString name, QList< QVariant > values)
 Sets a vector user property. This should be implemented by subclasses.
QList< QVariant > GetUserVectorProperty (QString name) const
 Returns a list of values of a vector user property.
void SetActiveAttribute (QString name)
 Set the active attribute.
QString GetActiveAttribute () const
 Returns the desired active attribute.

Static Public Member Functions

static VtkStationSourceNew ()
 Create new objects with New() because of VTKs object reference counting.

Protected Member Functions

 VtkStationSource ()
int RequestData (vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
 Computes the polygonal data object.
int RequestInformation (vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override

Protected Attributes

const std::vector< GeoLib::Point * > * _stations {nullptr}
 The stations to visualize.
std::map< std::string, DataHolderLib::Color_colorLookupTable
Protected Attributes inherited from VtkAlgorithmProperties
vtkProperty * _property
vtkTexture * _texture
bool _scalarVisibility
std::map< QString, vtkLookupTable * > _lut
QString _name
QString _activeAttributeName
bool _removable
QMap< QString, QVariant > * _algorithmUserProperties
QMap< QString, QList< QVariant > > * _algorithmUserVectorProperties

Private Member Functions

std::size_t GetIndexByName (std::string const &name)

Private Attributes

std::map< std::string, vtkIdType > _id_map

Additional Inherited Members

Signals inherited from VtkAlgorithmProperties
void ScalarVisibilityChanged (bool on)

Constructor & Destructor Documentation

◆ VtkStationSource()

VtkStationSource::VtkStationSource ( )
protected

Definition at line 26 of file VtkStationSource.cpp.

27{
28 _removable = false; // From VtkAlgorithmProperties
29 this->SetNumberOfInputPorts(0);
30
32 GetProperties()->SetColor(c[0] / 255.0, c[1] / 255.0, c[2] / 255.0);
33}
vtkProperty * GetProperties() const
Returns the vtk properties.
Color getRandomColor()
Returns a random RGB colour.
Definition Color.cpp:18
std::array< unsigned char, 4 > Color
Definition Color.h:12

References VtkAlgorithmProperties::_removable, VtkAlgorithmProperties::GetProperties(), and DataHolderLib::getRandomColor().

Referenced by New(), and vtkTypeMacro().

Member Function Documentation

◆ getColorLookupTable()

const std::map< std::string, DataHolderLib::Color > & VtkStationSource::getColorLookupTable ( ) const
inline

Returns the colour lookup table generated for boreholes. This method should only be called after the colour lookup table has actually been build (via RequestData() or setColorLookupTable()).

Definition at line 26 of file VtkStationSource.h.

27 { return _colorLookupTable; }
std::map< std::string, DataHolderLib::Color > _colorLookupTable

References _colorLookupTable.

Referenced by StationTreeView::displayStratigraphy(), and StationTreeView::writeStratigraphiesAsImages().

◆ GetIndexByName()

std::size_t VtkStationSource::GetIndexByName ( std::string const & name)
private

Definition at line 215 of file VtkStationSource.cpp.

216{
217 vtkIdType max_key(0);
218 for (auto& it : _id_map)
219 {
220 if (name == it.first)
221 {
222 return it.second;
223 }
224 if (it.second > max_key)
225 {
226 max_key = it.second;
227 }
228 }
229
230 vtkIdType new_index = (_id_map.empty()) ? 0 : (max_key + 1);
231 INFO("Key '{:s}' has been assigned index {:d}.", name, new_index);
232 _id_map.insert(std::pair<std::string, vtkIdType>(name, new_index));
233 return new_index;
234}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
std::map< std::string, vtkIdType > _id_map

References _id_map, and INFO().

Referenced by RequestData().

◆ New()

VtkStationSource * VtkStationSource::New ( )
static

Create new objects with New() because of VTKs object reference counting.

References VtkStationSource().

◆ PrintSelf()

void VtkStationSource::PrintSelf ( ostream & os,
vtkIndent indent )
override

Prints its data on a stream.

Definition at line 35 of file VtkStationSource.cpp.

36{
37 this->Superclass::PrintSelf(os, indent);
38
39 if (_stations->empty())
40 {
41 return;
42 }
43
44 os << indent << "== VtkStationSource =="
45 << "\n";
46
47 int i = 0;
48 for (auto station : *_stations)
49 {
50 os << indent << "Station " << i << " (" << (*station)[0] << ", "
51 << (*station)[1] << ", " << (*station)[2] << ")\n";
52 i++;
53 }
54}
const std::vector< GeoLib::Point * > * _stations
The stations to visualize.

References _stations.

◆ RequestData()

int VtkStationSource::RequestData ( vtkInformation * request,
vtkInformationVector ** inputVector,
vtkInformationVector * outputVector )
overrideprotected

Computes the polygonal data object.

Create 3d Station objects.

Definition at line 57 of file VtkStationSource.cpp.

60{
61 (void)request;
62 (void)inputVector;
63
64 if (!_stations)
65 {
66 return 0;
67 }
68 std::size_t nStations = _stations->size();
69 if (nStations == 0)
70 {
71 return 0;
72 }
73
74 bool useStationValues(false);
75 double sValue =
76 static_cast<GeoLib::Station*>((*_stations)[0])->getStationValue();
77 for (std::size_t i = 1; i < nStations; i++)
78 {
79 if (static_cast<GeoLib::Station*>((*_stations)[i])->getStationValue() !=
80 sValue)
81 {
82 useStationValues = true;
83 break;
84 }
85 }
86
87 bool isBorehole = dynamic_cast<GeoLib::StationBorehole*>((*_stations)[0]);
88
89 vtkSmartPointer<vtkInformation> outInfo =
90 outputVector->GetInformationObject(0);
91 vtkSmartPointer<vtkPolyData> output =
92 vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
93
94 vtkSmartPointer<vtkPoints> newStations = vtkSmartPointer<vtkPoints>::New();
95 vtkSmartPointer<vtkCellArray> newVerts =
96 vtkSmartPointer<vtkCellArray>::New();
97 newVerts->Allocate(nStations);
98
99 vtkSmartPointer<vtkCellArray> newLines;
100
101 if (isBorehole)
102 {
103 newLines = vtkSmartPointer<vtkCellArray>::New();
104 }
105
106 if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) >
107 0)
108 {
109 return 1;
110 }
111
112 vtkSmartPointer<vtkIntArray> station_ids =
113 vtkSmartPointer<vtkIntArray>::New();
114 station_ids->SetNumberOfComponents(1);
115 station_ids->SetName("SiteIDs");
116
117 vtkSmartPointer<vtkDoubleArray> station_values =
118 vtkSmartPointer<vtkDoubleArray>::New();
119 station_values->SetNumberOfComponents(1);
120 station_values->SetName("StationValue");
121
122 vtkSmartPointer<vtkIntArray> strat_ids =
123 vtkSmartPointer<vtkIntArray>::New();
124 strat_ids->SetNumberOfComponents(1);
125 strat_ids->SetName("Stratigraphies");
126
127 std::size_t lastMaxIndex(0);
128 std::size_t site_count(0);
129
130 // Generate graphic objects
131 for (auto station : *_stations)
132 {
133 vtkIdType sid = newStations->InsertNextPoint(station->data());
134 station_ids->InsertNextValue(site_count);
135 if (useStationValues)
136 {
137 station_values->InsertNextValue(
138 static_cast<GeoLib::Station*>(station)->getStationValue());
139 }
140
141 if (!isBorehole)
142 {
143 newVerts->InsertNextCell(1, &sid);
144 }
145 else
146 {
147 std::vector<GeoLib::Point*> profile =
148 static_cast<GeoLib::StationBorehole*>(station)->getProfile();
149 std::vector<std::string> soilNames =
150 static_cast<GeoLib::StationBorehole*>(station)->getSoilNames();
151 const std::size_t nLayers = profile.size();
152
153 for (std::size_t i = 1; i < nLayers; i++)
154 {
155 newStations->InsertNextPoint(profile[i]->data());
156 station_ids->InsertNextValue(site_count);
157 newLines->InsertNextCell(2);
158 newLines->InsertCellPoint(
159 lastMaxIndex); // start of borehole-layer
160 newLines->InsertCellPoint(
161 ++lastMaxIndex); // end of boreholelayer
162 strat_ids->InsertNextValue(this->GetIndexByName(soilNames[i]));
163 if (useStationValues)
164 {
165 station_values->InsertNextValue(
166 static_cast<GeoLib::Station*>(station)
167 ->getStationValue());
168 }
169 }
170 lastMaxIndex++;
171 }
172 site_count++;
173 }
174
175 output->SetPoints(newStations);
176
177 if (!isBorehole)
178 {
179 output->SetVerts(newVerts);
180 output->GetCellData()->AddArray(station_ids);
181 output->GetCellData()->SetActiveAttribute(
182 "SiteIDs", vtkDataSetAttributes::SCALARS);
183 }
184 else
185 {
186 output->SetLines(newLines);
187 // output->GetCellData()->AddArray(station_ids);
188 output->GetCellData()->AddArray(strat_ids);
189 output->GetCellData()->SetActiveAttribute(
190 "Stratigraphies", vtkDataSetAttributes::SCALARS);
191 }
192 if (useStationValues)
193 {
194 output->GetPointData()->AddArray(station_values);
195 }
196
197 output->Squeeze();
198
199 return 1;
200}
std::size_t GetIndexByName(std::string const &name)
bool isBorehole(GeoLib::Point const *pnt)

References _stations, and GetIndexByName().

◆ RequestInformation()

int VtkStationSource::RequestInformation ( vtkInformation * request,
vtkInformationVector ** inputVector,
vtkInformationVector * outputVector )
overrideprotected

Definition at line 202 of file VtkStationSource.cpp.

205{
206 return 1;
207}

◆ setStations()

void VtkStationSource::setStations ( const std::vector< GeoLib::Point * > * stations)
inline

Sets a predefined color lookup table for the colouring of borehole stratigraphies.

Sets the stations as a vector

Definition at line 34 of file VtkStationSource.h.

34{ _stations = stations; }

References _stations.

Referenced by BaseItem::BaseItem().

◆ SetUserProperty()

void VtkStationSource::SetUserProperty ( QString name,
QVariant value )
overridevirtual

Sets a user property. This should be implemented by subclasses.

Reimplemented from VtkAlgorithmProperties.

Definition at line 209 of file VtkStationSource.cpp.

210{
211 Q_UNUSED(name);
212 Q_UNUSED(value);
213}

◆ vtkTypeMacro()

VtkStationSource::vtkTypeMacro ( VtkStationSource ,
vtkPolyDataAlgorithm  )

References VtkStationSource().

Member Data Documentation

◆ _colorLookupTable

std::map<std::string, DataHolderLib::Color> VtkStationSource::_colorLookupTable
protected

The colour table for stratigraphic data. This table is either set using the setColorLookupTable() method or is generated automatically with random colours while creating the VtkStationSource-object.

Definition at line 58 of file VtkStationSource.h.

Referenced by getColorLookupTable().

◆ _id_map

std::map<std::string, vtkIdType> VtkStationSource::_id_map
private

Definition at line 63 of file VtkStationSource.h.

Referenced by GetIndexByName().

◆ _stations

const std::vector<GeoLib::Point*>* VtkStationSource::_stations {nullptr}
protected

The stations to visualize.

Definition at line 54 of file VtkStationSource.h.

54{nullptr};

Referenced by PrintSelf(), RequestData(), and setStations().


The documentation for this class was generated from the following files: