mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-06 18:38:59 +00:00
Merge topic 'pass_fields_and_coordinates_to_invoke'
08a33675 Prefer vtkm::cont::CastAndCall function over the member method. 31138293 Pass Fields and CoordinateSystems to Dispatcher::Invoke 146d8009 make CastAndCall a free function instead of a class. Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: T.J. Corona <tj.corona@kitware.com> Merge-request: !497
This commit is contained in:
commit
2406f45cd7
@ -78,7 +78,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
timer.Reset();
|
||||
vtkm::cont::DynamicArrayHandle coords =
|
||||
clip.ProcessField(input.GetCoordinateSystem(0).GetData());
|
||||
clip.ProcessField(input.GetCoordinateSystem(0));
|
||||
vtkm::Float64 processCoordinatesTime = timer.GetElapsedTime();
|
||||
output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coords));
|
||||
|
||||
|
@ -148,7 +148,7 @@ void displayCall()
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
outDataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
const vtkm::cont::DynamicArrayHandleCoordinateSystem &coordArray =
|
||||
outDataSet.GetCoordinateSystem(0).GetData();
|
||||
outDataSet.GetCoordinateSystem().GetData();
|
||||
|
||||
vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
|
||||
vtkm::Id numberOfPoints = coordArray.GetNumberOfValues();
|
||||
@ -156,7 +156,7 @@ void displayCall()
|
||||
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
|
||||
// So use cast and call on a functor that stores that dynamic array into static array we created
|
||||
vertexArray.Allocate(numberOfPoints);
|
||||
coordArray.CastAndCall(GetVertexArray());
|
||||
vtkm::cont::CastAndCall(coordArray, GetVertexArray());
|
||||
|
||||
// Each cell is a polyline
|
||||
glColor3f(1.0f, 0.0f, 0.0f);
|
||||
|
@ -204,14 +204,10 @@ void displayCall()
|
||||
outDataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
|
||||
|
||||
// Get the coordinate system and coordinate data
|
||||
const vtkm::cont::DynamicArrayHandleCoordinateSystem coordArray =
|
||||
outDataSet.GetCoordinateSystem(0).GetData();
|
||||
|
||||
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
|
||||
// So use cast and call on a functor that stores that dynamic array into static array we created
|
||||
vertexArray.Allocate(numberOfInPoints);
|
||||
coordArray.CastAndCall(GetVertexArray());
|
||||
vtkm::cont::CastAndCall(outDataSet.GetCoordinateSystem(), GetVertexArray());
|
||||
|
||||
// Draw the five tetrahedra belonging to each hexadron
|
||||
vtkm::Float32 color[5][3] = {
|
||||
|
@ -170,13 +170,11 @@ void displayCall()
|
||||
// Get the cell set, coordinate system and coordinate data
|
||||
vtkm::cont::CellSetSingleType<> cellSet;
|
||||
tetDataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
const vtkm::cont::DynamicArrayHandleCoordinateSystem &coordArray =
|
||||
tetDataSet.GetCoordinateSystem(0).GetData();
|
||||
|
||||
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
|
||||
// So use cast and call on a functor that stores that dynamic array into static array we created
|
||||
vertexArray.Allocate(numberOfInPoints);
|
||||
coordArray.CastAndCall(GetVertexArray());
|
||||
vtkm::cont::CastAndCall(tetDataSet.GetCoordinateSystem(), GetVertexArray());
|
||||
|
||||
// Draw the five tetrahedra belonging to each hexadron
|
||||
vtkm::Id tetra = 0;
|
||||
|
@ -176,14 +176,10 @@ void displayCall()
|
||||
outDataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
|
||||
|
||||
// Get the coordinate system and coordinate data
|
||||
const vtkm::cont::DynamicArrayHandleCoordinateSystem coordArray =
|
||||
outDataSet.GetCoordinateSystem(0).GetData();
|
||||
|
||||
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
|
||||
// So use cast and call on a functor that stores that dynamic array into static array we created
|
||||
vertexArray.Allocate(numberOfInPoints);
|
||||
coordArray.CastAndCall(GetVertexArray());
|
||||
vtkm::cont::CastAndCall(outDataSet.GetCoordinateSystem(), GetVertexArray());
|
||||
|
||||
// Draw the two triangles belonging to each quad
|
||||
vtkm::Float32 color[4][3] = {
|
||||
|
@ -132,13 +132,11 @@ void displayCall()
|
||||
// Get the cellset, coordinate system and coordinate data
|
||||
vtkm::cont::CellSetSingleType<> cellSet;
|
||||
tetDataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
const vtkm::cont::DynamicArrayHandleCoordinateSystem &coordArray =
|
||||
tetDataSet.GetCoordinateSystem(0).GetData();
|
||||
|
||||
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
|
||||
// So use cast and call on a functor that stores that dynamic array into static array we created
|
||||
vertexArray.Allocate(numberOfInPoints);
|
||||
coordArray.CastAndCall(GetVertexArray());
|
||||
vtkm::cont::CastAndCall(tetDataSet.GetCoordinateSystem(), GetVertexArray());
|
||||
|
||||
// Draw the two triangles belonging to each quad
|
||||
vtkm::Id triangle = 0;
|
||||
|
@ -258,6 +258,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Functor>
|
||||
void CastAndCall(const vtkm::cont::CoordinateSystem& coords, const Functor &f)
|
||||
{
|
||||
coords.GetData().CastAndCall(f);
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<>
|
||||
@ -266,17 +272,6 @@ struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
|
||||
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
||||
};
|
||||
|
||||
template<typename Functor>
|
||||
struct CastAndCall<vtkm::cont::CoordinateSystem, Functor>
|
||||
{
|
||||
VTKM_CONT_EXPORT
|
||||
void operator()(const vtkm::cont::CoordinateSystem &coordinateSystem,
|
||||
const Functor &func) const
|
||||
{
|
||||
coordinateSystem.GetData().CastAndCall(func);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
|
@ -518,23 +518,19 @@ private:
|
||||
mutable bool ModifiedFlag;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
template<typename Functor>
|
||||
void CastAndCall(const vtkm::cont::Field& field, const Functor &f)
|
||||
{
|
||||
field.GetData().CastAndCall(f);
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
template<>
|
||||
struct DynamicTransformTraits<vtkm::cont::Field>
|
||||
{
|
||||
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
||||
};
|
||||
|
||||
template<typename Functor>
|
||||
struct CastAndCall<vtkm::cont::Field, Functor>
|
||||
{
|
||||
VTKM_CONT_EXPORT
|
||||
void operator()(const vtkm::cont::Field &field, const Functor &func) const
|
||||
{
|
||||
field.GetData().CastAndCall(func);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace cont
|
||||
|
@ -25,6 +25,26 @@
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
template<typename T, typename S> class ArrayHandle;
|
||||
|
||||
/// A Generic interface to CastAndCall. The default implementation simply calls
|
||||
/// DynamicObject's CastAndCall, but specializations of this function exist for
|
||||
/// other classes (e.g. Field, CoordinateSystem, ArrayHandle).
|
||||
template<typename DynamicObject, typename Functor>
|
||||
void CastAndCall(const DynamicObject& dynamicObject, const Functor &f)
|
||||
{
|
||||
dynamicObject.CastAndCall(f);
|
||||
}
|
||||
|
||||
/// A specialization of CastAndCall for basic ArrayHandle types,
|
||||
/// Since the type is already known no deduction is needed.
|
||||
/// This specialization is used to simplify numerous worklet algorithms
|
||||
template<typename T, typename U, typename Functor>
|
||||
void CastAndCall(const vtkm::cont::ArrayHandle<T,U>& handle, const Functor &f)
|
||||
{
|
||||
f(handle);
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
/// Tag used to identify an object that is a dynamic object that contains a
|
||||
@ -57,19 +77,6 @@ struct DynamicTransformTraits {
|
||||
typedef vtkm::cont::internal::DynamicTransformTagStatic DynamicTag;
|
||||
};
|
||||
|
||||
/// A Generic interface to CastAndCall. The default implementation simply calls
|
||||
/// DynamicObject's CastAndCall, but specializations of this function exist for
|
||||
/// other classes (e.g. Field, CoordinateSystem).
|
||||
template<typename DynamicObject, typename Functor>
|
||||
struct CastAndCall
|
||||
{
|
||||
VTKM_CONT_EXPORT
|
||||
void operator()(const DynamicObject& dynamicObject, const Functor &f)
|
||||
{
|
||||
dynamicObject.CastAndCall(f);
|
||||
}
|
||||
};
|
||||
|
||||
/// This functor can be used as the transform in the \c DynamicTransformCont
|
||||
/// method of \c FunctionInterface. It will allow dynamic objects like
|
||||
/// \c DynamicArray to be cast to their concrete types for templated operation.
|
||||
@ -106,8 +113,7 @@ private:
|
||||
const ContinueFunctor &continueFunc,
|
||||
vtkm::cont::internal::DynamicTransformTagCastAndCall) const
|
||||
{
|
||||
CastAndCall<InputType, ContinueFunctor> castAndCall;
|
||||
castAndCall(dynamicInput, continueFunc);
|
||||
CastAndCall(dynamicInput, continueFunc);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -146,7 +146,7 @@ private:
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
vtkm::worklet::DispatcherMapTopology<
|
||||
vtkm::worklet::CellAverage,DeviceAdapterTag> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar"),
|
||||
cellset,
|
||||
result);
|
||||
|
||||
|
@ -125,7 +125,7 @@ void TestDataSet_Explicit()
|
||||
//run a basic for-each topology algorithm on this
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar"),
|
||||
subset,
|
||||
result);
|
||||
|
||||
@ -173,7 +173,7 @@ void TestDataSet_Structured2D()
|
||||
//run a basic for-each topology algorithm on this
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar"),
|
||||
subset,
|
||||
result);
|
||||
|
||||
@ -218,7 +218,7 @@ void TestDataSet_Structured3D()
|
||||
//run a basic for-each topology algorithm on this
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar"),
|
||||
subset,
|
||||
result);
|
||||
|
||||
|
@ -158,24 +158,6 @@ ThreeDimRectilinearTest()
|
||||
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DRectilinearDataSet0();
|
||||
|
||||
/*
|
||||
dataSet.PrintSummary(std::cout);
|
||||
vtkm::cont::CoordinateSystem cs = dataSet.GetCoordinateSystem();
|
||||
vtkm::cont::DynamicArrayHandleCoordinateSystem dcs = cs.GetData();
|
||||
vtkm::cont::ArrayHandleCartesianProduct<
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> > coords;
|
||||
dcs.CastToArrayHandle(coords);
|
||||
vtkm::Id n = dcs.GetNumberOfValues();
|
||||
vtkm::Vec<vtkm::Float32, 3> pt(0,0,0);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
pt = coords.GetPortalConstControl().Get(i);
|
||||
std::cout<<i<<": ["<<pt[0]<<" "<<pt[1]<<" "<<pt[2]<<"]"<<std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
dataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
|
||||
|
@ -152,7 +152,7 @@ void CheckDynamicArray(
|
||||
{
|
||||
BasicDynamicArrayChecks(array, numComponents);
|
||||
|
||||
array.CastAndCall(CheckFunctor());
|
||||
CastAndCall(array,CheckFunctor());
|
||||
|
||||
VTKM_TEST_ASSERT(CheckCalled,
|
||||
"The functor was never called (and apparently a bad value exception not thrown).");
|
||||
|
@ -66,6 +66,12 @@ void CheckDynamicCellSet(
|
||||
CheckCalled = false;
|
||||
dynamicCellSet.CastAndCall(CheckFunctor<CellSetType>());
|
||||
|
||||
VTKM_TEST_ASSERT(CheckCalled,
|
||||
"The functor was never called (and apparently a bad value exception not thrown).");
|
||||
|
||||
CheckCalled = false;
|
||||
CastAndCall(dynamicCellSet, CheckFunctor<CellSetType>());
|
||||
|
||||
VTKM_TEST_ASSERT(CheckCalled,
|
||||
"The functor was never called (and apparently a bad value exception not thrown).");
|
||||
}
|
||||
|
@ -105,7 +105,8 @@ vtkm::filter::ResultDataSet ExternalFaces::DoExecute(const vtkm::cont::DataSet&
|
||||
vtkm::cont::DataSet output;
|
||||
bool workletRan = false;
|
||||
ExternalFacesWorkletWrapper<DeviceAdapter> wrapper(output, workletRan);
|
||||
vtkm::filter::ApplyPolicyUnstructured(cells,policy).CastAndCall( wrapper );
|
||||
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyUnstructured(cells,policy),
|
||||
wrapper);
|
||||
|
||||
if(!workletRan)
|
||||
{
|
||||
|
@ -127,7 +127,8 @@ bool FilterDataSet<Derived>::MapFieldOntoOutput(ResultDataSet& result,
|
||||
valid);
|
||||
|
||||
typedef vtkm::filter::FilterTraits< Derived > Traits;
|
||||
vtkm::filter::ApplyPolicy(field, policy, Traits()).CastAndCall(functor);
|
||||
vtkm::cont::CastAndCall( vtkm::filter::ApplyPolicy(field, policy, Traits()),
|
||||
functor );
|
||||
}
|
||||
|
||||
//the bool valid will be modified by the map algorithm to hold if the
|
||||
|
@ -130,8 +130,8 @@ ResultDataSet FilterDataSetWithField<Derived>::PrepareForExecution(const vtkm::c
|
||||
result);
|
||||
|
||||
typedef vtkm::filter::FilterTraits< Derived > Traits;
|
||||
vtkm::filter::ApplyPolicy(field, policy, Traits()).CastAndCall(functor);
|
||||
|
||||
vtkm::cont::CastAndCall( vtkm::filter::ApplyPolicy(field, policy, Traits()),
|
||||
functor );
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -158,7 +158,8 @@ ResultDataSet FilterDataSetWithField<Derived>::PrepareForExecution(const vtkm::c
|
||||
result);
|
||||
|
||||
typedef vtkm::filter::FilterTraits< Derived > Traits;
|
||||
vtkm::filter::ApplyPolicy(field, policy, Traits()).CastAndCall(functor);
|
||||
vtkm::cont::CastAndCall( vtkm::filter::ApplyPolicy(field, policy, Traits()),
|
||||
functor );
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -192,7 +193,8 @@ bool FilterDataSetWithField<Derived>::MapFieldOntoOutput(ResultDataSet& result,
|
||||
valid);
|
||||
|
||||
typedef vtkm::filter::FilterTraits< Derived > Traits;
|
||||
vtkm::filter::ApplyPolicy(field, policy, Traits()).CastAndCall(functor);
|
||||
vtkm::cont::CastAndCall( vtkm::filter::ApplyPolicy(field, policy, Traits()),
|
||||
functor );
|
||||
}
|
||||
|
||||
//the bool valid will be modified by the map algorithm to hold if the
|
||||
|
@ -119,7 +119,8 @@ ResultField FilterField<Derived>::PrepareForExecution(const vtkm::cont::DataSet
|
||||
result);
|
||||
|
||||
typedef vtkm::filter::FilterTraits< Derived > Traits;
|
||||
vtkm::filter::ApplyPolicy(field, policy, Traits()).CastAndCall(functor);
|
||||
vtkm::cont::CastAndCall( vtkm::filter::ApplyPolicy(field, policy, Traits()),
|
||||
functor );
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -146,7 +147,8 @@ ResultField FilterField<Derived>::PrepareForExecution(const vtkm::cont::DataSet
|
||||
result);
|
||||
|
||||
typedef vtkm::filter::FilterTraits< Derived > Traits;
|
||||
vtkm::filter::ApplyPolicy(field, policy, Traits()).CastAndCall(functor);
|
||||
vtkm::cont::CastAndCall( vtkm::filter::ApplyPolicy(field, policy, Traits()),
|
||||
functor );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,8 @@ vtkm::filter::ResultDataSet Threshold::DoExecute(const vtkm::cont::DataSet& inpu
|
||||
//can use to reduce code duplication, and make it easier to write filters
|
||||
//that return complex dataset types.
|
||||
AddPermutationCellSet addCellSet(output, this->ValidCellIds);
|
||||
vtkm::filter::ApplyPolicy(cells, policy).CastAndCall(addCellSet);
|
||||
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicy(cells, policy),
|
||||
addCellSet);
|
||||
|
||||
//todo: We need to generate a new output policy that replaces
|
||||
//the original storage tag with a new storage tag where everything is
|
||||
|
@ -358,9 +358,10 @@ protected:
|
||||
this->DataSet.AddField(vtkm::cont::Field(name, association, data));
|
||||
break;
|
||||
case vtkm::cont::Field::ASSOC_CELL_SET:
|
||||
data.CastAndCall(PermuteCellData(this->CellsPermutation, data));
|
||||
vtkm::cont::CastAndCall( data,
|
||||
PermuteCellData(this->CellsPermutation, data) );
|
||||
this->DataSet.AddField(
|
||||
vtkm::cont::Field(name, association, "cells", data));
|
||||
vtkm::cont::Field(name, association, "cells", data));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -165,10 +165,10 @@ private:
|
||||
vtkm::Id npoints = cdata.GetNumberOfValues();
|
||||
|
||||
std::string typeName;
|
||||
cdata.CastAndCall(detail::GetDataTypeName(typeName));
|
||||
vtkm::cont::CastAndCall(cdata, detail::GetDataTypeName(typeName));
|
||||
|
||||
out << "POINTS " << npoints << " " << typeName << " " << std::endl;
|
||||
cdata.CastAndCall(detail::OutputPointsFunctor(out));
|
||||
vtkm::cont::CastAndCall(cdata, detail::OutputPointsFunctor(out));
|
||||
}
|
||||
|
||||
template <class CellSetType>
|
||||
@ -242,13 +242,13 @@ private:
|
||||
}
|
||||
|
||||
std::string typeName;
|
||||
field.GetData().CastAndCall(detail::GetDataTypeName(typeName));
|
||||
vtkm::cont::CastAndCall(field, detail::GetDataTypeName(typeName));
|
||||
|
||||
out << "SCALARS " << field.GetName() << " "
|
||||
<< typeName << " " << ncomps << std::endl;
|
||||
out << "LOOKUP_TABLE default" << std::endl;
|
||||
|
||||
field.GetData().CastAndCall(detail::OutputFieldFunctor(out));
|
||||
vtkm::cont::CastAndCall(field, detail::OutputFieldFunctor(out));
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,13 +281,13 @@ private:
|
||||
}
|
||||
|
||||
std::string typeName;
|
||||
field.GetData().CastAndCall(detail::GetDataTypeName(typeName));
|
||||
vtkm::cont::CastAndCall(field, detail::GetDataTypeName(typeName));
|
||||
|
||||
out << "SCALARS " << field.GetName() << " "
|
||||
<< typeName << " " << ncomps << std::endl;
|
||||
out << "LOOKUP_TABLE default" << std::endl;
|
||||
|
||||
field.GetData().CastAndCall(detail::OutputFieldFunctor(out));
|
||||
vtkm::cont::CastAndCall(field, detail::OutputFieldFunctor(out));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ public:
|
||||
rays.U,
|
||||
rays.V,
|
||||
rays.Scalar,
|
||||
scalarField->GetData());
|
||||
*scalarField);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -268,7 +268,7 @@ public:
|
||||
vtkm::Float32(scalarRange.Max)) )
|
||||
.Invoke(rays.HitIdx,
|
||||
rays.Scalar,
|
||||
scalarField->GetData());
|
||||
*scalarField);
|
||||
}
|
||||
} // Run
|
||||
|
||||
|
@ -1014,7 +1014,7 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
|
||||
Rays.MinDistance,
|
||||
Rays.MaxDistance,
|
||||
camera.FrameBuffer,
|
||||
ScalarField->GetData());
|
||||
*ScalarField);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1029,7 +1029,7 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
|
||||
Rays.MinDistance,
|
||||
Rays.MaxDistance,
|
||||
camera.FrameBuffer,
|
||||
ScalarField->GetData());
|
||||
*ScalarField);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1050,7 +1050,7 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
|
||||
Rays.MinDistance,
|
||||
Rays.MaxDistance,
|
||||
camera.FrameBuffer,
|
||||
ScalarField->GetData());
|
||||
*ScalarField);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1065,7 +1065,7 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
|
||||
Rays.MinDistance,
|
||||
Rays.MaxDistance,
|
||||
camera.FrameBuffer,
|
||||
ScalarField->GetData());
|
||||
*ScalarField);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ public:
|
||||
vtkm::cont::CellSetExplicit<> output;
|
||||
ClipWithImplicitFunction<ImplicitFunction> clip(this, cellSet, clipFunction,
|
||||
&output);
|
||||
coords.GetData().CastAndCall(clip);
|
||||
CastAndCall(coords, clip);
|
||||
|
||||
return output;
|
||||
}
|
||||
@ -683,14 +683,14 @@ public:
|
||||
vtkm::cont::DynamicArrayHandle *Output;
|
||||
};
|
||||
|
||||
template <typename DynamicArrayHandleType>
|
||||
template <typename FieldType>
|
||||
vtkm::cont::DynamicArrayHandle ProcessField(
|
||||
const DynamicArrayHandleType &fieldData) const
|
||||
const FieldType &fieldData) const
|
||||
{
|
||||
vtkm::cont::DynamicArrayHandle output;
|
||||
fieldData.CastAndCall(InterpolateField(this->NewPointsInterpolation,
|
||||
this->NewPointsOffset,
|
||||
&output));
|
||||
CastAndCall(fieldData, InterpolateField(this->NewPointsInterpolation,
|
||||
this->NewPointsOffset,
|
||||
&output));
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
|
||||
ThresholdWorklet worklet(predicate);
|
||||
DispatcherMapTopology<ThresholdWorklet, DeviceAdapter> dispatcher(worklet);
|
||||
dispatcher.Invoke(cellSet, field.GetData(), passFlags);
|
||||
dispatcher.Invoke(cellSet, field, passFlags);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public:
|
||||
|
||||
ThresholdWorklet worklet(predicate);
|
||||
DispatcherMapTopology<ThresholdWorklet, DeviceAdapter> dispatcher(worklet);
|
||||
dispatcher.Invoke(cellSet, field.GetData(), passFlags);
|
||||
dispatcher.Invoke(cellSet, field, passFlags);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ public:
|
||||
}
|
||||
|
||||
vtkm::cont::DynamicArrayHandle data;
|
||||
field.GetData().CastAndCall(PermuteCellData(this->ValidCellIds, data));
|
||||
CastAndCall(field, PermuteCellData(this->ValidCellIds, data));
|
||||
|
||||
return vtkm::cont::Field(field.GetName(), field.GetAssociation(),
|
||||
field.GetAssocCellSet(), data);
|
||||
|
@ -305,7 +305,6 @@ struct VertexClustering
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
@ -375,8 +374,10 @@ public:
|
||||
internal::AverageByKeyDynamicValue<vtkm::cont::ArrayHandle<vtkm::Id>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>,
|
||||
DeviceAdapter>
|
||||
averageByKey(pointCidArray, pointCidArrayReduced, repPointArray);
|
||||
coordinates.CastAndCall(averageByKey);
|
||||
averageByKey(pointCidArray,
|
||||
pointCidArrayReduced,
|
||||
repPointArray);
|
||||
CastAndCall(coordinates, averageByKey);
|
||||
|
||||
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
|
||||
std::cout << "Time after averaging (s): " << timer.GetElapsedTime() << std::endl;
|
||||
|
@ -40,7 +40,7 @@ void TestCellAverageUniform3D()
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar"),
|
||||
dataSet.GetCellSet(),
|
||||
result);
|
||||
|
||||
@ -63,7 +63,7 @@ void TestCellAverageUniform2D()
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar"),
|
||||
dataSet.GetCellSet(),
|
||||
result);
|
||||
|
||||
@ -86,7 +86,7 @@ void TestCellAverageExplicit()
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar"),
|
||||
dataSet.GetCellSet(),
|
||||
result);
|
||||
|
||||
|
@ -120,13 +120,15 @@ void TestClippingExplicit()
|
||||
|
||||
vtkm::worklet::Clip<DeviceAdapter> clip;
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||
clip.Run(ds.GetCellSet(0), ds.GetField("scalars").GetData(), clipValue);
|
||||
clip.Run(ds.GetCellSet(0),
|
||||
ds.GetField("scalars").GetData(),
|
||||
clipValue);
|
||||
|
||||
|
||||
vtkm::cont::DynamicArrayHandle coords =
|
||||
clip.ProcessField(ds.GetCoordinateSystem("coords").GetData());
|
||||
clip.ProcessField(ds.GetCoordinateSystem("coords"));
|
||||
vtkm::cont::DynamicArrayHandle scalars =
|
||||
clip.ProcessField(ds.GetField("scalars").GetData());
|
||||
clip.ProcessField(ds.GetField("scalars"));
|
||||
|
||||
|
||||
vtkm::Id connectivitySize = 12;
|
||||
@ -169,13 +171,15 @@ void TestClippingStrucutred()
|
||||
|
||||
vtkm::worklet::Clip<DeviceAdapter> clip;
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||
clip.Run(ds.GetCellSet(0), ds.GetField("scalars").GetData(), clipValue);
|
||||
clip.Run(ds.GetCellSet(0),
|
||||
ds.GetField("scalars").GetData(),
|
||||
clipValue);
|
||||
|
||||
|
||||
vtkm::cont::DynamicArrayHandle coords =
|
||||
clip.ProcessField(ds.GetCoordinateSystem("coords").GetData());
|
||||
clip.ProcessField(ds.GetCoordinateSystem("coords"));
|
||||
vtkm::cont::DynamicArrayHandle scalars =
|
||||
clip.ProcessField(ds.GetField("scalars").GetData());
|
||||
clip.ProcessField(ds.GetField("scalars"));
|
||||
|
||||
vtkm::Id connectivitySize = 36;
|
||||
vtkm::Id fieldSize = 13;
|
||||
@ -228,9 +232,9 @@ void TestClippingWithImplicitFunction()
|
||||
|
||||
|
||||
vtkm::cont::DynamicArrayHandle coords =
|
||||
clip.ProcessField(ds.GetCoordinateSystem("coords").GetData());
|
||||
clip.ProcessField(ds.GetCoordinateSystem("coords"));
|
||||
vtkm::cont::DynamicArrayHandle scalars =
|
||||
clip.ProcessField(ds.GetField("scalars").GetData());
|
||||
clip.ProcessField(ds.GetField("scalars"));
|
||||
|
||||
vtkm::Id connectivitySize = 36;
|
||||
vtkm::Id fieldSize = 13;
|
||||
|
@ -308,7 +308,7 @@ void TestMarchingCubesExplicit()
|
||||
|
||||
marchingCubes.Run(contourValue,
|
||||
cellSet,
|
||||
dataSet.GetCoordinateSystem().GetData(),
|
||||
dataSet.GetCoordinateSystem(),
|
||||
contourArray,
|
||||
vertices,
|
||||
normals,
|
||||
|
@ -90,7 +90,7 @@ void TestPointElevation()
|
||||
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointElevation>
|
||||
dispatcher(pointElevationWorklet);
|
||||
dispatcher.Invoke(dataSet.GetCoordinateSystem().GetData(),
|
||||
dispatcher.Invoke(dataSet.GetCoordinateSystem(),
|
||||
result);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,3> > coordinates;
|
||||
|
@ -42,7 +42,7 @@ void TestVertexClustering()
|
||||
// run
|
||||
vtkm::worklet::VertexClustering clustering;
|
||||
vtkm::cont::DataSet outDataSet = clustering.Run(dataSet.GetCellSet(),
|
||||
dataSet.GetCoordinateSystem().GetData(),
|
||||
dataSet.GetCoordinateSystem(),
|
||||
bounds,
|
||||
divisions,
|
||||
VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
|
@ -154,8 +154,8 @@ TestMaxPointOrCell()
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_explicit::MaxPointOrCellValue >
|
||||
dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar").GetData(),
|
||||
dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar"),
|
||||
dataSet.GetField("pointvar"),
|
||||
dataSet.GetCellSet(0),
|
||||
result);
|
||||
|
||||
@ -177,7 +177,7 @@ TestAvgPointToCell()
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_explicit::AveragePointToCellValue > dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar"),
|
||||
dataSet.GetCellSet(),
|
||||
result);
|
||||
|
||||
@ -200,7 +200,7 @@ TestAvgCellToPoint()
|
||||
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_explicit::AverageCellToPointValue > dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar"),
|
||||
dataSet.GetCellSet(),
|
||||
result);
|
||||
|
||||
|
@ -181,8 +181,8 @@ TestMaxPointOrCell()
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_uniform::MaxPointOrCellValue > dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar").GetData(),
|
||||
dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar"),
|
||||
dataSet.GetField("pointvar"),
|
||||
// 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
|
||||
@ -209,7 +209,7 @@ TestAvgPointToCell()
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_uniform::AveragePointToCellValue > dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("pointvar"),
|
||||
// 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
|
||||
@ -236,7 +236,7 @@ TestAvgCellToPoint()
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_uniform::AverageCellToPointValue > dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar").GetData(),
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar"),
|
||||
// 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
|
||||
@ -265,11 +265,11 @@ TestStructuredUniformPointCoords()
|
||||
|
||||
vtkm::cont::DataSet dataSet3D = testDataSet.Make3DUniformDataSet0();
|
||||
dispatcher.Invoke(dataSet3D.GetCellSet(),
|
||||
dataSet3D.GetCoordinateSystem().GetData());
|
||||
dataSet3D.GetCoordinateSystem());
|
||||
|
||||
vtkm::cont::DataSet dataSet2D = testDataSet.Make2DUniformDataSet0();
|
||||
dispatcher.Invoke(dataSet2D.GetCellSet(),
|
||||
dataSet2D.GetCoordinateSystem().GetData());
|
||||
dataSet2D.GetCoordinateSystem());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
Loading…
Reference in New Issue
Block a user