KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
kjb::qd::PixPathAc Class Reference

This is like PixPath except that it has an arclength cache, for teh performance. More...

#include <ppath_ac.h>

Inheritance diagram for kjb::qd::PixPathAc:
kjb::qd::PixPath

Public Member Functions

 PixPathAc (const PixPath &path)
 ctor copies from a PixPath. This is the only public ctor. More...
 
PixPathAcassign (unsigned index, const PixPoint &newp)
 assign a location in a PixPathAc More...
 
void swap (PixPathAc &vpp)
 swap representations of two PixPathAc objects More...
 
void push_back (const PixPoint &pp)
 add a new point to the end of the path More...
 
void clear ()
 throw away all points More...
 
PixPathAcappend (const_iterator begin, const_iterator end)
 append range of another path to this More...
 
PixPathAcappend (const PixPath &suffix)
 tack on a copy of a given path to the end of this path More...
 
int append_no_overlap (const PixPath &suffix)
 see description of PixPath::append_no_overlap() More...
 
PixPathAcow_reverse ()
 Reverse the order of this path, IN PLACE! More...
 
int arclength (std::vector< float > *alvec) const
 compute polygonal path length along path, ret. vector of results. More...
 
float arclength (size_t index) const
 Return the polygonal path length from front() to indexed point. More...
 
float arclength () const
 Return the polygonal path length for this path, front() to back() More...
 
size_t whereis_arclength_ratio (float) const
 Return index of PixPoint in path at a given arclength ratio. More...
 
size_t halfway () const
 Return index of PixPoint closest to but not beyond mid-arclength. More...
 
- Public Member Functions inherited from kjb::qd::PixPath
virtual ~PixPath ()
 obligatory dtor More...
 
const PixPointoperator[] (unsigned index) const
 Vector-like access to points (returning an rvalue). More...
 
virtual void pop_back ()
 
size_t size () const
 Number of points in the path (not the same as its length). More...
 
virtual void swap (PixPath &vpp)
 Swap the contents of two PixPaths. More...
 
const_iterator begin () const
 Return an iterator pointing to the first point in the path. More...
 
const_iterator end () const
 Rtn iterator pointing to just beyond the last point in the path. More...
 
const_reverse_iterator rbegin () const
 return a reverse-moving iterator to the last point in path More...
 
const_reverse_iterator rend () const
 return one-before-first iterator, in symmetry with end(). More...
 
PixPath subrange (unsigned, unsigned) const
 Returns a subrange of this PixPath object. More...
 
PixPath prefix (unsigned postlast) const
 Variation on subrange: return a prefix of this path (by value) More...
 
PixPath suffix (unsigned first) const
 Variation on subrange: return a suffix of this path (by value) More...
 
bool self_intersect (PixPoint *where=00) const
 Reveal whether the path has any self-intersections. More...
 
bool connected8 (bool emit_verbose_debug_output=false) const
 Is the path all connected, using 8-connectivity? More...
 
PixPoint front () const
 Return (by value) the first point in the path. More...
 
PixPoint back () const
 Return (by value) the last point in the path. More...
 
std::string str (const std::string &separator="\n") const
 Return the path as an ASCII string. More...
 
int save (const std::string &filename) const
 Saves the path to an ASCII file, returns NO_ERROR or ERROR. More...
 
bool operator== (const PixPath &) const
 Compare PixPaths; true iff the sequence of points is identical. More...
 
bool operator!= (const PixPath &other) const
 Compare PixPaths; true iff the sequence of points differs. More...
 
PixPath operator+ (const PixPath &) const
 Add, element-by-element, two PixPaths of the same length. More...
 
virtual PixPoint boundbox_min_min () const
 Return the corner point of a bounding box, with min x and y. More...
 
virtual PixPoint boundbox_max_max () const
 Similar to boundbox_min_min() but returns maximum x, y coords. More...
 
bool boundbox_within_boundbox (const PixPath &outer) const
 Test whether the axis-aligned bounding box of this path lies within the axis-aligned bounding box of the given path. More...
 
bool so_boundbox_holds_within (const PixPoint &q) const
 sort of like boundbox_within_boundbox but works on a single point More...
 
unsigned hits (const PixPoint &query_point) const
 Return number of times (maybe 0) the path hits a query point. More...
 
unsigned hits (const PixPath &query_path) const
 return number of common points between query_path and this path More...
 
PixPoint nearest (const PixPoint &, const_iterator *q=00) const
 Return the PixPath member closest to a given query point. More...
 
