2015-05-11 20:54:16 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2015-05-11 20:54:16 +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.
|
|
|
|
//============================================================================
|
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-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>
|
2021-04-02 17:37:49 +00:00
|
|
|
#include <vtkm/cont/UnknownArrayHandle.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 void Clear();
|
2015-10-23 13:43:20 +00:00
|
|
|
|
2019-08-13 17:08:54 +00:00
|
|
|
/// Get the number of cells contained in this DataSet
|
|
|
|
VTKM_CONT vtkm::Id GetNumberOfCells() const;
|
|
|
|
|
|
|
|
/// Get the number of points contained in this DataSet
|
|
|
|
///
|
|
|
|
/// Note: All coordinate systems for a DataSet are expected
|
|
|
|
/// to have the same number of points.
|
|
|
|
VTKM_CONT vtkm::Id GetNumberOfPoints() const;
|
|
|
|
|
2020-05-01 17:55:55 +00:00
|
|
|
VTKM_CONT void AddField(const Field& 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
|
|
|
|
2019-08-26 19:58:11 +00:00
|
|
|
VTKM_CONT
|
|
|
|
vtkm::cont::Field& GetField(vtkm::Id index);
|
|
|
|
|
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
|
|
|
{
|
2019-08-13 14:10:52 +00:00
|
|
|
bool found = false;
|
2016-05-05 21:07:55 +00:00
|
|
|
this->FindFieldIndex(name, assoc, found);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2019-08-13 14:10:52 +00:00
|
|
|
VTKM_CONT
|
|
|
|
bool HasCellField(const std::string& name) const
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
this->FindFieldIndex(name, vtkm::cont::Field::Association::CELL_SET, found);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
bool HasPointField(const std::string& name) const
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
this->FindFieldIndex(name, vtkm::cont::Field::Association::POINTS, found);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2019-08-19 13:04:53 +00:00
|
|
|
|
2020-05-01 17:55:55 +00:00
|
|
|
/// Returns the field that matches the provided name and association
|
2019-08-19 13:04:53 +00:00
|
|
|
/// Will return -1 if no match is 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
|
|
|
|
2020-05-01 17:55:55 +00:00
|
|
|
/// Returns the field that matches the provided name and association
|
2019-08-19 13:04:53 +00:00
|
|
|
/// Will throw an exception if no match is found
|
2019-08-26 19:58:11 +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));
|
|
|
|
}
|
|
|
|
|
2019-08-26 19:58:11 +00:00
|
|
|
VTKM_CONT
|
|
|
|
vtkm::cont::Field& GetField(
|
|
|
|
const std::string& name,
|
|
|
|
vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::ANY)
|
|
|
|
{
|
|
|
|
return this->GetField(this->GetFieldIndex(name, assoc));
|
|
|
|
}
|
|
|
|
//@}
|
|
|
|
|
2019-08-19 13:04:53 +00:00
|
|
|
/// Returns the first cell field that matches the provided name.
|
|
|
|
/// Will throw an exception if no match is found
|
2019-08-26 19:58:11 +00:00
|
|
|
//@{
|
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
|
|
|
}
|
|
|
|
|
2019-08-26 19:58:11 +00:00
|
|
|
VTKM_CONT
|
|
|
|
vtkm::cont::Field& GetCellField(const std::string& name)
|
|
|
|
{
|
|
|
|
return this->GetField(name, vtkm::cont::Field::Association::CELL_SET);
|
|
|
|
}
|
|
|
|
//@}
|
|
|
|
|
2019-08-19 13:04:53 +00:00
|
|
|
/// Returns the first point field that matches the provided name.
|
|
|
|
/// Will throw an exception if no match is found
|
2019-08-26 19:58:11 +00:00
|
|
|
//@{
|
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
|
|
|
}
|
|
|
|
|
2019-08-26 19:58:11 +00:00
|
|
|
VTKM_CONT
|
|
|
|
vtkm::cont::Field& GetPointField(const std::string& name)
|
|
|
|
{
|
|
|
|
return this->GetField(name, vtkm::cont::Field::Association::POINTS);
|
|
|
|
}
|
|
|
|
//@}
|
|
|
|
|
2020-05-27 19:27:47 +00:00
|
|
|
VTKM_CONT
|
2021-04-02 17:37:49 +00:00
|
|
|
void AddPointField(const std::string& fieldName, const vtkm::cont::UnknownArrayHandle& field)
|
2020-05-27 19:27:47 +00:00
|
|
|
{
|
|
|
|
this->AddField(make_FieldPoint(fieldName, field));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename Storage>
|
|
|
|
VTKM_CONT void AddPointField(const std::string& fieldName,
|
|
|
|
const vtkm::cont::ArrayHandle<T, Storage>& field)
|
|
|
|
{
|
|
|
|
this->AddField(make_FieldPoint(fieldName, field));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT void AddPointField(const std::string& fieldName, const std::vector<T>& field)
|
|
|
|
{
|
|
|
|
this->AddField(
|
|
|
|
make_Field(fieldName, vtkm::cont::Field::Association::POINTS, field, vtkm::CopyFlag::On));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT void AddPointField(const std::string& fieldName, const T* field, const vtkm::Id& n)
|
|
|
|
{
|
|
|
|
this->AddField(
|
|
|
|
make_Field(fieldName, vtkm::cont::Field::Association::POINTS, field, n, vtkm::CopyFlag::On));
|
|
|
|
}
|
|
|
|
|
|
|
|
//Cell centered field
|
|
|
|
VTKM_CONT
|
2021-04-02 17:37:49 +00:00
|
|
|
void AddCellField(const std::string& fieldName, const vtkm::cont::UnknownArrayHandle& field)
|
2020-05-27 19:27:47 +00:00
|
|
|
{
|
|
|
|
this->AddField(make_FieldCell(fieldName, field));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename Storage>
|
|
|
|
VTKM_CONT void AddCellField(const std::string& fieldName,
|
|
|
|
const vtkm::cont::ArrayHandle<T, Storage>& field)
|
|
|
|
{
|
|
|
|
this->AddField(make_FieldCell(fieldName, field));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT void AddCellField(const std::string& fieldName, const std::vector<T>& field)
|
|
|
|
{
|
|
|
|
this->AddField(
|
|
|
|
make_Field(fieldName, vtkm::cont::Field::Association::CELL_SET, field, vtkm::CopyFlag::On));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT void AddCellField(const std::string& fieldName, const T* field, const vtkm::Id& n)
|
|
|
|
{
|
|
|
|
this->AddField(make_Field(
|
|
|
|
fieldName, vtkm::cont::Field::Association::CELL_SET, field, n, vtkm::CopyFlag::On));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
{
|
2019-08-19 13:04:53 +00:00
|
|
|
return this->GetCoordinateSystemIndex(name) >= 0;
|
2016-05-05 21:07:55 +00:00
|
|
|
}
|
|
|
|
|
2019-08-19 13:04:53 +00:00
|
|
|
VTKM_CONT
|
|
|
|
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0) const;
|
|
|
|
|
2019-08-22 20:46:52 +00:00
|
|
|
VTKM_CONT
|
|
|
|
vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0);
|
|
|
|
|
2019-08-19 13:04:53 +00:00
|
|
|
/// Returns the index for the first CoordinateSystem whose
|
|
|
|
/// name matches the provided string.
|
|
|
|
/// Will return -1 if no match is 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
|
|
|
|
2019-08-19 13:04:53 +00:00
|
|
|
/// Returns the first CoordinateSystem that matches the provided name.
|
|
|
|
/// Will throw an exception if no match is found
|
2019-08-22 20:46:52 +00:00
|
|
|
//@{
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-08-19 13:04:53 +00:00
|
|
|
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name) const;
|
2016-03-16 21:35:38 +00:00
|
|
|
|
2019-08-22 20:46:52 +00:00
|
|
|
VTKM_CONT
|
|
|
|
vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name);
|
|
|
|
//@}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-08-13 17:08:54 +00:00
|
|
|
void SetCellSet(const vtkm::cont::DynamicCellSet& cellSet) { this->CellSet = cellSet; }
|
2015-07-28 23:33:52 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename CellSetType>
|
2019-08-13 17:08:54 +00:00
|
|
|
VTKM_CONT void SetCellSet(const CellSetType& cellSet)
|
2015-04-15 17:01:00 +00:00
|
|
|
{
|
2015-07-28 23:33:52 +00:00
|
|
|
VTKM_IS_CELL_SET(CellSetType);
|
2019-08-13 17:08:54 +00:00
|
|
|
this->CellSet = 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
|
2019-08-13 17:08:54 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& GetCellSet() const { return this->CellSet; }
|
2019-08-19 13:04:53 +00:00
|
|
|
|
2019-08-26 19:58:11 +00:00
|
|
|
VTKM_CONT
|
2019-08-13 17:08:54 +00:00
|
|
|
vtkm::cont::DynamicCellSet& GetCellSet() { return this->CellSet; }
|
2015-08-17 18:47:46 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-08-13 17:08:54 +00:00
|
|
|
/// Copies the structure i.e. coordinates systems and cellset from the source
|
2018-04-20 16:26:18 +00:00
|
|
|
/// dataset. The fields are left unchanged.
|
|
|
|
VTKM_CONT
|
|
|
|
void CopyStructure(const vtkm::cont::DataSet& source);
|
|
|
|
|
2021-02-01 16:35:00 +00:00
|
|
|
/// \brief Convert the structures in this data set to expected types.
|
|
|
|
///
|
|
|
|
/// A `DataSet` object can contain data structures of unknown types. Using the data
|
|
|
|
/// requires casting these data structures to concrete types. It is only possible to
|
|
|
|
/// check a finite number of data structures.
|
|
|
|
///
|
|
|
|
/// The types checked by default are listed in `vtkm/cont/DefaultTypes.h`, which can
|
|
|
|
/// be configured at compile time. If a `DataSet` contains data not listed there, then
|
|
|
|
/// it is likely going to cause problems pulling the data back out. To get around this
|
|
|
|
/// problem, you can call this method to convert the data to a form that is likely to
|
|
|
|
/// be recognized. This conversion is likely but not guaranteed because not all types
|
|
|
|
/// are convertable to something recognizable.
|
|
|
|
///
|
|
|
|
VTKM_CONT void ConvertToExpected();
|
|
|
|
|
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:
|
2020-05-01 17:55:55 +00:00
|
|
|
struct FieldCompare
|
|
|
|
{
|
|
|
|
using Key = std::pair<std::string, vtkm::cont::Field::Association>;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
bool operator()(const T& a, const T& b) const
|
|
|
|
{
|
|
|
|
if (a.first == b.first)
|
|
|
|
return a.second < b.second && a.second != vtkm::cont::Field::Association::ANY &&
|
|
|
|
b.second != vtkm::cont::Field::Association::ANY;
|
|
|
|
|
|
|
|
return a.first < b.first;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-20 16:46:00 +00:00
|
|
|
std::vector<vtkm::cont::CoordinateSystem> CoordSystems;
|
2020-05-01 17:55:55 +00:00
|
|
|
std::map<FieldCompare::Key, vtkm::cont::Field, FieldCompare> Fields;
|
2019-08-13 17:08:54 +00:00
|
|
|
vtkm::cont::DynamicCellSet CellSet;
|
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;
|
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
|
|
|
|
2018-06-18 17:56:38 +00:00
|
|
|
//=============================================================================
|
|
|
|
// Specializations of serialization related classes
|
2019-09-12 21:19:36 +00:00
|
|
|
/// @cond SERIALIZATION
|
2018-06-18 17:56:38 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
|
2019-12-05 17:55:57 +00:00
|
|
|
template <typename FieldTypeList = VTKM_DEFAULT_TYPE_LIST,
|
2019-12-05 21:38:41 +00:00
|
|
|
typename CellSetTypesList = VTKM_DEFAULT_CELL_SET_LIST>
|
2018-06-18 17:56:38 +00:00
|
|
|
struct SerializableDataSet
|
|
|
|
{
|
|
|
|
SerializableDataSet() = default;
|
|
|
|
|
|
|
|
explicit SerializableDataSet(const vtkm::cont::DataSet& dataset)
|
|
|
|
: DataSet(dataset)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
vtkm::cont::DataSet DataSet;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} // vtkm::cont
|
|
|
|
|
2019-02-05 16:02:29 +00:00
|
|
|
namespace mangled_diy_namespace
|
2018-06-18 17:56:38 +00:00
|
|
|
{
|
|
|
|
|
2018-11-06 16:40:39 +00:00
|
|
|
template <typename FieldTypeList, typename CellSetTypesList>
|
|
|
|
struct Serialization<vtkm::cont::SerializableDataSet<FieldTypeList, CellSetTypesList>>
|
2018-06-18 17:56:38 +00:00
|
|
|
{
|
|
|
|
private:
|
2018-11-06 16:40:39 +00:00
|
|
|
using Type = vtkm::cont::SerializableDataSet<FieldTypeList, CellSetTypesList>;
|
2018-06-18 17:56:38 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
static VTKM_CONT void save(BinaryBuffer& bb, const Type& serializable)
|
|
|
|
{
|
|
|
|
const auto& dataset = serializable.DataSet;
|
|
|
|
|
|
|
|
vtkm::IdComponent numberOfCoordinateSystems = dataset.GetNumberOfCoordinateSystems();
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::save(bb, numberOfCoordinateSystems);
|
2018-06-18 17:56:38 +00:00
|
|
|
for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i)
|
|
|
|
{
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::save(bb, dataset.GetCoordinateSystem(i));
|
2018-06-18 17:56:38 +00:00
|
|
|
}
|
|
|
|
|
2019-08-13 17:08:54 +00:00
|
|
|
vtkmdiy::save(bb, dataset.GetCellSet().ResetCellSetList(CellSetTypesList{}));
|
2018-06-18 17:56:38 +00:00
|
|
|
|
|
|
|
vtkm::IdComponent numberOfFields = dataset.GetNumberOfFields();
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::save(bb, numberOfFields);
|
2018-06-18 17:56:38 +00:00
|
|
|
for (vtkm::IdComponent i = 0; i < numberOfFields; ++i)
|
|
|
|
{
|
2021-01-25 17:36:56 +00:00
|
|
|
vtkmdiy::save(bb, dataset.GetField(i));
|
2018-06-18 17:56:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static VTKM_CONT void load(BinaryBuffer& bb, Type& serializable)
|
|
|
|
{
|
|
|
|
auto& dataset = serializable.DataSet;
|
|
|
|
dataset = {}; // clear
|
|
|
|
|
|
|
|
vtkm::IdComponent numberOfCoordinateSystems = 0;
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::load(bb, numberOfCoordinateSystems);
|
2018-06-18 17:56:38 +00:00
|
|
|
for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i)
|
|
|
|
{
|
|
|
|
vtkm::cont::CoordinateSystem coords;
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::load(bb, coords);
|
2018-06-18 17:56:38 +00:00
|
|
|
dataset.AddCoordinateSystem(coords);
|
|
|
|
}
|
|
|
|
|
2019-08-13 17:08:54 +00:00
|
|
|
vtkm::cont::DynamicCellSetBase<CellSetTypesList> cells;
|
|
|
|
vtkmdiy::load(bb, cells);
|
|
|
|
dataset.SetCellSet(vtkm::cont::DynamicCellSet(cells));
|
2018-06-18 17:56:38 +00:00
|
|
|
|
|
|
|
vtkm::IdComponent numberOfFields = 0;
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::load(bb, numberOfFields);
|
2018-06-18 17:56:38 +00:00
|
|
|
for (vtkm::IdComponent i = 0; i < numberOfFields; ++i)
|
|
|
|
{
|
2021-01-25 17:36:56 +00:00
|
|
|
vtkm::cont::Field field;
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::load(bb, field);
|
2021-01-25 17:36:56 +00:00
|
|
|
dataset.AddField(field);
|
2018-06-18 17:56:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // diy
|
2019-09-12 21:19:36 +00:00
|
|
|
/// @endcond SERIALIZATION
|
2018-06-18 17:56:38 +00:00
|
|
|
|
2015-01-28 16:27:15 +00:00
|
|
|
#endif //vtk_m_cont_DataSet_h
|