LibCarna Version 3.4.0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
LibCarna::presets::MaskRenderingStage Class Reference

Renders 3D masks. More...

#include <MaskRenderingStage.hpp>

+ Inheritance diagram for LibCarna::presets::MaskRenderingStage:
+ Collaboration diagram for LibCarna::presets::MaskRenderingStage:

Public Member Functions

 MaskRenderingStage (unsigned int geometryType, unsigned int maskRole=DEFAULT_ROLE_MASK)
 Instantiates.
 
virtual ~MaskRenderingStage ()
 Deletes.
 
virtual void reshape (base::FrameRenderer &fr, unsigned int width, unsigned int height) override
 Orders this stage to reshape its buffers according to the specified width and height.
 
virtual void renderPass (const base::math::Matrix4f &viewTransform, base::RenderTask &rt, const base::Viewport &vp) override
 Performs the mask rendering.
 
const base::Colorcolor () const
 Tells the rendering color.
 
void setColor (const base::Color &color)
 Sets the rendering color.
 
bool isFilling () const
 Tells whether filled regions are rendered (instead of borders only).
 
void setFilling (bool filled)
 Sets whether to render filled regions (instead of borders only).
 
- Public Member Functions inherited from LibCarna::presets::VolumeRenderingStage
 VolumeRenderingStage (unsigned int geometryType)
 Instantiates. The created stage will render such base::Geometry scene graph nodes, whose geometry types equal geometryType.
 
virtual ~VolumeRenderingStage ()
 Deletes.
 
void setSampleRate (unsigned int sampleRate)
 Sets number of slices to be rendered per segment.
 
unsigned int sampleRate () const
 Tells number of slices to be rendered per segment.
 
- Public Member Functions inherited from LibCarna::base::GeometryStage< base::Renderable::BackToFront >
 GeometryStage (unsigned int geometryType, unsigned int geometryTypeMask=RenderQueue< base::Renderable::BackToFront >::EXACT_MATCH_GEOMETRY_TYPE_MASK)
 Instantiates s.t. the predefined rendering queue enqueues such LibCarna::base::Geometry scene graph nodes, whose geometry type AND-linked with geometryTypeMask equals the geometryType specified here.
 
virtual ~GeometryStage ()
 Releases acquired video resources.
 
virtual void prepareFrame (Node &root) override
 Called once before each frame.
 
std::size_t renderedPassesCount () const
 Tells the number of passes rendered so far since the beginning of the current frame.
 
GeometryFeatureType::ManagedInterface & videoResource (GeometryFeatureType &geometryFeature) const
 Interfaces the geometryFeature video resources that were acquired by this rendering stage.
 
const GeometryFeatureType::ManagedInterface & videoResource (const GeometryFeatureType &geometryFeature) const
 
- Public Member Functions inherited from LibCarna::base::RenderStage
 RenderStage ()
 Instantiates in enabled-state.
 
virtual ~RenderStage ()
 Deletes.
 
void setViewTransformFixed (bool viewTransformFixed)
 Sets whether the view transform is pass-invariant for the duration of a single frame.
 
bool isViewTransformFixed () const
 Tells whether the view transform is pass-invariant for the duration of a single frame.
 
bool isInitialized () const
 Tells whether this stage is ready for rendering.
 
bool isEnabled () const
 Tells whether this stage is enabled. Disabled stages are not rendered by render tasks.
 
void setEnabled (bool)
 Sets whether this stage is enabled. Disabled stages are not rendered by render tasks.
 
base::FrameRendererrenderer ()
 References the renderer this stage belongs to.
 
const base::FrameRendererrenderer () const
 
void addRenderStageListener (RenderStageListener &listener)
 Adds listener to the set of listeners this instance notifies in \(\mathcal O\left(\log n\right)\).
 
void removeRenderStageListener (RenderStageListener &listener)
 Removes listener from the set of listeners this instance notifies in \(\mathcal O\left(\log n\right)\).
 

Public Attributes

