VR-Engage  2.2
Loading...
Searching...
No Matches
DtEntityHelper Class Reference

Detailed Description

DtEntityHelper provides a comprehensive set of utility functions for working with simulation entities. It facilitates entity lookup, position and orientation calculations, sensor management, and various spatial operations. This class serves as a bridge between the VR-Engage application and the underlying simulation entities, abstracting complex operations behind simple interface methods.

The class follows a singleton pattern for global access while maintaining proper initialization controls.

#include <entityHelper.h>

Public Member Functions

 DtEntityHelper (makVrv::DtDe &de, makVre::DtEntityResolver *resolver)
 
virtual ~DtEntityHelper ()
 
DtVector lookupEntityLocation (const std::string &globalId)
 
DtVector lookupEntityLocation (makVrv::DtUniqueID uniqueId)
 
DtQuaternion orientToVector (DtVector cigStart, DtVector cigEnd)
 
double degreesToTarget (std::string &globalId, DtVector cigEnd)
 
double degreesToTarget (makVrv::DtUniqueID uniqueId, DtVector cigEnd)
 
double degreesToTarget (DtVector cigStart, DtVector cigEnd)
 
makVrv::DtSceneObject * getSceneObject (makVrv::DtUniqueID uniqueId)
 
double getHeading (makVrv::DtUniqueID uniqueId)
 
double getHeading (makVrv::DtSceneObject *scnObj)
 
double getHeading (makVrv::DtObserver *obs)
 
double getAltitude (makVrv::DtUniqueID uniqueId)
 
double getAltitude (makVrv::DtSceneObject *scnObj)
 
makVrv::DtUniqueID uniqueIdFromMarkingText (const std::string &markingText)
 
makVrv::DtUniqueID uniqueIdFromConnectionId (const std::string &connectionId)
 
std::string connectionIdFromMarkingText (const std::string &markingText)
 
std::string connectionIdFromUniqueId (makVrv::DtUniqueID id)
 
std::string markingTextFromUniqueId (makVrv::DtUniqueID uniqueId)
 
std::string markingTextFromConnectionId (const std::string &id)
 
bool entityExists (const std::string &entityName)
 
std::vector< std::string > sensorsForEntity (const std::string &entityName)
 
makVrv::DtUniqueID sensorUniqueId (makVrv::DtUniqueID hostId, const std::string &sensorName)
 

Static Public Member Functions

static void initialize (makVrv::DtDe &de, makVre::DtEntityResolver *resolver)
 
static DtEntityHelperinstance ()
 
static bool isInitialized ()
 

Protected Types

using StringToIdMap = std::map<std::string, makVrv::DtUniqueID>
 
using StringToStringMap = std::map<std::string, std::string>
 

Protected Member Functions

void slot_elementsRemoved (const makVrv::DtElementData::ElementIdList &elements)
 

Protected Attributes

makVrv::DtDe & myDe
 
StringToIdMap myMarkingTextToUniqueIdMap
 
StringToIdMap myConnectionIdToUniqueIdMap
 
StringToStringMap myMarkingTextToConnectionIdMap
 
makVre::DtEntityResolvermyEntityResolver
 
makVrv::DtIntersector * myIntersector
 
enum  TargetingPodResponse { NO_SENSOR , TRACK_LOCATION , TRACK_TARGET }
 
TargetingPodResponse targetingPodInfo (const std::string &entityName, makVrv::DtUniqueID sensorId, DtVector &trackedLocation, makVrv::DtUniqueID &trackedTarget)
 
TargetingPodResponse targetingPodInfo (const std::string &entityName, DtVector &trackedLocation, makVrv::DtUniqueID &trackedTarget)
 
std::string sensorTrackingMode (makVrv::DtUniqueID hostId, makVrv::DtUniqueID sensorId)
 
makVrv::DtUniqueID sensorTargetUniqueId (makVrv::DtUniqueID hostId, makVrv::DtUniqueID sensorId)
 
DtVector sensorTargetLocation (makVrv::DtUniqueID hostId, makVrv::DtUniqueID sensorId)
 
