AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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'. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
void clearPressure ()
 Fill the pressure map with zeros. More...
 
agxOSG::GeometryNode * createAtlasRendering ()
 
osg::Geometry * getGraphicsMesh ()
 Returns an OSG Geometry that can be used to render the collected pressure. More...
 
size_t getNumTriangles () const
 
size_t getNumVertices () const
 
const agxCollide::Trimesh * getPhysicsMesh ()
 
osg::Image * getPressureMap ()
 Returns the pressure map. More...
 
int getReferenceCount () const
 
osg::Vec2Array & getTextureCoordinates ()
 
size_t getVertexIndex (size_t triangleIndex, size_t localVertexIndex) const
 
template<typename T >
bool is () const
 Subclass test. More...
 
bool isDirty () const
 Check if the pressure map is dirty. More...
 
bool isPressurized () const
 Check if the pressure map is pressurized. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
bool registerColorConverter (agxOSG::PressureToColorConverter *colorConverter)
 Make the given color converter perform color conversion on this atlas' pressure map when PressureAtlas::updateColorImages is called. More...
 
bool registerPressureGenerator (agxOSG::PressureGenerator *generator)
 Let this PressureAtlas take over overship of the given pressure generator. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
bool unregisterColorConverter (agxOSG::PressureToColorConverter *colorConverter)
 Cause the given color converter to no longer receive update calls from PressureAtlas::updateColorImages. More...
 
void updateColorImages ()
 Trigger a color conversion on all converters, if the pressure map is dirty. More...
 

Static Public Member Functions

template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~PressureAtlas ()
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

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

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

Definition at line 175 of file PressureAtlas.h.

Member Function Documentation

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.
void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
void agxOSG::PressureAtlas::clearPressure ( )

Fill the pressure map with zeros.

Set the dirty flag and clear the pressurized flag.

agxOSG::GeometryNode* agxOSG::PressureAtlas::createAtlasRendering ( )
void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
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.

size_t agxOSG::PressureAtlas::getNumTriangles ( ) const
Returns
The number of triangles of the mesh.
size_t agxOSG::PressureAtlas::getNumVertices ( ) const
Returns
The number of vertices in the graphics mesh. This is always 3*getNumTriangles().
const agxCollide::Trimesh* agxOSG::PressureAtlas::getPhysicsMesh ( )
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.

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
osg::Vec2Array& agxOSG::PressureAtlas::getTextureCoordinates ( )
Returns
The texture coordinates for the vertices of the graphics mesh.
size_t agxOSG::PressureAtlas::getVertexIndex ( size_t  triangleIndex,
size_t  localVertexIndex 
) const
template<typename T >
bool agx::Referenced::is ( ) const
inherited
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.
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.
void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

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.
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.
static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

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.
void agxOSG::PressureAtlas::updateColorImages ( )

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

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.


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