FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Public Member Functions | Public Attributes | List of all members
Wizt::FragmentPainter Struct Referenceabstract

A helper class that supports rendering of a collection of fragments from various fields. More...

#include <FragmentPainter.hpp>

Inheritance diagram for Wizt::FragmentPainter:
Wizt::VertexFieldCollection Wizt::FloatOrigin Wizt::Fish< Fiber::Grid > std::multimap< string, RefPtr< VertexField > > Wizt::VStateCreatorBase Wizt::VertexRenderObject Wizt::SplatRenderObject Wizt::VertexGeometryShader VectorViz::VectorSpeckle Wizt::TensorShaderBase

Public Member Functions

 FragmentPainter (VObject *that, const string &fragmentselectorname="selection", int EL=5)
 Constructor, needs a VObject to initialize the slot driving the fragment selector.
 
virtual string FragmentSelectionField () const
 Return the name of the field that will be responsible for the coordinates of the fields.
 
virtual string GLCacheField (const RefPtr< ValuePool > &Context) const
 The name of the field that will be used for caching opengl VBO's at each of this fragments.
 
virtual RefPtr< ValueSetCacheableVariables (const RefPtr< ValuePool > &Context) const
 Return a set of variables for which the results shall be cached, i.e.
 
virtual string VBOCacheKey (const RefPtr< ValuePool > &Context) const
 A child-class defined arbitrary string used to extend the cache modifier.
 
virtual RefPtr< VBO::RenderercreateRenderer (VGLRenderContext &Context, const RefPtr< MemBase > &FieldCoordinates, const RefPtr< FragmentSelector > &FS) const
 Create a Renderer object for the VBO, which by default is a DrawArrays() renderer that emits points for each vertex.
 
virtual void updateRenderer (VGLRenderContext &Context, const RefPtr< VBO::Renderer > &R, const RefPtr< MemBase > &FieldCoordinates, const RefPtr< FragmentSelector > &FS) const
 Update a renderer object, in case the fragment selector is newer.
 
virtual Ageable YoungestDependency (const RefPtr< ValuePool > &Context, const WeakPtr< Representation > &RefinementRep) const
 Optional child class for specifying dependencies that may have changed and require re-creation of a cached VBO.
 
virtual bool appendOnDemandFragments (VGLRenderContext &Context, const RefPtr< VBO > &myVBO, int RefinementLevel, const WeakPtr< Representation > &RefinementRep, const RefPtr< FragmentID > &fragment_identifier, const Fiber::Fragment &FragmentData, const RefPtr< GLProgram > &Shader) const
 Virtual function to allow derived classes to create data on demand, i.e.
 
virtual void setRendererParameters (VGLRenderContext &Context, const RefPtr< VBO::Renderer > &theRenderer, const RefPtr< CreativeArrayBase > &VertexCoordinates, const RefPtr< GLProgram > &theShaderProgram) const =0
 Given a Renderer, which usually is has been created by the createRenderer() virtual function, modify its parameters, depending on the context.
 
virtual bool FunctorsAreOlderThan (const Ageable &A, const RefPtr< ValuePool > &Context) const
 
virtual void updateFromFunctorsAge (Ageable &A, const RefPtr< ValuePool > &Context) const
 
void renderFragments (Fiber::FragmentCluster &FC, VGLRenderContext &Context, VGLRenderObject::UsedVBO_t &UsedVBO, const RefPtr< GLProgram > &myProgram) const
 Render all the field fragments that are stored and available here.
 
- Public Member Functions inherited from Wizt::VertexFieldCollection
 VertexFieldCollection (VObject *that)
 Construct a collection of fields on the vertices of a Grid.
 
 ~VertexFieldCollection ()
 Destructor.
 
TypedSlot< Fiber::Field > & insertVertexField (const string &s, const RefPtr< VertexField > &)
 Add a vertex field under the given name.
 
