OGS
VtkCompositePointToGlyphFilter Class Reference

Detailed Description

Converts point data to scalar-scaled spheres.

Definition at line 22 of file VtkCompositePointToGlyphFilter.h.

#include <VtkCompositePointToGlyphFilter.h>

Inheritance diagram for VtkCompositePointToGlyphFilter:
[legend]
Collaboration diagram for VtkCompositePointToGlyphFilter:
[legend]

Public Member Functions

 VtkCompositePointToGlyphFilter (vtkAlgorithm *inputAlgorithm)
 
 ~VtkCompositePointToGlyphFilter () override
 
void init () override
 
void SetUserProperty (QString name, QVariant value) override
 Sets a user property. This should be implemented by subclasses.
 
- Public Member Functions inherited from VtkCompositeFilter
 VtkCompositeFilter (vtkAlgorithm *inputAlgorithm)
 Constructor.
 
 ~VtkCompositeFilter () override
 Destructor.
 
int GetInputDataObjectType () const
 
int GetOutputDataObjectType () const
 
vtkAlgorithm * GetOutputAlgorithm () const
 
- Public Member Functions inherited from VtkAlgorithmProperties
 VtkAlgorithmProperties (QObject *parent=nullptr)
 Constructor (sets default values)
 
 ~VtkAlgorithmProperties () override
 
vtkProperty * GetProperties () const
 Returns the vtk properties.
 
vtkTexture * GetTexture ()
 Returns a texture (if one has been assigned).
 
void SetTexture (vtkTexture *t)
 Sets a texture for the VtkVisPipelineItem.
 
vtkLookupTable * GetLookupTable (const QString &array_name)
 Returns the colour lookup table (if one has been assigned).
 
void RemoveLookupTable (const QString &array_name)
 Removes the lookup table for the given scalar.
 
void SetLookUpTable (const QString &array_name, vtkLookupTable *lut)
 Sets a colour lookup table for the given scalar array of the VtkVisPipelineItem.
 
void SetLookUpTable (const QString &array_name, const QString &filename)
 Loads a predefined color lookup table from a file for the specified scalar array.
 
bool GetScalarVisibility () const
 Returns the scalar visibility.
 
void SetScalarVisibility (bool on)
 Sets the scalar visibility.
 
QString GetName () const
 Returns the name. This is set to the file path if it is a source algorithm.
 
void SetName (QString name)
 Sets the name.
 
bool IsRemovable () const
 Is this algorithm removable from the pipeline (view).
 
QMap< QString, QVariant > * GetAlgorithmUserProperties () const
 Returns a map of user properties.
 
QMap< QString, QList< QVariant > > * GetAlgorithmUserVectorProperties () const
 Returns a map of vector user properties.
 
QVariant GetUserProperty (QString name) const
 Returns the value of a user property.
 
virtual void SetUserVectorProperty (QString name, QList< QVariant > values)
 Sets a vector user property. This should be implemented by subclasses.
 
QList< QVariant > GetUserVectorProperty (QString name) const
 Returns a list of values of a vector user property.
 
void SetActiveAttribute (QString name)
 Set the active attribute.
 
QString GetActiveAttribute () const
 Returns the desired active attribute.
 

Private Attributes

vtkSphereSource * _glyphSource
 

Additional Inherited Members

- Signals inherited from VtkAlgorithmProperties
void ScalarVisibilityChanged (bool on)
 
- Protected Member Functions inherited from VtkCompositeFilter
double GetInitialRadius () const
 Calculates a 1/200th of the largest extension of the bounding box (this is used as default radius for various filters)
 
- Protected Attributes inherited from VtkCompositeFilter
int _inputDataObjectType
 
int _outputDataObjectType
 
vtkAlgorithm * _inputAlgorithm
 
vtkAlgorithm * _outputAlgorithm
 
- Protected Attributes inherited from VtkAlgorithmProperties
vtkProperty * _property
 
vtkTexture * _texture
 
bool _scalarVisibility
 
std::map< QString, vtkLookupTable * > _lut
 
QString _name
 
QString _activeAttributeName
 
bool _removable
 
QMap< QString, QVariant > * _algorithmUserProperties
 
QMap< QString, QList< QVariant > > * _algorithmUserVectorProperties
 

Constructor & Destructor Documentation

◆ VtkCompositePointToGlyphFilter()

VtkCompositePointToGlyphFilter::VtkCompositePointToGlyphFilter ( vtkAlgorithm * inputAlgorithm)
explicit

Definition at line 23 of file VtkCompositePointToGlyphFilter.cpp.

25 : VtkCompositeFilter(inputAlgorithm), _glyphSource(nullptr)
26{
27 this->init();
28}
VtkCompositeFilter(vtkAlgorithm *inputAlgorithm)
Constructor.

References init().

◆ ~VtkCompositePointToGlyphFilter()

VtkCompositePointToGlyphFilter::~VtkCompositePointToGlyphFilter ( )
override

Definition at line 30 of file VtkCompositePointToGlyphFilter.cpp.

31{
32 _glyphSource->Delete();
33}

References _glyphSource.

Member Function Documentation

◆ init()

void VtkCompositePointToGlyphFilter::init ( )
overridevirtual

Implements VtkCompositeFilter.

Definition at line 35 of file VtkCompositePointToGlyphFilter.cpp.

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}
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

References _glyphSource, VtkCompositeFilter::_inputAlgorithm, VtkCompositeFilter::_inputDataObjectType, VtkCompositeFilter::_outputAlgorithm, VtkCompositeFilter::_outputDataObjectType, and VtkCompositeFilter::GetInitialRadius().

Referenced by VtkCompositePointToGlyphFilter().

◆ SetUserProperty()

void VtkCompositePointToGlyphFilter::SetUserProperty ( QString name,
QVariant value )
overridevirtual

Sets a user property. This should be implemented by subclasses.

Reimplemented from VtkAlgorithmProperties.

Definition at line 84 of file VtkCompositePointToGlyphFilter.cpp.

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}
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.

References _glyphSource, VtkCompositeFilter::_outputAlgorithm, and VtkAlgorithmProperties::SetUserProperty().

Member Data Documentation

◆ _glyphSource

vtkSphereSource* VtkCompositePointToGlyphFilter::_glyphSource
private

The documentation for this class was generated from the following files: