vtk-m2/vtkm/cont/CoordinateSystem.h
Kenneth Moreland 9f624f0a36 Have CoordinateSystem inherit from Field
Previously, coordinate systems in a DataSet simply pointed to field data
specifying the coordinate information (although the ability to get that
back out of the DataSet was missing). This makes sense since point
coordinates are in fact just fields with a particular semantic meaning
to them.

However, there is an issue with this approach. It turns out that there
are special representations that are very common for point coordinates
and very uncommon for other types of fields. For example, a uniform
(a.k.a. regular or image) grid has point coordinates that are easily
derived from the point index, but such fields are quite uncommon
elsewhere.

Representing this kind of structure in the Field list of a DataSet is
problematic. Either all fields have to check to see if they are this
type, which will cause an explosion of unnecessary generated code, or
you will have to actually write out the coordinates in memory, which is
really wasteful but what was done previously.

However, by storing fields representing coordinate systems in a separate
batch, we can use these special types without the stated explosion.
2015-08-25 14:38:41 -06:00

74 lines
2.2 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.
//
// 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.
//============================================================================
#ifndef vtk_m_cont_CoordinateSystem_h
#define vtk_m_cont_CoordinateSystem_h
#include <vtkm/cont/Field.h>
namespace vtkm {
namespace cont {
class CoordinateSystem : public vtkm::cont::Field
{
public:
VTKM_CONT_EXPORT
CoordinateSystem(std::string name,
vtkm::IdComponent order,
const vtkm::cont::DynamicArrayHandle &data)
: Field(name, order, ASSOC_POINTS, data) { }
template<typename T, typename Storage>
VTKM_CONT_EXPORT
CoordinateSystem(std::string name,
vtkm::IdComponent order,
const ArrayHandle<T, Storage> &data)
: Field(name, order, ASSOC_POINTS, data) { }
template<typename T>
VTKM_CONT_EXPORT
CoordinateSystem(std::string name,
vtkm::IdComponent order,
const std::vector<T> &data)
: Field(name, order, ASSOC_POINTS, data) { }
template<typename T>
VTKM_CONT_EXPORT
CoordinateSystem(std::string name,
vtkm::IdComponent order,
const T *data,
vtkm::Id numberOfValues)
: Field(name, order, ASSOC_POINTS, data, numberOfValues) { }
VTKM_CONT_EXPORT
virtual void PrintSummary(std::ostream &out) const
{
out << " Coordinate System ";
this->PrintSummary(out);
}
};
} // namespace cont
} // namespace vtkm
#endif //vtk_m_cont_CoordinateSystem_h