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

Expand, if possible, a PixPath to fill a specified minimum size. More...

#include <pathresize.h>

Inheritance diagram for kjb::qd::PixPath_expander:
kjb::qd::PixPath

Public Member Functions

 PixPath_expander (const PixPath &p, size_t sz, float distance_too_close)
 ctor builds a new path with at least as many points as requested. More...
 
- Public Member Functions inherited from kjb::qd::PixPath
virtual ~PixPath ()
 obligatory dtor More...
 
virtual PixPathassign (unsigned index, const PixPoint &newp)
 Change a member of the path to a new PixPoint. More...
 
const PixPointoperator[] (unsigned index) const
 Vector-like access to points (returning an rvalue). More...
 
virtual void push_back (const PixPoint &pp)
 Vector-like appending a new PixPoint on the end of the object. 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...
 
virtual void clear ()
 Discard all points. 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...
 
virtual PixPathappend (const_iterator begin, const_iterator end)
 Append a range from a given other path to the end of this path. More...
 
virtual PixPathappend (const PixPath &suffix)
 Append the given path to the tail of this path; overwrites. More...
 
virtual int append_no_overlap (const PixPath &suffix)
 Like append(), with extra avoid-the-duplicates fuss; overwrites. 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...
 
virtual int arclength (std::vector< float > *) const
 Return a vector of arclengths along the polygonal path. More...
 
virtual float arclength () const
 compute and return polygonal path length of this 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 PixPath cull_cozy_points (const PixPath &, float)
 return a new path after eliminating points that are too close 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...
 

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

Detailed Description

Expand, if possible, a PixPath to fill a specified minimum size.

This class will expand a PixPath to a specified size if at all possible. The result will be a PixPath at least as large as the given size, or the class will throw an exception. The resulting path might be larger than sz. Also, the result will not contain duplicate points.

Constructor & Destructor Documentation

kjb::qd::PixPath_expander::PixPath_expander ( const PixPath p,
size_t  sz,
float  distance_too_close 
)
inline

ctor builds a new path with at least as many points as requested.

Parameters
ppath used as initial estimate of what output should be like
szoutput should have at least this many points, or more
distance_too_closeadjacent points in output must be more distant than this (in units of pixels).

First, it will eliminate points that are too close together. Then, if necessary, it will interpolate new points between existing points.

Member Function Documentation

PixPath kjb::qd::PixPath_expander::cull_cozy_points ( const PixPath inpath,
float  distance_too_close 
)
static

return a new path after eliminating points that are too close

Copy the path, removing adjacent points that are too close together.

Returns
path modified so adjacent points are not too close together.

This uses a few heuristics to try to make the resulting path have a small Hausdorff distance from the original path. The path might curve back on itself, or even touch itself, but this method does not address that phenomenon.


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