const unsigned int maskRole
 Holds the role that mask volume data is expected to take when attached to base::Geometry nodes.
 
- Public Attributes inherited from LibCarna::base::GeometryStage< base::Renderable::BackToFront >
const unsigned int geometryType
 Renders such geometries whose type AND-linked with geometryTypeMask equals this.
 
const unsigned int geometryTypeMask
 Renders such geometries whose type AND-linked with this equals geometryType.
 

Static Public Attributes

static const base::Color DEFAULT_COLOR
 Holds the default rendering color.
 
static const unsigned int DEFAULT_ROLE_MASK
 Holds the default value of maskRole.
 
static const bool DEFAULT_FILLING
 Holds the default value of isFilling.
 
- Static Public Attributes inherited from LibCarna::presets::VolumeRenderingStage
static const unsigned int DEFAULT_SAMPLE_RATE = 200
 Holds the default number of slices rendered per segment.
 

Protected Member Functions

virtual unsigned int loadVideoResources () override
 Loads video resources when rendering is triggered for the first time. Override this method if you need any additional resources to be loaded, but always call the base implementation.
 
virtual void createVolumeSamplers (const std::function< void(unsigned int, base::Sampler *) > &registerSampler) override
 Creates texture samplers for volume textures and uses registerSampler to assign them to the roles that they should be used with.
 
virtual const base::ShaderProgramacquireShader () override
 Acquires the mask_rendering shader from the base::ShaderManager.
 
virtual const std::string & uniformName (unsigned int role) const override
 Maps maskRole to mask.
 
virtual void configureShader () override
 Sets the border rendering mode and the rendering color.
 
virtual void configureShader (const base::Renderable &) override
 Does nothing.
 
- Protected Member Functions inherited from LibCarna::presets::VolumeRenderingStage
virtual void render (const base::Renderable &) override
 Renders the renderable.
 
- Protected Member Functions inherited from LibCarna::base::GeometryStage< base::Renderable::BackToFront >
void activateGLContext () const
 Ensures that the OpenGL context of the hosting LibCarna::base::FrameRenderer is the current one.
 
virtual void buildRenderQueues (Node &root, const math::Matrix4f &viewTransform)
 Builds the rendering queues of this stage.
 
virtual void rewindRenderQueues ()
 Rewinds the rendering queues of this stage.
 
virtual void updateRenderQueues (const math::Matrix4f &viewTransform)
 Recomputes the model-view transforms of the renderables enqueued by this stage.
 

Additional Inherited Members

- Protected Attributes inherited from LibCarna::base::GeometryStage< base::Renderable::BackToFront >
RenderQueue< base::Renderable::BackToFrontrq
 Holds the predefined rendering queue of this rendering stage.
 

Detailed Description

Renders 3D masks.

The MaskRenderingStage constructor takes a geometry type parameter:

mr = new presets::MaskRenderingStage( GEOMETRY_TYPE_VOLUMETRIC );
void appendStage(RenderStage *stage)
Appends stage to the rendering stages sequence.
base::FrameRenderer & renderer()
References the renderer this stage belongs to.

The concept of geometry types is explained here.

Note
In the rendering process this stage will usually be inserted as the last stage.

A mask can be produced, for example, by threshold a 3D intensity image:

mask.reset( new base::IntensityVolumeUInt8( scene->volume().size ) );
for( std::size_t pos = 0; pos < mask->buffer().size(); ++pos )
{
mask->buffer()[ pos ] = scene->volume().buffer()[ pos ] > 48000 ? 255 : 0;
}
Represents an association.
static BufferedVectorFieldTexture< BufferedVectorFieldType > & create(const BufferedVectorFieldType &field)
Instantiates. Invoke release when it isn't needed any longer.

The mask can then be attached to, for example, an already existing geometry node:

geometry.putFeature( mr->maskRole, maskTexture );
maskTexture.release();

This will render an image similar to this:

exemplary rendering from code above
Author
Leonid Kostrykin

Definition at line 58 of file MaskRenderingStage.hpp.

