本文整理汇总了C++中TPPLPoly::Invert方法的典型用法代码示例。如果您正苦于以下问题:C++ TPPLPoly::Invert方法的具体用法?C++ TPPLPoly::Invert怎么用?C++ TPPLPoly::Invert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPPLPoly
的用法示例。
在下文中一共展示了TPPLPoly::Invert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTPPLPoly
// Initialize polypartition TPPLPoly from a list of indices and vertices
//
// verts - 3D polygon vertex vectors
// xind,yind - Indices of 3D vectors to extract as x and y coordinates for 2D
// triangulation computation.
// inds,size - Array of indices into the `verts` list
// isHole - Value for the hole flag, and to determine the orientation
static void initTPPLPoly(TPPLPoly& poly,
const std::vector<float>& verts,
int xind, int yind,
const GLuint* inds, int size,
bool isHole)
{
// Check for explicitly closed polygons (last and first vertices equal) and
// discard the last vertex in these cases. This is a pretty stupid
// convention, but the OGC have blessed it and now we've got a bunch of
// geospatial formats (kml, WKT, GeoJSON) which require it. Sigh.
// http://gis.stackexchange.com/questions/10308/why-do-valid-polygons-repeat-the-same-start-and-end-point/10309#10309
if (inds[0] == inds[size-1] ||
(verts[3*inds[0]+0] == verts[3*inds[size-1]+0] &&
verts[3*inds[0]+1] == verts[3*inds[size-1]+1] &&
verts[3*inds[0]+2] == verts[3*inds[size-1]+2]))
{
g_logger.warning_limited("Ignoring duplicate final vertex in explicitly closed polygon");
size -= 1;
}
// Copy into polypartition data structure
poly.Init(size);
for (int i = 0; i < size; ++i)
{
poly[i].x = verts[3*inds[i]+xind];
poly[i].y = verts[3*inds[i]+yind];
poly[i].id = inds[i];
}
int orientation = poly.GetOrientation();
// Invert so that outer = ccw, holes = cw
if ((orientation == TPPL_CW) ^ isHole)
poly.Invert();
poly.SetHole(isHole);
}