#include <vgl_polygon.h>
May have holes or multiple sections. The polygon is stored as a list of "sheets", each sheet is a list of 2d points. Iterate through all points using
for (unsigned int s = 0; s < polygon.num_sheets(); ++s) for (unsigned int p = 0; p < polygon[s].size(); ++p) do_something(polygon[s][p].x(), polygon[s][p].y());
Definition at line 31 of file vgl_polygon.h.
Public Types | |
| typedef vgl_point_2d< T > | point_t |
| typedef vcl_vector< point_t > | sheet_t |
Public Member Functions | |
| vgl_polygon () | |
| Default constructor - constructs an empty polygon with no sheets. | |
| vgl_polygon (unsigned int num_sheets) | |
| Construct an empty polygon, setting the number of (empty) sheets. | |
| vgl_polygon (point_t const p[], int n) | |
| Construct a single-sheet polygon from a list of n points. | |
| vgl_polygon (T const *x, T const *y, int n) | |
| Construct a single-sheet polygon from a list of n points. | |
| vgl_polygon (T const x_y[], int n) | |
| Construct a single-sheet polygon from a list of n points, given in (x,y) pairs. | |
| vgl_polygon (sheet_t const &points, unsigned n_sheets=1) | |
| Construct a single-sheet polygon from a sheet, i.e. | |
| vgl_polygon (vcl_vector< sheet_t > const &sheets) | |
| Construct by specifying all of its sheets. | |
| vgl_polygon (vgl_polygon const &a) | |
| ~vgl_polygon () | |
| bool | contains (point_t const &p) const |
| Returns true if p(x,y) is inside the polygon, else false. | |
| bool | contains (T x, T y) const |
| void | add_contour (point_t const p[], int n) |
| Add a single sheet to this polygon, specified by the given list of n points. | |
| void | add_contour (T const *x, T const *y, int n) |
| Add a single sheet to this polygon, specified by the given list of n points. | |
| void | add_contour (T const x_y[], int n) |
| Add a single sheet to this polygon, specified by the given list of n (x,y) pairs. | |
| void | clear () |
| Set the number of sheets to zero, so the polygon becomes empty. | |
| void | new_sheet () |
| Add a new (empty) sheet to the polygon. | |
| void | push_back (T x, T y) |
| Add a new point to the last sheet. | |
| void | push_back (point_t const &) |
| Add a new point to the last sheet. | |
| void | push_back (sheet_t const &s) |
| Add a pre-existing sheet to the polygon. | |
| unsigned int | num_sheets () const |
| unsigned int | num_vertices () const |
| sheet_t & | operator[] (int i) |
| Get the ith sheet. | |
| sheet_t const & | operator[] (int i) const |
| Get the ith sheet. | |
| vcl_ostream & | print (vcl_ostream &) const |
| Pretty print. | |
Protected Attributes | |
| vcl_vector< sheet_t > | sheets_ |
Related Functions | |
| (Note that these are not member functions.) | |
| T | vgl_area_signed (vgl_polygon< T > const &poly) |
| Computes the signed area of a polygon. | |
| T | vgl_area (vgl_polygon< T > const &poly) |
| The area of a polygon. | |
| T | vgl_area_enforce_orientation (vgl_polygon< T > const &poly) |
| The orientation enforced area of a polygon. | |
| vgl_polygon< T > | vgl_clip (const vgl_polygon< T > &poly1, const vgl_polygon< T > &poly2, vgl_clip_type op=vgl_clip_type_intersect) |
| Clip a polygon against another polygon. | |
| vgl_point_2d< T > | vgl_closest_point (vgl_polygon< T > const &poly, vgl_point_2d< T > const &point, bool closed=true) |
| Return the point on the given polygon closest to the given point. | |
| double | vgl_distance (vgl_polygon< T > const &poly, vgl_point_2d< T > const &point, bool closed=true) |
| distance between a point and the closest point on the polygon. | |
| bool | vgl_polygon_test_inside (T const *xs, T const *ys, unsigned n, T x, T y) |
| return true iff (x, y) is inside (or on boundary of) the given n-gon. | |
|
|||||
|
Definition at line 34 of file vgl_polygon.h. |
|
|||||
|
Definition at line 36 of file vgl_polygon.h. |
|
|||||||||
|
Default constructor - constructs an empty polygon with no sheets.
Definition at line 41 of file vgl_polygon.h. |
|
||||||||||
|
Construct an empty polygon, setting the number of (empty) sheets.
Definition at line 44 of file vgl_polygon.h. |
|
||||||||||||||||
|
Construct a single-sheet polygon from a list of n points. More sheets can be added later with the add_contour method. Definition at line 13 of file vgl_polygon.txx. |
|
||||||||||||||||||||
|
Construct a single-sheet polygon from a list of n points. More sheets can be added later with the add_contour method. Definition at line 21 of file vgl_polygon.txx. |
|
||||||||||||||||
|
Construct a single-sheet polygon from a list of n points, given in (x,y) pairs. The x_y array should thus be of size 2*n ! More sheets can be added later with the add_contour method. Definition at line 29 of file vgl_polygon.txx. |
|
||||||||||||||||
|
Construct a single-sheet polygon from a sheet, i.e. , a vector of 2D points. Note: n_sheets is only there to distinguish this from the next constructor for VC6 which seems to have a problem. Definition at line 62 of file vgl_polygon.h. |
|
||||||||||
|
Construct by specifying all of its sheets.
Definition at line 65 of file vgl_polygon.h. |
|
||||||||||
|
Definition at line 68 of file vgl_polygon.h. |
|
|||||||||
|
Definition at line 71 of file vgl_polygon.h. |
|
||||||||||||||||
|
Add a single sheet to this polygon, specified by the given list of n (x,y) pairs. The x_y array should thus be of size 2*n ! This increments the number of sheets by one. Definition at line 55 of file vgl_polygon.txx. |
|
||||||||||||||||||||
|
Add a single sheet to this polygon, specified by the given list of n points. This increments the number of sheets by one. Definition at line 46 of file vgl_polygon.txx. |
|
||||||||||||||||
|
Add a single sheet to this polygon, specified by the given list of n points. This increments the number of sheets by one. Definition at line 37 of file vgl_polygon.txx. |
|
|||||||||
|
Set the number of sheets to zero, so the polygon becomes empty.
Definition at line 94 of file vgl_polygon.h. |
|
||||||||||||||||
|
Definition at line 78 of file vgl_polygon.txx. |
|
||||||||||
|
Returns true if p(x,y) is inside the polygon, else false.
Definition at line 74 of file vgl_polygon.h. |
|
|||||||||
|
Add a new (empty) sheet to the polygon. This increments the number of sheets by one. Definition at line 98 of file vgl_polygon.h. |
|
|||||||||
|
Definition at line 109 of file vgl_polygon.h. |
|
|||||||||
|
Definition at line 111 of file vgl_polygon.h. |
|
||||||||||
|
Get the ith sheet.
Definition at line 119 of file vgl_polygon.h. |
|
||||||||||
|
Get the ith sheet.
Definition at line 116 of file vgl_polygon.h. |
|
||||||||||
|
Pretty print.
Definition at line 102 of file vgl_polygon.txx. |
|
||||||||||
|
Add a pre-existing sheet to the polygon.
Definition at line 107 of file vgl_polygon.h. |
|
||||||||||
|
Add a new point to the last sheet.
Definition at line 72 of file vgl_polygon.txx. |
|
||||||||||||||||
|
Add a new point to the last sheet.
Definition at line 66 of file vgl_polygon.txx. |
|
||||||||||
|
The area of a polygon.
Definition at line 27 of file vgl_area.txx. |
|
||||||||||
|
The orientation enforced area of a polygon.
Definition at line 39 of file vgl_area.txx. |
|
||||||||||
|
Computes the signed area of a polygon. The sign is positive if the polygon is oriented counter-clockwise (in RH coordinate system) and negative otherwise. For "polygons" consisting of more than one contour, the result is valid only if the contours are oriented consistently. That is, an enclosed contour must have opposite orientation to the enclosing contour.
Definition at line 11 of file vgl_area.txx. |
|
||||||||||||||||||||
|
Clip a polygon against another polygon. The two polygons poly1 and poly2 are combined with each other. The operation (intersection, union, etc) is given by parameter op.
Definition at line 139 of file vgl_clip.txx. |
|
||||||||||||||||||||
|
Return the point on the given polygon closest to the given point. If the third argument is "false", the edge from last to first point of each polygon sheet is not considered part of the polygon. Definition at line 286 of file vgl_closest_point.txx. |
|
||||||||||||||||||||
|
distance between a point and the closest point on the polygon. If the third argument is "false", the edge from last to first point of each polygon sheet is not considered part of the polygon. Definition at line 252 of file vgl_distance.txx. |
|
||||||||||||||||||||||||||||
|
return true iff (x, y) is inside (or on boundary of) the given n-gon.
Definition at line 12 of file vgl_polygon_test.txx. |
|
|||||
|
Definition at line 127 of file vgl_polygon.h. |
1.4.4