From b2e20bf90e8038006ebc77f824e16dab9e2bf365 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Sat, 20 Oct 2018 20:40:20 +0200 Subject: [PATCH] Fix issues from removing field type templates The script fixed up most of the issues. However, there were some instances that the script was not able to pick up on. There were also some instances that still needed a means to select types. --- docs/changelog/field-tags-no-template.md | 31 ++++++++++++++ vtkm/cont/DynamicCellSet.h | 2 +- .../arg/testing/UnitTestTypeCheckArray.cxx | 40 +++--------------- vtkm/filter/WarpVector.hxx | 8 +++- vtkm/rendering/CanvasRayTracer.cxx | 9 +--- vtkm/rendering/MapperWireframer.cxx | 5 ++- vtkm/rendering/Triangulator.h | 3 +- vtkm/rendering/Wireframer.h | 7 ++-- .../raytracing/ConnectivityTracer.cxx | 10 ++--- .../raytracing/CylinderExtractor.cxx | 2 +- .../raytracing/CylinderIntersector.cxx | 3 +- vtkm/rendering/raytracing/QuadIntersector.cxx | 5 ++- vtkm/rendering/raytracing/SphereExtractor.cxx | 3 +- .../raytracing/SphereIntersector.cxx | 5 ++- .../raytracing/TriangleIntersector.cxx | 12 +++++- .../raytracing/VolumeRendererStructured.cxx | 19 +++++---- vtkm/worklet/testing/UnitTestClipping.cxx | 10 ++++- .../testing/UnitTestThresholdPoints.cxx | 12 ++++-- .../testing/UnitTestWorkletMapField.cxx | 42 ------------------- .../UnitTestWorkletMapFieldExecArg.cxx | 2 +- .../UnitTestWorkletMapPointNeighborhood.cxx | 10 ++++- .../UnitTestWorkletMapTopologyExplicit.cxx | 6 ++- .../UnitTestWorkletMapTopologyUniform.cxx | 4 +- 23 files changed, 125 insertions(+), 125 deletions(-) diff --git a/docs/changelog/field-tags-no-template.md b/docs/changelog/field-tags-no-template.md index 53b7b43cf..633ea6051 100644 --- a/docs/changelog/field-tags-no-template.md +++ b/docs/changelog/field-tags-no-template.md @@ -26,6 +26,37 @@ It needs to be run in a Unix-compatible shell. It takes a single argument, which is a top level directory to modify files. The script processes all C++ source files recursively from that directory. +## Selecting data types for auxiliary filter fields + +The main rational for making these changes is that the types of the inputs +to worklets is almost always already determined by the calling filter. +However, although it is straightforward to specify the type of the "main" +(active) scalars in a filter, it is less clear what to do for additional +fields if a filter needs a second or third field. + +Typically, in the case of a second or third field, it is up to the +`DoExecute` method in the filter implementation to apply a policy to that +field. When applying a policy, you give it a policy object (nominally +passed by the user) and a traits of the filter. Generally, the accepted +list of types for a field should be part of the filter's traits For +example, consider the `WarpVector` filter. This filter only works on +`Vec`s of size 3, so its traits class looks like this. + +``` cpp +template <> +class FilterTraits +{ +public: + // WarpVector can only applies to Float and Double Vec3 arrays + using InputFieldTypeList = vtkm::TypeListTagFieldVec3; +}; +``` + +However, the `WarpVector` filter also requires two fields instead of one. +The first (active) field is handled by its superclass (`FilterField`), but +the second (auxiliary) field must be managed in the `DoExecute`. Generally, +this can be done by simply applying the policy with the filter traits. + ## Change in executable size The whole intention of these template parameters in the first place was to diff --git a/vtkm/cont/DynamicCellSet.h b/vtkm/cont/DynamicCellSet.h index 736807dda..5bd22ae49 100644 --- a/vtkm/cont/DynamicCellSet.h +++ b/vtkm/cont/DynamicCellSet.h @@ -100,7 +100,7 @@ VTKM_CONT CellSetType* DynamicCellSetTryCast( /// /// By default, \c DynamicCellSet will assume that the value type in the array /// matches one of the types specified by \c VTKM_DEFAULT_CELL_SET_LIST_TAG. -/// This list can be changed by using the \c ResetTypeList method. It is +/// This list can be changed by using the \c ResetCellSetList method. It is /// worthwhile to match these lists closely to the possible types that might be /// used. If a type is missing you will get a runtime error. If there are more /// types than necessary, then the template mechanism will create a lot of diff --git a/vtkm/cont/arg/testing/UnitTestTypeCheckArray.cxx b/vtkm/cont/arg/testing/UnitTestTypeCheckArray.cxx index 371642260..ba153f077 100644 --- a/vtkm/cont/arg/testing/UnitTestTypeCheckArray.cxx +++ b/vtkm/cont/arg/testing/UnitTestTypeCheckArray.cxx @@ -36,7 +36,7 @@ struct TryArraysOfType void operator()(T) const { using vtkm::cont::arg::TypeCheck; - using TypeCheckTagArray = vtkm::cont::arg::TypeCheckTagArray; + using vtkm::cont::arg::TypeCheckTagArray; using StandardArray = vtkm::cont::ArrayHandle; VTKM_TEST_ASSERT((TypeCheck::value), @@ -70,48 +70,18 @@ void TestCheckAtomicArray() using Int64Array = vtkm::cont::ArrayHandle; using FloatArray = vtkm::cont::ArrayHandle; - using DefaultTypeCheck = TypeCheckTagAtomicArray<>; - VTKM_TEST_ASSERT((TypeCheck::value), + VTKM_TEST_ASSERT((TypeCheck::value), "Check for 32-bit int failed."); - VTKM_TEST_ASSERT((TypeCheck::value), + VTKM_TEST_ASSERT((TypeCheck::value), "Check for 64-bit int failed."); - VTKM_TEST_ASSERT(!(TypeCheck::value), "Check for float failed."); - - using ExpandedTypeCheck = TypeCheckTagAtomicArray; - VTKM_TEST_ASSERT((TypeCheck::value), - "Check for 32-bit int failed."); - VTKM_TEST_ASSERT((TypeCheck::value), - "Check for 64-bit int failed."); - VTKM_TEST_ASSERT(!(TypeCheck::value), "Check for float failed."); - - using RestrictedTypeCheck = TypeCheckTagAtomicArray>; - VTKM_TEST_ASSERT((TypeCheck::value), - "Check for 32-bit int failed."); - VTKM_TEST_ASSERT(!(TypeCheck::value), - "Check for 64-bit int failed."); - VTKM_TEST_ASSERT(!(TypeCheck::value), "Check for float failed."); + VTKM_TEST_ASSERT(!(TypeCheck::value), + "Check for float failed."); } void TestCheckArray() { vtkm::testing::Testing::TryTypes(TryArraysOfType()); - std::cout << "Trying some arrays with types that do not match the list." << std::endl; - using vtkm::cont::arg::TypeCheck; - using vtkm::cont::arg::TypeCheckTagArray; - - using ScalarArray = vtkm::cont::ArrayHandle; - VTKM_TEST_ASSERT((TypeCheck, ScalarArray>::value), - "Scalar for scalar check failed."); - VTKM_TEST_ASSERT(!(TypeCheck, ScalarArray>::value), - "Scalar for vector check failed."); - - using VecArray = vtkm::cont::ArrayHandle>; - VTKM_TEST_ASSERT((TypeCheck, VecArray>::value), - "Vector for vector check failed."); - VTKM_TEST_ASSERT(!(TypeCheck, VecArray>::value), - "Vector for scalar check failed."); - TestCheckAtomicArray(); } diff --git a/vtkm/filter/WarpVector.hxx b/vtkm/filter/WarpVector.hxx index 8d0781f93..5f4e6433b 100644 --- a/vtkm/filter/WarpVector.hxx +++ b/vtkm/filter/WarpVector.hxx @@ -21,6 +21,8 @@ #include #include +#include + namespace vtkm { namespace filter @@ -48,7 +50,11 @@ inline VTKM_CONT vtkm::cont::DataSet WarpVector::DoExecute( using vecType = vtkm::Vec; auto vectorF = inDataSet.GetField(this->VectorFieldName, this->VectorFieldAssociation); vtkm::cont::ArrayHandle result; - this->Worklet.Run(field, vtkm::filter::ApplyPolicy(vectorF, policy), this->Scale, result); + this->Worklet.Run( + field, + vtkm::filter::ApplyPolicy(vectorF, policy, vtkm::filter::FilterTraits()), + this->Scale, + result); return internal::CreateResult(inDataSet, result, diff --git a/vtkm/rendering/CanvasRayTracer.cxx b/vtkm/rendering/CanvasRayTracer.cxx index 4ba57fa07..a0219e144 100644 --- a/vtkm/rendering/CanvasRayTracer.cxx +++ b/vtkm/rendering/CanvasRayTracer.cxx @@ -45,13 +45,8 @@ public: { } - using ControlSignature = void(FieldIn, - WholeArrayInOut, - FieldIn, - FieldIn, - FieldIn, - WholeArrayOut, - WholeArrayOut>>); + using ControlSignature = + void(FieldIn, WholeArrayInOut, FieldIn, FieldIn, FieldIn, WholeArrayOut, WholeArrayOut); using ExecutionSignature = void(_1, _2, _3, _4, _5, _6, _7, WorkIndex); template ( Convert1DCoordinates(this->LogarithmY, this->LogarithmX)) - .Invoke(coords.GetData(), inScalarField.GetData(), newCoords, newScalars); + .Invoke(coords.GetData(), + inScalarField.GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + newCoords, + newScalars); actualCoords = vtkm::cont::CoordinateSystem("coords", newCoords); actualField = vtkm::cont::Field( diff --git a/vtkm/rendering/Triangulator.h b/vtkm/rendering/Triangulator.h index 84d55c2f6..a8b851a18 100644 --- a/vtkm/rendering/Triangulator.h +++ b/vtkm/rendering/Triangulator.h @@ -246,8 +246,7 @@ public: VTKM_CONT UniqueTriangles() {} - using ControlSignature = void(WholeArrayIn>>, - WholeArrayOut); + using ControlSignature = void(WholeArrayIn, WholeArrayOut); using ExecutionSignature = void(_1, _2, WorkIndex); VTKM_EXEC diff --git a/vtkm/rendering/Wireframer.h b/vtkm/rendering/Wireframer.h index bd6b9885d..facb58fb3 100644 --- a/vtkm/rendering/Wireframer.h +++ b/vtkm/rendering/Wireframer.h @@ -397,9 +397,7 @@ public: VTKM_CONT BufferConverter() {} - using ControlSignature = void(FieldIn, - WholeArrayOut, - WholeArrayOut>>); + using ControlSignature = void(FieldIn, WholeArrayOut, WholeArrayOut); using ExecutionSignature = void(_1, _2, _3, WorkIndex); template @@ -553,7 +551,8 @@ private: Camera.GetClippingRange()); vtkm::worklet::DispatcherMapField> plotterDispatcher(plotter); plotterDispatcher.SetDevice(DeviceTag()); - plotterDispatcher.Invoke(PointIndices, Coordinates, ScalarField.GetData()); + plotterDispatcher.Invoke( + PointIndices, Coordinates, ScalarField.GetData().ResetTypes(vtkm::TypeListTagFieldScalar())); BufferConverter converter; vtkm::worklet::DispatcherMapField converterDispatcher(converter); diff --git a/vtkm/rendering/raytracing/ConnectivityTracer.cxx b/vtkm/rendering/raytracing/ConnectivityTracer.cxx index cdc46a423..e95a519ed 100644 --- a/vtkm/rendering/raytracing/ConnectivityTracer.cxx +++ b/vtkm/rendering/raytracing/ConnectivityTracer.cxx @@ -1196,7 +1196,7 @@ void ConnectivityTracer::SampleCells(Ray& rays, detail::RayTrackingScalarBounds.Max))); dispatcher.Invoke(rays.HitIdx, this->Coords, - this->ScalarField.GetData(), + this->ScalarField.GetData().ResetTypes(ScalarRenderingTypes()), *(tracker.EnterDist), *(tracker.ExitDist), tracker.CurrentDistance, @@ -1215,7 +1215,7 @@ void ConnectivityTracer::SampleCells(Ray& rays, detail::RayTrackingScalarBounds.Max))); dispatcher.Invoke(rays.HitIdx, - this->ScalarField.GetData(), + this->ScalarField.GetData().ResetTypes(ScalarRenderingTypes()), *(tracker.EnterDist), *(tracker.ExitDist), tracker.CurrentDistance, @@ -1243,8 +1243,8 @@ void ConnectivityTracer::IntegrateCells(Ray& rays, *(tracker.EnterDist), *(tracker.ExitDist), rays.Distance, - this->ScalarField.GetData(), - this->EmissionField.GetData(), + this->ScalarField.GetData().ResetTypes(ScalarRenderingTypes()), + this->EmissionField.GetData().ResetTypes(ScalarRenderingTypes()), absorp, emission, rays.HitIdx); @@ -1257,7 +1257,7 @@ void ConnectivityTracer::IntegrateCells(Ray& rays, *(tracker.EnterDist), *(tracker.ExitDist), rays.Distance, - this->ScalarField.GetData(), + this->ScalarField.GetData().ResetTypes(ScalarRenderingTypes()), rays.Buffers.at(0).Buffer, rays.HitIdx); } diff --git a/vtkm/rendering/raytracing/CylinderExtractor.cxx b/vtkm/rendering/raytracing/CylinderExtractor.cxx index ee44adc44..930ed5b08 100644 --- a/vtkm/rendering/raytracing/CylinderExtractor.cxx +++ b/vtkm/rendering/raytracing/CylinderExtractor.cxx @@ -282,7 +282,7 @@ void CylinderExtractor::SetVaryingRadius(const vtkm::Float32 minRadius, Radii.Allocate(this->CylIds.GetNumberOfValues()); vtkm::worklet::DispatcherMapField( detail::FieldRadius(minRadius, maxRadius, range)) - .Invoke(this->CylIds, this->Radii, field); + .Invoke(this->CylIds, this->Radii, field.GetData().ResetTypes(vtkm::TypeListTagFieldScalar())); } diff --git a/vtkm/rendering/raytracing/CylinderIntersector.cxx b/vtkm/rendering/raytracing/CylinderIntersector.cxx index 9e92de250..b06f4281f 100644 --- a/vtkm/rendering/raytracing/CylinderIntersector.cxx +++ b/vtkm/rendering/raytracing/CylinderIntersector.cxx @@ -492,7 +492,8 @@ void CylinderIntersector::IntersectionDataImp(Ray& rays, vtkm::worklet::DispatcherMapField>( detail::GetScalar(vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max))) - .Invoke(rays.HitIdx, rays.Scalar, *scalarField, CylIds); + .Invoke( + rays.HitIdx, rays.Scalar, scalarField->GetData().ResetTypes(ScalarRenderingTypes()), CylIds); } void CylinderIntersector::IntersectionData(Ray& rays, diff --git a/vtkm/rendering/raytracing/QuadIntersector.cxx b/vtkm/rendering/raytracing/QuadIntersector.cxx index f264eb902..a0fa6b997 100644 --- a/vtkm/rendering/raytracing/QuadIntersector.cxx +++ b/vtkm/rendering/raytracing/QuadIntersector.cxx @@ -454,7 +454,10 @@ void QuadIntersector::IntersectionDataImp(Ray& rays, vtkm::worklet::DispatcherMapField>( detail::GetScalar(vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max))) - .Invoke(rays.HitIdx, rays.Scalar, *scalarField, QuadIds); + .Invoke(rays.HitIdx, + rays.Scalar, + scalarField->GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + QuadIds); } void QuadIntersector::IntersectionData(Ray& rays, diff --git a/vtkm/rendering/raytracing/SphereExtractor.cxx b/vtkm/rendering/raytracing/SphereExtractor.cxx index 8be0936a0..290cce5f1 100644 --- a/vtkm/rendering/raytracing/SphereExtractor.cxx +++ b/vtkm/rendering/raytracing/SphereExtractor.cxx @@ -263,7 +263,8 @@ void SphereExtractor::SetVaryingRadius(const vtkm::Float32 minRadius, Radii.Allocate(this->PointIds.GetNumberOfValues()); vtkm::worklet::DispatcherMapField( detail::FieldRadius(minRadius, maxRadius, range)) - .Invoke(this->PointIds, this->Radii, field); + .Invoke( + this->PointIds, this->Radii, field.GetData().ResetTypes(vtkm::TypeListTagFieldScalar())); } vtkm::cont::ArrayHandle SphereExtractor::GetPointIds() diff --git a/vtkm/rendering/raytracing/SphereIntersector.cxx b/vtkm/rendering/raytracing/SphereIntersector.cxx index 618dcc2a3..21ffc904e 100644 --- a/vtkm/rendering/raytracing/SphereIntersector.cxx +++ b/vtkm/rendering/raytracing/SphereIntersector.cxx @@ -368,7 +368,10 @@ void SphereIntersector::IntersectionDataImp(Ray& rays, vtkm::worklet::DispatcherMapField>( detail::GetScalar(vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max))) - .Invoke(rays.HitIdx, rays.Scalar, *scalarField, PointIds); + .Invoke(rays.HitIdx, + rays.Scalar, + scalarField->GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + PointIds); } void SphereIntersector::IntersectionData(Ray& rays, diff --git a/vtkm/rendering/raytracing/TriangleIntersector.cxx b/vtkm/rendering/raytracing/TriangleIntersector.cxx index 91d2e3314..b40625fdb 100644 --- a/vtkm/rendering/raytracing/TriangleIntersector.cxx +++ b/vtkm/rendering/raytracing/TriangleIntersector.cxx @@ -360,13 +360,21 @@ public: { vtkm::worklet::DispatcherMapField>( LerpScalar(vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max))) - .Invoke(rays.HitIdx, rays.U, rays.V, rays.Scalar, *scalarField, triangles); + .Invoke(rays.HitIdx, + rays.U, + rays.V, + rays.Scalar, + scalarField->GetData().ResetTypes(ScalarRenderingTypes()), + triangles); } else { vtkm::worklet::DispatcherMapField>( NodalScalar(vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max))) - .Invoke(rays.HitIdx, rays.Scalar, *scalarField, triangles); + .Invoke(rays.HitIdx, + rays.Scalar, + scalarField->GetData().ResetTypes(ScalarRenderingTypes()), + triangles); } } // Run diff --git a/vtkm/rendering/raytracing/VolumeRendererStructured.cxx b/vtkm/rendering/raytracing/VolumeRendererStructured.cxx index 9721d52f9..dd61d7439 100644 --- a/vtkm/rendering/raytracing/VolumeRendererStructured.cxx +++ b/vtkm/rendering/raytracing/VolumeRendererStructured.cxx @@ -846,7 +846,7 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray

