VAPOR3 3.9.4
VolumeAlgorithm.h
Go to the documentation of this file.
1#pragma once
2
3#include <vapor/Grid.h>
5#include <vector>
6#include <map>
7#include <string>
9
10namespace VAPoR {
11
12struct GLManager;
13class VolumeAlgorithmFactory;
14class VolumeRenderer;
15class VolumeParams;
16class ViewpointParams;
17class AnnotationParams;
18class Transform;
19
29
31public:
32 enum class Type { Any, DVR, Iso };
33
35 virtual ~VolumeAlgorithm() {}
36 virtual void SaveDepthBuffer(bool fast){};
37 virtual int Render(bool fast) = 0;
38 virtual int LoadData(const Grid *grid) = 0;
39 virtual int LoadSecondaryData(const Grid *grid) = 0;
40 virtual void DeleteSecondaryData() = 0;
41 virtual void GetFinalBlendingMode(int *src, int *dst) = 0;
42
47 virtual bool RequiresChunkedRendering() = 0;
48 virtual float GuestimateFastModeSpeedupFactor() const { return 1; }
49 virtual int CheckHardwareSupport(const Grid *grid) const { return 0; }
50
51 static VolumeAlgorithm *NewAlgorithm(const std::string &name, GLManager *gl, VolumeRenderer *renderer);
52
54
55protected:
57
62 void GetExtents(glm::vec3 *dataMin, glm::vec3 *dataMax, glm::vec3 *userMin, glm::vec3 *userMax) const;
63
64private:
65 static std::map<std::string, VolumeAlgorithmFactory *> factories;
66 VolumeRenderer * _renderer;
67};
68
70public:
72 static std::string GetName() { return "NULL"; }
73 static Type GetType() { return Type::Any; }
74 int Render(bool fast) { return 0; }
75 int LoadData(const Grid *grid) { return 0; }
76 int LoadSecondaryData(const Grid *grid) { return 0; }
78 bool RequiresChunkedRendering() { return false; }
79 void GetFinalBlendingMode(int *src, int *dst) {}
80};
81
83public:
84 std::string name;
86 virtual VolumeAlgorithm *Create(GLManager *gl, VolumeRenderer *renderer) = 0;
87};
88
89template<class T> class VolumeAlgorithmRegistrar : public VolumeAlgorithmFactory {
90public:
92 {
93 static_assert(std::is_base_of<VolumeAlgorithm, T>::value, "Register is not derived from VolumeAlgorithm");
94 name = T::GetName();
95 type = T::GetType();
97 }
98 VolumeAlgorithm *Create(GLManager *gl, VolumeRenderer *renderer) { return new T(gl, renderer); }
99};
100
101} // namespace VAPoR
A class for describing visual features displayed in the visualizer.
Abstract base class for a 2D or 3D structured or unstructured grid.
Definition: Grid.h:56
Mixin class that prevents copying.
class that indicates location and direction of view
Definition: Transform.h:22
A class for describing the viewpoint and lights in a 3D VAPOR scene.
virtual VolumeAlgorithm * Create(GLManager *gl, VolumeRenderer *renderer)=0
VolumeAlgorithm::Type type
static std::string GetName()
int LoadSecondaryData(const Grid *grid)
int LoadData(const Grid *grid)
void GetFinalBlendingMode(int *src, int *dst)
VolumeAlgorithmNull(GLManager *gl, VolumeRenderer *renderer)
VolumeAlgorithm * Create(GLManager *gl, VolumeRenderer *renderer)
Strategy pattern for volume rendering algorithms.
void GetExtents(glm::vec3 *dataMin, glm::vec3 *dataMax, glm::vec3 *userMin, glm::vec3 *userMax) const
virtual void SaveDepthBuffer(bool fast)
static void Register(VolumeAlgorithmFactory *f)
virtual bool RequiresChunkedRendering()=0
virtual int LoadData(const Grid *grid)=0
AnnotationParams * GetAnnotationParams() const
virtual int CheckHardwareSupport(const Grid *grid) const
VolumeAlgorithm(GLManager *gl, VolumeRenderer *renderer)
virtual float GuestimateFastModeSpeedupFactor() const
virtual void DeleteSecondaryData()=0
static VolumeAlgorithm * NewAlgorithm(const std::string &name, GLManager *gl, VolumeRenderer *renderer)
virtual void GetFinalBlendingMode(int *src, int *dst)=0
VolumeParams * GetParams() const
virtual int LoadSecondaryData(const Grid *grid)=0
Transform * GetDatasetTransform() const
ViewpointParams * GetViewpointParams() const
virtual int Render(bool fast)=0
Contains references to context scope OpenGL data.
Definition: GLManager.h:18