mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Fix gaps in type support
With recent changes to allow a configuration to change the default types, storage, and cell sets, it is possible to feed filters and other components types they were not previously expecting. Fix feature gaps where these components were not accepting the types they should.
This commit is contained in:
parent
dc112b5169
commit
42bc9a393c
@ -51,9 +51,9 @@ struct TryArraysOfType
|
||||
using CompositeArray = vtkm::cont::ArrayHandleCompositeVector<StandardArray, StandardArray>;
|
||||
VTKM_TEST_ASSERT((TypeCheck<TypeCheckTagArrayIn, CompositeArray>::value),
|
||||
"Composite array type check failed.");
|
||||
VTKM_TEST_ASSERT((TypeCheck<TypeCheckTagArrayInOut, CountingArray>::value),
|
||||
VTKM_TEST_ASSERT((TypeCheck<TypeCheckTagArrayInOut, CompositeArray>::value),
|
||||
"Counting array type check failed.");
|
||||
VTKM_TEST_ASSERT((TypeCheck<TypeCheckTagArrayOut, CountingArray>::value),
|
||||
VTKM_TEST_ASSERT((TypeCheck<TypeCheckTagArrayOut, CompositeArray>::value),
|
||||
"Counting array type check failed.");
|
||||
|
||||
// Just some type that is not a valid array.
|
||||
|
@ -46,6 +46,13 @@ inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Vec<vtkm::Id, 1> index)
|
||||
{
|
||||
return vtkm::Id3(index[0], 1, 1);
|
||||
}
|
||||
|
||||
/// Given a \c Vec of (semi) arbitrary size, inflate it to a vtkm::Id3 by padding with zeros.
|
||||
/// \overload
|
||||
inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Id index)
|
||||
{
|
||||
return vtkm::Id3(index, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Container for thread information in a WorkletPointNeighborhood.
|
||||
|
@ -22,8 +22,8 @@ namespace filter
|
||||
class CrossProduct : public vtkm::filter::FilterField<CrossProduct>
|
||||
{
|
||||
public:
|
||||
//currently the DotProduct filter only works on vector data.
|
||||
using SupportedTypes = TypeListVecCommon;
|
||||
//CrossProduct filter only works on vec3 data.
|
||||
using SupportedTypes = vtkm::TypeListFieldVec3;
|
||||
|
||||
VTKM_CONT
|
||||
CrossProduct();
|
||||
|
@ -22,9 +22,6 @@ namespace filter
|
||||
class DotProduct : public vtkm::filter::FilterField<DotProduct>
|
||||
{
|
||||
public:
|
||||
//currently the DotProduct filter only works on vector data.
|
||||
using SupportedTypes = TypeListVecCommon;
|
||||
|
||||
VTKM_CONT
|
||||
DotProduct();
|
||||
|
||||
@ -123,11 +120,10 @@ public:
|
||||
//@}
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
private:
|
||||
std::string SecondaryFieldName;
|
||||
|
@ -33,7 +33,7 @@ inline VTKM_CONT DotProduct::DotProduct()
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
inline VTKM_CONT vtkm::cont::DataSet DotProduct::DoExecute(
|
||||
const vtkm::cont::DataSet& inDataSet,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& primary,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& primary,
|
||||
const vtkm::filter::FieldMetadata& fieldMetadata,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
@ -46,10 +46,9 @@ inline VTKM_CONT vtkm::cont::DataSet DotProduct::DoExecute(
|
||||
{
|
||||
secondaryField = inDataSet.GetField(this->SecondaryFieldName, this->SecondaryFieldAssociation);
|
||||
}
|
||||
auto secondary =
|
||||
vtkm::filter::ApplyPolicyFieldOfType<vtkm::Vec<T, 3>>(secondaryField, policy, *this);
|
||||
auto secondary = vtkm::filter::ApplyPolicyFieldOfType<T>(secondaryField, policy, *this);
|
||||
|
||||
vtkm::cont::ArrayHandle<T> output;
|
||||
vtkm::cont::ArrayHandle<typename vtkm::VecTraits<T>::ComponentType> output;
|
||||
this->Invoke(vtkm::worklet::DotProduct{}, primary, secondary, output);
|
||||
|
||||
return CreateResult(inDataSet, output, this->GetOutputFieldName(), fieldMetadata);
|
||||
|
@ -428,9 +428,12 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
auto cellSetUnstructured =
|
||||
cellset.ResetCellSetList(VTKM_DEFAULT_CELL_SET_LIST_UNSTRUCTURED{});
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> segmentsPerCell;
|
||||
vtkm::worklet::DispatcherMapTopology<CountSegments> countInvoker;
|
||||
countInvoker.Invoke(cellset, segmentsPerCell);
|
||||
countInvoker.Invoke(cellSetUnstructured, segmentsPerCell);
|
||||
|
||||
vtkm::Id total = 0;
|
||||
total = vtkm::cont::Algorithm::Reduce(segmentsPerCell, vtkm::Id(0));
|
||||
@ -440,7 +443,7 @@ public:
|
||||
outputIndices.Allocate(total);
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<Cylinderize> cylInvoker;
|
||||
cylInvoker.Invoke(cellset, cellOffsets, outputIndices);
|
||||
cylInvoker.Invoke(cellSetUnstructured, cellOffsets, outputIndices);
|
||||
|
||||
output = total;
|
||||
}
|
||||
|
@ -113,7 +113,8 @@ public:
|
||||
{
|
||||
if (DIM == 2)
|
||||
{
|
||||
// Do nothing mark says
|
||||
outputIndices.Set(
|
||||
cellIndex, { cellIndex, cellIndices[0], cellIndices[1], cellIndices[2], cellIndices[3] });
|
||||
}
|
||||
else if (DIM == 3)
|
||||
{
|
||||
@ -123,7 +124,8 @@ public:
|
||||
vtkm::Id4 idx;
|
||||
idx[0] = 0;
|
||||
idx[1] = 1;
|
||||
idx[2] = 5, idx[3] = 4;
|
||||
idx[2] = 5;
|
||||
idx[3] = 4;
|
||||
cell2quad(idx, quad, offset, cellIndices, outputIndices);
|
||||
|
||||
idx[0] = 1;
|
||||
@ -300,24 +302,38 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 5>>& outputIndices,
|
||||
vtkm::Id& output)
|
||||
{
|
||||
vtkm::cont::Invoker invoke;
|
||||
|
||||
if (cellset.IsSameType(vtkm::cont::CellSetStructured<3>()))
|
||||
{
|
||||
vtkm::cont::CellSetStructured<3> cellSetStructured3D =
|
||||
cellset.Cast<vtkm::cont::CellSetStructured<3>>();
|
||||
const vtkm::Id numCells = cellSetStructured3D.GetNumberOfCells();
|
||||
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> cellIdxs(0, 1, numCells);
|
||||
vtkm::cont::ArrayHandleIndex cellIdxs(numCells);
|
||||
outputIndices.Allocate(numCells * QUAD_PER_CSS);
|
||||
vtkm::worklet::DispatcherMapTopology<SegmentedStructured<3>> segInvoker;
|
||||
segInvoker.Invoke(cellSetStructured3D, cellIdxs, outputIndices);
|
||||
invoke(SegmentedStructured<3>{}, cellSetStructured3D, cellIdxs, outputIndices);
|
||||
|
||||
output = numCells * QUAD_PER_CSS;
|
||||
}
|
||||
else if (cellset.IsSameType(vtkm::cont::CellSetStructured<2>()))
|
||||
{
|
||||
vtkm::cont::CellSetStructured<2> cellSetStructured2D =
|
||||
cellset.Cast<vtkm::cont::CellSetStructured<2>>();
|
||||
const vtkm::Id numCells = cellSetStructured2D.GetNumberOfCells();
|
||||
|
||||
vtkm::cont::ArrayHandleIndex cellIdxs(numCells);
|
||||
outputIndices.Allocate(numCells);
|
||||
invoke(SegmentedStructured<2>{}, cellSetStructured2D, cellIdxs, outputIndices);
|
||||
|
||||
output = numCells;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto cellSetUnstructured =
|
||||
cellset.ResetCellSetList(VTKM_DEFAULT_CELL_SET_LIST_UNSTRUCTURED{});
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> quadsPerCell;
|
||||
vtkm::worklet::DispatcherMapTopology<CountQuads> countInvoker;
|
||||
countInvoker.Invoke(cellset, quadsPerCell);
|
||||
invoke(CountQuads{}, cellSetUnstructured, quadsPerCell);
|
||||
|
||||
vtkm::Id total = 0;
|
||||
total = vtkm::cont::Algorithm::Reduce(quadsPerCell, vtkm::Id(0));
|
||||
@ -326,8 +342,7 @@ public:
|
||||
vtkm::cont::Algorithm::ScanExclusive(quadsPerCell, cellOffsets);
|
||||
outputIndices.Allocate(total);
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<Quadralize> quadInvoker;
|
||||
quadInvoker.Invoke(cellset, cellOffsets, outputIndices);
|
||||
invoke(Quadralize{}, cellSetUnstructured, cellOffsets, outputIndices);
|
||||
|
||||
output = total;
|
||||
}
|
||||
|
@ -682,9 +682,11 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
auto cellSetUnstructured =
|
||||
cellset.ResetCellSetList(VTKM_DEFAULT_CELL_SET_LIST_UNSTRUCTURED{});
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> trianglesPerCell;
|
||||
vtkm::worklet::DispatcherMapTopology<CountTriangles>(CountTriangles())
|
||||
.Invoke(cellset, trianglesPerCell);
|
||||
.Invoke(cellSetUnstructured, trianglesPerCell);
|
||||
|
||||
vtkm::Id totalTriangles = 0;
|
||||
totalTriangles = vtkm::cont::Algorithm::Reduce(trianglesPerCell, vtkm::Id(0));
|
||||
@ -694,7 +696,7 @@ public:
|
||||
outputIndices.Allocate(totalTriangles);
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<Trianglulate>(Trianglulate())
|
||||
.Invoke(cellset, cellOffsets, outputIndices);
|
||||
.Invoke(cellSetUnstructured, cellOffsets, outputIndices);
|
||||
|
||||
outputTriangles = totalTriangles;
|
||||
}
|
||||
|
@ -255,9 +255,11 @@ void CylinderExtractor::SetCylinderIdsFromCells(const vtkm::cont::DynamicCellSet
|
||||
//
|
||||
if (cells.IsSameType(vtkm::cont::CellSetExplicit<>()))
|
||||
{
|
||||
auto cellsExplicit = cells.Cast<vtkm::cont::CellSetExplicit<>>();
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> points;
|
||||
vtkm::worklet::DispatcherMapTopology<detail::CountSegments>(detail::CountSegments())
|
||||
.Invoke(cells, points);
|
||||
.Invoke(cellsExplicit, points);
|
||||
|
||||
vtkm::Id totalPoints = 0;
|
||||
totalPoints = vtkm::cont::Algorithm::Reduce(points, vtkm::Id(0));
|
||||
@ -267,7 +269,7 @@ void CylinderExtractor::SetCylinderIdsFromCells(const vtkm::cont::DynamicCellSet
|
||||
CylIds.Allocate(totalPoints);
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<detail::Pointify>(detail::Pointify())
|
||||
.Invoke(cells, cellOffsets, this->CylIds);
|
||||
.Invoke(cellsExplicit, cellOffsets, this->CylIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,9 +221,11 @@ void QuadExtractor::SetQuadIdsFromCells(const vtkm::cont::DynamicCellSet& cells)
|
||||
//
|
||||
if (cells.IsSameType(vtkm::cont::CellSetExplicit<>()))
|
||||
{
|
||||
auto cellsExplicit = cells.Cast<vtkm::cont::CellSetExplicit<>>();
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> points;
|
||||
vtkm::worklet::DispatcherMapTopology<detail::CountQuads>(detail::CountQuads())
|
||||
.Invoke(cells, points);
|
||||
.Invoke(cellsExplicit, points);
|
||||
|
||||
vtkm::Id total = 0;
|
||||
total = vtkm::cont::Algorithm::Reduce(points, vtkm::Id(0));
|
||||
@ -233,7 +235,7 @@ void QuadExtractor::SetQuadIdsFromCells(const vtkm::cont::DynamicCellSet& cells)
|
||||
QuadIds.Allocate(total);
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<detail::Pointify>(detail::Pointify())
|
||||
.Invoke(cells, cellOffsets, this->QuadIds);
|
||||
.Invoke(cellsExplicit, cellOffsets, this->QuadIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,9 +224,11 @@ void SphereExtractor::SetPointIdsFromCells(const vtkm::cont::DynamicCellSet& cel
|
||||
//
|
||||
if (cells.IsSameType(vtkm::cont::CellSetExplicit<>()))
|
||||
{
|
||||
auto cellsExplicit = cells.Cast<vtkm::cont::CellSetExplicit<>>();
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> points;
|
||||
vtkm::worklet::DispatcherMapTopology<detail::CountPoints>(detail::CountPoints())
|
||||
.Invoke(cells, points);
|
||||
.Invoke(cellsExplicit, points);
|
||||
|
||||
vtkm::Id totalPoints = 0;
|
||||
totalPoints = vtkm::cont::Algorithm::Reduce(points, vtkm::Id(0));
|
||||
@ -236,7 +238,7 @@ void SphereExtractor::SetPointIdsFromCells(const vtkm::cont::DynamicCellSet& cel
|
||||
PointIds.Allocate(totalPoints);
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<detail::Pointify>(detail::Pointify())
|
||||
.Invoke(cells, cellOffsets, this->PointIds);
|
||||
.Invoke(cellsExplicit, cellOffsets, this->PointIds);
|
||||
}
|
||||
else if (cells.IsSameType(SingleType()))
|
||||
{
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
|
||||
namespace vtkm
|
||||
@ -29,7 +30,13 @@ public:
|
||||
const vtkm::Vec<T, Size>& v2,
|
||||
T& outValue) const
|
||||
{
|
||||
outValue = vtkm::Dot(v1, v2);
|
||||
outValue = static_cast<T>(vtkm::Dot(v1, v2));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC void operator()(T s1, T s2, T& outValue) const
|
||||
{
|
||||
outValue = static_cast<T>(s1 * s2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user