vtk-m/vtkm/filter/FieldMetadata.h

95 lines
2.8 KiB
C
Raw Normal View History

2016-01-19 14:59:31 +00:00
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +00:00
//
2016-01-19 14:59:31 +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_filter_FieldMetadata_h
#define vtk_m_filter_FieldMetadata_h
#include <vtkm/cont/CoordinateSystem.h>
2017-05-18 14:51:24 +00:00
#include <vtkm/cont/Field.h>
2016-01-19 14:59:31 +00:00
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace filter
{
2016-01-19 14:59:31 +00:00
class FieldMetadata
{
public:
VTKM_CONT
2017-05-18 14:29:41 +00:00
FieldMetadata()
: Name()
, Association(vtkm::cont::Field::Association::ANY)
2017-05-18 14:29:41 +00:00
{
}
2016-01-19 14:59:31 +00:00
VTKM_CONT
2017-05-18 14:29:41 +00:00
FieldMetadata(const vtkm::cont::Field& f)
: Name(f.GetName())
, Association(f.GetAssociation())
{
}
2016-01-19 14:59:31 +00:00
VTKM_CONT
2017-05-18 14:29:41 +00:00
FieldMetadata(const vtkm::cont::CoordinateSystem& sys)
: Name(sys.GetName())
, Association(sys.GetAssociation())
{
}
2016-01-19 14:59:31 +00:00
VTKM_CONT
bool IsPointField() const { return this->Association == vtkm::cont::Field::Association::POINTS; }
2016-01-19 14:59:31 +00:00
VTKM_CONT
bool IsCellField() const { return this->Association == vtkm::cont::Field::Association::CELL_SET; }
2016-01-19 14:59:31 +00:00
VTKM_CONT
2017-05-18 14:29:41 +00:00
const std::string& GetName() const { return this->Name; }
VTKM_CONT
vtkm::cont::Field::Association GetAssociation() const { return this->Association; }
2016-01-19 14:59:31 +00:00
/// Construct a new field with the same association as stored in this FieldMetaData
/// but with a new name
2017-05-18 14:29:41 +00:00
template <typename T, typename StorageTag>
VTKM_CONT vtkm::cont::Field AsField(const std::string& name,
const vtkm::cont::ArrayHandle<T, StorageTag>& handle) const
2017-05-18 14:29:41 +00:00
{
return vtkm::cont::Field(name, this->Association, handle);
2017-05-18 14:29:41 +00:00
}
/// 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
2017-05-18 14:29:41 +00:00
{
return vtkm::cont::Field(name, this->Association, handle);
2017-05-18 14:29:41 +00:00
}
/// 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);
}
2016-01-19 14:59:31 +00:00
private:
2017-05-18 14:29:41 +00:00
std::string Name; ///< name of field
vtkm::cont::Field::Association Association;
2016-01-19 14:59:31 +00:00
};
}
}
#endif //vtk_m_filter_FieldMetadata_h