VolViz
A volume visualization tool
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Classes | Public Types | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
VolViz::Private_::VisualizerImpl Class Reference

#include <VisualizerImpl.h>

+ Collaboration diagram for VolViz::Private_::VisualizerImpl:

Classes

struct  DepthRange
 
struct  SelectionBuffer
 Pixel buffers used for mouse picking. More...
 
struct  SingleVertData
 
struct  TextureWrapper
 Auxiliary textures use in the deferred shading process. More...
 

Public Types

using Point2 = Eigen::Vector2f
 
using Size2 = Eigen::Vector2f
 
using Lights = std::unordered_map< Visualizer::LightName, Light >
 

Public Member Functions

 VisualizerImpl (Visualizer *vis)
 
void start ()
 
void enableMultithreading () noexcept
 
void renderOneFrame (bool block=true)
 
 operator bool () const noexcept
 
void setVolume (VolumeDescriptor descriptor, span< float const > data)
 
void setVolume (VolumeDescriptor descriptor, span< Color const > data)
 
Size3f volumeSize () const noexcept
 
template<class Descriptor , typename = std::enable_if_t<std::is_base_of< GeometryDescriptor, std::decay_t<Descriptor>>::value>>
void addGeometry (Visualizer::GeometryName name, Descriptor const &descriptor)
 
template<class Descriptor , typename = std::enable_if_t<std::is_base_of< GeometryDescriptor, std::decay_t<Descriptor>>::value>>
bool updateGeometry (Visualizer::GeometryName name, Descriptor &&descriptor)
 
Camera const & camera () const noexcept
 Convenience method for easy camera access. More...
 
Cameracamera () noexcept
 
auto cameraClient () const noexcept
 
Shadersshaders () noexcept
 
void attachVolumeToShader (GL::ShaderProgram &shader) const
 
void drawSingleVertex () const noexcept
 
void bindVolume (GLuint unitIdx=0) const noexcept
 Bind the volume texture to texture unit i. More...
 
Eigen::Matrix4f textureTransformationMatrix () const noexcept
 

Public Attributes

AtomicCache< LengthcachedScale
 
AtomicCache< ColorcachedBackgroundColor
 

Private Types

enum  TextureID : std::size_t {
  TextureID::NormalsAndSpecular = 0, TextureID::Albedo = 1, TextureID::Depth = 2, TextureID::RenderedImage = 3,
  TextureID::FinalDepth = 4, TextureID::VolumeTexture = 5, TextureID::SelectionTexture = 6
}
 IDs for the auxiliary textures used for the deferred rendering. More...
 
enum  ViewState { ViewState::Scene3D, ViewState::LightingComponents, ViewState::SelectionIndices }
 
enum  MoveState { MoveState::None, MoveState::Rotating, MoveState::Dragging }
 
using InitQueueEntry = std::pair< Visualizer::GeometryName, Geometry::UniquePtr >
 
using GeometryList = std::unordered_map< Visualizer::GeometryName, Geometry::UniquePtr >
 
using GeometryInitQueue = moodycamel::ConcurrentQueue< InitQueueEntry >
 
using Clock = std::chrono::steady_clock
 
using TimePoint = std::chrono::time_point< Clock >
 
