ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
larcfm::PolyPath Class Reference

#include <PolyPath.h>

Inheritance diagram for larcfm::PolyPath:
larcfm::ErrorReporter

Public Types

enum  PathMode {
  MORPHING , AVG_VEL , USER_VEL , USER_VEL_FINITE ,
  USER_VEL_EVER
}
 

Public Member Functions

 PolyPath ()
 
 PolyPath (const std::string &n)
 
 PolyPath (const std::string &n, PathMode m)
 
 PolyPath (const std::string &n, const SimplePoly &p)
 
 PolyPath (const std::string &n, const SimplePoly &p, double t)
 
 PolyPath (const std::string &n, const SimplePoly &p, const Velocity &v, double t)
 
 PolyPath (const std::string &n, const std::vector< SimplePoly > &ps, const std::vector< double > &ts)
 
PolyPath copy () const
 
Triple< Plan, double, double > buildPlan () const
 
bool isLatLon () const
 
bool isStatic () const
 
bool isContinuing () const
 
bool isUserVel () const
 
PathMode getPathMode () const
 
void setPathMode (PathMode m)
 
std::string getID () const
 
void setID (const std::string &n)
 
std::string getNote () const
 
void setNote (const std::string &n)
 
int size () const
 
void addPolygon (const SimplePoly &p, double time)
 
void addPolygon (const SimplePoly &p, const Velocity &v, double time)
 
void remove (int n)
 
double getFirstTime () const
 
double getLastTime () const
 
double getLastPolyTime () const
 
void makeVertexCountEqual ()
 
SimplePoly interpolate (double time) const
 
Velocity initialVelocity (int n)
 
Velocity initialVertexVelocity (int vert, int n)
 
int getSegment (double tm) const
 
SimplePoly position (double time) const
 
int getIndex (double time) const
 
SimplePolygetPolyRef (int n)
 
SimplePoly getPoly (int n) const
 
double getTime (int n) const
 
void setTime (int n, double t)
 
void setPolygon (int i, const SimplePoly &p)
 
void setVelocity (int i, const Velocity &v)
 
bool validate () const
 
PolyPath truncate (double t)
 
void addVertex (const Position &p, double bottom, double top, double time)
 
void addVertex (int n, const Position &p)
 
void removeVertex (int vert)
 
void translate (Vect3 off)
 
void timeshift (double shift)
 
Velocity velocity (double time)
 
Velocity vertexVelocity (int vert, double time)
 
Velocity finalVelocity (int i)
 
Velocity finalVertexVelocity (int vert, int i)
 
MovingPolygon3D getInitialMovingPolygon (int i, const EuclideanProjection &proj)
 
MovingPolygon3D getMovingPolygon (double time, const EuclideanProjection &proj)
 
bool isContainment () const
 
void setContainment (bool b)
 
std::string toString ()
 
std::string toStringShort ()
 
std::string toOutput ()
 
std::string toOutput (int precision, bool tcpColumns)
 
std::vector< std::string > toStringList (int i, int j, int precision, int latLonExtraPrecision, bool tcpColumns)
 
SimpleMovingPoly getSimpleMovingPoly (int i)
 
SimpleMovingPoly getSimpleMovingPoly (double t)
 
bool contains (const Position &p, double t) const
 
bool contains2D (const Position &p, double t) const
 
BoundingRectangle getBoundingRectangle (double user_vel_time_extension)
 
BoundingRectangle getBoundingRectangle ()
 
bool hasError () const
 
bool hasMessage () const
 
std::string getMessage ()
 
std::string getMessageNoClear () const
 
void addWarning (std::string s) const
 
void addError (std::string s) const
 

Static Public Member Functions

static PolyPath pathFromState (const std::string &n, const SimplePoly &p, const Velocity &v, double tstart, double tend)
 
static PolyPath pathFromState (const std::string &n, const MovingPolygon3D &mp, EuclideanProjection proj, double tstart, double tend)
 
static std::string pathModeToString (PathMode m)
 
static PathMode parsePathMode (const std::string &s)
 

Private Attributes

