WSF
WsfSA_GroupUtils Class Reference

#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_GroupCreateGroup (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_GroupMergeGroups (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.

Member Enumeration Documentation

◆ GroupSorting

Enumerator
cASCENDING_THREAT 
cDESCENDING_THREAT 
cASCENDING_TARGET 
cDESCENDING_TARGET 
cASCENDING_ALTITUDE 
cDESCENDING_ALTITUDE 
cASCENDING_DISTANCE 
cDESCENDING_DISTANCE 
cASCENDING_ENTITY_COUNT 
cDESCENDING_ENTITY_COUNT 
cASCENDING_RADIUS 
cDESCENDING_RADIUS 

◆ SplitCriteria

Enumerator
cMAX_THREAT 
cMIN_THREAT 
cMAX_TARGET 
cMIN_TARGET 
cMAX_ALTITUDE 
cMIN_ALTITUDE 
cMAX_DISTANCE 
cMIN_DISTANCE 
cRIGHTMOST_FROM_HEADING 
cLEFTMOST_FROM_HEADING 

Member Function Documentation

◆ CalcRadiusForGroup_nm()

double WsfSA_GroupUtils::CalcRadiusForGroup_nm ( const WsfSA_Group * aGroup,
double aMinGroupRadius_nm )
static

Calculate the radius for the given group.

Parameters
aGroupA pointer to the group which has its radius recalculated.
aMinGroupRadius_nmThe minimum radius that a group can have.

References DistanceFromCentroid(), WsfSA_Group::GetElementList(), WsfSA_Group::GetRadiusCurrent_nm(), and WsfSA_Group::GetRadiusMinimum_nm().

Referenced by RecalculateGroupCentroid().

◆ CalculateNumPIs() [1/2]

int WsfSA_GroupUtils::CalculateNumPIs ( const std::list< WsfSA_Group * > & aGroupList)
static

This calculates the number of PIs represented within the list of recognized groups.

Parameters
aGroupListThe list of currently recognized groups.
Returns
The number of PIs represented within the list of recognized groups.

◆ CalculateNumPIs() [2/2]

int WsfSA_GroupUtils::CalculateNumPIs ( const std::list< WsfSA_PerceivedItem * > & aItemList)
static

This calculates the number of PIs represented within a list of groups and entity perceptions.

Parameters
aItemListThe list of currently recognized groups.
Returns
The number of PIs represented within the list of 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().

◆ CreateGroup()

WsfSA_Group * WsfSA_GroupUtils::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 )
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.

Parameters
aPI_LimitThe maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite.
aPI_CurrentThe current number of recognized PIs.
aGroupListThe mutable list of currently recognized groups.
aOwningPlatformA pointer to the platform from which this group originates.
aElementsThe list of entities that should be contained within this new group.
aNameThe name of the new group.
aMinGroupRadius_nmDefault settings of new groups created by this function.
aProtectIf 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.
Returns
False if an entity being removed from an unfocused group causes the PI limit to be exceeded, true otherwise.

References RecalculateGroupCentroid(), WsfSA_Group::SetElementList(), WsfSA_Group::SetElementProtection(), WsfSA_Group::SetPerceivedName(), and WsfSA_Group::SetRadiusMinimum_nm().

Referenced by WsfSA_Perceive::CreateGroup().

◆ DisbandGroup()

bool WsfSA_GroupUtils::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 )
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.

Parameters
aPI_LimitThe maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite.
aPI_CurrentThe current number of recognized PIs.
aGroupListThe mutable list of currently recognized groups.
aGroupThe group to disband.
aNamingFuncA 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_nmDefault settings of new groups created by this function.
aProtectIf 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.
Returns
False if disbanding an unfocused group causes the PI limit to be exceeded, true otherwise.

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().

◆ DistanceFromCentroid()

double WsfSA_GroupUtils::DistanceFromCentroid ( const WsfSA_Group * aGroup,
const WsfSA_EntityPerception * aEntity )
static

Calculate the distance from a group's centroid to and entity.

Parameters
aGroupA pointer to the group whose centroid is used.
aEntityA 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().

◆ MergeGroups()

WsfSA_Group * WsfSA_GroupUtils::MergeGroups ( std::list< WsfSA_Group * > & aGroupList,
const std::list< WsfSA_Group * > & aGroups,
const WsfPlatform * aOwningPlatform,
double aMinGroupRadius_nm,
bool aProtect = false )
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.

Parameters
aGroupListThe mutable list of currently recognized groups.
aGroupsThe list of groups to merge together.
aOwningPlatformA pointer to the platform from which this group originates.
aMinGroupRadius_nmDefault settings of new groups created by this function.
aProtectIf 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.
Returns
False if the groups cannot be merged due to conflicting focus, true otherwise.

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().

◆ Prune()

void WsfSA_GroupUtils::Prune ( int aPI_Limit,
std::list< WsfSA_PerceivedItem * > & aGroupList,
std::list< WsfSA_PerceivedItem * > & aToRemove )
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.

Parameters
aPI_LimitThe maximum number of allowable PIs.
aGroupListThe list of currently recognized groups.
aToRemoveGroups 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().

◆ PruneRecursive()

void WsfSA_GroupUtils::PruneRecursive ( int aPI_Limit,
WsfSA_PerceivedItem::Importance aImportance,
bool aPreserve,
std::list< WsfSA_PerceivedItem * > & aGroupList,
std::list< WsfSA_PerceivedItem * > & aToRemove )
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.

