当前位置: 首页>>代码示例>>C++>>正文


C++ Polygons::resize方法代码示例

本文整理汇总了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);
    }
开发者ID:Alkaponj,项目名称:repsnapper,代码行数:57,代码来源:cairo_clipper.cpp

示例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); 
}
开发者ID:Alkaponj,项目名称:repsnapper,代码行数:40,代码来源:main.cpp


注:本文中的Polygons::resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。