mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
migrate GhostCellRemove and Threshold
This commit is contained in:
parent
7e08f4fb1b
commit
679f1b00e9
@ -34,13 +34,13 @@
|
||||
#include <vtkm/filter/PointAverage.h>
|
||||
#include <vtkm/filter/PolicyBase.h>
|
||||
#include <vtkm/filter/Tetrahedralize.h>
|
||||
#include <vtkm/filter/Threshold.h>
|
||||
#include <vtkm/filter/Triangulate.h>
|
||||
#include <vtkm/filter/VectorMagnitude.h>
|
||||
#include <vtkm/filter/VertexClustering.h>
|
||||
#include <vtkm/filter/WarpScalar.h>
|
||||
#include <vtkm/filter/WarpVector.h>
|
||||
#include <vtkm/filter/entity_extraction/ExternalFaces.h>
|
||||
#include <vtkm/filter/entity_extraction/Threshold.h>
|
||||
#include <vtkm/filter/entity_extraction/ThresholdPoints.h>
|
||||
|
||||
#include <vtkm/io/VTKDataSetReader.h>
|
||||
|
@ -55,13 +55,11 @@ set(common_header_template_sources
|
||||
FilterParticleAdvection.hxx
|
||||
FilterTemporalParticleAdvection.hxx
|
||||
PointAverage.hxx
|
||||
Threshold.hxx
|
||||
)
|
||||
|
||||
set(common_sources_device
|
||||
CellAverage.cxx
|
||||
PointAverage.cxx
|
||||
Threshold.cxx
|
||||
)
|
||||
|
||||
set(extra_headers
|
||||
@ -135,7 +133,6 @@ set(extra_header_template_sources
|
||||
Entropy.hxx
|
||||
FieldToColors.hxx
|
||||
GhostCellClassify.hxx
|
||||
GhostCellRemove.hxx
|
||||
Histogram.hxx
|
||||
ImageConnectivity.hxx
|
||||
ImageDifference.hxx
|
||||
|
@ -7,79 +7,34 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_GhostCellRemove_h
|
||||
#define vtk_m_filter_GhostCellRemove_h
|
||||
|
||||
#include <vtkm/CellClassification.h>
|
||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||
#include <vtkm/filter/Threshold.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/entity_extraction/GhostCellRemove.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
struct GhostCellRemovePolicy : vtkm::filter::PolicyBase<GhostCellRemovePolicy>
|
||||
{
|
||||
using FieldTypeList = vtkm::List<vtkm::UInt8>;
|
||||
};
|
||||
VTKM_DEPRECATED(
|
||||
1.8,
|
||||
"Use vtkm/filter/entity_extraction/GhostCellRemove.h instead of vtkm/filter/GhostCellRemove.h.")
|
||||
inline void GhostCellRemove_deprecated() {}
|
||||
|
||||
/// \brief Removes ghost cells
|
||||
///
|
||||
class GhostCellRemove : public vtkm::filter::FilterDataSetWithField<GhostCellRemove>
|
||||
inline void GhostCellRemove_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
//currently the GhostCellRemove filter only works on uint8 data.
|
||||
using SupportedTypes = vtkm::List<vtkm::UInt8>;
|
||||
|
||||
VTKM_CONT
|
||||
GhostCellRemove();
|
||||
|
||||
VTKM_CONT
|
||||
void RemoveGhostField() { this->RemoveField = true; }
|
||||
VTKM_CONT
|
||||
void RemoveAllGhost() { this->RemoveAll = true; }
|
||||
VTKM_CONT
|
||||
void RemoveByType(const vtkm::UInt8& vals)
|
||||
{
|
||||
this->RemoveAll = false;
|
||||
this->RemoveVals = vals;
|
||||
GhostCellRemove_deprecated();
|
||||
}
|
||||
VTKM_CONT
|
||||
bool GetRemoveGhostField() { return this->RemoveField; }
|
||||
VTKM_CONT
|
||||
bool GetRemoveAllGhost() const { return this->RemoveAll; }
|
||||
|
||||
VTKM_CONT
|
||||
bool GetRemoveByType() const { return !this->RemoveAll; }
|
||||
VTKM_CONT
|
||||
vtkm::UInt8 GetRemoveType() const { return this->RemoveVals; }
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter
|
||||
//this call is only valid after DoExecute is run
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
private:
|
||||
bool RemoveAll;
|
||||
bool RemoveField;
|
||||
vtkm::UInt8 RemoveVals;
|
||||
vtkm::worklet::Threshold Worklet;
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::GhostCellRemove.") GhostCellRemove
|
||||
: public vtkm::filter::entity_extraction::GhostCellRemove
|
||||
{
|
||||
using entity_extraction::GhostCellRemove::GhostCellRemove;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#ifndef vtk_m_filter_GhostCellRemove_hxx
|
||||
#include <vtkm/filter/GhostCellRemove.hxx>
|
||||
#endif
|
||||
|
||||
#endif //vtk_m_filter_GhostCellRemove_h
|
||||
|
@ -1,41 +0,0 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// 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.
|
||||
//============================================================================
|
||||
#define vtkm_filter_Threshold_cxx
|
||||
#include <vtkm/filter/Threshold.h>
|
||||
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
bool Threshold::MapFieldOntoOutput(vtkm::cont::DataSet& result, const vtkm::cont::Field& field)
|
||||
{
|
||||
if (field.IsFieldPoint() || field.IsFieldGlobal())
|
||||
{
|
||||
//we copy the input handle to the result dataset, reusing the metadata
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
return vtkm::filter::MapFieldPermutation(field, this->Worklet.GetValidCellIds(), result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_FILTER_COMMON_INSTANTIATE_EXECUTE_METHOD(Threshold);
|
||||
}
|
||||
}
|
@ -7,84 +7,33 @@
|
||||
// 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
|
||||
|
||||
#include <vtkm/filter/vtkm_filter_common_export.h>
|
||||
|
||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||
#include <vtkm/worklet/Threshold.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/entity_extraction/Threshold.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
/// \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
|
||||
class VTKM_FILTER_COMMON_EXPORT Threshold : public vtkm::filter::FilterDataSetWithField<Threshold>
|
||||
VTKM_DEPRECATED(1.8,
|
||||
"Use vtkm/filter/entity_extraction/Threshold.h instead of vtkm/filter/Threshold.h.")
|
||||
inline void Threshold_deprecated() {}
|
||||
|
||||
inline void Threshold_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
using SupportedTypes = vtkm::TypeListScalarAll;
|
||||
|
||||
VTKM_CONT
|
||||
void SetLowerThreshold(vtkm::Float64 value) { this->LowerValue = value; }
|
||||
VTKM_CONT
|
||||
void SetUpperThreshold(vtkm::Float64 value) { this->UpperValue = value; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 GetLowerThreshold() const { return this->LowerValue; }
|
||||
VTKM_CONT
|
||||
vtkm::Float64 GetUpperThreshold() const { return this->UpperValue; }
|
||||
|
||||
//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; }
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter
|
||||
//this call is only valid after DoExecute is called
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, const vtkm::cont::Field& field);
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
{
|
||||
return this->MapFieldOntoOutput(result, field);
|
||||
Threshold_deprecated();
|
||||
}
|
||||
|
||||
private:
|
||||
double LowerValue = 0;
|
||||
double UpperValue = 0;
|
||||
bool ReturnAllInRange = false;
|
||||
vtkm::worklet::Threshold Worklet;
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::entity_extraction::Threshold.") Threshold
|
||||
: public vtkm::filter::entity_extraction::Threshold
|
||||
{
|
||||
using entity_extraction::Threshold::Threshold;
|
||||
};
|
||||
|
||||
#ifndef vtkm_filter_Threshold_cxx
|
||||
VTKM_FILTER_COMMON_EXPORT_EXECUTE_METHOD(Threshold);
|
||||
#endif
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#include <vtkm/filter/Threshold.hxx>
|
||||
|
||||
#endif //vtk_m_filter_Threshold_h
|
||||
|
@ -12,7 +12,9 @@ set(entity_extraction_headers
|
||||
ExtractGeometry.h
|
||||
ExtractPoints.h
|
||||
ExtractStructured.h
|
||||
GhostCellRemove.h
|
||||
MaskPoints.h
|
||||
Threshold.h
|
||||
ThresholdPoints.h
|
||||
)
|
||||
set(entity_extraction_sources_device
|
||||
@ -20,7 +22,9 @@ set(entity_extraction_sources_device
|
||||
ExtractGeometry.cxx
|
||||
ExtractPoints.cxx
|
||||
ExtractStructured.cxx
|
||||
GhostCellRemove.cxx
|
||||
MaskPoints.cxx
|
||||
Threshold.cxx
|
||||
ThresholdPoints.cxx
|
||||
)
|
||||
|
||||
|
@ -8,19 +8,14 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_GhostCellRemove_hxx
|
||||
#define vtk_m_filter_GhostCellRemove_hxx
|
||||
#include <vtkm/filter/GhostCellRemove.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/CellSetPermutation.h>
|
||||
#include <vtkm/RangeId3.h>
|
||||
#include <vtkm/cont/UnknownCellSet.h>
|
||||
|
||||
#include <vtkm/RangeId3.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
#include <vtkm/filter/entity_extraction/ExtractStructured.h>
|
||||
#include <vtkm/worklet/CellDeepCopy.h>
|
||||
#include <vtkm/filter/entity_extraction/GhostCellRemove.h>
|
||||
#include <vtkm/filter/entity_extraction/worklet/Threshold.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -285,29 +280,52 @@ namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace
|
||||
{
|
||||
bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
const vtkm::worklet::Threshold& Worklet)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
//we copy the input handle to the result dataset, reusing the metadata
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
return vtkm::filter::MapFieldPermutation(field, Worklet.GetValidCellIds(), result);
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
namespace entity_extraction
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT GhostCellRemove::GhostCellRemove()
|
||||
: vtkm::filter::FilterDataSetWithField<GhostCellRemove>()
|
||||
, RemoveAll(false)
|
||||
, RemoveField(false)
|
||||
, RemoveVals(0)
|
||||
VTKM_CONT GhostCellRemove::GhostCellRemove()
|
||||
{
|
||||
this->SetActiveField("vtkmGhostCells");
|
||||
this->SetFieldsToPass("vtkmGhostCells", vtkm::filter::FieldSelection::MODE_EXCLUDE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
//get the cells and coordinates of the dataset
|
||||
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
||||
vtkm::cont::UnknownCellSet cellOut;
|
||||
const auto& field = this->GetFieldFromDataSet(input);
|
||||
|
||||
// We are pretty sure the field array is an array of vtkm::UInt8 since it is the only supported
|
||||
// type.
|
||||
auto fieldArray = field.GetData().AsArrayHandle<vtkm::cont::ArrayHandle<vtkm::UInt8>>();
|
||||
|
||||
//Preserve structured output where possible.
|
||||
if (cells.CanConvert<vtkm::cont::CellSetStructured<1>>() ||
|
||||
@ -316,7 +334,7 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
|
||||
{
|
||||
vtkm::RangeId3 range;
|
||||
if (CanDoStructuredStrip(
|
||||
cells, field, this->Invoke, this->GetRemoveAllGhost(), this->GetRemoveType(), range))
|
||||
cells, fieldArray, this->Invoke, this->GetRemoveAllGhost(), this->GetRemoveType(), range))
|
||||
{
|
||||
vtkm::filter::entity_extraction::ExtractStructured extract;
|
||||
extract.SetInvoker(this->Invoke);
|
||||
@ -334,18 +352,21 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
|
||||
}
|
||||
}
|
||||
|
||||
vtkm::cont::UnknownCellSet cellOut;
|
||||
vtkm::worklet::Threshold Worklet;
|
||||
|
||||
if (this->GetRemoveAllGhost())
|
||||
{
|
||||
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||
field,
|
||||
fieldMeta.GetAssociation(),
|
||||
cellOut = Worklet.Run(cells.ResetCellSetList<VTKM_DEFAULT_CELL_SET_LIST>(),
|
||||
fieldArray,
|
||||
field.GetAssociation(),
|
||||
RemoveAllGhosts());
|
||||
}
|
||||
else if (this->GetRemoveByType())
|
||||
{
|
||||
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||
field,
|
||||
fieldMeta.GetAssociation(),
|
||||
cellOut = Worklet.Run(cells.ResetCellSetList<VTKM_DEFAULT_CELL_SET_LIST>(),
|
||||
fieldArray,
|
||||
field.GetAssociation(),
|
||||
RemoveGhostByType(this->GetRemoveType()));
|
||||
}
|
||||
else
|
||||
@ -357,36 +378,12 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
|
||||
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
||||
output.SetCellSet(cellOut);
|
||||
|
||||
auto mapper = [&, this](auto& result, const auto& f) { DoMapField(result, f, Worklet); };
|
||||
MapFieldsOntoOutput(input, output, mapper);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool GhostCellRemove::MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
//we copy the input handle to the result dataset, reusing the metadata
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
return vtkm::filter::MapFieldPermutation(field, this->Worklet.GetValidCellIds(), result);
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //vtk_m_filter_GhostCellRemove_hxx
|
65
vtkm/filter/entity_extraction/GhostCellRemove.h
Normal file
65
vtkm/filter/entity_extraction/GhostCellRemove.h
Normal file
@ -0,0 +1,65 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// 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_entity_extraction_GhostCellRemove_h
|
||||
#define vtk_m_filter_entity_extraction_GhostCellRemove_h
|
||||
|
||||
#include <vtkm/CellClassification.h>
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/entity_extraction/vtkm_filter_entity_extraction_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace entity_extraction
|
||||
{
|
||||
/// \brief Removes ghost cells
|
||||
///
|
||||
class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT GhostCellRemove : public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
GhostCellRemove();
|
||||
|
||||
VTKM_CONT
|
||||
void RemoveGhostField() { this->RemoveField = true; }
|
||||
VTKM_CONT
|
||||
void RemoveAllGhost() { this->RemoveAll = true; }
|
||||
VTKM_CONT
|
||||
void RemoveByType(const vtkm::UInt8& vals)
|
||||
{
|
||||
this->RemoveAll = false;
|
||||
this->RemoveVals = vals;
|
||||
}
|
||||
VTKM_CONT
|
||||
bool GetRemoveGhostField() { return this->RemoveField; }
|
||||
VTKM_CONT
|
||||
bool GetRemoveAllGhost() const { return this->RemoveAll; }
|
||||
|
||||
VTKM_CONT
|
||||
bool GetRemoveByType() const { return !this->RemoveAll; }
|
||||
VTKM_CONT
|
||||
vtkm::UInt8 GetRemoveType() const { return this->RemoveVals; }
|
||||
|
||||
private:
|
||||
VTKM_CONT
|
||||
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
||||
|
||||
bool RemoveAll = false;
|
||||
bool RemoveField = false;
|
||||
vtkm::UInt8 RemoveVals = 0;
|
||||
};
|
||||
|
||||
} // namespace entity_extraction
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_entity_extraction_GhostCellRemove_h
|
@ -7,14 +7,16 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_filter_Threshold_hxx
|
||||
#define vtk_m_filter_Threshold_hxx
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/CellSetPermutation.h>
|
||||
#include <vtkm/cont/UnknownCellSet.h>
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
#include <vtkm/filter/entity_extraction/Threshold.h>
|
||||
#include <vtkm/filter/entity_extraction/worklet/Threshold.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace entity_extraction
|
||||
{
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -49,36 +51,61 @@ private:
|
||||
vtkm::Float64 Upper;
|
||||
};
|
||||
|
||||
bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
const vtkm::worklet::Threshold& Worklet)
|
||||
{
|
||||
if (field.IsFieldPoint() || field.IsFieldGlobal())
|
||||
{
|
||||
//we copy the input handle to the result dataset, reusing the metadata
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
return vtkm::filter::MapFieldPermutation(field, Worklet.GetValidCellIds(), result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // end anon namespace
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
vtkm::cont::DataSet Threshold::DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
vtkm::cont::DataSet Threshold::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
//get the cells and coordinates of the dataset
|
||||
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
||||
const auto& field = this->GetFieldFromDataSet(input);
|
||||
|
||||
ThresholdRange predicate(this->GetLowerThreshold(), this->GetUpperThreshold());
|
||||
vtkm::cont::UnknownCellSet cellOut =
|
||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||
field,
|
||||
fieldMeta.GetAssociation(),
|
||||
vtkm::worklet::Threshold Worklet;
|
||||
vtkm::cont::UnknownCellSet cellOut;
|
||||
|
||||
auto ResolveArrayType = [&, this](const auto& concrete) {
|
||||
// TODO: document the reason a .ResetCellSetList is needed here.
|
||||
cellOut = Worklet.Run(cells.ResetCellSetList<VTKM_DEFAULT_CELL_SET_LIST>(),
|
||||
concrete,
|
||||
field.GetAssociation(),
|
||||
predicate,
|
||||
this->GetAllInRange());
|
||||
};
|
||||
|
||||
const auto& fieldArray = field.GetData();
|
||||
fieldArray.CastAndCallForTypes<vtkm::TypeListScalarAll, VTKM_DEFAULT_STORAGE_LIST>(
|
||||
ResolveArrayType);
|
||||
|
||||
vtkm::cont::DataSet output;
|
||||
output.SetCellSet(cellOut);
|
||||
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
||||
|
||||
auto mapper = [&, this](auto& result, const auto& f) { DoMapField(result, f, Worklet); };
|
||||
MapFieldsOntoOutput(input, output, mapper);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // namespace entity_extraction
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
66
vtkm/filter/entity_extraction/Threshold.h
Normal file
66
vtkm/filter/entity_extraction/Threshold.h
Normal file
@ -0,0 +1,66 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// 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_entity_extraction_Threshold_h
|
||||
#define vtk_m_filter_entity_extraction_Threshold_h
|
||||
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/entity_extraction/vtkm_filter_entity_extraction_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace entity_extraction
|
||||
{
|
||||
/// \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
|
||||
class VTKM_FILTER_ENTITY_EXTRACTION_EXPORT Threshold : public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
void SetLowerThreshold(vtkm::Float64 value) { this->LowerValue = value; }
|
||||
VTKM_CONT
|
||||
void SetUpperThreshold(vtkm::Float64 value) { this->UpperValue = value; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 GetLowerThreshold() const { return this->LowerValue; }
|
||||
VTKM_CONT
|
||||
vtkm::Float64 GetUpperThreshold() const { return this->UpperValue; }
|
||||
|
||||
//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; }
|
||||
|
||||
private:
|
||||
VTKM_CONT
|
||||
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
||||
|
||||
double LowerValue = 0;
|
||||
double UpperValue = 0;
|
||||
bool ReturnAllInRange = false;
|
||||
};
|
||||
} // namespace entity_extraction
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_entity_extraction_Threshold_h
|
@ -13,7 +13,9 @@ set(unit_tests
|
||||
UnitTestExtractGeometryFilter.cxx
|
||||
UnitTestExtractPointsFilter.cxx
|
||||
UnitTestExtractStructuredFilter.cxx
|
||||
UnitTestGhostCellRemove.cxx
|
||||
UnitTestMaskPointsFilter.cxx
|
||||
UnitTestThresholdFilter.cxx
|
||||
UnitTestThresholdPointsFilter.cxx
|
||||
)
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/GhostCellRemove.h>
|
||||
#include <vtkm/filter/entity_extraction/GhostCellRemove.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -247,7 +247,7 @@ void TestGhostCellRemove()
|
||||
std::vector<std::string> removeType = { "all", "byType" };
|
||||
for (auto& rt : removeType)
|
||||
{
|
||||
vtkm::filter::GhostCellRemove ghostCellRemoval;
|
||||
vtkm::filter::entity_extraction::GhostCellRemove ghostCellRemoval;
|
||||
ghostCellRemoval.RemoveGhostField();
|
||||
|
||||
if (rt == "all")
|
||||
@ -294,7 +294,7 @@ void TestGhostCellRemove()
|
||||
else if (dsType == "rectilinear")
|
||||
ds = MakeRectilinear(nx, ny, nz, layer, true);
|
||||
|
||||
vtkm::filter::GhostCellRemove ghostCellRemoval;
|
||||
vtkm::filter::entity_extraction::GhostCellRemove ghostCellRemoval;
|
||||
ghostCellRemoval.RemoveGhostField();
|
||||
auto output = ghostCellRemoval.Execute(ds);
|
||||
VTKM_TEST_ASSERT(output.GetCellSet().IsType<vtkm::cont::CellSetExplicit<>>(),
|
@ -10,8 +10,8 @@
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/Threshold.h>
|
||||
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||
#include <vtkm/filter/entity_extraction/Threshold.h>
|
||||
|
||||
using vtkm::cont::testing::MakeTestDataSet;
|
||||
|
||||
@ -24,7 +24,7 @@ public:
|
||||
void TestRegular2D(bool returnAllInRange) const
|
||||
{
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make2DUniformDataSet0();
|
||||
vtkm::filter::Threshold threshold;
|
||||
vtkm::filter::entity_extraction::Threshold threshold;
|
||||
|
||||
if (returnAllInRange)
|
||||
{
|
||||
@ -80,7 +80,7 @@ public:
|
||||
void TestRegular3D(bool returnAllInRange) const
|
||||
{
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet0();
|
||||
vtkm::filter::Threshold threshold;
|
||||
vtkm::filter::entity_extraction::Threshold threshold;
|
||||
|
||||
if (returnAllInRange)
|
||||
{
|
||||
@ -141,7 +141,7 @@ public:
|
||||
std::cout << "Testing threshold on 3D explicit dataset" << std::endl;
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DExplicitDataSet1();
|
||||
|
||||
vtkm::filter::Threshold threshold;
|
||||
vtkm::filter::entity_extraction::Threshold threshold;
|
||||
|
||||
threshold.SetLowerThreshold(20);
|
||||
threshold.SetUpperThreshold(21);
|
||||
@ -171,7 +171,7 @@ public:
|
||||
std::cout << "Testing threshold on 3D explicit dataset with empty results" << std::endl;
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DExplicitDataSet1();
|
||||
|
||||
vtkm::filter::Threshold threshold;
|
||||
vtkm::filter::entity_extraction::Threshold threshold;
|
||||
|
||||
threshold.SetLowerThreshold(500);
|
||||
threshold.SetUpperThreshold(500.1);
|
@ -14,6 +14,7 @@ set(headers
|
||||
ExtractStructured.h
|
||||
ExtractPoints.h
|
||||
MaskPoints.h
|
||||
Threshold.h
|
||||
ThresholdPoints.h
|
||||
)
|
||||
|
||||
|
@ -32,7 +32,6 @@ set(unit_tests
|
||||
UnitTestGradientExplicit.cxx
|
||||
UnitTestGradientUniform.cxx
|
||||
UnitTestGhostCellClassify.cxx
|
||||
UnitTestGhostCellRemove.cxx
|
||||
UnitTestHistogramFilter.cxx
|
||||
UnitTestImageConnectivityFilter.cxx
|
||||
UnitTestImageDifferenceFilter.cxx
|
||||
@ -60,7 +59,6 @@ set(unit_tests
|
||||
UnitTestStreamSurfaceFilter.cxx
|
||||
UnitTestSurfaceNormalsFilter.cxx
|
||||
UnitTestTetrahedralizeFilter.cxx
|
||||
UnitTestThresholdFilter.cxx
|
||||
UnitTestTriangulateFilter.cxx
|
||||
UnitTestTubeFilter.cxx
|
||||
UnitTestVectorMagnitudeFilter.cxx
|
||||
|
@ -9,8 +9,8 @@
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/MergePartitionedDataSet.h>
|
||||
#include <vtkm/filter/Threshold.h>
|
||||
#include <vtkm/filter/entity_extraction/ExternalFaces.h>
|
||||
#include <vtkm/filter/entity_extraction/Threshold.h>
|
||||
#include <vtkm/source/Amr.h>
|
||||
|
||||
#include <vtkm/rendering/testing/RenderTest.h>
|
||||
@ -30,7 +30,7 @@ void TestAmrArraysExecute(int dim, int numberOfLevels, int cellsPerDimension)
|
||||
// amrDataSet.PrintSummary(std::cout);
|
||||
|
||||
// Remove blanked cells
|
||||
vtkm::filter::Threshold threshold;
|
||||
vtkm::filter::entity_extraction::Threshold threshold;
|
||||
threshold.SetLowerThreshold(0);
|
||||
threshold.SetUpperThreshold(1);
|
||||
threshold.SetActiveField("vtkGhostType");
|
||||
|
@ -69,7 +69,6 @@ set(headers
|
||||
StreamSurface.h
|
||||
SurfaceNormals.h
|
||||
Tetrahedralize.h
|
||||
Threshold.h
|
||||
TriangleWinding.h
|
||||
Triangulate.h
|
||||
Tube.h
|
||||
|
@ -65,7 +65,6 @@ set(unit_tests
|
||||
UnitTestSurfaceNormals.cxx
|
||||
UnitTestTemporalAdvection.cxx
|
||||
UnitTestTetrahedralize.cxx
|
||||
UnitTestThreshold.cxx
|
||||
UnitTestTriangleWinding.cxx
|
||||
UnitTestTriangulate.cxx
|
||||
UnitTestTube.cxx
|
||||
|
@ -1,252 +0,0 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/worklet/Threshold.h>
|
||||
|
||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class HasValue
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
HasValue(vtkm::Float32 value)
|
||||
: Value(value)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename ScalarType>
|
||||
VTKM_EXEC bool operator()(ScalarType value) const
|
||||
{
|
||||
return static_cast<vtkm::Float32>(value) == this->Value;
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Float32 Value;
|
||||
};
|
||||
|
||||
class ThresholdRange
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
ThresholdRange() {}
|
||||
|
||||
ThresholdRange(const vtkm::Float64& lower, const vtkm::Float64& upper)
|
||||
: Lower(lower)
|
||||
, Upper(upper)
|
||||
{
|
||||
}
|
||||
|
||||
void SetLowerValue(const vtkm::Float64& lower) { Lower = lower; }
|
||||
void SetUpperValue(const vtkm::Float64& upper) { Upper = upper; }
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC bool operator()(const T& value) const
|
||||
{
|
||||
|
||||
return value >= static_cast<T>(this->Lower) && value <= static_cast<T>(this->Upper);
|
||||
}
|
||||
|
||||
//Needed to work with ArrayHandleVirtual
|
||||
template <typename PortalType>
|
||||
VTKM_EXEC bool operator()(
|
||||
const vtkm::internal::ArrayPortalValueReference<PortalType>& value) const
|
||||
{
|
||||
using T = typename PortalType::ValueType;
|
||||
return value.Get() >= static_cast<T>(this->Lower) && value.Get() <= static_cast<T>(this->Upper);
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Float64 Lower;
|
||||
vtkm::Float64 Upper;
|
||||
};
|
||||
|
||||
using vtkm::cont::testing::MakeTestDataSet;
|
||||
|
||||
class TestingThreshold
|
||||
{
|
||||
public:
|
||||
void TestUniform2D(bool returnAllInRange) const
|
||||
{
|
||||
using CellSetType = vtkm::cont::CellSetStructured<2>;
|
||||
using OutCellSetType = vtkm::cont::CellSetPermutation<CellSetType>;
|
||||
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make2DUniformDataSet0();
|
||||
|
||||
CellSetType cellset;
|
||||
dataset.GetCellSet().AsCellSet(cellset);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> pointvar;
|
||||
dataset.GetField("pointvar").GetData().AsArrayHandle(pointvar);
|
||||
|
||||
vtkm::worklet::Threshold threshold;
|
||||
ThresholdRange predicate;
|
||||
|
||||
if (returnAllInRange)
|
||||
{
|
||||
std::cout << "Testing threshold on 2D uniform dataset returning values 'all in range'"
|
||||
<< std::endl;
|
||||
predicate.SetLowerValue(10);
|
||||
predicate.SetUpperValue(60);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Testing threshold on 2D uniform dataset returning values 'part in range'"
|
||||
<< std::endl;
|
||||
predicate.SetLowerValue(60);
|
||||
predicate.SetUpperValue(61);
|
||||
}
|
||||
|
||||
OutCellSetType outCellSet = threshold.Run(
|
||||
cellset, pointvar, vtkm::cont::Field::Association::POINTS, predicate, returnAllInRange);
|
||||
|
||||
if (returnAllInRange)
|
||||
{
|
||||
VTKM_TEST_ASSERT(outCellSet.GetNumberOfCells() == 1, "Wrong number of cells");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar;
|
||||
dataset.GetField("cellvar").GetData().AsArrayHandle(cellvar);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray = threshold.ProcessCellField(cellvar);
|
||||
|
||||
VTKM_TEST_ASSERT(cellFieldArray.GetNumberOfValues() == 1 &&
|
||||
cellFieldArray.ReadPortal().Get(0) == 100.1f,
|
||||
"Wrong cell field data");
|
||||
}
|
||||
else
|
||||
{
|
||||
VTKM_TEST_ASSERT(outCellSet.GetNumberOfCells() == 1, "Wrong number of cells");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar;
|
||||
dataset.GetField("cellvar").GetData().AsArrayHandle(cellvar);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray = threshold.ProcessCellField(cellvar);
|
||||
|
||||
VTKM_TEST_ASSERT(cellFieldArray.GetNumberOfValues() == 1 &&
|
||||
cellFieldArray.ReadPortal().Get(0) == 200.1f,
|
||||
"Wrong cell field data");
|
||||
}
|
||||
}
|
||||
|
||||
void TestUniform3D(bool returnAllInRange) const
|
||||
{
|
||||
using CellSetType = vtkm::cont::CellSetStructured<3>;
|
||||
using OutCellSetType = vtkm::cont::CellSetPermutation<CellSetType>;
|
||||
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet0();
|
||||
|
||||
CellSetType cellset;
|
||||
dataset.GetCellSet().AsCellSet(cellset);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> pointvar;
|
||||
dataset.GetField("pointvar").GetData().AsArrayHandle(pointvar);
|
||||
|
||||
vtkm::worklet::Threshold threshold;
|
||||
ThresholdRange predicate;
|
||||
|
||||
if (returnAllInRange)
|
||||
{
|
||||
std::cout << "Testing threshold on 3D uniform dataset returning values 'all in range'"
|
||||
<< std::endl;
|
||||
predicate.SetLowerValue(10.1);
|
||||
predicate.SetUpperValue(180);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Testing threshold on 3D uniform dataset returning values 'part in range'"
|
||||
<< std::endl;
|
||||
predicate.SetLowerValue(20);
|
||||
predicate.SetUpperValue(21);
|
||||
}
|
||||
|
||||
OutCellSetType outCellSet = threshold.Run(
|
||||
cellset, pointvar, vtkm::cont::Field::Association::POINTS, predicate, returnAllInRange);
|
||||
|
||||
if (returnAllInRange)
|
||||
{
|
||||
VTKM_TEST_ASSERT(outCellSet.GetNumberOfCells() == 3, "Wrong number of cells");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar;
|
||||
dataset.GetField("cellvar").GetData().AsArrayHandle(cellvar);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray = threshold.ProcessCellField(cellvar);
|
||||
|
||||
VTKM_TEST_ASSERT(cellFieldArray.GetNumberOfValues() == 3 &&
|
||||
cellFieldArray.ReadPortal().Get(0) == 100.1f &&
|
||||
cellFieldArray.ReadPortal().Get(1) == 100.2f &&
|
||||
cellFieldArray.ReadPortal().Get(2) == 100.3f,
|
||||
"Wrong cell field data");
|
||||
}
|
||||
else
|
||||
{
|
||||
VTKM_TEST_ASSERT(outCellSet.GetNumberOfCells() == 2, "Wrong number of cells");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar;
|
||||
dataset.GetField("cellvar").GetData().AsArrayHandle(cellvar);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray = threshold.ProcessCellField(cellvar);
|
||||
|
||||
VTKM_TEST_ASSERT(cellFieldArray.GetNumberOfValues() == 2 &&
|
||||
cellFieldArray.ReadPortal().Get(0) == 100.1f &&
|
||||
cellFieldArray.ReadPortal().Get(1) == 100.2f,
|
||||
"Wrong cell field data");
|
||||
}
|
||||
}
|
||||
|
||||
void TestExplicit3D() const
|
||||
{
|
||||
std::cout << "Testing threshold on 3D explicit dataset" << std::endl;
|
||||
|
||||
using CellSetType = vtkm::cont::CellSetExplicit<>;
|
||||
using OutCellSetType = vtkm::cont::CellSetPermutation<CellSetType>;
|
||||
|
||||
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DExplicitDataSet0();
|
||||
|
||||
CellSetType cellset;
|
||||
dataset.GetCellSet().AsCellSet(cellset);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar;
|
||||
dataset.GetField("cellvar").GetData().AsArrayHandle(cellvar);
|
||||
|
||||
vtkm::worklet::Threshold threshold;
|
||||
OutCellSetType outCellSet =
|
||||
threshold.Run(cellset, cellvar, vtkm::cont::Field::Association::CELL_SET, HasValue(100.1f));
|
||||
|
||||
VTKM_TEST_ASSERT(outCellSet.GetNumberOfCells() == 1, "Wrong number of cells");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray = threshold.ProcessCellField(cellvar);
|
||||
|
||||
VTKM_TEST_ASSERT(cellFieldArray.GetNumberOfValues() == 1 &&
|
||||
cellFieldArray.ReadPortal().Get(0) == 100.1f,
|
||||
"Wrong cell field data");
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
this->TestUniform2D(false);
|
||||
this->TestUniform2D(true);
|
||||
this->TestUniform3D(false);
|
||||
this->TestUniform3D(true);
|
||||
this->TestExplicit3D();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int UnitTestThreshold(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestingThreshold(), argc, argv);
|
||||
}
|
Loading…
Reference in New Issue
Block a user