1 //============================================================================
2 //  Copyright (c) Kitware, Inc.
3 //  All rights reserved.
4 //  See LICENSE.txt for details.
5 //  This software is distributed WITHOUT ANY WARRANTY; without even
6 //  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 //  PURPOSE.  See the above copyright notice for more information.
8 //
9 //  Copyright 2016 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10 //  Copyright 2016 UT-Battelle, LLC.
11 //  Copyright 2016 Los Alamos National Security.
12 //
13 //  Under the terms of Contract DE-NA0003525 with NTESS,
14 //  the U.S. Government retains certain rights in this software.
15 //
16 //  Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 //  Laboratory (LANL), the U.S. Government retains certain rights in
18 //  this software.
19 //============================================================================
20 #ifndef vtk_m_filter_NDEntropy_h
21 #define vtk_m_filter_NDEntropy_h
22 
23 #include <vtkm/filter/FilterDataSet.h>
24 
25 namespace vtkm
26 {
27 namespace filter
28 {
29 /// \brief Calculate the entropy of input N-Dims fields
30 ///
31 /// This filter calculate the entropy of input N-Dims fields.
32 ///
33 class NDEntropy : public vtkm::filter::FilterDataSet<NDEntropy>
34 {
35 public:
36   VTKM_CONT
37   NDEntropy();
38 
39   VTKM_CONT
40   void AddFieldAndBin(const std::string& fieldName, vtkm::Id numOfBins);
41 
42   template <typename Policy, typename Device>
43   VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData,
44                                           vtkm::filter::PolicyBase<Policy> policy,
45                                           Device);
46 
47   template <typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter>
48   VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
49                             const vtkm::cont::ArrayHandle<T, StorageType>& input,
50                             const vtkm::filter::FieldMetadata& fieldMeta,
51                             const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
52                             DeviceAdapter tag);
53 
54 private:
55   std::vector<vtkm::Id> NumOfBins;
56   std::vector<std::string> FieldNames;
57 };
58 }
59 } // namespace vtkm::filter
60 
61 #include <vtkm/filter/NDEntropy.hxx>
62 
63 #endif //vtk_m_filter_NDEntropy_h
64