ICAROUS
|
#include <PolyPath.h>
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 |
SimplePoly & | getPolyRef (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< SimplePoly > | polyList |
std::vector< double > | times |
std::vector< Velocity > | vlist |
std::string | label |
std::string | note |
PathMode | mode |
ErrorLog | error |
bool | modeSet |
bool | containment |
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!
larcfm::PolyPath::PolyPath | ( | ) |
Constructor
|
explicit |
Constructor with associated name
n | name string |
larcfm::PolyPath::PolyPath | ( | const std::string & | n, |
const SimplePoly & | p | ||
) |
Make a PolyPlan for a non-dynamic area p.
p |
larcfm::PolyPath::PolyPath | ( | const std::string & | n, |
const SimplePoly & | p, | ||
double | t | ||
) |
Construct a new (dynamic) path including polygon p at time t
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.
p | position |
v | velocity |
time | start time for this polygon |
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.
p | polygon |
time | time |
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.
p | A new point. |
bottom | polygon's bottom altitude |
top | polygon's top altitude |
time | the time for the poly p is a vertex of |
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.
n | index |
p | position |
PolyPath larcfm::PolyPath::copy | ( | ) | const |
Return a deep copy of this path.
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
user_vel_time_extension | time |
double larcfm::PolyPath::getFirstTime | ( | ) | const |
Returns the start time of this path. Static paths have a start time of 0.
string larcfm::PolyPath::getID | ( | ) | const |
Returns the name associated with this path
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.
time | time |
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
i | index |
proj | projection |
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 the time of the last polygon in the path
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
|
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.
Implements larcfm::ErrorReporter.
|
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.)
Implements larcfm::ErrorReporter.
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.
time | time |
proj | projection |
string larcfm::PolyPath::getNote | ( | ) | const |
Get the note field.
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]
SimplePoly larcfm::PolyPath::getPoly | ( | int | n | ) | const |
Returns a copy of the poly at step index n.
n | index |
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.
tm | time |
double larcfm::PolyPath::getTime | ( | int | n | ) | const |
Returns the time for a given step index.
n | index |
|
inlinevirtual |
|
inlinevirtual |
Does this object have an error or a warning?
Implements larcfm::ErrorReporter.
Velocity larcfm::PolyPath::initialVelocity | ( | int | n | ) |
Returns the initial velocity of this path, starting from a given step index.
n | index |
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.
time | time |
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.
bool larcfm::PolyPath::isLatLon | ( | ) | const |
Return true if this path contains any geodetic points.
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).
bool larcfm::PolyPath::isUserVel | ( | ) | const |
Helper function to combine the 3 user vel modes
void larcfm::PolyPath::makeVertexCountEqual | ( | ) |
Convert the polygons in this path so that all have the same number of vertices.
SimplePoly larcfm::PolyPath::position | ( | double | time | ) | const |
Interpolate the poly at the given time If time is outside the path's limit, return null.
time | time |
Interpolate the poly at the given time If time is outside the path's limit, return null.
time |
void larcfm::PolyPath::remove | ( | int | n | ) |
Remove a poly from this path, by step index.
n | index |
void larcfm::PolyPath::removeVertex | ( | int | vert | ) |
Remove the nth vertex from all polygons on the path.
vert | index of vertex to be removed. |
void larcfm::PolyPath::setID | ( | const std::string & | n | ) |
Sets the name to be associated with this path.
n | new name |
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]
m | path mode |
void larcfm::PolyPath::setPolygon | ( | int | i, |
const SimplePoly & | p | ||
) |
Set the polygon at index i to be a copy of p
i | index |
p | polygon |
Set the polygon at index i to be a copy of p
void larcfm::PolyPath::setTime | ( | int | n, |
double | t | ||
) |
Sets the time t for a given step n. The order of times must be preserved.
n | index |
t | time |
Sets the time t for a given step n. The order of times must be preserved.
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.
i | index |
v | velocity |
Set the user velocity at index i to be v This only has effect if isCalculatedVelocities() is false.
int larcfm::PolyPath::size | ( | ) | const |
Returns the number of time points in this path. Static paths will have a size of 1.
void larcfm::PolyPath::timeshift | ( | double | shift | ) |
Shift all times in the path by the given number of seconds.
shift | Amount of shift. |
string larcfm::PolyPath::toOutput | ( | ) |
Returns a string representation of this path that is compatible with the PolyReader input format.
string larcfm::PolyPath::toString | ( | ) |
Returns a string representation of this path.
void larcfm::PolyPath::translate | ( | Vect3 | off | ) |
Translate the entire path by a Euclidean offset
off | Euclidean offset |
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.
t | The time to halt the path. |
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.
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.
time | time |