9f624f0a36
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.
70 lines
2.5 KiB
C++
70 lines
2.5 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 2014 Sandia Corporation.
|
|
// Copyright 2014 UT-Battelle, LLC.
|
|
// Copyright 2014 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_ArrayHandleUniformPointCoordinates_h
|
|
#define vtk_m_cont_ArrayHandleUniformPointCoordinates_h
|
|
|
|
#include <vtkm/internal/ArrayPortalUniformPointCoordinates.h>
|
|
#include <vtkm/cont/ArrayHandle.h>
|
|
#include <vtkm/cont/StorageImplicit.h>
|
|
|
|
namespace vtkm {
|
|
namespace cont {
|
|
|
|
/// ArrayHandleUniformPointCoordinates is a specialization of ArrayHandle. It
|
|
/// contains the information necessary to compute the point coordinates in a
|
|
/// uniform orthogonal grid (extent, origin, and spacing) and implicitly
|
|
/// computes these coordinates in its array portal.
|
|
///
|
|
class ArrayHandleUniformPointCoordinates
|
|
: public vtkm::cont::ArrayHandle<
|
|
vtkm::Vec<vtkm::FloatDefault,3>,
|
|
vtkm::cont::StorageTagImplicit<
|
|
vtkm::internal::ArrayPortalUniformPointCoordinates> >
|
|
{
|
|
public:
|
|
typedef vtkm::Vec<vtkm::FloatDefault,3> ValueType;
|
|
typedef vtkm::cont::StorageTagImplicit<
|
|
vtkm::internal::ArrayPortalUniformPointCoordinates> StorageTag;
|
|
|
|
typedef vtkm::cont::ArrayHandle<ValueType, StorageTag> Superclass;
|
|
|
|
private:
|
|
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
|
|
|
|
public:
|
|
VTKM_CONT_EXPORT
|
|
ArrayHandleUniformPointCoordinates() : Superclass() { }
|
|
|
|
VTKM_CONT_EXPORT
|
|
ArrayHandleUniformPointCoordinates(
|
|
vtkm::Id3 dimensions,
|
|
ValueType origin = ValueType(0.0f, 0.0f, 0.0f),
|
|
ValueType spacing = ValueType(1.0f, 1.0f, 1.0f))
|
|
: Superclass(
|
|
StorageType(vtkm::internal::ArrayPortalUniformPointCoordinates(
|
|
dimensions, origin, spacing)))
|
|
{ }
|
|
};
|
|
|
|
}
|
|
} // namespace vtkm::cont
|
|
|
|
#endif //vtk_+m_cont_ArrayHandleUniformPointCoordinates_h
|