本文整理汇总了C++中PolygonRef::area方法的典型用法代码示例。如果您正苦于以下问题:C++ PolygonRef::area方法的具体用法?C++ PolygonRef::area怎么用?C++ PolygonRef::area使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolygonRef
的用法示例。
在下文中一共展示了PolygonRef::area方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleWallStruts
void AreaSupport::handleWallStruts(
Polygons& supportLayer_this,
int supportMinAreaSqrt,
int supportTowerDiameter
)
{
for (unsigned int p = 0; p < supportLayer_this.size(); p++)
{
PolygonRef poly = supportLayer_this[p];
if (poly.size() < 6) // might be a single wall
{
PolygonRef poly = supportLayer_this[p];
int best = -1;
int best_length2 = -1;
for (unsigned int i = 0; i < poly.size(); i++)
{
int length2 = vSize2(poly[i] - poly[(i+1) % poly.size()]);
if (length2 > best_length2)
{
best = i;
best_length2 = length2;
}
}
if (best_length2 < supportMinAreaSqrt * supportMinAreaSqrt)
break; // this is a small area, not a wall!
// an estimate of the width of the area
int width = sqrt( poly.area() * poly.area() / best_length2 ); // sqrt (a^2 / l^2) instead of a / sqrt(l^2)
// add square tower (strut) in the middle of the wall
if (width < supportMinAreaSqrt)
{
Point mid = (poly[best] + poly[(best+1) % poly.size()] ) / 2;
Polygons struts;
PolygonRef strut = struts.newPoly();
strut.add(mid + Point( supportTowerDiameter/2, supportTowerDiameter/2));
strut.add(mid + Point(-supportTowerDiameter/2, supportTowerDiameter/2));
strut.add(mid + Point(-supportTowerDiameter/2, -supportTowerDiameter/2));
strut.add(mid + Point( supportTowerDiameter/2, -supportTowerDiameter/2));
supportLayer_this = supportLayer_this.unionPolygons(struts);
}
}
}
}