2015-02-10 20:01:27 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2015-02-10 20:01:27 +00:00
|
|
|
// 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_worklet_Dispatcher_MapTopology_h
|
|
|
|
#define vtk_m_worklet_Dispatcher_MapTopology_h
|
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
#include <vtkm/TopologyElementTag.h>
|
2015-02-10 20:01:27 +00:00
|
|
|
#include <vtkm/cont/DeviceAdapter.h>
|
|
|
|
#include <vtkm/worklet/WorkletMapTopology.h>
|
|
|
|
#include <vtkm/worklet/internal/DispatcherBase.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace worklet
|
|
|
|
{
|
2015-02-10 20:01:27 +00:00
|
|
|
|
|
|
|
/// \brief Dispatcher for worklets that inherit from \c WorkletMapTopology.
|
|
|
|
///
|
2018-08-28 20:36:50 +00:00
|
|
|
template <typename WorkletType>
|
2017-05-18 14:29:41 +00:00
|
|
|
class DispatcherMapTopology
|
2018-08-28 20:36:50 +00:00
|
|
|
: public vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType>,
|
2017-05-18 14:29:41 +00:00
|
|
|
WorkletType,
|
|
|
|
vtkm::worklet::detail::WorkletMapTopologyBase>
|
2015-02-10 20:01:27 +00:00
|
|
|
{
|
2018-02-22 13:29:13 +00:00
|
|
|
using Superclass =
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType>,
|
2018-02-22 13:29:13 +00:00
|
|
|
WorkletType,
|
|
|
|
vtkm::worklet::detail::WorkletMapTopologyBase>;
|
Move Scatter from Worklet to Dispatcher
Previously, when a Worklet needed a scatter, the scatter object was
stored in the Worklet object. That was problematic because that means
the Scatter, which is a control object, was shoved into the execution
environment.
To prevent that, move the Scatter into the Dispatcher object. The
worklet still declares a ScatterType alias, but no longer has a
GetScatter method. Instead, the Dispatcher now takes a Scatter object in
its constructor. If using the default scatter (ScatterIdentity), the
default constructor is used. If using another type of Scatter that
requires data to set up its state, then the caller of the worklet needs
to provide that to the dispatcher. For convenience, worklets are
encouraged to have a MakeScatter method to help construct a proper
scatter object.
2018-04-27 04:43:51 +00:00
|
|
|
using ScatterType = typename Superclass::ScatterType;
|
2015-02-10 20:01:27 +00:00
|
|
|
|
|
|
|
public:
|
2019-01-21 02:14:55 +00:00
|
|
|
template <typename... T>
|
|
|
|
VTKM_CONT DispatcherMapTopology(T&&... args)
|
|
|
|
: Superclass(std::forward<T>(args)...)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
2015-02-10 20:01:27 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename Invocation>
|
2018-06-28 18:29:27 +00:00
|
|
|
VTKM_CONT void DoInvoke(Invocation& invocation) const
|
2015-02-10 20:01:27 +00:00
|
|
|
{
|
2020-01-07 18:40:04 +00:00
|
|
|
using namespace vtkm::worklet::internal;
|
|
|
|
|
2015-10-07 18:14:00 +00:00
|
|
|
// This is the type for the input domain
|
2018-02-22 13:29:13 +00:00
|
|
|
using InputDomainType = typename Invocation::InputDomainType;
|
2019-07-30 16:53:51 +00:00
|
|
|
using SchedulingRangeType = typename WorkletType::VisitTopologyType;
|
2015-02-10 20:01:27 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
// If you get a compile error on this line, then you have tried to use
|
|
|
|
// something that is not a vtkm::cont::CellSet as the input domain to a
|
|
|
|
// topology operation (that operates on a cell set connection domain).
|
|
|
|
VTKM_IS_CELL_SET(InputDomainType);
|
|
|
|
|
2015-02-10 20:01:27 +00:00
|
|
|
// We can pull the input domain parameter (the data specifying the input
|
|
|
|
// domain) from the invocation object.
|
2018-06-28 18:29:27 +00:00
|
|
|
const auto& inputDomain = invocation.GetInputDomain();
|
2015-02-10 20:01:27 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
// Now that we have the input domain, we can extract the range of the
|
|
|
|
// scheduling and call BadicInvoke.
|
2020-01-29 15:39:41 +00:00
|
|
|
this->BasicInvoke(invocation, SchedulingRange(inputDomain, SchedulingRangeType{}));
|
2015-02-10 20:01:27 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} // namespace vtkm::worklet
|
|
|
|
|
|
|
|
#endif //vtk_m_worklet_Dispatcher_MapTopology_h
|