mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
CoordinateSystem data is VariantArrayHandle
`CoordinateSystem` differed from `Field` in that its `GetData` method returned an `ArrayHandleVirtualCoordinates` instead of a `VariantArrayHandle`. This is probably confusing since `CoordianteSystem` inherits `Field` and has a pretty dramatic difference in this behavior. In preparation to deprecate `ArrayHandleVirtualCoordinates`, this changes `CoordiantSystem` to be much more like `Field`. (In the future, we may change the `CoordinateSystem` to point to a `Field` rather than be a special `Field`.) A method named `GetDataAsMultiplexer` has been added to `CoordinateSystem`. This method allows you to get data from `CoordinateSystem` as a single array type without worrying about creating functors to handle different types and without needing virtual methods.
This commit is contained in:
parent
e2027da0c3
commit
be7f06bbe7
@ -110,6 +110,39 @@ VTKM_CONT void ArrayCopy(const vtkm::cont::ArrayHandle<InValueType, InStorage>&
|
||||
// Static dispatch cases 1 & 2
|
||||
detail::ArrayCopyImpl(source, destination, JustCopyStorage{});
|
||||
}
|
||||
|
||||
// Forward declaration
|
||||
// Cannot include VariantArrayHandle.h here due to circular dependency.
|
||||
template <typename TypeList>
|
||||
class VariantArrayHandleBase;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct ArrayCopyFunctor
|
||||
{
|
||||
template <typename InValueType, typename InStorage, typename OutValueType, typename OutStorage>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<InValueType, InStorage>& source,
|
||||
vtkm::cont::ArrayHandle<OutValueType, OutStorage>& destination) const
|
||||
{
|
||||
vtkm::cont::ArrayCopy(source, destination);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// \brief Deep copies data in a `VariantArrayHandle` to an array of a known type.
|
||||
///
|
||||
/// This form of `ArrayCopy` can be used to copy data from an unknown array type to
|
||||
/// an array of a known type. Note that regardless of the source type, the data will
|
||||
/// be deep copied.
|
||||
///
|
||||
template <typename InTypeList, typename OutValueType, typename OutStorage>
|
||||
VTKM_CONT void ArrayCopy(const vtkm::cont::VariantArrayHandleBase<InTypeList>& source,
|
||||
vtkm::cont::ArrayHandle<OutValueType, OutStorage>& destination)
|
||||
{
|
||||
source.CastAndCall(detail::ArrayCopyFunctor{}, destination);
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -128,7 +128,6 @@ set(template_sources
|
||||
CellSetExtrude.hxx
|
||||
CellSetStructured.hxx
|
||||
ColorTable.hxx
|
||||
CoordinateSystem.hxx
|
||||
FieldRangeCompute.hxx
|
||||
FieldRangeGlobalCompute.hxx
|
||||
StorageVirtual.hxx
|
||||
|
@ -234,7 +234,7 @@ void CellLocatorBoundingIntervalHierarchy::Build()
|
||||
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
|
||||
vtkm::Id numCells = cellSet.GetNumberOfCells();
|
||||
vtkm::cont::CoordinateSystem coords = this->GetCoordinates();
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates points = coords.GetData();
|
||||
auto points = coords.GetDataAsMultiplexer();
|
||||
|
||||
//std::cout << "No of cells: " << numCells << "\n";
|
||||
//std::cout.precision(3);
|
||||
@ -457,7 +457,7 @@ struct CellLocatorBIHPrepareForExecutionFunctor
|
||||
vtkm::cont::VirtualObjectHandle<vtkm::exec::CellLocator>& bihExec,
|
||||
const vtkm::cont::ArrayHandle<vtkm::exec::CellLocatorBoundingIntervalHierarchyNode>& nodes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& processedCellIds,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coords) const
|
||||
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coords) const
|
||||
{
|
||||
using ExecutionType =
|
||||
vtkm::exec::CellLocatorBoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
|
||||
@ -501,7 +501,7 @@ const vtkm::exec::CellLocator* CellLocatorBoundingIntervalHierarchy::PrepareForE
|
||||
this->ExecutionObjectHandle,
|
||||
this->Nodes,
|
||||
this->ProcessedCellIds,
|
||||
this->GetCoordinates().GetData());
|
||||
this->GetCoordinates().GetDataAsMultiplexer());
|
||||
return this->ExecutionObjectHandle.PrepareForExecution(device, token);
|
||||
;
|
||||
}
|
||||
|
@ -94,9 +94,9 @@ private:
|
||||
using ArrayPortalConst =
|
||||
typename vtkm::cont::ArrayHandle<T>::template ExecutionTypes<DeviceAdapter>::PortalConst;
|
||||
|
||||
using CoordsPortalType = decltype(vtkm::cont::ArrayHandleVirtualCoordinates{}.PrepareForInput(
|
||||
DeviceAdapter{},
|
||||
std::declval<vtkm::cont::Token&>()));
|
||||
using CoordsPortalType =
|
||||
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst;
|
||||
|
||||
using CellSetP2CExecType =
|
||||
decltype(std::declval<CellSetType>().PrepareForInput(DeviceAdapter{},
|
||||
@ -150,7 +150,7 @@ public:
|
||||
vtkm::TopologyElementTagCell{},
|
||||
vtkm::TopologyElementTagPoint{},
|
||||
token))
|
||||
, Coords(coords.GetData().PrepareForInput(DeviceAdapter{}, token))
|
||||
, Coords(coords.GetDataAsMultiplexer().PrepareForInput(DeviceAdapter{}, token))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -81,12 +81,10 @@ struct CellLocatorUniformGridPrepareForExecutionFunctor
|
||||
template <typename DeviceAdapter, typename... Args>
|
||||
VTKM_CONT bool operator()(DeviceAdapter,
|
||||
vtkm::cont::VirtualObjectHandle<vtkm::exec::CellLocator>& execLocator,
|
||||
vtkm::cont::Token& token,
|
||||
Args&&... args) const
|
||||
{
|
||||
using ExecutionType = vtkm::exec::CellLocatorUniformGrid<DeviceAdapter, dimensions>;
|
||||
ExecutionType* execObject =
|
||||
new ExecutionType(std::forward<Args>(args)..., DeviceAdapter(), token);
|
||||
ExecutionType* execObject = new ExecutionType(std::forward<Args>(args)..., DeviceAdapter());
|
||||
execLocator.Reset(execObject);
|
||||
return true;
|
||||
}
|
||||
@ -103,26 +101,22 @@ const vtkm::exec::CellLocator* CellLocatorUniformGrid::PrepareForExecution(
|
||||
success = vtkm::cont::TryExecuteOnDevice(device,
|
||||
CellLocatorUniformGridPrepareForExecutionFunctor<3>(),
|
||||
this->ExecutionObjectHandle,
|
||||
token,
|
||||
this->CellDims,
|
||||
this->PointDims,
|
||||
this->Origin,
|
||||
this->InvSpacing,
|
||||
this->MaxPoint,
|
||||
this->GetCoordinates().GetData());
|
||||
this->MaxPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = vtkm::cont::TryExecuteOnDevice(device,
|
||||
CellLocatorUniformGridPrepareForExecutionFunctor<2>(),
|
||||
this->ExecutionObjectHandle,
|
||||
token,
|
||||
this->CellDims,
|
||||
this->PointDims,
|
||||
this->Origin,
|
||||
this->InvSpacing,
|
||||
this->MaxPoint,
|
||||
this->GetCoordinates().GetData());
|
||||
this->MaxPoint);
|
||||
}
|
||||
if (!success)
|
||||
{
|
||||
|
@ -10,22 +10,30 @@
|
||||
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/CoordinateSystem.hxx>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates CoordDataDepWrapper::ToArray() const
|
||||
{
|
||||
return this->Cast<vtkm::cont::ArrayHandleVirtualCoordinates>();
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem()
|
||||
: Superclass()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& data)
|
||||
: Superclass(name, Association::POINTS, data)
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(std::string name,
|
||||
const vtkm::cont::VariantArrayHandleCommon& data)
|
||||
: Superclass(name, Association::POINTS, vtkm::cont::VariantArrayHandle{ data })
|
||||
{
|
||||
}
|
||||
|
||||
@ -38,21 +46,19 @@ CoordinateSystem::CoordinateSystem(std::string name,
|
||||
vtkm::Vec3f spacing)
|
||||
: Superclass(name,
|
||||
Association::POINTS,
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates(
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing)))
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates CoordinateSystem::GetData() const
|
||||
VTKM_CONT vtkm::cont::detail::CoordDataDepWrapper CoordinateSystem::GetData() const
|
||||
{
|
||||
return this->Superclass::GetData().Cast<vtkm::cont::ArrayHandleVirtualCoordinates>();
|
||||
return vtkm::cont::detail::CoordDataDepWrapper(this->Superclass::GetData());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void CoordinateSystem::SetData(const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& newdata)
|
||||
VTKM_CONT vtkm::cont::CoordinateSystem::MultiplexerArrayType
|
||||
CoordinateSystem::GetDataAsMultiplexer() const
|
||||
{
|
||||
this->Superclass::SetData(newdata);
|
||||
return this->GetData().AsMultiplexer<MultiplexerArrayType>();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -103,14 +109,5 @@ template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>>::StorageTag>&);
|
||||
|
||||
template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(std::string name,
|
||||
const vtkm::cont::VariantArrayHandle&);
|
||||
|
||||
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<float, 3>>&);
|
||||
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<double, 3>>&);
|
||||
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(const vtkm::cont::VariantArrayHandle&);
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define vtk_m_cont_CoordinateSystem_h
|
||||
|
||||
#include <vtkm/Bounds.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCast.h>
|
||||
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
|
||||
@ -21,25 +22,112 @@ namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// CoordinateSystem::GetData used to return an ArrayHandleVirtualCoordinates.
|
||||
// That behavior is deprecated, and CoordianteSystem::GetData now returns a
|
||||
// VariantArrayHandle similar (although slightly different than) its superclass.
|
||||
// This wrapper class supports the old deprecated behavior until it is no longer
|
||||
// supported. Once the behavior is removed (probably when
|
||||
// ArrayHandleVirtualCoordinates is removed), then this class should be removed.
|
||||
class VTKM_ALWAYS_EXPORT CoordDataDepWrapper
|
||||
: public vtkm::cont::VariantArrayHandleBase<vtkm::List<vtkm::Vec3f>>
|
||||
{
|
||||
using Superclass = vtkm::cont::VariantArrayHandleBase<vtkm::List<vtkm::Vec3f>>;
|
||||
|
||||
VTKM_CONT_EXPORT VTKM_CONT vtkm::cont::ArrayHandleVirtualCoordinates ToArray() const;
|
||||
|
||||
public:
|
||||
using Superclass::Superclass;
|
||||
|
||||
// Make the return also behave as ArrayHandleVirtualCoordiantes
|
||||
// TODO: Deprecate this behavior
|
||||
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
operator vtkm::cont::ArrayHandleVirtualCoordinates() const
|
||||
{
|
||||
return this->ToArray();
|
||||
}
|
||||
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
operator vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagVirtual>() const
|
||||
{
|
||||
return this->ToArray();
|
||||
}
|
||||
|
||||
using ValueType VTKM_DEPRECATED(1.6,
|
||||
"CoordinateSystem::GetData() now returns a VariantArrayHandle.") =
|
||||
vtkm::Vec3f;
|
||||
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
ArrayHandleVirtualCoordinates::ReadPortalType ReadPortal() const
|
||||
{
|
||||
return this->ToArray().ReadPortal();
|
||||
}
|
||||
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
ArrayHandleVirtualCoordinates::WritePortalType WritePortal() const
|
||||
{
|
||||
return this->ToArray().WritePortal();
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
typename ArrayHandleVirtualCoordinates::ExecutionTypes<Device>::PortalConst
|
||||
PrepareForInput(Device device, vtkm::cont::Token& token) const
|
||||
{
|
||||
return this->ToArray().PrepareForInput(device, token);
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
typename ArrayHandleVirtualCoordinates::ExecutionTypes<Device>::Portal
|
||||
PrepareForInPlace(Device device, vtkm::cont::Token& token) const
|
||||
{
|
||||
return this->ToArray().PrepareForInPlace(device, token);
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
typename ArrayHandleVirtualCoordinates::ExecutionTypes<Device>::Portal
|
||||
PrepareForOutput(vtkm::Id numberOfValues, Device device, vtkm::cont::Token& token) const
|
||||
{
|
||||
return this->ToArray().PrepareForOutput(numberOfValues, device, token);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
VTKM_CONT VTKM_DEPRECATED(
|
||||
1.6,
|
||||
"CoordinateSystem::GetData() now returns a "
|
||||
"VariantArrayHandle.") inline void printSummary_ArrayHandle(const detail::CoordDataDepWrapper&
|
||||
array,
|
||||
std::ostream& out,
|
||||
bool full = false)
|
||||
{
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates coordArray = array;
|
||||
vtkm::cont::printSummary_ArrayHandle(coordArray, out, full);
|
||||
}
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
|
||||
class VTKM_CONT_EXPORT CoordinateSystem : public vtkm::cont::Field
|
||||
{
|
||||
using Superclass = vtkm::cont::Field;
|
||||
using CoordinatesTypeList = vtkm::List<vtkm::cont::ArrayHandleVirtualCoordinates::ValueType>;
|
||||
using CoordinatesTypeList = vtkm::List<vtkm::Vec3f_32, vtkm::Vec3f_64>;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
CoordinateSystem();
|
||||
|
||||
VTKM_CONT CoordinateSystem(std::string name,
|
||||
const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& data);
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT CoordinateSystem(std::string name,
|
||||
const vtkm::cont::VariantArrayHandleBase<TypeList>& data);
|
||||
VTKM_CONT CoordinateSystem(std::string name, const vtkm::cont::VariantArrayHandleCommon& data);
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT CoordinateSystem(std::string name, const ArrayHandle<T, Storage>& data)
|
||||
: Superclass(name, Association::POINTS, vtkm::cont::ArrayHandleVirtualCoordinates(data))
|
||||
: Superclass(name, Association::POINTS, data)
|
||||
{
|
||||
}
|
||||
|
||||
@ -54,17 +142,32 @@ public:
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfPoints() const { return this->GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates GetData() const;
|
||||
VTKM_CONT detail::CoordDataDepWrapper GetData() const;
|
||||
|
||||
VTKM_CONT void SetData(const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& newdata);
|
||||
private:
|
||||
struct StorageToArray
|
||||
{
|
||||
template <typename S>
|
||||
using IsInvalid = vtkm::cont::internal::IsInvalidArrayHandle<vtkm::Vec3f, S>;
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void SetData(const vtkm::cont::ArrayHandle<T, Storage>& newdata);
|
||||
template <typename S>
|
||||
using Transform = vtkm::cont::ArrayHandle<vtkm::Vec3f, S>;
|
||||
};
|
||||
|
||||
VTKM_CONT
|
||||
template <typename TypeList>
|
||||
void SetData(const vtkm::cont::VariantArrayHandleBase<TypeList>& newdata);
|
||||
public:
|
||||
using MultiplexerArrayType = //
|
||||
vtkm::cont::ArrayHandleMultiplexerFromList< //
|
||||
vtkm::ListTransform< //
|
||||
vtkm::ListRemoveIf<VTKM_DEFAULT_STORAGE_LIST, StorageToArray::IsInvalid>, //
|
||||
StorageToArray::Transform>>;
|
||||
|
||||
/// \brief Returns the data for the coordinate system as an `ArrayHandleMultiplexer`.
|
||||
///
|
||||
/// This array will handle all potential types supported by CoordinateSystem, so all types can be
|
||||
/// handled with one compile pass. However, using this precludes specialization for special
|
||||
/// arrays such as `ArrayHandleUniformPointCoordinates` that could have optimized code paths
|
||||
///
|
||||
VTKM_CONT MultiplexerArrayType GetDataAsMultiplexer() const;
|
||||
|
||||
VTKM_CONT
|
||||
void GetRange(vtkm::Range* range) const
|
||||
@ -138,6 +241,12 @@ struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
|
||||
using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct DynamicTransformTraits<vtkm::cont::detail::CoordDataDepWrapper>
|
||||
{
|
||||
using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
@ -148,22 +257,32 @@ struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
|
||||
namespace mangled_diy_namespace
|
||||
{
|
||||
|
||||
template <>
|
||||
struct Serialization<vtkm::cont::detail::CoordDataDepWrapper>
|
||||
: public Serialization<
|
||||
vtkm::cont::VariantArrayHandleBase<vtkm::List<vtkm::Vec3f_32, vtkm::Vec3f_64>>>
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Serialization<vtkm::cont::CoordinateSystem>
|
||||
{
|
||||
using CoordinatesTypeList = vtkm::List<vtkm::Vec3f_32, vtkm::Vec3f_64>;
|
||||
|
||||
static VTKM_CONT void save(BinaryBuffer& bb, const vtkm::cont::CoordinateSystem& cs)
|
||||
{
|
||||
vtkmdiy::save(bb, cs.GetName());
|
||||
vtkmdiy::save(bb, cs.GetData());
|
||||
vtkmdiy::save(
|
||||
bb, static_cast<vtkm::cont::VariantArrayHandleBase<CoordinatesTypeList>>(cs.GetData()));
|
||||
}
|
||||
|
||||
static VTKM_CONT void load(BinaryBuffer& bb, vtkm::cont::CoordinateSystem& cs)
|
||||
{
|
||||
std::string name;
|
||||
vtkmdiy::load(bb, name);
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates array;
|
||||
vtkmdiy::load(bb, array);
|
||||
cs = vtkm::cont::CoordinateSystem(name, array);
|
||||
vtkm::cont::VariantArrayHandleBase<CoordinatesTypeList> data;
|
||||
vtkmdiy::load(bb, data);
|
||||
cs = vtkm::cont::CoordinateSystem(name, data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,73 +0,0 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_CoordinateSystem_hxx
|
||||
#define vtk_m_cont_CoordinateSystem_hxx
|
||||
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct MakeArrayHandleVirtualCoordinatesFunctor
|
||||
{
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<vtkm::Vec3f_32, StorageTag>& array,
|
||||
ArrayHandleVirtualCoordinates& output) const
|
||||
{
|
||||
output = vtkm::cont::ArrayHandleVirtualCoordinates(array);
|
||||
}
|
||||
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<vtkm::Vec3f_64, StorageTag>& array,
|
||||
ArrayHandleVirtualCoordinates& output) const
|
||||
{
|
||||
output = vtkm::cont::ArrayHandleVirtualCoordinates(array);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleVirtualCoordinates MakeArrayHandleVirtualCoordinates(
|
||||
const vtkm::cont::VariantArrayHandleBase<TypeList>& array)
|
||||
{
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates output;
|
||||
vtkm::cont::CastAndCall(array.ResetTypes(vtkm::TypeListFieldVec3{}),
|
||||
MakeArrayHandleVirtualCoordinatesFunctor{},
|
||||
output);
|
||||
return output;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::VariantArrayHandleBase<TypeList>& data)
|
||||
: Superclass(name, Association::POINTS, detail::MakeArrayHandleVirtualCoordinates(data))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void CoordinateSystem::SetData(const vtkm::cont::ArrayHandle<T, Storage>& newdata)
|
||||
{
|
||||
this->SetData(vtkm::cont::ArrayHandleVirtualCoordinates(newdata));
|
||||
}
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT void CoordinateSystem::SetData(
|
||||
const vtkm::cont::VariantArrayHandleBase<TypeList>& newdata)
|
||||
{
|
||||
this->SetData(detail::MakeArrayHandleVirtualCoordinates(newdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -126,10 +126,10 @@ public:
|
||||
this->ModifiedFlag = true;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetData(const vtkm::cont::VariantArrayHandle& newdata)
|
||||
template <typename TypeList>
|
||||
VTKM_CONT void SetData(const vtkm::cont::VariantArrayHandleBase<TypeList>& newdata)
|
||||
{
|
||||
this->Data = newdata;
|
||||
this->Data = vtkm::cont::VariantArrayHandle(newdata);
|
||||
this->ModifiedFlag = true;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ struct PointLocatorUniformGrid::PrepareExecutionObjectFunctor
|
||||
rmin,
|
||||
rmax,
|
||||
self.Dims,
|
||||
self.GetCoordinates().GetData().PrepareForInput(DeviceAdapter(), token),
|
||||
self.GetCoordinates().GetDataAsMultiplexer().PrepareForInput(DeviceAdapter(), token),
|
||||
self.PointIds.PrepareForInput(DeviceAdapter(), token),
|
||||
self.CellLower.PrepareForInput(DeviceAdapter(), token),
|
||||
self.CellUpper.PrepareForInput(DeviceAdapter(), token));
|
||||
|
@ -76,10 +76,6 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims)
|
||||
vtkm::Vec<vtkm::FloatDefault, DIMENSIONS>(0.0f),
|
||||
vtkm::Vec<vtkm::FloatDefault, DIMENSIONS>(1.0f));
|
||||
|
||||
// copy points
|
||||
vtkm::cont::ArrayHandle<PointType> points;
|
||||
vtkm::cont::ArrayCopy(uniformDs.GetCoordinateSystem().GetData(), points);
|
||||
|
||||
auto uniformCs =
|
||||
uniformDs.GetCellSet().template Cast<vtkm::cont::CellSetStructured<DIMENSIONS>>();
|
||||
|
||||
@ -99,15 +95,21 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims)
|
||||
|
||||
// Warp the coordinates
|
||||
std::uniform_real_distribution<vtkm::FloatDefault> warpFactor(-0.10f, 0.10f);
|
||||
auto pointsPortal = points.WritePortal();
|
||||
for (vtkm::Id i = 0; i < pointsPortal.GetNumberOfValues(); ++i)
|
||||
auto inPointsPortal = uniformDs.GetCoordinateSystem()
|
||||
.GetData()
|
||||
.template Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>()
|
||||
.ReadPortal();
|
||||
vtkm::cont::ArrayHandle<PointType> points;
|
||||
points.Allocate(inPointsPortal.GetNumberOfValues());
|
||||
auto outPointsPortal = points.WritePortal();
|
||||
for (vtkm::Id i = 0; i < outPointsPortal.GetNumberOfValues(); ++i)
|
||||
{
|
||||
PointType warpVec(0);
|
||||
for (vtkm::IdComponent c = 0; c < DIMENSIONS; ++c)
|
||||
{
|
||||
warpVec[c] = warpFactor(RandomGenerator);
|
||||
}
|
||||
pointsPortal.Set(i, pointsPortal.Get(i) + warpVec);
|
||||
outPointsPortal.Set(i, inPointsPortal.Get(i) + warpVec);
|
||||
}
|
||||
|
||||
// build dataset
|
||||
|
@ -61,7 +61,7 @@ vtkm::cont::DataSet MakeTestDataSetRectilinear()
|
||||
vtkm::cont::DataSet MakeTestDataSetCurvilinear()
|
||||
{
|
||||
auto recti = MakeTestDataSetRectilinear();
|
||||
auto coords = recti.GetCoordinateSystem().GetData();
|
||||
auto coords = recti.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
|
||||
vtkm::cont::ArrayHandle<PointType> sheared;
|
||||
sheared.Allocate(coords.GetNumberOfValues());
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/VecFromPortalPermute.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/exec/CellInside.h>
|
||||
#include <vtkm/exec/CellLocator.h>
|
||||
#include <vtkm/exec/ParametricCoordinates.h>
|
||||
@ -74,12 +74,13 @@ public:
|
||||
CellLocatorBoundingIntervalHierarchyExec() {}
|
||||
|
||||
VTKM_CONT
|
||||
CellLocatorBoundingIntervalHierarchyExec(const NodeArrayHandle& nodes,
|
||||
const CellIdArrayHandle& cellIds,
|
||||
const CellSetType& cellSet,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
|
||||
DeviceAdapter,
|
||||
vtkm::cont::Token& token)
|
||||
CellLocatorBoundingIntervalHierarchyExec(
|
||||
const NodeArrayHandle& nodes,
|
||||
const CellIdArrayHandle& cellIds,
|
||||
const CellSetType& cellSet,
|
||||
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coords,
|
||||
DeviceAdapter,
|
||||
vtkm::cont::Token& token)
|
||||
: Nodes(nodes.PrepareForInput(DeviceAdapter(), token))
|
||||
, CellIds(cellIds.PrepareForInput(DeviceAdapter(), token))
|
||||
, CellSet(cellSet.PrepareForInput(DeviceAdapter(), VisitType(), IncidentType(), token))
|
||||
@ -277,8 +278,9 @@ private:
|
||||
using CellSetPortal = typename CellSetType::template ExecutionTypes<DeviceAdapter,
|
||||
VisitType,
|
||||
IncidentType>::ExecObjectType;
|
||||
using CoordsPortal = typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst;
|
||||
using CoordsPortal =
|
||||
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst;
|
||||
|
||||
NodePortal Nodes;
|
||||
CellIdPortal CellIds;
|
||||
|
@ -34,8 +34,6 @@ private:
|
||||
using VisitType = vtkm::TopologyElementTagCell;
|
||||
using IncidentType = vtkm::TopologyElementTagPoint;
|
||||
using CellSetPortal = vtkm::exec::ConnectivityStructured<VisitType, IncidentType, dimensions>;
|
||||
using CoordsPortal = typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
@ -44,15 +42,12 @@ public:
|
||||
const vtkm::Vec3f origin,
|
||||
const vtkm::Vec3f invSpacing,
|
||||
const vtkm::Vec3f maxPoint,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
|
||||
DeviceAdapter,
|
||||
vtkm::cont::Token& token)
|
||||
DeviceAdapter)
|
||||
: CellDims(cellDims)
|
||||
, PointDims(pointDims)
|
||||
, Origin(origin)
|
||||
, InvSpacing(invSpacing)
|
||||
, MaxPoint(maxPoint)
|
||||
, Coords(coords.PrepareForInput(DeviceAdapter(), token))
|
||||
{
|
||||
}
|
||||
|
||||
@ -120,7 +115,6 @@ private:
|
||||
vtkm::Vec3f Origin;
|
||||
vtkm::Vec3f InvSpacing;
|
||||
vtkm::Vec3f MaxPoint;
|
||||
CoordsPortal Coords;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#ifndef vtk_m_exec_PointLocatorUniformGrid_h
|
||||
#define vtk_m_exec_PointLocatorUniformGrid_h
|
||||
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
@ -29,7 +30,7 @@ class VTKM_ALWAYS_EXPORT PointLocatorUniformGrid final : public vtkm::exec::Poin
|
||||
{
|
||||
public:
|
||||
using CoordPortalType =
|
||||
typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
|
||||
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst;
|
||||
using IdPortalType =
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Id>::template ExecutionTypes<DeviceAdapter>::PortalConst;
|
||||
|
@ -108,6 +108,8 @@ VTKM_FILTER_EXPORT_EXECUTE_METHOD(ClipWithField);
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#ifndef vtk_m_filter_ClipWithField_hxx
|
||||
#include <vtkm/filter/ClipWithField.hxx>
|
||||
#endif
|
||||
|
||||
#endif // vtk_m_filter_ClipWithField_h
|
||||
|
@ -11,6 +11,8 @@
|
||||
#ifndef vtk_m_filter_ClipWithField_hxx
|
||||
#define vtk_m_filter_ClipWithField_hxx
|
||||
|
||||
#include <vtkm/filter/ClipWithField.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/CellSetPermutation.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
@ -21,6 +23,26 @@ namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct ClipWithFieldProcessCoords
|
||||
{
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& inCoords,
|
||||
const std::string& coordsName,
|
||||
const vtkm::worklet::Clip& worklet,
|
||||
vtkm::cont::DataSet& output) const
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> outArray = worklet.ProcessPointField(inCoords);
|
||||
vtkm::cont::CoordinateSystem outCoords(coordsName, outArray);
|
||||
output.AddCoordinateSystem(outCoords);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
@ -37,9 +59,6 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
//get the cells and coordinates of the dataset
|
||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
||||
|
||||
const vtkm::cont::CoordinateSystem& inputCoords =
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
|
||||
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, this->ClipValue, this->Invert);
|
||||
|
||||
@ -48,9 +67,14 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
output.SetCellSet(outputCellSet);
|
||||
|
||||
// Compute the new boundary points and add them to the output:
|
||||
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
|
||||
vtkm::cont::CoordinateSystem outputCoords(inputCoords.GetName(), outputCoordsArray);
|
||||
output.AddCoordinateSystem(outputCoords);
|
||||
for (vtkm::IdComponent coordSystemId = 0; coordSystemId < input.GetNumberOfCoordinateSystems();
|
||||
++coordSystemId)
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = input.GetCoordinateSystem(coordSystemId);
|
||||
coords.GetData().CastAndCall(
|
||||
detail::ClipWithFieldProcessCoords{}, coords.GetName(), this->Worklet, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,8 @@ VTKM_FILTER_EXPORT_EXECUTE_METHOD(ClipWithImplicitFunction);
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#ifndef vtk_m_filter_ClipWithImplicitFunction_hxx
|
||||
#include <vtkm/filter/ClipWithImplicitFunction.hxx>
|
||||
#endif
|
||||
|
||||
#endif // vtk_m_filter_ClipWithImplicitFunction_h
|
||||
|
@ -11,6 +11,8 @@
|
||||
#ifndef vtk_m_filter_ClipWithImplicitFunction_hxx
|
||||
#define vtk_m_filter_ClipWithImplicitFunction_hxx
|
||||
|
||||
#include <vtkm/filter/ClipWithImplicitFunction.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/CellSetPermutation.h>
|
||||
#include <vtkm/cont/DynamicCellSet.h>
|
||||
@ -19,6 +21,26 @@ namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct ClipWithImplicitFunctionProcessCoords
|
||||
{
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& inCoords,
|
||||
const std::string& coordsName,
|
||||
const vtkm::worklet::Clip& worklet,
|
||||
vtkm::cont::DataSet& output) const
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> outArray = worklet.ProcessPointField(inCoords);
|
||||
vtkm::cont::CoordinateSystem outCoords(coordsName, outArray);
|
||||
output.AddCoordinateSystem(outCoords);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename DerivedPolicy>
|
||||
inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
||||
@ -37,14 +59,18 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
||||
inputCoords,
|
||||
this->Invert);
|
||||
|
||||
// compute output coordinates
|
||||
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
|
||||
vtkm::cont::CoordinateSystem outputCoords(inputCoords.GetName(), outputCoordsArray);
|
||||
|
||||
//create the output data
|
||||
vtkm::cont::DataSet output;
|
||||
output.SetCellSet(outputCellSet);
|
||||
output.AddCoordinateSystem(outputCoords);
|
||||
|
||||
// compute output coordinates
|
||||
for (vtkm::IdComponent coordSystemId = 0; coordSystemId < input.GetNumberOfCoordinateSystems();
|
||||
++coordSystemId)
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = input.GetCoordinateSystem(coordSystemId);
|
||||
coords.GetData().CastAndCall(
|
||||
detail::ClipWithImplicitFunctionProcessCoords{}, coords.GetName(), this->Worklet, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ inline VTKM_CONT vtkm::cont::DataSet SplitSharpEdges::DoExecute(
|
||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||
this->FeatureAngle,
|
||||
field,
|
||||
input.GetCoordinateSystem().GetData(),
|
||||
input.GetCoordinateSystem().GetDataAsMultiplexer(),
|
||||
newCoords,
|
||||
newCellset);
|
||||
|
||||
|
@ -85,7 +85,8 @@ inline vtkm::cont::DataSet SurfaceNormals::DoExecute(
|
||||
|
||||
const auto cellset =
|
||||
vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy, *this);
|
||||
const auto& coords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()).GetData();
|
||||
const auto coords =
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()).GetDataAsMultiplexer();
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> faceNormals;
|
||||
vtkm::worklet::FacetedSurfaceNormals faceted;
|
||||
|
@ -75,7 +75,7 @@ void TestPointMerging()
|
||||
//Convert the baseData implicit points to explicit points, since the contour
|
||||
//filter for uniform data always does point merging
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> newcoords;
|
||||
vtkm::cont::Algorithm::Copy(baseData.GetCoordinateSystem().GetData(), newcoords);
|
||||
vtkm::cont::ArrayCopy(baseData.GetCoordinateSystem().GetData(), newcoords);
|
||||
baseData.GetCoordinateSystem().SetData(newcoords);
|
||||
|
||||
vtkm::filter::Contour marchingCubes;
|
||||
|
@ -102,8 +102,8 @@ void ValidateCoordTransform(const vtkm::cont::DataSet& ds,
|
||||
const vtkm::cont::DataSet& dsTrn,
|
||||
const std::vector<bool>& isAngle)
|
||||
{
|
||||
auto points = ds.GetCoordinateSystem().GetData();
|
||||
auto pointsTrn = dsTrn.GetCoordinateSystem().GetData();
|
||||
auto points = ds.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
auto pointsTrn = dsTrn.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
VTKM_TEST_ASSERT(points.GetNumberOfValues() == pointsTrn.GetNumberOfValues(),
|
||||
"Incorrect number of points in point transform");
|
||||
|
||||
|
@ -172,7 +172,7 @@ static vtkm::cont::DataSet MakeExplicit(vtkm::Id numI, vtkm::Id numJ, vtkm::Id n
|
||||
|
||||
vtkm::cont::DataSet dsUniform = MakeUniform(numI, numJ, numK, numLayers);
|
||||
|
||||
auto coordData = dsUniform.GetCoordinateSystem(0).GetData();
|
||||
auto coordData = dsUniform.GetCoordinateSystem(0).GetDataAsMultiplexer();
|
||||
vtkm::Id numPts = coordData.GetNumberOfValues();
|
||||
vtkm::cont::ArrayHandle<CoordType> explCoords;
|
||||
|
||||
|
@ -101,7 +101,7 @@ void TestFile(const std::string& fname,
|
||||
particleAdvection.SetActiveField("vec");
|
||||
auto output = particleAdvection.Execute(ds);
|
||||
|
||||
auto coords = output.GetCoordinateSystem().GetData();
|
||||
auto coords = output.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
vtkm::cont::DynamicCellSet dcells = output.GetCellSet();
|
||||
VTKM_TEST_ASSERT(dcells.GetNumberOfCells() == numPoints, "Wrong number of cells");
|
||||
VTKM_TEST_ASSERT(dcells.IsType<vtkm::cont::CellSetSingleType<>>(), "Wrong cell type");
|
||||
|
@ -76,12 +76,13 @@ void TestPointElevationNoPolicy()
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> resultArrayHandle;
|
||||
result.GetPointField("height").GetData().CopyTo(resultArrayHandle);
|
||||
auto coordinates = inputData.GetCoordinateSystem().GetData();
|
||||
auto coordinates = inputData.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
auto coordsPortal = coordinates.ReadPortal();
|
||||
auto resultPortal = resultArrayHandle.ReadPortal();
|
||||
for (vtkm::Id i = 0; i < resultArrayHandle.GetNumberOfValues(); ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
test_equal(coordinates.ReadPortal().Get(i)[1] * 2.0, resultArrayHandle.ReadPortal().Get(i)),
|
||||
"Wrong result for PointElevation worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(coordsPortal.Get(i)[1] * 2.0, resultPortal.Get(i)),
|
||||
"Wrong result for PointElevation worklet");
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,12 +107,13 @@ void TestPointElevationWithPolicy()
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> resultArrayHandle;
|
||||
result.GetPointField("elevation").GetData().CopyTo(resultArrayHandle);
|
||||
auto coordinates = inputData.GetCoordinateSystem().GetData();
|
||||
auto coordinates = inputData.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
auto coordsPortal = coordinates.ReadPortal();
|
||||
auto resultPortal = resultArrayHandle.ReadPortal();
|
||||
for (vtkm::Id i = 0; i < resultArrayHandle.GetNumberOfValues(); ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
test_equal(coordinates.ReadPortal().Get(i)[1] * 2.0, resultArrayHandle.ReadPortal().Get(i)),
|
||||
"Wrong result for PointElevation worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(coordsPortal.Get(i)[1] * 2.0, resultPortal.Get(i)),
|
||||
"Wrong result for PointElevation worklet");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,10 +74,9 @@ void ValidatePointTransform(const vtkm::cont::CoordinateSystem& coords,
|
||||
.GetData()
|
||||
.CopyTo(resultArrayHandle);
|
||||
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates outPointsArrayHandle =
|
||||
result.GetCoordinateSystem().GetData();
|
||||
auto outPointsArrayHandle = result.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
|
||||
auto points = coords.GetData();
|
||||
auto points = coords.GetDataAsMultiplexer();
|
||||
VTKM_TEST_ASSERT(points.GetNumberOfValues() == resultArrayHandle.GetNumberOfValues(),
|
||||
"Incorrect number of points in point transform");
|
||||
|
||||
|
@ -132,7 +132,7 @@ void TestSplitSharpEdgesFilterSplitEveryEdge(vtkm::cont::DataSet& simpleCubeWith
|
||||
splitSharpEdgesFilter.SetActiveField("Normals", vtkm::cont::Field::Association::CELL_SET);
|
||||
vtkm::cont::DataSet result = splitSharpEdgesFilter.Execute(simpleCubeWithSN);
|
||||
|
||||
auto newCoords = result.GetCoordinateSystem().GetData();
|
||||
auto newCoords = result.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
auto newCoordsP = newCoords.ReadPortal();
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> newPointvarField;
|
||||
result.GetField("pointvar").GetData().CopyTo(newPointvarField);
|
||||
@ -165,7 +165,7 @@ void TestSplitSharpEdgesFilterNoSplit(vtkm::cont::DataSet& simpleCubeWithSN,
|
||||
splitSharpEdgesFilter.SetActiveField("Normals", vtkm::cont::Field::Association::CELL_SET);
|
||||
vtkm::cont::DataSet result = splitSharpEdgesFilter.Execute(simpleCubeWithSN);
|
||||
|
||||
auto newCoords = result.GetCoordinateSystem().GetData();
|
||||
auto newCoords = result.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
vtkm::cont::CellSetExplicit<>& newCellset =
|
||||
result.GetCellSet().Cast<vtkm::cont::CellSetExplicit<>>();
|
||||
auto newCoordsP = newCoords.ReadPortal();
|
||||
|
@ -139,7 +139,7 @@ void TestStreamlineFile(const std::string& fname,
|
||||
streamline.SetActiveField("vec");
|
||||
auto output = streamline.Execute(ds);
|
||||
|
||||
auto coords = output.GetCoordinateSystem().GetData();
|
||||
auto coords = output.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
vtkm::cont::DynamicCellSet dcells = output.GetCellSet();
|
||||
VTKM_TEST_ASSERT(dcells.GetNumberOfCells() == numPoints, "Wrong number of cells");
|
||||
VTKM_TEST_ASSERT(dcells.IsType<vtkm::cont::CellSetExplicit<>>(), "Wrong cell type");
|
||||
|
@ -60,7 +60,7 @@ void TestVertexClustering()
|
||||
}
|
||||
|
||||
{
|
||||
auto pointArray = output.GetCoordinateSystem(0).GetData();
|
||||
auto pointArray = output.GetCoordinateSystem(0).GetDataAsMultiplexer();
|
||||
std::cerr << "output_points = " << pointArray.GetNumberOfValues() << "\n";
|
||||
std::cerr << "output_point[] = ";
|
||||
vtkm::cont::printSummary_ArrayHandle(pointArray, std::cerr, true);
|
||||
@ -70,7 +70,7 @@ void TestVertexClustering()
|
||||
vtkm::cont::printSummary_ArrayHandle(cellvar, std::cerr, true);
|
||||
|
||||
using PointType = vtkm::Vec3f_64;
|
||||
auto pointArray = output.GetCoordinateSystem(0).GetData();
|
||||
auto pointArray = output.GetCoordinateSystem(0).GetDataAsMultiplexer();
|
||||
VTKM_TEST_ASSERT(pointArray.GetNumberOfValues() == output_points,
|
||||
"Number of output points mismatch");
|
||||
auto pointArrayPortal = pointArray.ReadPortal();
|
||||
|
@ -163,7 +163,7 @@ void WritePoints(std::ostream& out, const vtkm::cont::DataSet& dataSet)
|
||||
out << "POINTS " << npoints << " " << vtkm::io::internal::DataTypeName<vtkm::FloatDefault>::Name()
|
||||
<< " " << '\n';
|
||||
|
||||
OutputPointsFunctor{ out }(cdata);
|
||||
cdata.CastAndCall(OutputPointsFunctor{ out });
|
||||
}
|
||||
|
||||
template <class CellSetType>
|
||||
|
@ -509,12 +509,13 @@ public:
|
||||
template <typename CellSetType,
|
||||
typename ShapeHandleType,
|
||||
typename ConnHandleType,
|
||||
typename OffsetsHandleType>
|
||||
typename OffsetsHandleType,
|
||||
typename CoordsType>
|
||||
VTKM_CONT void GenerateFaceConnnectivity(const CellSetType cellSet,
|
||||
const ShapeHandleType shapes,
|
||||
const ConnHandleType conn,
|
||||
const OffsetsHandleType shapeOffsets,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
|
||||
const CoordsType& coords,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& faceConnectivity,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id3>& cellFaceId,
|
||||
vtkm::Float32 BoundingBox[6],
|
||||
@ -662,7 +663,7 @@ MeshConnectivityBuilder::~MeshConnectivityBuilder()
|
||||
VTKM_CONT
|
||||
void MeshConnectivityBuilder::BuildConnectivity(
|
||||
vtkm::cont::CellSetSingleType<>& cellSetUnstructured,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coordinates,
|
||||
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coordinates,
|
||||
vtkm::Bounds coordsBounds)
|
||||
{
|
||||
Logger* logger = Logger::GetInstance();
|
||||
@ -725,7 +726,7 @@ void MeshConnectivityBuilder::BuildConnectivity(
|
||||
VTKM_CONT
|
||||
void MeshConnectivityBuilder::BuildConnectivity(
|
||||
vtkm::cont::CellSetExplicit<>& cellSetUnstructured,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coordinates,
|
||||
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coordinates,
|
||||
vtkm::Bounds coordsBounds)
|
||||
{
|
||||
Logger* logger = Logger::GetInstance();
|
||||
@ -902,14 +903,14 @@ MeshConnContainer* MeshConnectivityBuilder::BuildConnectivity(
|
||||
if (type == Unstructured)
|
||||
{
|
||||
vtkm::cont::CellSetExplicit<> cells = cellset.Cast<vtkm::cont::CellSetExplicit<>>();
|
||||
this->BuildConnectivity(cells, coordinates.GetData(), coordBounds);
|
||||
this->BuildConnectivity(cells, coordinates.GetDataAsMultiplexer(), coordBounds);
|
||||
meshConn =
|
||||
new UnstructuredContainer(cells, coordinates, FaceConnectivity, FaceOffsets, Triangles);
|
||||
}
|
||||
else if (type == UnstructuredSingle)
|
||||
{
|
||||
vtkm::cont::CellSetSingleType<> cells = cellset.Cast<vtkm::cont::CellSetSingleType<>>();
|
||||
this->BuildConnectivity(cells, coordinates.GetData(), coordBounds);
|
||||
this->BuildConnectivity(cells, coordinates.GetDataAsMultiplexer(), coordBounds);
|
||||
meshConn = new UnstructuredSingleContainer(cells, coordinates, FaceConnectivity, Triangles);
|
||||
}
|
||||
else if (type == Structured)
|
||||
|
@ -43,12 +43,12 @@ public:
|
||||
protected:
|
||||
VTKM_CONT
|
||||
void BuildConnectivity(vtkm::cont::CellSetSingleType<>& cellSetUnstructured,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coordinates,
|
||||
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coordinates,
|
||||
vtkm::Bounds coordsBounds);
|
||||
|
||||
VTKM_CONT
|
||||
void BuildConnectivity(vtkm::cont::CellSetExplicit<>& cellSetUnstructured,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coordinates,
|
||||
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coordinates,
|
||||
vtkm::Bounds coordsBounds);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> FaceConnectivity;
|
||||
|
@ -737,7 +737,7 @@ void VolumeRendererStructured::SetData(const vtkm::cont::CoordinateSystem& coord
|
||||
IsUniformDataSet = !coords.GetData().IsType<CartesianArrayHandle>();
|
||||
IsSceneDirty = true;
|
||||
SpatialExtent = coords.GetBounds();
|
||||
Coordinates = coords.GetData();
|
||||
Coordinates = coords;
|
||||
ScalarField = &scalarField;
|
||||
Cellset = cellset;
|
||||
ScalarRange = scalarRange;
|
||||
@ -829,7 +829,7 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
|
||||
{
|
||||
vtkm::cont::Token token;
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates vertices;
|
||||
vertices = Coordinates.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
|
||||
vertices = Coordinates.GetData().Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
|
||||
UniformLocator<Device> locator(vertices, Cellset, token);
|
||||
|
||||
if (isAssocPoints)
|
||||
@ -872,7 +872,7 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
|
||||
{
|
||||
vtkm::cont::Token token;
|
||||
CartesianArrayHandle vertices;
|
||||
vertices = Coordinates.Cast<CartesianArrayHandle>();
|
||||
vertices = Coordinates.GetData().Cast<CartesianArrayHandle>();
|
||||
RectilinearLocator<Device> locator(vertices, Cellset, token);
|
||||
if (isAssocPoints)
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ protected:
|
||||
bool IsSceneDirty;
|
||||
bool IsUniformDataSet;
|
||||
vtkm::Bounds SpatialExtent;
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates Coordinates;
|
||||
vtkm::cont::CoordinateSystem Coordinates;
|
||||
vtkm::cont::CellSetStructured<3> Cellset;
|
||||
const vtkm::cont::Field* ScalarField;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec4f_32> ColorMap;
|
||||
|
@ -65,10 +65,10 @@ struct AverageByKey
|
||||
/// This method uses an existing \c Keys object to collected values by those keys and find
|
||||
/// the average of those groups.
|
||||
///
|
||||
template <typename ValueType, typename InValuesStorage, typename OutAveragesStorage>
|
||||
template <typename InArrayType, typename OutArrayType>
|
||||
VTKM_CONT static void Run(const vtkm::worklet::internal::KeysBase& keys,
|
||||
const vtkm::cont::ArrayHandle<ValueType, InValuesStorage>& inValues,
|
||||
vtkm::cont::ArrayHandle<ValueType, OutAveragesStorage>& outAverages)
|
||||
const InArrayType& inValues,
|
||||
OutArrayType& outAverages)
|
||||
{
|
||||
|
||||
vtkm::worklet::DispatcherReduceByKey<AverageWorklet> dispatcher;
|
||||
|
@ -424,8 +424,7 @@ private:
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>>::Superclass;
|
||||
|
||||
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates MapCoordinatesUniform(
|
||||
const UniformCoordinatesArrayHandle& coords)
|
||||
UniformCoordinatesArrayHandle MapCoordinatesUniform(const UniformCoordinatesArrayHandle& coords)
|
||||
{
|
||||
using CoordsArray = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
||||
using CoordType = CoordsArray::ValueType;
|
||||
@ -441,11 +440,10 @@ private:
|
||||
inOrigin[2] + static_cast<ValueType>(this->VOI.Z.Min) * inSpacing[2]);
|
||||
CoordType outSpacing = inSpacing * static_cast<CoordType>(this->SampleRate);
|
||||
|
||||
auto out = CoordsArray(this->OutputDimensions, outOrigin, outSpacing);
|
||||
return vtkm::cont::ArrayHandleVirtualCoordinates(out);
|
||||
return CoordsArray(this->OutputDimensions, outOrigin, outSpacing);
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates MapCoordinatesRectilinear(
|
||||
RectilinearCoordinatesArrayHandle MapCoordinatesRectilinear(
|
||||
const RectilinearCoordinatesArrayHandle& coords)
|
||||
{
|
||||
// For structured datasets, the cellsets are of different types based on
|
||||
@ -478,28 +476,43 @@ private:
|
||||
}
|
||||
VTKM_ASSERT(dim == this->InputDimensionality);
|
||||
|
||||
auto out = vtkm::cont::make_ArrayHandleCartesianProduct(xyzs[0], xyzs[1], xyzs[2]);
|
||||
return vtkm::cont::ArrayHandleVirtualCoordinates(out);
|
||||
return vtkm::cont::make_ArrayHandleCartesianProduct(xyzs[0], xyzs[1], xyzs[2]);
|
||||
}
|
||||
|
||||
struct MapCoordinatesFunctor
|
||||
{
|
||||
template <typename T, typename S>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, S>& coords,
|
||||
ExtractStructured& self,
|
||||
vtkm::cont::VariantArrayHandleCommon& output) const
|
||||
{
|
||||
output = self.ProcessPointField(coords);
|
||||
}
|
||||
|
||||
VTKM_CONT void operator()(const UniformCoordinatesArrayHandle& coords,
|
||||
ExtractStructured& self,
|
||||
vtkm::cont::VariantArrayHandleCommon& output) const
|
||||
{
|
||||
output = self.MapCoordinatesUniform(coords);
|
||||
}
|
||||
|
||||
VTKM_CONT void operator()(const RectilinearCoordinatesArrayHandle& coords,
|
||||
ExtractStructured& self,
|
||||
vtkm::cont::VariantArrayHandleCommon& output) const
|
||||
{
|
||||
output = self.MapCoordinatesRectilinear(coords);
|
||||
}
|
||||
};
|
||||
|
||||
friend MapCoordinatesFunctor;
|
||||
|
||||
public:
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates MapCoordinates(
|
||||
vtkm::cont::VariantArrayHandleCommon MapCoordinates(
|
||||
const vtkm::cont::CoordinateSystem& coordinates)
|
||||
{
|
||||
auto coArray = coordinates.GetData();
|
||||
if (coArray.IsType<UniformCoordinatesArrayHandle>())
|
||||
{
|
||||
return this->MapCoordinatesUniform(coArray.Cast<UniformCoordinatesArrayHandle>());
|
||||
}
|
||||
else if (coArray.IsType<RectilinearCoordinatesArrayHandle>())
|
||||
{
|
||||
return this->MapCoordinatesRectilinear(coArray.Cast<RectilinearCoordinatesArrayHandle>());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto out = this->ProcessPointField(coArray);
|
||||
return vtkm::cont::ArrayHandleVirtualCoordinates(out);
|
||||
}
|
||||
vtkm::cont::VariantArrayHandleCommon output;
|
||||
vtkm::cont::CastAndCall(coordinates, MapCoordinatesFunctor{}, *this, output);
|
||||
return output;
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
#include <vtkm/cont/ExecutionAndControlObjectBase.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/cont/VariantArrayHandle.h>
|
||||
|
||||
#include <vtkm/Bounds.h>
|
||||
#include <vtkm/Hash.h>
|
||||
@ -419,17 +420,18 @@ public:
|
||||
points = uniquePointCoordinates;
|
||||
}
|
||||
|
||||
template <typename TL>
|
||||
VTKM_CONT void Run(
|
||||
vtkm::Float64 delta, // Distance to consider two points coincident
|
||||
bool fastCheck, // If true, approximate distances are used
|
||||
const vtkm::Bounds& bounds, // Bounds of points
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates& points) // coordinates, modified to merge close
|
||||
vtkm::Float64 delta, // Distance to consider two points coincident
|
||||
bool fastCheck, // If true, approximate distances are used
|
||||
const vtkm::Bounds& bounds, // Bounds of points
|
||||
vtkm::cont::VariantArrayHandleBase<TL>& points) // coordinates, modified to merge close
|
||||
{
|
||||
// Get a cast to a concrete set of point coordiantes so that it can be modified in place
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> concretePoints;
|
||||
if (points.IsType<decltype(concretePoints)>())
|
||||
if (points.template IsType<decltype(concretePoints)>())
|
||||
{
|
||||
concretePoints = points.Cast<decltype(concretePoints)>();
|
||||
concretePoints = points.template Cast<decltype(concretePoints)>();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -439,7 +441,7 @@ public:
|
||||
Run(delta, fastCheck, bounds, concretePoints);
|
||||
|
||||
// Make sure that the modified points are reflected back in the virtual array.
|
||||
points = vtkm::cont::ArrayHandleVirtualCoordinates(concretePoints);
|
||||
points = concretePoints;
|
||||
}
|
||||
|
||||
template <typename ShapeStorage, typename ConnectivityStorage, typename OffsetsStorage>
|
||||
@ -455,9 +457,6 @@ public:
|
||||
template <typename InArrayHandle, typename OutArrayHandle>
|
||||
VTKM_CONT void MapPointField(const InArrayHandle& inArray, OutArrayHandle& outArray) const
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
|
||||
VTKM_IS_ARRAY_HANDLE(OutArrayHandle);
|
||||
|
||||
vtkm::worklet::AverageByKey::Run(this->MergeKeys, inArray, outArray);
|
||||
}
|
||||
|
||||
@ -465,8 +464,6 @@ public:
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<typename InArrayHandle::ValueType> MapPointField(
|
||||
const InArrayHandle& inArray) const
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
|
||||
|
||||
vtkm::cont::ArrayHandle<typename InArrayHandle::ValueType> outArray;
|
||||
this->MapPointField(inArray, outArray);
|
||||
|
||||
|
@ -194,12 +194,27 @@ public:
|
||||
VTKM_CONT vtkm::cont::ArrayHandlePermutation<vtkm::cont::ArrayHandle<vtkm::Id>, InArrayHandle>
|
||||
MapPointFieldShallow(const InArrayHandle& inArray) const
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
|
||||
VTKM_ASSERT(this->PointScatter);
|
||||
|
||||
return vtkm::cont::make_ArrayHandlePermutation(this->PointScatter->GetOutputToInputMap(),
|
||||
inArray);
|
||||
}
|
||||
|
||||
private:
|
||||
struct MapPointFieldDeepFunctor
|
||||
{
|
||||
template <typename InArrayHandle, typename OutArrayHandle>
|
||||
VTKM_CONT void operator()(const InArrayHandle& inArray,
|
||||
OutArrayHandle& outArray,
|
||||
const RemoveUnusedPoints& self) const
|
||||
{
|
||||
self.MapPointFieldDeep(inArray, outArray);
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
///@{
|
||||
/// \brief Maps a point field from the original points to the new reduced points
|
||||
///
|
||||
/// Given an array handle that holds the values for a point field of the
|
||||
@ -209,35 +224,30 @@ public:
|
||||
/// This version of point mapping performs a deep copy into the destination
|
||||
/// array provided.
|
||||
///
|
||||
template <typename InArrayHandle, typename OutArrayHandle>
|
||||
VTKM_CONT void MapPointFieldDeep(const InArrayHandle& inArray, OutArrayHandle& outArray) const
|
||||
template <typename InT, typename InS, typename OutT, typename OutS>
|
||||
VTKM_CONT void MapPointFieldDeep(const vtkm::cont::ArrayHandle<InT, InS>& inArray,
|
||||
vtkm::cont::ArrayHandle<OutT, OutS>& outArray) const
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
|
||||
VTKM_IS_ARRAY_HANDLE(OutArrayHandle);
|
||||
|
||||
vtkm::cont::ArrayCopy(this->MapPointFieldShallow(inArray), outArray);
|
||||
}
|
||||
|
||||
/// \brief Maps a point field from the original points to the new reduced points
|
||||
///
|
||||
/// Given an array handle that holds the values for a point field of the
|
||||
/// original data set, returns a new array handle containing field values
|
||||
/// rearranged to the new indices of the reduced point set.
|
||||
///
|
||||
/// This version of point mapping performs a deep copy into an array that is
|
||||
/// returned.
|
||||
///
|
||||
template <typename InArrayTypes, typename OutArrayHandle>
|
||||
VTKM_CONT void MapPointFieldDeep(const vtkm::cont::VariantArrayHandleBase<InArrayTypes>& inArray,
|
||||
OutArrayHandle& outArray) const
|
||||
{
|
||||
vtkm::cont::CastAndCall(inArray, MapPointFieldDeepFunctor{}, outArray, *this);
|
||||
}
|
||||
|
||||
template <typename InArrayHandle>
|
||||
vtkm::cont::ArrayHandle<typename InArrayHandle::ValueType> MapPointFieldDeep(
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<typename InArrayHandle::ValueType> MapPointFieldDeep(
|
||||
const InArrayHandle& inArray) const
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
|
||||
|
||||
vtkm::cont::ArrayHandle<typename InArrayHandle::ValueType> outArray;
|
||||
this->MapPointFieldDeep(inArray, outArray);
|
||||
|
||||
return outArray;
|
||||
}
|
||||
///@}
|
||||
|
||||
const vtkm::worklet::ScatterCounting& GetPointScatter() const
|
||||
{
|
||||
|
@ -131,9 +131,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <typename CellSetType, typename NormalCompType>
|
||||
template <typename CellSetType, typename PointsType, typename NormalCompType>
|
||||
void Run(const CellSetType& cellset,
|
||||
const vtkm::cont::VariantArrayHandleBase<vtkm::TypeListFieldVec3>& points,
|
||||
const PointsType& points,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<NormalCompType, 3>>& normals)
|
||||
{
|
||||
if (this->Normalize)
|
||||
|
@ -164,17 +164,11 @@ public:
|
||||
vtkm::cont::DynamicCellSet Result;
|
||||
|
||||
// Generic handler:
|
||||
template <typename CellSetType,
|
||||
typename PointComponentType,
|
||||
typename PointStorageType,
|
||||
typename CellNormalComponentType,
|
||||
typename CellNormalStorageType>
|
||||
VTKM_CONT void operator()(
|
||||
const CellSetType& cellSet,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<PointComponentType, 3>, PointStorageType>& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalComponentType, 3>, CellNormalStorageType>&
|
||||
cellNormals,
|
||||
...)
|
||||
template <typename CellSetType, typename CoordsType, typename CellNormalsType>
|
||||
VTKM_CONT void operator()(const CellSetType& cellSet,
|
||||
const CoordsType& coords,
|
||||
const CellNormalsType& cellNormals,
|
||||
...)
|
||||
{
|
||||
const auto numCells = cellSet.GetNumberOfCells();
|
||||
if (numCells == 0)
|
||||
@ -257,19 +251,11 @@ public:
|
||||
}
|
||||
|
||||
// Specialization for CellSetExplicit
|
||||
template <typename S,
|
||||
typename C,
|
||||
typename O,
|
||||
typename PointComponentType,
|
||||
typename PointStorageType,
|
||||
typename CellNormalComponentType,
|
||||
typename CellNormalStorageType>
|
||||
VTKM_CONT void operator()(
|
||||
const vtkm::cont::CellSetExplicit<S, C, O>& cellSet,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<PointComponentType, 3>, PointStorageType>& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalComponentType, 3>, CellNormalStorageType>&
|
||||
cellNormals,
|
||||
int)
|
||||
template <typename S, typename C, typename O, typename CoordsType, typename CellNormalsType>
|
||||
VTKM_CONT void operator()(const vtkm::cont::CellSetExplicit<S, C, O>& cellSet,
|
||||
const CoordsType& coords,
|
||||
const CellNormalsType& cellNormals,
|
||||
int)
|
||||
{
|
||||
using WindToCellNormals = vtkm::worklet::DispatcherMapField<WorkletWindToCellNormals>;
|
||||
|
||||
@ -303,17 +289,11 @@ public:
|
||||
}
|
||||
|
||||
// Specialization for CellSetSingleType
|
||||
template <typename C,
|
||||
typename PointComponentType,
|
||||
typename PointStorageType,
|
||||
typename CellNormalComponentType,
|
||||
typename CellNormalStorageType>
|
||||
VTKM_CONT void operator()(
|
||||
const vtkm::cont::CellSetSingleType<C>& cellSet,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<PointComponentType, 3>, PointStorageType>& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalComponentType, 3>, CellNormalStorageType>&
|
||||
cellNormals,
|
||||
int)
|
||||
template <typename C, typename CoordsType, typename CellNormalsType>
|
||||
VTKM_CONT void operator()(const vtkm::cont::CellSetSingleType<C>& cellSet,
|
||||
const CoordsType& coords,
|
||||
const CellNormalsType& cellNormals,
|
||||
int)
|
||||
{
|
||||
using WindToCellNormals = vtkm::worklet::DispatcherMapField<WorkletWindToCellNormals>;
|
||||
|
||||
@ -348,16 +328,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CellSetType,
|
||||
typename PointComponentType,
|
||||
typename PointStorageType,
|
||||
typename CellNormalComponentType,
|
||||
typename CellNormalStorageType>
|
||||
VTKM_CONT static vtkm::cont::DynamicCellSet Run(
|
||||
const CellSetType& cellSet,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<PointComponentType, 3>, PointStorageType>& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalComponentType, 3>, CellNormalStorageType>&
|
||||
cellNormals)
|
||||
template <typename CellSetType, typename CoordsType, typename CellNormalsType>
|
||||
VTKM_CONT static vtkm::cont::DynamicCellSet Run(const CellSetType& cellSet,
|
||||
const CoordsType& coords,
|
||||
const CellNormalsType& cellNormals)
|
||||
{
|
||||
Launcher launcher;
|
||||
// The last arg is just to help with overload resolution on the templated
|
||||
|
@ -65,7 +65,7 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet, vtkm::IdComponen
|
||||
using Timer = vtkm::cont::Timer;
|
||||
|
||||
vtkm::cont::DynamicCellSet cellSet = dataSet.GetCellSet();
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates vertices = dataSet.GetCoordinateSystem().GetData();
|
||||
auto vertices = dataSet.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
|
||||
std::cout << "Using numPlanes: " << numPlanes << "\n";
|
||||
std::cout << "Building Bounding Interval Hierarchy Tree" << std::endl;
|
||||
|
@ -120,7 +120,7 @@ void TestClippingExplicit()
|
||||
clipValue,
|
||||
invertClip);
|
||||
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetDataAsMultiplexer();
|
||||
vtkm::cont::ArrayHandle<Coord3D> coords = clip.ProcessPointField(coordsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
|
||||
@ -176,7 +176,7 @@ void TestClippingStructured()
|
||||
clipValue,
|
||||
invertClip);
|
||||
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetDataAsMultiplexer();
|
||||
CoordsOutType coords = clip.ProcessPointField(coordsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
|
||||
@ -238,7 +238,7 @@ void TestClippingWithImplicitFunction()
|
||||
ds.GetCoordinateSystem("coords"),
|
||||
invertClip);
|
||||
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetDataAsMultiplexer();
|
||||
vtkm::cont::ArrayHandle<Coord3D> coords = clip.ProcessPointField(coordsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
|
||||
@ -297,7 +297,7 @@ void TestClippingWithImplicitFunctionInverted()
|
||||
ds.GetCoordinateSystem("coords"),
|
||||
invertClip);
|
||||
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
|
||||
auto coordsIn = ds.GetCoordinateSystem("coords").GetDataAsMultiplexer();
|
||||
vtkm::cont::ArrayHandle<Coord3D> coords = clip.ProcessPointField(coordsIn);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
|
||||
|
@ -107,7 +107,7 @@ void ValidateCoordTransform(const vtkm::cont::CoordinateSystem& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f>& doubleTransform,
|
||||
const std::vector<bool>& isAngle)
|
||||
{
|
||||
auto points = coords.GetData();
|
||||
auto points = coords.GetDataAsMultiplexer();
|
||||
VTKM_TEST_ASSERT(points.GetNumberOfValues() == transform.GetNumberOfValues() &&
|
||||
points.GetNumberOfValues() == doubleTransform.GetNumberOfValues(),
|
||||
"Incorrect number of points in point transform");
|
||||
|
@ -85,7 +85,8 @@ struct ValidateNormals
|
||||
using NormalType = vtkm::Vec<vtkm::FloatDefault, 3>;
|
||||
using NormalsArrayType = vtkm::cont::ArrayHandleVirtual<NormalType>;
|
||||
using NormalsPortalType = decltype(std::declval<NormalsArrayType>().ReadPortal());
|
||||
using PointsType = decltype(std::declval<vtkm::cont::CoordinateSystem>().GetData().ReadPortal());
|
||||
using PointsType =
|
||||
decltype(std::declval<vtkm::cont::CoordinateSystem>().GetDataAsMultiplexer().ReadPortal());
|
||||
|
||||
vtkm::cont::CoordinateSystem Coords;
|
||||
CellSetType Cells;
|
||||
@ -139,7 +140,7 @@ struct ValidateNormals
|
||||
const vtkm::cont::Field& cellNormalsField)
|
||||
: Coords{ dataset.GetCoordinateSystem() }
|
||||
, Cells{ dataset.GetCellSet().Cast<CellSetType>() }
|
||||
, Points{ this->Coords.GetData().ReadPortal() }
|
||||
, Points{ this->Coords.GetDataAsMultiplexer().ReadPortal() }
|
||||
, CheckPoints(checkPoints)
|
||||
, CheckCells(checkCells)
|
||||
{
|
||||
@ -170,7 +171,7 @@ struct ValidateNormals
|
||||
// Locate a point with the minimum x coordinate:
|
||||
const vtkm::Id startPoint = [&]() -> vtkm::Id {
|
||||
const vtkm::Float64 xMin = this->Coords.GetBounds().X.Min;
|
||||
const auto points = this->Coords.GetData().ReadPortal();
|
||||
const auto points = this->Coords.GetDataAsMultiplexer().ReadPortal();
|
||||
const vtkm::Id numPoints = points.GetNumberOfValues();
|
||||
vtkm::Id resultIdx = -1;
|
||||
for (vtkm::Id pointIdx = 0; pointIdx < numPoints; ++pointIdx)
|
||||
@ -343,7 +344,7 @@ void TestOrientNormals(bool testPoints, bool testCells)
|
||||
}
|
||||
|
||||
// modify normals in place
|
||||
const auto coords = dataset.GetCoordinateSystem().GetData();
|
||||
const auto coords = dataset.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
const auto cells = dataset.GetCellSet();
|
||||
if (testPoints && testCells)
|
||||
{
|
||||
|
@ -78,12 +78,13 @@ void TestPointElevation()
|
||||
pointElevationWorklet);
|
||||
dispatcher.Invoke(dataSet.GetCoordinateSystem(), result);
|
||||
|
||||
auto coordinates = dataSet.GetCoordinateSystem().GetData();
|
||||
auto coordinates = dataSet.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
auto coordinatesPortal = coordinates.ReadPortal();
|
||||
auto resultPortal = result.ReadPortal();
|
||||
for (vtkm::Id i = 0; i < result.GetNumberOfValues(); ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
test_equal(coordinates.ReadPortal().Get(i)[1] * 2.0, result.ReadPortal().Get(i)),
|
||||
"Wrong result for PointElevation worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(coordinatesPortal.Get(i)[1] * 2.0, resultPortal.Get(i)),
|
||||
"Wrong result for PointElevation worklet");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ void ValidatePointTransform(const vtkm::cont::CoordinateSystem& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f>& result,
|
||||
const vtkm::Matrix<vtkm::FloatDefault, 4, 4>& matrix)
|
||||
{
|
||||
auto points = coords.GetData();
|
||||
auto points = coords.GetDataAsMultiplexer();
|
||||
VTKM_TEST_ASSERT(points.GetNumberOfValues() == result.GetNumberOfValues(),
|
||||
"Incorrect number of points in point transform");
|
||||
|
||||
|
@ -121,7 +121,7 @@ void TestSplitSharpEdgesSplitEveryEdge(vtkm::cont::DataSet& simpleCube,
|
||||
splitSharpEdges.Run(simpleCube.GetCellSet(),
|
||||
featureAngle,
|
||||
faceNormals,
|
||||
simpleCube.GetCoordinateSystem().GetData(),
|
||||
simpleCube.GetCoordinateSystem().GetDataAsMultiplexer(),
|
||||
newCoords,
|
||||
newCellset);
|
||||
|
||||
@ -166,7 +166,7 @@ void TestSplitSharpEdgesNoSplit(vtkm::cont::DataSet& simpleCube,
|
||||
splitSharpEdges.Run(simpleCube.GetCellSet(),
|
||||
featureAngle,
|
||||
faceNormals,
|
||||
simpleCube.GetCoordinateSystem().GetData(),
|
||||
simpleCube.GetCoordinateSystem().GetDataAsMultiplexer(),
|
||||
newCoords,
|
||||
newCellset);
|
||||
|
||||
@ -213,7 +213,8 @@ void TestSplitSharpEdges()
|
||||
vtkm::cont::DataSet simpleCube = Make3DExplicitSimpleCube();
|
||||
NormalsArrayHandle faceNormals;
|
||||
vtkm::worklet::FacetedSurfaceNormals faceted;
|
||||
faceted.Run(simpleCube.GetCellSet(), simpleCube.GetCoordinateSystem().GetData(), faceNormals);
|
||||
faceted.Run(
|
||||
simpleCube.GetCellSet(), simpleCube.GetCoordinateSystem().GetDataAsMultiplexer(), faceNormals);
|
||||
|
||||
vtkm::worklet::SplitSharpEdges splitSharpEdges;
|
||||
|
||||
|
@ -53,7 +53,7 @@ vtkm::cont::DataSet GenerateDataSet()
|
||||
void Validate(vtkm::cont::DataSet dataSet)
|
||||
{
|
||||
const auto cellSet = dataSet.GetCellSet().Cast<vtkm::cont::CellSetExplicit<>>();
|
||||
const auto coordsArray = dataSet.GetCoordinateSystem().GetData();
|
||||
const auto coordsArray = dataSet.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
const auto conn =
|
||||
cellSet.GetConnectivityArray(vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{});
|
||||
const auto offsets =
|
||||
|
@ -69,7 +69,7 @@ void TestVertexClustering()
|
||||
auto pointArray = outDataSet.GetCoordinateSystem(0).GetData();
|
||||
std::cerr << "output_points = " << pointArray.GetNumberOfValues() << "\n";
|
||||
std::cerr << "output_point[] = ";
|
||||
vtkm::cont::printSummary_ArrayHandle(pointArray, std::cerr, true);
|
||||
pointArray.PrintSummary(std::cerr);
|
||||
}
|
||||
|
||||
vtkm::cont::printSummary_ArrayHandle(pointvar, std::cerr, true);
|
||||
@ -78,7 +78,7 @@ void TestVertexClustering()
|
||||
VTKM_TEST_ASSERT(outDataSet.GetNumberOfCoordinateSystems() == 1,
|
||||
"Number of output coordinate systems mismatch");
|
||||
using PointType = vtkm::Vec3f_64;
|
||||
auto pointArray = outDataSet.GetCoordinateSystem(0).GetData();
|
||||
auto pointArray = outDataSet.GetCoordinateSystem(0).GetDataAsMultiplexer();
|
||||
VTKM_TEST_ASSERT(pointArray.GetNumberOfValues() == output_points,
|
||||
"Number of output points mismatch");
|
||||
for (vtkm::Id i = 0; i < pointArray.GetNumberOfValues(); ++i)
|
||||
|
@ -60,7 +60,7 @@ void TestWarpScalar()
|
||||
vecType normal = vtkm::make_Vec<vtkm::FloatDefault>(static_cast<vtkm::FloatDefault>(0.0),
|
||||
static_cast<vtkm::FloatDefault>(0.0),
|
||||
static_cast<vtkm::FloatDefault>(1.0));
|
||||
auto coordinate = ds.GetCoordinateSystem().GetData();
|
||||
auto coordinate = ds.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
vtkm::Id nov = coordinate.GetNumberOfValues();
|
||||
vtkm::cont::ArrayHandleConstant<vecType> normalAH =
|
||||
vtkm::cont::make_ArrayHandleConstant(normal, nov);
|
||||
|
@ -73,7 +73,7 @@ void TestWarpVector()
|
||||
vecType vector = vtkm::make_Vec<vtkm::FloatDefault>(static_cast<vtkm::FloatDefault>(0.0),
|
||||
static_cast<vtkm::FloatDefault>(0.0),
|
||||
static_cast<vtkm::FloatDefault>(2.0));
|
||||
auto coordinate = ds.GetCoordinateSystem().GetData();
|
||||
auto coordinate = ds.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
vtkm::Id nov = coordinate.GetNumberOfValues();
|
||||
vtkm::cont::ArrayHandleConstant<vecType> vectorAH =
|
||||
vtkm::cont::make_ArrayHandleConstant(vector, nov);
|
||||
|
Loading…
Reference in New Issue
Block a user