OGS
VtkCompositeElementSelectionFilter Class Reference

Detailed Description

This filter selects/thresholds elements based on the selected array.

Definition at line 15 of file VtkCompositeElementSelectionFilter.h.

#include <VtkCompositeElementSelectionFilter.h>

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

Public Member Functions

 VtkCompositeElementSelectionFilter (vtkAlgorithm *inputAlgorithm)
 ~VtkCompositeElementSelectionFilter () override=default
void init () override
void setRange (double min_val, double max_val)
void setSelectionArray (const std::string &selection_name, const std::vector< double > &selection=std::vector< double >())
void SetUserVectorProperty (QString name, QList< QVariant > values) override
 Sets a vector 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.
virtual void SetUserProperty (QString name, QVariant value)
 Sets a user property. This should be implemented by subclasses.
QVariant GetUserProperty (QString name) const
 Returns the value of a user property.
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 Member Functions

VtkColorLookupTableGetLookupTable ()
 Returns a colour lookup table optimised for quality measures.

Private Attributes

std::pair< double, double > _range
std::string _selection_name
std::vector< double > _selection

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

◆ VtkCompositeElementSelectionFilter()

VtkCompositeElementSelectionFilter::VtkCompositeElementSelectionFilter ( vtkAlgorithm * inputAlgorithm)
explicit

Definition at line 20 of file VtkCompositeElementSelectionFilter.cpp.

22 : VtkCompositeFilter(inputAlgorithm),
23 _range(0.0, 1.0),
24 _selection_name("Selection")
25{
26}
VtkCompositeFilter(vtkAlgorithm *inputAlgorithm)
Constructor.

References VtkCompositeFilter::VtkCompositeFilter(), _range, and _selection_name.

◆ ~VtkCompositeElementSelectionFilter()

VtkCompositeElementSelectionFilter::~VtkCompositeElementSelectionFilter ( )
overridedefault

Member Function Documentation

◆ GetLookupTable()

VtkColorLookupTable * VtkCompositeElementSelectionFilter::GetLookupTable ( )
private

Returns a colour lookup table optimised for quality measures.

Definition at line 105 of file VtkCompositeElementSelectionFilter.cpp.

106{
107 VtkColorLookupTable* lut = VtkColorLookupTable::New();
108 lut->SetTableRange(0, 1);
109 DataHolderLib::Color a{{0, 0, 255, 255}}; // blue
110 DataHolderLib::Color b{{0, 255, 0, 255}}; // green
111 DataHolderLib::Color c{{255, 255, 0, 255}}; // yellow
112 DataHolderLib::Color d{{255, 0, 0, 255}}; // red
113 lut->setColor(1.0, a);
114 lut->setColor(0.5, b);
115 lut->setColor(0.25, c);
116 lut->setColor(0.1, d);
117 lut->Build();
118 return lut;
119}
void setColor(double pos, DataHolderLib::Color const &color)
void Build() override
Builds the colour table based on the previously set parameters. This method should only be called aft...
static VtkColorLookupTable * New()
Create new objects with New() because of VTKs object reference counting.
std::array< unsigned char, 4 > Color
Definition Color.h:12

References VtkColorLookupTable::Build(), VtkColorLookupTable::New(), and VtkColorLookupTable::setColor().

Referenced by init().

◆ init()

void VtkCompositeElementSelectionFilter::init ( )
overridevirtual

Implements VtkCompositeFilter.

Definition at line 28 of file VtkCompositeElementSelectionFilter.cpp.