RefPtr< VertexField > & operator[] (const string &s)
 Retrieve a VertexField for the given name, create one, if required.
 
RefPtr< VertexFieldoperator() (const string &s) const
 Search for a VertexField under the given name.
 
Fiber::Info< Fiber::SkeletongetRefinementLevel (int Level, const RefPtr< ValuePool > &VP, int IndexDepth=0, const Fiber::BundlePtr &SpaceTime=Fiber::BundlePtr(NullPtr())) const override
 Implementation of the virtual callback function that will load data sets from a grid into a collection of VertexFields, as specified earlier.
 
virtual GridSelector myGridSelector (const RefPtr< ValuePool > &VP) const
 Virtual function that allows child classes to specify the Grid that shall be used.
 
GridSelector getGridSelector (const RefPtr< ValuePool > &VP) const override
 Get the Grid that will be used here.
 
void retrieveFields (Fiber::FieldCollection &FieldMap, const RefPtr< Fiber::Representation > &MyRepresentation, const RefPtr< ValuePool > &Context, const RefPtr< Fiber::Skeleton > &DestVertices, Fiber::Grid &DestGrid, Fiber::Slice &DestGridSlice, const string &HelperDestGridName, bool StoreResult=true)
 From the given Representation, retrieve all fields as required here into the provided Fieldmap.
 
int append (const RefPtr< VBO > &myVBO, const VertexFragment &VertexFragments, const RefPtr< GLProgram > &Shader) const
 Append all the fields stored in these vertex fragments to the given vertex buffer object.
 
bool isOlderThan (const Ageable &A, const RefPtr< ValuePool > &Context) const
 Check if all parameters in this collection of fields is older than the given age.
 
void updateAge (Ageable &A, const RefPtr< ValuePool > &Context) const
 
RefPtr< StringListgetCurrentFieldnames (const RefPtr< ValuePool > &Context) const
 Get a list of all currently selected fields.
 
int iterate (Iterator &It) const
 Iterate through all available vertex fields.
 
- Public Member Functions inherited from Wizt::Fish< Fiber::Grid >
 Fish (const string &s="grid", int prior=2)
 Constructor, optionally pass a parameter of this grid's name (ie.
 
virtual ~Fish ()
 Destructor.
 
void registerGridAsOutput ()
 Make grid visible as output.
 
Fiber::Bundle::GridInfo_t findMostRecentGrid (GridSelector &GS, const RefPtr< ValuePool > &VP, const Fiber::BundlePtr &SpaceTime=Fiber::BundlePtr(NullPtr())) const
 This is a convenience function to find the most recent grid for the current time ( Fish<Slice>() or virtual function getTime() ).
 
Fiber::Bundle::GridInfo_t findMostRecentGrid (const RefPtr< ValuePool > &VP, const Fiber::BundlePtr &SpaceTime=Fiber::BundlePtr(NullPtr())) const
 Find the most recent grid for the current time ( Fish<Slice>() or virtual function getTime() ).
 
Fiber::Info< Fiber::SkeletongetRefinementLevel (int Level, const RefPtr< ValuePool > &VP, int IndexDepth=0, const Fiber::BundlePtr &SpaceTime=Fiber::BundlePtr(NullPtr())) const override
 Get an refinement level for the given spacetime based on the GridSelector as returned by getGridSelector().
 
bool IterateLevelsOnMostRecentGrid (LevelIterator &LI, const RefPtr< ValuePool > &Context, const Fiber::BundlePtr &SpaceTime=Fiber::BundlePtr(NullPtr())) const
 Iterate over all the selected levels of a Grid via an instance of the LevelIterator.
 
RefPtr< Fiber::FieldgetField (const Fiber::FieldSelector &FS, const RefPtr< ValuePool > &VP, const Fiber::BundlePtr &SpaceTime=Fiber::BundlePtr(NullPtr()))
 Retrieve a field for the given FieldSelector on the currently selected Grid.
 
