OGS
VtkCompositeThresholdFilter Class Reference

Detailed Description

Visualises only parts of meshes that are above/below/within given thresholds. In init() the threshold is first set to double min / max values. Set the threshold later on via SetUserVectorProperty() to the actual data range.

Definition at line 22 of file VtkCompositeThresholdFilter.h.

#include <VtkCompositeThresholdFilter.h>

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

Public Member Functions

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

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) More...
 
- 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

◆ VtkCompositeThresholdFilter()

VtkCompositeThresholdFilter::VtkCompositeThresholdFilter ( vtkAlgorithm *  inputAlgorithm)
explicit

Definition at line 24 of file VtkCompositeThresholdFilter.cpp.

26  : VtkCompositeFilter(inputAlgorithm)
27 {
28  this->init();
29 }
VtkCompositeFilter(vtkAlgorithm *inputAlgorithm)
Constructor.

References init().

◆ ~VtkCompositeThresholdFilter()

VtkCompositeThresholdFilter::~VtkCompositeThresholdFilter ( )
overridedefault

Member Function Documentation

◆ init()

void VtkCompositeThresholdFilter::init ( )
overridevirtual

Implements VtkCompositeFilter.

Definition at line 33 of file VtkCompositeThresholdFilter.cpp.

34 {
35  // Set meta information about input and output data types
36  this->_inputDataObjectType = VTK_DATA_SET;
37  this->_outputDataObjectType = VTK_UNSTRUCTURED_GRID;
38 
39  // Because this is the only filter here we cannot use vtkSmartPointer
40  vtkThreshold* threshold = vtkThreshold::New();
41  threshold->SetInputConnection(_inputAlgorithm->GetOutputPort());
42 
43  // Use first array of parent as input array
44  _inputAlgorithm->Update();
45  vtkDataSet* dataSet =
46  vtkDataSet::SafeDownCast(_inputAlgorithm->GetOutputDataObject(0));
47  vtkDataSetAttributes* pointAttributes =
48  dataSet->GetAttributes(vtkDataObject::AttributeTypes::POINT);
49  vtkDataSetAttributes* cellAttributes =
50  dataSet->GetAttributes(vtkDataObject::AttributeTypes::CELL);
51  if (pointAttributes->GetNumberOfArrays() > 0)
52  {
53  threshold->SetInputArrayToProcess(
54  0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS,
55  pointAttributes->GetArray(0)->GetName());
56  }
57  else if (cellAttributes->GetNumberOfArrays() > 0)
58  {
59  threshold->SetInputArrayToProcess(
60  0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS,
61  cellAttributes->GetArray(0)->GetName());
62  }
63  else
64  {
65  WARN("Threshold filter could not find an array on its input object!");
66  return;
67  }
68 
69  // Sets a filter property which will be user editable
70  threshold->SetSelectedComponent(0);
71 
72  // Setting the threshold to min / max values to ensure that the whole data
73  // is first processed. This is needed for correct lookup table generation.
74  const double dMin = std::numeric_limits<double>::lowest();
75  const double dMax = std::numeric_limits<double>::max();
76  threshold->ThresholdBetween(dMin, dMax);
77 
78  // Create a list for the ThresholdBetween (vector) property.
79  QList<QVariant> thresholdRangeList;
80  // Insert the values (same values as above)
81  thresholdRangeList.push_back(dMin);
82  thresholdRangeList.push_back(dMax);
83  // Put that list in the property map
84  (*_algorithmUserVectorProperties)["Range"] = thresholdRangeList;
85 
86  // Make a new entry in the property map for the SelectedComponent property
87  (*_algorithmUserProperties)["Selected Component"] = 0;
88 
89  // Must all scalars match the criterium
90  threshold->SetAllScalars(1);
91  (*_algorithmUserProperties)["Evaluate all points"] = true;
92 
93  // The threshold filter is last one and so it is also the _outputAlgorithm
94  _outputAlgorithm = threshold;
95 }
void WARN(char const *fmt, Args const &... args)
Definition: Logging.h:37
vtkAlgorithm * _outputAlgorithm
vtkAlgorithm * _inputAlgorithm

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

Referenced by VtkCompositeThresholdFilter().

◆ SetUserProperty()

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

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

Reimplemented from VtkAlgorithmProperties.

Definition at line 97 of file VtkCompositeThresholdFilter.cpp.

98 {
100 
101  // Use the same name as in init()
102  if (name.compare("Selected Component") == 0)
103  {
104  // Set the property on the algorithm
105  static_cast<vtkThreshold*>(_outputAlgorithm)
106  ->SetSelectedComponent(value.toInt());
107  }
108  else if (name.compare("Evaluate all points") == 0)
109  {
110  static_cast<vtkThreshold*>(_outputAlgorithm)
111  ->SetAllScalars(value.toBool());
112  }
113 }
virtual void SetUserProperty(QString name, QVariant value)
Sets a user property. This should be implemented by subclasses.

References VtkCompositeFilter::_outputAlgorithm, MaterialPropertyLib::name, and VtkAlgorithmProperties::SetUserProperty().

◆ SetUserVectorProperty()

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

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

Reimplemented from VtkAlgorithmProperties.

Definition at line 115 of file VtkCompositeThresholdFilter.cpp.

117 {
119 
120  // Use the same name as in init()
121  if (name.compare("Range") == 0)
122  {
123  // Set the vector property on the algorithm
124  static_cast<vtkThreshold*>(_outputAlgorithm)
125  ->ThresholdBetween(values[0].toDouble(), values[1].toDouble());
126  }
127 }
virtual void SetUserVectorProperty(QString name, QList< QVariant > values)
Sets a vector user property. This should be implemented by subclasses.

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


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