libVFRendering  0.14.0

A vector field rendering library
BoundingBoxRenderer.hxx
1 #ifndef VFRENDERING_BOUNDING_BOX_RENDERER_HXX
2 #define VFRENDERING_BOUNDING_BOX_RENDERER_HXX
3 
4 #include <VFRendering/RendererBase.hxx>
5 
6 namespace VFRendering {
8 public:
9  enum Option {
10  COLOR = 600,
11  LEVEL_OF_DETAIL,
12  LINE_WIDTH
13  };
14 
15 
16  BoundingBoxRenderer(const View& view, const std::vector<glm::vec3>& vertices, const std::vector<float>& dashing_values={});
17  static BoundingBoxRenderer forCuboid(const View& view, const glm::vec3& center, const glm::vec3& side_lengths, const glm::vec3& periodic_boundary_condition_lengths={0.0f, 0.0f, 0.0f}, float dashes_per_length=1.0f);
18  static BoundingBoxRenderer forParallelepiped(const View& view, const glm::vec3& center, const glm::vec3& v1, const glm::vec3& v2, const glm::vec3& v3, const glm::vec3& periodic_boundary_condition_lengths={0.0f, 0.0f, 0.0f}, float dashes_per_length=1.0f);
19  static BoundingBoxRenderer forHexagonalCell(const View& view, const glm::vec3& center, float radius, float height, const glm::vec2& periodic_boundary_condition_lengths={0.0f, 0.0f}, float dashes_per_length=1.0f);
20  virtual ~BoundingBoxRenderer();
21  virtual void draw(float aspect_ratio) override;
22  virtual void optionsHaveChanged(const std::vector<int>& changed_options) override;
23 
24 protected:
25  virtual void update(bool keep_geometry) override;
26  void updateVertexData();
27 
28 private:
29  void initialize();
30 
31  bool m_is_initialized = false;
32  unsigned int m_program = 0;
33  unsigned int m_vao = 0;
34  unsigned int m_vbo = 0;
35  unsigned int m_dash_vbo = 0;
36  unsigned int num_vertices = 0;
37  std::vector<glm::vec3> m_vertices;
38  std::vector<float> m_dashing_values;
39 };
40 
41 namespace Utilities {
42 template<>
43 struct Options::Option<BoundingBoxRenderer::Option::COLOR>{
44  glm::vec3 default_value = {1.0, 1.0, 1.0};
45 };
46 
47 template<>
48 struct Options::Option<BoundingBoxRenderer::Option::LEVEL_OF_DETAIL>{
49  int default_value = 10;
50 };
51 
52 template<>
53 struct Options::Option<BoundingBoxRenderer::Option::LINE_WIDTH>{
54  float default_value = 0.0;
55 };
56 }
57 }
58 
59 #endif
VFRendering::RendererBase
Definition: RendererBase.hxx:12
VFRendering::View
Definition: View.hxx:23
VFRendering::BoundingBoxRenderer
Definition: BoundingBoxRenderer.hxx:7