- Public Member Functions inherited from Wizt::FloatOrigin
RefPtr< Chunk< Eagle::point3 > > computeShiftedCoordinates (const RefPtr< Chunk< Eagle::point3 > > &RawCoordinates, const Eagle::tvector3 &TranslationVector) const
 
VRenderContext::ModelViewState getCoordinateTranslation (const VRenderContext &Context, Eagle::tvector3 &TranslationVector) const
 
VRenderContext::ModelViewState getCoordinateTranslation (const VRenderContext &Context, Intercube &IC, Eagle::tvector3 &TranslationVector) const
 
- Public Member Functions inherited from Wizt::VStateCreatorBase
RefPtr< State > & getState (const WeakPtr< ValuePool > &VP) const
 
RefPtr< InterfaceBasehasLocalInterface (const type_info &InterfaceType) const
 
RefPtr< State > myState (const WeakPtr< ValuePool > &Context) const
 
virtual RefPtr< State > newState () const
 
void setState (const WeakPtr< ValuePool > &, const RefPtr< State > &st) const
 

Public Attributes

TypedSlot< FragmentSelectorMyFragmentSelector
 The input slot for selecting fragments out of a collection of fragments.
 
TypedSlot< intMyNumOfRefFragments
 
TypedSlot< OptionsMyOptions
 
TypedSlot< doubletsFloatOriginThreshold
 
- Public Attributes inherited from Wizt::VertexFieldCollection
RefPtr< VertexFieldPositions
 The coordinates are a field that will always be available here.
 
- Public Attributes inherited from Wizt::Fish< Fiber::Grid >
TypedSlot< Fiber::GridMyGrid
 

Additional Inherited Members

- Public Types inherited from Wizt::VertexFieldCollection
enum  { NumberOfInputFields = 1 }
 
- Static Public Member Functions inherited from Wizt::FloatOrigin
static VRenderContext::ModelViewState getTranslationVector (const VRenderContext &Context, Intercube &IC, Eagle::tvector3 &TranslationVector, double CameraShiftThreshold)
 
static Eagle::tvector3 getTranslationVector (Intercube &IC)
 

Detailed Description

A helper class that supports rendering of a collection of fragments from various fields.

A collection of fragments may be all data sets of a fragmented field, as well as some subset of such that is determined by a FragmentSelector. For each geometrical region, there may be multiple fields available (as specified by the VertexFieldCollection), which are all shuffled to a collection of Vertex Buffer Object, ready to be used by some fragment shader that needs to be implemented in a child class.

Within the fragment shader, the respective field data will be available as arrays under the names under which they are stored in the VertexFieldCollection . For instance, the constructor of a child class would contain the following line:

(*this)["normalvectors"] = new VBOField<TypedNormalArray<Eagle::tvector3> >(this, "vectorfield");
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34

It defines that the child class will use some input field named "vectorfield" that is provided to the fragment shader under the name "normalvectors".

Via the FragmentSelector this class also supports \i selective drawing of regions of interest.

Author
Werner Benger

Member Function Documentation

◆ appendOnDemandFragments()

bool Wizt::FragmentPainter::appendOnDemandFragments ( VGLRenderContext Context,
const RefPtr< VBO > &  myVBO,
int  RefinementLevel,
const WeakPtr< Representation > &  RefinementRep,
const RefPtr< FragmentID > &  fragment_identifier,
const Fiber::Fragment FragmentData,
const RefPtr< GLProgram > &  Shader 
) const
virtual

Virtual function to allow derived classes to create data on demand, i.e.

only when requested and required for rendering. Use in cooperation with YoungestDependency() to specify when a cached VBO shall be re-created. This function will never be called if those input data change otherwise.

◆ CacheableVariables()

RefPtr< ValueSet > Wizt::FragmentPainter::CacheableVariables ( const RefPtr< ValuePool > &  Context) const
virtual