std::vector< SimplePolypolyList
 
std::vector< double > times
 
std::vector< Velocityvlist
 
std::string label
 
std::string note
 
PathMode mode
 
ErrorLog error
 
bool modeSet
 
bool containment
 

Detailed Description

Polygons are arranged in "paths" similar to aircraft plans (and, in fact, this object can produce one – or more – faux-aircraft plans that approximate the area in question). The polygon is allowed to change shape as it travels along the path, but the number of vertices must remain constant. The shape at non-specified time points is linearly interpolated from the neighboring points.

(Note that the default mode has changed from MORPHING to AVG_VEL.)

Paths can have one of several modes: AVG_VEL (the default): Velocities are calculated between the average points of consecutive steps. Polygons do not need to have the same number of vertices at each step. The path starts to exist at the first time and stops existing at the last time. Vertical speed is based on the bottom of the steps. In the case of a single-step path, velocity is zero and time is ignored: the polygon always exists statically at that location. The time interval the path exists is either [t1,t2] or [0,+inf] (for 1-step paths) MORPHING: all polygons must have the same number of vertices. Velocities are calculated vertex by vertex between consecutive steps. The path starts to exist at the first time and stops existing at the last time. Vertical speed is based on the bottom of the steps. In the case of a single-step path, velocity is zero and time is ignored: the polygon always exists statically at that location. The time interval the path exists is either [t1,t2] or [0,+inf] (for 1-step paths) USER_VEL: Velocities are user-specified and applied to all vertices. Polygons do not need to have the same number of vertices at each step. The path starts to exist at the first time, and the last step will have an infinitely continuing velocity. The time interval the path exists is always [t1,+inf] USER_VEL_FINITE: As USER_VEL, but the path does not continue beyond the last step. (One-step paths are considered the same as USER_VEL.)
The last step is mostly ignored except for time and can be any non-null polygon. The time interval the path exists is always [t1,t2] USER_VEL_EVER: As USER_VEL, but the path also continues into the past from the first point (at least to time 0). The time interval the path exists is always [0,+inf]

While different modes can mimic many of the same behaviors, there are some internal optimizations when processing certain polygon modes. For example it is more efficient to use a static polygon than to use a USER_VEL polygon with zero velocity. Interpolating MORPHING polygons also can require more computation than other varieties.

Note: polygon support is experimental and the interface is subject to change!

Constructor & Destructor Documentation

◆ PolyPath() [1/4]

larcfm::PolyPath::PolyPath ( )

Constructor

◆ PolyPath() [2/4]

larcfm::PolyPath::PolyPath ( const std::string &  n)
explicit

Constructor with associated name

Parameters
nname string

◆ PolyPath() [3/4]

larcfm::PolyPath::PolyPath ( const std::string &  n,
const SimplePoly p 
)

Make a PolyPlan for a non-dynamic area p.

Parameters
p

◆ PolyPath() [4/4]

larcfm::PolyPath::PolyPath ( const std::string &  n,
const SimplePoly p,
double  t 
)

Construct a new (dynamic) path including polygon p at time t

Member Function Documentation

◆ addPolygon() [1/2]

void larcfm::PolyPath::addPolygon ( const SimplePoly p,
const Velocity v,
double  time 
)

Add a polygon with velocity information. If mode has not been already set, this defaults to USER_VEL mode.

Parameters
pposition
vvelocity
timestart time for this polygon

◆ addPolygon() [2/2]

void larcfm::PolyPath::addPolygon ( const SimplePoly p,
double  time 
)

Add a polygon without velocity data. If the mode has not been set, this defaults to MORPHING mode.

Parameters
ppolygon
timetime

◆ addVertex() [1/2]

void larcfm::PolyPath::addVertex ( const Position p,
double  bottom,
double  top,
double  time 
)

A quick and dirty method for building paths one point at a time. This does not check that there are the same number of points at each step – call validate() on this object when done to confirm that the final path is correct.

Parameters
pA new point.
bottompolygon's bottom altitude
toppolygon's top altitude
timethe time for the poly p is a vertex of