DtVector sensorFrustumCenter (makVrv::DtUniqueID hostId, makVrv::DtUniqueID sensorId)
 
enum  SensorTrackingMode { TrackEntity , TrackLocation }
 
boost::signalslib::signal< void(makVrv::DtElementID entity)> signal_entityRemoved
 
bool entityPositionAndOrientation (makVrv::DtUniqueID id, DtVector &position, DtTaitBryan &orientation)
 
bool sensorRefOrientation (makVrv::DtUniqueID hostId, makVrv::DtUniqueID sensorId, DtTaitBryan &orientation)
 
DtVector localToGeodeticInDegrees (const DtVector &local)
 
bool getIntersectionPoint (const DtVector &localPosition, double x, double y, double z, double w, DtVector &intersectionPoint)
 
DtEntityType entityType (makVrv::DtUniqueID uniqueId)
 
makVre::DtEntityResolverentityResolver ()
 

Member Typedef Documentation

◆ StringToIdMap

using DtEntityHelper::StringToIdMap = std::map<std::string, makVrv::DtUniqueID>
protected

Type definition for string-to-ID mapping.

◆ StringToStringMap

using DtEntityHelper::StringToStringMap = std::map<std::string, std::string>
protected

Type definition for string-to-string mapping.

Member Enumeration Documentation

◆ TargetingPodResponse

Entity sensor utilities.

Response types for targeting pod queries

Enumeration of possible states a targeting pod can be in.

Enumerator
NO_SENSOR 

No suitable sensor found on the entity.

TRACK_LOCATION 

Sensor is tracking a location in space.

TRACK_TARGET 

Sensor is tracking another entity.

◆ SensorTrackingMode

Sensor tracking modes.

Enumeration of the possible tracking modes for sensors.

Enumerator
TrackEntity 

Sensor is tracking an entity.

TrackLocation 

Sensor is tracking a location.

Constructor & Destructor Documentation

◆ DtEntityHelper()

DtEntityHelper::DtEntityHelper ( makVrv::DtDe & de,
makVre::DtEntityResolver * resolver )

Constructor.

Parameters
deReference to the display engine
resolverPointer to the entity resolver

Creates a new entity helper object with the specified display engine and entity resolver. The display engine provides access to the visual representation of entities, while the entity resolver maps between different entity identifiers.

References de().

Referenced by instance().

◆ ~DtEntityHelper()

virtual DtEntityHelper::~DtEntityHelper ( )
virtual

Virtual destructor.

Cleans up resources used by the entity helper.

Member Function Documentation

◆ initialize()

static void DtEntityHelper::initialize ( makVrv::DtDe & de,
makVre::DtEntityResolver * resolver )
static

Initializes the singleton instance.

Parameters
deReference to the display engine
resolverPointer to the entity resolver

Initializes the singleton instance of the entity helper with the specified display engine and entity resolver. This must be called before any other static methods are used.

References de().

◆ instance()

static DtEntityHelper & DtEntityHelper::instance ( )
static

Gets the singleton instance.

Returns
Reference to the singleton instance

Retrieves the singleton instance of the entity helper. The helper must be initialized before calling this method.

References DtEntityHelper().

◆ isInitialized()

static bool DtEntityHelper::isInitialized ( )
static

Checks if the singleton is initialized.

Returns
True if initialized, false otherwise

Determines whether the singleton instance has been properly initialized.

◆ lookupEntityLocation() [1/2]

DtVector DtEntityHelper::lookupEntityLocation ( const std::string & globalId)

Entity location methods.

Finds an entity's location given its global simulation ID

Parameters
globalIdGlobal simulation identifier string
Returns
3D vector containing the entity's position in geocentric coordinates

Looks up the current position of an entity using its global simulation ID. Returns the entity's position in geocentric coordinates.

◆ lookupEntityLocation() [2/2]

DtVector DtEntityHelper::lookupEntityLocation ( makVrv::DtUniqueID uniqueId)

Finds an entity's location given its unique ID.

Parameters
uniqueIdUnique identifier for the entity
Returns
3D vector containing the entity's position in geocentric coordinates

