vtk-m2/vtkm/filter/FieldMetadata.h
Kenneth Moreland f8f41e0ef5 Update use of field association enumerations
The enumerations in `vtkm::cont::Field::Association` were renamed in the
previous commit. The old names still exist, but are deprecated. Change
the rest of the code to use the new names.
2022-03-17 11:02:37 -06:00

95 lines
2.8 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.
//============================================================================
#ifndef vtk_m_filter_FieldMetadata_h
#define vtk_m_filter_FieldMetadata_h
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/Field.h>
namespace vtkm
{
namespace filter
{
class FieldMetadata
{
public:
VTKM_CONT
FieldMetadata()
: Name()
, Association(vtkm::cont::Field::Association::Any)
{
}
VTKM_CONT
FieldMetadata(const vtkm::cont::Field& f)
: Name(f.GetName())
, Association(f.GetAssociation())
{
}
VTKM_CONT
FieldMetadata(const vtkm::cont::CoordinateSystem& sys)
: Name(sys.GetName())
, Association(sys.GetAssociation())
{
}
VTKM_CONT
bool IsPointField() const { return this->Association == vtkm::cont::Field::Association::Points; }
VTKM_CONT
bool IsCellField() const { return this->Association == vtkm::cont::Field::Association::Cells; }
VTKM_CONT
const std::string& GetName() const { return this->Name; }
VTKM_CONT
vtkm::cont::Field::Association GetAssociation() const { return this->Association; }
/// Construct a new field with the same association as stored in this FieldMetaData
/// but with a new name
template <typename T, typename StorageTag>
VTKM_CONT vtkm::cont::Field AsField(const std::string& name,
const vtkm::cont::ArrayHandle<T, StorageTag>& handle) const
{
return vtkm::cont::Field(name, this->Association, handle);
}
/// Construct a new field with the same association as stored in this FieldMetaData
/// but with a new name
VTKM_CONT
vtkm::cont::Field AsField(const std::string& name,
const vtkm::cont::UnknownArrayHandle& handle) const
{
return vtkm::cont::Field(name, this->Association, handle);
}
/// Construct a new field with the same association and name as stored in this FieldMetaData
template <typename T, typename StorageTag>
VTKM_CONT vtkm::cont::Field AsField(const vtkm::cont::ArrayHandle<T, StorageTag>& handle) const
{
return this->AsField(this->Name, handle);
}
/// Construct a new field with the same association and name as stored in this FieldMetaData
VTKM_CONT vtkm::cont::Field AsField(const vtkm::cont::UnknownArrayHandle& handle) const
{
return this->AsField(this->Name, handle);
}
private:
std::string Name; ///< name of field
vtkm::cont::Field::Association Association;
};
}
}
#endif //vtk_m_filter_FieldMetadata_h