Ejemplo n.º 1
0
/*------------------------------------------------------------------------------*/
void GW_Mesh::IterateConnectedComponent_Vertex( GW_Vertex& start_vert, VertexIterate_Callback pCallback )
{
	/* march on the voronoi diagram */
	T_VertexList VertexToProceed;
	VertexToProceed.push_back( &start_vert );
	T_VertexMap VertexDone;
	VertexDone[ start_vert.GetID() ] = &start_vert;


	while( !VertexToProceed.empty() )
	{
		GW_Vertex* pVert = VertexToProceed.front();
		GW_ASSERT( pVert!=NULL );
		VertexToProceed.pop_front();

		/* cut the face */
		pCallback( *pVert );

		/* add neighbors */
		for( GW_VertexIterator it = pVert->BeginVertexIterator(); it!=pVert->EndVertexIterator(); ++it )
		{
			GW_Vertex* pNewVert = (GW_Vertex*) *it;
			if( pNewVert==NULL )
				break;
			GW_ASSERT( pNewVert!=NULL );
			if( VertexDone.find(pNewVert->GetID())==VertexDone.end() )
			{				
				VertexToProceed.push_back( pNewVert );
				VertexDone[ pNewVert->GetID() ] = pNewVert;	// so that it won't be added anymore
			}
		}
	}
}
Ejemplo n.º 2
0
void GW_Mesh::ExtractBoundary( GW_Vertex& seed, T_VertexList& boundary, T_VertexMap* pExtracted )
{
	GW_ASSERT( seed.IsBoundaryVertex() );
	GW_Vertex* pPrev = NULL;
	GW_Vertex* pCur = &seed;
	GW_Vertex* pNext = NULL;
	GW_U32 num = 0;
	do
	{
		num++;
		boundary.push_back(pCur);
		if( pExtracted!=NULL )
			(*pExtracted)[ pCur->GetID() ] = pCur;
		pNext = NULL;
		for( GW_VertexIterator it = pCur->BeginVertexIterator(); 
				(it!=pCur->EndVertexIterator()) && (pNext==NULL); ++it )
		{
			GW_Vertex* pVert = *it;
            if( pVert->IsBoundaryVertex() && pVert!=pPrev )
				pNext = pVert;
		}
		GW_ASSERT( pNext!=NULL );
		pPrev = pCur;
		pCur = pNext;
	}
	while( pCur!=&seed && pNext!=NULL && num<this->GetNbrVertex() );
}
/*------------------------------------------------------------------------------*/
void GW_GeodesicDisplayer::RemoveFrontColor( GW_Vertex& VertFront )
{
	VertexColorMap_.erase( VertFront.GetID() );
}
Ejemplo n.º 4
0
/*------------------------------------------------------------------------------*/
void GW_Mesh::BuildConnectivity()
{
	T_FaceList* VertexToFaceMap = new T_FaceList[this->GetNbrVertex()];

	/* build the inverse map vertex->face */
	for( IT_FaceVector it = FaceVector_.begin(); it!=FaceVector_.end(); ++it )
	{
		GW_Face* pFace = *it;
		GW_ASSERT( pFace!=NULL );
		for( GW_U32 i=0; i<3; ++i )
		{
			GW_Vertex* pVert = pFace->GetVertex(i);
			GW_ASSERT(pVert!=NULL);
			GW_ASSERT( pVert->GetID() <= this->GetNbrVertex() ); 
			VertexToFaceMap[pVert->GetID()].push_back( pFace );
		}
	}
	/* now we can set up connectivity */
	for( IT_FaceVector it=FaceVector_.begin(); it!=FaceVector_.end(); ++it )
	{
		GW_Face* pFace = *it;
		GW_ASSERT( pFace!=NULL );

		/* set up the neigbooring faces of the 3 vertices */
		T_FaceList* pFaceLists[3];
		for( GW_U32 i=0; i<3; ++i )
		{
			GW_Vertex* pVert = pFace->GetVertex(i);
			pFaceLists[i] = &VertexToFaceMap[pVert->GetID()];
		}

		/* compute neighbor in the 3 directions */
		for( GW_U32 i=0; i<3; ++i )
		{
			GW_Face* pNeighbor = NULL;
			GW_U32 i1 = (i+1)%3;
			GW_U32 i2 = (i+2)%3;
			/* we must find the intersection of the surrounding faces of these 2 vertex */
			GW_Bool bFind = GW_False;
			for( IT_FaceList it1 = pFaceLists[i1]->begin(); it1!=pFaceLists[i1]->end() && bFind!=GW_True; ++it1 )
			{
				GW_Face* pFace1 = *it1;
				for( IT_FaceList it2 = pFaceLists[i2]->begin(); it2!=pFaceLists[i2]->end() && bFind!=GW_True; ++it2 )
				{
					GW_Face* pFace2 = *it2;
					if( pFace1==pFace2 && pFace1!=pFace )
					{
						pNeighbor = pFace1;
						bFind=GW_True;
					}
				}
			}
			//			GW_ASSERT( pNeighbor!=NULL );
			/* assign the face */
/*			if( pFace->GetFaceNeighbor(i)!=NULL )
				GW_ASSERT( pFace->GetFaceNeighbor(i)==pNeighbor );	*/
			pFace->SetFaceNeighbor( pNeighbor, i );
			/* make some test on the neighbor to assure symetry
			   in the connectivity relationship */
			if( pNeighbor!=NULL )
			{
				GW_I32 nEdgeNumber = pNeighbor->GetEdgeNumber( *pFace->GetVertex(i1),*pFace->GetVertex(i2) );
				GW_ASSERT( nEdgeNumber>=0 );
#if 0
				if( pNeighbor->GetFaceNeighbor( nEdgeNumber )!=NULL )
					GW_ASSERT(pNeighbor->GetFaceNeighbor(nEdgeNumber)==pFace);
#endif
				pNeighbor->SetFaceNeighbor( pFace, nEdgeNumber );
			}
		}
	}

	GW_DELETEARRAY( VertexToFaceMap );
}
/*------------------------------------------------------------------------------*/
void GW_GeodesicDisplayer::AddFrontColor( GW_Vertex& VertFront, GW_Vector3D& Color )
{
	GW_U32 nID = VertFront.GetID();
	VertexColorMap_[nID] = Color;
}