2018-04-05 21:12:20 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-04-05 21:12:20 +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.
|
|
|
|
//============================================================================
|
|
|
|
#include <vtkm/cont/BoundsCompute.h>
|
|
|
|
|
|
|
|
#include <vtkm/cont/CoordinateSystem.h>
|
|
|
|
#include <vtkm/cont/DataSet.h>
|
2019-09-02 14:38:47 +00:00
|
|
|
#include <vtkm/cont/PartitionedDataSet.h>
|
2018-04-05 21:12:20 +00:00
|
|
|
|
|
|
|
#include <numeric> // for std::accumulate
|
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Bounds BoundsCompute(const vtkm::cont::DataSet& dataset, vtkm::Id coordinate_system_index)
|
|
|
|
{
|
2018-04-16 20:56:23 +00:00
|
|
|
return dataset.GetNumberOfCoordinateSystems() > coordinate_system_index
|
|
|
|
? dataset.GetCoordinateSystem(coordinate_system_index).GetBounds()
|
|
|
|
: vtkm::Bounds();
|
2018-04-05 21:12:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
VTKM_CONT
|
2019-09-02 14:38:47 +00:00
|
|
|
vtkm::Bounds BoundsCompute(const vtkm::cont::PartitionedDataSet& pds,
|
2018-04-05 21:12:20 +00:00
|
|
|
vtkm::Id coordinate_system_index)
|
|
|
|
{
|
2019-09-02 14:38:47 +00:00
|
|
|
return std::accumulate(pds.begin(),
|
|
|
|
pds.end(),
|
2018-04-05 21:12:20 +00:00
|
|
|
vtkm::Bounds(),
|
2019-09-02 14:38:47 +00:00
|
|
|
[=](const vtkm::Bounds& val, const vtkm::cont::DataSet& partition) {
|
|
|
|
return val +
|
|
|
|
vtkm::cont::BoundsCompute(partition, coordinate_system_index);
|
2018-04-05 21:12:20 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Bounds BoundsCompute(const vtkm::cont::DataSet& dataset, const std::string& name)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return dataset.GetCoordinateSystem(name).GetBounds();
|
|
|
|
}
|
|
|
|
catch (vtkm::cont::ErrorBadValue&)
|
|
|
|
{
|
|
|
|
// missing coordinate_system_index, return empty bounds.
|
|
|
|
return vtkm::Bounds();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
VTKM_CONT
|
2019-09-02 14:38:47 +00:00
|
|
|
vtkm::Bounds BoundsCompute(const vtkm::cont::PartitionedDataSet& pds, const std::string& name)
|
2018-04-05 21:12:20 +00:00
|
|
|
{
|
2019-09-02 14:38:47 +00:00
|
|
|
return std::accumulate(pds.begin(),
|
|
|
|
pds.end(),
|
2018-04-05 21:12:20 +00:00
|
|
|
vtkm::Bounds(),
|
2019-09-02 14:38:47 +00:00
|
|
|
[=](const vtkm::Bounds& val, const vtkm::cont::DataSet& partition) {
|
|
|
|
return val + vtkm::cont::BoundsCompute(partition, name);
|
2018-04-05 21:12:20 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|