本文整理汇总了C++中Polygons::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygons::resize方法的具体用法?C++ Polygons::resize怎么用?C++ Polygons::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygons
的用法示例。
在下文中一共展示了Polygons::resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cairo_to_clipper
void cairo_to_clipper(cairo_t* cr,
Polygons &pg,
int scaling_factor,
Transform transform)
{
if (scaling_factor > 8 || scaling_factor < 0)
throw clipperCairoException("cairo_to_clipper: invalid scaling factor");
double scaling = std::pow((double)10, scaling_factor);
pg.clear();
cairo_path_t *path = cairo_copy_path_flat(cr);
int poly_count = 0;
for (int i = 0; i < path->num_data; i += path->data[i].header.length) {
if( path->data[i].header.type == CAIRO_PATH_CLOSE_PATH) poly_count++;
}
pg.resize(poly_count);
int i = 0, pc = 0;
while (pc < poly_count)
{
int vert_count = 1;
int j = i;
while(j < path->num_data &&
path->data[j].header.type != CAIRO_PATH_CLOSE_PATH)
{
if (path->data[j].header.type == CAIRO_PATH_LINE_TO)
vert_count++;
j += path->data[j].header.length;
}
pg[pc].resize(vert_count);
if (path->data[i].header.type != CAIRO_PATH_MOVE_TO) {
pg.resize(pc);
break;
}
pg[pc][0].X = Round(path->data[i+1].point.x *scaling);
pg[pc][0].Y = Round(path->data[i+1].point.y *scaling);
if (transform != tNone)
transform_point(cr, transform, &pg[pc][0].X, &pg[pc][0].Y);
i += path->data[i].header.length;
j = 1;
while (j < vert_count && i < path->num_data &&
path->data[i].header.type == CAIRO_PATH_LINE_TO) {
pg[pc][j].X = Round(path->data[i+1].point.x *scaling);
pg[pc][j].Y = Round(path->data[i+1].point.y *scaling);
if (transform != tNone)
transform_point(cr, transform, &pg[pc][j].X, &pg[pc][j].Y);
j++;
i += path->data[i].header.length;
}
pc++;
i += path->data[i].header.length;
}
cairo_path_destroy(path);
}
示例2: UpdatePolygons
void UpdatePolygons(bool updateSolutionOnly)
{
if (VertCount < 0) VertCount = -VertCount;
if (VertCount > 50) VertCount = 50;
if (VertCount < 3) VertCount = 3;
Clipper c;
if (!updateSolutionOnly)
{
delta = 0.0;
RECT r;
GetWindowRect(hStatus, &r);
int statusHeight = r.bottom - r.top;
GetClientRect(hWnd, &r);
sub.resize(1);
clp.resize(1);
//int ints[] = {0,0,0, -100,100, -100,100, 0};
//int ints2[] = {0, 100, 100, -200,0, -200,100, 100};
//MakePolygonFromInts(ints, 8, sub[0]);
//TranslatePolygon(sub[0], 100,220);
//MakePolygonFromInts(ints2, 8, clp[0]);
//TranslatePolygon(sub[1], 100,220);
MakeRandomPoly(sub[0], r.right, r.bottom - statusHeight, VertCount);
MakeRandomPoly(clp[0], r.right, r.bottom - statusHeight, VertCount);
//SaveToFile("subj.txt", sub);
//SaveToFile("clip.txt", clp);
}
c.AddPolygons(sub, ptSubject);
c.AddPolygons(clp, ptClip);
c.Execute(ct, sol, pft, pft);
if (delta != 0.0)
OffsetPolygons(sol,sol,delta,jt);
InvalidateRect(hWnd, NULL, false);
}