OGS
VtkCompositeNodeSelectionFilter.cpp
Go to the documentation of this file.
1
16
17#include <vtkDataSetAlgorithm.h>
18#include <vtkGlyph3D.h>
19#include <vtkSmartPointer.h>
20#include <vtkSphereSource.h>
21
22#include <memory>
23
24#include "VtkPointsSource.h"
25
27 vtkAlgorithm* inputAlgorithm)
28 : VtkCompositeFilter(inputAlgorithm)
29{
30 // this->init();
31}
32
34{
35 for (auto& item : _selection)
36 {
37 delete item;
38 }
39}
40
42{
43 this->_inputDataObjectType = VTK_DATA_SET;
44 this->_outputDataObjectType = VTK_POLY_DATA;
45
46 if (!_selection.empty())
47 {
48 vtkSmartPointer<VtkPointsSource> point_source =
49 vtkSmartPointer<VtkPointsSource>::New();
50 point_source->setPoints(&_selection);
51
52 vtkSmartPointer<vtkSphereSource> _glyphSource =
53 vtkSmartPointer<vtkSphereSource>::New();
54 _glyphSource->SetRadius(this->GetInitialRadius());
55
56 vtkGlyph3D* glyphFilter = vtkGlyph3D::New();
57 glyphFilter->SetSourceConnection(_glyphSource->GetOutputPort());
58 glyphFilter->SetInputConnection(point_source->GetOutputPort());
59
60 _outputAlgorithm = glyphFilter;
61 }
62 else
63 {
64 _outputAlgorithm = nullptr;
65 }
66}
67
69 const std::vector<unsigned>& point_indeces)
70{
71 for (unsigned int point_index : point_indeces)
72 {
73 double* coords = static_cast<vtkDataSetAlgorithm*>(_inputAlgorithm)
74 ->GetOutput()
75 ->GetPoint(point_index);
76 auto* p(new GeoLib::Point(coords[0], coords[1], coords[2]));
77 _selection.push_back(p);
78 }
79 init();
80}
Definition of the VtkCompositeNodeSelectionFilter class.
Definition of the VtkPointsSource class.
Is used to combine several filter in one VtkVisPipelineItem. You can use vtk filter and custom filter...
vtkAlgorithm * _outputAlgorithm
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)