PixPoint nearest (const kjb::Vector2 &, const_iterator *q=00) const
 Return the PixPath member closest to the given real xy coordinates. More...
 
PixPathow_reverse ()
 Reverse the order of the points in the path (overwriting!) More...
 
PixPath reverse () const
 return a copy of this list after reversing the front-back order. More...
 
int cubic_fit (std::vector< float > *x, std::vector< float > *y, int ref=0) const
 Fit a cubic polynomial to the given list of x and y points. More...
 
PixPath interpolate (bool forbid_self_intersection=false) const
 This interpolates pixels between unconnected pixels. More...
 
PixPath cull_redundant_points () const
 Remove "unnecessary" points (ones that can be bresenham interpolated) More...
 
PixPath merge_redundant_slopes () const
 return a path with interior points removed but preserve all slopes. More...
 
PixPath expel (const_iterator) const
 Duplicate this path, except that we omit the indicated point. More...
 
PixPath expel (size_t index_of_unwanted_point) const
 Duplicate this path, except we omit the point with given index. More...
 
virtual float hausdorff_distance (const PixPath &that) const
 Compute the Hausdorff metric between two sets of points. More...
 
float closest_pair (const_iterator *pa=0, const_iterator *pb=0) const
 Find the distance between closest pair of points, ignoring adjacency. More...
 
float closest_adjacent_pair (const_iterator *pa=0) const
 Find a pair of adjacent points at least as close as any other. More...
 
bool has_subsequence (const PixPath &subseq) const
 tests whether a given path is a subsequence of this path More...
 
double angle_at (unsigned) const
 Compute included angle at some interior point in a path. More...
 
PixPoint::Integer bracket_cross_at (unsigned index) const
 cross product of line segs (index-1,index+1) x (index,index+1) More...
 
double heading_shift_at (unsigned index) const
 compute shift in "heading" angle at an interior point More...
 
bool intersect_at_with (unsigned preindex1, unsigned preindex2, unsigned *endpoint_intersector_index=00) const
 Test whether two segments of this path intersect. More...
 
bool do_segments_intersect (unsigned *s1=00, unsigned *s2=00, unsigned *count=00) const
 quadratic time test whether any 2 path segments cross each other More...
 
unsigned longest_segment (float *length=00) const
 return index of first point of longest segment More...
 
kjb::Vector2 centroid () const
 return the "mean" of the points (nonempty, none may be unused) More...
 
unsigned member_near_centroid () const
 return index of a member point nearest centroid() (qv) More...
 

Static Public Member Functions

static PixPathAc reserve (size_t potential_size=0)
 named ctor creates an empty path but reserves some memory for it More...
 
- Static Public Member Functions inherited from kjb::qd::PixPath
static PixPath reserve (size_t potential_size=0)
 named ctor creates an empty path but reserves some memory for it More...
 
static PixPath load (const std::string &filename)
 named ctor loads path coordinates from an ASCII file More...
 
static PixPath fenceposts (const PixPoint &pt_a, const PixPoint &pt_b, size_t sz)
 named ctor makes a path of evenly spaced points from a to b More...
 
static PixPath parse (const std::string &coords)
 named ctor builds from string-format list of coordinates More...
 

Protected Member Functions

 PixPathAc ()
 default ctor almost the same as the PixPath default ctor More...
 
 PixPathAc (size_t potential_size)
 ctor receives the size to reserve More...
 
 PixPathAc (const std::string &fn)
 ctor loads from a file, just like PixPath ctor More...
 
- Protected Member Functions inherited from kjb::qd::PixPath
 PixPath ()
 Default ctor starts as empty, and you can push points onto it. More...
 
 PixPath (size_t potential_size)
 ctor receives the size to reserve More...
 
 PixPath (const std::string &)
 ctor to load from an ASCII file More...
 
 PixPath (const PixPoint &, const PixPoint &, size_t)
 ctor makes evenly spaced points between termini More...
 
 PixPath (const std::string &, int)
 ctor that parses a string of characters More...
 

Additional Inherited Members

- Public Types inherited from kjb::qd::PixPath
typedef const PixPointconst_reference
 Reference to an element – required to use std::back_inserter(). More...
 
typedef PixPoint value_type
 Element type – required to use std::back_inserter() in c++11. More...
 
typedef VecPP::const_iterator const_iterator
 constant iterator through PixPath points More...
 
typedef
VecPP::const_reverse_iterator 
const_reverse_iterator
 constant reverse iterator through PixPath points More...
 

