本文整理汇总了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.);
}
示例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.);
}
示例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;
}
示例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;
}