Exemplo n.º 1
0
void GW_Mesh::CheckIntegrity()
{
	for( GW_U32 i=0; i<this->GetNbrVertex(); ++i ) 
	{
		GW_Vertex* pVert = this->GetVertex(i); GW_ASSERT( pVert!=NULL );
		GW_Face* pFace = pVert->GetFace();	GW_ASSERT( pFace!=NULL );
		if( pFace!=NULL && pFace->GetVertex(0)!=pVert &&
			pFace->GetVertex(1)!=pVert &&
			pFace->GetVertex(2)!=pVert )
			GW_ASSERT( GW_False );
	}
	for( GW_U32 i=0; i<this->GetNbrFace(); ++i )
	{
		GW_Face* pFace = this->GetFace(i);	GW_ASSERT( pFace!=NULL );
		for( GW_U32 k=0; k<3; ++k )
		{
			GW_U32 k1 = (k+1)%3;
			GW_U32 k2 = (k+2)%3;
			GW_Face* pNeighFace = pFace->GetFaceNeighbor(k);
			GW_Vertex* pV1 = pFace->GetVertex(k1);	GW_ASSERT( pV1!=NULL );
			GW_Vertex* pV2 = pFace->GetVertex(k2);	GW_ASSERT( pV2!=NULL );
			if( pNeighFace!=NULL )
			{
				GW_ASSERT( pNeighFace->GetFaceNeighbor(*pV1, *pV2)==pFace );
				GW_ASSERT( pFace->GetFaceNeighbor(*pV1, *pV2)==pNeighFace);
			}
		}
	}
}
Exemplo n.º 2
0
/*------------------------------------------------------------------------------*/
GW_Vertex* GW_Mesh::GetRandomVertex()
{
	GW_U32 nNumber = 0;
	GW_Vertex* pStartVertex = NULL;
	while( pStartVertex==NULL )
	{
		if( nNumber>=this->GetNbrVertex()/10 )
			return NULL;
		GW_U32 nNumVert = (GW_U32) floor(GW_RAND*this->GetNbrVertex());
		pStartVertex = this->GetVertex( nNumVert );
		if( pStartVertex->GetFace()==NULL )
			pStartVertex = NULL;
		nNumber++;
	}
	return pStartVertex;
}