Constructor & Destructor Documentation

◆ MaskRenderingStage()

LibCarna::presets::MaskRenderingStage::MaskRenderingStage ( unsigned int  geometryType,
unsigned int  maskRole = DEFAULT_ROLE_MASK 
)
explicit

Instantiates.

The created stage will render such base::Geometry scene graph nodes, whose geometry types equal geometryType. The mask data will be obtained from maskRole.

Member Function Documentation

◆ acquireShader()

virtual const base::ShaderProgram & LibCarna::presets::MaskRenderingStage::acquireShader ( )
overrideprotectedvirtual

Acquires the mask_rendering shader from the base::ShaderManager.

Implements LibCarna::presets::VolumeRenderingStage.

◆ configureShader() [1/2]

virtual void LibCarna::presets::MaskRenderingStage::configureShader ( )
overrideprotectedvirtual

Sets the border rendering mode and the rendering color.

Implements LibCarna::presets::VolumeRenderingStage.

◆ configureShader() [2/2]

virtual void LibCarna::presets::MaskRenderingStage::configureShader ( const base::Renderable )
overrideprotectedvirtual

Does nothing.

Implements LibCarna::presets::VolumeRenderingStage.

◆ createVolumeSamplers()

virtual void LibCarna::presets::MaskRenderingStage::createVolumeSamplers ( const std::function< void(unsigned int, base::Sampler *) > &  registerSampler)
overrideprotectedvirtual

Creates texture samplers for volume textures and uses registerSampler to assign them to the roles that they should be used with.

Implements LibCarna::presets::VolumeRenderingStage.

◆ loadVideoResources()

virtual unsigned int LibCarna::presets::MaskRenderingStage::loadVideoResources ( )
overrideprotectedvirtual

Loads video resources when rendering is triggered for the first time. Override this method if you need any additional resources to be loaded, but always call the base implementation.

Returns
the first texture unit to use for volume textures. The dafault implementation returns base::Texture<0>::SETUP_UNIT +1.

Reimplemented from LibCarna::presets::VolumeRenderingStage.

◆ renderPass()

virtual void LibCarna::presets::MaskRenderingStage::renderPass ( const base::math::Matrix4f viewTransform,
base::RenderTask rt,
const base::Viewport vp 
)
overridevirtual

Performs the mask rendering.

Reimplemented from LibCarna::presets::VolumeRenderingStage.

◆ reshape()

virtual void LibCarna::presets::MaskRenderingStage::reshape ( base::FrameRenderer fr,
unsigned int  width,
unsigned int  height 
)
overridevirtual

Orders this stage to reshape its buffers according to the specified width and height.

Attention
Always call the base implementaion!
Parameters
frreferences the frame renderer this stage belongs to.
widthis the root viewport width.
heightis the root viewport height.

Reimplemented from LibCarna::base::RenderStage.

◆ uniformName()

virtual const std::string & LibCarna::presets::MaskRenderingStage::uniformName ( unsigned int  role) const
overrideprotectedvirtual

Member Data Documentation

◆ DEFAULT_COLOR

const base::Color LibCarna::presets::MaskRenderingStage::DEFAULT_COLOR
static

Holds the default rendering color.

Definition at line 66 of file MaskRenderingStage.hpp.

◆ DEFAULT_FILLING

const bool LibCarna::presets::MaskRenderingStage::DEFAULT_FILLING
static

Holds the default value of isFilling.

Definition at line 68 of file MaskRenderingStage.hpp.

◆ DEFAULT_ROLE_MASK

const unsigned int LibCarna::presets::MaskRenderingStage::DEFAULT_ROLE_MASK
static

Holds the default value of maskRole.

Definition at line 67 of file MaskRenderingStage.hpp.

◆ maskRole

const unsigned int LibCarna::presets::MaskRenderingStage::maskRole

Holds the role that mask volume data is expected to take when attached to base::Geometry nodes.

Definition at line 74 of file MaskRenderingStage.hpp.


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