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

A pressure map for a single trimesh. More...

#include <PressureAtlas.h>

+ Inheritance diagram for agxOSG::PressureAtlas:

Public Member Functions

 PressureAtlas (const agxCollide::Trimesh *mesh, agx::Real texelsPerMeter)
 
void addPressure (const agx::Vec3 &point, agx::UInt32 triangleIndex, agx::Real magnitude, agx::Real radius)
 Add a pressure sphere centered at 'point', given in the mesh's coordinate system, The given 'magnitude' is the pressure at the given 'point'.
 
void clearPressure ()
 Fill the pressure map with zeros.
 
agxOSG::GeometryNode * createAtlasRendering ()
 
osg::Geometry * getGraphicsMesh ()
 Returns an OSG Geometry that can be used to render the collected pressure.
 
size_t getNumTriangles () const
 
size_t getNumVertices () const
 
const agxCollide::Trimesh * getPhysicsMesh ()
 
osg::Image * getPressureMap ()
 Returns the pressure map.
 
osg::Vec2Array & getTextureCoordinates ()
 
size_t getVertexIndex (size_t triangleIndex, size_t localVertexIndex) const
 
bool isDirty () const
 Check if the pressure map is dirty.
 
bool isPressurized () const
 Check if the pressure map is pressurized.
 
bool registerColorConverter (agxOSG::PressureToColorConverter *colorConverter)
 Make the given color converter perform color conversion on this atlas' pressure map when PressureAtlas::updateColorImages is called.
 
bool registerPressureGenerator (agxOSG::PressureGenerator *generator)
 Let this PressureAtlas take over overship of the given pressure generator.
 
bool unregisterColorConverter (agxOSG::PressureToColorConverter *colorConverter)
 Cause the given color converter to no longer receive update calls from PressureAtlas::updateColorImages.
 
void updateColorImages ()
 Trigger a color conversion on all converters, if the pressure map is dirty.
 
- 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 Member Functions

virtual ~PressureAtlas ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

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.
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

A pressure map for a single trimesh.

Holds both the AGX trimesh used for simulation and a corresponding OSG geometry used for rendering, as well as a 32-bit floating-point image for the pressure data itself.

Definition at line 43 of file PressureAtlas.h.

Constructor & Destructor Documentation

◆ PressureAtlas()

agxOSG::PressureAtlas::PressureAtlas ( const agxCollide::Trimesh *  mesh,
agx::Real  texelsPerMeter 
)

◆ ~PressureAtlas()

virtual agxOSG::PressureAtlas::~PressureAtlas ( )
inlineprotectedvirtual

Definition at line 175 of file PressureAtlas.h.

Member Function Documentation

◆ addPressure()

void agxOSG::PressureAtlas::addPressure ( const agx::Vec3 &  point,
agx::UInt32  triangleIndex,
agx::Real  magnitude,
agx::Real  radius 
)

Add a pressure sphere centered at 'point', given in the mesh's coordinate system, The given 'magnitude' is the pressure at the given 'point'.

The added pressure will decrease linearly with distance from 'point' to reaches zero for points at or beyond 'radius' distance from 'point'.

The point should be on the triangle with the given triangle index.

Will mark the atlas as dirty and pressurized if the magnitude is non-zero.

Parameters
pointThe point, in mesh coordinates, where the pressure originates.
triangleIndexThe index of the triangle on which the point is located.
magnitudeThe pressure at the point, given in Pa. Must be non-negative.
radiusThe radius of the sphere which should be given a pressure contribution. Must be positive.

◆ clearPressure()

void agxOSG::PressureAtlas::clearPressure ( )

Fill the pressure map with zeros.

Set the dirty flag and clear the pressurized flag.

◆ createAtlasRendering()

agxOSG::GeometryNode * agxOSG::PressureAtlas::createAtlasRendering ( )

◆ getGraphicsMesh()

osg::Geometry * agxOSG::PressureAtlas::getGraphicsMesh ( )

Returns an OSG Geometry that can be used to render the collected pressure.

Contains texture coordinates into the pressure map.

◆ getNumTriangles()

size_t agxOSG::PressureAtlas::getNumTriangles ( ) const
Returns
The number of triangles of the mesh.

◆ getNumVertices()

size_t agxOSG::PressureAtlas::getNumVertices ( ) const
Returns
The number of vertices in the graphics mesh. This is always 3*getNumTriangles().

◆ getPhysicsMesh()

const agxCollide::Trimesh * agxOSG::PressureAtlas::getPhysicsMesh ( )

◆ getPressureMap()

osg::Image * agxOSG::PressureAtlas::getPressureMap ( )

Returns the pressure map.

It is a 2D image containing the pressure on the mesh mapped onto the mesh according to the texture coordinate found in the osg::Geometry returned by getGraphicsMesh(). The image format is one 32-bit floating point channel per texel, i.e., GL_RED, GL_FLOAT.

◆ getTextureCoordinates()

osg::Vec2Array & agxOSG::PressureAtlas::getTextureCoordinates ( )
Returns
The texture coordinates for the vertices of the graphics mesh.

◆ getVertexIndex()

size_t agxOSG::PressureAtlas::getVertexIndex ( size_t  triangleIndex,
size_t  localVertexIndex 
) const

◆ isDirty()

bool agxOSG::PressureAtlas::isDirty ( ) const

Check if the pressure map is dirty.

It is dirty if 'clearPressure' or 'addPressure' has been called with a non-zero magnitude since the last call to 'updateColorImages'.

Returns
True if the pressure map is dirty. False otherwise.

◆ isPressurized()

bool agxOSG::PressureAtlas::isPressurized ( ) const

Check if the pressure map is pressurized.

It is pressurized if 'addPressure' has been called with a non-zero pressure since the last call to 'clearPressure'.

Returns
True if the pressure map has at elast one non-zero element. False otherwise.

◆ registerColorConverter()

bool agxOSG::PressureAtlas::registerColorConverter ( agxOSG::PressureToColorConverter *  colorConverter)

Make the given color converter perform color conversion on this atlas' pressure map when PressureAtlas::updateColorImages is called.

Will hold a reference to the converter.

Parameters
colorConverterColor converter that should convert this atlas' pressure map.
Returns
True if the color converter was registered. False if it was already registered.

◆ registerPressureGenerator()

bool agxOSG::PressureAtlas::registerPressureGenerator ( agxOSG::PressureGenerator *  generator)

Let this PressureAtlas take over overship of the given pressure generator.

A generator can only be registered on one atlas at the time and will be rejected (false returned) if it was already registered to another atlas.

Returns
True if the generator was registered. False otherwise.

◆ unregisterColorConverter()

bool agxOSG::PressureAtlas::unregisterColorConverter ( agxOSG::PressureToColorConverter *  colorConverter)

Cause the given color converter to no longer receive update calls from PressureAtlas::updateColorImages.

Will release a reference to the color converter, so beware that the given pointer may become dangling.

Parameters
colorConverterThe color converter to unregister.
Returns
True if the color converter was unregistered. False if it wasn't registered.

◆ updateColorImages()

void agxOSG::PressureAtlas::updateColorImages ( )

Trigger a color conversion on all converters, if the pressure map is dirty.


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