OGS
VtkCompositeGeoObjectFilter.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4// ** INCLUDES **
6
7#include <vtkAlgorithmOutput.h>
8#include <vtkDataSetSurfaceFilter.h>
9#include <vtkPointData.h>
10#include <vtkSmartPointer.h>
11#include <vtkThreshold.h>
12
15#include "VtkPolylinesSource.h"
16#include "VtkStationSource.h"
17#include "VtkSurfacesSource.h"
18
20 vtkAlgorithm* inputAlgorithm)
21 : VtkCompositeFilter(inputAlgorithm),
22 _type(GeoLib::GEOTYPE::POINT),
23 _threshold(vtkThreshold::New())
24{
25 if (inputAlgorithm->GetNumberOfInputPorts() &&
26 inputAlgorithm->GetNumberOfInputConnections(0))
27 {
28 vtkAlgorithmOutput* ao = inputAlgorithm->GetInputConnection(0, 0);
29
30 if (ao)
31 {
32 vtkAlgorithm* parentAlg = ao->GetProducer();
33
34 if (dynamic_cast<VtkPolylinesSource*>(parentAlg) != nullptr)
35 {
36 _type = GeoLib::GEOTYPE::POLYLINE;
37 }
38 else if (dynamic_cast<VtkSurfacesSource*>(parentAlg) != nullptr)
39 {
40 _type = GeoLib::GEOTYPE::SURFACE;
41 }
42 else if (dynamic_cast<VtkStationSource*>(parentAlg) != nullptr)
43 {
44 /* TODO
45 if (dynamic_cast<VtkStationSource*>(parentAlg)->getType() ==
46 GeoLib::Station::StationType::BOREHOLE) _type =
47 GeoLib::GEOTYPE::POLYLINE;
48 */
49 }
50 }
51 this->init();
52 }
53}
54
56
58{
59 this->_inputDataObjectType = VTK_POLY_DATA;
60 this->_outputDataObjectType = VTK_POLY_DATA;
61
62 _threshold->SetInputConnection(_inputAlgorithm->GetOutputPort());
63 _threshold->SetSelectedComponent(0);
64 _threshold->SetThresholdFunction(
65 vtkThreshold::ThresholdType::THRESHOLD_BETWEEN);
66 _threshold->SetLowerThreshold(0);
67 _threshold->SetUpperThreshold(0);
68
69 vtkDataSetSurfaceFilter* surface = vtkDataSetSurfaceFilter::New();
70 surface->SetInputConnection(_threshold->GetOutputPort());
71
72 VtkCompositeFilter* composite;
74 {
75 composite = new VtkCompositePointToGlyphFilter(surface);
76 composite->SetUserProperty("Radius", this->GetInitialRadius());
78 }
80 {
81 composite = new VtkCompositeLineToTubeFilter(surface);
82 composite->SetUserProperty("Radius", this->GetInitialRadius());
84 }
85 else
86 {
87 _outputAlgorithm = surface;
88 }
89}
90
92{
93 double const d_idx = static_cast<double>(idx);
94 _threshold->SetThresholdFunction(
95 vtkThreshold::ThresholdType::THRESHOLD_BETWEEN);
96 _threshold->SetLowerThreshold(d_idx);
97 _threshold->SetUpperThreshold(d_idx);
98}
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.
vtkAlgorithm * GetOutputAlgorithm() const
vtkAlgorithm * _outputAlgorithm
VtkCompositeFilter(vtkAlgorithm *inputAlgorithm)
Constructor.
double GetInitialRadius() const
Calculates a 1/200th of the largest extension of the bounding box (this is used as default radius for...
vtkAlgorithm * _inputAlgorithm
VtkCompositeGeoObjectFilter(vtkAlgorithm *inputAlgorithm)
~VtkCompositeGeoObjectFilter() override
Converts lines to tube-objects.
Converts point data to scalar-scaled spheres.