17#ifndef __gui_mrview_tool_connectome_edge_h__
18#define __gui_mrview_tool_connectome_edge_h__
23#include "connectome/connectome.h"
54 void clear_exemplar() {
if (streamtube)
delete streamtube.release();
if (streamline)
delete streamline.release();
if (exemplar)
delete exemplar.release(); }
56 void create_streamline() { assert (!streamline); assert (exemplar); streamline.reset (
new Streamline (*exemplar)); }
60 void create_streamtube() { assert (!streamtube); assert (exemplar); streamtube.reset (
new Streamtube (*exemplar)); }
67 const Eigen::Vector3f&
get_node_centre (
const size_t i)
const { assert (i==0 || i==1);
return node_centres[i]; }
68 Eigen::Vector3f
get_com()
const {
return (node_centres[0] + node_centres[1]) * 0.5; }
72 const Eigen::Vector3f&
get_dir()
const {
return dir; }
75 void set_colour (
const Eigen::Array3f& i) { colour = i; }
76 const Eigen::Array3f&
get_colour()
const {
return colour; }
81 bool is_diagonal()
const {
return (node_indices[0] == node_indices[1]); }
83 bool to_draw()
const {
return (visible && (alpha > 0.0f) && (size > 0.0f)); }
86 const node_t node_indices[2];
87 const Eigen::Vector3f node_centres[2];
88 const Eigen::Vector3f dir;
93 Eigen::Array3f colour;
105 Line (
const Edge& parent);
107 vertex_buffer (
std::move (that.vertex_buffer)),
108 tangent_buffer (
std::move (that.tangent_buffer)),
109 vertex_array_object (
std::move (that.vertex_array_object)) { }
117 std::unique_ptr<Line> line;
124 Exemplar (Exemplar&& that) :
125 endpoints { that.endpoints[0], that.endpoints[1] },
126 vertices (
std::move (that.vertices)),
127 tangents (
std::move (that.tangents)),
128 normals (
std::move (that.normals)),
129 binormals (
std::move (that.binormals)) { }
130 Exemplar () =
delete;
132 const Eigen::Vector3f endpoints[2];
134 friend class Streamline;
135 friend class Streamtube;
137 std::unique_ptr<Exemplar> exemplar;
143 Streamline (
const Exemplar& exemplar);
144 Streamline (Streamline&& that) :
146 vertex_buffer (
std::move (that.vertex_buffer)),
147 tangent_buffer (
std::move (that.tangent_buffer)),
148 vertex_array_object (
std::move (that.vertex_array_object)) { that.count = 0; }
149 Streamline () =
delete;
155 GL::VertexBuffer vertex_buffer, tangent_buffer;
156 GL::VertexArrayObject vertex_array_object;
158 std::unique_ptr<Streamline> streamline;
164 Streamtube (
const Exemplar&);
165 Streamtube (Streamtube&& that) :
167 vertex_buffer (
std::move (that.vertex_buffer)),
168 tangent_buffer (
std::move (that.tangent_buffer)),
169 normal_buffer (
std::move (that.normal_buffer)),
170 vertex_array_object (
std::move (that.vertex_array_object)) { that.count = 0; }
173 static void LOD (
const size_t lod) { shared.set_LOD (lod); }
176 GL::VertexBuffer vertex_buffer, tangent_buffer, normal_buffer;
177 GL::VertexArrayObject vertex_array_object;
182 Shared() : max_num_points (0), LOD (0), element_counts (nullptr) { }
183 ~Shared() { clear(); }
184 void check_num_points (
const size_t num_points) {
if (num_points > max_num_points) { clear(); max_num_points = num_points; regenerate(); } }
185 void set_LOD (
const size_t v) {
if (LOD != v) { clear(); LOD = v; regenerate(); } }
186 size_t points_per_vertex()
const {
return Math::pow2 (LOD + 1); }
188 size_t max_num_points;
190 GLsizei* element_counts;
191 GLuint** element_indices;
195 friend class Streamtube;
197 static Shared shared;
200 std::unique_ptr<Streamtube> streamtube;
constexpr T pow2(const T &v)