Commit 7861b5a8 authored by Kenneth Moreland's avatar Kenneth Moreland Committed by Kitware Robot

Merge topic 'selecting-input-map-fields'

d74b96ba Support FieldSelection initialization with vtkm::Pair initializer list
8e312f81 Add MODE_EXCLUDE to FieldSelection
9c51de8d Add MODE_NONE to FieldSelection
a4aa42c0 Avoid "weird" arrays in fields
6a6ac7cd Change filter to pass all fields by default
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1116
parents 89b46e95 d74b96ba
......@@ -22,6 +22,7 @@
#include <initializer_list>
#include <set>
#include <vtkm/Pair.h>
#include <vtkm/cont/Field.h>
namespace vtkm
......@@ -39,12 +40,14 @@ class FieldSelection
public:
enum ModeEnum
{
MODE_SELECTED,
MODE_ALL
MODE_NONE,
MODE_ALL,
MODE_SELECT,
MODE_EXCLUDE
};
VTKM_CONT
FieldSelection(ModeEnum mode = MODE_SELECTED)
FieldSelection(ModeEnum mode = MODE_SELECT)
: Mode(mode)
{
}
......@@ -52,8 +55,8 @@ public:
/// Use this constructor create a field selection given the field names e.g.
/// `FieldSelection({"field_one", "field_two"})`.
VTKM_CONT
FieldSelection(std::initializer_list<std::string> fields)
: Mode(MODE_SELECTED)
FieldSelection(std::initializer_list<std::string> fields, ModeEnum mode = MODE_SELECT)
: Mode(mode)
{
for (const std::string& afield : fields)
{
......@@ -64,14 +67,36 @@ public:
/// Use this constructor create a field selection given the field names and
/// associations e.g.
/// @code{cpp}
/// using pair_type = std::pair<std::string, vtkm::cont::Field::AssociationEnum>;
/// FieldSelection({
/// pair_type{"field_one", vtkm::cont::Field::ASSOC_POINTS},
/// pair_type{"field_two", vtkm::cont::Field::ASSOC_CELL_SET} });
/// @endcode
VTKM_CONT
FieldSelection(
std::initializer_list<std::pair<std::string, vtkm::cont::Field::AssociationEnum>> fields,
ModeEnum mode = MODE_SELECT)
: Mode(mode)
{
for (const auto& item : fields)
{
this->AddField(item.first, item.second);
}
}
/// Use this constructor create a field selection given the field names and
/// associations e.g.
/// @code{cpp}
/// using pair_type = vtkm::Pair<std::string, vtkm::cont::Field::AssociationEnum>;
/// FieldSelection({
/// {"field_one", vtkm::cont::Field::ASSOC_POINTS},
/// {"field_two", vtkm::cont::Field::ASSOC_CELL_SET} });
/// pair_type{"field_one", vtkm::cont::Field::ASSOC_POINTS},
/// pair_type{"field_two", vtkm::cont::Field::ASSOC_CELL_SET} });
/// @endcode
VTKM_CONT
FieldSelection(
std::initializer_list<std::pair<std::string, vtkm::cont::Field::AssociationEnum>> fields)
: Mode(MODE_SELECTED)
std::initializer_list<vtkm::Pair<std::string, vtkm::cont::Field::AssociationEnum>> fields,
ModeEnum mode = MODE_SELECT)
: Mode(mode)
{
for (const auto& item : fields)
{
......@@ -96,33 +121,23 @@ public:
{
switch (this->Mode)
{
case MODE_NONE:
return false;
case MODE_ALL:
return true;
case MODE_SELECTED:
case MODE_SELECT:
default:
if (this->Fields.find(Field(name, association)) != this->Fields.end())
{
return true;
}
// if not exact match, let's lookup for ASSOC_ANY.
for (const auto& aField : this->Fields)
{
if (aField.Name == name)
{
if (aField.Association == vtkm::cont::Field::ASSOC_ANY ||
association == vtkm::cont::Field::ASSOC_ANY)
{
return true;
}
}
}
return false;
return this->HasField(name, association);
case MODE_EXCLUDE:
return !this->HasField(name, association);
}
}
//@{
/// Add fields to map. Note, if Mode is not MODE_SELECTED, then adding fields
/// Add fields to map. Note, if Mode is not MODE_SELECT, then adding fields
/// will have no impact of the fields that will be mapped.
VTKM_CONT
void AddField(const vtkm::cont::Field& inputField)
......@@ -138,6 +153,38 @@ public:
}
//@}
/// Returns true if the input field has been added to this selection.
/// Note that depending on the mode of this selection, the result of HasField
/// is not necessarily the same as IsFieldSelected. (If the mode is MODE_SELECT,
/// then the result of the two will be the same.)
VTKM_CONT
bool HasField(const vtkm::cont::Field& inputField) const
{
return this->HasField(inputField.GetName(), inputField.GetAssociation());
}
bool HasField(const std::string& name,
vtkm::cont::Field::AssociationEnum association = vtkm::cont::Field::ASSOC_ANY) const
{
if (this->Fields.find(Field(name, association)) != this->Fields.end())
{
return true;
}
// if not exact match, let's lookup for ASSOC_ANY.
for (const auto& aField : this->Fields)
{
if (aField.Name == name)
{
if (aField.Association == vtkm::cont::Field::ASSOC_ANY ||
association == vtkm::cont::Field::ASSOC_ANY)
{
return true;
}
}
}
return false;
}
/// Clear all fields added using `AddField`.
VTKM_CONT
void ClearFields() { this->Fields.clear(); }
......
......@@ -62,25 +62,33 @@ public:
///
/// On success, this the dataset produced. On error, vtkm::cont::ErrorExecution will be thrown.
VTKM_CONT
vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input,
const FieldSelection& fieldSelection = FieldSelection());
vtkm::cont::DataSet Execute(
const vtkm::cont::DataSet& input,
const vtkm::filter::FieldSelection& fieldSelection =
vtkm::filter::FieldSelection(vtkm::filter::FieldSelection::MODE_ALL));
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
const FieldSelection& fieldSelection = FieldSelection());
VTKM_CONT vtkm::cont::DataSet Execute(
const vtkm::cont::DataSet& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
const vtkm::filter::FieldSelection& fieldSelection =
vtkm::filter::FieldSelection(vtkm::filter::FieldSelection::MODE_ALL));
//@}
//@{
/// MultiBlock variants of execute.
VTKM_CONT
vtkm::cont::MultiBlock Execute(const vtkm::cont::MultiBlock& input,
const FieldSelection& fieldSelection = FieldSelection());
vtkm::cont::MultiBlock Execute(
const vtkm::cont::MultiBlock& input,
const vtkm::filter::FieldSelection& fieldSelection =
vtkm::filter::FieldSelection(vtkm::filter::FieldSelection::MODE_ALL));
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::MultiBlock Execute(const vtkm::cont::MultiBlock& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
const FieldSelection& fieldSelection = FieldSelection());
VTKM_CONT vtkm::cont::MultiBlock Execute(
const vtkm::cont::MultiBlock& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
const vtkm::filter::FieldSelection& fieldSelection =
vtkm::filter::FieldSelection(vtkm::filter::FieldSelection::MODE_ALL));
//@}
private:
......
......@@ -54,8 +54,9 @@ inline VTKM_CONT Filter<Derived>::~Filter()
//----------------------------------------------------------------------------
template <typename Derived>
inline VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(const vtkm::cont::DataSet& input,
const FieldSelection& fieldSelection)
inline VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(
const vtkm::cont::DataSet& input,
const vtkm::filter::FieldSelection& fieldSelection)
{
return this->Execute(input, vtkm::filter::PolicyDefault(), fieldSelection);
}
......@@ -66,7 +67,7 @@ template <typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(
const vtkm::cont::DataSet& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
const FieldSelection& fieldSelection)
const vtkm::filter::FieldSelection& fieldSelection)
{
Derived* self = static_cast<Derived*>(this);
//self->DoPreExecute(input, policy, fieldSelection);
......@@ -93,7 +94,7 @@ inline VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(
template <typename Derived>
inline VTKM_CONT vtkm::cont::MultiBlock Filter<Derived>::Execute(
const vtkm::cont::MultiBlock& input,
const FieldSelection& fieldSelection)
const vtkm::filter::FieldSelection& fieldSelection)
{
return this->Execute(input, vtkm::filter::PolicyDefault(), fieldSelection);
}
......@@ -104,7 +105,7 @@ template <typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::MultiBlock Filter<Derived>::Execute(
const vtkm::cont::MultiBlock& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
const FieldSelection& fieldSelection)
const vtkm::filter::FieldSelection& fieldSelection)
{
// Derived* self = static_cast<Derived*>(this);
//self->DoPreExecute(input, policy, fieldSelection);
......
......@@ -35,7 +35,7 @@ vtkm::cont::DataSet MakeDataTestSet1()
vtkm::cont::DataSet ds = MakeTestDataSet().Make3DUniformDataSet1();
vtkm::filter::CleanGrid clean;
return clean.Execute(ds, vtkm::filter::FieldSelection::MODE_ALL);
return clean.Execute(ds);
}
vtkm::cont::DataSet MakeDataTestSet2()
......@@ -68,7 +68,7 @@ void TestExternalFacesExplicitGrid(const vtkm::cont::DataSet& ds,
vtkm::filter::ExternalFaces externalFaces;
externalFaces.SetCompactPoints(compactPoints);
externalFaces.SetPassPolyData(passPolyData);
vtkm::cont::DataSet resultds = externalFaces.Execute(ds, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet resultds = externalFaces.Execute(ds);
// verify cellset
vtkm::cont::CellSetExplicit<>& new_cellSet =
......
......@@ -48,8 +48,7 @@ public:
extractGeometry.SetExtractBoundaryCells(false);
extractGeometry.SetExtractOnlyBoundaryCells(false);
vtkm::cont::DataSet output =
extractGeometry.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = extractGeometry.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 8),
"Wrong result for ExtractGeometry");
......@@ -77,8 +76,7 @@ public:
extractGeometry.SetExtractBoundaryCells(false);
extractGeometry.SetExtractOnlyBoundaryCells(false);
vtkm::cont::DataSet output =
extractGeometry.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = extractGeometry.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 56),
"Wrong result for ExtractGeometry");
......@@ -106,8 +104,7 @@ public:
extractGeometry.SetExtractBoundaryCells(true);
extractGeometry.SetExtractOnlyBoundaryCells(false);
vtkm::cont::DataSet output =
extractGeometry.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = extractGeometry.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 64),
"Wrong result for ExtractGeometry");
......@@ -134,8 +131,7 @@ public:
extractGeometry.SetExtractBoundaryCells(true);
extractGeometry.SetExtractOnlyBoundaryCells(true);
vtkm::cont::DataSet output =
extractGeometry.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = extractGeometry.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 56),
"Wrong result for ExtractGeometry");
......
......@@ -47,8 +47,7 @@ public:
extractPoints.SetExtractInside(true);
extractPoints.SetCompactPoints(true);
vtkm::cont::DataSet output =
extractPoints.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = extractPoints.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 27),
"Wrong result for ExtractPoints");
......@@ -81,8 +80,7 @@ public:
extractPoints.SetExtractInside(false);
extractPoints.SetCompactPoints(true);
vtkm::cont::DataSet output =
extractPoints.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = extractPoints.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 98),
"Wrong result for ExtractPoints");
......@@ -115,8 +113,7 @@ public:
extractPoints.SetImplicitFunction(sphere);
extractPoints.SetExtractInside(true);
vtkm::cont::DataSet output =
extractPoints.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = extractPoints.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 27),
"Wrong result for ExtractPoints");
}
......@@ -136,8 +133,7 @@ public:
extractPoints.SetImplicitFunction(box);
extractPoints.SetExtractInside(true);
vtkm::cont::DataSet output =
extractPoints.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = extractPoints.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 8),
"Wrong result for ExtractPoints");
}
......@@ -157,8 +153,7 @@ public:
extractPoints.SetImplicitFunction(box);
extractPoints.SetExtractInside(false);
vtkm::cont::DataSet output =
extractPoints.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = extractPoints.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 3),
"Wrong result for ExtractPoints");
}
......
......@@ -26,7 +26,7 @@ namespace
void TestFieldSelection()
{
{
// empty field selection, everything should be false.
std::cout << "empty field selection, everything should be false." << std::endl;
vtkm::filter::FieldSelection selection;
VTKM_TEST_ASSERT(selection.IsFieldSelected("foo") == false, "field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::ASSOC_POINTS) == false,
......@@ -34,7 +34,7 @@ void TestFieldSelection()
}
{
// field selection with select all, everything should be false.
std::cout << "field selection with select all, everything should be true." << std::endl;
vtkm::filter::FieldSelection selection(vtkm::filter::FieldSelection::MODE_ALL);
VTKM_TEST_ASSERT(selection.IsFieldSelected("foo") == true, "field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::ASSOC_POINTS) == true,
......@@ -42,7 +42,15 @@ void TestFieldSelection()
}
{
// field selection with specific fields selected.
std::cout << "field selection with select none, everything should be false." << std::endl;
vtkm::filter::FieldSelection selection(vtkm::filter::FieldSelection::MODE_NONE);
VTKM_TEST_ASSERT(selection.IsFieldSelected("foo") == false, "field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::ASSOC_POINTS) == false,
"field selection failed.");
}
{
std::cout << "field selection with specific fields selected (AddField)." << std::endl;
vtkm::filter::FieldSelection selection;
selection.AddField("foo");
selection.AddField("bar", vtkm::cont::Field::ASSOC_CELL_SET);
......@@ -57,7 +65,7 @@ void TestFieldSelection()
}
{
// field selection with specific fields selected.
std::cout << "field selection with specific fields selected (initializer list)." << std::endl;
vtkm::filter::FieldSelection selection{ "foo", "bar" };
VTKM_TEST_ASSERT(selection.IsFieldSelected("foo") == true, "field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("foo", vtkm::cont::Field::ASSOC_POINTS) == true,
......@@ -70,7 +78,8 @@ void TestFieldSelection()
}
{
// field selection with specific fields selected.
std::cout << "field selection with specific fields selected (std::pair initializer list)."
<< std::endl;
using pair_type = std::pair<std::string, vtkm::cont::Field::AssociationEnum>;
vtkm::filter::FieldSelection selection{ pair_type{ "foo", vtkm::cont::Field::ASSOC_ANY },
pair_type{ "bar", vtkm::cont::Field::ASSOC_CELL_SET } };
......@@ -83,6 +92,40 @@ void TestFieldSelection()
"field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar") == true, "field selection failed.");
}
{
std::cout << "field selection with specific fields selected (vtkm::Pair initializer list)."
<< std::endl;
using pair_type = vtkm::Pair<std::string, vtkm::cont::Field::AssociationEnum>;
vtkm::filter::FieldSelection selection{ pair_type{ "foo", vtkm::cont::Field::ASSOC_ANY },
pair_type{ "bar", vtkm::cont::Field::ASSOC_CELL_SET } };
VTKM_TEST_ASSERT(selection.IsFieldSelected("foo") == true, "field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("foo", vtkm::cont::Field::ASSOC_POINTS) == true,
"field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::ASSOC_POINTS) == false,
"field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::ASSOC_CELL_SET) == true,
"field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar") == true, "field selection failed.");
}
{
std::cout << "field selection with specific fields excluded." << std::endl;
using pair_type = std::pair<std::string, vtkm::cont::Field::AssociationEnum>;
vtkm::filter::FieldSelection selection(
{ pair_type{ "foo", vtkm::cont::Field::ASSOC_ANY },
pair_type{ "bar", vtkm::cont::Field::ASSOC_CELL_SET } },
vtkm::filter::FieldSelection::MODE_EXCLUDE);
VTKM_TEST_ASSERT(selection.IsFieldSelected("foo") == false, "field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("foo", vtkm::cont::Field::ASSOC_POINTS) == false,
"field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::ASSOC_POINTS) == true,
"field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar", vtkm::cont::Field::ASSOC_CELL_SET) == false,
"field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("bar") == false, "field selection failed.");
VTKM_TEST_ASSERT(selection.IsFieldSelected("baz") == true, "field selection failed.");
}
}
}
......
......@@ -303,7 +303,7 @@ void TestMarchingCubesUniformGrid()
mc.SetIsoValue(0, 0.5);
mc.SetActiveField("nodevar");
auto result = mc.Execute(dataSet);
auto result = mc.Execute(dataSet, vtkm::filter::FieldSelection::MODE_NONE);
{
VTKM_TEST_ASSERT(result.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
......
......@@ -41,7 +41,7 @@ public:
vtkm::Id stride = 2;
mask.SetStride(stride);
vtkm::cont::DataSet output = mask.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = mask.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 8),
"Wrong result for Mask");
......@@ -65,7 +65,7 @@ public:
vtkm::Id stride = 9;
mask.SetStride(stride);
vtkm::cont::DataSet output = mask.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = mask.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 7),
"Wrong result for Mask");
......@@ -87,7 +87,7 @@ public:
vtkm::Id stride = 2;
mask.SetStride(stride);
vtkm::cont::DataSet output = mask.Execute(dataset, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = mask.Execute(dataset);
VTKM_TEST_ASSERT(test_equal(output.GetCellSet().GetNumberOfCells(), 2),
"Wrong result for Mask");
......
......@@ -390,8 +390,7 @@ void MapperWireframer::RenderCells(const vtkm::cont::DynamicCellSet& inCellSet,
vtkm::filter::ExternalFaces externalFaces;
externalFaces.SetCompactPoints(false);
externalFaces.SetPassPolyData(true);
vtkm::cont::DataSet output =
externalFaces.Execute(dataSet, vtkm::filter::FieldSelection::MODE_ALL);
vtkm::cont::DataSet output = externalFaces.Execute(dataSet);
cellSet = output.GetCellSet();
actualField = output.GetField(0);
}
......
......@@ -19,12 +19,15 @@
// this software.
//
//=============================================================================
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/MarchingCubes.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/worklet/connectivities/CellSetConnectivity.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
class TangleField : public vtkm::worklet::WorkletMapField
{
public:
......@@ -94,7 +97,9 @@ static vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, pointFieldArray);
vtkm::Id numCells = dims[0] * dims[1] * dims[2];
auto cellFieldArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, numCells);
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
vtkm::cont::ArrayCopy(vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, numCells),
cellFieldArray);
vtkm::Vec<vtkm::FloatDefault, 3> origin(0.0f, 0.0f, 0.0f);
vtkm::Vec<vtkm::FloatDefault, 3> spacing(1.0f / static_cast<vtkm::FloatDefault>(dims[0]),
......
......@@ -19,6 +19,7 @@
//============================================================================
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/DataSet.h>
......@@ -100,7 +101,9 @@ vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, pointFieldArray);
vtkm::Id numCells = dims[0] * dims[1] * dims[2];
auto cellFieldArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, numCells);
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
vtkm::cont::ArrayCopy(vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, numCells),
cellFieldArray);
vtkm::Vec<vtkm::FloatDefault, 3> origin(0.0f, 0.0f, 0.0f);
vtkm::Vec<vtkm::FloatDefault, 3> spacing(1.0f / static_cast<vtkm::FloatDefault>(dims[0]),
......@@ -246,7 +249,9 @@ inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComp
DataArrayHandle distanceToOrigin(coordinates);
DataArrayHandle distanceToOther(coordinates, EuclideanNorm(CoordType(1., 1., 1.)));
auto cellFieldArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, nCells);
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
vtkm::cont::ArrayCopy(vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, nCells),
cellFieldArray);
ConnectivityArrayHandle connectivity(
vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, nCells * HexTraits::NUM_POINTS),
......@@ -287,7 +292,7 @@ void TestMarchingCubesUniformGrid()
dataSet.GetCellSet().CopyTo(cellSet);
vtkm::cont::ArrayHandle<vtkm::Float32> pointFieldArray;
dataSet.GetField("nodevar").GetData().CopyTo(pointFieldArray);
vtkm::cont::ArrayHandleCounting<vtkm::Id> cellFieldArray;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
dataSet.GetField("cellvar").GetData().CopyTo(cellFieldArray);
vtkm::worklet::MarchingCubes isosurfaceFilter;
......@@ -309,7 +314,7 @@ void TestMarchingCubesUniformGrid()
scalarsArray = isosurfaceFilter.ProcessPointField(pointFieldArray, DeviceAdapter());
vtkm::cont::ArrayHandle<vtkm::Id> cellFieldArrayOut;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArrayOut;
cellFieldArrayOut = isosurfaceFilter.ProcessCellField(cellFieldArray, DeviceAdapter());
std::cout << "vertices: ";
......@@ -378,10 +383,10 @@ void TestMarchingCubesExplicit()
scalars = marchingCubes.ProcessPointField(projectedArray, DeviceAdapter());
vtkm::cont::ArrayHandle<vtkm::Id> cellFieldArray;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
dataSet.GetField("cellvar").GetData().CopyTo(cellFieldArray);
vtkm::cont::ArrayHandle<vtkm::Id> cellFieldArrayOut;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArrayOut;
cellFieldArrayOut = marchingCubes.ProcessCellField(cellFieldArray, DeviceAdapter());
std::cout << "vertices: ";
......@@ -407,9 +412,13 @@ void TestMarchingCubesExplicit()
"Wrong scalars result for MarchingCubes filter");
}
void TestMarchingCubes()
{
TestMarchingCubesUniformGrid();
TestMarchingCubesExplicit();
}
int UnitTestMarchingCubes(int, char* [])
{
int result1 = vtkm::cont::testing::Testing::Run(TestMarchingCubesUniformGrid);
int result2 = vtkm::cont::testing::Testing::Run(TestMarchingCubesExplicit);
return result1 == 0 && result2 == 0;
return vtkm::cont::testing::Testing::Run(TestMarchingCubes);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment