OGS
VtkCompositeLineToTubeFilter.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 <vtkCleanPolyData.h>
8#include <vtkSmartPointer.h>
9#include <vtkTubeFilter.h>
10
12 vtkAlgorithm* inputAlgorithm)
13 : VtkCompositeFilter(inputAlgorithm)
14{
15 this->init();
16}
17
19
21{
22 this->_inputDataObjectType = VTK_DATA_SET;
23 this->_outputDataObjectType = VTK_POLY_DATA;
24
25 // collapse coincident points
26 vtkSmartPointer<vtkCleanPolyData> mergePoints =
27 vtkSmartPointer<vtkCleanPolyData>::New();
28 mergePoints->SetInputConnection(0, _inputAlgorithm->GetOutputPort(0));
29 mergePoints->SetTolerance(0.0);
30 mergePoints->ConvertLinesToPointsOn();
31
32 double default_radius(GetInitialRadius());
33 int default_number_of_sides(8);
34 vtkTubeFilter* tubes = vtkTubeFilter::New();
35 tubes->SetInputConnection(0, mergePoints->GetOutputPort(0));
36
37 // tubes->SetInputArrayToProcess(1,0,0,vtkDataObject::FIELD_ASSOCIATION_CELLS,"StationValue");
38 // tubes->SetVaryRadiusToVaryRadiusByScalar(); // KR radius changes with
39 // scalar
40
41 tubes->SetInputArrayToProcess(
42 1, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "Stratigraphies");
43 tubes->SetRadius(default_radius);
44 tubes->SetNumberOfSides(default_number_of_sides);
45 tubes->SetCapping(1);
46
47 (*_algorithmUserProperties)["Radius"] = default_radius;
48 (*_algorithmUserProperties)["NumberOfSides"] = default_number_of_sides;
49 (*_algorithmUserProperties)["Capping"] = true;
50
51 _outputAlgorithm = tubes;
52}
53
54void VtkCompositeLineToTubeFilter::SetUserProperty(QString name, QVariant value)
55{
57
58 if (name.compare("Radius") == 0)
59 {
60 static_cast<vtkTubeFilter*>(_outputAlgorithm)
61 ->SetRadius(value.toDouble());
62 }
63 else if (name.compare("NumberOfSides") == 0)
64 {
65 static_cast<vtkTubeFilter*>(_outputAlgorithm)
66 ->SetNumberOfSides(value.toInt());
67 }
68 else if (name.compare("Capping") == 0)
69 {
70 static_cast<vtkTubeFilter*>(_outputAlgorithm)
71 ->SetCapping(value.toBool());
72 }
73}
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.
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
void SetUserProperty(QString name, QVariant value) override
Sets a user property. This should be implemented by subclasses.
VtkCompositeLineToTubeFilter(vtkAlgorithm *inputAlgorithm)
~VtkCompositeLineToTubeFilter() override