Commit e02313e7 authored by Cory Quammen's avatar Cory Quammen Committed by Kitware Robot
Browse files

Merge topic 'invert-threshold'

43a744f1

 Add Invert option to vtkThreshold

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: default avatarUtkarsh Ayachit <utkarsh.ayachit@kitware.com>
Merge-request: !4854
parents bc550a57 43a744f1
......@@ -21,6 +21,7 @@
#include "vtkImageData.h"
#include "vtkPointData.h"
#include "vtkFloatArray.h"
int TestThreshold(int, char *[])
{
//---------------------------------------------------
......@@ -64,5 +65,19 @@ int TestThreshold(int, char *[])
return EXIT_FAILURE;
}
// Get the total number of cells
int totalCellCount = source->GetOutput()->GetNumberOfCells();
int thresholdedCellCount = filter->GetOutput()->GetNumberOfCells();
// Now invert the threshold and test the number of cells
filter->InvertOn();
filter->Update();
int invertedCellCount = filter->GetOutput()->GetNumberOfCells();
if (invertedCellCount + thresholdedCellCount != totalCellCount)
{
std::cerr << "Cell count and inverted cell count inconsistent" << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
......@@ -47,6 +47,7 @@ vtkThreshold::vtkThreshold()
vtkDataSetAttributes::SCALARS);
this->UseContinuousCellRange = 0;
this->Invert = false;
}
vtkThreshold::~vtkThreshold() = default;
......@@ -218,7 +219,10 @@ int vtkThreshold::RequestData(
keepCell = this->EvaluateComponents( inScalars, cellId );
}
if ( numCellPts > 0 && keepCell )
// Invert the keep flag if the Invert option is enabled.
keepCell = this->Invert ? (1 - keepCell) : keepCell;
if ( numCellPts > 0 && keepCell)
{
// satisfied thresholding (also non-empty cell, i.e. not VTK_EMPTY_CELL)
for (i=0; i < numCellPts; i++)
......
......@@ -173,6 +173,17 @@ public:
int GetPointsDataType();
//@}
//@{
/**
* Invert the threshold results. That is, cells that would have been in the output with this
* option off are excluded, while cells that would have been excluded from the output are
* included.
*/
vtkSetMacro(Invert, bool);
vtkGetMacro(Invert, bool);
vtkBooleanMacro(Invert, bool);
//@}
//@{
/**
* Set/get the desired precision for the output types. See the documentation
......@@ -201,6 +212,7 @@ protected:
int SelectedComponent;
int OutputPointsPrecision;
vtkTypeBool UseContinuousCellRange;
bool Invert;
int (vtkThreshold::*ThresholdFunction)(double s);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment