|
WSF
|
#include <WsfSA_GroupUtils.hpp>
Public Types | |
| enum | SplitCriteria { cMAX_THREAT = 1 , cMIN_THREAT = 2 , cMAX_TARGET = 3 , cMIN_TARGET = 4 , cMAX_ALTITUDE = 5 , cMIN_ALTITUDE = 6 , cMAX_DISTANCE = 7 , cMIN_DISTANCE = 8 , cRIGHTMOST_FROM_HEADING = 9 , cLEFTMOST_FROM_HEADING = 10 } |
| enum | GroupSorting { cASCENDING_THREAT = 1 , cDESCENDING_THREAT = 2 , cASCENDING_TARGET = 3 , cDESCENDING_TARGET = 4 , cASCENDING_ALTITUDE = 5 , cDESCENDING_ALTITUDE = 6 , cASCENDING_DISTANCE = 7 , cDESCENDING_DISTANCE = 8 , cASCENDING_ENTITY_COUNT = 9 , cDESCENDING_ENTITY_COUNT = 10 , cASCENDING_RADIUS = 11 , cDESCENDING_RADIUS = 12 } |
Static Public Member Functions | |
| static int | StringToSplitCriteria (const std::string &aEnumString) |
| Get a split criteria enumeration from a string. | |
| static int | StringToGroupSorting (const std::string &aEnumString) |
| Get a group sorting enumeration from a string. | |
| static int | CalculateNumPIs (const std::list< WsfSA_PerceivedItem * > &aItemList) |
| This calculates the number of PIs represented within a list of groups and entity perceptions. | |
| static int | CalculateNumPIs (const std::list< WsfSA_Group * > &aGroupList) |
| This calculates the number of PIs represented within the list of recognized groups. | |
| static bool | RenameGroup (const std::list< WsfSA_Group * > &aGroupList, WsfSA_Group *aGroup, const std::string &aName) |
| This allows a group to be renamed. | |
| static WsfSA_Group * | CreateGroup (int aPI_Limit, int aPI_Current, std::list< WsfSA_Group * > &aGroupList, const WsfPlatform *aOwningPlatform, const std::list< WsfSA_EntityPerception * > &aElements, const std::string &aName, double aMinGroupRadius_nm, bool aProtect=false) |
| Creates a new group and inserts all entities from the array argument into it. | |
| static bool | DisbandGroup (int aPI_Limit, int aPI_Current, std::list< WsfSA_Group * > &aGroupList, WsfSA_Group *aGroup, std::function< std::string()> aNamingFunc, double aMinGroupRadius_nm, bool aProtect=false) |
| Disbands the group. | |
| static WsfSA_Group * | MergeGroups (std::list< WsfSA_Group * > &aGroupList, const std::list< WsfSA_Group * > &aGroups, const WsfPlatform *aOwningPlatform, double aMinGroupRadius_nm, bool aProtect=false) |
| Merges the groups. | |
| static std::pair< WsfSA_Group *, WsfSA_Group * > | SplitGroup (int aPI_Limit, int aPI_Current, std::list< WsfSA_Group * > &aGroupList, WsfSA_Group *aGroup, int aNumElements, int aCriterion, WsfPlatform *aPlatform, const std::string &aNewGroupName, double aMinGroupRadius_nm, bool aProtect=false) |
| Splits a group according to the splitCriteria enumeration. | |
| static bool | TransferEntity (int aPI_Limit, int aPI_Current, std::list< WsfSA_Group * > &aGroupList, WsfSA_EntityPerception *aEntity, WsfSA_Group *aGroup, double aMinGroupRadius_nm, bool aProtect=false) |
| Transfers the entity into the group. | |
| static bool | RemoveEntityFromGroup (int aPI_Limit, int aPI_Current, std::list< WsfSA_Group * > &aGroupList, WsfSA_EntityPerception *aEntity, const std::string &aDegenerateGroupName, double aMinGroupRadius_nm, bool aProtect=false) |
| Removes an entity from a group, but does not delete the entity. | |
| static bool | SetFocus (int aPI_Limit, int aPI_Current, WsfSA_Group *aGroup, bool aFocus, bool aProtect=false) |
| Sets a group to focused or unfocused depending on whether focus is true or false, respectively. | |
| static void | Prune (int aPI_Limit, std::list< WsfSA_PerceivedItem * > &aGroupList, std::list< WsfSA_PerceivedItem * > &aToRemove) |
| Removes PIs which are in excess of the PI limit by unfocusing or removing groups. | |
| static void | PruneRecursive (int aPI_Limit, WsfSA_PerceivedItem::Importance aImportance, bool aPreserve, std::list< WsfSA_PerceivedItem * > &aGroupList, std::list< WsfSA_PerceivedItem * > &aToRemove) |
| Removes PIs which are in excess of the PI limit by unfocusing or removing groups. | |
| static void | SortedGroups (int aSortingEnum, std::vector< WsfSA_Group * > &aOutputGroups, const std::list< WsfSA_Group * > &aGroupList, const WsfPlatform *aPlatform) |
| Returns the groups sorted according to a sorting enumeration. | |
| static void | RecalculateGroupCentroid (WsfSA_Group *aGroup, double aMinGroupRadius_nm) |
| This recalculates the centroid and radius the given group. | |
| static double | CalcRadiusForGroup_nm (const WsfSA_Group *aGroup, double aMinGroupRadius_nm) |
| Calculate the radius for the given group. | |
| static double | DistanceFromCentroid (const WsfSA_Group *aGroup, const WsfSA_EntityPerception *aEntity) |
| Calculate the distance from a group's centroid to and entity. | |
|
static |
Calculate the radius for the given group.
| aGroup | A pointer to the group which has its radius recalculated. |
| aMinGroupRadius_nm | The minimum radius that a group can have. |
References DistanceFromCentroid(), WsfSA_Group::GetElementList(), WsfSA_Group::GetRadiusCurrent_nm(), and WsfSA_Group::GetRadiusMinimum_nm().
Referenced by RecalculateGroupCentroid().
|
static |
This calculates the number of PIs represented within the list of recognized groups.
| aGroupList | The list of currently recognized groups. |
|
static |
This calculates the number of PIs represented within a list of groups and entity perceptions.
| aItemList | The list of currently recognized groups. |
References WsfSA_PerceivedItem::GROUP.
Referenced by WsfSA_Perceive::CreateGroup(), WsfSA_Perceive::DisbandGroup(), PruneRecursive(), WsfSA_Perceive::RemoveEntityFromGroup(), WsfSA_Perceive::SetFocus(), WsfSA_Perceive::SplitGroup(), WsfSA_Perceive::TransferEntity(), UT_DEFINE_SCRIPT_METHOD(), and UT_DEFINE_SCRIPT_METHOD().
|
static |
Creates a new group and inserts all entities from the array argument into it.
As an exception to the general approach, if an entity in the array is already in another group, it will be removed from that group, but that group will not be marked as protected.
| aPI_Limit | The maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite. |
| aPI_Current | The current number of recognized PIs. |
| aGroupList | The mutable list of currently recognized groups. |
| aOwningPlatform | A pointer to the platform from which this group originates. |
| aElements | The list of entities that should be contained within this new group. |
| aName | The name of the new group. |
| aMinGroupRadius_nm | Default settings of new groups created by this function. |
| aProtect | If this function was called from script, then this should be set to true in order to protect the user's changes from being overridden by automatic merges or splits. Otherwise, it should be false. |
References RecalculateGroupCentroid(), WsfSA_Group::SetElementList(), WsfSA_Group::SetElementProtection(), WsfSA_Group::SetPerceivedName(), and WsfSA_Group::SetRadiusMinimum_nm().
Referenced by WsfSA_Perceive::CreateGroup().
|
static |
Disbands the group.
This does not delete the entities within that group. The group is deleted, so it should be considered invalid after successfully calling the function.
| aPI_Limit | The maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite. |
| aPI_Current | The current number of recognized PIs. |
| aGroupList | The mutable list of currently recognized groups. |
| aGroup | The group to disband. |
| aNamingFunc | A callable object which takes no object and returns a string which will be used to name the degenerate groups created upon successful completion of DisbandGroup. |
| aMinGroupRadius_nm | Default settings of new groups created by this function. |
| aProtect | If this function was called from script, then this should be set to true in order to protect the user's changes from being overridden by automatic merges or splits. Otherwise, it should be false. |
References WsfSA_Group::AddElement(), WsfSA_Group::GetElementList(), WsfSA_Group::GetFocus(), WsfSA_Group::GetNumElements(), WsfSA_PerceivedItem::OwningPlatform(), RecalculateGroupCentroid(), WsfSA_Group::RemoveElement(), WsfSA_Group::SetElementProtection(), WsfSA_Group::SetPerceivedName(), and WsfSA_Group::SetRadiusMinimum_nm().
Referenced by WsfSA_Perceive::DisbandGroup().
|
static |
Calculate the distance from a group's centroid to and entity.
| aGroup | A pointer to the group whose centroid is used. |
| aEntity | A pointer to the entity whose location is used. |
References WsfSA_EntityPerception::GetAltitude_ft(), WsfSA_Group::GetAltitude_ft(), WsfGeoPoint::GetDistanceFrom(), WsfSA_EntityPerception::GetLat_deg(), WsfSA_Group::GetLat_deg(), WsfSA_EntityPerception::GetLon_deg(), and WsfSA_Group::GetLon_deg().
Referenced by WsfSA_GroupManager::AttemptToJoinBestGroup(), and CalcRadiusForGroup_nm().
|
static |
Merges the groups.
All groups are deleted, and a new group is created, so the original groups should be considered invalid after successfully calling this function.
| aGroupList | The mutable list of currently recognized groups. |
| aGroups | The list of groups to merge together. |
| aOwningPlatform | A pointer to the platform from which this group originates. |
| aMinGroupRadius_nm | Default settings of new groups created by this function. |
| aProtect | If this function was called from script, then this should be set to true in order to protect the user's changes from being overridden by automatic merges or splits. Otherwise, it should be false. |
References WsfSA_Group::GetFocus(), RecalculateGroupCentroid(), WsfSA_Group::SetElementList(), WsfSA_Group::SetElementProtection(), WsfSA_Group::SetFocus(), WsfSA_Group::SetPerceivedName(), and WsfSA_Group::SetRadiusMinimum_nm().
Referenced by WsfSA_Perceive::MergeGroups().
|
static |
Removes PIs which are in excess of the PI limit by unfocusing or removing groups.
This calls PruneRecursive with aImportance = NOMINAL and aPreserve = true.
| aPI_Limit | The maximum number of allowable PIs. |
| aGroupList | The list of currently recognized groups. |
| aToRemove | Groups which were removed from the group list are added to this list. The entities within those groups should stop being perceived. |
References WsfSA_PerceivedItem::NOMINAL, and PruneRecursive().
Referenced by WsfSA_Perceive::Prune().
|
static |
Removes PIs which are in excess of the PI limit by unfocusing or removing groups.
This runs recursively with more permissive parameters until the number of PIs is within the PI limit.
| aPI_Limit | The maximum number of allowable PIs. |
| aImportance | The maximum importance level at which groups are allowed to be demoted or removed. |
| aPreserve | True if user-modified groups should be preserved. |
| aGroupList | The list of currently recognized groups. |
| aToRemove | Groups which were removed from the group list are added to this list. The entities within those groups should stop being perceived. |
References CalculateNumPIs(), WsfSA_PerceivedItem::GROUP, WsfSA_PerceivedItem::IGNORED, WsfSA_PerceivedItem::IMPORTANT, WsfSA_PerceivedItem::NOMINAL, and PruneRecursive().
Referenced by Prune(), and PruneRecursive().
|
static |
This recalculates the centroid and radius the given group.
| aGroup | A pointer to the group which has its centroid and radius recalculated. |
| aMinGroupRadius_nm | The minimum radius that a group can have. |
References CalcRadiusForGroup_nm(), WsfSA_Group::GetElementList(), WsfSA_Group::SetAltitude_ft(), WsfSA_PerceivedItem::SetAltitudeValid(), WsfSA_Group::SetHeading_deg(), WsfSA_PerceivedItem::SetHeadingValid(), WsfSA_Group::SetLat_deg(), WsfSA_Group::SetLon_deg(), WsfSA_Group::SetRadiusCurrent_nm(), WsfSA_Group::SetSpeed_kts(), and WsfSA_PerceivedItem::SetSpeedValid().
Referenced by WsfSA_GroupManager::AttemptToJoinBestGroup(), CreateGroup(), DisbandGroup(), WsfSA_GroupManager::FormDegenerateGroup(), MergeGroups(), RemoveEntityFromGroup(), SplitGroup(), and TransferEntity().
|
static |
Removes an entity from a group, but does not delete the entity.
| aPI_Limit | The maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite. |
| aPI_Current | The current number of recognized PIs. |
| aGroupList | The mutable list of currently recognized groups. |
| aEntity | The entity to remove from its group. |
| aDegenerateGroupName | The name given to the entity's new degenerate group. |
| aMinGroupRadius_nm | Default settings of new groups created by this function. |
| aProtect | If this function was called from script, then this should be set to true in order to protect the user's changes from being overridden by automatic merges or splits. Otherwise, it should be false. |
References WsfSA_Group::AddElement(), WsfSA_Group::GetFocus(), WsfSA_EntityPerception::GetParentGroup(), RecalculateGroupCentroid(), WsfSA_Group::RemoveElement(), WsfSA_Group::SetElementProtection(), WsfSA_Group::SetPerceivedName(), and WsfSA_Group::SetRadiusMinimum_nm().
Referenced by WsfSA_Perceive::RemoveEntityFromGroup().
|
static |
This allows a group to be renamed.
| aGroupList | The list of currently recognized groups. |
| aGroup | The group to rename. |
| aName | The new name. |
References WsfSA_Group::SetPerceivedName().
Referenced by WsfSA_Perceive::RenameGroup().
|
static |
Sets a group to focused or unfocused depending on whether focus is true or false, respectively.
| aPI_Limit | The maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite. |
| aPI_Current | The current number of recognized PIs. |
| aGroup | The group for which focus is set. |
| aFocus | Sets the group to focused if true, unfocused otherwise. |
| aProtect | If this function was called from script, then this should be set to true in order to protect the user's changes from being overridden by automatic merges or splits. Otherwise, it should be false. |
References WsfSA_Group::GetFocus(), WsfSA_Group::GetNumElements(), WsfSA_Group::SetFocus(), and WsfSA_Group::SetFocusProtection().
Referenced by WsfSA_Perceive::SetFocus().
|
static |
Returns the groups sorted according to a sorting enumeration.
| aSortingEnum | An enumeration which corresponds to a sorting order. |
| aOutputGroups | The vector populated with the group pointers, in sorted order. This should be passed in as an empty group. |
| aGroupList | The original list of groups. |
| aPlatform | The owning platform, which is required for some sortings, such as distance from the platform. This can be nullptr only for sortings which do not require it, such as by group radius. |
References WsfSA_PerceivedItem::CalcRangeForPlatform(), cASCENDING_ALTITUDE, cASCENDING_DISTANCE, cASCENDING_ENTITY_COUNT, cASCENDING_RADIUS, cASCENDING_TARGET, cASCENDING_THREAT, cDESCENDING_ALTITUDE, cDESCENDING_DISTANCE, cDESCENDING_ENTITY_COUNT, cDESCENDING_RADIUS, cDESCENDING_TARGET, cDESCENDING_THREAT, WsfSA_Group::GetAltitude_ft(), WsfSA_Group::GetNumElements(), WsfSA_Group::GetRadiusCurrent_nm(), WsfSA_PerceivedItem::GetTargetValue(), and WsfSA_PerceivedItem::GetThreatLevel().
Referenced by WsfSA_Assess::SortedGroups().
|
static |
Splits a group according to the splitCriteria enumeration.
The number of entities specified by the number argument will be added to a new group which fits splitCriteria. The remainder will be put into the other created group. The input group is deleted, so the original group should be considered invalid after successfully calling this function.
| aPI_Limit | The maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite. |
| aPI_Current | The current number of recognized PIs. |
| aGroupList | The mutable list of currently recognized groups. |
| aGroup | The group to split. |
| aNumElements | The number of elements that will appear in the new group. |
| aCriterion | An enumeration describing how the group should be split. |
| aPlatform | The platform which is calling this function, which is necessary for some split criteria. |
| aNewGroupName | The name given to the group containing the entities which met aCriterion. |
| aMinGroupRadius_nm | Default settings of new groups created by this function. |
| aProtect | If this function was called from script, then this should be set to true in order to protect the user's changes from being overridden by automatic merges or splits. Otherwise, it should be false. |
References cLEFTMOST_FROM_HEADING, cMAX_ALTITUDE, cMAX_DISTANCE, cMAX_TARGET, cMAX_THREAT, cMIN_ALTITUDE, cMIN_DISTANCE, cMIN_TARGET, cMIN_THREAT, cRIGHTMOST_FROM_HEADING, WsfSA_Group::GetElementList(), WsfSA_Group::GetFocus(), WsfSA_Group::GetNumElements(), WsfSA_Group::GetPerceivedName(), WsfSA_PerceivedItem::OwningPlatform(), RecalculateGroupCentroid(), WsfSA_Group::SetElementList(), WsfSA_Group::SetElementProtection(), WsfSA_Group::SetFocus(), WsfSA_Group::SetPerceivedName(), and WsfSA_Group::SetRadiusMinimum_nm().
Referenced by WsfSA_Perceive::SplitGroup().
|
static |
Get a group sorting enumeration from a string.
| aEnumString | The string from which to determine the group sorting. |
References cASCENDING_ALTITUDE, cASCENDING_DISTANCE, cASCENDING_ENTITY_COUNT, cASCENDING_RADIUS, cASCENDING_TARGET, cASCENDING_THREAT, cDESCENDING_ALTITUDE, cDESCENDING_DISTANCE, cDESCENDING_ENTITY_COUNT, cDESCENDING_RADIUS, cDESCENDING_TARGET, and cDESCENDING_THREAT.
Referenced by UT_DEFINE_SCRIPT_METHOD().
|
static |
Get a split criteria enumeration from a string.
| aEnumString | The string from which to determine the split criteria. |
References cLEFTMOST_FROM_HEADING, cMAX_ALTITUDE, cMAX_DISTANCE, cMAX_TARGET, cMAX_THREAT, cMIN_ALTITUDE, cMIN_DISTANCE, cMIN_TARGET, cMIN_THREAT, and cRIGHTMOST_FROM_HEADING.
Referenced by UT_DEFINE_SCRIPT_METHOD().
|
static |
Transfers the entity into the group.
As an exception to the general approach, if the entity is already in another group, it will be removed from that group, but that group will not be marked as protected.
| aPI_Limit | The maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite. |
| aPI_Current | The current number of recognized PIs. |
| aGroupList | The mutable list of currently recognized groups. |
| aEntity | The entity to transfer. |
| aGroup | The group into which the entity will be transferred. |
| aMinGroupRadius_nm | Default settings of new groups created by this function. |
| aProtect | If this function was called from script, then this should be set to true in order to protect the user's changes from being overridden by automatic merges or splits. Otherwise, it should be false. |
References WsfSA_Group::AddElement(), WsfSA_Group::GetFocus(), WsfSA_EntityPerception::GetParentGroup(), RecalculateGroupCentroid(), and WsfSA_Group::SetElementProtection().
Referenced by WsfSA_Perceive::TransferEntity().