Updating tests for the new Clip tables

This commit is contained in:
ayenpure 2018-12-08 11:57:34 +05:30
parent 831914f318
commit d0cf80bddd
3 changed files with 27 additions and 19 deletions

@ -73,7 +73,7 @@ void TestClipStructured()
"Wrong number of coordinate systems in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
"Wrong number of fields in the output dataset");
VTKM_TEST_ASSERT(outputData.GetCellSet().GetNumberOfCells() == 12,
VTKM_TEST_ASSERT(outputData.GetCellSet().GetNumberOfCells() == 8,
"Wrong number of cells in the output dataset");
vtkm::cont::DynamicArrayHandle temp = outputData.GetField("scalars").GetData();
@ -106,6 +106,7 @@ void TestClipStructuredInverted()
clip.SetInvertClip(invert);
clip.SetFieldsToPass("scalars");
auto outputData = clip.Execute(ds);
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,

@ -269,7 +269,13 @@ public:
for (vtkm::IdComponent iter = pointCount - 1; iter >= 0; iter--)
{
if (!this->Invert && static_cast<vtkm::Float64>(scalars[iter]) <= this->Value)
{
caseId++;
}
else if (this->Invert && static_cast<vtkm::Float64>(scalars[iter]) >= this->Value)
{
caseId++;
}
if (iter > 0)
caseId *= 2;
}

@ -125,7 +125,6 @@ vtkm::cont::DataSet MakeTestDatasetStructured()
void TestClippingExplicit()
{
vtkm::cont::DataSet ds = MakeTestDatasetExplicit();
vtkm::worklet::Clip clip;
bool invertClip = false;
vtkm::cont::CellSetExplicit<> outputCellSet =
@ -142,16 +141,16 @@ void TestClippingExplicit()
ds.GetField("cellvar").GetData().CopyTo(cellvarIn);
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar = clip.ProcessCellField(cellvarIn);
vtkm::Id connectivitySize = 12;
vtkm::Id connectivitySize = 8;
vtkm::Id fieldSize = 7;
vtkm::Id expectedConnectivity[] = { 5, 4, 0, 5, 0, 1, 5, 1, 6, 6, 1, 2 };
vtkm::Id expectedConnectivity[] = { 0, 1, 5, 4, 1, 2, 6, 5 };
Coord3D expectedCoords[] = {
Coord3D(0.00f, 0.00f, 0.0f), Coord3D(1.00f, 0.00f, 0.0f), Coord3D(1.00f, 1.00f, 0.0f),
Coord3D(0.00f, 1.00f, 0.0f), Coord3D(0.00f, 0.50f, 0.0f), Coord3D(0.25f, 0.75f, 0.0f),
Coord3D(0.50f, 1.00f, 0.0f),
};
vtkm::Float32 expectedScalars[] = { 1, 2, 1, 0, 0.5, 0.5, 0.5 };
std::vector<vtkm::Float32> expectedCellvar = { 100.f, 100.f, -100.f, -100.f };
std::vector<vtkm::Float32> expectedCellvar = { 100.f, -100.f };
VTKM_TEST_ASSERT(outputCellSet.GetNumberOfPoints() == fieldSize,
"Wrong number of points in cell set.");
@ -196,11 +195,11 @@ void TestClippingStructured()
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar = clip.ProcessCellField(cellvarIn);
vtkm::Id connectivitySize = 36;
vtkm::Id connectivitySize = 28;
vtkm::Id fieldSize = 13;
vtkm::Id expectedConnectivity[] = { 0, 1, 9, 0, 9, 10, 0, 10, 3, 1, 2, 9,
2, 11, 9, 2, 5, 11, 3, 10, 6, 10, 12, 6,
12, 7, 6, 11, 5, 8, 11, 8, 12, 8, 7, 12 };
vtkm::Id expectedConnectivity[] = { 9, 10, 3, 1, 1, 3, 0, 11, 9, 1, 5, 5, 1, 2,
10, 12, 7, 3, 3, 7, 6, 12, 11, 5, 7, 7, 5, 8 };
Coord3D expectedCoords[] = {
Coord3D(0.0f, 0.0f, 0.0f), Coord3D(1.0f, 0.0f, 0.0f), Coord3D(2.0f, 0.0f, 0.0f),
Coord3D(0.0f, 1.0f, 0.0f), Coord3D(1.0f, 1.0f, 0.0f), Coord3D(2.0f, 1.0f, 0.0f),
@ -209,8 +208,8 @@ void TestClippingStructured()
Coord3D(1.0f, 1.5f, 0.0f),
};
vtkm::Float32 expectedScalars[] = { 1, 1, 1, 1, 0, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5 };
std::vector<vtkm::Float32> expectedCellvar = { -100.f, -100.f, -100.f, 100.f, 100.f, 100.f,
30.f, 30.f, 30.f, -30.f, -30.f, -30.f };
std::vector<vtkm::Float32> expectedCellvar = { -100.f, -100.f, 100.f, 100.f,
30.f, 30.f, -30.f, -30.f };
VTKM_TEST_ASSERT(outputCellSet.GetNumberOfPoints() == fieldSize,
"Wrong number of points in cell set.");
@ -237,6 +236,7 @@ void TestClippingWithImplicitFunction()
vtkm::FloatDefault radius(0.5);
vtkm::cont::DataSet ds = MakeTestDatasetStructured();
bool invertClip = false;
vtkm::worklet::Clip clip;
vtkm::cont::CellSetExplicit<> outputCellSet =
@ -256,11 +256,12 @@ void TestClippingWithImplicitFunction()
ds.GetField("cellvar").GetData().CopyTo(cellvarIn);
vtkm::cont::ArrayHandle<vtkm::Float32> cellvar = clip.ProcessCellField(cellvarIn);
vtkm::Id connectivitySize = 36;
vtkm::Id connectivitySize = 28;
vtkm::Id fieldSize = 13;
vtkm::Id expectedConnectivity[] = { 0, 1, 9, 0, 9, 10, 0, 10, 3, 1, 2, 9,
2, 11, 9, 2, 5, 11, 3, 10, 6, 10, 12, 6,
12, 7, 6, 11, 5, 8, 11, 8, 12, 8, 7, 12 };
vtkm::Id expectedConnectivity[] = { 9, 10, 3, 1, 1, 3, 0, 11, 9, 1, 5, 5, 1, 2,
10, 12, 7, 3, 3, 7, 6, 12, 11, 5, 7, 7, 5, 8 };
Coord3D expectedCoords[] = {
Coord3D(0.0f, 0.0f, 0.0f), Coord3D(1.0f, 0.0f, 0.0f), Coord3D(2.0f, 0.0f, 0.0f),
Coord3D(0.0f, 1.0f, 0.0f), Coord3D(1.0f, 1.0f, 0.0f), Coord3D(2.0f, 1.0f, 0.0f),
@ -269,9 +270,8 @@ void TestClippingWithImplicitFunction()
Coord3D(1.0f, 1.25f, 0.0f),
};
vtkm::Float32 expectedScalars[] = { 1, 1, 1, 1, 0, 1, 1, 1, 1, 0.25, 0.25, 0.25, 0.25 };
std::vector<vtkm::Float32> expectedCellvar = { -100.f, -100.f, -100.f, 100.f, 100.f, 100.f,
30.f, 30.f, 30.f, -30.f, -30.f, -30.f };
std::vector<vtkm::Float32> expectedCellvar = { -100.f, -100.f, 100.f, 100.f,
30.f, 30.f, -30.f, -30.f };
VTKM_TEST_ASSERT(
TestArrayHandle(outputCellSet.GetConnectivityArray(vtkm::TopologyElementTagPoint(),
@ -295,6 +295,7 @@ void TestClippingWithImplicitFunctionInverted()
vtkm::FloatDefault radius(0.5);
vtkm::cont::DataSet ds = MakeTestDatasetStructured();
bool invertClip = true;
vtkm::worklet::Clip clip;
vtkm::cont::CellSetExplicit<> outputCellSet =
@ -316,7 +317,7 @@ void TestClippingWithImplicitFunctionInverted()
vtkm::Id connectivitySize = 12;
vtkm::Id fieldSize = 13;
vtkm::Id expectedConnectivity[] = { 4, 10, 9, 4, 9, 11, 4, 12, 10, 4, 11, 12 };
vtkm::Id expectedConnectivity[] = { 10, 9, 4, 9, 11, 4, 12, 10, 4, 11, 12, 4 };
Coord3D expectedCoords[] = {
Coord3D(0.0f, 0.0f, 0.0f), Coord3D(1.0f, 0.0f, 0.0f), Coord3D(2.0f, 0.0f, 0.0f),
Coord3D(0.0f, 1.0f, 0.0f), Coord3D(1.0f, 1.0f, 0.0f), Coord3D(2.0f, 1.0f, 0.0f),