Return a set of variables for which the results shall be cached, i.e.

there resides an OpenGL object for each state of each of those variables. They are all kept in memory until the cache is full. A typical example are fields. So when the user switches from one field to another field, and back to the first one, the OpenGL object does not need to be recomputed again, but is retrieved from the Cache. A typical counter example is a floating point value, since that one has an infinite number of possibilities. And it is unlikely that a user will accidentally switch back to an old value of a float slider, thus caching relative to float values is not reasonable. It is still possible, however, and could make sense if float values are rounded.

A typical implementation of this function, assuming two slots "MyGrid" and "MyField") looks like this:

{
*retval << (*MyField)(Context);
return retval;
}
virtual RefPtr< ValueSet > CacheableVariables(const RefPtr< ValuePool > &Context) const
Return a set of variables for which the results shall be cached, i.e.
Definition FragmentPainter.cpp:58
Deprecated:

Reimplemented in Wizt::VertexRenderObject.

◆ createRenderer()

RefPtr< VBO::Renderer > Wizt::FragmentPainter::createRenderer ( VGLRenderContext Context,
const RefPtr< MemBase > &  FieldCoordinates,
const RefPtr< FragmentSelector > &  FS 
) const
virtual

Create a Renderer object for the VBO, which by default is a DrawArrays() renderer that emits points for each vertex.

The Renderer is kept alive as long as the VBO it belongs to is kept alive.

Reimplemented in Wizt::SplatRenderObject, and Wizt::VertexGeometryShader.

◆ FragmentSelectionField()

string Wizt::FragmentPainter::FragmentSelectionField ( ) const
virtual

Return the name of the field that will be responsible for the coordinates of the fields.

By default, this will be "Positions".

Referenced by GLCacheField(), and renderFragments().

◆ GLCacheField()

string Wizt::FragmentPainter::GLCacheField ( const RefPtr< ValuePool > &  Context) const
virtual

The name of the field that will be used for caching opengl VBO's at each of this fragments.

This is a temporary workaround. It will NOT work correctly if a VBO depends on multiple fields. The VBO will only change if the GLCacheField changes (ie., its fragments).

There will be ONE VBO per fragment of this GLCacheField.

Per default, this will be the FragmentSelectionField().

If a rendering method implements a vector field visualization of Grid that does not change, then this function would refer to the name of that vector field. However, if the coordinates changes but not the vector field, it will still display the same. This needs to be reworked.

References FragmentSelectionField().

◆ setRendererParameters()

void Wizt::FragmentPainter::setRendererParameters ( VGLRenderContext Context,
const RefPtr< VBO::Renderer > &  theRenderer,
const RefPtr< CreativeArrayBase > &  VertexCoordinates,
const RefPtr< GLProgram > &  theShaderProgram 
) const
pure virtual

Given a Renderer, which usually is has been created by the createRenderer() virtual function, modify its parameters, depending on the context.

In contrast to the cacheable variables (see CacheableVariables() ), these parameters that are modified here do not require re-creation of a VBO object. This function will be called just before the VBO object is called to re-render the already loaded data.

Parameters
theShaderProgramThe Program which will be used for rendering. It will be null if no Shader Program is used.

◆ VBOCacheKey()

string Wizt::FragmentPainter::VBOCacheKey ( const RefPtr< ValuePool > &  Context) const
virtual

A child-class defined arbitrary string used to extend the cache modifier.

Reimplemented in Wizt::TensorShaderBase.

◆ YoungestDependency()

Ageable Wizt::FragmentPainter::YoungestDependency ( const RefPtr< ValuePool > &  Context,
const WeakPtr< Representation > &  RefinementRep 
) const
virtual

Optional child class for specifying dependencies that may have changed and require re-creation of a cached VBO.

This function is to be used in cooperation with appendOnDemandFragments().

Reimplemented in Wizt::TensorShaderBase.

References MemCore::Ageable::InfinitelyOld().