◆ addVertex() [2/2]

void larcfm::PolyPath::addVertex ( int  n,
const Position p 
)

This adds a vertex to every polygon on this path. The vertex will be added relative to the centroid in each case, so other polygons may need to be modified to match.

Parameters
nindex
pposition

◆ copy()

PolyPath larcfm::PolyPath::copy ( ) const

Return a deep copy of this path.

Returns
path of polygon

◆ getBoundingRectangle()

BoundingRectangle larcfm::PolyPath::getBoundingRectangle ( double  user_vel_time_extension)

Computes a large bounding rectangle around the moving polygon.

Note: for the USER_VEL AND USER_VEL_EVER types, the last polygon is extended "user_vel_time_extension" hours

Parameters
user_vel_time_extensiontime
Returns
bounding rectangle

◆ getFirstTime()

double larcfm::PolyPath::getFirstTime ( ) const

Returns the start time of this path. Static paths have a start time of 0.

Returns
first time

◆ getID()

string larcfm::PolyPath::getID ( ) const

Returns the name associated with this path

Returns
name

◆ getIndex()

int larcfm::PolyPath::getIndex ( double  time) const

Returns the step index associated with a particular time, if there is a match, otherwise returns a negative value. -1 indicates a time before the path begins. -x indicates a time after point (x-1), so a time between points 1 and 2 will return index -2. A time after the path will return -size-1.

Parameters
timetime
Returns
index

◆ getInitialMovingPolygon()

MovingPolygon3D larcfm::PolyPath::getInitialMovingPolygon ( int  i,
const EuclideanProjection &  proj 
)

This will return a moving polygon that starts at point i and ends at point i+1

Parameters
iindex
projprojection
Returns
polygon

◆ getLastPolyTime()

double larcfm::PolyPath::getLastPolyTime ( ) const

Returns the time associated with the last polygon in the path. Note that this may not be the same as getlastTime().

Returns
time

Returns the time of the last polygon in the path

◆ getLastTime()

double larcfm::PolyPath::getLastTime ( ) const

Returns the end time of this path. Static paths have an end time of 0. Continuing paths have an end time of POSITIVE_INFINITY

Returns
last time

◆ getMessage()

std::string larcfm::PolyPath::getMessage ( )
inlinevirtual

Return a string representation of any errors or warnings. Calling this method will clear any messages and reset both the error and warning status to none.

Returns
error and warning messages. If there are no messages, an empty string is returned.

Implements larcfm::ErrorReporter.

◆ getMessageNoClear()

std::string larcfm::PolyPath::getMessageNoClear ( ) const
inlinevirtual

Return a string representation of any errors or warnings. Calling this method will not clear the error or warning status (i.e., hasError() will return the same value before and after this call.)

Returns
error and warning messages. If there are no messages, an empty string is returned.

Implements larcfm::ErrorReporter.

◆ getMovingPolygon()

MovingPolygon3D larcfm::PolyPath::getMovingPolygon ( double  time,
const EuclideanProjection &  proj 
)

This will return a moving polygon that STARTS at time t (relative time 0) and ends at its segment end time.

Parameters
timetime
projprojection
Returns
polygon

◆ getNote()

string larcfm::PolyPath::getNote ( ) const

Get the note field.

Returns
note

◆ getPathMode()

PolyPath::PathMode larcfm::PolyPath::getPathMode ( ) const

Get the mode for this path. AVG_VEL (the default): Velocities are calculated between the average points of consecutive steps. Polygons do not need to have the same number of vertices at each step. The path starts to exist at the first time and stops existing at the last time. In the case of a single-step path, velocity is zero and time is ignored: the polygon always exists statically at that location. The time interval the path exists is either [t1,t2] or [0,+inf] (for 1-step paths) MORPHING: all polygons must have the same number of vertices. Velocities are calculated vertex by vertex between consecutive steps. The path starts to exist at the first time and stops existing at the last time. In the case of a single-step path, velocity is zero and time is ignored: the polygon always exists statically at that location. The time interval the path exists is either [t1,t2] or [0,+inf] (for 1-step paths) USER_VEL: Velocities are user-specified and applied to all vertices. Polygons do not need to have the same number of vertices at each step. The path starts to exist at the first time, and the last step will have an infinitely continuing velocity. The time interval the path exists is always [t1,+inf] USER_VEL_FINITE: As USER_VEL, but the path does not continue beyond the last step. (One-step paths are considered the same as USER_VEL.)
The last step is mostly ignored except for time and can be any non-null polygon. The time interval the path exists is always [t1,t2] USER_VEL_EVER: As USER_VEL, but the path also continues into the past from the first point (at least to time 0). The time interval the path exists is always [0,+inf]

