ZFPCompressor1D.h 2.77 KB
Newer Older
Mark Kim's avatar
Mark Kim committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
//============================================================================
//  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 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
//  Copyright 2014 UT-Battelle, LLC.
//  Copyright 2014 Los Alamos National Security.
//
//  Under the terms of Contract DE-NA0003525 with NTESS,
//  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_filter_ZFPCompressor1D_h
#define vtk_m_filter_ZFPCompressor1D_h

24
#include <vtkm/filter/FilterField.h>
Mark Kim's avatar
Mark Kim committed
25
#include <vtkm/worklet/ZFP1DCompressor.h>
Mark Kim's avatar
Mark Kim committed
26 27 28 29 30 31 32 33 34 35 36

namespace vtkm
{
namespace filter
{
/// \brief Compress a scalar field using ZFP

/// Takes as input a 1D array and generates on
/// output of compressed data.
/// @warning
/// This filter is currently only supports 1D volumes.
37
class ZFPCompressor1D : public vtkm::filter::FilterField<ZFPCompressor1D>
Mark Kim's avatar
Mark Kim committed
38 39 40 41 42
{
public:
  VTKM_CONT
  ZFPCompressor1D();

43 44
  void SetRate(vtkm::Float64 _rate) { rate = _rate; }
  vtkm::Float64 GetRate() { return rate; }
Mark Kim's avatar
Mark Kim committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

  template <typename T, typename StorageType, typename DerivedPolicy>
  VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
                                          const vtkm::cont::ArrayHandle<T, StorageType>& field,
                                          const vtkm::filter::FieldMetadata& fieldMeta,
                                          const vtkm::filter::PolicyBase<DerivedPolicy>& policy);

  //Map a new field onto the resulting dataset after running the filter
  //this call is only valid
  template <typename T, typename StorageType, typename DerivedPolicy>
  VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
                            const vtkm::cont::ArrayHandle<T, StorageType>& input,
                            const vtkm::filter::FieldMetadata& fieldMeta,
                            const vtkm::filter::PolicyBase<DerivedPolicy>& policy);

private:
61
  vtkm::Float64 rate;
62
  vtkm::worklet::ZFP1DCompressor compressor;
Mark Kim's avatar
Mark Kim committed
63 64 65 66 67 68
};

template <>
class FilterTraits<ZFPCompressor1D>
{
public:
69
  struct TypeListTagMCScalars : vtkm::ListTagBase<vtkm::Int32, vtkm::Float32, vtkm::Float64>
Mark Kim's avatar
Mark Kim committed
70 71 72 73 74 75 76 77 78
  {
  };
  using InputFieldTypeList = TypeListTagMCScalars;
};
}
} // namespace vtkm::filter

#include <vtkm/filter/ZFPCompressor1D.hxx>

79
#endif // vtk_m_filter_ZFPCompressor1D_h