Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Potentialfield Class Reference

An abstract base class for all fields. More...

#include <Pfield.h>

Inheritance diagram for Potentialfield:

Inheritance graph
[legend]
Collaboration diagram for Potentialfield:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Potentialfield ()
 Constructor.

virtual ~Potentialfield ()
 Destructor.

virtual void init ()
 Initializes values and / or allocates additional memory for subsequent computations.

void getResult (const PfPose &pose, PotentialfieldResult &result)
 Computes the result of a field.

void getValueArray (double x1, double y1, double x2, double y2, int xSteps, int ySteps, double value[], double &max)
 Computes an array of field values, used by visualization.

void getDirectionArray (double x1, double y1, double x2, double y2, int xSteps, int ySteps, PfVec directions[])
 Computes an array of gradient directions, used by visualization.

PfVec getFieldVecAt (const PfPose &pose)
 Computes the gradient at a given position.

double getFieldValueAt (const PfPose &pose)
 Computes the field value at a given position.

virtual void addObject (Object *object)
 Adds an object to the field.

std::string getName () const
 Returns the name of the field.

virtual BehaviorFieldType getBehaviorFieldType () const=0
 Returns the type of the field.

void setTimeConstraints (KeepType whatToKeep, ChangeType keepForN, int n, ChangeType blockForM, int m, ChangeType keepMaxForO, int o)
 Sets the time constraints.

void setCriterion (Criterion criterion, double value=0)
 Sets the validity criterion.

std::vector< std::string > getCombinedFields () const
 Returns the names of the fields, this field is combined with.

void addCombinedField (const std::string &fieldName)
 Adds the name of a field, this field is combined with.

bool isCombined ()
 Returns whether the field is combined with other fields or not.

void setSelectionFeedback (bool selected)
 Gives the field information about being selected or not.

bool hasToRemainActive ()
 Checks, if the field is still blocking other fields.

void setActivation (bool isActive)
 Activates and / or deactivates the field.


Protected Member Functions

virtual void execute (const PfPose &pose, PotentialfieldResult &result)=0
 Computes the result of a field.

bool isBlocked ()
 Checks if the field is blocked and cannot compute a result.

void checkForBlockAppliance ()
 Checks if the field has to be blocked in future and sets a block if necessary.


Protected Attributes

std::vector< Object * > objects
 The objects assigned to this field.

std::string name
 The name of the field.

Criterion criterion
 The criterion for result computation.

double criterionParameter
 An additional parameter for criterion.

std::vector< std::string > combinedFields
 The names of the combined fields.

PotentialfieldResult lastResult
 The last result computed by this field.

KeepType whatToKeep
 Describes what to keep: result or field.

ChangeType keepForN
 Keep for n CALLS or MILLISECONDS.

unsigned int n
 The value corresponding to keepForN.

ChangeType blockForM
 Block for m CALLS or MILLISECONDS.

unsigned int m
 The value corresponding to blockForM.

ChangeType keepMaxForO
 Keep this field at most for o CALLS or MILLISECONDS.

int o
 The value corresponding to keepMaxForO.

bool currentlySelected
 Describes, if the field has been selected last turn.

unsigned long selectedSince
 Describes how long this field has been selected.

unsigned long selectedCalls
 Describes how often this field has been selected.

unsigned long block
 Describes whether calls to be blocked or the point of time until the block is active.

bool isActive
 Flag: True, if the field is active and executable.


Detailed Description

An abstract base class for all fields.

Definition at line 44 of file Pfield.h.


Constructor & Destructor Documentation

Potentialfield::Potentialfield  ) 
 

Constructor.

Definition at line 19 of file Pfield.cpp.

References block, currentlySelected, and isActive.

Potentialfield::~Potentialfield  )  [virtual]
 

Destructor.

Definition at line 27 of file Pfield.cpp.

References combinedFields.


Member Function Documentation

virtual void Potentialfield::init  )  [inline, virtual]
 

Initializes values and / or allocates additional memory for subsequent computations.

This function should be called after all values are set and all objects have been assigned

Reimplemented in Actionfield.

Definition at line 56 of file Pfield.h.

Referenced by PotentialfieldComposition::addField().

void Potentialfield::getResult const PfPose pose,
PotentialfieldResult result
 

Computes the result of a field.

Parameters:
pose The pose on which the field affects
result The returned result

Definition at line 219 of file Pfield.cpp.

References PotentialfieldResult::action, PotentialfieldResult::actionPossible, CALLS, currentlySelected, execute(), getSystemTime(), isActive, isBlocked(), KEEP_RESULT, keepForN, lastResult, MILLISECONDS, selectedCalls, selectedSince, PotentialfieldResult::timeStamp, and whatToKeep.

Here is the call graph for this function:

void Potentialfield::getValueArray double  x1,
double  y1,
double  x2,
double  y2,
int  xSteps,
int  ySteps,
double  value[],
double &  max
 

Computes an array of field values, used by visualization.

