本文整理汇总了C++中Vect_new_line_struct函数的典型用法代码示例。如果您正苦于以下问题:C++ Vect_new_line_struct函数的具体用法?C++ Vect_new_line_struct怎么用?C++ Vect_new_line_struct使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vect_new_line_struct函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: border
/*!
\brief Creates buffer around area.
\param Map vector map
\param area area id
\param da distance along major axis
\param db distance along minor axis
\param dalpha angle between 0x and major axis
\param round make corners round
\param caps add caps at line ends
\param tol maximum distance between theoretical arc and output segments
\param[out] oPoints output polygon outer border (ccw order)
\param[out] inner_count number of holes
\param[out] iPoints array of output polygon's holes (cw order)
*/
void Vect_area_buffer2(struct Map_info *Map, int area, double da, double db,
double dalpha, int round, int caps, double tol,
struct line_pnts **oPoints,
struct line_pnts ***iPoints, int *inner_count)
{
struct line_pnts *tPoints, *outer;
struct line_pnts **isles;
int isles_count = 0, n_isles;
int i, isle;
int more = 8;
int isles_allocated = 0;
G_debug(2, "Vect_area_buffer()");
/* initializations */
tPoints = Vect_new_line_struct();
n_isles = Vect_get_area_num_isles(Map, area);
isles_allocated = n_isles;
isles = G_malloc(isles_allocated * sizeof(struct line_pnts *));
/* outer contour */
outer = Vect_new_line_struct();
Vect_get_area_points(Map, area, outer);
/* does not work with zero length line segments */
Vect_line_prune(outer);
/* inner contours */
for (i = 0; i < n_isles; i++) {
isle = Vect_get_area_isle(Map, area, i);
Vect_get_isle_points(Map, isle, tPoints);
/* Check if the isle is big enough */
/*
if (Vect_line_length(tPoints) < 2*PI*max)
continue;
*/
/* does not work with zero length line segments */
Vect_line_prune(tPoints);
add_line_to_array(tPoints, &isles, &isles_count, &isles_allocated,
more);
tPoints = Vect_new_line_struct();
}
buffer_lines(outer, isles, isles_count, 0, da, db, dalpha, round, caps,
tol, oPoints, iPoints, inner_count);
Vect_destroy_line_struct(tPoints);
Vect_destroy_line_struct(outer);
destroy_lines_array(isles, isles_count);
return;
}
示例2: create_arcs
/**
* \brief Create network arcs (edge) based on given point vector map (nodes)
*
* \param file input file defining arcs
* \param Points input vector point map
* \param Out output vector map
* \param afield arcs layer
* \param nfield nodes layer
*
* \return number of new arcs
*/
int create_arcs(FILE * file, struct Map_info *Pnts,
struct Map_info *Out, int afield, int nfield)
{
char buff[1024];
int lcat, fcat, tcat;
int node1, node2;
int narcs;
struct line_pnts *points, *points2;
struct line_cats *cats;
points = Vect_new_line_struct();
points2 = Vect_new_line_struct();
points = Vect_new_line_struct();
cats = Vect_new_cats_struct();
narcs = 0;
while (G_getl2(buff, sizeof(buff) - 1, file)) {
if (sscanf(buff, "%d%d%d", &lcat, &fcat, &tcat) != 3)
G_fatal_error(_("Error reading file: '%s'"), buff);
node1 = find_node(Pnts, afield, fcat);
node2 = find_node(Pnts, afield, tcat);
if (node1 < 1 || node2 < 1) {
G_warning(_("Skipping arc %d"), lcat);
continue;
}
/* geometry */
Vect_read_line(Pnts, points, cats, node1);
field2n(cats, nfield);
Vect_write_line(Out, GV_POINT, points, cats);
Vect_read_line(Pnts, points2, cats, node2);
field2n(cats, nfield);
Vect_write_line(Out, GV_POINT, points2, cats);
Vect_append_points(points, points2, GV_FORWARD);
/* category */
Vect_reset_cats(cats);
Vect_cat_set(cats, afield, lcat);
Vect_write_line(Out, GV_LINE, points, cats);
narcs++;
}
Vect_destroy_line_struct(points);
Vect_destroy_cats_struct(cats);
return narcs;
}
示例3: Vect_line_buffer
/*!
\brief Creates buffer around line.
See also Vect_line_buffer().
\param InPoints input line geometry
\param da distance along major axis
\param db distance along minor axis
\param dalpha angle between 0x and major axis
\param round make corners round
\param caps add caps at line ends
\param tol maximum distance between theoretical arc and output segments
\param[out] oPoints output polygon outer border (ccw order)
\param[out] inner_count number of holes
\param[out] iPoints array of output polygon's holes (cw order)
*/
void Vect_line_buffer2(struct line_pnts *Points, double da, double db,
double dalpha, int round, int caps, double tol,
struct line_pnts **oPoints,
struct line_pnts ***iPoints, int *inner_count)
{
struct planar_graph *pg;
struct line_pnts *tPoints, *outer;
struct line_pnts **isles;
int isles_count = 0;
int res, winding;
int more = 8;
int isles_allocated = 0;
G_debug(2, "Vect_line_buffer()");
Vect_line_prune(Points);
if (Points->n_points == 1)
return Vect_point_buffer2(Points->x[0], Points->y[0], da, db,
dalpha, round, tol, oPoints);
/* initializations */
tPoints = Vect_new_line_struct();
isles = NULL;
pg = pg_create(Points);
/* outer contour */
outer = Vect_new_line_struct();
extract_outer_contour(pg, 0, outer);
/* inner contours */
res = extract_inner_contour(pg, &winding, tPoints);
while (res != 0) {
add_line_to_array(tPoints, &isles, &isles_count, &isles_allocated,
more);
tPoints = Vect_new_line_struct();
res = extract_inner_contour(pg, &winding, tPoints);
}
buffer_lines(outer, isles, isles_count, RIGHT_SIDE, da, db, dalpha, round,
caps, tol, oPoints, iPoints, inner_count);
Vect_destroy_line_struct(tPoints);
Vect_destroy_line_struct(outer);
destroy_lines_array(isles, isles_count);
pg_destroy_struct(pg);
return;
}
示例4: G_site_put
/* Writes a site to file open on fptr. */
int G_site_put(struct Map_info *Map, const Site * s)
{
static struct line_pnts *Points = NULL;
static struct line_cats *Cats = NULL;
if (Points == NULL)
Points = Vect_new_line_struct();
if (Cats == NULL)
Cats = Vect_new_cats_struct();
Vect_reset_line(Points);
Vect_reset_cats(Cats);
/* no 3D support so far: s->dim[0] */
Vect_append_point(Points, s->east, s->north, 0.0);
G_debug(4, "cattype = %d", s->cattype);
if (s->cattype == FCELL_TYPE || s->cattype == DCELL_TYPE)
G_fatal_error(_("Category must be integer"));
if (s->cattype == CELL_TYPE)
Vect_cat_set(Cats, 1, s->ccat);
Vect_write_line(Map, GV_POINT, Points, Cats);
return 0;
}
示例5: QgsAbstractFeatureIterator
QgsGrassFeatureIterator::QgsGrassFeatureIterator( QgsGrassProvider* p, const QgsFeatureRequest& request )
: QgsAbstractFeatureIterator( request ), P( p )
{
// make sure that only one iterator is active
if ( P->mActiveIterator )
{
QgsMessageLog::logMessage( QObject::tr( "Already active iterator on this provider was closed." ), QObject::tr( "GRASS" ) );
P->mActiveIterator->close();
}
P->mActiveIterator = this;
// check if outdated and update if necessary
P->ensureUpdated();
// Init structures
mPoints = Vect_new_line_struct();
mCats = Vect_new_cats_struct();
mList = Vect_new_list();
// Create selection array
allocateSelection( P->mMap );
resetSelection( 1 );
if ( request.filterType() == QgsFeatureRequest::FilterRect )
{
setSelectionRect( request.filterRect(), request.flags() & QgsFeatureRequest::ExactIntersect );
}
else
{
// TODO: implement fast lookup by feature id
//no filter - use all features
resetSelection( 1 );
}
}
示例6: plot_area
/* create paths for area and islands */
static int plot_area(struct Map_info *P_map, int area, double shift)
{
struct line_pnts *Points;
int j, ret, ni, island;
/* allocate memory for coordinates */
Points = Vect_new_line_struct();
/* plot areas */
if (0 > (ret = Vect_get_area_points(P_map, area, Points))) {
if (ret == -1)
G_warning(_("Read error in vector map"));
return 0;
}
construct_path(Points, shift, WHOLE_PATH);
/* plot islands */
ni = Vect_get_area_num_isles(P_map, area);
for (j = 0; j < ni; j++) {
island = Vect_get_area_isle(P_map, area, j);
if (0 > (ret = Vect_get_isle_points(P_map, island, Points))) {
if (ret == -1)
G_warning(_("Read error in vector map"));
return -1;
}
construct_path(Points, shift, WHOLE_PATH);
}
return 1;
}
示例7: Vect_get_area_perimeter
double Vect_get_area_perimeter(const struct Map_info *Map, int area)
{
const struct Plus_head *Plus;
struct P_area *Area;
struct line_pnts *Points;
double d;
int i;
G_debug(3, "Vect_get_area_perimeter(): area = %d", area);
Points = Vect_new_line_struct();
Plus = &(Map->plus);
Area = Plus->Area[area];
Vect_get_area_points(Map, area, Points);
Vect_line_prune(Points);
d = Vect_line_geodesic_length(Points);
/* adding island perimeters */
for (i = 0; i < Area->n_isles; i++) {
Vect_get_isle_points(Map, Area->isles[i], Points);
Vect_line_prune(Points);
d += Vect_line_geodesic_length(Points);
}
Vect_destroy_line_struct(Points);
G_debug(3, " perimeter = %f", d);
return (d);
}
示例8: Vect_get_area_area
/*!
\brief Returns area of area without areas of isles
\param Map vector map
\param area area id
\return area of area without areas of isles
*/
double Vect_get_area_area(const struct Map_info *Map, int area)
{
const struct Plus_head *Plus;
struct P_area *Area;
struct line_pnts *Points;
double size;
int i;
static int first_time = 1;
G_debug(3, "Vect_get_area_area(): area = %d", area);
if (first_time == 1) {
G_begin_polygon_area_calculations();
first_time = 0;
}
Points = Vect_new_line_struct();
Plus = &(Map->plus);
Area = Plus->Area[area];
Vect_get_area_points(Map, area, Points);
size = G_area_of_polygon(Points->x, Points->y, Points->n_points);
/* substructing island areas */
for (i = 0; i < Area->n_isles; i++) {
Vect_get_isle_points(Map, Area->isles[i], Points);
size -= G_area_of_polygon(Points->x, Points->y, Points->n_points);
}
Vect_destroy_line_struct(Points);
G_debug(3, " area = %f", size);
return (size);
}
示例9: points
/*!
\brief Get area boundary points (native format)
Used by Vect_build_line_area() and Vect_get_area_points().
\param Map pointer to Map_info struct
\param lines array of boundary lines
\param n_lines number of lines in array
\param[out] APoints pointer to output line_pnts struct
\return number of points
\return -1 on error
*/
int Vect__get_area_points_nat(const struct Map_info *Map, const plus_t *lines, int n_lines,
struct line_pnts *BPoints)
{
int i, line, aline, dir;
static struct line_pnts *Points;
if (!Points)
Points = Vect_new_line_struct();
Vect_reset_line(BPoints);
for (i = 0; i < n_lines; i++) {
line = lines[i];
aline = abs(line);
G_debug(5, " append line(%d) = %d", i, line);
if (0 > Vect_read_line(Map, Points, NULL, aline))
return -1;
dir = line > 0 ? GV_FORWARD : GV_BACKWARD;
Vect_append_points(BPoints, Points, dir);
BPoints->n_points--; /* skip last point, avoids duplicates */
}
BPoints->n_points++; /* close polygon */
return BPoints->n_points;
}
示例10: load_lines
/** Get the lines and boundaries from the map and load them in an array
*/
void load_lines(struct Map_info *map, struct Point **points, int *num_points,
struct Line **lines, int *num_lines)
{
int index_line = 0;
int index_point = 0;
struct line_pnts *sites;
struct line_cats *cats;
int cat = 0;
int type;
sites = Vect_new_line_struct();
cats = Vect_new_cats_struct();
while ((type = Vect_read_next_line(map, sites, cats)) > -1) {
if (type != GV_LINE && type != GV_BOUNDARY && type != GV_POINT)
continue;
if (type == GV_LINE)
process_line(sites, points, &index_point, lines, &index_line, -1);
else if (type == GV_BOUNDARY)
process_boundary(sites, points, &index_point, lines, &index_line,
cat++);
else if (type == GV_POINT)
process_point(sites, points, &index_point, -1);
}
*num_points = index_point;
*num_lines = index_line;
Vect_destroy_line_struct(sites);
Vect_destroy_cats_struct(cats);
}
示例11: Vect_tin_get_z
/*!
\brief Calculates z coordinate for point from TIN
\param Map pointer to vector map
\param tx,ty point coordinates
\param[out] tz z-coordinate of point
\param[out] angle angle
\param[out] slope slope
\return 1 on success,
\return 0 point is not in area,
\return -1 area has not 4 points or has island
*/
int
Vect_tin_get_z(struct Map_info *Map,
double tx, double ty, double *tz, double *angle, double *slope)
{
int i, area, n_points;
struct Plus_head *Plus;
P_AREA *Area;
static struct line_pnts *Points;
static int first_time = 1;
double *x, *y, *z;
double vx1, vx2, vy1, vy2, vz1, vz2;
double a, b, c, d;
/* TODO angle, slope */
Plus = &(Map->plus);
if (first_time == 1) {
Points = Vect_new_line_struct();
first_time = 0;
}
area = Vect_find_area(Map, tx, ty);
G_debug(3, "TIN: area = %d", area);
if (area == 0)
return 0;
Area = Plus->Area[area];
if (Area->n_isles > 0)
return -1;
Vect_get_area_points(Map, area, Points);
n_points = Points->n_points;
if (n_points != 4)
return -1;
x = Points->x;
y = Points->y;
z = Points->z;
for (i = 0; i < 3; i++) {
G_debug(3, "TIN: %d %f %f %f", i, x[i], y[i], z[i]);
}
vx1 = x[1] - x[0];
vy1 = y[1] - y[0];
vz1 = z[1] - z[0];
vx2 = x[2] - x[0];
vy2 = y[2] - y[0];
vz2 = z[2] - z[0];
a = vy1 * vz2 - vy2 * vz1;
b = vz1 * vx2 - vz2 * vx1;
c = vx1 * vy2 - vx2 * vy1;
d = -a * x[0] - b * y[0] - c * z[0];
/* OK ? */
*tz = -(d + a * tx + b * ty) / c;
G_debug(3, "TIN: z = %f", *tz);
return 1;
}
示例12: Vect_new_line_struct
QgsGrassFeatureIterator::QgsGrassFeatureIterator( QgsGrassFeatureSource* source, bool ownSource, const QgsFeatureRequest& request )
: QgsAbstractFeatureIteratorFromSource<QgsGrassFeatureSource>( source, ownSource, request )
{
sMutex.lock();
// Init structures
mPoints = Vect_new_line_struct();
mCats = Vect_new_cats_struct();
mList = Vect_new_list();
// Create selection array
allocateSelection( mSource->mMap );
resetSelection( 1 );
if ( request.filterType() == QgsFeatureRequest::FilterRect )
{
setSelectionRect( request.filterRect(), request.flags() & QgsFeatureRequest::ExactIntersect );
}
else
{
// TODO: implement fast lookup by feature id
//no filter - use all features
resetSelection( 1 );
}
}
示例13: P_estimate_splinestep
double P_estimate_splinestep(struct Map_info *Map, double *dens, double *dist)
{
int type, npoints = 0;
double xmin = 0, xmax = 0, ymin = 0, ymax = 0;
double x, y, z;
struct line_pnts *points;
struct line_cats *categories;
struct bound_box region_box;
struct Cell_head orig;
G_get_set_window(&orig);
Vect_region_box(&orig, ®ion_box);
points = Vect_new_line_struct();
categories = Vect_new_cats_struct();
Vect_rewind(Map);
while ((type = Vect_read_next_line(Map, points, categories)) > 0) {
if (!(type & GV_POINT))
continue;
x = points->x[0];
y = points->y[0];
if (points->z != NULL)
z = points->z[0];
else
z = 0.0;
/* only use points in current region */
if (Vect_point_in_box(x, y, z, ®ion_box)) {
npoints++;
if (npoints > 1) {
if (xmin > x)
xmin = x;
else if (xmax < x)
xmax = x;
if (ymin > y)
ymin = y;
else if (ymax < y)
ymax = y;
}
else {
xmin = xmax = x;
ymin = ymax = y;
}
}
}
if (npoints > 0) {
/* estimated average distance between points in map units */
*dist = sqrt(((xmax - xmin) * (ymax - ymin)) / npoints);
/* estimated point density as number of points per square map unit */
*dens = npoints / ((xmax - xmin) * (ymax - ymin));
return 0;
}
else {
return -1;
}
}
示例14: G_site_get
/*-
* Reads ptr and returns 0 on success,
* -1 on EOF,
* -2 on other fatal error or insufficient data,
* 1 on format mismatch (extra data)
*/
int G_site_get(struct Map_info *Map, Site * s)
{
int i, type, cat;
static struct line_pnts *Points = NULL;
static struct line_cats *Cats = NULL;
SITE_ATT *sa;
if (Points == NULL)
Points = Vect_new_line_struct();
if (Cats == NULL)
Cats = Vect_new_cats_struct();
while (1) {
type = Vect_read_next_line(Map, Points, Cats);
if (type == -1)
return -2; /* Error */
if (type == -2)
return -1; /* EOF */
if (type != GV_POINT)
continue; /* Is not point */
Vect_cat_get(Cats, 1, &cat);
G_debug(4, "Site: %f|%f|%f|#%d", Points->x[0], Points->y[0],
Points->z[0], cat);
s->east = Points->x[0];
s->north = Points->y[0];
if (Vect_is_3d(Map))
s->dim[0] = Points->z[0];
s->ccat = cat;
/* find att */
if (Map->n_site_att > 0) {
sa = (SITE_ATT *) bsearch((void *)&cat, (void *)Map->site_att,
Map->n_site_att, sizeof(SITE_ATT),
site_att_cmp);
if (sa == NULL) {
G_warning(_("Attributes for category %d not found"), cat);
for (i = 0; i < Map->n_site_dbl; i++)
s->dbl_att[i] = 0;
for (i = 0; i < Map->n_site_str; i++)
G_strncpy(s->str_att[i], "", MAX_SITE_STRING);
}
else {
for (i = 0; i < Map->n_site_dbl; i++)
s->dbl_att[i] = sa->dbl[i];
for (i = 0; i < Map->n_site_str; i++)
G_strncpy(s->str_att[i], sa->str[i], MAX_SITE_STRING);
}
}
return 0;
}
}
示例15: pie
int
pie(double cx, double cy, int size, double *val, int ncols, COLOR * ocolor,
COLOR * colors)
{
int i, j, n;
double a, end_ang, ang, tot_sum, sum, step, r;
double x, y;
struct line_pnts *Points;
G_debug(4, "pie(): cx = %f cy = %f", cx, cy);
Points = Vect_new_line_struct();
/* Calc sum */
tot_sum = 0;
for (i = 0; i < ncols; i++)
tot_sum += val[i];
step = PI / 180;
r = (D_d_to_u_col(2) - D_d_to_u_col(1)) * size / 2; /* do it better */
/* Draw polygon for each value */
sum = 0;
ang = 0;
for (i = 0; i < ncols; i++) {
sum += val[i];
end_ang = 2 * PI * sum / tot_sum;
Vect_reset_line(Points);
if (val[0] != tot_sum) /* all in one slice, don't draw line to center */
Vect_append_point(Points, cx, cy, 0);
n = (int)ceil((end_ang - ang) / step);
for (j = 0, a = ang; j <= n; j++, a += step) {
if (a > end_ang)
a = end_ang;
x = cx + r * cos(a);
y = cy + r * sin(a);
Vect_append_point(Points, x, y, 0);
}
ang = end_ang;
if (val[0] != tot_sum)
Vect_append_point(Points, cx, cy, 0);
if (!colors[i].none) {
D_RGB_color(colors[i].r, colors[i].g, colors[i].b);
D_polygon_abs(Points->x, Points->y, Points->n_points);
}
D_RGB_color(ocolor->r, ocolor->g, ocolor->b);
D_polyline_abs(Points->x, Points->y, Points->n_points);
}
Vect_destroy_line_struct(Points);
return 0;
}