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