Parameters:
x1 Minimum x-coordinate to compute
y1 Minimum y-coordinate to compute
x2 Maximum x-coordinate to compute
y2 Maximum y-coordinate to compute
xSteps The computation steps in x-direction
ySteps The computation steps in y-direction
value An array containing all computed values, memory has to be allocated BEFORE calling the function
max Returns the maximum value

Definition at line 34 of file Pfield.cpp.

References getFieldValueAt(), max, min, PfPose::pos, PfVec::x, and PfVec::y.

Referenced by PotentialfieldComposition::getValueArray().

Here is the call graph for this function:

void Potentialfield::getDirectionArray double  x1,
double  y1,
double  x2,
double  y2,
int  xSteps,
int  ySteps,
PfVec  directions[]
 

Computes an array of gradient directions, used by visualization.

Parameters:
x1 Minimum x-coordinate to compute
y1 Minimum y-coordinate to compute
x2 Maximum x-coordinate to compute
y2 Maximum y-coordinate to compute
xSteps The computation steps in x-direction
ySteps The computation steps in y-direction
directions An array containing all computed gradients, memory has to be allocated BEFORE calling the function

Definition at line 71 of file Pfield.cpp.

References getFieldVecAt(), PfVec::length(), PfVec::normalize(), PfPose::pos, PfVec::x, and PfVec::y.

Referenced by PotentialfieldComposition::getDirectionArray().

Here is the call graph for this function:

PfVec Potentialfield::getFieldVecAt const PfPose pose  ) 
 

Computes the gradient at a given position.

Parameters:
pose The pose
Returns:
The gradient

Definition at line 95 of file Pfield.cpp.

References getBehaviorFieldType(), and MOTION_FIELD.

Referenced by Motionfield::execute(), getDirectionArray(), and Motionfield::pathPlanningStillNeeded().

Here is the call graph for this function:

double Potentialfield::getFieldValueAt const PfPose pose  ) 
 

Computes the field value at a given position.

Parameters:
pose The pose
Returns:
The field value

Definition at line 111 of file Pfield.cpp.

Referenced by getValueArray(), and PotentialfieldAStarNode::setValueAtPos().

virtual void Potentialfield::addObject Object object  )  [inline, virtual]
 

Adds an object to the field.

Parameters:
object The object

Reimplemented in Actionfield.

Definition at line 104 of file Pfield.h.

Referenced by Parser::addGroupToField(), Actionfield::addObject(), and Parser::parseObjectsForField().

std::string Potentialfield::getName  )  const [inline]
 

Returns the name of the field.

Returns:
The name

Definition at line 110 of file Pfield.h.

Referenced by PotentialfieldComposition::addField().

virtual BehaviorFieldType Potentialfield::getBehaviorFieldType  )  const [pure virtual]
 

Returns the type of the field.

Returns:
The type

Implemented in Actionfield, and Motionfield.

Referenced by getFieldVecAt().

void Potentialfield::setTimeConstraints KeepType  whatToKeep,
ChangeType  keepForN,
int  n,
ChangeType  blockForM,
int  m,
ChangeType  keepMaxForO,
int  o
[inline]
 

Sets the time constraints.

Parameters:
whatToKeep Describes what to keep: result or field
keepForN Keep for n CALLS or MILLISECONDS
n The value corresponding to keepForN
blockForM Block for m CALLS or MILLISECONDS
m The value corresponding to blockForM
keepMaxForO Keep this field at most o CALLS or MILLISECONDS
o The value corresponding to blockForO

Definition at line 127 of file Pfield.h.

Referenced by Parser::parseTimeConstraintsForField().

void Potentialfield::setCriterion Criterion  criterion,
double  value = 0
[inline]
 

Sets the validity criterion.

Parameters:
criterion The criterion
value An additional parameter (for criterion == CRITERION_CONST)

Definition at line 143 of file Pfield.h.

References criterionParameter.

Referenced by Parser::parseActionfield(), and Parser::parseMotionfield().

std::vector<std::string> Potentialfield::getCombinedFields  )  const [inline]
 

Returns the names of the fields, this field is combined with.

Returns:
A list of field names

Definition at line 149 of file Pfield.h.

References combinedFields.

void Potentialfield::addCombinedField const std::string &  fieldName  )  [inline]
 

Adds the name of a field, this field is combined with.

Parameters:
fieldName The name of the field

Definition at line 155 of file Pfield.h.

References combinedFields.

Referenced by Parser::parseActionfield(), and Parser::parseMotionfield().

bool Potentialfield::isCombined  )  [inline]
 

Returns whether the field is combined with other fields or not.

Returns:
true, if the field is combined with at least one other field

Definition at line 161 of file Pfield.h.

References combinedFields.

void Potentialfield::setSelectionFeedback bool  selected  ) 
 

Gives the field information about being selected or not.

Parameters:
selected True, if the field has been selected in the current run

Definition at line 123 of file Pfield.cpp.

References checkForBlockAppliance(), currentlySelected, getSystemTime(), selectedCalls, and selectedSince.

Here is the call graph for this function:

bool Potentialfield::hasToRemainActive  ) 
 

