vtk-m/vtkm/cont/DataSet.h

144 lines
3.8 KiB
C
Raw Normal View History

//============================================================================
// 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.
//
// Copyright 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
2015-01-28 16:27:15 +00:00
#ifndef vtk_m_cont_DataSet_h
#define vtk_m_cont_DataSet_h
2015-01-27 21:22:21 +00:00
2015-02-09 22:04:09 +00:00
#include <vtkm/CellType.h>
2015-01-27 21:22:21 +00:00
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/CoordinateSystem.h>
2015-01-27 21:22:21 +00:00
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/DynamicCellSet.h>
2015-02-10 17:36:10 +00:00
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/Field.h>
2015-01-27 21:22:21 +00:00
namespace vtkm {
namespace cont {
2015-01-28 16:27:15 +00:00
class DataSet
2015-01-27 21:22:21 +00:00
{
public:
VTKM_CONT_EXPORT
DataSet()
2015-02-10 17:36:10 +00:00
{
}
2015-05-19 20:21:15 +00:00
VTKM_CONT_EXPORT
void AddField(Field field)
{
this->Fields.push_back(field);
2015-02-10 17:36:10 +00:00
}
VTKM_CONT_EXPORT
const vtkm::cont::Field &GetField(vtkm::Id index) const
2015-02-10 17:36:10 +00:00
{
VTKM_ASSERT_CONT((index >= 0) &&
(index <= static_cast<vtkm::Id>(this->Fields.size())));
return this->Fields[static_cast<std::size_t>(index)];
2015-02-10 17:36:10 +00:00
}
VTKM_CONT_EXPORT
const vtkm::cont::Field &GetField(const std::string &name) const
{
for (std::size_t i=0; i < this->Fields.size(); ++i)
{
if (this->Fields[i].GetName() == name)
{
return this->Fields[i];
}
}
throw vtkm::cont::ErrorControlBadValue("No field with requested name");
}
VTKM_CONT_EXPORT
vtkm::cont::DynamicCellSet GetCellSet(vtkm::Id index=0) const
{
VTKM_ASSERT_CONT((index >= 0) &&
(index <= static_cast<vtkm::Id>(this->CellSets.size())));
return this->CellSets[static_cast<std::size_t>(index)];
}
2015-04-15 16:33:27 +00:00
VTKM_CONT_EXPORT
void AddCoordinateSystem(vtkm::cont::CoordinateSystem cs)
{
this->CoordSystems.push_back(cs);
}
VTKM_CONT_EXPORT
void AddCellSet(vtkm::cont::DynamicCellSet cellSet)
{
this->CellSets.push_back(cellSet);
}
template<typename CellSetType>
VTKM_CONT_EXPORT
void AddCellSet(const CellSetType &cellSet)
{
VTKM_IS_CELL_SET(CellSetType);
this->CellSets.push_back(vtkm::cont::DynamicCellSet(cellSet));
}
2015-02-10 17:36:10 +00:00
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfCellSets() const
{
return static_cast<vtkm::Id>(this->CellSets.size());
}
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfFields() const
{
return static_cast<vtkm::Id>(this->Fields.size());
}
VTKM_CONT_EXPORT
void PrintSummary(std::ostream &out) const
2015-05-20 19:26:10 +00:00
{
out<<"DataSet:\n";
out<<" CoordSystems["<<this->CoordSystems.size()<<"]\n";
for (std::size_t i = 0; i < this->CoordSystems.size(); i++)
{
this->CoordSystems[i].PrintSummary(out);
}
out<<" CellSets["<<this->GetNumberOfCellSets()<<"]\n";
for (vtkm::Id i = 0; i < this->GetNumberOfCellSets(); i++)
{
this->GetCellSet(i).GetCellSet().PrintSummary(out);
}
out<<" Fields["<<this->GetNumberOfFields()<<"]\n";
for (vtkm::Id i = 0; i < this->GetNumberOfFields(); i++)
{
this->GetField(i).PrintSummary(out);
}
2015-05-20 19:26:10 +00:00
}
2015-02-10 17:36:10 +00:00
private:
std::vector<vtkm::cont::CoordinateSystem> CoordSystems;
2015-02-10 17:36:10 +00:00
std::vector<vtkm::cont::Field> Fields;
std::vector<vtkm::cont::DynamicCellSet> CellSets;
2015-01-27 21:22:21 +00:00
};
} // namespace cont
} // namespace vtkm
2015-01-27 21:22:21 +00:00
2015-01-28 16:27:15 +00:00
#endif //vtk_m_cont_DataSet_h