2015-05-11 20:54:16 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2015-05-11 20:54:16 +00:00
|
|
|
// Copyright 2015 UT-Battelle, LLC.
|
|
|
|
// Copyright 2015 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2015-05-11 20:54:16 +00:00
|
|
|
// 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
|
|
|
|
2017-12-19 20:14:30 +00:00
|
|
|
#include <vtkm/cont/vtkm_cont_export.h>
|
|
|
|
|
2015-01-27 21:22:21 +00:00
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
2015-07-31 20:18:13 +00:00
|
|
|
#include <vtkm/cont/CoordinateSystem.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
2015-01-27 21:22:21 +00:00
|
|
|
#include <vtkm/cont/DynamicArrayHandle.h>
|
2015-07-28 23:33:52 +00:00
|
|
|
#include <vtkm/cont/DynamicCellSet.h>
|
2017-01-09 21:15:32 +00:00
|
|
|
#include <vtkm/cont/ErrorBadValue.h>
|
2015-07-31 20:18:13 +00:00
|
|
|
#include <vtkm/cont/Field.h>
|
2015-01-27 21:22:21 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2015-02-02 21:44:24 +00:00
|
|
|
|
2017-12-19 20:14:30 +00:00
|
|
|
class VTKM_CONT_EXPORT DataSet
|
2015-01-27 21:22:21 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-12-19 20:14:30 +00:00
|
|
|
VTKM_CONT DataSet();
|
2015-05-19 20:21:15 +00:00
|
|
|
|
2017-12-19 20:14:30 +00:00
|
|
|
VTKM_CONT void Clear();
|
2015-10-23 13:43:20 +00:00
|
|
|
|
2017-12-19 20:14:30 +00:00
|
|
|
VTKM_CONT void AddField(const Field& field) { this->Fields.push_back(field); }
|
2015-05-19 20:49:17 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-12-19 20:14:30 +00:00
|
|
|
const vtkm::cont::Field& GetField(vtkm::Id index) const;
|
2015-02-10 17:36:10 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
bool HasField(const std::string& name,
|
2018-05-18 20:10:15 +00:00
|
|
|
vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::ANY) const
|
2016-05-05 21:07:55 +00:00
|
|
|
{
|
|
|
|
bool found;
|
|
|
|
this->FindFieldIndex(name, assoc, found);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-26 17:53:28 +00:00
|
|
|
vtkm::Id GetFieldIndex(
|
|
|
|
const std::string& name,
|
2018-05-18 20:10:15 +00:00
|
|
|
vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::ANY) const;
|
2015-05-20 15:46:04 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::Field& GetField(
|
|
|
|
const std::string& name,
|
2018-05-18 20:10:15 +00:00
|
|
|
vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::ANY) const
|
2016-03-16 21:35:38 +00:00
|
|
|
{
|
|
|
|
return this->GetField(this->GetFieldIndex(name, assoc));
|
|
|
|
}
|
|
|
|
|
2017-01-31 19:50:52 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::Field& GetCellField(const std::string& name) const
|
2017-01-31 19:50:52 +00:00
|
|
|
{
|
2018-05-18 20:10:15 +00:00
|
|
|
return this->GetField(name, vtkm::cont::Field::Association::CELL_SET);
|
2017-01-31 19:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::Field& GetPointField(const std::string& name) const
|
2017-01-31 19:50:52 +00:00
|
|
|
{
|
2018-05-18 20:10:15 +00:00
|
|
|
return this->GetField(name, vtkm::cont::Field::Association::POINTS);
|
2017-01-31 19:50:52 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-12-19 20:14:30 +00:00
|
|
|
void AddCoordinateSystem(const vtkm::cont::CoordinateSystem& cs)
|
2015-04-15 17:01:00 +00:00
|
|
|
{
|
2017-12-19 20:14:30 +00:00
|
|
|
this->CoordSystems.push_back(cs);
|
2015-04-15 17:01:00 +00:00
|
|
|
}
|
2015-04-15 16:33:27 +00:00
|
|
|
|
2017-12-19 20:14:30 +00:00
|
|
|
VTKM_CONT
|
|
|
|
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0) const;
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
bool HasCoordinateSystem(const std::string& name) const
|
2016-05-05 21:07:55 +00:00
|
|
|
{
|
|
|
|
bool found;
|
|
|
|
this->FindCoordinateSystemIndex(name, found);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-12-19 20:14:30 +00:00
|
|
|
vtkm::Id GetCoordinateSystemIndex(const std::string& name) const;
|
2015-05-20 16:46:00 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name) const
|
2016-03-16 21:35:38 +00:00
|
|
|
{
|
|
|
|
return this->GetCoordinateSystem(this->GetCoordinateSystemIndex(name));
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-12-19 20:14:30 +00:00
|
|
|
void AddCellSet(const vtkm::cont::DynamicCellSet& cellSet) { this->CellSets.push_back(cellSet); }
|
2015-07-28 23:33:52 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename CellSetType>
|
|
|
|
VTKM_CONT void AddCellSet(const CellSetType& cellSet)
|
2015-04-15 17:01:00 +00:00
|
|
|
{
|
2015-07-28 23:33:52 +00:00
|
|
|
VTKM_IS_CELL_SET(CellSetType);
|
|
|
|
this->CellSets.push_back(vtkm::cont::DynamicCellSet(cellSet));
|
2015-04-15 17:01:00 +00:00
|
|
|
}
|
2015-02-10 17:36:10 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::DynamicCellSet GetCellSet(vtkm::Id index = 0) const
|
2015-08-17 18:47:46 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCellSets()));
|
2015-08-17 18:47:46 +00:00
|
|
|
return this->CellSets[static_cast<std::size_t>(index)];
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
bool HasCellSet(const std::string& name) const
|
2016-05-05 21:07:55 +00:00
|
|
|
{
|
|
|
|
bool found;
|
|
|
|
this->FindCellSetIndex(name, found);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-12-19 20:14:30 +00:00
|
|
|
vtkm::Id GetCellSetIndex(const std::string& name) const;
|
2015-09-22 14:22:30 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::DynamicCellSet GetCellSet(const std::string& name) const
|
2016-03-16 21:35:38 +00:00
|
|
|
{
|
|
|
|
return this->GetCellSet(this->GetCellSetIndex(name));
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-08-17 18:47:46 +00:00
|
|
|
vtkm::IdComponent GetNumberOfCellSets() const
|
|
|
|
{
|
|
|
|
return static_cast<vtkm::IdComponent>(this->CellSets.size());
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-08-17 18:47:46 +00:00
|
|
|
vtkm::IdComponent GetNumberOfFields() const
|
2015-05-12 18:57:32 +00:00
|
|
|
{
|
2015-08-17 18:47:46 +00:00
|
|
|
return static_cast<vtkm::IdComponent>(this->Fields.size());
|
2015-05-12 18:57:32 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-08-17 18:47:46 +00:00
|
|
|
vtkm::IdComponent GetNumberOfCoordinateSystems() const
|
2015-05-12 18:57:32 +00:00
|
|
|
{
|
2015-08-17 18:47:46 +00:00
|
|
|
return static_cast<vtkm::IdComponent>(this->CoordSystems.size());
|
2015-05-12 18:57:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-20 16:26:18 +00:00
|
|
|
/// Copies the structure i.e. coordinates systems and cellsets from the source
|
|
|
|
/// dataset. The fields are left unchanged.
|
|
|
|
VTKM_CONT
|
|
|
|
void CopyStructure(const vtkm::cont::DataSet& source);
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-12-19 20:14:30 +00:00
|
|
|
void PrintSummary(std::ostream& out) const;
|
2015-05-20 19:26:10 +00:00
|
|
|
|
2015-02-10 17:36:10 +00:00
|
|
|
private:
|
2015-05-20 16:46:00 +00:00
|
|
|
std::vector<vtkm::cont::CoordinateSystem> CoordSystems;
|
2015-02-10 17:36:10 +00:00
|
|
|
std::vector<vtkm::cont::Field> Fields;
|
2015-07-28 23:33:52 +00:00
|
|
|
std::vector<vtkm::cont::DynamicCellSet> CellSets;
|
2016-05-05 21:07:55 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-26 17:53:28 +00:00
|
|
|
vtkm::Id FindFieldIndex(const std::string& name,
|
2018-05-18 20:10:15 +00:00
|
|
|
vtkm::cont::Field::Association association,
|
2017-12-19 20:14:30 +00:00
|
|
|
bool& found) const;
|
2016-05-05 21:07:55 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-12-19 20:14:30 +00:00
|
|
|
vtkm::Id FindCoordinateSystemIndex(const std::string& name, bool& found) const;
|
2016-05-05 21:07:55 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-12-19 20:14:30 +00:00
|
|
|
vtkm::Id FindCellSetIndex(const std::string& name, bool& found) const;
|
2015-01-27 21:22:21 +00:00
|
|
|
};
|
|
|
|
|
2015-05-11 20:54:16 +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
|