OGS
VtkCompositeImageToPointCloudFilter.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
5
6#include <vtkPointData.h>
7#include <vtkSmartPointer.h>
8
9#include <QMap>
10#include <QString>
11#include <QVariant>
12
14
16 vtkAlgorithm* inputAlgorithm)
17 : VtkCompositeFilter(inputAlgorithm)
18{
19 init();
20}
21
23{
24 _inputDataObjectType = VTK_IMAGE_DATA;
25 _outputDataObjectType = VTK_POLY_DATA;
26
27 VtkImageDataToPointCloudFilter* point_cloud_filter =
29 point_cloud_filter->SetInputConnection(_inputAlgorithm->GetOutputPort());
30 _inputAlgorithm->Update();
31
32 QList<QVariant> n_points_range_list;
33 n_points_range_list.push_back(
34 point_cloud_filter->GetMinNumberOfPointsPerCell());
35 n_points_range_list.push_back(
36 point_cloud_filter->GetMaxNumberOfPointsPerCell());
37 (*_algorithmUserVectorProperties)["Number of points range"] =
38 n_points_range_list;
39 QList<QVariant> vertical_extent_list;
40 vertical_extent_list.push_back(point_cloud_filter->GetMinHeight());
41 vertical_extent_list.push_back(point_cloud_filter->GetMaxHeight());
42 (*_algorithmUserVectorProperties)["Vertical extent"] = vertical_extent_list;
43 (*_algorithmUserProperties)["Logarithmic interpolation"] =
44 !point_cloud_filter->GetIsLinear();
45 (*_algorithmUserProperties)["Gamma value"] = point_cloud_filter->GetGamma();
46
47 point_cloud_filter->Update();
48 _outputAlgorithm = point_cloud_filter;
49}
50
52 QVariant value)
53{
55
56 if ((name == "Gamma value") && (value.toDouble() > 0))
57 {
59 ->SetGamma(value.toDouble());
60 }
61 if (name == "Logarithmic interpolation")
62 {
63 if (value.toBool())
64 {
65 double const gamma =
67 .toDouble();
68 if (gamma > 0)
69 {
71 ->useLogarithmicInterpolation(gamma);
72 }
73 }
74 else
75 {
77 ->useLinearInterpolation();
78 }
79 }
80}
81
83 QString name, QList<QVariant> values)
84{
86
87 if (name == "Number of points range")
88 {
89 if (values[0].toInt() >= 0 && values[1].toInt() >= 0 &&
90 values[0].toInt() <= values[1].toInt())
91 {
93 ->SetMinNumberOfPointsPerCell(values[0].toInt());
95 ->SetMaxNumberOfPointsPerCell(values[1].toInt());
96 }
97 }
98 else if (name == "Vertical extent")
99 {
100 if (values[0].toDouble() <= values[1].toDouble())
101 {
103 ->SetMinHeight(values[0].toDouble());
105 ->SetMaxHeight(values[1].toDouble());
106 }
107 }
108}
virtual void SetUserVectorProperty(QString name, QList< QVariant > values)
Sets a vector user property. This should be implemented by subclasses.
QVariant GetUserProperty(QString name) const
Returns the value of a user property.
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.
vtkAlgorithm * _outputAlgorithm
VtkCompositeFilter(vtkAlgorithm *inputAlgorithm)
Constructor.
vtkAlgorithm * _inputAlgorithm
VtkCompositeImageToPointCloudFilter(vtkAlgorithm *inputAlgorithm)
void SetUserVectorProperty(QString name, QList< QVariant > values) override
Sets a vector user property. This should be implemented by subclasses.
void SetUserProperty(QString name, QVariant value) override
Sets a user property. This should be implemented by subclasses.
static VtkImageDataToPointCloudFilter * New()
Create a new objects (required because of VTKs reference counting)