Looks up the current position of an entity using its unique ID. Returns the entity's position in geocentric coordinates.

◆ orientToVector()

DtQuaternion DtEntityHelper::orientToVector ( DtVector cigStart,
DtVector cigEnd )

Orientation calculation methods.

Determines the quaternion to rotate from one vector to another

Parameters
cigStartStarting position vector in geocentric coordinates
cigEndTarget position vector in geocentric coordinates
Returns
Quaternion representing the rotation from start to end vector

Calculates a quaternion that rotates from the start vector to the end vector. This function assumes the database up vector as the up direction for both vectors. Useful for orienting entities to face specific targets or directions.

◆ degreesToTarget() [1/3]

double DtEntityHelper::degreesToTarget ( std::string & globalId,
DtVector cigEnd )

Determines the heading in degrees from an entity to a target point.

Parameters
globalIdGlobal simulation identifier string of the source entity
cigEndTarget position in geocentric coordinates
Returns
Heading in degrees from entity to target (0-360, clockwise from north)

Calculates the heading in degrees from an entity to a target point. The heading is measured clockwise from north (0-360 degrees).

◆ degreesToTarget() [2/3]

double DtEntityHelper::degreesToTarget ( makVrv::DtUniqueID uniqueId,
DtVector cigEnd )

Determines the heading in degrees from an entity to a target point.

Parameters
uniqueIdUnique identifier of the source entity
cigEndTarget position in geocentric coordinates
Returns
Heading in degrees from entity to target (0-360, clockwise from north)

Calculates the heading in degrees from an entity to a target point. The heading is measured clockwise from north (0-360 degrees).

◆ degreesToTarget() [3/3]

double DtEntityHelper::degreesToTarget ( DtVector cigStart,
DtVector cigEnd )

Determines the heading in degrees between two points.

Parameters
cigStartStarting position in geocentric coordinates
cigEndTarget position in geocentric coordinates
Returns
Heading in degrees from start to end point (0-360, clockwise from north)

Calculates the heading in degrees from a start point to an end point. The heading is measured clockwise from north (0-360 degrees). This version works with arbitrary positions rather than entities.

◆ getSceneObject()

makVrv::DtSceneObject * DtEntityHelper::getSceneObject ( makVrv::DtUniqueID uniqueId)

Entity lookup methods.

Gets the scene object for an entity

Parameters
uniqueIdUnique identifier of the entity
Returns
Pointer to the scene object, or NULL if not found

Retrieves the scene object associated with the specified entity. The scene object provides access to the visual representation and properties of the entity in the 3D scene.

◆ getHeading() [1/3]

double DtEntityHelper::getHeading ( makVrv::DtUniqueID uniqueId)

Gets an entity's current heading.

Parameters
uniqueIdUnique identifier of the entity
Returns
Heading in degrees (0-360, clockwise from north)

Retrieves the current heading of an entity specified by its unique ID. The heading is measured in degrees clockwise from north.

◆ getHeading() [2/3]

double DtEntityHelper::getHeading ( makVrv::DtSceneObject * scnObj)

Gets a scene object's current heading.

Parameters
scnObjPointer to the scene object
Returns
Heading in degrees (0-360, clockwise from north)

Retrieves the current heading of a scene object. The heading is measured in degrees clockwise from north.

◆ getHeading() [3/3]

double DtEntityHelper::getHeading ( makVrv::DtObserver * obs)

Gets an observer's current heading.

Parameters
obsPointer to the observer
Returns
Heading in degrees (0-360, clockwise from north)

Retrieves the current heading of an observer (camera view). The heading is measured in degrees clockwise from north.

◆ getAltitude() [1/2]

double DtEntityHelper::getAltitude ( makVrv::DtUniqueID uniqueId)

Gets an entity's current altitude.

Parameters
uniqueIdUnique identifier of the entity
Returns
Altitude in meters above mean sea level

Retrieves the current altitude of an entity specified by its unique ID. The altitude is measured in meters above mean sea level.

◆ getAltitude() [2/2]

double DtEntityHelper::getAltitude ( makVrv::DtSceneObject * scnObj)

