OGS
VtkCompositeElementSelectionFilter Class Reference

Detailed Description

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

Definition at line 26 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 31 of file VtkCompositeElementSelectionFilter.cpp.

33 : VtkCompositeFilter(inputAlgorithm),
34 _range(0.0, 1.0),
35 _selection_name("Selection")
36{
37}
VtkCompositeFilter(vtkAlgorithm *inputAlgorithm)
Constructor.

◆ ~VtkCompositeElementSelectionFilter()

VtkCompositeElementSelectionFilter::~VtkCompositeElementSelectionFilter ( )
overridedefault

Member Function Documentation

◆ GetLookupTable()

VtkColorLookupTable * VtkCompositeElementSelectionFilter::GetLookupTable ( )
private

Returns a colour lookup table optimised for quality measures.

Definition at line 116 of file VtkCompositeElementSelectionFilter.cpp.

117{
119 lut->SetTableRange(0, 1);
120 DataHolderLib::Color a{{0, 0, 255, 255}}; // blue
121 DataHolderLib::Color b{{0, 255, 0, 255}}; // green
122 DataHolderLib::Color c{{255, 255, 0, 255}}; // yellow
123 DataHolderLib::Color d{{255, 0, 0, 255}}; // red
124 lut->setColor(1.0, a);
125 lut->setColor(0.5, b);
126 lut->setColor(0.25, c);
127 lut->setColor(0.1, d);
128 lut->Build();
129 return lut;
130}
Calculates and stores a colour lookup table.
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:24

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

Referenced by init().

◆ init()

void VtkCompositeElementSelectionFilter::init ( )
overridevirtual

Implements VtkCompositeFilter.

Definition at line 39 of file VtkCompositeElementSelectionFilter.cpp.

40{
41 double thresholdLower(_range.first);
42 double thresholdUpper(_range.second);
43 this->_inputDataObjectType = VTK_UNSTRUCTURED_GRID;
44 this->_outputDataObjectType = VTK_UNSTRUCTURED_GRID;
45
46 this->SetLookUpTable(QString::fromStdString(_selection_name),
47 this->GetLookupTable());
48 vtkSmartPointer<VtkAppendArrayFilter> selFilter(nullptr);
49 if (!_selection.empty())
50 {
51 selFilter = vtkSmartPointer<VtkAppendArrayFilter>::New();
52 selFilter->SetInputConnection(_inputAlgorithm->GetOutputPort());
53 selFilter->SetArray(_selection_name, _selection);
54 selFilter->Update();
55 }
56
57 vtkSmartPointer<vtkIdFilter> idFilter = vtkSmartPointer<vtkIdFilter>::New();
58 if (_selection.empty())
59 { // if the array is empty it is assumed that an existing array should be
60 // used
61 idFilter->SetInputConnection(_inputAlgorithm->GetOutputPort());
62 }
63 else
64 {
65 idFilter->SetInputConnection(selFilter->GetOutputPort());
66 }
67 idFilter->PointIdsOn();
68 idFilter->CellIdsOn();
69 idFilter->FieldDataOn();
70 idFilter->Update();
71
72 vtkThreshold* threshold = vtkThreshold::New();
73 threshold->SetInputConnection(idFilter->GetOutputPort());
74 threshold->SetInputArrayToProcess(0, 0, 0,
75 vtkDataObject::FIELD_ASSOCIATION_CELLS,
76 _selection_name.c_str());
77 threshold->SetSelectedComponent(0);
78 threshold->SetThresholdFunction(
79 vtkThreshold::ThresholdType::THRESHOLD_BETWEEN);
80 threshold->SetLowerThreshold(thresholdLower);
81 threshold->SetUpperThreshold(thresholdUpper);
82 threshold->Update();
83
84 QList<QVariant> thresholdRangeList;
85 thresholdRangeList.push_back(thresholdLower);
86 thresholdRangeList.push_back(thresholdUpper);
87 (*_algorithmUserVectorProperties)["Threshold Between"] = thresholdRangeList;
88 _outputAlgorithm = threshold;
89}
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 35 of file VtkCompositeElementSelectionFilter.h.

35{ _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 91 of file VtkCompositeElementSelectionFilter.cpp.

93{
94 _selection_name = selection_name;
95 _selection = selection;
96 init();
97}

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 99 of file VtkCompositeElementSelectionFilter.cpp.

101{
103
104 if (name.compare("Threshold Between") == 0)
105 {
106 static_cast<vtkThreshold*>(_outputAlgorithm)
107 ->SetThresholdFunction(
108 vtkThreshold::ThresholdType::THRESHOLD_BETWEEN);
109 static_cast<vtkThreshold*>(_outputAlgorithm)
110 ->SetLowerThreshold(values[0].toDouble());
111 static_cast<vtkThreshold*>(_outputAlgorithm)
112 ->SetUpperThreshold(values[1].toDouble());
113 }
114}
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

Definition at line 45 of file VtkCompositeElementSelectionFilter.h.

Referenced by init(), and setRange().

◆ _selection

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

Definition at line 47 of file VtkCompositeElementSelectionFilter.h.

Referenced by init(), and setSelectionArray().

◆ _selection_name

std::string VtkCompositeElementSelectionFilter::_selection_name
private

Definition at line 46 of file VtkCompositeElementSelectionFilter.h.

Referenced by init(), and setSelectionArray().


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