vtk-m/vtkm/filter/CoordinateSystemTransform.hxx
Vicente Adolfo Bolea Sanchez e4aa20594a Output CoordinateSystemTransforms results in Coordinates
This commit changes how CoordinateSystemTransforms write their result.

Before theoy would write their result in a DataSet in which the new
Coords where stored in a field with the name of:
 - cylindricalCoordinateSystemTransform
 - sphericalCoordinateSystemTransform

Now, they write their results as a DataSet in which its first Coords
are the transformed Coords. Previous Coordinates are appended

Signed-off-by: Vicente Adolfo Bolea Sanchez <vicente.bolea@kitware.com>
2020-03-05 15:21:47 -05:00

76 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.
//============================================================================
#ifndef vtk_m_filter_CoordianteSystemTransform_hxx
#define vtk_m_filter_CoordianteSystemTransform_hxx
namespace vtkm
{
namespace filter
{
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet CylindricalCoordinateTransform::DoExecute(
const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& vtkmNotUsed(fieldMetadata),
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
vtkm::cont::ArrayHandle<T> outArray;
vtkm::cont::DataSet outDataSet;
this->Worklet.Run(field, outArray);
// We first add the result coords to keep them at the first position
// of the resulting dataset.
outDataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", outArray));
for (int i = 0; i < inDataSet.GetNumberOfCoordinateSystems(); i++)
{
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(i));
}
outDataSet.SetCellSet(inDataSet.GetCellSet());
return outDataSet;
}
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet SphericalCoordinateTransform::DoExecute(
const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& vtkmNotUsed(fieldMetadata),
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
vtkm::cont::ArrayHandle<T> outArray;
vtkm::cont::DataSet outDataSet;
this->Worklet.Run(field, outArray);
// We first add the result coords to keep them at the first position
// of the resulting dataset.
outDataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", outArray));
for (int i = 0; i < inDataSet.GetNumberOfCoordinateSystems(); i++)
{
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(i));
}
outDataSet.SetCellSet(inDataSet.GetCellSet());
return outDataSet;
}
}
} // namespace vtkm::filter
#endif