当前位置: 首页>>代码示例>>C++>>正文


C++ TriangleList::append方法代码示例

本文整理汇总了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;
}
开发者ID:mitya57,项目名称:interpolation-3d,代码行数:28,代码来源:3d.cpp

示例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;
}
开发者ID:mitya57,项目名称:interpolation-3d,代码行数:57,代码来源:3d.cpp

示例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;
	}

}
开发者ID:pythonxy,项目名称:Computer-Graphics,代码行数:65,代码来源:kdtree.cpp


注:本文中的TriangleList::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。