MeshLib
 
Loading...
Searching...
No Matches
MRHistogram.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRHeapBytes.h"
4
5namespace MR
6{
10{
11public:
12 Histogram() = default;
13
15 MRMESH_API Histogram( float min, float max, size_t size );
16
18 MRMESH_API void addSample( float sample, size_t count = 1 );
20 MRMESH_API void addHistogram( const Histogram& hist );
21
23 MRMESH_API const std::vector<size_t>& getBins() const;
24
26 MRMESH_API float getMin() const;
28 MRMESH_API float getMax() const;
29
31 MRMESH_API size_t getBinId( float sample ) const;
33 MRMESH_API std::pair<float, float> getBinMinMax( size_t binId ) const;
34
36 [[nodiscard]] size_t heapBytes() const { return MR::heapBytes( bins_ ); }
37
38private:
39 std::vector<size_t> bins_;
40 float min_{0.0f};
41 float max_{0.0f};
42 float binSize_{0.0f};
43};
44}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRHistogram.h:10
MRMESH_API void addSample(float sample, size_t count=1)
Adds sample to corresponding bin.
size_t heapBytes() const
returns the amount of memory this object occupies on heap
Definition MRHistogram.h:36
MRMESH_API float getMin() const
Gets minimum value of histogram.
MRMESH_API const std::vector< size_t > & getBins() const
Gets bins.
MRMESH_API std::pair< float, float > getBinMinMax(size_t binId) const
Gets minimum and maximum of diapason inherited by bin.
MRMESH_API float getMax() const
Gets maximum value of histogram.
MRMESH_API Histogram(float min, float max, size_t size)
Initialize histogram with minimum and maximum values, and number of bins.
MRMESH_API size_t getBinId(float sample) const
Gets id of bin that inherits sample.
Histogram()=default
MRMESH_API void addHistogram(const Histogram &hist)
Adds bins of input hist to this.
MRMESH_API size_t heapBytes(const FloatGrid &grid)
returns the amount of heap memory occupied by grid
Definition MRCameraOrientationPlugin.h:7
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32