using GeometryNameAndPosition = struct{Visualizer::GeometryName name
 

Private Member Functions

void setupFBOs ()
 Setup the required textures and frabebuffer objects for rendering. More...
 
void setupSelectionBuffers ()
 Setup selection buffers. More...
 
Position unproject (Position2 const &screenPoint, float depth) const noexcept
 
void handleKeyInput (int key, int scancode, int action, int mode)
 Key input handler. More...
 
void renderGeometry ()
 Renders the geometry. More...
 
void updateGeometries ()
 Update the geometry. More...
 
void renderGrid ()
 Renders a grid. More...
 
void renderPoint (Position const &position, Color const &color, float size)
 Renders a point. More...
 
void renderQuad (Point2 const &topLeft, Size2 const &size, TextureID texture, GL::ShaderProgram &prog)
 Renderes a textured quad. More...
 
void renderFullscreenQuad (TextureID texture, GL::ShaderProgram &quad)
 Renders a textured fullscreen quad. More...
 
void renderLightingTextures ()
 Renders all textures of the deferred lighting pass. More...
 
void renderLights ()
 Defferred shading lighing pass. More...
 
void renderAmbientLighting ()
 
void renderDiffuseLighting ()
 
void renderSpecularLighting ()
 
void renderLightDiffuse (Light const &light)
 
void renderLightSpecular (Light const &light)
 
void renderSelectionIndexTexture ()
 
GeometryNameAndPosition getGeometryUnderCursor ()
 
void dragSelectedGeometry ()
 
void renderFinalPass ()
 Renders the final image to screen. More...
 
void renderBoundingBox (Position const &position, Orientation const &orientation, Size3f const &size, Color const &color)
 Renders a bounding box. More...
 
void renderVolumeBBox ()
 
void addLight (Visualizer::LightName name, Light const &light)
 

Private Attributes

Position position
 
float depth
 
Visualizervisualizer_ = nullptr
 
GeometryFactory geomFactory_
 
struct
VolViz::Private_::VisualizerImpl::DepthRange 
depthRange_
 
GL::GLFW glfw_
 
Shaders shaders_
 Shader programs. More...
 
struct
VolViz::Private_::VisualizerImpl::TextureWrapper 
textures_
 
GL::Framebuffer finalFbo_ {0}
 Frabebuffer used for the deferred shading. More...
 
GL::Framebuffer lightingFbo_ {0}
 
struct
VolViz::Private_::VisualizerImpl::SelectionBuffer 
selectionBuffer_
 
GeometryList geometries_
 
std::mutex geometriesMutex_
 
GeometryInitQueue geometryInitQueue_
 
struct
VolViz::Private_::VisualizerImpl::SingleVertData 
singleVertexData_
 
enum
VolViz::Private_::VisualizerImpl::ViewState 
Scene3D
 
bool inSelectionMode {false}
 
Visualizer::GeometryName selectedGeometry_
 
Position selectedPoint_ {Position::Zero()}
 
Lights lights_
 Lights. More...
 
std::mutex lightMutex_
 
enum
VolViz::Private_::VisualizerImpl::MoveState 
moveState_ = MoveState::None
 
Position2 lastMousePos_ = Position2::Zero()
 Last position of the mouse cursor, used in the camera control code. More...
 
Position2 lastMouseDelta_ = Position2::Zero()
 
VolumeDescriptor currentVolume_
 
bool multithreadingEnabled_ {false}
 

Friends

class ::VolViz::Visualizer
 

Member Typedef Documentation

using VolViz::Private_::VisualizerImpl::Clock = std::chrono::steady_clock
private
using VolViz::Private_::VisualizerImpl::GeometryInitQueue = moodycamel::ConcurrentQueue<InitQueueEntry>
private
using VolViz::Private_::VisualizerImpl::Size2 = Eigen::Vector2f
using VolViz::Private_::VisualizerImpl::TimePoint = std::chrono::time_point<Clock>
private

Member Enumeration Documentation

enum VolViz::Private_::VisualizerImpl::TextureID : std::size_t
strongprivate

IDs for the auxiliary textures used for the deferred rendering.

Enumerator
NormalsAndSpecular 
Albedo 
Depth 
RenderedImage 
FinalDepth 
VolumeTexture 
SelectionTexture 

Constructor & Destructor Documentation

VolViz::Private_::VisualizerImpl::VisualizerImpl ( Visualizer vis)

Member Function Documentation

template<class Descriptor , typename = std::enable_if_t<std::is_base_of< GeometryDescriptor, std::decay_t<Descriptor>>::value>>
void VolViz::Private_::VisualizerImpl::addGeometry ( Visualizer::GeometryName  name,
Descriptor const &  descriptor 
)
inline
void VolViz::Private_::VisualizerImpl::addLight ( Visualizer::LightName  name,
Light const &  light 
)
private
void VolViz::Private_::VisualizerImpl::attachVolumeToShader ( GL::ShaderProgram shader) const
void VolViz::Private_::VisualizerImpl::bindVolume ( GLuint  unitIdx = 0) const
noexcept

Bind the volume texture to texture unit i.

Camera const& VolViz::Private_::VisualizerImpl::camera ( ) const
inlinenoexcept

Convenience method for easy camera access.

Camera& VolViz::Private_::VisualizerImpl::camera ( )
inlinenoexcept
auto VolViz::Private_::VisualizerImpl::cameraClient ( ) const
inlinenoexcept
void VolViz::Private_::VisualizerImpl::dragSelectedGeometry ( )
private
void VolViz::Private_::VisualizerImpl::drawSingleVertex ( ) const
noexcept

Issues an OpenGL draw call with a single vertex. This comes in handy if all the geometry is created by a geometry shader

void VolViz::Private_::VisualizerImpl::enableMultithreading ( )
noexcept
VisualizerImpl::GeometryNameAndPosition VolViz::Private_::VisualizerImpl::getGeometryUnderCursor ( )
private
void VolViz::Private_::VisualizerImpl::handleKeyInput ( int  key,
int  scancode,
int  action,
int  mode 
)
private

Key input handler.

VolViz::Private_::VisualizerImpl::operator bool ( ) const
noexcept
void VolViz::Private_::VisualizerImpl::renderAmbientLighting ( )
private
void VolViz::Private_::VisualizerImpl::renderBoundingBox ( Position const &  position,
Orientation const &  orientation,
Size3f const &  size,
Color const &  color 
)
private

Renders a bounding box.

void VolViz::Private_::VisualizerImpl::renderDiffuseLighting ( )
private
void VolViz::Private_::VisualizerImpl::renderFinalPass ( )
private

Renders the final image to screen.

void VolViz::Private_::VisualizerImpl::renderFullscreenQuad ( TextureID  texture,
GL::ShaderProgram quad 
)
private

Renders a textured fullscreen quad.

void VolViz::Private_::VisualizerImpl::renderGeometry ( )
private

Renders the geometry.

void VolViz::Private_::VisualizerImpl::renderGrid ( )
private

Renders a grid.

void VolViz::Private_::VisualizerImpl::renderLightDiffuse ( Light const &  light)
private
void VolViz::Private_::VisualizerImpl::renderLightingTextures ( )
private

Renders all textures of the deferred lighting pass.

void VolViz::Private_::VisualizerImpl::renderLights ( )
private

Defferred shading lighing pass.

void VolViz::Private_::VisualizerImpl::renderLightSpecular ( Light const &  light)
private
void VolViz::Private_::VisualizerImpl::renderOneFrame ( bool  block = true)
void VolViz::Private_::VisualizerImpl::renderPoint ( Position const &  position,
Color const &  color,
float  size 
)
private

Renders a point.

void VolViz::Private_::VisualizerImpl::renderQuad ( Point2 const &  topLeft,
Size2 const &  size,
TextureID  texture,
GL::ShaderProgram prog 
)
private

Renderes a textured quad.

void VolViz::Private_::VisualizerImpl::renderSelectionIndexTexture ( )
private
void VolViz::Private_::VisualizerImpl::renderSpecularLighting ( )
private
void VolViz::Private_::VisualizerImpl::renderVolumeBBox ( )
private
void VolViz::Private_::VisualizerImpl::setupFBOs ( )
private

Setup the required textures and frabebuffer objects for rendering.

void VolViz::Private_::VisualizerImpl::setupSelectionBuffers ( )
private

Setup selection buffers.

void VolViz::Private_::VisualizerImpl::setVolume ( VolumeDescriptor  descriptor,
span< float const >  data 
)
void VolViz::Private_::VisualizerImpl::setVolume ( VolumeDescriptor  descriptor,
span< Color const >  data 
)
Shaders& VolViz::Private_::VisualizerImpl::shaders ( )
inlinenoexcept
void VolViz::Private_::VisualizerImpl::start ( )
Eigen::Matrix4f VolViz::Private_::VisualizerImpl::textureTransformationMatrix ( ) const
noexcept

Returns a matrix that transforms world coordinates into texture coordinates

Position VolViz::Private_::VisualizerImpl::unproject ( Position2 const &  screenPoint,
float  depth 
) const
privatenoexcept

Unprojects a point in screen coordinates and a given depth to a 3D point in world space

void VolViz::Private_::VisualizerImpl::updateGeometries ( )
private

Update the geometry.

template<class Descriptor , typename = std::enable_if_t<std::is_base_of< GeometryDescriptor, std::decay_t<Descriptor>>::value>>
bool VolViz::Private_::VisualizerImpl::updateGeometry ( Visualizer::GeometryName  name,
Descriptor &&  descriptor 
)
inline
Size3f VolViz::Private_::VisualizerImpl::volumeSize ( ) const
noexcept

Friends And Related Function Documentation

friend class ::VolViz::Visualizer
friend

Member Data Documentation

AtomicCache<Color> VolViz::Private_::VisualizerImpl::cachedBackgroundColor
Initial value:
{
[this]() -> Color { return visualizer_->backgroundColor; }}

Visualizer's background color is cached here, since it is accessed at least once per frame and is usually cahnged very rare. Since every access to Visualizer's backgroundColor property requires thread synchronization, a cache is necessary here.

AtomicCache<Length> VolViz::Private_::VisualizerImpl::cachedScale
Initial value:
{
[this]() -> Length { return visualizer_->scale; }}

Visualizer's scale is cached here, since it is accessed at least once per frame and is usually cahnged very rare. Since every access to Visualizer's scale property requires thread synchronization, a cache is necessary here.

float VolViz::Private_::VisualizerImpl::depth
private
Position VolViz::Private_::VisualizerImpl::position
private

The documentation for this class was generated from the following files: