forked from Kitware/ParaView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvtkEntropyArrayMeasurement.h
124 lines (104 loc) · 4.29 KB
/
vtkEntropyArrayMeasurement.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*=========================================================================
Program: Visualization Toolkit
Module: vtkEntropyArrayMeasurement.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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.
=========================================================================*/
/**
* @class vtkEntropyArrayMeasurement
* @brief measures the entropy of an array
*
* Measures the entropy of an array, either by giving the full array,
* or by feeding value per value.
* Merging complexity is constant, and overall algorithm is linear in function
* of the input size.
*
* @warning Unlike most vtkAbstractArrayMeasurement, given accumulated data,
* the entropy complexity is linear in function of the number of bins.
*/
#ifndef vtkEntropyArrayMeasurement_h
#define vtkEntropyArrayMeasurement_h
#include "vtkAbstractArrayMeasurement.h"
#include "vtkFiltersHyperTreeGridADRModule.h" // For export macro
class VTKFILTERSHYPERTREEGRIDADR_EXPORT vtkEntropyArrayMeasurement
: public vtkAbstractArrayMeasurement
{
public:
static vtkEntropyArrayMeasurement* New();
vtkTypeMacro(vtkEntropyArrayMeasurement, vtkAbstractArrayMeasurement);
using Superclass::Add;
using Superclass::CanMeasure;
using Superclass::Measure;
/**
* Minimum times the function Add should be called on accumulators or this class
* in order to measure something.
*/
static constexpr vtkIdType MinimumNumberOfAccumulatedData = 1;
/**
* Number of accumulators required for measuring.
*/
static constexpr vtkIdType NumberOfAccumulators = 1;
/**
* Notifies if the entropy can be measured given the amount of input data.
* The entropy needs at least one accumulated data with non-zero weight.
*
* @param numberOfAccumulatedData is the number of times Add was called in the accumulators / this
* class
* @param totalWeight is the accumulated weight while accumulated. If weights were not set when
* accumulated, it should be equal to numberOfAccumulatedData.
* @return true if there is enough data and if totalWeight != 0, false otherwise.
*/
static bool IsMeasurable(vtkIdType numberOfAccumulatedData, double totalWeight);
/**
* Instantiates needed accumulators for measurement, i.e. one vtkBinsAccumulator* in our case.
*
* @return the array {vtkBinsAccumulator::New()}.
*/
static std::vector<vtkAbstractAccumulator*> NewAccumulators();
/**
* Computes the entropy of the set of accumulators needed (i.e. one vtkBinsAccumulator*).
*
* @param accumulators is an array of accumulators. It should be composed of a single
* vtkBinsAccumulator*.
* @param numberOfAccumulatedData is the number of times the method Add was called in the
* accumulators.
* @param totalWeight is the cumulated weight when adding data. If weight was not set while
* accumulating. it should equal numberOfAccumulatedData.
* @param value is where the entropy measurement is written into.
* @return true if the data is measurable, i.e. there is not enough data or a null totalWeight.
*/
bool Measure(vtkAbstractAccumulator** accumulators, vtkIdType numberOfAccumulatedData,
double totalWeight, double& value) override;
//@{
/**
* See the vtkAbstractArrayMeasurement API for description of this method.
*/
bool CanMeasure(vtkIdType numberOfAccumulatedData, double totalWeight) const override;
std::vector<vtkAbstractAccumulator*> NewAccumulatorInstances() const override;
vtkIdType GetMinimumNumberOfAccumulatedData() const override;
vtkIdType GetNumberOfAccumulators() const override;
//@}
//@{
/**
* Accessors on the DiscretizationStep used for calculating the entropy.
*/
double GetDiscretizationStep() const;
void SetDiscretizationStep(double);
//@}
protected:
//@{
/**
* Default constructor and destructor
*/
vtkEntropyArrayMeasurement();
virtual ~vtkEntropyArrayMeasurement() override = default;
//@}
private:
vtkEntropyArrayMeasurement(vtkEntropyArrayMeasurement&) = delete;
void operator=(vtkEntropyArrayMeasurement&) = delete;
};
#endif