Returns
path mode

◆ getPoly()

SimplePoly larcfm::PolyPath::getPoly ( int  n) const

Returns a copy of the poly at step index n.

Parameters
nindex
Returns
polygon

◆ getSegment()

int larcfm::PolyPath::getSegment ( double  tm) const

Return the segment number that contains 'time' in [s]. If the time is not contained in the flight plan then -1 is returned. If the time for point 1 is 10.0 and the time for point 2 is 20.0, then getSegment(10.0) will produce 0, getSegment(15.0) will produce 0, and getSegment(20.0) will produce 1.

Parameters
tmtime
Returns
segment number

◆ getTime()

double larcfm::PolyPath::getTime ( int  n) const

Returns the time for a given step index.

Parameters
nindex
Returns
time

◆ hasError()

bool larcfm::PolyPath::hasError ( ) const
inlinevirtual

Does this object have an error?

Returns
true if there is an error.

Implements larcfm::ErrorReporter.

◆ hasMessage()

bool larcfm::PolyPath::hasMessage ( ) const
inlinevirtual

Does this object have an error or a warning?

Returns
true if there is an error or warning.

Implements larcfm::ErrorReporter.

◆ initialVelocity()

Velocity larcfm::PolyPath::initialVelocity ( int  n)

Returns the initial velocity of this path, starting from a given step index.

Parameters
nindex
Returns
velocity

◆ interpolate()

SimplePoly larcfm::PolyPath::interpolate ( double  time) const

Returns an interpolated poly from an arbitrary time on this path. Returns null if the polygon does not exist at the given time.

Parameters
timetime
Returns
polygon

◆ isContinuing()

bool larcfm::PolyPath::isContinuing ( ) const

Return true if this PolyPath continues to exist past the defined path (it has a velocity, which may be zero, and no definite end point) This is the case if mode is USER_VEL or if there is only one step in the path. Note that static paths will also be continuing.

Returns
true, if continuing

◆ isLatLon()

bool larcfm::PolyPath::isLatLon ( ) const

Return true if this path contains any geodetic points.

Returns
true, if lat/lon

◆ isStatic()

bool larcfm::PolyPath::isStatic ( ) const

Return true if this PolyPath is static (it exists in a fixed location). This is the case if there is only one step in the path and the mode is MORPHING or AVG_VEL. Note that several optimizations are applied to static polygons that are not applied to a USER_VEL path with zero velocity (even though they ultimately have similar behaviors).

Returns
true, if static

◆ isUserVel()

bool larcfm::PolyPath::isUserVel ( ) const

Helper function to combine the 3 user vel modes

Returns
true, if user velocity

◆ makeVertexCountEqual()

void larcfm::PolyPath::makeVertexCountEqual ( )

Convert the polygons in this path so that all have the same number of vertices.

◆ position()

SimplePoly larcfm::PolyPath::position ( double  time) const

Interpolate the poly at the given time If time is outside the path's limit, return null.

Parameters
timetime
Returns
polygon

Interpolate the poly at the given time If time is outside the path's limit, return null.

Parameters
time
Returns

◆ remove()

void larcfm::PolyPath::remove ( int  n)

Remove a poly from this path, by step index.

Parameters
nindex

◆ removeVertex()

void larcfm::PolyPath::removeVertex ( int  vert)

Remove the nth vertex from all polygons on the path.

Parameters
vertindex of vertex to be removed.