Gets a scene object's current altitude.

Parameters
scnObjPointer to the scene object
Returns
Altitude in meters above mean sea level

Retrieves the current altitude of a scene object. The altitude is measured in meters above mean sea level.

◆ uniqueIdFromMarkingText()

makVrv::DtUniqueID DtEntityHelper::uniqueIdFromMarkingText ( const std::string & markingText)

Entity identifier conversion methods.

Converts marking text to a unique ID

Parameters
markingTextEntity marking text (display name)
Returns
Unique ID corresponding to the marking text

Looks up the unique ID of an entity based on its marking text (display name). Returns a null ID if no matching entity is found.

◆ uniqueIdFromConnectionId()

makVrv::DtUniqueID DtEntityHelper::uniqueIdFromConnectionId ( const std::string & connectionId)

Converts connection ID to a unique ID.

Parameters
connectionIdEntity connection identifier
Returns
Unique ID corresponding to the connection ID

Looks up the unique ID of an entity based on its connection identifier. Returns a null ID if no matching entity is found.

◆ connectionIdFromMarkingText()

std::string DtEntityHelper::connectionIdFromMarkingText ( const std::string & markingText)

Converts marking text to a connection ID.

Parameters
markingTextEntity marking text (display name)
Returns
Connection ID corresponding to the marking text

Looks up the connection identifier of an entity based on its marking text. Returns an empty string if no matching entity is found.

◆ connectionIdFromUniqueId()

std::string DtEntityHelper::connectionIdFromUniqueId ( makVrv::DtUniqueID id)

Converts unique ID to a connection ID.

Parameters
idUnique identifier of the entity
Returns
Connection ID corresponding to the unique ID

Looks up the connection identifier of an entity based on its unique ID. Returns an empty string if no matching entity is found.

◆ markingTextFromUniqueId()

std::string DtEntityHelper::markingTextFromUniqueId ( makVrv::DtUniqueID uniqueId)

Converts unique ID to marking text.

Parameters
uniqueIdUnique identifier of the entity
Returns
Marking text (display name) corresponding to the unique ID

Looks up the marking text (display name) of an entity based on its unique ID. Returns an empty string if no matching entity is found.

◆ markingTextFromConnectionId()

std::string DtEntityHelper::markingTextFromConnectionId ( const std::string & id)

Converts connection ID to marking text.

Parameters
idConnection identifier of the entity
Returns
Marking text (display name) corresponding to the connection ID

Looks up the marking text (display name) of an entity based on its connection ID. Returns an empty string if no matching entity is found.

◆ entityExists()

bool DtEntityHelper::entityExists ( const std::string & entityName)

Entity existence and property methods.

Checks if an entity exists in the simulation

Parameters
entityNameName of the entity to check
Returns
True if the entity exists, false otherwise

Determines whether an entity with the specified name exists in the current simulation. This can be used to verify an entity before attempting to interact with it.

◆ sensorsForEntity()

std::vector< std::string > DtEntityHelper::sensorsForEntity ( const std::string & entityName)

Gets all sensors for an entity.

Parameters
entityNameName of the entity
Returns
Vector of sensor names belonging to the entity

Retrieves a list of all named published sensor objects for the specified entity. These sensors can be used for tracking, targeting, or other sensor-related operations.

◆ sensorUniqueId()

makVrv::DtUniqueID DtEntityHelper::sensorUniqueId ( makVrv::DtUniqueID hostId,
const std::string & sensorName )

Gets the unique ID of a sensor.

Parameters
hostIdUnique ID of the host entity
sensorNameName of the sensor
Returns
Unique ID of the specified sensor

Retrieves the unique identifier for a specific sensor on a host entity. This ID can be used for further sensor-related operations.

◆ targetingPodInfo() [1/2]

TargetingPodResponse DtEntityHelper::targetingPodInfo ( const std::string & entityName,
makVrv::DtUniqueID sensorId,
DtVector & trackedLocation,
makVrv::DtUniqueID & trackedTarget )

Gets targeting pod information for a specific sensor.

