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


C++ Poly::addVertex方法代码示例

本文整理汇总了C++中Poly::addVertex方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::addVertex方法的具体用法?C++ Poly::addVertex怎么用?C++ Poly::addVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Poly的用法示例。


在下文中一共展示了Poly::addVertex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fr_dirp

// directed (one end is wider than the other)
vector<Poly> dir_thick_line(const Vector2d &from, const Vector2d &to,
			    double fr_width, double to_width)
{
  vector<Poly> p;
  if (fr_width < 0.001 || to_width < 0.001) return p;
  if (to.squared_distance(from) < 0.001) return p;
  if ((fr_width < 0) != (to_width < 0)) return p;
  Poly poly;
  Vector2d fdir = (to-from); fdir.normalize();
  Vector2d tdir = fdir;
  fdir *= fr_width/4.;
  tdir *= to_width/4.;
  Vector2d fr_dirp(-fdir.y(), fdir.x());
  Vector2d to_dirp(-tdir.y(), tdir.x());
  poly.addVertex(from-fdir-fr_dirp);
  poly.addVertex(from-fdir+fr_dirp);
  poly.addVertex(to+tdir+to_dirp);
  poly.addVertex(to+tdir-to_dirp);
  p.push_back(poly);
  return p;
  //return Clipping::getOffset(poly, distance/4, jmiter, 0);

  // slow:
  // poly.addVertex(from);
  // poly.addVertex(to);
  // return Clipping::getOffset(poly, distance/2, jround, distance/2.);
}
开发者ID:danielprint,项目名称:repsnapper,代码行数:28,代码来源:geometry.cpp

示例2: dirp

vector<Poly> thick_line(const Vector2d &from, const Vector2d &to, double width)
{
  vector<Poly> p;
  if (width < 0.001) return p;
  if (to.squared_distance(from) < 0.001) return p;
  Poly poly;
  Vector2d dir = (to-from); dir.normalize(); dir *= width/4.;
  Vector2d dirp(-dir.y(),dir.x());
  poly.addVertex(from-dir-dirp);
  poly.addVertex(from-dir+dirp);
  poly.addVertex(to+dir+dirp);
  poly.addVertex(to+dir-dirp);
  p.push_back(poly);
  return Clipping::getOffset(poly, width/4, jmiter, 0);

  // slow:
  // poly.addVertex(from);
  // poly.addVertex(to);
  // return Clipping::getOffset(poly, distance/2, jround, distance/2.);
}
开发者ID:danielprint,项目名称:repsnapper,代码行数:20,代码来源:geometry.cpp

示例3: parse_poly

Poly* parse_poly(char* buffer)
{
    char* cvec;
    Poly* poly = new Poly();
    cvec =  strtok(buffer, ";");
    while (cvec!=NULL)
    {
        poly->addVertex(parse_vector(cvec));
        cvec =  strtok(NULL, ";");
    }
    return poly;
}
开发者ID:YSFHQ,项目名称:ys-net-tools,代码行数:12,代码来源:readPoly.cpp

示例4: convexHull2D

// calc convex hull and Min and Max of layer
// Monotone chain algo
Poly convexHull2D(const vector<Poly> &polygons)
{
  Poly hullPolygon;
  vector<struct sortable_point> P;
  for (uint i = 0; i<polygons.size(); i++)
    for (uint j = 0; j<polygons[i].size(); j++) {
      struct sortable_point point;
      point.v = polygons[i].vertices[j];
      P.push_back(point);
    }

  int n = P.size();
  vector<Vector2d> H(2*n);

  if (n<2) return hullPolygon;
  if (n<4) {
    for (int i = 0; i < n; i++)
      hullPolygon.addVertex(P[i].v);
    return hullPolygon;
  }
  sort(P.begin(), P.end());

  // Build lower hull
  int k=0;
  for (int i = 0; i < n; i++) {
    while (k >= 2 && cross_2(H[k-2], H[k-1], P[i].v) <= 0) k--;
    H[k++] = P[i].v;
  }

  // Build upper hull
  for (int i = n-2, t = k+1; i >= 0; i--) {
    while (k >= t && cross_2(H[k-2], H[k-1], P[i].v) <= 0) k--;
    H[k++] = P[i].v;
  }
  H.resize(k);
  hullPolygon.vertices = H;
  hullPolygon.reverse();
  return hullPolygon;
}
开发者ID:danielprint,项目名称:repsnapper,代码行数:41,代码来源:geometry.cpp


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