OGS
VtkCompositePointToGlyphFilter.cpp
Go to the documentation of this file.
1
15// ** INCLUDES **
17
18#include <vtkDataSetAlgorithm.h>
19#include <vtkGlyph3D.h>
20#include <vtkPointData.h>
21#include <vtkSphereSource.h>
22
24 vtkAlgorithm* inputAlgorithm)
25 : VtkCompositeFilter(inputAlgorithm), _glyphSource(nullptr)
26{
27 this->init();
28}
29
34
36{
37 this->_inputDataObjectType = VTK_DATA_SET;
38 this->_outputDataObjectType = VTK_POLY_DATA;
39
40 std::size_t nPoints = static_cast<vtkDataSetAlgorithm*>(_inputAlgorithm)
41 ->GetOutput()
42 ->GetPointData()
43 ->GetNumberOfTuples();
44 int phi(10 - static_cast<std::size_t>(nPoints / 2000.0));
45 int theta(phi);
46 if (phi < 4)
47 {
48 phi = 4;
49 theta =
50 4; // for theta 3 would be possible, too, but 4 looks much better
51 }
52
53 double default_radius(GetInitialRadius());
54 _glyphSource = vtkSphereSource::New();
55 _glyphSource->SetRadius(default_radius);
56 _glyphSource->SetPhiResolution(phi);
57 _glyphSource->SetThetaResolution(theta);
58 (*_algorithmUserProperties)["Radius"] = default_radius;
59
60 (*_algorithmUserProperties)["PhiResolution"] = phi;
61 (*_algorithmUserProperties)["ThetaResolution"] = theta;
62
63 vtkGlyph3D* glyphFilter = vtkGlyph3D::New();
64 glyphFilter
65 ->ScalingOn(); // KR important to scale glyphs with double precision
66 // (e.g. 0.1 of their size for small datasets)
67 // glyphFilter->SetScaleModeToScaleByScalar(); // KR can easily obscure
68 // view when scalar values have large differences (this is also the default
69 // scaling method)
70 glyphFilter->SetScaleModeToDataScalingOff(); // KR scaling is possible but
71 // scalar values are ignored
72 glyphFilter->SetScaleFactor(1.0);
73 glyphFilter->SetSourceConnection(_glyphSource->GetOutputPort());
74 glyphFilter->SetInputConnection(_inputAlgorithm->GetOutputPort());
75 //(*_algorithmUserProperties)["ScaleMode"] = 0;
76 //(*_algorithmUserProperties)["ScaleFactor"] = 1.0;
77 //(*_algorithmUserProperties)["ColorMode"] = glyphFilter->GetColorMode();
78 //(*_algorithmUserProperties)["VectorMode"] = glyphFilter->GetVectorMode();
79 //(*_algorithmUserProperties)["Orient"] = glyphFilter->GetOrient();
80
81 _outputAlgorithm = glyphFilter;
82}
83
85 QVariant value)
86{
88
89 if (name.compare("Radius") == 0)
90 {
91 _glyphSource->SetRadius(value.toDouble());
92 }
93 else if (name.compare("PhiResolution") == 0)
94 {
95 _glyphSource->SetPhiResolution(value.toInt());
96 }
97 else if (name.compare("ThetaResolution") == 0)
98 {
99 _glyphSource->SetThetaResolution(value.toInt());
100 }
101 else if (name.compare("ScaleMode") == 0)
102 {
103 static_cast<vtkGlyph3D*>(_outputAlgorithm)->SetScaleMode(value.toInt());
104 }
105 else if (name.compare("ScaleFactor") == 0)
106 {
107 static_cast<vtkGlyph3D*>(_outputAlgorithm)
108 ->SetScaleFactor(value.toDouble());
109 }
110 else if (name.compare("ColorMode") == 0)
111 {
112 static_cast<vtkGlyph3D*>(_outputAlgorithm)->SetColorMode(value.toInt());
113 }
114 else if (name.compare("VectorMode") == 0)
115 {
116 static_cast<vtkGlyph3D*>(_outputAlgorithm)
117 ->SetVectorMode(value.toInt());
118 }
119 else if (name.compare("Orient") == 0)
120 {
121 static_cast<vtkGlyph3D*>(_outputAlgorithm)->SetOrient(value.toBool());
122 }
123}
Definition of the VtkCompositePointToGlyphFilter class.
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.
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 SetUserProperty(QString name, QVariant value) override
Sets a user property. This should be implemented by subclasses.
VtkCompositePointToGlyphFilter(vtkAlgorithm *inputAlgorithm)