Developer documentation
Version 3.0.3-105-gd3941f44
halfsphere.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __gui_shapes_halfsphere_h__
18#define __gui_shapes_halfsphere_h__
19
20#include "types.h"
21
22#include "gui/opengl/gl.h"
23#include "gui/opengl/gl_core_3_3.h"
24
25namespace MR
26{
27 namespace GUI
28 {
29 namespace Shapes
30 {
31
32
34 { MEMALIGN(HalfSphere)
35 public:
36 // TODO Initialise sphere & buffers at construction;
37 // currently it doesn't seem to work as a GL context has not yet been
38 // created, so gl::GenBuffers() returns zero
39 HalfSphere () : num_indices (0) { }
40
41 void LOD (const size_t);
42
43 size_t num_indices;
44 GL::VertexBuffer vertex_buffer;
45 GL::IndexBuffer index_buffer;
46
47
48 class Vertex { NOMEMALIGN
49 public:
50 Vertex () { }
51 Vertex (const float x[3]) { p[0] = x[0]; p[1] = x[1]; p[2] = x[2]; }
52 template <class Container>
53 Vertex (const Container& vertices, size_t i1, size_t i2) {
54 p[0] = vertices[i1][0] + vertices[i2][0];
55 p[1] = vertices[i1][1] + vertices[i2][1];
56 p[2] = vertices[i1][2] + vertices[i2][2];
57 Eigen::Map<Eigen::Vector3f> (p).normalize();
58 }
59
60 float& operator[] (const int n) { return p[n]; }
61 float operator[] (const int n) const { return p[n]; }
62
63 private:
64 float p[3];
65
66 };
67
68 vector<Vertex> vertices;
69 };
70
71
72 }
73 }
74}
75
76#endif
77
#define NOMEMALIGN
Definition: memory.h:22
Object< gl::VERTEX_SHADER > Vertex
Definition: shader.h:91
Definition: base.h:24