29{
30 double thresholdLower(_range.first);
31 double thresholdUpper(_range.second);
32 this->_inputDataObjectType = VTK_UNSTRUCTURED_GRID;
33 this->_outputDataObjectType = VTK_UNSTRUCTURED_GRID;
34
35 this->SetLookUpTable(QString::fromStdString(_selection_name),
36 this->GetLookupTable());
37 vtkSmartPointer<VtkAppendArrayFilter> selFilter(nullptr);
38 if (!_selection.empty())
39 {
40 selFilter = vtkSmartPointer<VtkAppendArrayFilter>::New();
41 selFilter->SetInputConnection(_inputAlgorithm->GetOutputPort());
42 selFilter->SetArray(_selection_name, _selection);
43 selFilter->Update();
44 }
45
46 vtkSmartPointer<vtkIdFilter> idFilter = vtkSmartPointer<vtkIdFilter>::New();
47 if (_selection.empty())
48 { // if the array is empty it is assumed that an existing array should be
49 // used
50 idFilter->SetInputConnection(_inputAlgorithm->GetOutputPort());
51 }
52 else
53 {
54 idFilter->SetInputConnection(selFilter->GetOutputPort());
55 }
56 idFilter->PointIdsOn();
57 idFilter->CellIdsOn();
58 idFilter->FieldDataOn();
59 idFilter->Update();
60
61 vtkThreshold* threshold = vtkThreshold::New();
62 threshold->SetInputConnection(idFilter->GetOutputPort());
63 threshold->SetInputArrayToProcess(0, 0, 0,
64 vtkDataObject::FIELD_ASSOCIATION_CELLS,
65 _selection_name.c_str());
66 threshold->SetSelectedComponent(0);
67 threshold->SetThresholdFunction(
68 vtkThreshold::ThresholdType::THRESHOLD_BETWEEN);
69 threshold->SetLowerThreshold(thresholdLower);
70 threshold->SetUpperThreshold(thresholdUpper);
71 threshold->Update();
72
73 QList<QVariant> thresholdRangeList;
74 thresholdRangeList.push_back(thresholdLower);
75 thresholdRangeList.push_back(thresholdUpper);
76 (*_algorithmUserVectorProperties)["Threshold Between"] = thresholdRangeList;
77 _outputAlgorithm = threshold;
78}
void SetLookUpTable(const QString &array_name, vtkLookupTable *lut)
Sets a colour lookup table for the given scalar array of the VtkVisPipelineItem.
VtkColorLookupTable * GetLookupTable()
Returns a colour lookup table optimised for quality measures.
vtkAlgorithm * _outputAlgorithm
vtkAlgorithm * _inputAlgorithm

References VtkCompositeFilter::_inputAlgorithm, VtkCompositeFilter::_inputDataObjectType, VtkCompositeFilter::_outputAlgorithm, VtkCompositeFilter::_outputDataObjectType, _range, _selection, _selection_name, GetLookupTable(), and VtkAlgorithmProperties::SetLookUpTable().

Referenced by setSelectionArray().

◆ setRange()

void VtkCompositeElementSelectionFilter::setRange ( double min_val,
double max_val )
inline

Definition at line 24 of file VtkCompositeElementSelectionFilter.h.

24{ _range = std::make_pair(min_val, max_val); }

References _range.

◆ setSelectionArray()

void VtkCompositeElementSelectionFilter::setSelectionArray ( const std::string & selection_name,
const std::vector< double > & selection = std::vector<double>() )

Definition at line 80 of file VtkCompositeElementSelectionFilter.cpp.

82{
83 _selection_name = selection_name;
84 _selection = selection;
85 init();
86}

References _selection, _selection_name, and init().

◆ SetUserVectorProperty()

void VtkCompositeElementSelectionFilter::SetUserVectorProperty ( QString name,
QList< QVariant > values )
overridevirtual

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

Reimplemented from VtkAlgorithmProperties.

Definition at line 88 of file VtkCompositeElementSelectionFilter.cpp.

90{
92
93 if (name.compare("Threshold Between") == 0)
94 {
95 static_cast<vtkThreshold*>(_outputAlgorithm)
96 ->SetThresholdFunction(
97 vtkThreshold::ThresholdType::THRESHOLD_BETWEEN);
98 static_cast<vtkThreshold*>(_outputAlgorithm)
99 ->SetLowerThreshold(values[0].toDouble());
100 static_cast<vtkThreshold*>(_outputAlgorithm)
101 ->SetUpperThreshold(values[1].toDouble());
102 }
103}
virtual void SetUserVectorProperty(QString name, QList< QVariant > values)
Sets a vector user property. This should be implemented by subclasses.

References VtkCompositeFilter::_outputAlgorithm, and VtkAlgorithmProperties::SetUserVectorProperty().

Member Data Documentation

◆ _range

std::pair<double, double> VtkCompositeElementSelectionFilter::_range
private

◆ _selection

std::vector<double> VtkCompositeElementSelectionFilter::_selection
private

Definition at line 36 of file VtkCompositeElementSelectionFilter.h.

Referenced by init(), and setSelectionArray().

◆ _selection_name

std::string VtkCompositeElementSelectionFilter::_selection_name
private

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