VAPOR3 3.9.4
Histo.h
Go to the documentation of this file.
1//************************************************************************
2// *
3// Copyright (C) 2004 *
4// University Corporation for Atmospheric Research *
5// All Rights Reserved *
6// *
7//************************************************************************/
8//
9// File: Histo.h
10//
11// Author: Alan Norton
12// National Center for Atmospheric Research
13// PO 3000, Boulder, Colorado
14//
15// Date: November 2004
16//
17// Description: Definition of Histo class:
18// it contains a histogram derived from volume data.
19// Used by TFEditor to draw histogram behind transfer function opacity
20//
21#ifndef HISTO_H
22#define HISTO_H
23#include <string>
24#include <vector>
25#include <climits>
26#include <vapor/MyBase.h>
28#include <vapor/RenderParams.h>
29#include <vapor/DataMgr.h>
30
32public:
33 Histo(int numberBins, float mnData, float mxData, string var, int ts);
34 Histo(int numberBins);
37 void reset(int newNumBins = -1);
38 void reset(int newNumBins, float mnData, float mxData);
39 void addToBin(float val);
40 void setBins(const vector<long> &bins);
42 int getMaxBinSizeBetweenIndices(const int start, const int end) const;
43 int getNumBins() const;
44 int getBinSize(int index) const;
45 int getBinSize(int index, int stride) const;
46 float getNormalizedBinSize(int bin) const;
47 float getNormalizedBinSizeForValue(float v) const;
49 int getBinIndexForValue(float v);
50 float getMinMapData() { return _minMapData; }
51 float getMaxMapData() { return _maxMapData; }
52 float getRange() { return _range; }
53
54 int getTimestepOfUpdate() { return _timestepOfUpdate; }
55 string getVarnameOfUpdate() { return _varnameOfUpdate; }
56
57 int Populate(const std::string &varName, VAPoR::DataMgr *dm, VAPoR::RenderParams *rp);
58 bool NeedsUpdate(const std::string &varName, VAPoR::DataMgr *dm, VAPoR::RenderParams *rp);
59 int PopulateIfNeeded(const std::string &varName, VAPoR::DataMgr *dm, VAPoR::RenderParams *rp);
60
61 static vector<float> GetDataSamples(const std::string &varName, VAPoR::DataMgr *dm, VAPoR::RenderParams *rp);
62
63private:
64 unsigned int *_binArray = nullptr;
65 unsigned int *_below = nullptr;
66 unsigned int *_above = nullptr;
67 int _nBinsBelow = 0, _nBinsAbove = 0;
68 long _numSamplesBelow, _numSamplesAbove;
69 int _numBins = 0;
70 float _minMapData, _maxMapData, _range;
71 float _minData, _maxData;
72 long _maxBinSize = -1;
73
74 int _refLevel = INT_MIN, _lod = INT_MIN;
75 std::vector<double> _minExts, _maxExts;
76 bool _populated = false;
77
78 int _timestepOfUpdate;
79 string _varnameOfUpdate;
80 bool autoSetProperties = false;
81
82 static vector<float> getDataSamplesIterating(const VAPoR::Grid *grid, const int stride);
83 static vector<float> getDataSamplesSampling(const VAPoR::Grid *grid, const vector<double> &minExts, const vector<double> &maxExts);
84
85 void populateIteratingHistogram(const VAPoR::Grid *grid, const int stride);
86 void populateSamplingHistogram(const VAPoR::Grid *grid, const vector<double> &minExts, const vector<double> &maxExts);
87 static int calculateStride(const std::string &varName, VAPoR::DataMgr *dm, const VAPoR::RenderParams *rp);
88 static bool shouldUseSampling(const std::string &varName, VAPoR::DataMgr *dm, const VAPoR::RenderParams *rp);
89 void setProperties(float mnData, float mxData, string var, int ts);
90 void calculateMaxBinSize();
91 void _getDataRange(const std::string &varName, VAPoR::DataMgr *d, VAPoR::RenderParams *r, float *min, float *max) const;
92};
93
94#endif // HISTO_H
Definition: Histo.h:31
int getMaxBinSizeBetweenIndices(const int start, const int end) const
float getRange()
Definition: Histo.h:52
int getTimestepOfUpdate()
Definition: Histo.h:54
int Populate(const std::string &varName, VAPoR::DataMgr *dm, VAPoR::RenderParams *rp)
int getBinIndexForValue(float v)
float getNormalizedBinSizeForValue(float v) const
void addToBin(float val)
float getNormalizedBinSize(int bin) const
string getVarnameOfUpdate()
Definition: Histo.h:55
int getNumBins() const
float getMinMapData()
Definition: Histo.h:50
float getNormalizedBinSizeForNormalizedValue(float v) const
void reset(int newNumBins=-1)
int getBinSize(int index, int stride) const
Histo(int numberBins)
void reset(int newNumBins, float mnData, float mxData)
int PopulateIfNeeded(const std::string &varName, VAPoR::DataMgr *dm, VAPoR::RenderParams *rp)
float getMaxMapData()
Definition: Histo.h:51
bool NeedsUpdate(const std::string &varName, VAPoR::DataMgr *dm, VAPoR::RenderParams *rp)
static vector< float > GetDataSamples(const std::string &varName, VAPoR::DataMgr *dm, VAPoR::RenderParams *rp)
void setBins(const vector< long > &bins)
int getBinSize(int index) const
Histo(int numberBins, float mnData, float mxData, string var, int ts)
int getMaxBinSize()
A cache based data reader.
Definition: DataMgr.h:110
Abstract base class for a 2D or 3D structured or unstructured grid.
Definition: Grid.h:56
A Params subclass for managing parameters used by Renderers.
Definition: RenderParams.h:43
#define RENDER_API
Definition: common.h:78