BRL-CAD
|
Data Structures | |
struct | bv_polygon |
struct | bg_poly_contour |
struct | bg_polygon |
struct | bg_polygons |
Macros | |
#define | CLIPPER_MAX 1518500249 |
Functions for working with polygons. More... | |
#define | BV_POLYGON_GENERAL 0 |
#define | BV_POLYGON_CIRCLE 1 |
#define | BV_POLYGON_ELLIPSE 2 |
#define | BV_POLYGON_RECTANGLE 3 |
#define | BV_POLYGON_SQUARE 4 |
#define | BV_POLYGON_UPDATE_DEFAULT 0 |
#define | BV_POLYGON_UPDATE_PROPS_ONLY 1 |
#define | BV_POLYGON_UPDATE_PT_SELECT 2 |
#define | BV_POLYGON_UPDATE_PT_MOVE 3 |
#define | BV_POLYGON_UPDATE_PT_APPEND 4 |
#define | BG_POLYGON_NULL {0, NULL, NULL, {0, 0, 0}, 0, 0} |
Enumerations | |
enum | triangulation_t { TRI_ANY = 0 , TRI_EAR_CLIPPING , TRI_CONSTRAINED_DELAUNAY , TRI_MONOTONE , TRI_HERTEL_MEHLHORN , TRI_KEIL_SNOEYINK , TRI_DELAUNAY } |
enum | bg_clip_t { bg_Union , bg_Difference , bg_Intersection , bg_Xor } |
Functions for working with polygons. More... | |
Functions | |
fastf_t | bg_find_polygon_area (struct bg_polygon *gpoly, fastf_t sf, matp_t model2view, fastf_t size) |
int | bg_polygons_overlap (struct bg_polygon *polyA, struct bg_polygon *polyB, matp_t model2view, const struct bn_tol *tol, fastf_t iscale) |
struct bg_polygon * | bg_clip_polygon (bg_clip_t op, struct bg_polygon *subj, struct bg_polygon *clip, fastf_t sf, matp_t model2view, matp_t view2model) |
struct bg_polygon * | bg_clip_polygons (bg_clip_t op, struct bg_polygons *subj, struct bg_polygons *clip, fastf_t sf, matp_t model2view, matp_t view2model) |
struct bg_polygon * | bg_polygon_fill_segments (struct bg_polygon *poly, vect2d_t line_slope, fastf_t line_spacing) |
void | bg_polygon_free (struct bg_polygon *gpp) |
void | bg_polygons_free (struct bg_polygons *gpp) |
void | bg_polygon_cpy (struct bg_polygon *dest, struct bg_polygon *src) |
int | bg_polygon_direction (size_t npts, const point2d_t *pts, const int *pt_indices) |
Test whether a polygon is clockwise (CW) or counter clockwise (CCW) More... | |
int | bg_pnt_in_polygon (size_t npts, const point2d_t *pts, const point2d_t *test_pt) |
test whether a point is inside a 2d polygon More... | |
int | bg_nested_polygon_triangulate (int **faces, int *num_faces, point2d_t **out_pts, int *num_outpts, const int *poly, const size_t poly_npts, const int **holes_array, const size_t *holes_npts, const size_t nholes, const int *steiner, const size_t steiner_npts, const point2d_t *pts, const size_t npts, triangulation_t type) |
Triangulate a 2D polygon with holes. More... | |
int | bg_polygon_triangulate (int **faces, int *num_faces, point2d_t **out_pts, int *num_outpts, const int *steiner, const size_t steiner_npts, const point2d_t *pts, const size_t npts, triangulation_t type) |
Triangulate a 2D polygon without holes. More... | |
int | bg_poly2tri_test (int **faces, int *num_faces, point2d_t **out_pts, int *num_outpts, const int *poly, const size_t poly_pnts, const int **holes_array, const size_t *holes_npts, const size_t nholes, const int *steiner, const size_t steiner_npts, const point2d_t *pts) |
int | bg_3d_polygon_area (fastf_t *area, size_t npts, const point_t *pts) |
Calculate the interior area of a polygon in a 3D plane in space. More... | |
int | bg_3d_polygon_centroid (point_t *cent, size_t npts, const point_t *pts) |
Calculate the centroid of a non self-intersecting polygon in a 3D plane in space. More... | |
int | bg_3d_polygon_sort_ccw (size_t npts, point_t *pts, plane_t cmp) |
Sort an array of point_ts, building a convex polygon, counter-clockwise. More... | |
int | bg_3d_polygon_make_pnts_planes (size_t *npts, point_t **pts, size_t neqs, const plane_t *eqs) |
Calculate for an array of plane_eqs, which build a polyhedron, the point_t's for each face. More... | |
void | bg_polygon_plot_2d (const char *filename, const point2d_t *pnts, int npnts, int r, int g, int b) |
void | bg_polygon_plot (const char *filename, const point_t *pnts, int npnts, int r, int g, int b) |
void | bg_tri_plot_2d (const char *filename, const int *faces, int num_faces, const point2d_t *pnts, int r, int g, int b) |
struct bv_scene_obj * | bv_create_polygon_obj (struct bview *v, struct bv_polygon *p) |
struct bv_scene_obj * | bv_create_polygon (struct bview *v, int type, int x, int y) |
int | bv_update_polygon (struct bv_scene_obj *s, struct bview *v, int utype) |
void | bv_polygon_vlist (struct bv_scene_obj *s) |
struct bv_scene_obj * | bv_select_polygon (struct bu_ptbl *objs, struct bview *v) |
int | bv_move_polygon (struct bv_scene_obj *s) |
struct bv_scene_obj * | bg_dup_view_polygon (const char *nname, struct bv_scene_obj *s) |
int | bv_polygon_csg (struct bu_ptbl *objs, struct bv_scene_obj *p, bg_clip_t op, int merge) |
#define CLIPPER_MAX 1518500249 |
#define BG_POLYGON_NULL {0, NULL, NULL, {0, 0, 0}, 0, 0} |
Definition at line 61 of file polygon_types.h.
enum triangulation_t |
Triangulation is the process of finding a set of triangles that as a set cover the same total surface area as a polygon. There are many algorithms for this operation, which have various trade-offs in speed and output quality.
Enumerator | |
---|---|
TRI_ANY | |
TRI_EAR_CLIPPING | |
TRI_CONSTRAINED_DELAUNAY | |
TRI_MONOTONE | |
TRI_HERTEL_MEHLHORN | |
TRI_KEIL_SNOEYINK | |
TRI_DELAUNAY |
enum bg_clip_t |
Functions for working with polygons.
Enumerator | |
---|---|
bg_Union | |
bg_Difference | |
bg_Intersection | |
bg_Xor |
Definition at line 40 of file polygon_types.h.
fastf_t bg_find_polygon_area | ( | struct bg_polygon * | gpoly, |
fastf_t | sf, | ||
matp_t | model2view, | ||
fastf_t | size | ||
) |
int bg_polygons_overlap | ( | struct bg_polygon * | polyA, |
struct bg_polygon * | polyB, | ||
matp_t | model2view, | ||
const struct bn_tol * | tol, | ||
fastf_t | iscale | ||
) |
struct bg_polygon * bg_clip_polygon | ( | bg_clip_t | op, |
struct bg_polygon * | subj, | ||
struct bg_polygon * | clip, | ||
fastf_t | sf, | ||
matp_t | model2view, | ||
matp_t | view2model | ||
) |
struct bg_polygon * bg_clip_polygons | ( | bg_clip_t | op, |
struct bg_polygons * | subj, | ||
struct bg_polygons * | clip, | ||
fastf_t | sf, | ||
matp_t | model2view, | ||
matp_t | view2model | ||
) |
struct bg_polygon * bg_polygon_fill_segments | ( | struct bg_polygon * | poly, |
vect2d_t | line_slope, | ||
fastf_t | line_spacing | ||
) |
void bg_polygon_free | ( | struct bg_polygon * | gpp | ) |
void bg_polygons_free | ( | struct bg_polygons * | gpp | ) |
void bg_polygon_cpy | ( | struct bg_polygon * | dest, |
struct bg_polygon * | src | ||
) |
int bg_polygon_direction | ( | size_t | npts, |
const point2d_t * | pts, | ||
const int * | pt_indices | ||
) |
Test whether a polygon is clockwise (CW) or counter clockwise (CCW)
Determine if a set of points forming a polygon are in clockwise or counter-clockwise order (see http://stackoverflow.com/a/1165943)
[in] | npts | number of points in polygon |
[in] | pts | array of points |
[in] | pt_indices | index values into pts array building a convex polygon. duplicated points aren't allowed. |
If pt_indices is NULL, the first npts points in pts will be checked in array order.
test whether a point is inside a 2d polygon
franklin's test for point inclusion within a polygon - see https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html for more details and the implementation file polygon.c for license info.
[in] | npts | number of points pts contains |
[in] | pts | array of points, building a convex polygon. duplicated points aren't allowed. the points in the array will be sorted counter-clockwise. |
[in] | test_pt | point to test. |
int bg_nested_polygon_triangulate | ( | int ** | faces, |
int * | num_faces, | ||
point2d_t ** | out_pts, | ||
int * | num_outpts, | ||
const int * | poly, | ||
const size_t | poly_npts, | ||
const int ** | holes_array, | ||
const size_t * | holes_npts, | ||
const size_t | nholes, | ||
const int * | steiner, | ||
const size_t | steiner_npts, | ||
const point2d_t * | pts, | ||
const size_t | npts, | ||
triangulation_t | type | ||
) |
Triangulate a 2D polygon with holes.
The primary polygon definition must be provided as an array of counter-clockwise indices to 2D points. If interior "hole" polygons are present, they must be passed in via the holes_array and their indices be ordered clockwise.
If no holes are present, caller should pass NULL for holes_array and holes_npts, and 0 for nholes, or use bg_polygon_triangulate instead.
[out] | faces | Set of faces in the triangulation, stored as integer indices to the pts. The first three indices are the vertices of the first face, the second three define the second face, and so forth. |
[out] | num_faces | Number of faces created |
[out] | out_pts | output points used by faces set. If an algorithm was selected that generates new points, this will be a new array. |
[out] | num_outpts | number of output points, if an algorithm was selected that generates new points |
[in] | poly | Non-hole polygon, defined as a CCW array of indices into the pts array. |
[in] | poly_npts | Number of points in non-hole polygon |
[in] | holes_array | Array of hole polygons, each defined as a CW array of indices into the pts array. |
[in] | holes_npts | Array of counts of points in hole polygons |
[in] | nholes | Number of hole polygons contained in holes_array |
[in] | steiner | Array of Steiner points |
[in] | steiner_npts | Number of Steiner points |
[in] | pts | Array of points defining a polygon. Duplicated points |
[in] | npts | Number of points pts contains |
[in] | type | Type of triangulation |
int bg_polygon_triangulate | ( | int ** | faces, |
int * | num_faces, | ||
point2d_t ** | out_pts, | ||
int * | num_outpts, | ||
const int * | steiner, | ||
const size_t | steiner_npts, | ||
const point2d_t * | pts, | ||
const size_t | npts, | ||
triangulation_t | type | ||
) |
Triangulate a 2D polygon without holes.
The polygon cannot have holes and must be provided as an array of counter-clockwise 2D points.
No points are added as part of this triangulation process - the result uses only those points in the original polygon, and hence only the face information is created as output.
The same fundamental routines are used here as in the bg_nested_polygon_triangulate logic - this is a convenience function to simplify calling the routine when specification of hole polygons is not needed.
[out] | faces | Set of faces in the triangulation, stored as integer indices to the pts. The first three indices are the vertices of the first face, the second three define the second face, and so forth. |
[out] | num_faces | Number of faces created |
[out] | out_pts | output points used by faces set, if an algorithm was selected that generates new points |
[out] | num_outpts | number of output points, if an algorithm was selected that generates new points |
[in] | steiner | Array of Steiner points |
[in] | steiner_npts | Number of Steiner points |
[in] | pts | Array of points defining a polygon. Duplicated points |
[in] | npts | Number of points pts contains |
[in] | type | Triangulation type |
int bg_poly2tri_test | ( | int ** | faces, |
int * | num_faces, | ||
point2d_t ** | out_pts, | ||
int * | num_outpts, | ||
const int * | poly, | ||
const size_t | poly_pnts, | ||
const int ** | holes_array, | ||
const size_t * | holes_npts, | ||
const size_t | nholes, | ||
const int * | steiner, | ||
const size_t | steiner_npts, | ||
const point2d_t * | pts | ||
) |
Calculate the interior area of a polygon in a 3D plane in space.
If npts > 4, Greens Theorem is used. The polygon mustn't be self-intersecting.
[out] | area | The interior area of the polygon |
[in] | npts | Number of point_ts, stored in pts |
[in] | pts | All points of the polygon, sorted counter-clockwise. The array mustn't contain duplicated or non-coplanar points. |
Calculate the centroid of a non self-intersecting polygon in a 3D plane in space.
[out] | cent | The centroid of the polygon |
[in] | npts | Number of point_ts, stored in pts |
[in] | pts | all points of the polygon, sorted counter-clockwise. The array mustn't contain duplicated points or non-coplanar points. |
Sort an array of point_ts, building a convex polygon, counter-clockwise.
[in] | npts | Number of points, pts contains |
pts | Array of point_ts, building a convex polygon. Duplicated points aren't allowed. The points in the array will be sorted counter-clockwise. | |
[in] | cmp | Plane equation of the polygon |
int bg_3d_polygon_make_pnts_planes | ( | size_t * | npts, |
point_t ** | pts, | ||
size_t | neqs, | ||
const plane_t * | eqs | ||
) |
Calculate for an array of plane_eqs, which build a polyhedron, the point_t's for each face.
[out] | npts | Array, which stores for every face the number of point_ts, added to pts. Needs to be allocated with npts[neqs] already. |
[out] | pts | 2D-array which stores the point_ts for every face. The array needs to be allocated with pts[neqs][neqs-1] already. |
[in] | neqs | Number of plane_ts, stored in eqs |
[in] | eqs | Array, that contains the plane equations, which build the polyhedron |
void bg_polygon_plot_2d | ( | const char * | filename, |
const point2d_t * | pnts, | ||
int | npnts, | ||
int | r, | ||
int | g, | ||
int | b | ||
) |
void bg_polygon_plot | ( | const char * | filename, |
const point_t * | pnts, | ||
int | npnts, | ||
int | r, | ||
int | g, | ||
int | b | ||
) |
void bg_tri_plot_2d | ( | const char * | filename, |
const int * | faces, | ||
int | num_faces, | ||
const point2d_t * | pnts, | ||
int | r, | ||
int | g, | ||
int | b | ||
) |
struct bv_scene_obj * bv_create_polygon_obj | ( | struct bview * | v, |
struct bv_polygon * | p | ||
) |
struct bv_scene_obj * bv_create_polygon | ( | struct bview * | v, |
int | type, | ||
int | x, | ||
int | y | ||
) |
int bv_update_polygon | ( | struct bv_scene_obj * | s, |
struct bview * | v, | ||
int | utype | ||
) |
void bv_polygon_vlist | ( | struct bv_scene_obj * | s | ) |
struct bv_scene_obj * bv_select_polygon | ( | struct bu_ptbl * | objs, |
struct bview * | v | ||
) |
int bv_move_polygon | ( | struct bv_scene_obj * | s | ) |
struct bv_scene_obj * bg_dup_view_polygon | ( | const char * | nname, |
struct bv_scene_obj * | s | ||
) |
int bv_polygon_csg | ( | struct bu_ptbl * | objs, |
struct bv_scene_obj * | p, | ||
bg_clip_t | op, | ||
int | merge | ||
) |