Vec4D CSceneData::getColor(float fX, float fY)const
{
	int nCellX = fX;
	int nCellY = fY;
	float u = fX - nCellX;
	float v = fY - nCellY;
	Vec4D a = getVertexColor(nCellX,	nCellY);
	Vec4D b = getVertexColor(nCellX+1,	nCellY);
	Vec4D c = getVertexColor(nCellX,	nCellY+1);
	Vec4D d = getVertexColor(nCellX+1,	nCellY+1);
	return bilinearInterpolation(a,b,c,d,u,v);
}
Exemple #2
0
//------------------------------------------------------------------------------
void NiceGraph::layersByGroupLayout(float radius, float nodeSize)
{	
	float count[5] = {0,0,0,0,0}; 	// only handles up to five groups
	float last[5];
	float xStep = radius / (2.0 * nodeSize * getNumVertices());
	float yStep = 2 * xStep;

	// first count how many are in each group for each one
	for (map<int,Vertex*>::iterator iter = vertexList.begin(); iter != vertexList.end(); iter++)
	{
		int group = getVertexColor(iter->first);
		switch (group)
		{
			case 0:count[0]++;break;
			case 1:count[1]++;break;
			case 2:count[2]++;break;
			case 3:count[3]++;break;
			case 4:count[4]++;break;
		}
	}

	// now set starting points
	for (int i = 0; i < 5; i++)
	{
		last[i] = -1.0 * xStep * count[i] / 2.0;	
	}

	// now set the plotting points
	for (map<int,Vertex*>::iterator iter = vertexList.begin(); iter != vertexList.end(); iter++)
	{
		// set position for this vertex
		int v = iter->first;
		int group = getVertexColor(v);
		float x = last[group];
		float y = group * yStep;
		float z = 0;
		setXYZPos (v,x,y,z);

		// now update coordinates for next iteration
		last[group]+=xStep;
	}
}