Parameters
aPI_LimitThe maximum number of allowable PIs.
aImportanceThe maximum importance level at which groups are allowed to be demoted or removed.
aPreserveTrue if user-modified groups should be preserved.
aGroupListThe list of currently recognized groups.
aToRemoveGroups 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().

◆ RecalculateGroupCentroid()

void WsfSA_GroupUtils::RecalculateGroupCentroid ( WsfSA_Group * aGroup,
double aMinGroupRadius_nm )
static

◆ RemoveEntityFromGroup()

bool WsfSA_GroupUtils::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 )
static

Removes an entity from a group, but does not delete the entity.

Parameters
aPI_LimitThe maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite.
aPI_CurrentThe current number of recognized PIs.
aGroupListThe mutable list of currently recognized groups.
aEntityThe entity to remove from its group.
aDegenerateGroupNameThe name given to the entity's new degenerate group.
aMinGroupRadius_nmDefault settings of new groups created by this function.
aProtectIf 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.
Returns
False if removing an entity from an unfocused group causes the PI limit to be exceeded, true otherwise.

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().

◆ RenameGroup()

bool WsfSA_GroupUtils::RenameGroup ( const std::list< WsfSA_Group * > & aGroupList,
WsfSA_Group * aGroup,
const std::string & aName )
static

This allows a group to be renamed.

Parameters
aGroupListThe list of currently recognized groups.
aGroupThe group to rename.
aNameThe new name.
Returns
True if success.

References WsfSA_Group::SetPerceivedName().

Referenced by WsfSA_Perceive::RenameGroup().

◆ SetFocus()

bool WsfSA_GroupUtils::SetFocus ( int aPI_Limit,
int aPI_Current,
WsfSA_Group * aGroup,
bool aFocus,
bool aProtect = false )
static

Sets a group to focused or unfocused depending on whether focus is true or false, respectively.

Parameters
aPI_LimitThe maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite.
aPI_CurrentThe current number of recognized PIs.
aGroupThe group for which focus is set.
aFocusSets the group to focused if true, unfocused otherwise.
aProtectIf 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.
Returns
False if setting an unfocused group to focused causes the PI limit to be exceeded, or if the group cannot be unfocused due to having only one entity.

References WsfSA_Group::GetFocus(), WsfSA_Group::GetNumElements(), WsfSA_Group::SetFocus(), and WsfSA_Group::SetFocusProtection().

Referenced by WsfSA_Perceive::SetFocus().

◆ SortedGroups()

void WsfSA_GroupUtils::SortedGroups ( int aSortingEnum,
std::vector< WsfSA_Group * > & aOutputGroups,
const std::list< WsfSA_Group * > & aGroupList,
const WsfPlatform * aPlatform )
static

Returns the groups sorted according to a sorting enumeration.

Parameters
aSortingEnumAn enumeration which corresponds to a sorting order.
aOutputGroupsThe vector populated with the group pointers, in sorted order. This should be passed in as an empty group.
aGroupListThe original list of groups.
aPlatformThe 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().

◆ SplitGroup()

std::pair< WsfSA_Group *, WsfSA_Group * > WsfSA_GroupUtils::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 )
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.

Parameters
aPI_LimitThe maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite.
aPI_CurrentThe current number of recognized PIs.
aGroupListThe mutable list of currently recognized groups.
aGroupThe group to split.
aNumElementsThe number of elements that will appear in the new group.
aCriterionAn enumeration describing how the group should be split.
aPlatformThe platform which is calling this function, which is necessary for some split criteria.
aNewGroupNameThe name given to the group containing the entities which met aCriterion.
aMinGroupRadius_nmDefault settings of new groups created by this function.
aProtectIf 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.
Returns
A pair containing the remainder of the original group, followed by the new group described by the split criteria and number of elements given.

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().

◆ StringToGroupSorting()

int WsfSA_GroupUtils::StringToGroupSorting ( const std::string & aEnumString)
static

Get a group sorting enumeration from a string.

Parameters
aEnumStringThe string from which to determine the group sorting.
Returns
The enumeration determined from the string.

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().

◆ StringToSplitCriteria()

int WsfSA_GroupUtils::StringToSplitCriteria ( const std::string & aEnumString)
static

Get a split criteria enumeration from a string.

Parameters
aEnumStringThe string from which to determine the split criteria.
Returns
The enumeration determined from the string.

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().

◆ TransferEntity()

bool WsfSA_GroupUtils::TransferEntity ( int aPI_Limit,
int aPI_Current,
std::list< WsfSA_Group * > & aGroupList,
WsfSA_EntityPerception * aEntity,
WsfSA_Group * aGroup,
double aMinGroupRadius_nm,
bool aProtect = false )
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.

Parameters
aPI_LimitThe maximum number of PIs which should be allowed. If set to 0 or a negative number, it is assumed to be infinite.
aPI_CurrentThe current number of recognized PIs.
aGroupListThe mutable list of currently recognized groups.
aEntityThe entity to transfer.
aGroupThe group into which the entity will be transferred.
aMinGroupRadius_nmDefault settings of new groups created by this function.
aProtectIf 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.
Returns
False if transferring an entity from an unfocused group to a focused one causes the PI limit to be exceeded, true otherwise.

References WsfSA_Group::AddElement(), WsfSA_Group::GetFocus(), WsfSA_EntityPerception::GetParentGroup(), RecalculateGroupCentroid(), and WsfSA_Group::SetElementProtection().

Referenced by WsfSA_Perceive::TransferEntity().


The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved