AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxOSG::PressureRenderer Class Reference

An utility class for handling of pressure rendering and legend. More...

#include <PressureRenderer.h>

+ Inheritance diagram for agxOSG::PressureRenderer:

Classes

struct  MaxAvgData
 
struct  MaxAvgRecording
 

Public Member Functions

 PressureRenderer (osg::Group *root, agxOSG::SceneDecorator *decorator, agxSDK::Simulation *simulation, const agx::Real minPressure, const agx::Real maxPressure, const agxRender::ColorVector &colors, const agx::Real texelsPerMeter=agx::Real(50), const agx::Real rangeFactor=agx::Real(2.0e-5), agxOSG::PressureFromContacts::ForceType forceType=agxOSG::PressureFromContacts::TOTAL_FORCE)
 Constructor using agx data.
 
 PressureRenderer (osg::Group *root, agxOSG::SceneDecorator *decorator, agxSDK::Simulation *simulation, osgSim::ColorRange *colorRange=new osgSim::ColorRange(0.0f, 1.0e5f), const agx::Real texelsPerMeter=agx::Real(50), const agx::Real rangeFactor=agx::Real(2.0e-5), agxOSG::PressureFromContacts::ForceType forceType=agxOSG::PressureFromContacts::TOTAL_FORCE)
 Constructor using osg color range directly.
 
void addFilter (agxSDK::ExecuteFilter *filter)
 Add a contact filter.
 
bool addGeometry (agxCollide::Geometry *geometry, bool keepGeometryNode=false)
 Adds all shapes in a geometry to the pressure rendering.
 
bool addTrimesh (agxCollide::Trimesh *trimesh, bool keepGeometryNode=false)
 Adds a trimesh to the pressure rendering.
 
osgSim::ColorRange * getColorRange ()
 Gets the color range.
 
agx::Vec2 getLegendPosition () const
 Returns the legend center position in relative screen space (0 to 1).
 
size_t getNumRecordings ()
 
agxOSG::PressureAtlasManager * getPressureAtlasManager ()
 Gets the pressure atlas manager.
 
bool isRecording ()
 
bool renderAvgPressure (size_t recording)
 Replace the texture data for measured geometries with a recorded average pressure.
 
bool renderMaxPressure (size_t recording)
 Replace the texture data for measured geometries with a recorded maximum pressure.
 
bool restoreRendering ()
 Disable rendering of recorded maximum or average data.
 
void setEnableLegend (bool flag)
 Enables/disables legend in HUD.
 
void setLegendPosition (const agx::Vec2 &pos)
 Sets the legend center position in relative screen space (0 to 1).
 
bool startMaxAvgRecording ()
 Start recording of maximum and average pressure for each pressure atlas currently owned by this PressureRenderer.
 
size_t stopMaxAvgRecording ()
 Stop the current recording.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Protected Types

typedef agx::Vector< MaxAvgRecording > MaxAvgRecordingVector
 

Protected Member Functions

virtual ~PressureRenderer ()
 
bool renderPressure (size_t recording, bool useMax)
 
void unregisterRecorders ()
 
void updateTextureData ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

agxOSG::PressureAtlasManagerRef m_atlasManager
 
osg::ref_ptr< osgSim::ColorRange > m_colorRange
 
size_t m_currentRecording
 
osg::observer_ptr< agxOSG::SceneDecorator > m_decorator
 
agx::Vector< agxSDK::ExecuteFilterRef > m_filters
 
const agxOSG::PressureFromContacts::ForceType m_forceType
 
agx::Vec2 m_legendPosition
 
osg::ref_ptr< agxOSG::Transform > m_legendTransform
 
agx::Vector< MaxAvgData > m_maxAvgData
 
agx::Vector< MaxAvgRecordingVector > m_maxAvgRecordings
 
agx::Vector< agxCollide::TrimeshRef > m_meshes
 
agx::Real m_rangeFactor
 
osg::observer_ptr< osg::Group > m_root
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

An utility class for handling of pressure rendering and legend.

Definition at line 50 of file PressureRenderer.h.

Member Typedef Documentation

◆ MaxAvgRecordingVector

Constructor & Destructor Documentation

◆ PressureRenderer() [1/2]

agxOSG::PressureRenderer::PressureRenderer ( osg::Group *  root,
agxOSG::SceneDecorator *  decorator,
agxSDK::Simulation *  simulation,
osgSim::ColorRange *  colorRange = new osgSim::ColorRange(0.0f, 1.0e5f),
const agx::Real  texelsPerMeter = agx::Real(50),
const agx::Real  rangeFactor = agx::Real(2.0e-5),
agxOSG::PressureFromContacts::ForceType  forceType = agxOSG::PressureFromContacts::TOTAL_FORCE 
)