◆ setID()

void larcfm::PolyPath::setID ( const std::string &  n)

Sets the name to be associated with this path.

Parameters
nnew name

◆ setPathMode()

void larcfm::PolyPath::setPathMode ( PathMode  m)

Set the mode for this path. Note that switching away from a USER_Vel* mode can cause a loss of stored velocity information. AVG_VEL (the default): Velocities are calculated between the average points of consecutive steps. Polygons do not need to have the same number of vertices at each step. The path starts to exist at the first time and stops existing at the last time. In the case of a single-step path, velocity is zero and time is ignored: the polygon always exists statically at that location. The time interval the path exists is either [t1,t2] or [0,+inf] (for 1-step paths) MORPHING: all polygons must have the same number of vertices. Velocities are calculated vertex by vertex between consecutive steps. The path starts to exist at the first time and stops existing at the last time. In the case of a single-step path, velocity is zero and time is ignored: the polygon always exists statically at that location. The time interval the path exists is either [t1,t2] or [0,+inf] (for 1-step paths) USER_VEL: Velocities are user-specified and applied to all vertices. Polygons do not need to have the same number of vertices at each step. The path starts to exist at the first time, and the last step will have an infinitely continuing velocity. The time interval the path exists is always [t1,+inf] USER_VEL_FINITE: As USER_VEL, but the path does not continue beyond the last step. (One-step paths are considered the same as USER_VEL.)
The last step is mostly ignored except for time and can be any non-null polygon. The time interval the path exists is always [t1,t2] USER_VEL_EVER: As USER_VEL, but the path also continues into the past from the first point (at least to time 0). The time interval the path exists is always [0,+inf]

Parameters
mpath mode

◆ setPolygon()

void larcfm::PolyPath::setPolygon ( int  i,
const SimplePoly p 
)

Set the polygon at index i to be a copy of p

Parameters
iindex
ppolygon

Set the polygon at index i to be a copy of p

◆ setTime()

void larcfm::PolyPath::setTime ( int  n,
double  t 
)

Sets the time t for a given step n. The order of times must be preserved.

Parameters
nindex
ttime

Sets the time t for a given step n. The order of times must be preserved.

◆ setVelocity()

void larcfm::PolyPath::setVelocity ( int  i,
const Velocity v 
)

Set the user velocity at index i to be v This only has effect if isCalculatedVelocities() is false.

Parameters
iindex
vvelocity

Set the user velocity at index i to be v This only has effect if isCalculatedVelocities() is false.

◆ size()

int larcfm::PolyPath::size ( ) const

Returns the number of time points in this path. Static paths will have a size of 1.

Returns
size

◆ timeshift()

void larcfm::PolyPath::timeshift ( double  shift)

Shift all times in the path by the given number of seconds.

Parameters
shiftAmount of shift.

◆ toOutput()

string larcfm::PolyPath::toOutput ( )

Returns a string representation of this path that is compatible with the PolyReader input format.

Returns
string representation

◆ toString()

string larcfm::PolyPath::toString ( )

Returns a string representation of this path.

◆ translate()

void larcfm::PolyPath::translate ( Vect3  off)

Translate the entire path by a Euclidean offset

Parameters
offEuclidean offset

◆ truncate()

PolyPath larcfm::PolyPath::truncate ( double  t)

Return a truncated version of this path that ends at time t. This will change a USER_VEL path into a USER_VEL_FINITE path.

Parameters
tThe time to halt the path.
Returns
A truncated path. If t ≤ the path's start time, then return an empty path. If t ≥ the path's end time, then return a copy of the original path.

◆ validate()

bool larcfm::PolyPath::validate ( ) const

Returns true if the polypath follows expected behaviors (i.e. increasing times and same size for each MORPHING poly). Otherwise this sets error messages.

Returns
true, if polypath performs expected behaviors

◆ velocity()

Velocity larcfm::PolyPath::velocity ( double  time)

Interpolate the averagePoint velocity at the given time If time is outside the path's limit, return invalid velocity.

Parameters
timetime
Returns
velocity

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