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


C++ Tesselator::getVertices方法代码示例

本文整理汇总了C++中Tesselator::getVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ Tesselator::getVertices方法的具体用法?C++ Tesselator::getVertices怎么用?C++ Tesselator::getVertices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tesselator的用法示例。


在下文中一共展示了Tesselator::getVertices方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Output

void  Output(double* OutputCoords[3], int* OutputIndices[3])
{
	if (tess.getIndices().size() == 0 ||OutputIndices == NULL || OutputIndices == NULL)
	{
		return;
	}
	std::vector<TVec3d>::iterator itr = tess.getVertices().begin();
	for (int i = 0;itr != tess.getVertices().end(); itr++, i++)
	{
		OutputCoords[i][0] = itr->x;
		OutputCoords[i][1] = itr->y;
		OutputCoords[i][2] = itr->z;
#ifdef _DEBUG
		//test
		std::cout<<OutputCoords[i][0]<<OutputCoords[i][1]<<OutputCoords[i][2]<<std::endl;
#endif
	}
#ifdef _DEBUG
	//test
	std::cout<<"good5"<<std::endl;
#endif
	std::vector<unsigned int>::iterator itr2 = tess.getIndices().begin();
	for (int i = 0; itr2 != tess.getIndices().end(); itr2 += 3, i++)
	{
		OutputIndices[i][0] = *itr2;
		OutputIndices[i][1] = *(itr2 + 1);
		OutputIndices[i][2] = *(itr2 + 2);
#ifdef _DEBUG	
		//test
		std::cout<<OutputIndices[i][0]<<OutputIndices[i][1]<<OutputIndices[i][2]<<std::endl;
#endif
	}
	//very important
	tess.getIndices().clear();
	tess.getVertices().clear();
	tess.getTexCoords().clear();
	std::vector<Vec3*>::iterator itr3 = IntRingCoords.begin();
	for (;itr3 != IntRingCoords.end(); itr3++)
	{
		delete *itr3;
		*itr3 = NULL;
	}
	IntRingCoords.clear();
	IntRingCoordsNum.clear();
#ifdef _DEBUG
	//test
	std::cout<<"good6"<<std::endl;	
#endif
}
开发者ID:johnzjq,项目名称:mySVN,代码行数:49,代码来源:Interface.cpp

示例2: tesselate

	void Polygon::tesselate( AppearanceManager &appearanceManager, const TVec3d& normal )
	{
		_indices.clear();

		if ( !_exteriorRing || _exteriorRing->size() < 3 )
		{ 
			mergeRings( appearanceManager );
			return;
		}

		TexCoords texCoords;
		bool t = appearanceManager.getTexCoords( _exteriorRing->getId(), texCoords );
		_exteriorRing->finish( t ? &texCoords : &_texCoords );
		if ( t ) std::copy( texCoords.begin(), texCoords.end(), std::back_inserter( _texCoords ) );

		for ( unsigned int i = 0; i < _interiorRings.size(); i++ ) {
			TexCoords texCoords;
			bool t = appearanceManager.getTexCoords( _interiorRings[i]->getId(), texCoords );
			_interiorRings[i]->finish( t ? &texCoords : &_texCoords );
			if ( t ) std::copy( texCoords.begin(), texCoords.end(), std::back_inserter( _texCoords ) );
		}

		// Compute the total number of vertices
		unsigned int vsize = _exteriorRing->size();
		for ( unsigned int i = 0; i < _interiorRings.size(); i++ )
			vsize += _interiorRings[i]->size();

		Tesselator* tess = appearanceManager.getTesselator();
		tess->init( vsize, normal );

		tess->addContour( _exteriorRing->getVertices(), texCoords );

		for ( unsigned int i = 0; i < _interiorRings.size(); i++ )
			tess->addContour( _interiorRings[i]->getVertices(), texCoords ); 

		tess->compute();
		_vertices.reserve( tess->getVertices().size() );
		std::copy( tess->getVertices().begin(), tess->getVertices().end(), std::back_inserter( _vertices ) );

		unsigned int indicesSize = tess->getIndices().size();
		if ( indicesSize > 0 ) 
		{
			_indices.resize( indicesSize );
			memcpy( &_indices[0], &tess->getIndices()[0], indicesSize * sizeof(unsigned int) );
		}
		clearRings();
	}
