VR-Forces 4.0.4 Class Documentation
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions
DtAggregateSpatialModel Class Reference

Functor class used to allow entity identifiers to be used as a key to a std::map. More...

List of all members.

Public Member Functions

 DtAggregateSpatialModel (DtVrfObjectManager &objectManager, const DtExerciseClock &exerciseClock)
 default constructor
virtual ~DtAggregateSpatialModel ()
 destructor
virtual void init ()
 Registers for org view callbacks.
virtual void timedTick ()
 This version of tick checks to see if the time to tick has arrived (myNextTickTime <= exerciseClock()->approximateElapsedRealTime()).
virtual void setTickPeriodUsesRealTime (bool value)
 indicate whether tick period is to be computed using real time or simulation time.
virtual bool tickPeriodUsesRealTime () const
virtual void setMinTickPeriod (double minTickPeriod)
 specifies a minimum tick period (which can also be thought of as
virtual double minTickPeriod () const
 access the minimum tick period
virtual void setMinTickPeriodVariance (double minTickPeriodVariance)
 set the variance in the minimum tick time. Default is 0.
virtual double minTickPeriodVariance () const
 access the variance in the minimum tick period
virtual void setNextTickTime (double nextTickTime)
 The next tick time is normally calculated internally.
virtual double nextTickTime () const
 access the next tick time
virtual void setTickAsFastAsPossibleWhenPaused (bool yesNo)
 Sets flag indicating whether or not to override tick behavior when paused and tick as fast as possible (regardless of running tick rate).
virtual bool tickAsFastAsPossibleWhenPaused () const
virtual
DtAggregateSpatialDataConstPtr 
lookup (const DtEntityIdentifier &id) const
 Lookup the state data for a given entity.
virtual void printHierarchy () const
 Prints contents of nodes for entire aggregate hierarchy. For debugging.

Static Public Member Functions

static void nodeAddedCallback (DtEntityIdentifier eid, void *userData)
 Callback invoked when node is added to organization hierarchy.
static void nodeRemovedCallback (DtEntityIdentifier eid, void *userData)
 Callback invoked when child is about to be removed from organization hierarchy.
static void childAddedCallback (DtEntityIdentifier eid, void *userData)
 Callback invoked when child is added to aggregate's list of child nodes.
static void childRemovedCallback (DtEntityIdentifier eid, void *userData)
 Callback invoked when child is about to be removed from aggregate's list of child nodes.

Protected Types

typedef std::map
< DtEntityIdentifier,
DtAggregateNodePtr
DtAggregateNodeMap

Protected Member Functions

virtual double calculateNextTickTime () const
 The next tick time is equal to mySimManager->exerciseClock()-> approximateElapsedRealTime() + myMinTickPeriod + a random # between -myMinTickPeriodVariance/2.
virtual void tick ()
 Checks to see if organization has changed since last tick.
virtual void destroyTreesAndMap ()
 Clears tree of aggregate state nodes and associated map for quick lookup.
virtual void buildTreesAndMap ()
 Builds tree of aggregate state nodes and associated map for quick lookup.
virtual void traverseTreesAndUpdateNodes ()
 Iterates over tree in depth-first manner.
virtual DtAggregateNodePtr createNode (const DtOrganizationManagerNode &orgViewNode)
 Creates new node (recursively) from corresponding node in DtOrganizationManager.
virtual void updateNode (DtAggregateNodePtr node)
 Iterates over children, calling updateNode() on each.
virtual bool updateNodeData (DtAggregateNodePtr node, const DtAggregateSpatialData &newData)
 Updates node with new state data.
virtual bool computeState (DtAggregateNodeConstPtr node, DtAggregateSpatialData &state)
 Computes new state data for given node.
virtual bool computeOrientation (DtAggregateNodeConstPtr node, DtAggregateNodeList subordinates, DtDcm &geocentricOrientation, double &heading)
 Computes geocentric orientation for given node, based on given list of subordinates.
virtual bool computeLocationAndBoundingGeometry (DtAggregateNodeConstPtr node, DtAggregateNodeList subordinates, const DtDcm &geocentricOrientation, DtVector &geocentricLocation, DtSimBoundingGeometry &boundingGeometry)
 Computes geocentric location and bounding geometry for given node, based on given list of subordinates.
virtual bool computeVelocity (DtAggregateNodeConstPtr node, DtAggregateNodeList subordinates, DtVector &geocentricVelocity)
 Computes geocentric location and bounding geometry for given node, based on given list of subordinates.
virtual void subordinatesToIncludeInComputingState (DtAggregateNodeConstPtr node, DtAggregateNodeList &list)
 Returns a list of subordinates to include when computing state.
virtual
DtOrgViewManagedObjectListConstPtr 
subordinatesToIncludeInComputingState (DtAggregateNodeConstPtr node) const
 Returns list of subordinate to include in computation of aggregate extent.
virtual void processNodeAdded (DtEntityIdentifier eid)
 Marks organization as having changed, so we recompute the trees and map next tick.
virtual void processNodeRemoved (DtEntityIdentifier eid)
 Marks organization as having changed, so we recompute the trees and map next tick.
virtual void processChildAdded (DtEntityIdentifier eid)
 Calls setOrganizationHasChanged(true).
virtual void processChildRemoved (DtEntityIdentifier eid)
 Calls setOrganizationHasChanged(true).
virtual void printNode (DtAggregateNodePtr node, int indentLevel=0) const
 Human-readable representation of individual node, for debugging.
virtual void registerOrgViewCallbacks ()
 Register/unregister node added/removed callback function with organization manager.
void unregisterOrgViewCallbacks ()
 Register/unregister node added/removed callback function with organization manager.
virtual void registerAggregateNodeCallbacks (DtOrganizationManagerNode &aggregateNode)
 Register/unregister aggregate node callback function with given node.
void unregisterAggregateNodeCallbacks (DtOrganizationManagerNode &aggregateNode)
 Register/unregister aggregate node callback function with given node.
virtual bool organizationHasChanged () const
 Flag indicating whether organization hierarchy has changed since the last tick.
virtual void setOrganizationHasChanged (bool yesNo)
 Flag indicating whether organization hierarchy has changed since the last tick.

Protected Attributes

DtAggregateNodeMap myNodeMap
 Map of DtAggregateNodePtr's, keyed on the DtEntityIdentifier of the corresponding entity/aggregate.
DtAggregateNodeList myRootNodeList
 List of root nodes (force level nodes)
const DtExerciseClockmyExerciseClock
DtVrfObjectManagermyObjectManager
 Used by this class to build the trees of DtAggregateNodes.
bool myOrganizationHasChanged
 Flag indicating whether organization hierarchy has changed since the last tick.
bool myTickPeriodUsesRealTime
 For variable tick rate support.
double myMinTickPeriod
double myMinTickPeriodVariance
double myNextTickTime
double myLastTickSimTime
bool myTickAsFastAsPossibleWhenPaused

Private Member Functions

 DtAggregateSpatialModel (const DtAggregateSpatialModel &orig)
 Copy Constructor not implemented -- Copy Not Allowed.
DtAggregateSpatialModeloperator= (const DtAggregateSpatialModel &orig)
 Assignment Operator Not implemented - Assignment Not Allowed.

Detailed Description

Functor class used to allow entity identifiers to be used as a key to a std::map.

When VR-Link implements a < operator for DtEntityIdentifier this class will no longer be needed.

DtAggregateSpatialModel computes aggregate location state (location, extent, velocity, and orientation) for every aggregate in the organization hierarchy each tick.


Member Typedef Documentation

typedef std::map<DtEntityIdentifier, DtAggregateNodePtr> DtAggregateSpatialModel::DtAggregateNodeMap [protected]

Constructor & Destructor Documentation

default constructor

destructor

Copy Constructor not implemented -- Copy Not Allowed.


Member Function Documentation

virtual void DtAggregateSpatialModel::init ( ) [virtual]

Registers for org view callbacks.

Builds initial tree of nodes containing state data for each individual/aggregate in the the simulation.

virtual void DtAggregateSpatialModel::timedTick ( ) [virtual]

This version of tick checks to see if the time to tick has arrived (myNextTickTime <= exerciseClock()->approximateElapsedRealTime()).

If it has, it will then call tick(), and recalculate the next tick time.

virtual void DtAggregateSpatialModel::setTickPeriodUsesRealTime ( bool  value) [virtual]

indicate whether tick period is to be computed using real time or simulation time.

If real time is used, then aggregates will update even while paused. Default is true.

virtual void DtAggregateSpatialModel::setMinTickPeriod ( double  minTickPeriod) [virtual]

specifies a minimum tick period (which can also be thought of as

  1. / maximum tick rate). This is specified in seconds. Default is 0.
virtual double DtAggregateSpatialModel::minTickPeriod ( ) const [virtual]

access the minimum tick period

virtual void DtAggregateSpatialModel::setMinTickPeriodVariance ( double  minTickPeriodVariance) [virtual]

set the variance in the minimum tick time. Default is 0.

virtual double DtAggregateSpatialModel::minTickPeriodVariance ( ) const [virtual]

access the variance in the minimum tick period

virtual void DtAggregateSpatialModel::setNextTickTime ( double  nextTickTime) [virtual]

The next tick time is normally calculated internally.

setNextTickTime can be used to force a tick (set nextTickTime to exerciseClock()-> approximateElapsedRealTime())

virtual double DtAggregateSpatialModel::nextTickTime ( ) const [virtual]

access the next tick time

Sets flag indicating whether or not to override tick behavior when paused and tick as fast as possible (regardless of running tick rate).

virtual DtAggregateSpatialDataConstPtr DtAggregateSpatialModel::lookup ( const DtEntityIdentifier &  id) const [virtual]

Lookup the state data for a given entity.

Contains the latest state information for a given individual/aggregate in the hierarchy.

Parameters:
idSite/host/object Id of entity Data record containing entity spatial data, i.e. position, orientation, velocity (returns emtpy pointer if not found).
virtual void DtAggregateSpatialModel::printHierarchy ( ) const [virtual]

Prints contents of nodes for entire aggregate hierarchy. For debugging.

virtual double DtAggregateSpatialModel::calculateNextTickTime ( ) const [protected, virtual]

The next tick time is equal to mySimManager->exerciseClock()-> approximateElapsedRealTime() + myMinTickPeriod + a random # between -myMinTickPeriodVariance/2.

and +myMinTickPeriodVariance/2. If the exercise clock is paused, the variance is always set to zero to insure that the extra calls to DtFRand() don't prevent repeatability.

virtual void DtAggregateSpatialModel::tick ( ) [protected, virtual]

Checks to see if organization has changed since last tick.

If it has, destroys and rebuilds the tree of nodes containing aggregate state information. Traverses the tree depth first and updates each node with new state data. For nodes representing individual entities, this is the same as the data maintained in the corresponding entity's state repository. For aggregate entities, it is computed from the state information of its subordinates (child nodes).

virtual void DtAggregateSpatialModel::destroyTreesAndMap ( ) [protected, virtual]

Clears tree of aggregate state nodes and associated map for quick lookup.

virtual void DtAggregateSpatialModel::buildTreesAndMap ( ) [protected, virtual]

Builds tree of aggregate state nodes and associated map for quick lookup.

Traverses the DtOrganizationManager to construct it.

virtual void DtAggregateSpatialModel::traverseTreesAndUpdateNodes ( ) [protected, virtual]

Iterates over tree in depth-first manner.

At each node, calls updateNode().

virtual DtAggregateNodePtr DtAggregateSpatialModel::createNode ( const DtOrganizationManagerNode orgViewNode) [protected, virtual]

Creates new node (recursively) from corresponding node in DtOrganizationManager.

virtual void DtAggregateSpatialModel::updateNode ( DtAggregateNodePtr  node) [protected, virtual]

Iterates over children, calling updateNode() on each.

Then calls computeState() to calculate new state values for the entity represented by the given node. Then calls updateNodeData() with new state information. This effectively iterates over tree and applies the state computation in a depth-first manner.

virtual bool DtAggregateSpatialModel::updateNodeData ( DtAggregateNodePtr  node,
const DtAggregateSpatialData newData 
) [protected, virtual]

Updates node with new state data.

virtual bool DtAggregateSpatialModel::computeState ( DtAggregateNodeConstPtr  node,
DtAggregateSpatialData state 
) [protected, virtual]

Computes new state data for given node.

Calls subordinatesToIncludeInComputingState() first to get the subordinates eligible for inclusion in calculations. Then calls computeOrienation() computeLocationAndBoundingGeometry() computeVelocity().

virtual bool DtAggregateSpatialModel::computeOrientation ( DtAggregateNodeConstPtr  node,
DtAggregateNodeList  subordinates,
DtDcm &  geocentricOrientation,
double &  heading 
) [protected, virtual]

Computes geocentric orientation for given node, based on given list of subordinates.

If list of subordinates is empty, returns the current orienation and heading of the corresponding DtVrfObject (individual or aggregate with no children). If subordinate list is not empty, computes orientation based on average heading.

virtual bool DtAggregateSpatialModel::computeLocationAndBoundingGeometry ( DtAggregateNodeConstPtr  node,
DtAggregateNodeList  subordinates,
const DtDcm &  geocentricOrientation,
DtVector geocentricLocation,
DtSimBoundingGeometry boundingGeometry 
) [protected, virtual]

Computes geocentric location and bounding geometry for given node, based on given list of subordinates.

If list of subordinates is empty, returns the current orienation and heading of the corresponding DtVrfObject (individual or aggregate with no children). If subordinate list is not empty, computes orientation based on average heading. Algorithm for computing location and bounding extent:

  1. Compute the center of mass of the aggregate
  2. Put subordinates in body coordinate system of aggregate.
  3. Compute the bounding extent of aggregate by progressively expanding bounding volume of aggregate to include each subordinate's bounding volume.
  4. Adjust (expand) the bounding extent of aggregate as necessary, such that the final bounding extent is symmetric along each axis.
virtual bool DtAggregateSpatialModel::computeVelocity ( DtAggregateNodeConstPtr  node,
DtAggregateNodeList  subordinates,
DtVector geocentricVelocity 
) [protected, virtual]

Computes geocentric location and bounding geometry for given node, based on given list of subordinates.

If list of subordinates is empty, returns the current velocity of the corresponding DtVrfObject (individual or aggregate with no children). If subordinate list is not empty, computes velocity based on average velocity.

Returns a list of subordinates to include when computing state.

Calls version that takes a DtVrfObject& to actually determine membership in this list.

Returns list of subordinate to include in computation of aggregate extent.

List of which subordinates to include are determined with the following priority: 1 - taskable subordinates 2 - movement-cabaple subordinates (regardless of independently-tasked status) 3 - all subordinates

virtual void DtAggregateSpatialModel::processNodeAdded ( DtEntityIdentifier  eid) [protected, virtual]

Marks organization as having changed, so we recompute the trees and map next tick.

virtual void DtAggregateSpatialModel::processNodeRemoved ( DtEntityIdentifier  eid) [protected, virtual]

Marks organization as having changed, so we recompute the trees and map next tick.

virtual void DtAggregateSpatialModel::processChildAdded ( DtEntityIdentifier  eid) [protected, virtual]

Calls setOrganizationHasChanged(true).

virtual void DtAggregateSpatialModel::processChildRemoved ( DtEntityIdentifier  eid) [protected, virtual]

Calls setOrganizationHasChanged(true).

virtual void DtAggregateSpatialModel::registerOrgViewCallbacks ( ) [protected, virtual]

Register/unregister node added/removed callback function with organization manager.

Register/unregister node added/removed callback function with organization manager.

virtual void DtAggregateSpatialModel::registerAggregateNodeCallbacks ( DtOrganizationManagerNode aggregateNode) [protected, virtual]

Register/unregister aggregate node callback function with given node.

Register/unregister aggregate node callback function with given node.

virtual bool DtAggregateSpatialModel::organizationHasChanged ( ) const [protected, virtual]

Flag indicating whether organization hierarchy has changed since the last tick.

virtual void DtAggregateSpatialModel::setOrganizationHasChanged ( bool  yesNo) [protected, virtual]

Flag indicating whether organization hierarchy has changed since the last tick.

virtual void DtAggregateSpatialModel::printNode ( DtAggregateNodePtr  node,
int  indentLevel = 0 
) const [protected, virtual]

Human-readable representation of individual node, for debugging.

static void DtAggregateSpatialModel::nodeAddedCallback ( DtEntityIdentifier  eid,
void *  userData 
) [static]

Callback invoked when node is added to organization hierarchy.

Calls processNodeAdded().

static void DtAggregateSpatialModel::nodeRemovedCallback ( DtEntityIdentifier  eid,
void *  userData 
) [static]

Callback invoked when child is about to be removed from organization hierarchy.

Calls processNodeRemoved().

static void DtAggregateSpatialModel::childAddedCallback ( DtEntityIdentifier  eid,
void *  userData 
) [static]

Callback invoked when child is added to aggregate's list of child nodes.

Calls processChildAdded().

static void DtAggregateSpatialModel::childRemovedCallback ( DtEntityIdentifier  eid,
void *  userData 
) [static]

Callback invoked when child is about to be removed from aggregate's list of child nodes.

Calls processChildRemoved().

DtAggregateSpatialModel& DtAggregateSpatialModel::operator= ( const DtAggregateSpatialModel orig) [private]

Assignment Operator Not implemented - Assignment Not Allowed.


Member Data Documentation

Map of DtAggregateNodePtr's, keyed on the DtEntityIdentifier of the corresponding entity/aggregate.

List of root nodes (force level nodes)

Used by this class to build the trees of DtAggregateNodes.

Trees created by this class will have the same structure as those maintained by the DtOrganizationView.

Flag indicating whether organization hierarchy has changed since the last tick.

For variable tick rate support.


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

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)