本文整理汇总了C++中Vertices::swap方法的典型用法代码示例。如果您正苦于以下问题:C++ Vertices::swap方法的具体用法?C++ Vertices::swap怎么用?C++ Vertices::swap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertices
的用法示例。
在下文中一共展示了Vertices::swap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertOutlineToTriangles
void ConvertOutlineToTriangles(Vertices &ioOutline,const QuickVec<int> &inSubPolys)
{
// Order polygons ...
int subs = inSubPolys.size();
if (subs<1)
return;
QuickVec<SubInfo> subInfo;
QuickVec<EdgePoint> edges(ioOutline.size());
int index = 0;
int groupId = 0;
for(int sub=0;sub<subs;sub++)
{
SubInfo info;
info.p0 = sub>0?inSubPolys[sub-1]:0;
info.size = inSubPolys[sub] - info.p0;
if (ioOutline[info.p0] == ioOutline[info.p0+info.size-1])
info.size--;
if (info.size>2)
{
UserPoint *p = &ioOutline[info.p0];
double area = 0.0;
for(int i=2;i<info.size;i++)
{
UserPoint v_prev = p[i-1] - p[0];
UserPoint v_next = p[i] - p[0];
area += v_prev.Cross(v_next);
}
bool reverse = area < 0;
int parent = -1;
for(int prev=subInfo.size()-1; prev>=0 && parent==-1; prev--)
{
if (subInfo[prev].contains(p[0]))
{
int prev_p0 = subInfo[prev].p0;
int prev_size = subInfo[prev].size;
int inside = PIP_MAYBE;
for(int test_point = 0; test_point<info.size && inside==PIP_MAYBE; test_point++)
{
inside = PointInPolygon( p[test_point], &ioOutline[prev_p0], prev_size);
if (inside==PIP_YES)
parent = prev;
}
}
}
if (parent==-1 || subInfo[parent].is_internal )
{
info.group = groupId++;
info.is_internal = false;
}
else
{
info.group = subInfo[parent].group;
info.is_internal = true;
}
info.first = &edges[index];
AddSubPoly(info.first,p,info.size,reverse!=info.is_internal);
if (sub<subs-1)
info.calcExtent();
index += info.size;
subInfo.push_back(info);
}
}
Vertices triangles;
for(int group=0;group<groupId;group++)
{
int first = -1;
int size = 0;
for(int sub=0;sub<subInfo.size();sub++)
{
SubInfo &info = subInfo[sub];
if (info.group==group)
{
if (first<0)
{
first = sub;
size = info.size;
}
else
{
LinkSubPolys(subInfo[first].first,info.first, info.link);
size += info.size + 2;
}
}
}
ConvertOutlineToTriangles(subInfo[first].first, size,triangles);
}
ioOutline.swap(triangles);
}