Parameters
entityNameName of the entity that owns the targeting pod
sensorIdUnique ID of the specific sensor to query
trackedLocation[out] Location being tracked (valid if response is TRACK_LOCATION)
trackedTarget[out] Entity being tracked (valid if response is TRACK_TARGET)
Returns
Status of the targeting pod (NO_SENSOR, TRACK_LOCATION, or TRACK_TARGET)

Retrieves information about what a specific targeting pod sensor is currently tracking. Depending on the sensor's state, either trackedLocation or trackedTarget will be populated.

◆ targetingPodInfo() [2/2]

TargetingPodResponse DtEntityHelper::targetingPodInfo ( const std::string & entityName,
DtVector & trackedLocation,
makVrv::DtUniqueID & trackedTarget )

Gets targeting pod information using the first available gimbaled sensor.

Parameters
entityNameName of the entity that owns the targeting pod
trackedLocation[out] Location being tracked (valid if response is TRACK_LOCATION)
trackedTarget[out] Entity being tracked (valid if response is TRACK_TARGET)
Returns
Status of the targeting pod (NO_SENSOR, TRACK_LOCATION, or TRACK_TARGET)

Retrieves information about what the entity's first gimbaled sensor is tracking. This is a convenience method when the specific sensor ID is not known. Depending on the sensor's state, either trackedLocation or trackedTarget will be populated.

◆ sensorTrackingMode()

std::string DtEntityHelper::sensorTrackingMode ( makVrv::DtUniqueID hostId,
makVrv::DtUniqueID sensorId )

Gets the tracking mode of a sensor.

Parameters
hostIdUnique ID of the host entity
sensorIdUnique ID of the sensor
Returns
String describing the tracking mode (e.g., "TRACK ENTITY", "TRACK LOCATION")

Retrieves the current tracking mode of a sensor as a string. Common values include "TRACK ENTITY", "TRACK LOCATION", and others specific to the sensor type and configuration.

◆ sensorTargetUniqueId()

makVrv::DtUniqueID DtEntityHelper::sensorTargetUniqueId ( makVrv::DtUniqueID hostId,
makVrv::DtUniqueID sensorId )

Gets the unique ID of a sensor's target entity.

Parameters
hostIdUnique ID of the host entity
sensorIdUnique ID of the sensor
Returns
Unique ID of the entity being tracked by the sensor

Retrieves the unique identifier of the entity that the sensor is currently tracking. Returns a null ID if the sensor is not tracking an entity or if it's tracking a location instead.

◆ sensorTargetLocation()

DtVector DtEntityHelper::sensorTargetLocation ( makVrv::DtUniqueID hostId,
makVrv::DtUniqueID sensorId )

Gets the location a sensor is targeting.

Parameters
hostIdUnique ID of the host entity
sensorIdUnique ID of the sensor
Returns
Geocentric coordinates of the location being tracked

Retrieves the geocentric coordinates of the location that the sensor is currently tracking. If the sensor is tracking an entity, this returns the current location of that entity.

◆ sensorFrustumCenter()

DtVector DtEntityHelper::sensorFrustumCenter ( makVrv::DtUniqueID hostId,
makVrv::DtUniqueID sensorId )

Gets the center of a sensor's view frustum.

Parameters
hostIdUnique ID of the host entity
sensorIdUnique ID of the sensor
Returns
Geocentric coordinates of the frustum center

Retrieves the geocentric coordinates of the center point of the sensor's view frustum. This represents the center of the sensor's field of view, which may differ from its target location.

◆ entityPositionAndOrientation()

bool DtEntityHelper::entityPositionAndOrientation ( makVrv::DtUniqueID id,
DtVector & position,
DtTaitBryan & orientation )

Spatial calculation functions.

Gets an entity's position and orientation

Parameters
idUnique ID of the entity
position[out] Vector to receive entity's position
orientation[out] Orientation values to receive entity's orientation
Returns
True if the position and orientation were successfully retrieved

Retrieves the current position and orientation of an entity. The position is returned in the local coordinate system, and the orientation is returned as Tait-Bryan angles (heading, pitch, roll).

