|
VR-Engage
2.2
|
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 DtEntityHelper & | instance () |
| 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::DtEntityResolver * | myEntityResolver |
| 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::DtEntityResolver * | entityResolver () |
|
protected |
Type definition for string-to-ID mapping.
|
protected |
Type definition for string-to-string mapping.
| DtEntityHelper::DtEntityHelper | ( | makVrv::DtDe & | de, |
| makVre::DtEntityResolver * | resolver ) |
Constructor.
| de | Reference to the display engine |
| resolver | Pointer 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().
|
virtual |
Virtual destructor.
Cleans up resources used by the entity helper.
|
static |
Initializes the singleton instance.
| de | Reference to the display engine |
| resolver | Pointer 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().
|
static |
Gets the singleton instance.
Retrieves the singleton instance of the entity helper. The helper must be initialized before calling this method.
References DtEntityHelper().
|
static |
Checks if the singleton is initialized.
Determines whether the singleton instance has been properly initialized.
| DtVector DtEntityHelper::lookupEntityLocation | ( | const std::string & | globalId | ) |
Entity location methods.
Finds an entity's location given its global simulation ID
| globalId | Global simulation identifier string |
Looks up the current position of an entity using its global simulation ID. Returns the entity's position in geocentric coordinates.
| DtVector DtEntityHelper::lookupEntityLocation | ( | makVrv::DtUniqueID | uniqueId | ) |
Finds an entity's location given its unique ID.
| uniqueId | Unique identifier for the entity |
Looks up the current position of an entity using its unique ID. Returns the entity's position in geocentric coordinates.
| DtQuaternion DtEntityHelper::orientToVector | ( | DtVector | cigStart, |
| DtVector | cigEnd ) |
Orientation calculation methods.
Determines the quaternion to rotate from one vector to another
| cigStart | Starting position vector in geocentric coordinates |
| cigEnd | Target position vector in geocentric coordinates |
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.
| double DtEntityHelper::degreesToTarget | ( | std::string & | globalId, |
| DtVector | cigEnd ) |
Determines the heading in degrees from an entity to a target point.
| globalId | Global simulation identifier string of the source entity |
| cigEnd | Target position in geocentric coordinates |
Calculates the heading in degrees from an entity to a target point. The heading is measured clockwise from north (0-360 degrees).
| double DtEntityHelper::degreesToTarget | ( | makVrv::DtUniqueID | uniqueId, |
| DtVector | cigEnd ) |
Determines the heading in degrees from an entity to a target point.
| uniqueId | Unique identifier of the source entity |
| cigEnd | Target position in geocentric coordinates |
Calculates the heading in degrees from an entity to a target point. The heading is measured clockwise from north (0-360 degrees).
| double DtEntityHelper::degreesToTarget | ( | DtVector | cigStart, |
| DtVector | cigEnd ) |
Determines the heading in degrees between two points.
| cigStart | Starting position in geocentric coordinates |
| cigEnd | Target position in geocentric coordinates |
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.
| makVrv::DtSceneObject * DtEntityHelper::getSceneObject | ( | makVrv::DtUniqueID | uniqueId | ) |
Entity lookup methods.
Gets the scene object for an entity
| uniqueId | Unique identifier of the entity |
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.
| double DtEntityHelper::getHeading | ( | makVrv::DtUniqueID | uniqueId | ) |
Gets an entity's current heading.
| uniqueId | Unique identifier of the entity |
Retrieves the current heading of an entity specified by its unique ID. The heading is measured in degrees clockwise from north.
| double DtEntityHelper::getHeading | ( | makVrv::DtSceneObject * | scnObj | ) |
Gets a scene object's current heading.
| scnObj | Pointer to the scene object |
Retrieves the current heading of a scene object. The heading is measured in degrees clockwise from north.
| double DtEntityHelper::getHeading | ( | makVrv::DtObserver * | obs | ) |
Gets an observer's current heading.
| obs | Pointer to the observer |
Retrieves the current heading of an observer (camera view). The heading is measured in degrees clockwise from north.
| double DtEntityHelper::getAltitude | ( | makVrv::DtUniqueID | uniqueId | ) |
Gets an entity's current altitude.
| uniqueId | Unique identifier of the entity |
Retrieves the current altitude of an entity specified by its unique ID. The altitude is measured in meters above mean sea level.
| double DtEntityHelper::getAltitude | ( | makVrv::DtSceneObject * | scnObj | ) |
Gets a scene object's current altitude.
| scnObj | Pointer to the scene object |
Retrieves the current altitude of a scene object. The altitude is measured in meters above mean sea level.
| makVrv::DtUniqueID DtEntityHelper::uniqueIdFromMarkingText | ( | const std::string & | markingText | ) |
Entity identifier conversion methods.
Converts marking text to a unique ID
| markingText | Entity marking text (display name) |
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.
| makVrv::DtUniqueID DtEntityHelper::uniqueIdFromConnectionId | ( | const std::string & | connectionId | ) |
Converts connection ID to a unique ID.
| connectionId | Entity connection identifier |
Looks up the unique ID of an entity based on its connection identifier. Returns a null ID if no matching entity is found.
| std::string DtEntityHelper::connectionIdFromMarkingText | ( | const std::string & | markingText | ) |
Converts marking text to a connection ID.
| markingText | Entity marking text (display name) |
Looks up the connection identifier of an entity based on its marking text. Returns an empty string if no matching entity is found.
| std::string DtEntityHelper::connectionIdFromUniqueId | ( | makVrv::DtUniqueID | id | ) |
Converts unique ID to a connection ID.
| id | Unique identifier of the entity |
Looks up the connection identifier of an entity based on its unique ID. Returns an empty string if no matching entity is found.
| std::string DtEntityHelper::markingTextFromUniqueId | ( | makVrv::DtUniqueID | uniqueId | ) |
Converts unique ID to marking text.
| uniqueId | Unique identifier of the entity |
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.
| std::string DtEntityHelper::markingTextFromConnectionId | ( | const std::string & | id | ) |
Converts connection ID to marking text.
| id | Connection identifier of the entity |
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.
| bool DtEntityHelper::entityExists | ( | const std::string & | entityName | ) |
Entity existence and property methods.
Checks if an entity exists in the simulation
| entityName | Name of the entity to check |
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.
| std::vector< std::string > DtEntityHelper::sensorsForEntity | ( | const std::string & | entityName | ) |
Gets all sensors for an entity.
| entityName | Name of 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.
| makVrv::DtUniqueID DtEntityHelper::sensorUniqueId | ( | makVrv::DtUniqueID | hostId, |
| const std::string & | sensorName ) |
Gets the unique ID of a sensor.
| hostId | Unique ID of the host entity |
| sensorName | Name of the sensor |
Retrieves the unique identifier for a specific sensor on a host entity. This ID can be used for further sensor-related operations.
| TargetingPodResponse DtEntityHelper::targetingPodInfo | ( | const std::string & | entityName, |
| makVrv::DtUniqueID | sensorId, | ||
| DtVector & | trackedLocation, | ||
| makVrv::DtUniqueID & | trackedTarget ) |
Gets targeting pod information for a specific sensor.
| entityName | Name of the entity that owns the targeting pod |
| sensorId | Unique 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) |
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.
| TargetingPodResponse DtEntityHelper::targetingPodInfo | ( | const std::string & | entityName, |
| DtVector & | trackedLocation, | ||
| makVrv::DtUniqueID & | trackedTarget ) |
Gets targeting pod information using the first available gimbaled sensor.
| entityName | Name 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) |
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.
| std::string DtEntityHelper::sensorTrackingMode | ( | makVrv::DtUniqueID | hostId, |
| makVrv::DtUniqueID | sensorId ) |
Gets the tracking mode of a sensor.
| hostId | Unique ID of the host entity |
| sensorId | Unique ID of the sensor |
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.
| makVrv::DtUniqueID DtEntityHelper::sensorTargetUniqueId | ( | makVrv::DtUniqueID | hostId, |
| makVrv::DtUniqueID | sensorId ) |
Gets the unique ID of a sensor's target entity.
| hostId | Unique ID of the host entity |
| sensorId | Unique ID of 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.
| DtVector DtEntityHelper::sensorTargetLocation | ( | makVrv::DtUniqueID | hostId, |
| makVrv::DtUniqueID | sensorId ) |
Gets the location a sensor is targeting.
| hostId | Unique ID of the host entity |
| sensorId | Unique ID of the sensor |
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.
| DtVector DtEntityHelper::sensorFrustumCenter | ( | makVrv::DtUniqueID | hostId, |
| makVrv::DtUniqueID | sensorId ) |
Gets the center of a sensor's view frustum.
| hostId | Unique ID of the host entity |
| sensorId | Unique ID of the sensor |
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.
| bool DtEntityHelper::entityPositionAndOrientation | ( | makVrv::DtUniqueID | id, |
| DtVector & | position, | ||
| DtTaitBryan & | orientation ) |
Spatial calculation functions.
Gets an entity's position and orientation
| id | Unique ID of the entity |
| position | [out] Vector to receive entity's position |
| orientation | [out] Orientation values to receive entity's orientation |
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).
| bool DtEntityHelper::sensorRefOrientation | ( | makVrv::DtUniqueID | hostId, |
| makVrv::DtUniqueID | sensorId, | ||
| DtTaitBryan & | orientation ) |
Gets a sensor's orientation relative to its host.
| hostId | Unique ID of the host entity |
| sensorId | Unique ID of the sensor |
| orientation | [out] Orientation values to receive sensor's orientation |
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.
| DtVector DtEntityHelper::localToGeodeticInDegrees | ( | const DtVector & | local | ) |
Converts local coordinates to geodetic coordinates.
| local | Vector in local coordinate system |
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.
| bool DtEntityHelper::getIntersectionPoint | ( | const DtVector & | localPosition, |
| double | x, | ||
| double | y, | ||
| double | z, | ||
| double | w, | ||
| DtVector & | intersectionPoint ) |
Calculates a terrain intersection point.
| localPosition | Starting position in local coordinates |
| x | X component of the direction quaternion |
| y | Y component of the direction quaternion |
| z | Z component of the direction quaternion |
| w | W component of the direction quaternion |
| intersectionPoint | [out] Vector to receive intersection coordinates |
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.
| DtEntityType DtEntityHelper::entityType | ( | makVrv::DtUniqueID | uniqueId | ) |
Gets an entity's type information.
| uniqueId | Unique ID of the entity |
Retrieves type information for the specified entity, including domain, kind, country, category, subcategory, and specific data.
| makVre::DtEntityResolver * DtEntityHelper::entityResolver | ( | ) |
Gets the entity resolver being used.
Provides access to the entity resolver object used by this helper. The entity resolver maps between different entity representation systems.
|
protected |
Slot called when elements are removed.
| elements | List of element IDs that were removed |
Internal handler that processes element removal notifications and emits the signal_entityRemoved signal for each removed entity.
| 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.
|
protected |
Reference to the display engine.
Provides access to the 3D visualization and scene management system.
|
protected |
Mapping from marking text to unique IDs.
|
protected |
Mapping from connection IDs to unique IDs.
|
protected |
Mapping from marking text to connection IDs.
|
protected |
Pointer to the entity resolver.
Used to translate between different entity identifier systems.
|
protected |
Pointer to the terrain intersection calculator.
Used for ray-terrain intersection calculations.