vtk-m/vtkm/cont/DataSetFieldAdd.h

106 lines
3.6 KiB
C
Raw Normal View History

2015-11-03 03:24:57 +00:00
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +00:00
//
2015-11-03 03:24:57 +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_cont_DataSetFieldAdd_h
#define vtk_m_cont_DataSetFieldAdd_h
2020-05-27 19:27:47 +00:00
#include <vtkm/Deprecated.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Field.h>
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace cont
{
2015-11-03 03:24:57 +00:00
2020-05-27 19:27:47 +00:00
class VTKM_DEPRECATED(1.6,
"The AddPointField and AddCellField methods should now be called "
"directly on the vtkm::cont::DataSet object") DataSetFieldAdd
2015-11-03 03:24:57 +00:00
{
public:
2017-05-18 14:29:41 +00:00
VTKM_CONT
DataSetFieldAdd() {}
//Point centered fields.
VTKM_CONT
static void AddPointField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const vtkm::cont::UnknownArrayHandle& field)
2017-05-18 14:29:41 +00:00
{
dataSet.AddField(make_FieldPoint(fieldName, field));
2017-05-18 14:29:41 +00:00
}
template <typename T, typename Storage>
VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
2017-05-18 14:29:41 +00:00
const vtkm::cont::ArrayHandle<T, Storage>& field)
{
dataSet.AddField(make_FieldPoint(fieldName, field));
2017-05-18 14:29:41 +00:00
}
template <typename T>
VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
2017-05-18 14:29:41 +00:00
const std::vector<T>& field)
{
dataSet.AddField(
make_Field(fieldName, vtkm::cont::Field::Association::POINTS, field, vtkm::CopyFlag::On));
2017-05-18 14:29:41 +00:00
}
template <typename T>
VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const T* field,
const vtkm::Id& n)
2017-05-18 14:29:41 +00:00
{
dataSet.AddField(
make_Field(fieldName, vtkm::cont::Field::Association::POINTS, field, n, vtkm::CopyFlag::On));
2017-05-18 14:29:41 +00:00
}
//Cell centered field
VTKM_CONT
static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const vtkm::cont::UnknownArrayHandle& field)
2017-05-18 14:29:41 +00:00
{
dataSet.AddField(make_FieldCell(fieldName, field));
2017-05-18 14:29:41 +00:00
}
template <typename T, typename Storage>
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const vtkm::cont::ArrayHandle<T, Storage>& field)
2017-05-18 14:29:41 +00:00
{
dataSet.AddField(make_FieldCell(fieldName, field));
2017-05-18 14:29:41 +00:00
}
template <typename T>
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const std::vector<T>& field)
2017-05-18 14:29:41 +00:00
{
dataSet.AddField(
make_Field(fieldName, vtkm::cont::Field::Association::CELL_SET, field, vtkm::CopyFlag::On));
2017-05-18 14:29:41 +00:00
}
template <typename T>
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const T* field,
const vtkm::Id& n)
2017-05-18 14:29:41 +00:00
{
dataSet.AddField(make_Field(
fieldName, vtkm::cont::Field::Association::CELL_SET, field, n, vtkm::CopyFlag::On));
2017-05-18 14:29:41 +00:00
}
2015-11-03 03:24:57 +00:00
};
}
2017-05-18 14:29:41 +00:00
} //namespace vtkm::cont
2015-11-03 03:24:57 +00:00
#endif //vtk_m_cont_DataSetFieldAdd_h