Simplify ExtractStructured implementation

This commit is contained in:
Sujin Philip 2017-05-23 15:18:50 -04:00
parent d618728356
commit fbabd58222
5 changed files with 600 additions and 706 deletions

@ -37,28 +37,28 @@ public:
// Set the bounding box for the volume of interest
VTKM_CONT
vtkm::Bounds GetVOI() const { return this->VOI; }
vtkm::RangeId3 GetVOI() const { return this->VOI; }
VTKM_CONT
void SetVOI(int i0, int i1, int j0, int j1, int k0, int k1)
void SetVOI(vtkm::Id i0, vtkm::Id i1, vtkm::Id j0, vtkm::Id j1, vtkm::Id k0, vtkm::Id k1)
{
this->VOI = vtkm::Bounds(i0, i1, j0, j1, k0, k1);
this->VOI = vtkm::RangeId3(i0, i1, j0, j1, k0, k1);
}
VTKM_CONT
void SetVOI(int bounds[6]) { this->VOI = vtkm::Bounds(bounds); }
void SetVOI(vtkm::Id extents[6]) { this->VOI = vtkm::RangeId3(extents); }
VTKM_CONT
void SetVOI(vtkm::Id3 minPoint, vtkm::Id3 maxPoint)
{
this->VOI = vtkm::Bounds(minPoint, maxPoint);
this->VOI = vtkm::RangeId3(minPoint, maxPoint);
}
VTKM_CONT
void SetVOI(const vtkm::Bounds& voi) { this->VOI = voi; }
void SetVOI(const vtkm::RangeId3& voi) { this->VOI = voi; }
// Sampling rate
VTKM_CONT
vtkm::Id3 GetSampleRate() const { return this->SampleRate; }
VTKM_CONT
void SetSampleRate(int i, int j, int k) { this->SampleRate = vtkm::Id3(i, j, k); }
void SetSampleRate(vtkm::Id i, vtkm::Id j, vtkm::Id k) { this->SampleRate = vtkm::Id3(i, j, k); }
VTKM_CONT
void SetSampleRate(vtkm::Id3 sampleRate) { this->SampleRate = sampleRate; }
@ -83,7 +83,7 @@ public:
const DeviceAdapter& tag);
private:
vtkm::Bounds VOI;
vtkm::RangeId3 VOI;
vtkm::Id3 SampleRate;
bool IncludeBoundary;
vtkm::worklet::ExtractStructured Worklet;

