2016-01-19 14:59:31 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2016-01-19 14:59:31 +00:00
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef vtk_m_filter_Threshold_h
|
|
|
|
#define vtk_m_filter_Threshold_h
|
|
|
|
|
2020-08-19 23:20:43 +00:00
|
|
|
#include <vtkm/filter/vtkm_filter_common_export.h>
|
2019-09-09 13:39:23 +00:00
|
|
|
|
2016-05-05 18:42:46 +00:00
|
|
|
#include <vtkm/filter/FilterDataSetWithField.h>
|
2016-01-19 14:59:31 +00:00
|
|
|
#include <vtkm/worklet/Threshold.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2017-07-06 17:51:45 +00:00
|
|
|
/// \brief Extracts cells where scalar value in cell satisfies threshold criterion
|
|
|
|
///
|
|
|
|
/// Extracts all cells from any dataset type that
|
|
|
|
/// satisfy a threshold criterion. A cell satisfies the criterion if the
|
|
|
|
/// scalar value of every point or cell satisfies the criterion. The
|
|
|
|
/// criterion takes the form of between two values. The output of this
|
|
|
|
/// filter is an permutation of the input dataset.
|
|
|
|
///
|
|
|
|
/// You can threshold either on point or cell fields
|
2020-11-17 19:37:05 +00:00
|
|
|
class VTKM_FILTER_COMMON_EXPORT Threshold : public vtkm::filter::FilterDataSetWithField<Threshold>
|
2016-01-19 14:59:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-12-05 17:55:57 +00:00
|
|
|
using SupportedTypes = vtkm::TypeListScalarAll;
|
2019-08-02 02:03:04 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetLowerThreshold(vtkm::Float64 value) { this->LowerValue = value; }
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetUpperThreshold(vtkm::Float64 value) { this->UpperValue = value; }
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Float64 GetLowerThreshold() const { return this->LowerValue; }
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Float64 GetUpperThreshold() const { return this->UpperValue; }
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2021-08-31 19:33:45 +00:00
|
|
|
//If using scalars from point data, all scalars for all points in a cell must
|
|
|
|
//satisfy the threshold criterion if AllScalars is set. Otherwise, just a
|
|
|
|
//single scalar value satisfying the threshold criterion will extract the cell.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetAllInRange(bool value) { this->ReturnAllInRange = value; }
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
bool GetAllInRange() const { return this->ReturnAllInRange; }
|
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
2018-04-02 21:58:21 +00:00
|
|
|
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
2016-01-19 14:59:31 +00:00
|
|
|
|
|
|
|
//Map a new field onto the resulting dataset after running the filter
|
2020-02-06 21:58:59 +00:00
|
|
|
//this call is only valid after DoExecute is called
|
2020-11-17 19:37:05 +00:00
|
|
|
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, const vtkm::cont::Field& field);
|
2020-02-06 21:58:59 +00:00
|
|
|
|
|
|
|
template <typename DerivedPolicy>
|
|
|
|
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
|
|
|
const vtkm::cont::Field& field,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
2019-09-09 13:39:23 +00:00
|
|
|
{
|
2020-02-06 21:58:59 +00:00
|
|
|
return this->MapFieldOntoOutput(result, field);
|
2019-09-09 13:39:23 +00:00
|
|
|
}
|
2016-01-19 14:59:31 +00:00
|
|
|
|
|
|
|
private:
|
2019-09-09 13:39:23 +00:00
|
|
|
double LowerValue = 0;
|
|
|
|
double UpperValue = 0;
|
2021-08-31 19:33:45 +00:00
|
|
|
bool ReturnAllInRange = false;
|
2017-06-16 21:27:47 +00:00
|
|
|
vtkm::worklet::Threshold Worklet;
|
2016-01-19 14:59:31 +00:00
|
|
|
};
|
2019-09-09 13:39:23 +00:00
|
|
|
|
|
|
|
#ifndef vtkm_filter_Threshold_cxx
|
2020-11-17 19:37:05 +00:00
|
|
|
VTKM_FILTER_COMMON_EXPORT_EXECUTE_METHOD(Threshold);
|
2019-09-09 13:39:23 +00:00
|
|
|
#endif
|
2016-01-19 14:59:31 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
|
|
|
|
2019-10-07 19:39:02 +00:00
|
|
|
#include <vtkm/filter/Threshold.hxx>
|
|
|
|
|
2016-04-07 21:09:11 +00:00
|
|
|
#endif // vtk_m_filter_Threshold_h
|