Add subsample and include boundary

This commit is contained in:
Patricia Kroll Fasel - 090207 2017-04-27 14:53:51 -06:00
parent 14066d8692
commit 0e3a98f827
5 changed files with 378 additions and 245 deletions

@ -35,15 +35,37 @@ public:
// Set the bounding box for the volume of interest
VTKM_CONT
const vtkm::Bounds& GetVOI() const { return this->VOI; }
vtkm::Bounds GetVOI() const { return this->VOI; }
VTKM_CONT
void SetVOI(vtkm::Bounds voi) { this->VOI = voi; }
void SetVOI(const int &i0, const int &i1,
const int &j0, const int &j1,
const int &k0, const int &k1)
{ this->VOI = vtkm::Bounds(i0, i1, j0, j1, k0, k1); }
VTKM_CONT
void SetVOI(const int bounds[6])
{ this->VOI = vtkm::Bounds(bounds); }
VTKM_CONT
void SetVOI(const vtkm::Id3 &minPoint, const vtkm::Id3 &maxPoint)
{ this->VOI = vtkm::Bounds(minPoint, maxPoint); }
VTKM_CONT
void SetVOI(const vtkm::Bounds &voi)
{ this->VOI = voi; }
// Sampling rate
VTKM_CONT
const vtkm::Id3& GetSampleRate() const { return this->SampleRate; }
vtkm::Id3 GetSampleRate() const { return this->SampleRate; }
VTKM_CONT
void SetSampleRate(vtkm::Id3 sampleRate) { this->SampleRate = sampleRate; }
void SetSampleRate(const int & i, const int &j, const int &k)
{ this->SampleRate = vtkm::Id3(i,j,k); }
VTKM_CONT
void SetSampleRate(vtkm::Id3 sampleRate) { this->SampleRate = sampleRate; }
// Include the outer boundary on a subsample
VTKM_CONT
bool GetIncludeBoundary() { return this->IncludeBoundary; }
VTKM_CONT
void SetIncludeBoundary(const bool &value) { this->IncludeBoundary = value; }
template<typename DerivedPolicy, typename DeviceAdapter>
VTKM_CONT
@ -63,6 +85,7 @@ public:
private:
vtkm::Bounds VOI;
vtkm::Id3 SampleRate;
bool IncludeBoundary;
vtkm::worklet::ExtractStructured Worklet;
};

