vtk-m/vtkm/cont/BoundsGlobalCompute.cxx
Kenneth Moreland ec34cb56c4 Use new ways to get array portal in control environment
Also fix deadlocks that occur when portals are not destroyed
in time.
2020-02-26 13:10:46 -07:00

74 lines
2.4 KiB
C++

//============================================================================
// 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.
//============================================================================
#include <vtkm/cont/BoundsGlobalCompute.h>
#include <vtkm/cont/BoundsCompute.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/FieldRangeGlobalCompute.h>
#include <vtkm/cont/PartitionedDataSet.h>
#include <numeric> // for std::accumulate
namespace vtkm
{
namespace cont
{
namespace detail
{
VTKM_CONT
vtkm::Bounds MergeBoundsGlobal(const vtkm::Bounds& local)
{
vtkm::cont::ArrayHandle<vtkm::Range> ranges;
ranges.Allocate(3);
ranges.WritePortal().Set(0, local.X);
ranges.WritePortal().Set(1, local.Y);
ranges.WritePortal().Set(2, local.Z);
ranges = vtkm::cont::detail::MergeRangesGlobal(ranges);
auto portal = ranges.ReadPortal();
return vtkm::Bounds(portal.Get(0), portal.Get(1), portal.Get(2));
}
}
//-----------------------------------------------------------------------------
VTKM_CONT
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::DataSet& dataset,
vtkm::Id coordinate_system_index)
{
return detail::MergeBoundsGlobal(vtkm::cont::BoundsCompute(dataset, coordinate_system_index));
}
//-----------------------------------------------------------------------------
VTKM_CONT
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::PartitionedDataSet& pds,
vtkm::Id coordinate_system_index)
{
return detail::MergeBoundsGlobal(vtkm::cont::BoundsCompute(pds, coordinate_system_index));
}
//-----------------------------------------------------------------------------
VTKM_CONT
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::DataSet& dataset, const std::string& name)
{
return detail::MergeBoundsGlobal(vtkm::cont::BoundsCompute(dataset, name));
}
//-----------------------------------------------------------------------------
VTKM_CONT
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::PartitionedDataSet& pds, const std::string& name)
{
return detail::MergeBoundsGlobal(vtkm::cont::BoundsCompute(pds, name));
}
}
}