Constructor using osg color range directly.

Parameters
rootThe scene root.
decoratorThe scene decorator, used here for the hud-legend.
simulationThe simulation
colorRangeThe color range, containing colors, and min and max pressure.
texelsPerMeterThe amount of texels per length unit (meter)
rangeFactorRelationship between a contact force and area of the pressure circle. In m/N.
forceTypeThe type of the force to add. Tangential (friction) only, normal only, or both.

◆ PressureRenderer() [2/2]

agxOSG::PressureRenderer::PressureRenderer ( osg::Group *  root,
agxOSG::SceneDecorator *  decorator,
agxSDK::Simulation *  simulation,
const agx::Real  minPressure,
const agx::Real  maxPressure,
const agxRender::ColorVector &  colors,
const agx::Real  texelsPerMeter = agx::Real(50),
const agx::Real  rangeFactor = agx::Real(2.0e-5),
agxOSG::PressureFromContacts::ForceType  forceType = agxOSG::PressureFromContacts::TOTAL_FORCE 
)

Constructor using agx data.

Parameters
rootThe scene root.
decoratorThe scene decorator, used here for the hud-legend.
simulationThe simulation
minPressureThe min pressure for texturing
maxPressureThe max pressure for texturing
colorsA vector of colors for coloring. See osgSim::ColorRange for details.
texelsPerMeterThe amount of texels per length unit (meter)
rangeFactorRelationship between a contact force and area of the pressure circle. In m/N.
forceTypeThe type of the force to add. Tangential (friction) only, normal only, or both.

◆ ~PressureRenderer()

virtual agxOSG::PressureRenderer::~PressureRenderer ( )
protectedvirtual

Member Function Documentation

◆ addFilter()

void agxOSG::PressureRenderer::addFilter ( agxSDK::ExecuteFilter *  filter)

Add a contact filter.

A contact will only contribute pressure if it is accepted by all filters. Filters will only affect meshes and geometries which have been added after the filter has been added.

Parameters
filter

◆ addGeometry()

bool agxOSG::PressureRenderer::addGeometry ( agxCollide::Geometry *  geometry,
bool  keepGeometryNode = false 
)

Adds all shapes in a geometry to the pressure rendering.

Note
: right now, only trimeshes are supported. The geometry has to be part of the simulation, and have an osg-node which is in the root's tree.
Parameters
geometryThe geometry.
keepGeometryNodeShould existing geometry nodes be kept? Interesting when blending render states.
Returns
True if successful, false otherwise

◆ addTrimesh()

bool agxOSG::PressureRenderer::addTrimesh ( agxCollide::Trimesh *  trimesh,
bool  keepGeometryNode = false 
)

Adds a trimesh to the pressure rendering.

The trimesh's geometry has to be part of the simulation, and have an osg-node which is in the root's tree.

Parameters
trimeshThe trimesh.
keepGeometryNodeShould existing geometry nodes be kept? Interesting when blending render states.
Returns
True if successful, false otherwise

◆ getColorRange()

osgSim::ColorRange * agxOSG::PressureRenderer::getColorRange ( )

Gets the color range.

◆ getLegendPosition()

agx::Vec2 agxOSG::PressureRenderer::getLegendPosition ( ) const

Returns the legend center position in relative screen space (0 to 1).

◆ getNumRecordings()

size_t agxOSG::PressureRenderer::getNumRecordings ( )
Returns
The number of finished recordings.

◆ getPressureAtlasManager()

agxOSG::PressureAtlasManager * agxOSG::PressureRenderer::getPressureAtlasManager ( )

Gets the pressure atlas manager.

◆ isRecording()

bool agxOSG::PressureRenderer::isRecording ( )
Returns
True if a currently recording. False otherwise.

◆ renderAvgPressure()

bool agxOSG::PressureRenderer::renderAvgPressure ( size_t  recording)

Replace the texture data for measured geometries with a recorded average pressure.

Each measured trimesh must be part of a geometry rendered using the OSG mesh created by the owning PressureAtlas, and the geometry must have an associated texture.

Will change the osg::Image object held by the osg::Texture2D object that is part of the OSG render tree.

Parameters
recordingThe recording ID from which the average pressure should be fetched.
Returns
True if the given recording was selected. False if the given recording ID is invalid.

◆ renderMaxPressure()