@ -27,6 +27,9 @@ namespace filter {
inline VTKM_CONT
ExtractStructured::ExtractStructured():
vtkm::filter::FilterDataSet<ExtractStructured>(),
VOI(vtkm::Bounds(1,1,1,1,1,1)),
SampleRate(vtkm::Id3(1,1,1)),
IncludeBoundary(false),
Worklet()
{
}
@ -37,7 +40,7 @@ template<typename DerivedPolicy,
inline VTKM_CONT
vtkm::filter::ResultDataSet ExtractStructured::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
const vtkm::filter::PolicyBase<DerivedPolicy>&,
const DeviceAdapter&)
{
const vtkm::cont::DynamicCellSet& cells =
@ -50,6 +53,7 @@ vtkm::filter::ResultDataSet ExtractStructured::DoExecute(
coordinates,
this->VOI,
this->SampleRate,
this->IncludeBoundary,
DeviceAdapter());
return vtkm::filter::ResultDataSet(output);

@ -55,14 +55,18 @@ public:
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 4),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 71.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(8) == 91.0f, "Wrong point field data");
@ -72,17 +76,15 @@ public:
void TestUniform3D0() const
{
std::cout << std::endl << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::ResultDataSet result;
vtkm::filter::ExtractStructured extract;
// VOI within dataset
vtkm::Bounds bounds(1,3, 1,3, 1,3);
vtkm::Id3 sample(1,1,1);
extract.SetVOI(bounds);
extract.SetSampleRate(sample);
extract.SetVOI(1,3, 1,3, 1,3);
extract.SetSampleRate(1,1,1);
result = extract.Execute(dataset);
@ -96,14 +98,18 @@ public:
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 99.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(26) == 97.0f, "Wrong point field data");
@ -113,17 +119,17 @@ public:
void TestUniform3D1() const
{
std::cout << std::endl << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::ResultDataSet result;
vtkm::filter::ExtractStructured extract;
// VOI surrounds dataset
vtkm::Bounds bounds(-1,7, -1,7, -1,7);
vtkm::Id3 sample(1,1,1);
extract.SetVOI(bounds);
extract.SetSampleRate(sample);
vtkm::Id3 minPoint(-1,-1,-1);
vtkm::Id3 maxPoint(7,7,7);
extract.SetVOI(minPoint, maxPoint);
extract.SetSampleRate(1,1,1);
result = extract.Execute(dataset);
@ -137,14 +143,18 @@ public:
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 64),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(31) == 99.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(93) == 97.0f, "Wrong point field data");
@ -154,7 +164,7 @@ public:
void TestUniform3D2() const
{
std::cout << std::endl << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::ResultDataSet result;
@ -178,14 +188,18 @@ public:
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 0.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(26) == 15.0f, "Wrong point field data");
@ -195,7 +209,7 @@ public:
void TestUniform3D3() const
{
std::cout << std::endl << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::ResultDataSet result;
@ -219,14 +233,18 @@ public:
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 27),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 99.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(63) == 0.0f, "Wrong point field data");
@ -236,7 +254,7 @@ public:
void TestUniform3D4() const
{
std::cout << std::endl << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::ResultDataSet result;
@ -260,14 +278,18 @@ public:
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 90.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(26) == 0.0f, "Wrong point field data");
@ -277,7 +299,7 @@ public:
void TestUniform3D5() const
{
std::cout << std::endl << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::ResultDataSet result;
@ -301,14 +323,18 @@ public:
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 4),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 90.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(8) == 0.0f, "Wrong point field data");
@ -318,7 +344,7 @@ public:
void TestUniform3D6() const
{
std::cout << std::endl << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::ResultDataSet result;
@ -342,18 +368,18 @@ public:
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
std::cout << outPointData.GetPortalConstControl().Get(0) << std::endl;
std::cout << outPointData.GetPortalConstControl().Get(26) << std::endl;
std::cout << outCellData.GetPortalConstControl().Get(0) << std::endl;
std::cout << outCellData.GetPortalConstControl().Get(3) << std::endl;
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 0.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(26) == 0.0f, "Wrong point field data");
@ -363,7 +389,7 @@ std::cout << outCellData.GetPortalConstControl().Get(3) << std::endl;
void TestUniform3D7() const
{
std::cout << std::endl << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::ResultDataSet result;
@ -387,23 +413,74 @@ std::cout << outCellData.GetPortalConstControl().Get(3) << std::endl;
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 1),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 0.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(7) == 97.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outCellData.GetPortalConstControl().Get(0) == 16.0f, "Wrong cell field data");
}
void TestUniform3D8() const
{
std::cout << "Testing extract structured uniform" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::ResultDataSet result;
vtkm::filter::ExtractStructured extract;
// Bounding box within data set with sampling
vtkm::Bounds bounds(0,4, 0,4, 1,3);
vtkm::Id3 sample(3,3,2);
extract.SetVOI(bounds);
extract.SetSampleRate(sample);
extract.SetIncludeBoundary(true);
result = extract.Execute(dataset);
extract.MapFieldOntoOutput(result, dataset.GetField("pointvar") );
extract.MapFieldOntoOutput(result, dataset.GetField("cellvar") );
vtkm::cont::DataSet output = result.GetDataSet();
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(), 18),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 4),
"Wrong result for ExtractStructured worklet");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 0.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(4) == 99.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(13) == 97.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outCellData.GetPortalConstControl().Get(0) == 16.0f, "Wrong cell field data");
VTKM_TEST_ASSERT(outCellData.GetPortalConstControl().Get(3) == 31.0f, "Wrong cell field data");
}
void TestRectilinear2D() const
{
std::cout << std::endl << "Testing extract structured rectilinear" << std::endl;
std::cout << "Testing extract structured rectilinear" << std::endl;
vtkm::cont::DataSet dataset = MakeTestDataSet().Make2DRectilinearDataSet0();
vtkm::filter::ResultDataSet result;
@ -427,14 +504,18 @@ std::cout << outCellData.GetPortalConstControl().Get(3) << std::endl;
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 1),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 0.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(3) == 4.0f, "Wrong point field data");
@ -468,14 +549,18 @@ std::cout << outCellData.GetPortalConstControl().Get(3) << std::endl;
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(), 1),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(output.HasField("pointvar"), "Point field not mapped correctly");
VTKM_TEST_ASSERT(output.HasField("cellvar"), "Cell field not mapped correctly");
vtkm::cont::ArrayHandle<vtkm::Float32> outPointData;
vtkm::cont::ArrayHandle<vtkm::Float32> outCellData;
output.GetField("pointvar").GetData().CopyTo(outPointData);
output.GetField("cellvar").GetData().CopyTo(outCellData);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfPoints(),
outPointData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(test_equal(output.GetCellSet(0).GetNumberOfCells(),
outCellData.GetNumberOfValues()),
"Data/Geometry mismatch for ExtractStructured filter");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(0) == 0.0f, "Wrong point field data");
VTKM_TEST_ASSERT(outPointData.GetPortalConstControl().Get(7) == 10.0f, "Wrong point field data");
@ -493,6 +578,7 @@ std::cout << outCellData.GetPortalConstControl().Get(3) << std::endl;
this->TestUniform3D5();
this->TestUniform3D6();
this->TestUniform3D7();
this->TestUniform3D8();
this->TestRectilinear2D();
this->TestRectilinear3D();
}

