本文整理汇总了C++中TriangleList::append方法的典型用法代码示例。如果您正苦于以下问题:C++ TriangleList::append方法的具体用法?C++ TriangleList::append怎么用?C++ TriangleList::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriangleList
的用法示例。
在下文中一共展示了TriangleList::append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSurroundingTriangles
TriangleList getSurroundingTriangles(QPointF *points, quint32 size, quint32 layers,
Vertex v, QPointF *centerPtr) {
TriangleList result;
if (!v.layer) {
for (quint32 i = 0; i < size; ++i)
result.append(TRIANGLE(0, i, 0));
return result;
}
// inner part
result.append(TRIANGLE(v.layer - 1, v.sector, 2 * v.index));
if (v.index) {
result.append(TRIANGLE(v.layer - 1, v.sector, 2 * v.index - 1));
result.append(TRIANGLE(v.layer - 1, v.sector, 2 * v.index - 2));
} else
result.append(TRIANGLE(v.layer - 1, (v.sector + size - 1) % size, 2 * v.layer - 2));
// outer part
if (v.layer < layers) {
result.append(TRIANGLE(v.layer, v.sector, 2 * v.index));
result.append(TRIANGLE(v.layer, v.sector, 2 * v.index + 1));
if (v.index) {
result.append(TRIANGLE(v.layer, v.sector, 2 * v.index - 1));
} else {
result.append(TRIANGLE(v.layer, (v.sector + size - 1) % size, 2 * v.layer - 1));
result.append(TRIANGLE(v.layer, (v.sector + size - 1) % size, 2 * v.layer));
}
}
return result;
}
示例2: getCommonTriangles
TriangleList getCommonTriangles(QPointF *points, quint32 size, quint32 layers,
Vertex v1, Vertex v2, QPointF *centerPtr) {
TriangleList result;
if (v1.layer > v2.layer)
qSwap(v1, v2);
if (!v2.layer)
return result;
if (v1.layer == 0 && v2.layer == 1) {
result.append(TRIANGLE(0, v2.sector, 0));
result.append(TRIANGLE(0, (v2.sector + size - 1) % size, 0));
} else if (v1.sector == v2.sector) {
if (v1.layer == v2.layer) {
if (v2.index == v1.index + 1) {
if (v1.layer < layers)
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2 + 1));
result.append(TRIANGLE(v1.layer - 1, v1.sector, v1.index * 2));
} else if (v2.index == v1.index - 1) {
if (v1.layer < layers)
result.append(TRIANGLE(v1.layer, v1.sector, v2.index * 2 + 1));
result.append(TRIANGLE(v1.layer - 1, v1.sector, v2.index * 2));
}
}
else if (v2.layer == v1.layer + 1) {
if (v2.index == v1.index) {
if (v1.index)
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2 - 1));
else
result.append(TRIANGLE(v1.layer, (v1.sector + size - 1) % size, v1.layer * 2));
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2));
} else if (v2.index == v1.index + 1) {
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2));
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2 + 1));
}
}
} else if ((v2.sector == (v1.sector + 1) % size)
&& v1.index == v1.layer - 1 && v2.index == 0) {
if (v1.layer == v2.layer) {
result.append(TRIANGLE(v1.layer - 1, v1.sector, v1.index * 2));
if (v1.layer < layers)
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2 + 1));
} else if (v1.layer == v2.layer + 1) {
result.append(TRIANGLE(v2.layer, v1.sector, v1.index * 2 - 1));
result.append(TRIANGLE(v2.layer, v1.sector, v1.index * 2));
}
} else if ((v1.sector == (v2.sector + 1) % size)
&& v2.index == v2.layer - 1 && v1.index == 0) {
if (v1.layer == v2.layer) {
result.append(TRIANGLE(v1.layer - 1, v2.sector, v2.index * 2));
if (v1.layer < layers)
result.append(TRIANGLE(v1.layer, v2.sector, v2.index * 2 + 1));
} else if (v1.layer == v2.layer - 1) {
result.append(TRIANGLE(v1.layer, v2.sector, v2.index * 2 - 1));
result.append(TRIANGLE(v1.layer, v2.sector, v2.index * 2));
}
}
return result;
}
示例3: Subdivide
void KDTree::Subdivide(KDTreeNode &node,TriangleList *triangles,aabb& box,int depth)
{
if(!triangles)return ;
int count = triangles->GetCount();
if( count < minTrianglesPerleafNode ||(depth>=20&&count<=maxTrianglesPerleafNode))
{
node.SetTriangleList(triangles);
node.Type = LEFT;
node.box = box;
return ;
}
aabb frontBox,backBox;
real splitPosition;
bool foundOptimalSplit = findOptimalSplitPositon(triangles,box,depth,splitPosition,frontBox, backBox);
if(foundOptimalSplit == true)
{
node.Type = PATITION;
node.SetAxis(depth%Dimension);
node.SetSplitPosition(splitPosition);
node.box = box;
TriangleList *frontTriangles = new TriangleList();
TriangleList *backTriangles = new TriangleList();
for( int i=0; i < count; i++)
{
//Determine on which side of the split each
//triangle belongs.
TriangleNode * triangle= triangles->GetHead();
triangles->DeleteHead();
int position = partitionTriangle(triangle,depth,splitPosition);
triangle->next = NULL;
switch(position)
{
case kdBefore:
frontTriangles->append(triangle);
break;
case kdAfter:
backTriangles->append(triangle);
break;
case kdIntersection:
//frontTriangles->append(triangle);
backTriangles->append(triangle);
break;
}
}
node.m_lchild = new KDTreeNode();
node.m_rchild = new KDTreeNode();
Subdivide(*node.m_lchild,frontTriangles,frontBox,depth+1);
Subdivide(*node.m_rchild,backTriangles,backBox,depth+1);
}else
{
node.SetTriangleList(triangles);
node.Type = LEFT;
node.box = box;
}
}