OGS
VtkCompositeNodeSelectionFilter.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 <vtkDataSetAlgorithm.h>
7#include <vtkGlyph3D.h>
8#include <vtkSmartPointer.h>
9#include <vtkSphereSource.h>
10
11#include <memory>
12
13#include "VtkPointsSource.h"
14
16 vtkAlgorithm* inputAlgorithm)
17 : VtkCompositeFilter(inputAlgorithm)
18{
19 // this->init();
20}
21
23{
24 for (auto& item : _selection)
25 {
26 delete item;
27 }
28}
29
31{
32 this->_inputDataObjectType = VTK_DATA_SET;
33 this->_outputDataObjectType = VTK_POLY_DATA;
34
35 if (!_selection.empty())
36 {
37 vtkSmartPointer<VtkPointsSource> point_source =
38 vtkSmartPointer<VtkPointsSource>::New();
39 point_source->setPoints(&_selection);
40
41 vtkSmartPointer<vtkSphereSource> _glyphSource =
42 vtkSmartPointer<vtkSphereSource>::New();
43 _glyphSource->SetRadius(this->GetInitialRadius());
44
45 vtkGlyph3D* glyphFilter = vtkGlyph3D::New();
46 glyphFilter->SetSourceConnection(_glyphSource->GetOutputPort());
47 glyphFilter->SetInputConnection(point_source->GetOutputPort());
48
49 _outputAlgorithm = glyphFilter;
50 }
51 else
52 {
53 _outputAlgorithm = nullptr;
54 }
55}
56
58 const std::vector<unsigned>& point_indeces)
59{
60 for (unsigned int point_index : point_indeces)
61 {
62 double* coords = static_cast<vtkDataSetAlgorithm*>(_inputAlgorithm)
63 ->GetOutput()
64 ->GetPoint(point_index);
65 auto* p(new GeoLib::Point(coords[0], coords[1], coords[2]));
66 _selection.push_back(p);
67 }
68 init();
69}
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 setSelectionArray(const std::vector< unsigned > &point_indeces)
Sets the point indices to be highlighted.
VtkCompositeNodeSelectionFilter(vtkAlgorithm *inputAlgorithm)