@ -28,7 +28,7 @@ namespace filter
//-----------------------------------------------------------------------------
inline VTKM_CONT ExtractStructured::ExtractStructured()
: vtkm::filter::FilterDataSet<ExtractStructured>()
, VOI(vtkm::Bounds(1, 1, 1, 1, 1, 1))
, VOI(vtkm::RangeId3(0, -1, 0, -1, 0, -1))
, SampleRate(vtkm::Id3(1, 1, 1))
, IncludeBoundary(false)
, Worklet()
@ -39,16 +39,27 @@ inline VTKM_CONT ExtractStructured::ExtractStructured()
template <typename DerivedPolicy, typename DeviceAdapter>
inline VTKM_CONT vtkm::filter::ResultDataSet ExtractStructured::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::filter::PolicyBase<DerivedPolicy>&,
const DeviceAdapter&)
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
const DeviceAdapter& device)
{
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::CoordinateSystem& coordinates =
input.GetCoordinateSystem(this->GetActiveCellSetIndex());
vtkm::cont::DataSet output = this->Worklet.Run(
cells, coordinates, this->VOI, this->SampleRate, this->IncludeBoundary, DeviceAdapter());
auto cellset = this->Worklet.Run(vtkm::filter::ApplyPolicyStructured(cells, policy),
this->VOI,
this->SampleRate,
this->IncludeBoundary,
device);
auto coords =
this->Worklet.MapCoordinates(vtkm::filter::ApplyPolicy(coordinates, policy), device);
vtkm::cont::CoordinateSystem outputCoordinates(coordinates.GetName(),
vtkm::cont::DynamicArrayHandle(coords));
vtkm::cont::DataSet output;
output.AddCellSet(vtkm::cont::DynamicCellSet(cellset));
output.AddCoordinateSystem(outputCoordinates);
return vtkm::filter::ResultDataSet(output);
}
@ -61,10 +72,9 @@ inline VTKM_CONT bool ExtractStructured::DoMapField(
const vtkm::filter::PolicyBase<DerivedPolicy>&,
const DeviceAdapter& device)
{
// point data is copied as is because it was not collapsed
if (fieldMeta.IsPointField())
{
vtkm::cont::ArrayHandle<T, StorageType> output = this->Worklet.ProcessPointField(input, device);
vtkm::cont::ArrayHandle<T> output = this->Worklet.ProcessPointField(input, device);
result.GetDataSet().AddField(fieldMeta.AsField(output));
return true;
@ -73,7 +83,7 @@ inline VTKM_CONT bool ExtractStructured::DoMapField(
// cell data must be scattered to the cells created per input cell
if (fieldMeta.IsCellField())
{
vtkm::cont::ArrayHandle<T, StorageType> output = this->Worklet.ProcessCellField(input, device);
vtkm::cont::ArrayHandle<T> output = this->Worklet.ProcessCellField(input, device);
result.GetDataSet().AddField(fieldMeta.AsField(output));
return true;

@ -37,11 +37,11 @@ public:
vtkm::cont::DataSet dataset = MakeTestDataSet().Make2DUniformDataSet1();
vtkm::filter::ResultDataSet result;
vtkm::Bounds bounds(1, 3, 1, 3, 0, 0);
vtkm::RangeId3 range(1, 4, 1, 4, 0, 1);
vtkm::Id3 sample(1, 1, 1);
vtkm::filter::ExtractStructured extract;
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
result = extract.Execute(dataset);
@ -86,7 +86,7 @@ public:
vtkm::filter::ExtractStructured extract;
// VOI within dataset
extract.SetVOI(1, 3, 1, 3, 1, 3);
extract.SetVOI(1, 4, 1, 4, 1, 4);
extract.SetSampleRate(1, 1, 1);
result = extract.Execute(dataset);
@ -132,7 +132,7 @@ public:
// VOI surrounds dataset
vtkm::Id3 minPoint(-1, -1, -1);
vtkm::Id3 maxPoint(7, 7, 7);
vtkm::Id3 maxPoint(8, 8, 8);
extract.SetVOI(minPoint, maxPoint);
extract.SetSampleRate(1, 1, 1);
@ -178,9 +178,9 @@ public:
vtkm::filter::ExtractStructured extract;
// VOI surrounds dataset
vtkm::Bounds bounds(-1, 2, -1, 2, -1, 2);
vtkm::RangeId3 range(-1, 3, -1, 3, -1, 3);
vtkm::Id3 sample(1, 1, 1);
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
result = extract.Execute(dataset);
@ -223,10 +223,10 @@ public:
vtkm::filter::ExtractStructured extract;
// Bounding box intersects dataset on far boundary
vtkm::Bounds bounds(1, 7, 1, 7, 1, 7);
// RangeId3 intersects dataset on far boundary
vtkm::RangeId3 range(1, 8, 1, 8, 1, 8);
vtkm::Id3 sample(1, 1, 1);
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
result = extract.Execute(dataset);
@ -270,10 +270,10 @@ public:
vtkm::filter::ExtractStructured extract;
// Bounding box intersects dataset without corner
vtkm::Bounds bounds(2, 7, 1, 3, 1, 3);
// RangeId3 intersects dataset without corner
vtkm::RangeId3 range(2, 8, 1, 4, 1, 4);
vtkm::Id3 sample(1, 1, 1);
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
result = extract.Execute(dataset);
@ -317,10 +317,10 @@ public:
vtkm::filter::ExtractStructured extract;
// Bounding box intersects dataset with plane
vtkm::Bounds bounds(2, 7, 1, 1, 1, 3);
// RangeId3 intersects dataset with plane
vtkm::RangeId3 range(2, 8, 1, 2, 1, 4);
vtkm::Id3 sample(1, 1, 1);
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
result = extract.Execute(dataset);
@ -363,10 +363,10 @@ public:
vtkm::filter::ExtractStructured extract;
// Bounding box within data set with sampling
vtkm::Bounds bounds(0, 4, 0, 4, 1, 3);
// RangeId3 within data set with sampling
vtkm::RangeId3 range(0, 5, 0, 5, 1, 4);
vtkm::Id3 sample(2, 2, 1);
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
result = extract.Execute(dataset);
@ -409,10 +409,10 @@ public:
vtkm::filter::ExtractStructured extract;
// Bounding box within data set with sampling
vtkm::Bounds bounds(0, 4, 0, 4, 1, 3);
// RangeId3 within data set with sampling
vtkm::RangeId3 range(0, 5, 0, 5, 1, 4);
vtkm::Id3 sample(3, 3, 2);
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
result = extract.Execute(dataset);
@ -454,10 +454,10 @@ public:
vtkm::filter::ExtractStructured extract;
// Bounding box within data set with sampling
vtkm::Bounds bounds(0, 4, 0, 4, 1, 3);
// RangeId3 within data set with sampling
vtkm::RangeId3 range(0, 5, 0, 5, 1, 4);
vtkm::Id3 sample(3, 3, 2);
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
extract.SetIncludeBoundary(true);
@ -503,10 +503,10 @@ public:
vtkm::filter::ExtractStructured extract;
// Bounds
vtkm::Bounds bounds(0, 1, 0, 1, 0, 0);
// RangeId3
vtkm::RangeId3 range(0, 2, 0, 2, 0, 1);
vtkm::Id3 sample(1, 1, 1);
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
result = extract.Execute(dataset);
@ -547,11 +547,10 @@ public:
vtkm::filter::ExtractStructured extract;
// Bounds and subsample
vtkm::Bounds bounds(0, 1, 0, 1, 0, 1);
// RangeId3 and subsample
vtkm::RangeId3 range(0, 2, 0, 2, 0, 2);
vtkm::Id3 sample(1, 1, 1);
extract.SetVOI(bounds);
extract.SetVOI(range);
extract.SetSampleRate(sample);
result = extract.Execute(dataset);

File diff suppressed because it is too large Load Diff

@ -20,7 +20,6 @@
#include <vtkm/worklet/ExtractStructured.h>
#include <vtkm/Bounds.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
@ -33,7 +32,7 @@ class TestingExtractStructured
public:
void TestUniform2D() const
{
std::cout << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform 2D" << std::endl;
typedef vtkm::cont::CellSetStructured<2> CellSetType;
// Create the input uniform cell set
@ -41,24 +40,23 @@ public:
CellSetType cellSet;
dataSet.GetCellSet(0).CopyTo(cellSet);
// Bounds and subsample
vtkm::Bounds bounds(1, 3, 1, 3, 0, 0);
// RangeId3 and subsample
vtkm::RangeId3 range(1, 4, 1, 4, 0, 1);
vtkm::Id3 sample(1, 1, 1);
bool includeBoundary = false;
vtkm::worklet::ExtractStructured worklet;
vtkm::cont::DataSet outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds, sample, includeBoundary, DeviceAdapter());
auto outCellSet = worklet.Run(cellSet, range, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 9),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 9),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 4),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 4),
"Wrong result for ExtractStructured worklet");
}
void TestUniform3D() const
{
std::cout << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform 3D" << std::endl;
typedef vtkm::cont::CellSetStructured<3> CellSetType;
// Create the input uniform cell set
@ -67,63 +65,57 @@ public:
dataSet.GetCellSet(0).CopyTo(cellSet);
vtkm::worklet::ExtractStructured worklet;
vtkm::cont::DataSet outDataSet;
vtkm::worklet::ExtractStructured::DynamicCellSetStructured outCellSet;
// Bounding box within dataset
vtkm::Bounds bounds0(1, 3, 1, 3, 1, 3);
// RangeId3 within dataset
vtkm::RangeId3 range0(1, 4, 1, 4, 1, 4);
vtkm::Id3 sample(1, 1, 1);
bool includeBoundary = false;
outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds0, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 27),
outCellSet = worklet.Run(cellSet, range0, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 27),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 8),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
// Bounding box surrounds dataset
vtkm::Bounds bounds1(-1, 7, -1, 7, -1, 7);
outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds1, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 125),
// RangeId3 surrounds dataset
vtkm::RangeId3 range1(-1, 8, -1, 8, -1, 8);
outCellSet = worklet.Run(cellSet, range1, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 125),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 64),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 64),
"Wrong result for ExtractStructured worklet");
// Bounding box intersects dataset on near boundary
vtkm::Bounds bounds2(-1, 2, -1, 2, -1, 2);
outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds2, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 27),
// RangeId3 intersects dataset on near boundary
vtkm::RangeId3 range2(-1, 3, -1, 3, -1, 3);
outCellSet = worklet.Run(cellSet, range2, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 27),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 8),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
// Bounding box intersects dataset on far boundary
vtkm::Bounds bounds3(1, 7, 1, 7, 1, 7);
outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds3, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 64),
// RangeId3 intersects dataset on far boundary
vtkm::RangeId3 range3(1, 8, 1, 8, 1, 8);
outCellSet = worklet.Run(cellSet, range3, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 64),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 27),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 27),
"Wrong result for ExtractStructured worklet");
// Bounding box intersects dataset without corner
vtkm::Bounds bounds4(2, 7, 1, 3, 1, 3);
outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds4, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 27),
// RangeId3 intersects dataset without corner
vtkm::RangeId3 range4(2, 8, 1, 4, 1, 4);
outCellSet = worklet.Run(cellSet, range4, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 27),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 8),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
// Bounding box intersects dataset with plane
vtkm::Bounds bounds5(2, 7, 1, 1, 1, 3);
outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds5, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 9),
// RangeId3 intersects dataset with plane
vtkm::RangeId3 range5(2, 8, 1, 2, 1, 4);
outCellSet = worklet.Run(cellSet, range5, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 9),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 4),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 4),
"Wrong result for ExtractStructured worklet");
}
@ -138,45 +130,42 @@ public:
dataSet.GetCellSet(0).CopyTo(cellSet);
vtkm::worklet::ExtractStructured worklet;
vtkm::cont::DataSet outDataSet;
vtkm::worklet::ExtractStructured::DynamicCellSetStructured outCellSet;
// Bounding box within data set with sampling
vtkm::Bounds bounds0(0, 4, 0, 4, 1, 3);
// RangeId3 within data set with sampling
vtkm::RangeId3 range0(0, 5, 0, 5, 1, 4);
vtkm::Id3 sample0(2, 2, 1);
bool includeBoundary0 = false;
outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds0, sample0, includeBoundary0, DeviceAdapter());
outCellSet = worklet.Run(cellSet, range0, sample0, includeBoundary0, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 27),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 27),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 8),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
// Bounds and subsample
vtkm::Bounds bounds1(0, 4, 0, 4, 1, 3);
// RangeId3 and subsample
vtkm::RangeId3 range1(0, 5, 0, 5, 1, 4);
vtkm::Id3 sample1(3, 3, 2);
bool includeBoundary1 = false;
outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds1, sample1, includeBoundary1, DeviceAdapter());
outCellSet = worklet.Run(cellSet, range1, sample1, includeBoundary1, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 8),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 8),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 1),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 1),
"Wrong result for ExtractStructured worklet");
// Bounds and subsample
vtkm::Bounds bounds2(0, 4, 0, 4, 1, 3);
// RangeId3 and subsample
vtkm::RangeId3 range2(0, 5, 0, 5, 1, 4);
vtkm::Id3 sample2(3, 3, 2);
bool includeBoundary2 = true;
outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds2, sample2, includeBoundary2, DeviceAdapter());
outCellSet = worklet.Run(cellSet, range2, sample2, includeBoundary2, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 18),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 18),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 4),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 4),
"Wrong result for ExtractStructured worklet");
}
@ -190,19 +179,18 @@ public:
CellSetType cellSet;
dataSet.GetCellSet(0).CopyTo(cellSet);
// Bounds and subsample
vtkm::Bounds bounds(0, 1, 0, 1, 0, 0);
// RangeId3 and subsample
vtkm::RangeId3 range(0, 2, 0, 2, 0, 1);
vtkm::Id3 sample(1, 1, 1);
bool includeBoundary = false;
// Extract subset
vtkm::worklet::ExtractStructured worklet;
vtkm::cont::DataSet outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds, sample, includeBoundary, DeviceAdapter());
auto outCellSet = worklet.Run(cellSet, range, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 4),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 4),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 1),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 1),
"Wrong result for ExtractStructured worklet");
}
@ -216,19 +204,18 @@ public:
CellSetType cellSet;
dataSet.GetCellSet(0).CopyTo(cellSet);
// Bounds and subsample
vtkm::Bounds bounds(0, 1, 0, 1, 0, 1);
// RangeId3 and subsample
vtkm::RangeId3 range(0, 2, 0, 2, 0, 2);
vtkm::Id3 sample(1, 1, 1);
bool includeBoundary = false;
// Extract subset
vtkm::worklet::ExtractStructured worklet;
vtkm::cont::DataSet outDataSet = worklet.Run(
cellSet, dataSet.GetCoordinateSystem(0), bounds, sample, includeBoundary, DeviceAdapter());
auto outCellSet = worklet.Run(cellSet, range, sample, includeBoundary, DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 8),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 8),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 1),
VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 1),
"Wrong result for ExtractStructured worklet");
}