@ -28,19 +28,18 @@
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Field.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/WorkletMapTopology.h>
#include <vtkm/worklet/ScatterCounting.h>
#include <vtkm/Math.h>
namespace vtkm {
namespace worklet {
//
// Distribute input point/cell data to subset output point/cell data
// Distribute input point/cell data to subset/subsample output data
//
struct DistributeData : public vtkm::worklet::WorkletMapField
{
@ -79,7 +78,7 @@ public:
ExtractStructured() {}
//
// Determine if point index is within range of the subset and subsampling
// Create map of input points to output points with subset/subsample
//
class CreatePointMap : public vtkm::worklet::WorkletMapField
{
@ -92,99 +91,138 @@ public:
vtkm::Id PlaneSize;
vtkm::Bounds OutBounds;
vtkm::Id3 Sample;
bool IncludeBoundary;
VTKM_CONT
CreatePointMap(const vtkm::Id3 inDimension,
const vtkm::Bounds &outBounds,
const vtkm::Id3 &sample) :
const vtkm::Id3 &sample,
const bool includeBoundary) :
RowSize(inDimension[0]),
PlaneSize(inDimension[1] * inDimension[0]),
PlaneSize(inDimension[0] * inDimension[1]),
OutBounds(outBounds),
Sample(sample)
{}
Sample(sample),
IncludeBoundary(includeBoundary) {}
VTKM_EXEC
vtkm::IdComponent operator()(const vtkm::Id index) const
{
vtkm::IdComponent passValue = 0;
// Position of this point or cell in the grid
// Position of this point in the grid
vtkm::Id k = index / PlaneSize;
vtkm::Id j = (index % PlaneSize) / RowSize;
vtkm::Id i = index % RowSize;
// Within the subset range
// Turn on points if within the subset bounding box
vtkm::Id3 ijk = vtkm::Id3(i, j, k);
if (OutBounds.Contains(ijk))
{
// Within the subsampling criteria
vtkm::Id3 minPt = vtkm::make_Vec(OutBounds.X.Min,
OutBounds.Y.Min,
OutBounds.Z.Min);
if (((i - minPt[0]) % Sample[0]) == 0 &&
((j - minPt[1]) % Sample[1]) == 0 &&
((k - minPt[2]) % Sample[2]) == 0)
{
passValue = 1;
}
passValue = 1;
}
// Turn off points not within subsampling
vtkm::Id3 minPt = vtkm::make_Vec(OutBounds.X.Min, OutBounds.Y.Min, OutBounds.Z.Min);
vtkm::Id3 value = vtkm::make_Vec((i - minPt[0]) % Sample[0],
(j - minPt[1]) % Sample[1],
(k - minPt[2]) % Sample[2]);
// If include boundary then max boundary is also within subsampling
if (IncludeBoundary)
{
if (i == OutBounds.X.Max) value[0] = 0;
if (j == OutBounds.Y.Max) value[1] = 0;
if (k == OutBounds.Z.Max) value[2] = 0;
}
// If the value for the point is not 0 in all dimensions it is not in sample
if (value != vtkm::Id3(0,0,0))
{
passValue = 0;
}
return passValue;
}
};
//
// Determine if cell index is within range of the subset and subsampling
// Create map of input cells to output cells with subset/subsample
//
class CreateCellMap : public vtkm::worklet::WorkletMapField
class CreateCellMap : public vtkm::worklet::WorkletMapPointToCell
{
public:
typedef void ControlSignature(FieldIn<IdType> index,
FieldOut<IdComponentType> passValue);
typedef _2 ExecutionSignature(_1);
typedef void ControlSignature(CellSetIn cellset,
WholeArrayIn<IdComponentType> pointMap,
FieldOutCell<IdComponentType> passValue);
typedef _3 ExecutionSignature(PointCount, PointIndices, _2);
vtkm::Id3 InDimension;
vtkm::Id3 OutDimension;
vtkm::Id RowSize;
vtkm::Id PlaneSize;
vtkm::Bounds OutBounds;
vtkm::Id3 Sample;
VTKM_CONT
CreateCellMap(const vtkm::Id3 inDimension,
const vtkm::Bounds &outBounds,
const vtkm::Id3 &sample) :
CreateCellMap(const vtkm::Id3 &inDimension,
const vtkm::Id3 &outDimension) :
InDimension(inDimension),
OutDimension(outDimension),
RowSize(inDimension[0]),
PlaneSize(inDimension[0] * inDimension[1]),
OutBounds(outBounds),
Sample(sample) {}
PlaneSize(inDimension[0] * inDimension[1]) {}
template <typename ConnectivityInVec, typename InPointMap>
VTKM_EXEC
vtkm::IdComponent operator()(const vtkm::Id index) const
vtkm::IdComponent operator()(const vtkm::Id numIndices,
const ConnectivityInVec &connectivityIn,
const InPointMap &pointMap) const
{
vtkm::IdComponent passValue = 0;
// Position of this point or cell in the grid
vtkm::Id k = index / PlaneSize;
vtkm::Id j = (index % PlaneSize) / RowSize;
vtkm::Id i = index % RowSize;
// Within the subset range and sample range
// Outer point of cell must be within range or is it not used
vtkm::Id3 ijk = vtkm::Id3(i, j, k);
vtkm::Id3 ijk1 = ijk + vtkm::Id3(1,1,1);
if (OutBounds.Contains(ijk))
// If all surrounding points are in the subset, cell will be also
vtkm::IdComponent passValue = 1;
for (vtkm::IdComponent indx = 0; indx < numIndices; indx++)
{
if (Sample == vtkm::Id3(1,1,1))
if (pointMap.Get(connectivityIn[indx]) == 0)
{
passValue = 1;
passValue = 0;
}
else if (OutBounds.Contains(ijk1))
}
// Cell might still be in subset through subsampling
if (passValue == 0)
{
// If the lower left point is in the sample it is a candidate for subsample
vtkm::Id ptId = connectivityIn[0];
if (pointMap.Get(ptId) == 1)
{
// Within the subsampling criteria
vtkm::Id3 minPt = vtkm::make_Vec(OutBounds.X.Min,
OutBounds.Y.Min,
OutBounds.Z.Min);
if (((i - minPt[0]) % Sample[0]) == 0 &&
((j - minPt[1]) % Sample[1]) == 0 &&
((k - minPt[2]) % Sample[2]) == 0)
vtkm::Id3 position((ptId % RowSize), ((ptId % PlaneSize) / RowSize), (ptId / PlaneSize));
vtkm::Id newPtId;
vtkm::Id3 foundValidPoint(0,0,0);
vtkm::Id3 offset(1, RowSize, PlaneSize);
for (vtkm::IdComponent dim = 0; dim < 3; dim++)
{
if (OutDimension[dim] == 1)
{
foundValidPoint[dim] = 1;
}
else
{
// Check down the dimension for one other sampled point to complete cell
newPtId = ptId + offset[dim];
vtkm::Id indx = position[dim] + 1;
bool done = false;
while (indx < InDimension[dim] && done == false)
{
if (pointMap.Get(newPtId) == 1)
{
foundValidPoint[dim] = 1;
done = true;
}
indx++;
newPtId += offset[dim];
}
}
}
// If there is a valid point in all dimensions cell is in sample
if (foundValidPoint == vtkm::Id3(1,1,1))
{
passValue = 1;
}
@ -194,59 +232,6 @@ public:
}
};
//
// Create maps for mapping point and cell data to subset
//
template <typename DeviceAdapter>
void CreateDataMaps(const vtkm::Id3 &pointDimension,
const vtkm::Id &numberOfPoints,
const vtkm::Id &numberOfCells,
const vtkm::Bounds &outBounds,
const vtkm::Id3 &sample,
const DeviceAdapter)
{
vtkm::cont::ArrayHandleIndex pointIndices(numberOfPoints);
vtkm::cont::ArrayHandleIndex cellIndices(numberOfCells);
std::cout << "POINT DIMENSION " << pointDimension << std::endl;
std::cout << "POINT BOUNDS " << outBounds << std::endl;
// Create the map for the input point data to output
CreatePointMap pointWorklet(pointDimension, outBounds, sample);
vtkm::worklet::DispatcherMapField<CreatePointMap> pointDispatcher(pointWorklet);
pointDispatcher.Invoke(pointIndices,
this->PointMap);
vtkm::Id count = 0;
for (vtkm::Id i = 0; i < numberOfPoints; i++)
{
std::cout << "point " << i << " = " << PointMap.GetPortalControl().Get(i) << std::endl;
if (PointMap.GetPortalControl().Get(i) == 1) count++;
}
std::cout << "Data Points " << count << std::endl;
// Create the map for the input cell data to output
vtkm::Id3 cellDimension = pointDimension - vtkm::Id3(1,1,1);
vtkm::Bounds cellBounds = outBounds;
if (cellBounds.X.Max > 1)
cellBounds.X.Max -= 1;
if (cellBounds.Y.Max > 1)
cellBounds.Y.Max -= 1;
if (cellBounds.Z.Max > 1)
cellBounds.Z.Max -= 1;
std::cout << "CELL DIMENSION " << cellDimension << std::endl;
std::cout << "CELL BOUNDS " << cellBounds << std::endl;
CreateCellMap cellWorklet(cellDimension, cellBounds, sample);
vtkm::worklet::DispatcherMapField<CreateCellMap> cellDispatcher(cellWorklet);
cellDispatcher.Invoke(cellIndices,
this->CellMap);
count = 0;
for (vtkm::Id i = 0; i < numberOfCells; i++)
{
if (CellMap.GetPortalControl().Get(i) == 1) count++;
}
std::cout << "Data Cells " << count << std::endl;
}
//
// Uniform Structured
//
@ -258,6 +243,7 @@ std::cout << "Data Cells " << count << std::endl;
const vtkm::cont::CoordinateSystem &coordinates,
const vtkm::Bounds outBounds,
const vtkm::Id3 &sample,
const bool &includeBoundary,
DeviceAdapter)
{
typedef vtkm::cont::ArrayHandleUniformPointCoordinates UniformArrayHandle;
@ -273,29 +259,32 @@ std::cout << "Data Cells " << count << std::endl;
// Sizes and values of input Uniform Structured
vtkm::Id3 inDimension = Coordinates.GetDimensions();
vtkm::Vec<vtkm::FloatDefault,3> inOrigin = Coordinates.GetOrigin();
vtkm::Vec<vtkm::FloatDefault,3> inSpacing = Coordinates.GetSpacing();
std::cout << "UNIFORM IN DIMENSION " << inDimension << std::endl;
std::cout << "UNIFORM IN ORIGIN " << inOrigin << std::endl;
std::cout << "UNIFORM IN SPACING " << inSpacing << std::endl;
// Sizes of output Uniform with subsets and sampling
vtkm::Id3 outDimension = vtkm::make_Vec(outBounds.X.Max - outBounds.X.Min + 1,
outBounds.Y.Max - outBounds.Y.Min + 1,
outBounds.Z.Max - outBounds.Z.Min + 1);
// Calculate output subset dimension
// minBound will not change because first point or cell is always included
// maxBound is the same if no sampling, or if sample point lands on boundary,
// or if include boundary is set
// Otherwise maxBound will be the last stride point
vtkm::Id3 lastIndex = vtkm::make_Vec(outBounds.X.Max - outBounds.X.Min,
outBounds.Y.Max - outBounds.Y.Min,
outBounds.Z.Max - outBounds.Z.Min);
vtkm::Id3 outDimension = lastIndex + vtkm::Id3(1,1,1);
// Adjust for sampling and include boundary
for (vtkm::IdComponent dim = 0; dim < outDim; dim++)
{
if (sample[dim] > 1)
if (sample[dim] != 1)
{
outDimension[dim] = outDimension[dim] / sample[dim] + 1;
outDimension[dim] = 1 + (lastIndex[dim] / sample[dim]);
if (includeBoundary == true && (lastIndex[dim] % sample[dim] != 0))
{
outDimension[dim] += 1;
}
}
}
vtkm::Vec<vtkm::FloatDefault,3> outOrigin = vtkm::make_Vec(0,0,0);
vtkm::Vec<vtkm::FloatDefault,3> outSpacing = vtkm::make_Vec(1,1,1);
std::cout << "UNIFORM OUT DIMENSION " << outDimension << std::endl;
std::cout << "UNIFORM OUT ORIGIN " << outOrigin << std::endl;
std::cout << "UNIFORM OUT SPACING " << outSpacing << std::endl;
// Create output dataset which needs modified coordinate system and cellset
vtkm::cont::DataSet output;
@ -357,16 +346,24 @@ std::cout << "Data Cells " << count << std::endl;
output.AddCellSet(outCellSet);
}
}
std::cout << "Geometry Points " << output.GetCellSet(0).GetNumberOfPoints() << std::endl;
std::cout << "Geometry Cells " << output.GetCellSet(0).GetNumberOfCells() << std::endl;
// Calculate and save the maps of point and cell data to subset
CreateDataMaps(inDimension,
cellSet.GetNumberOfPoints(),
cellSet.GetNumberOfCells(),
outBounds,
sample,
DeviceAdapter());
// Create the map for the input point data to output
vtkm::cont::ArrayHandleIndex pointIndices(cellSet.GetNumberOfPoints());
CreatePointMap pointMap(inDimension,
outBounds,
sample,
includeBoundary);
vtkm::worklet::DispatcherMapField<CreatePointMap> pointDispatcher(pointMap);
pointDispatcher.Invoke(pointIndices,
this->PointMap);
// Create the map for the input cell data to output
CreateCellMap cellMap(inDimension,
outDimension);
vtkm::worklet::DispatcherMapTopology<CreateCellMap> cellDispatcher(cellMap);
cellDispatcher.Invoke(cellSet,
this->PointMap,
this->CellMap);
return output;
}
@ -382,6 +379,7 @@ std::cout << "Geometry Cells " << output.GetCellSet(0).GetNumberOfCells() << std
const vtkm::cont::CoordinateSystem &coordinates,
const vtkm::Bounds &outBounds,
const vtkm::Id3 &sample,
const bool &includeBoundary,
DeviceAdapter)
{
typedef vtkm::cont::ArrayHandle<vtkm::FloatDefault> DefaultHandle;
@ -402,31 +400,25 @@ std::cout << "Geometry Cells " << output.GetCellSet(0).GetNumberOfCells() << std
vtkm::Id3 inDimension(X.GetNumberOfValues(),
Y.GetNumberOfValues(),
Z.GetNumberOfValues());
std::cout << "Number of x coordinates " << inDimension[0] << std::endl;
std::cout << "Number of y coordinates " << inDimension[1] << std::endl;
std::cout << "Number of z coordinates " << inDimension[2] << std::endl;
for (vtkm::Id x = 0; x < inDimension[0]; x++)
std::cout << "X " << x << " = " << X.Get(x) << std::endl;
for (vtkm::Id y = 0; y < inDimension[1]; y++)
std::cout << "Y " << y << " = " << Y.Get(y) << std::endl;
for (vtkm::Id z = 0; z < inDimension[2]; z++)
std::cout << "Z " << z << " = " << Z.Get(z) << std::endl;
// Calculate output subset dimension
vtkm::Id3 lastIndex = vtkm::make_Vec(outBounds.X.Max - outBounds.X.Min,
outBounds.Y.Max - outBounds.Y.Min,
outBounds.Z.Max - outBounds.Z.Min);
vtkm::Id3 outDimension = lastIndex + vtkm::Id3(1,1,1);
vtkm::cont::DataSet output;
// Sizes and values of output Rectilinear Structured
vtkm::Id3 outDimension = vtkm::make_Vec(outBounds.X.Max - outBounds.X.Min + 1,
outBounds.Y.Max - outBounds.Y.Min + 1,
outBounds.Z.Max - outBounds.Z.Min + 1);
// Adjust for sampling and include boundary
for (vtkm::IdComponent dim = 0; dim < outDim; dim++)
{
if (sample[dim] > 1)
if (sample[dim] != 1)
{
outDimension[dim] = outDimension[dim] / sample[dim] + 1;
outDimension[dim] = 1 + lastIndex[dim] / sample[dim];
if (includeBoundary == true && (lastIndex[dim] % sample[dim] != 0))
{
outDimension[dim] += 1;
}
}
}
std::cout << "RECTILINEAR OUT DIMENSIONS " << outDimension << std::endl;
// Set output coordinate system
DefaultHandle Xc, Yc, Zc;
@ -461,13 +453,10 @@ std::cout << "Geometry Cells " << output.GetCellSet(0).GetNumberOfCells() << std
}
}
for (vtkm::Id x = 0; x < outDimension[0]; x++)
std::cout << "Xc " << x << " = " << Xc.GetPortalControl().Get(x) << std::endl;
for (vtkm::Id y = 0; y < outDimension[1]; y++)
std::cout << "Yc " << y << " = " << Yc.GetPortalControl().Get(y) << std::endl;
for (vtkm::Id z = 0; z < outDimension[2]; z++)
std::cout << "Zc " << z << " = " << Zc.GetPortalControl().Get(z) << std::endl;
// Create output dataset which needs modified coordinate system and cellset
vtkm::cont::DataSet output;
// Set the output CoordinateSystem information
CartesianArrayHandle outCoordinateData(Xc, Yc, Zc);
vtkm::cont::CoordinateSystem outCoordinates(coordinates.GetName(), outCoordinateData);
output.AddCoordinateSystem(outCoordinates);
@ -524,16 +513,24 @@ std::cout << "Geometry Cells " << output.GetCellSet(0).GetNumberOfCells() << std
output.AddCellSet(outCellSet);
}
}
std::cout << "Number of Cells " << output.GetCellSet(0).GetNumberOfCells() << std::endl;
std::cout << "Number of Points " << output.GetCellSet(0).GetNumberOfPoints() << std::endl;
// Calculate and save the maps of point and cell data to subset
CreateDataMaps(inDimension,
cellSet.GetNumberOfPoints(),
cellSet.GetNumberOfCells(),
outBounds,
sample,
DeviceAdapter());
// Create the map for the input point data to output
vtkm::cont::ArrayHandleIndex pointIndices(cellSet.GetNumberOfPoints());
CreatePointMap pointMap(inDimension,
outBounds,
sample,
includeBoundary);
vtkm::worklet::DispatcherMapField<CreatePointMap> pointDispatcher(pointMap);
pointDispatcher.Invoke(pointIndices,
this->PointMap);
// Create the map for the input cell data to output
CreateCellMap cellMap(inDimension,
outDimension);
vtkm::worklet::DispatcherMapTopology<CreateCellMap> cellDispatcher(cellMap);
cellDispatcher.Invoke(cellSet,
this->PointMap,
this->CellMap);
return output;
}
@ -546,6 +543,7 @@ std::cout << "Number of Points " << output.GetCellSet(0).GetNumberOfPoints() <<
const vtkm::cont::CoordinateSystem &coordinates,
const vtkm::Bounds &boundingBox,
const vtkm::Id3 &sample,
const bool &includeBoundary,
DeviceAdapter)
{
// Check legality of input cellset and set input dimension
@ -567,7 +565,6 @@ std::cout << "Number of Points " << output.GetCellSet(0).GetNumberOfPoints() <<
throw vtkm::cont::ErrorBadType("Only Structured cell sets allowed");
return vtkm::cont::DataSet();
}
std::cout << "INPUT DIMENSION " << inDim << std::endl;
// Check legality of requested bounds
if (boundingBox.IsNonEmpty() == false)
@ -586,9 +583,6 @@ std::cout << "Number of Points " << output.GetCellSet(0).GetNumberOfPoints() <<
// Requested bounding box intersection with input bounding box
vtkm::Bounds inBounds = coordinates.GetBounds();
vtkm::Bounds outBounds = boundingBox;
std::cout << "INPUT BOUNDING BOX " << inBounds << std::endl;
std::cout << "ORIGINAL BOUNDING BOX " << boundingBox << std::endl;
std::cout << "SAMPLE " << sample << std::endl;
if (outBounds.X.Min < inBounds.X.Min)
outBounds.X.Min = inBounds.X.Min;
@ -602,7 +596,6 @@ std::cout << "Number of Points " << output.GetCellSet(0).GetNumberOfPoints() <<
outBounds.Z.Min = inBounds.Z.Min;
if (outBounds.Z.Max > inBounds.Z.Max)
outBounds.Z.Max = inBounds.Z.Max;
std::cout << "OUTPUT BOUNDING BOX " << outBounds << std::endl;
// Bounding box intersects
if (outBounds.IsNonEmpty() == false)
@ -621,7 +614,6 @@ std::cout << "Number of Points " << output.GetCellSet(0).GetNumberOfPoints() <<
outDim++;
if (outDim > inDim)
outDim = inDim;
std::cout << "OUTPUT DIMENSION " << outDim << std::endl;
// Uniform, Regular or Rectilinear
typedef vtkm::cont::ArrayHandleUniformPointCoordinates UniformArrayHandle;
@ -637,6 +629,7 @@ std::cout << "Number of Points " << output.GetCellSet(0).GetNumberOfPoints() <<
coordinates,
outBounds,
sample,
includeBoundary,
DeviceAdapter());
}
else
@ -646,6 +639,7 @@ std::cout << "Number of Points " << output.GetCellSet(0).GetNumberOfPoints() <<
coordinates,
outBounds,
sample,
includeBoundary,
DeviceAdapter());
}
}