开发者ID:jpouderoux,项目名称:libcitygml-jklimke,代码行数:47,代码来源:citymodel.cpp

示例3: Tessellation


//.........这里部分代码省略.........
	pNorm[2] = 0.0;

	Vec3 lVert;
	lVert[0] = ExtRingCoords[ExtRingVertNum - 1][0];
	lVert[1] = ExtRingCoords[ExtRingVertNum - 1][1];
	lVert[2] = ExtRingCoords[ExtRingVertNum - 1][2];

	for (int i = 0 ; i < ExtRingVertNum; i++)
	{
		Vec3 pStep;
		pStep[0] = (lVert[2] + ExtRingCoords[i][2]) * (lVert[1] - ExtRingCoords[i][1]);
		pStep[1] = (lVert[0] + ExtRingCoords[i][0]) * (lVert[2] - ExtRingCoords[i][2]);
		pStep[2] = (lVert[1] + ExtRingCoords[i][1]) * (lVert[0] - ExtRingCoords[i][0]);

		pNorm[0] = pNorm[0] + pStep[0];
		pNorm[1] = pNorm[1] + pStep[1];
		pNorm[2] = pNorm[2] + pStep[2];

		lVert[0] = ExtRingCoords[i][0];
		lVert[1] = ExtRingCoords[i][1];
		lVert[2] = ExtRingCoords[i][2];
	}
#ifdef _DEBUG
	//test
	std::cout<<"good2"<<std::endl;
#endif
	//do tessellation
	//verts number
	int VertNum = ExtRingVertNum;
	for (int i = 0; i < IntRingCoordsNum.size(); i++)
		VertNum += IntRingCoordsNum[i];
	//
#ifdef _DEBUG
	//test
	std::cout<<"good2.1"<<std::endl;
	std::cout<<"VertNum: "<<VertNum<<std::endl;
	std::cout<<pNorm[0]<<pNorm[1]<<pNorm[2]<<std::endl;
#endif
	tess.init(VertNum, TVec3d(pNorm[0], pNorm[1], pNorm[2]));
	std::vector<TVec3d> ring;
	std::vector<TVec2f> tag;//no use
	//add ExtierRing
	for (int i = 0; i < ExtRingVertNum; i++)
	{
		TVec3d vert(ExtRingCoords[i][0], ExtRingCoords[i][1], ExtRingCoords[i][2]);
		ring.push_back(vert);
	}
#ifdef _DEBUG
	//test
	std::cout<<"good2.2"<<std::endl;
	std::cout<<ring.size()<<std::endl;
#endif
	tess.addContour(ring, tag);
	ring.clear();
	//add InteriorRings
	for (int i = 0; i < IntRingNum; i++)
	{	
		for (int j = 0 ; j < IntRingCoordsNum[i]; j++)
		{
			TVec3d vert(IntRingCoords[i][j][0], IntRingCoords[i][j][1], IntRingCoords[i][j][2]);
			ring.push_back(vert);
		}
		tess.addContour(ring, tag);
		ring.clear();
	}
#ifdef _DEBUG
	//test
	std::cout<<"good2.3"<<std::endl;
#endif
	tess.compute();
	//return results
	if (tess.getIndices().size() == 0)
	{
		return false;
	}
#ifdef _DEBUG
	//test
	std::cout<<"good3"<<std::endl;
#endif
	//return coordsSAT
	OutputVertNum = tess.getVertices().size();
	OutputIndiceNum = tess.getIndices().size()/3;

	//
	{
		delete[] ExtRingCoords;
		ExtRingCoords = NULL;
		std::vector<Vec3*>::iterator itr = IntRingCoords.begin();
		for (; itr != IntRingCoords.end(); itr++)
		{
			delete[] *itr;
			*itr = NULL;
		}
	}
#ifdef _DEBUG
	//test
	std::cout<<"good4"<<std::endl;
#endif
	return true;
}
开发者ID:johnzjq,项目名称:mySVN,代码行数:101,代码来源:Interface.cpp


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