GetData().ResetTypes(vtkm::TypeListTagFieldScalar())); } else { @@ -861,7 +861,7 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray

GetData().ResetTypes(vtkm::TypeListTagFieldScalar())); } } else @@ -884,7 +884,7 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray

GetData().ResetTypes(vtkm::TypeListTagFieldScalar())); } else { @@ -896,12 +896,13 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray

GetData().ResetTypes(vtkm::TypeListTagFieldScalar())); } } diff --git a/vtkm/worklet/testing/UnitTestClipping.cxx b/vtkm/worklet/testing/UnitTestClipping.cxx index 4d477eef8..41f4d4df7 100644 --- a/vtkm/worklet/testing/UnitTestClipping.cxx +++ b/vtkm/worklet/testing/UnitTestClipping.cxx @@ -128,7 +128,10 @@ void TestClippingExplicit() vtkm::worklet::Clip clip; bool invertClip = false; vtkm::cont::CellSetExplicit<> outputCellSet = - clip.Run(ds.GetCellSet(0), ds.GetField("scalars").GetData(), clipValue, invertClip); + clip.Run(ds.GetCellSet(0), + ds.GetField("scalars").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + clipValue, + invertClip); auto coordsIn = ds.GetCoordinateSystem("coords").GetData(); vtkm::cont::ArrayHandle coords = clip.ProcessPointField(coordsIn); @@ -181,7 +184,10 @@ void TestClippingStructured() bool invertClip = false; vtkm::worklet::Clip clip; vtkm::cont::CellSetExplicit<> outputCellSet = - clip.Run(ds.GetCellSet(0), ds.GetField("scalars").GetData(), clipValue, invertClip); + clip.Run(ds.GetCellSet(0), + ds.GetField("scalars").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + clipValue, + invertClip); auto coordsIn = ds.GetCoordinateSystem("coords").GetData(); CoordsOutType coords = clip.ProcessPointField(coordsIn); diff --git a/vtkm/worklet/testing/UnitTestThresholdPoints.cxx b/vtkm/worklet/testing/UnitTestThresholdPoints.cxx index 513a42441..af3d59069 100644 --- a/vtkm/worklet/testing/UnitTestThresholdPoints.cxx +++ b/vtkm/worklet/testing/UnitTestThresholdPoints.cxx @@ -118,7 +118,9 @@ public: vtkm::worklet::ThresholdPoints threshold; OutCellSetType outCellSet; outCellSet = threshold.Run( - dataset.GetCellSet(0), dataset.GetField("pointvar").GetData(), ValuesBetween(40.0f, 71.0f)); + dataset.GetCellSet(0), + dataset.GetField("pointvar").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + ValuesBetween(40.0f, 71.0f)); outDataSet.AddCellSet(outCellSet); VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 11), @@ -148,7 +150,9 @@ public: vtkm::worklet::ThresholdPoints threshold; OutCellSetType outCellSet; outCellSet = threshold.Run( - dataset.GetCellSet(0), dataset.GetField("pointvar").GetData(), ValuesAbove(1.0f)); + dataset.GetCellSet(0), + dataset.GetField("pointvar").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + ValuesAbove(1.0f)); outDataSet.AddCellSet(outCellSet); VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 27), @@ -171,7 +175,9 @@ public: vtkm::worklet::ThresholdPoints threshold; OutCellSetType outCellSet; outCellSet = threshold.Run( - dataset.GetCellSet(0), dataset.GetField("pointvar").GetData(), ValuesBelow(50.0f)); + dataset.GetCellSet(0), + dataset.GetField("pointvar").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + ValuesBelow(50.0f)); outDataSet.AddCellSet(outCellSet); VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfCells(), 6), diff --git a/vtkm/worklet/testing/UnitTestWorkletMapField.cxx b/vtkm/worklet/testing/UnitTestWorkletMapField.cxx index c32508bdd..ff9e9da1c 100644 --- a/vtkm/worklet/testing/UnitTestWorkletMapField.cxx +++ b/vtkm/worklet/testing/UnitTestWorkletMapField.cxx @@ -60,30 +60,6 @@ public: } }; -class TestMapFieldWorkletLimitedTypes : public vtkm::worklet::WorkletMapField -{ -public: - using ControlSignature = void(FieldIn, FieldOut, FieldInOut); - using ExecutionSignature = _2(_1, _3, WorkIndex); - - template - VTKM_EXEC T1 operator()(const T1& in, T3& inout, vtkm::Id workIndex) const - { - if (!test_equal(in, TestValue(workIndex, T1()) + T1(100))) - { - this->RaiseError("Got wrong input value."); - } - - if (!test_equal(inout, TestValue(workIndex, T3()) + T3(100))) - { - this->RaiseError("Got wrong in-out value."); - } - inout = inout - T3(100); - - return in - T1(100); - } -}; - namespace mapfield { static constexpr vtkm::Id ARRAY_SIZE = 10; @@ -197,26 +173,8 @@ void TestWorkletMapField(vtkm::cont::DeviceAdapterId id) { std::cout << "Testing Map Field on device adapter: " << id.GetName() << std::endl; - std::cout << "--- Worklet accepting all types." << std::endl; vtkm::testing::Testing::TryTypes(mapfield::DoTestWorklet(), vtkm::TypeListTagCommon()); - - std::cout << "--- Worklet accepting some types." << std::endl; - vtkm::testing::Testing::TryTypes(mapfield::DoTestWorklet(), - vtkm::TypeListTagFieldScalar()); - - std::cout << "--- Sending bad type to worklet." << std::endl; - try - { - //can only test with variant arrays, as static arrays will fail to compile - DoVariantTestWorklet badWorkletTest; - badWorkletTest(vtkm::Vec()); - VTKM_TEST_FAIL("Did not throw expected error."); - } - catch (vtkm::cont::ErrorBadType& error) - { - std::cout << "Got expected error: " << error.GetMessage() << std::endl; - } } } // mapfield namespace diff --git a/vtkm/worklet/testing/UnitTestWorkletMapFieldExecArg.cxx b/vtkm/worklet/testing/UnitTestWorkletMapFieldExecArg.cxx index 2ab94b7bc..37c8dbb3b 100644 --- a/vtkm/worklet/testing/UnitTestWorkletMapFieldExecArg.cxx +++ b/vtkm/worklet/testing/UnitTestWorkletMapFieldExecArg.cxx @@ -91,7 +91,7 @@ struct DoTestWorklet outputHandle = vtkm::cont::ArrayHandle(); outputHandle.Allocate(ARRAY_SIZE); - vtkm::cont::VariantArrayHandle outputFieldDynamic(outputFieldArray); + vtkm::cont::VariantArrayHandleBase> outputFieldDynamic(outputFieldArray); dispatcher.Invoke(counting, inputHandle, outputHandle, outputFieldDynamic); std::cout << "Check dynamic array result." << std::endl; diff --git a/vtkm/worklet/testing/UnitTestWorkletMapPointNeighborhood.cxx b/vtkm/worklet/testing/UnitTestWorkletMapPointNeighborhood.cxx index 4d9c9f0c0..99192cd94 100644 --- a/vtkm/worklet/testing/UnitTestWorkletMapPointNeighborhood.cxx +++ b/vtkm/worklet/testing/UnitTestWorkletMapPointNeighborhood.cxx @@ -195,7 +195,10 @@ static void TestMaxNeighborValue() vtkm::cont::ArrayHandle output; vtkm::cont::DataSet dataSet3D = testDataSet.Make3DUniformDataSet0(); - dispatcher.Invoke(dataSet3D.GetField("pointvar"), dataSet3D.GetCellSet(), output); + dispatcher.Invoke( + dataSet3D.GetField("pointvar").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + dataSet3D.GetCellSet(), + output); vtkm::Float32 expected3D[18] = { 110.3f, 120.3f, 120.3f, 110.3f, 120.3f, 120.3f, 170.5f, 180.5f, 180.5f, 170.5f, 180.5f, 180.5f, @@ -207,7 +210,10 @@ static void TestMaxNeighborValue() } vtkm::cont::DataSet dataSet2D = testDataSet.Make2DUniformDataSet1(); - dispatcher.Invoke(dataSet2D.GetField("pointvar"), dataSet2D.GetCellSet(), output); + dispatcher.Invoke( + dataSet2D.GetField("pointvar").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + dataSet2D.GetCellSet(), + output); vtkm::Float32 expected2D[25] = { 100.0f, 100.0f, 78.0f, 49.0f, 33.0f, 100.0f, 100.0f, 78.0f, 50.0f, 48.0f, 94.0f, 94.0f, 91.0f, 91.0f, diff --git a/vtkm/worklet/testing/UnitTestWorkletMapTopologyExplicit.cxx b/vtkm/worklet/testing/UnitTestWorkletMapTopologyExplicit.cxx index ce9785272..4e36862b0 100644 --- a/vtkm/worklet/testing/UnitTestWorkletMapTopologyExplicit.cxx +++ b/vtkm/worklet/testing/UnitTestWorkletMapTopologyExplicit.cxx @@ -97,7 +97,11 @@ static void TestMaxPointOrCell() vtkm::cont::ArrayHandle result; vtkm::worklet::DispatcherMapTopology<::test_explicit::MaxPointOrCellValue> dispatcher; - dispatcher.Invoke(dataSet.GetField("cellvar"), dataSet.GetField("pointvar"), &cellset, result); + dispatcher.Invoke( + dataSet.GetField("cellvar").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + dataSet.GetField("pointvar").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + &cellset, + result); std::cout << "Make sure we got the right answer." << std::endl; VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(0), 100.1f), diff --git a/vtkm/worklet/testing/UnitTestWorkletMapTopologyUniform.cxx b/vtkm/worklet/testing/UnitTestWorkletMapTopologyUniform.cxx index 87ce3ae74..dd836ff08 100644 --- a/vtkm/worklet/testing/UnitTestWorkletMapTopologyUniform.cxx +++ b/vtkm/worklet/testing/UnitTestWorkletMapTopologyUniform.cxx @@ -121,8 +121,8 @@ static void TestMaxPointOrCell() vtkm::worklet::DispatcherMapTopology<::test_uniform::MaxPointOrCellValue> dispatcher; dispatcher.Invoke( - dataSet.GetField("cellvar"), - dataSet.GetField("pointvar"), + dataSet.GetField("cellvar").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), + dataSet.GetField("pointvar").GetData().ResetTypes(vtkm::TypeListTagFieldScalar()), // We know that the cell set is a structured 2D grid and // The worklet does not work with general types because // of the way we get cell indices. We need to make that