◆ sensorRefOrientation()

bool DtEntityHelper::sensorRefOrientation ( makVrv::DtUniqueID hostId,
makVrv::DtUniqueID sensorId,
DtTaitBryan & orientation )

Gets a sensor's orientation relative to its host.

Parameters
hostIdUnique ID of the host entity
sensorIdUnique ID of the sensor
orientation[out] Orientation values to receive sensor's orientation
Returns
True if the orientation was successfully retrieved

Retrieves the current orientation of a sensor relative to its host entity. The orientation is returned as Tait-Bryan angles (heading, pitch, roll) in the reference frame of the host object.

◆ localToGeodeticInDegrees()

DtVector DtEntityHelper::localToGeodeticInDegrees ( const DtVector & local)

Converts local coordinates to geodetic coordinates.

Parameters
localVector in local coordinate system
Returns
Geodetic coordinates in degrees (latitude, longitude, altitude)

Converts a position from the local coordinate system to geodetic coordinates. The result is expressed as degrees of latitude and longitude, and altitude in meters.

◆ getIntersectionPoint()

bool DtEntityHelper::getIntersectionPoint ( const DtVector & localPosition,
double x,
double y,
double z,
double w,
DtVector & intersectionPoint )

Calculates a terrain intersection point.

Parameters
localPositionStarting position in local coordinates
xX component of the direction quaternion
yY component of the direction quaternion
zZ component of the direction quaternion
wW component of the direction quaternion
intersectionPoint[out] Vector to receive intersection coordinates
Returns
True if an intersection was found, false otherwise

Calculates the intersection point between a ray and the terrain. The ray starts at localPosition and extends in the direction specified by the quaternion components (x, y, z, w). If an intersection is found, the coordinates are stored in intersectionPoint.

◆ entityType()

DtEntityType DtEntityHelper::entityType ( makVrv::DtUniqueID uniqueId)

Gets an entity's type information.

Parameters
uniqueIdUnique ID of the entity
Returns
Entity type information

Retrieves type information for the specified entity, including domain, kind, country, category, subcategory, and specific data.

◆ entityResolver()

makVre::DtEntityResolver * DtEntityHelper::entityResolver ( )

Gets the entity resolver being used.

Returns
Pointer to the entity resolver

Provides access to the entity resolver object used by this helper. The entity resolver maps between different entity representation systems.

◆ slot_elementsRemoved()

void DtEntityHelper::slot_elementsRemoved ( const makVrv::DtElementData::ElementIdList & elements)
protected

Slot called when elements are removed.

Parameters
elementsList of element IDs that were removed

Internal handler that processes element removal notifications and emits the signal_entityRemoved signal for each removed entity.

Member Data Documentation

◆ signal_entityRemoved

boost::signalslib::signal<void(makVrv::DtElementID entity)> DtEntityHelper::signal_entityRemoved

Signal emitted when an entity is removed.

This signal is emitted whenever an entity is removed from the simulation. Handlers can connect to this signal to perform cleanup or other operations when entities are removed.

◆ myDe

makVrv::DtDe& DtEntityHelper::myDe
protected

Reference to the display engine.

Provides access to the 3D visualization and scene management system.

◆ myMarkingTextToUniqueIdMap

StringToIdMap DtEntityHelper::myMarkingTextToUniqueIdMap
protected

Mapping from marking text to unique IDs.

◆ myConnectionIdToUniqueIdMap

StringToIdMap DtEntityHelper::myConnectionIdToUniqueIdMap
protected

Mapping from connection IDs to unique IDs.

◆ myMarkingTextToConnectionIdMap

StringToStringMap DtEntityHelper::myMarkingTextToConnectionIdMap
protected

Mapping from marking text to connection IDs.

◆ myEntityResolver

makVre::DtEntityResolver* DtEntityHelper::myEntityResolver
protected

Pointer to the entity resolver.

Used to translate between different entity identifier systems.

◆ myIntersector

makVrv::DtIntersector* DtEntityHelper::myIntersector
protected

Pointer to the terrain intersection calculator.

Used for ray-terrain intersection calculations.


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