@ -33,7 +33,6 @@ class TestingExtractStructured
public:
void TestUniform2D() const
{
std::cout << std::endl << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
typedef vtkm::cont::CellSetStructured<2> CellSetType;
@ -45,14 +44,15 @@ public:
// Bounds and subsample
vtkm::Bounds bounds(1,3, 1,3, 0,0);
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());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 9),
@ -63,7 +63,7 @@ public:
void TestUniform3D() const
{
std::cout << std::endl << "Testing extract structured uniform" << std::endl;
std::cout << "Testing extract structured uniform" << std::endl;
typedef vtkm::cont::CellSetStructured<3> CellSetType;
// Create the input uniform cell set
@ -77,16 +77,18 @@ public:
// Bounding box within dataset
vtkm::Bounds bounds0(1,3, 1,3, 1,3);
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),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
std::cout << std::endl;
// Bounding box surrounds dataset
vtkm::Bounds bounds1(-1,7, -1,7, -1,7);
@ -94,12 +96,12 @@ public:
dataSet.GetCoordinateSystem(0),
bounds1,
sample,
includeBoundary,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 125),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 64),
"Wrong result for ExtractStructured worklet");
std::cout << std::endl;
// Bounding box intersects dataset on near boundary
vtkm::Bounds bounds2(-1,2, -1,2, -1,2);
@ -107,12 +109,12 @@ public:
dataSet.GetCoordinateSystem(0),
bounds2,
sample,
includeBoundary,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 27),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
std::cout << std::endl;
// Bounding box intersects dataset on far boundary
vtkm::Bounds bounds3(1,7, 1,7, 1,7);
@ -120,12 +122,12 @@ public:
dataSet.GetCoordinateSystem(0),
bounds3,
sample,
includeBoundary,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 64),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 27),
"Wrong result for ExtractStructured worklet");
std::cout << std::endl;
// Bounding box intersects dataset without corner
vtkm::Bounds bounds4(2,7, 1,3, 1,3);
@ -133,12 +135,12 @@ public:
dataSet.GetCoordinateSystem(0),
bounds4,
sample,
includeBoundary,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 27),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
std::cout << std::endl;
// Bounding box intersects dataset with plane
vtkm::Bounds bounds5(2,7, 1,1, 1,3);
@ -146,17 +148,16 @@ public:
dataSet.GetCoordinateSystem(0),
bounds5,
sample,
includeBoundary,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 9),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 4),
"Wrong result for ExtractStructured worklet");
std::cout << std::endl;
}
void TestUniform3D1() const
{
std::cout << std::endl << std::endl;
std::cout << "Testing extract structured uniform with sampling" << std::endl;
typedef vtkm::cont::CellSetStructured<3> CellSetType;
@ -171,35 +172,57 @@ public:
// Bounding box within data set with sampling
vtkm::Bounds bounds0(0,4, 0,4, 1,3);
vtkm::Id3 sample0(2,2,1);
bool includeBoundary0 = false;
outDataSet = worklet.Run(cellSet,
dataSet.GetCoordinateSystem(0),
bounds0,
sample0,
includeBoundary0,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 27),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 8),
"Wrong result for ExtractStructured worklet");
std::cout << std::endl;
// Bounds and subsample
vtkm::Bounds bounds1(0,4, 0,4, 1,3);
vtkm::Id3 sample1(3,3,2);
bool includeBoundary1 = false;
outDataSet = worklet.Run(cellSet,
dataSet.GetCoordinateSystem(0),
bounds1,
sample1,
includeBoundary1,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 8),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 1),
"Wrong result for ExtractStructured worklet");
std::cout << std::endl;
// Bounds and subsample
vtkm::Bounds bounds2(0,4, 0,4, 1,3);
vtkm::Id3 sample2(3,3,2);
bool includeBoundary2 = true;
outDataSet = worklet.Run(cellSet,
dataSet.GetCoordinateSystem(0),
bounds2,
sample2,
includeBoundary2,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 18),
"Wrong result for ExtractStructured worklet");
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfCells(), 4),
"Wrong result for ExtractStructured worklet");
}
void TestRectilinear2D() const
{
std::cout << std::endl << std::endl;
std::cout << "Testing extract structured rectilinear" << std::endl;
typedef vtkm::cont::CellSetStructured<2> CellSetType;
@ -211,6 +234,7 @@ public:
// Bounds and subsample
vtkm::Bounds bounds(0,1, 0,1, 0,0);
vtkm::Id3 sample(1,1,1);
bool includeBoundary = false;
// Extract subset
vtkm::worklet::ExtractStructured worklet;
@ -219,6 +243,7 @@ public:
dataSet.GetCoordinateSystem(0),
bounds,
sample,
includeBoundary,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 4),
@ -229,7 +254,6 @@ public:
void TestRectilinear3D() const
{
std::cout << std::endl << std::endl;
std::cout << "Testing extract structured rectilinear" << std::endl;
typedef vtkm::cont::CellSetStructured<3> CellSetType;
@ -241,6 +265,7 @@ public:
// Bounds and subsample
vtkm::Bounds bounds(0,1, 0,1, 0,1);
vtkm::Id3 sample(1,1,1);
bool includeBoundary = false;
// Extract subset
vtkm::worklet::ExtractStructured worklet;
@ -249,6 +274,7 @@ public:
dataSet.GetCoordinateSystem(0),
bounds,
sample,
includeBoundary,
DeviceAdapter());
VTKM_TEST_ASSERT(test_equal(outDataSet.GetCellSet(0).GetNumberOfPoints(), 8),