Checks, if the field is still blocking other fields.

Returns:
true, if the field has to remain active

Definition at line 202 of file Pfield.cpp.

References CALLS, currentlySelected, getSystemTime(), keepForN, selectedCalls, and selectedSince.

Here is the call graph for this function:

void Potentialfield::setActivation bool  isActive  )  [inline]
 

Activates and / or deactivates the field.

Parameters:
isActive Deactivates the field, if false.

Definition at line 177 of file Pfield.h.

virtual void Potentialfield::execute const PfPose pose,
PotentialfieldResult result
[protected, pure virtual]
 

Computes the result of a field.

Parameters:
pose The pose on which the field affects
result The returned result

Implemented in Actionfield, and Motionfield.

Referenced by getResult().

bool Potentialfield::isBlocked  )  [protected]
 

Checks if the field is blocked and cannot compute a result.

Returns:
true, if the field is blocked

Definition at line 150 of file Pfield.cpp.

References block, blockForM, CALLS, and getSystemTime().

Referenced by getResult().

Here is the call graph for this function:

void Potentialfield::checkForBlockAppliance  )  [protected]
 

Checks if the field has to be blocked in future and sets a block if necessary.

Definition at line 167 of file Pfield.cpp.

References block, blockForM, CALLS, currentlySelected, getSystemTime(), keepMaxForO, m, o, selectedCalls, and selectedSince.

Referenced by setSelectionFeedback().

Here is the call graph for this function:


Member Data Documentation

std::vector<Object*> Potentialfield::objects [protected]
 

The objects assigned to this field.

Definition at line 182 of file Pfield.h.

std::string Potentialfield::name [protected]
 

The name of the field.

Definition at line 184 of file Pfield.h.

Criterion Potentialfield::criterion [protected]
 

The criterion for result computation.

Definition at line 186 of file Pfield.h.

double Potentialfield::criterionParameter [protected]
 

An additional parameter for criterion.

Definition at line 188 of file Pfield.h.

Referenced by setCriterion().

std::vector<std::string> Potentialfield::combinedFields [protected]
 

The names of the combined fields.

Definition at line 190 of file Pfield.h.

Referenced by addCombinedField(), getCombinedFields(), isCombined(), and ~Potentialfield().

PotentialfieldResult Potentialfield::lastResult [protected]
 

The last result computed by this field.

Definition at line 192 of file Pfield.h.

Referenced by getResult().

KeepType Potentialfield::whatToKeep [protected]
 

Describes what to keep: result or field.

Definition at line 194 of file Pfield.h.

Referenced by getResult().

ChangeType Potentialfield::keepForN [protected]
 

Keep for n CALLS or MILLISECONDS.

Definition at line 196 of file Pfield.h.

Referenced by getResult(), and hasToRemainActive().

unsigned int Potentialfield::n [protected]
 

The value corresponding to keepForN.

Definition at line 198 of file Pfield.h.

ChangeType Potentialfield::blockForM [protected]
 

Block for m CALLS or MILLISECONDS.

Definition at line 200 of file Pfield.h.

Referenced by checkForBlockAppliance(), and isBlocked().

unsigned int Potentialfield::m [protected]
 

The value corresponding to blockForM.

Definition at line 202 of file Pfield.h.

Referenced by checkForBlockAppliance().

ChangeType Potentialfield::keepMaxForO [protected]
 

Keep this field at most for o CALLS or MILLISECONDS.

Definition at line 204 of file Pfield.h.

Referenced by checkForBlockAppliance().

int Potentialfield::o [protected]
 

The value corresponding to keepMaxForO.

Definition at line 206 of file Pfield.h.

Referenced by checkForBlockAppliance().

bool Potentialfield::currentlySelected [protected]
 

Describes, if the field has been selected last turn.

Definition at line 208 of file Pfield.h.

Referenced by checkForBlockAppliance(), getResult(), hasToRemainActive(), Potentialfield(), and setSelectionFeedback().

unsigned long Potentialfield::selectedSince [protected]
 

Describes how long this field has been selected.

Definition at line 210 of file Pfield.h.

Referenced by checkForBlockAppliance(), getResult(), hasToRemainActive(), and setSelectionFeedback().

unsigned long Potentialfield::selectedCalls [protected]
 

Describes how often this field has been selected.

Definition at line 212 of file Pfield.h.

Referenced by checkForBlockAppliance(), getResult(), hasToRemainActive(), and setSelectionFeedback().

unsigned long Potentialfield::block [protected]
 

Describes whether calls to be blocked or the point of time until the block is active.

Definition at line 214 of file Pfield.h.

Referenced by checkForBlockAppliance(), isBlocked(), and Potentialfield().

bool Potentialfield::isActive [protected]
 

Flag: True, if the field is active and executable.

Definition at line 216 of file Pfield.h.

Referenced by getResult(), and Potentialfield().


The documentation for this class was generated from the following files:
Generated on Thu Sep 23 20:10:46 2004 for GT2004 by doxygen 1.3.6