Skip to content

Commit

Permalink
Merge branch 'develop' into feature-IO-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
smavros authored Nov 11, 2017
2 parents 9f8137a + ac833ef commit f16d8d0
Show file tree
Hide file tree
Showing 48 changed files with 1,254 additions and 519 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Directories ###
build/*
_build/*
output/*
output_llg/*
output_gneb/*
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ control of parameters.
* Modular backends including **parallelisation on GPU** (CUDA) and **CPU** (OpenMP)

### *Documentation*
More details may be found in the [Reference section](docs/README.md) including
More details may be found at [spirit-docs.readthedocs.io](http://spirit-docs.readthedocs.io)
or in the [Reference section](docs/README.md) including
* [Framework build instructions](docs/BUILD.md)
* [Core build instructions](core/docs/BUILD.md)
* [Core API Reference](core/docs/API.md)
Expand Down
6 changes: 6 additions & 0 deletions VFRendering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ set(SOURCE_FILES
src/CoordinateSystemRenderer.cxx
src/FPSCounter.cxx
src/Geometry.cxx
src/GlyphRenderer.cxx
src/IsosurfaceRenderer.cxx
src/Options.cxx
src/RendererBase.cxx
src/SurfaceRenderer.cxx
src/Utilities.cxx
src/VectorField.cxx
src/VectorFieldRenderer.cxx
src/VectorfieldIsosurface.cxx
src/VectorSphereRenderer.cxx
src/View.cxx
Expand All @@ -60,11 +63,14 @@ set(HEADER_FILES
include/VFRendering/CoordinateSystemRenderer.hxx
include/VFRendering/FPSCounter.hxx
include/VFRendering/Geometry.hxx
include/VFRendering/GlyphRenderer.hxx
include/VFRendering/IsosurfaceRenderer.hxx
include/VFRendering/Options.hxx
include/VFRendering/RendererBase.hxx
include/VFRendering/SurfaceRenderer.hxx
include/VFRendering/Utilities.hxx
include/VFRendering/VectorField.hxx
include/VFRendering/VectorFieldRenderer.hxx
include/VFRendering/VectorSphereRenderer.hxx
include/VFRendering/View.hxx
include/shaders
Expand Down
24 changes: 3 additions & 21 deletions VFRendering/include/VFRendering/ArrowRenderer.hxx
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef VFRENDERING_ARROW_RENDERER_HXX
#define VFRENDERING_ARROW_RENDERER_HXX

#include <VFRendering/RendererBase.hxx>
#include <VFRendering/GlyphRenderer.hxx>

namespace VFRendering {
class ArrowRenderer : public RendererBase {
class ArrowRenderer : public GlyphRenderer {
public:
enum Option {
CONE_RADIUS = 200,
Expand All @@ -14,26 +14,8 @@ public:
LEVEL_OF_DETAIL
};

ArrowRenderer(const View& view);
virtual ~ArrowRenderer();
virtual void update(bool keep_geometry) override;
virtual void draw(float aspect_ratio) override;
ArrowRenderer(const View& view, const VectorField& vf);
virtual void optionsHaveChanged(const std::vector<int>& changed_options) override;

private:
void updateShaderProgram();
void updateVertexData();
void initialize();

bool m_is_initialized = false;
unsigned int m_program = 0;
unsigned int m_vao = 0;
unsigned int m_vbo = 0;
unsigned int m_ibo = 0;
unsigned int m_instance_position_vbo = 0;
unsigned int m_instance_direction_vbo = 0;
unsigned int m_num_indices = 0;
unsigned int m_num_instances = 0;
};

namespace Utilities {
Expand Down
38 changes: 38 additions & 0 deletions VFRendering/include/VFRendering/GlyphRenderer.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef VFRENDERING_GLYPH_RENDERER_HXX
#define VFRENDERING_GLYPH_RENDERER_HXX

#include <VFRendering/VectorFieldRenderer.hxx>

namespace VFRendering {
class GlyphRenderer : public VectorFieldRenderer {
public:

GlyphRenderer(const View& view, const VectorField& vf);
virtual ~GlyphRenderer();
virtual void update(bool keep_geometry) override;
virtual void draw(float aspect_ratio) override;
virtual void optionsHaveChanged(const std::vector<int>& changed_options) override;
void setGlyph(const std::vector<glm::vec3>& positions, const std::vector<glm::vec3>& normals, const std::vector<std::uint16_t>& indices);

private:
void updateShaderProgram();
void updateVertexData();
void initialize();

bool m_is_initialized = false;
std::vector<glm::vec3> m_positions;
std::vector<glm::vec3> m_normals;
std::vector<std::uint16_t> m_indices;
unsigned int m_program = 0;
unsigned int m_vao = 0;
unsigned int m_position_vbo = 0;
unsigned int m_normal_vbo = 0;
unsigned int m_ibo = 0;
unsigned int m_instance_position_vbo = 0;
unsigned int m_instance_direction_vbo = 0;
unsigned int m_num_indices = 0;
unsigned int m_num_instances = 0;
};
}

#endif
6 changes: 3 additions & 3 deletions VFRendering/include/VFRendering/IsosurfaceRenderer.hxx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

#include <functional>

#include <VFRendering/RendererBase.hxx>
#include <VFRendering/VectorFieldRenderer.hxx>

namespace VFRendering {
class IsosurfaceRenderer : public RendererBase {
class IsosurfaceRenderer : public VectorFieldRenderer {
public:

typedef float isovalue_type;
Expand All @@ -19,7 +19,7 @@ public:
FLIP_NORMALS
};

IsosurfaceRenderer(const View& view);
IsosurfaceRenderer(const View& view, const VectorField& vf);
virtual ~IsosurfaceRenderer();
virtual void draw(float aspect_ratio) override;
virtual void optionsHaveChanged(const std::vector<int>& changed_options) override;
Expand Down
8 changes: 1 addition & 7 deletions VFRendering/include/VFRendering/RendererBase.hxx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include <glm/glm.hpp>

#include <VFRendering/Options.hxx>
#include <VFRendering/View.hxx>
#include <VFRendering/Options.hxx>

namespace VFRendering {
class RendererBase {
Expand All @@ -25,17 +25,11 @@ public:

protected:
const Options& options() const;
const std::vector<glm::vec3>& positions() const;
const std::vector<glm::vec3>& directions() const;
const std::vector<std::array<Geometry::index_type, 3>>& surfaceIndices() const;
const std::vector<std::array<Geometry::index_type, 4>>& volumeIndices() const;
virtual void options(const Options& options);

private:
const View& m_view;
Options m_options;
unsigned long m_geometry_update_id = 0;
unsigned long m_vectors_update_id = 0;
};

template<int index>
Expand Down
32 changes: 32 additions & 0 deletions VFRendering/include/VFRendering/SphereRenderer.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef VFRENDERING_SPHERE_RENDERER_HXX
#define VFRENDERING_SPHERE_RENDERER_HXX

#include <VFRendering/GlyphRenderer.hxx>

namespace VFRendering {
class SphereRenderer : public GlyphRenderer {
public:
enum Option {
SPHERE_RADIUS = 800,
LEVEL_OF_DETAIL
};

SphereRenderer(const View& view, const VectorField& vf);
virtual void optionsHaveChanged(const std::vector<int>& changed_options) override;
};

namespace Utilities {
template<>
struct Options::Option<SphereRenderer::Option::SPHERE_RADIUS> {
float default_value = 0.2f;
};


template<>
struct Options::Option<SphereRenderer::Option::LEVEL_OF_DETAIL> {
unsigned int default_value = 2;
};
}
}

#endif
6 changes: 3 additions & 3 deletions VFRendering/include/VFRendering/SurfaceRenderer.hxx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include <array>

#include <VFRendering/RendererBase.hxx>
#include <VFRendering/VectorFieldRenderer.hxx>

namespace VFRendering {

class SurfaceRenderer : public RendererBase {
class SurfaceRenderer : public VectorFieldRenderer {
public:
SurfaceRenderer(const View& view);
SurfaceRenderer(const View& view, const VectorField& vf);
virtual ~SurfaceRenderer();
virtual void draw(float aspect_ratio) override;
virtual void optionsHaveChanged(const std::vector<int>& changed_options) override;
Expand Down
2 changes: 1 addition & 1 deletion VFRendering/include/VFRendering/Utilities.hxx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public:

unsigned int createProgram(const std::string& vertex_shader_source,
const std::string& fragment_shader_source,
const std::vector<std::string>& attributes) throw(OpenGLException);
const std::vector<std::string>& attributes);

enum class Colormap {
DEFAULT,
Expand Down
43 changes: 43 additions & 0 deletions VFRendering/include/VFRendering/VectorField.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef VFRENDERING_VECTORFIELD_HXX
#define VFRENDERING_VECTORFIELD_HXX

#include <array>
#include <memory>

#include <glm/glm.hpp>

#include <VFRendering/Options.hxx>
#include <VFRendering/FPSCounter.hxx>
#include <VFRendering/Utilities.hxx>
#include <VFRendering/Geometry.hxx>

namespace VFRendering {

class VectorField {
public:

VectorField(const Geometry& geometry, const std::vector<glm::vec3>& vectors);
virtual ~VectorField();

void update(const Geometry& geometry, const std::vector<glm::vec3>& vectors);
void updateGeometry(const Geometry& geometry);
void updateVectors(const std::vector<glm::vec3>& vectors);

const std::vector<glm::vec3>& positions() const;
const std::vector<glm::vec3>& directions() const;
const std::vector<std::array<Geometry::index_type, 3>>& surfaceIndices() const;
const std::vector<std::array<Geometry::index_type, 4>>& volumeIndices() const;

unsigned long geometryUpdateId() const;
unsigned long vectorsUpdateId() const;

private:
Geometry m_geometry;
std::vector<glm::vec3> m_vectors;
unsigned long m_geometry_update_id = 0;
unsigned long m_vectors_update_id = 0;
};

}

#endif
35 changes: 35 additions & 0 deletions VFRendering/include/VFRendering/VectorFieldRenderer.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef VFRENDERING_VECTORFIELD_RENDERER_HXX
#define VFRENDERING_VECTORFIELD_RENDERER_HXX

#include <vector>

#include <glm/glm.hpp>

#include <VFRendering/View.hxx>
#include <VFRendering/VectorField.hxx>
#include <VFRendering/RendererBase.hxx>

namespace VFRendering {
class VectorFieldRenderer : public RendererBase {
public:

VectorFieldRenderer(const View& view, const VectorField& vf);

virtual ~VectorFieldRenderer() {};
virtual void updateIfNecessary();

protected:
const std::vector<glm::vec3>& positions() const;
const std::vector<glm::vec3>& directions() const;
const std::vector<std::array<Geometry::index_type, 3>>& surfaceIndices() const;
const std::vector<std::array<Geometry::index_type, 4>>& volumeIndices() const;

private:
const VectorField& m_vf;
unsigned long m_geometry_update_id = 0;
unsigned long m_vectors_update_id = 0;
};

}

#endif
6 changes: 3 additions & 3 deletions VFRendering/include/VFRendering/VectorSphereRenderer.hxx
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#ifndef VFRENDERING_VECTOR_SPHERE_RENDERER_HXX
#define VFRENDERING_VECTOR_SPHERE_RENDERER_HXX

#include <VFRendering/RendererBase.hxx>
#include <VFRendering/VectorFieldRenderer.hxx>

namespace VFRendering {

class VectorSphereRenderer : public RendererBase {
class VectorSphereRenderer : public VectorFieldRenderer {
public:
enum Option {
POINT_SIZE_RANGE = 400,
INNER_SPHERE_RADIUS,
USE_SPHERE_FAKE_PERSPECTIVE
};

VectorSphereRenderer(const View& view);
VectorSphereRenderer(const View& view, const VectorField& vf);
virtual ~VectorSphereRenderer();
virtual void draw(float aspect_ratio) override;
virtual void optionsHaveChanged(const std::vector<int>& changed_options) override;
Expand Down
24 changes: 8 additions & 16 deletions VFRendering/include/VFRendering/View.hxx
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public:
CAMERA_POSITION,
CENTER_POSITION,
UP_VECTOR,
LIGHT_POSITION
LIGHT_POSITION,
CLEAR
};

View();
Expand All @@ -49,33 +50,18 @@ public:
void options(const Options& options);
const Options& options() const;

void update(const Geometry& geometry, const std::vector<glm::vec3>& vectors);
void updateVectors(const std::vector<glm::vec3>& vectors);

const std::vector<glm::vec3>& positions() const;
const std::vector<glm::vec3>& directions() const;
const std::vector<std::array<Geometry::index_type, 3>>& surfaceIndices() const;
const std::vector<std::array<Geometry::index_type, 4>>& volumeIndices() const;

void renderers(const std::vector<std::pair<std::shared_ptr<RendererBase>, std::array<float, 4>>>& renderers);

unsigned long geometryUpdateId() const;
unsigned long vectorsUpdateId() const;

private:
void setCamera(glm::vec3 camera_position, glm::vec3 center_position, glm::vec3 up_vector);
void optionsHaveChanged(const std::vector<int>& changed_options);
void initialize();

bool m_is_initialized = false;
Geometry m_geometry;
std::vector<glm::vec3> m_vectors;
std::vector<std::pair<std::shared_ptr<RendererBase>, std::array<float, 4>>> m_renderers;
Utilities::FPSCounter m_fps_counter;
glm::vec2 m_framebuffer_size;
bool m_is_centered = false;
unsigned long m_geometry_update_id = 0;
unsigned long m_vectors_update_id = 0;

Options m_options;
};
Expand Down Expand Up @@ -139,6 +125,12 @@ template<>
struct Options::Option<View::Option::LIGHT_POSITION> {
glm::vec3 default_value = {0, 0, 1000};
};

/** Option to set whether or not the background needs to be cleared. */
template<>
struct Options::Option<View::Option::CLEAR> {
bool default_value = true;
};
}
}

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f16d8d0

Please sign in to comment.