Detailed Description

This is like PixPath except that it has an arclength cache, for teh performance.

Constructor & Destructor Documentation

kjb::qd::PixPathAc::PixPathAc ( )
inlineprotected

default ctor almost the same as the PixPath default ctor

kjb::qd::PixPathAc::PixPathAc ( size_t  potential_size)
inlineprotected

ctor receives the size to reserve

kjb::qd::PixPathAc::PixPathAc ( const std::string &  fn)
inlineprotected

ctor loads from a file, just like PixPath ctor

kjb::qd::PixPathAc::PixPathAc ( const PixPath path)
inline

ctor copies from a PixPath. This is the only public ctor.

Member Function Documentation

PixPathAc& kjb::qd::PixPathAc::append ( const_iterator  begin,
const_iterator  end 
)
inlinevirtual

append range of another path to this

Reimplemented from kjb::qd::PixPath.

PixPathAc& kjb::qd::PixPathAc::append ( const PixPath suffix)
inlinevirtual

tack on a copy of a given path to the end of this path

Parameters
suffixpath to be concatenated
Returns
reference to this path after the update

Reimplemented from kjb::qd::PixPath.

int kjb::qd::PixPathAc::append_no_overlap ( const PixPath suffix)
inlinevirtual

see description of PixPath::append_no_overlap()

Reimplemented from kjb::qd::PixPath.

int kjb::qd::PixPathAc::arclength ( std::vector< float > *  alvec) const
inlinevirtual

compute polygonal path length along path, ret. vector of results.

There is little use for this method, but it is here for completeness. Instead you probably should use method arclength( size_t ) const.

Parameters
alvecPointer to vector of floats into which we return the cumulative polygonal path lengths from start to each vertex
Returns
kjb_c::ERROR or kjb_c::NO_ERROR as appropriate

Reimplemented from kjb::qd::PixPath.

float kjb::qd::PixPathAc::arclength ( size_t  index) const
inline

Return the polygonal path length from front() to indexed point.

Parameters
indexindex of vector at which to compute polygonal path length.
Returns
Polygonal path length computed as summed Euclidean distances.

This method makes the previous one sort of obsolete. I recommend you use this method.

float kjb::qd::PixPathAc::arclength ( ) const
virtual

Return the polygonal path length for this path, front() to back()

Reimplemented from kjb::qd::PixPath.

PixPathAc& kjb::qd::PixPathAc::assign ( unsigned  index,
const PixPoint newp 
)
inlinevirtual

assign a location in a PixPathAc

Reimplemented from kjb::qd::PixPath.

void kjb::qd::PixPathAc::clear ( )
inlinevirtual

throw away all points

Reimplemented from kjb::qd::PixPath.

size_t kjb::qd::PixPathAc::halfway ( ) const
inline

Return index of PixPoint closest to but not beyond mid-arclength.

PixPathAc& kjb::qd::PixPathAc::ow_reverse ( )
inline

Reverse the order of this path, IN PLACE!

void kjb::qd::PixPathAc::push_back ( const PixPoint pp)
inlinevirtual

add a new point to the end of the path

Reimplemented from kjb::qd::PixPath.

static PixPathAc kjb::qd::PixPathAc::reserve ( size_t  potential_size = 0)
inlinestatic

named ctor creates an empty path but reserves some memory for it

void kjb::qd::PixPathAc::swap ( PixPathAc vpp)
inline

swap representations of two PixPathAc objects

size_t kjb::qd::PixPathAc::whereis_arclength_ratio ( float  rat) const

Return index of PixPoint in path at a given arclength ratio.

Parameters
ratRatio of two polygonal path lengths. The denominator is the path length of whole path. The numerator is the path length from the path front to the index of the vertex to be returned, if that vertex exists. If it does not exist, then there must be a vertex "before" and "after" the desired point, and we return the index of the one "before," i.e., closer to the front. Confusing? Example: if rat=0.5 then you get the index of the vertex at halfway or nearest halfway without going over halfway. If the ratio is more than one, we return the index of the last point. One exception to the above description: If the ratio is not positive, we return the index of the front point.

The actual arclength at that point is at most the given value: it is the "floor" of possible arclength ratios. This has to search the path for the desired ratio. If the arclength is already memoized, it takes time O(log N) where N is the path size. If the arclength is not memoized, it takes time O(N).

Returns
index of the vertex as described above.
Exceptions
Too_smallif the path has no vertices

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