bool agxOSG::PressureRenderer::renderMaxPressure ( size_t  recording)

Replace the texture data for measured geometries with a recorded maximum pressure.

Each measured trimesh must be part of a geometry rendered using the OSG mesh created by the owning PressureAtlas, and the geometry must have an associated texture.

Will change the osg::Image object held by the osg::Texture2D object that is part of the OSG render tree.

Parameters
recordingThe recording ID from which the maximum pressure should be fetched.
Returns
True if the given recording was selected. False if the given recording ID is invalid.

◆ renderPressure()

bool agxOSG::PressureRenderer::renderPressure ( size_t  recording,
bool  useMax 
)
protected

◆ restoreRendering()

bool agxOSG::PressureRenderer::restoreRendering ( )

Disable rendering of recorded maximum or average data.

Each texture will be returned the osg::Image object it held when the recording started.

Returns
True if original texture data was restored, fase if currently not rendering maximum or average pressure.

◆ setEnableLegend()

void agxOSG::PressureRenderer::setEnableLegend ( bool  flag)

Enables/disables legend in HUD.

◆ setLegendPosition()

void agxOSG::PressureRenderer::setLegendPosition ( const agx::Vec2 &  pos)

Sets the legend center position in relative screen space (0 to 1).

◆ startMaxAvgRecording()

bool agxOSG::PressureRenderer::startMaxAvgRecording ( )

Start recording of maximum and average pressure for each pressure atlas currently owned by this PressureRenderer.

Should not be called while a recording is already in progress.

Returns
True is a recording was started. False if a recording was already taking place.

◆ stopMaxAvgRecording()

size_t agxOSG::PressureRenderer::stopMaxAvgRecording ( )

Stop the current recording.

An ID for the recording is returned. The recorded data can be rendered on the geometries using 'renderMaxPressure(ID)' or 'renderAvgPressure(ID)'.

Should only be called while recording.

Returns
A recording ID for the new recording, or agx::InvalidIndex if not currently recording.

◆ unregisterRecorders()

void agxOSG::PressureRenderer::unregisterRecorders ( )
protected

◆ updateTextureData()

void agxOSG::PressureRenderer::updateTextureData ( )
protected

Member Data Documentation

◆ m_atlasManager

agxOSG::PressureAtlasManagerRef agxOSG::PressureRenderer::m_atlasManager
protected

Definition at line 235 of file PressureRenderer.h.

◆ m_colorRange

osg::ref_ptr<osgSim::ColorRange> agxOSG::PressureRenderer::m_colorRange
protected

Definition at line 236 of file PressureRenderer.h.

◆ m_currentRecording

size_t agxOSG::PressureRenderer::m_currentRecording
protected

Definition at line 287 of file PressureRenderer.h.

◆ m_decorator

osg::observer_ptr<agxOSG::SceneDecorator> agxOSG::PressureRenderer::m_decorator
protected

Definition at line 234 of file PressureRenderer.h.

◆ m_filters

agx::Vector<agxSDK::ExecuteFilterRef> agxOSG::PressureRenderer::m_filters
protected

Definition at line 240 of file PressureRenderer.h.

◆ m_forceType

const agxOSG::PressureFromContacts::ForceType agxOSG::PressureRenderer::m_forceType
protected

Definition at line 290 of file PressureRenderer.h.

◆ m_legendPosition

agx::Vec2 agxOSG::PressureRenderer::m_legendPosition
protected

Definition at line 238 of file PressureRenderer.h.

◆ m_legendTransform

osg::ref_ptr<agxOSG::Transform> agxOSG::PressureRenderer::m_legendTransform
protected

Definition at line 237 of file PressureRenderer.h.

◆ m_maxAvgData

agx::Vector<MaxAvgData> agxOSG::PressureRenderer::m_maxAvgData
protected

Definition at line 261 of file PressureRenderer.h.

◆ m_maxAvgRecordings

agx::Vector<MaxAvgRecordingVector> agxOSG::PressureRenderer::m_maxAvgRecordings
protected

Definition at line 284 of file PressureRenderer.h.

◆ m_meshes

agx::Vector<agxCollide::TrimeshRef> agxOSG::PressureRenderer::m_meshes
protected

Definition at line 232 of file PressureRenderer.h.

◆ m_rangeFactor

agx::Real agxOSG::PressureRenderer::m_rangeFactor
protected

Definition at line 239 of file PressureRenderer.h.

◆ m_root

osg::observer_ptr<osg::Group> agxOSG::PressureRenderer::m_root
protected

Definition at line 233 of file PressureRenderer.h.


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