Exemplo n.º 1
0
void ResetGlobalVariables()
{
	GlobalTraffic.Clear();
	AnonymitySets.Clear();
	OutputVariables.Clear();
	Vehicles.Clear();
	VehicleMax=0;
	TimeMax=0;
	SimulationTime=-1;
}
Exemplo n.º 2
0
/*****************************************************************************
* UnfoldedView - displays the unfolded cube in random orientation and layout
*
* The input cube faces are randomized in terms of their orientation and layout
* but the correct edge to edge mapping of the cube faces remains correct.  The
* resulting image is then drawn centered relative to the input XY-coordinates.
*
* RETURNS: NA
*/
void CJMCube::ConstructUnfoldedView(int x, int y)
	{
	Random *	rnd      = new Random();     // Random number generator
	ArrayList * workList = new ArrayList();  // Working array
	ArrayList * faceList = new ArrayList();  // Status of picked faces
	ArrayList * showList = new ArrayList();
	Int32		edgeMap  = 0;
	Int32		faceMap  = 0;
	Int32		i;
	Int32		face;
	Int32		pick;

	Bitmap *	newList[] = new Bitmap *[NUM_FACES];

	// Copy the reference set of cube faces into a working set

	for (i = 0; i < NUM_FACES; i++)
		{
		workList->Add(m_seedList[i]->Clone
			(
			RectangleF
				(
				0, 0, 
				static_cast<float> (m_seedList[i]->Width), 
				static_cast<float> (m_seedList[i]->Height)
				),
			Imaging::PixelFormat::DontCare)
			);

		faceList->Add(__box(Int32(i)));
		}

	// Randomly select faces and edges to be appended to selection item

	for (i = NUM_FACES; i > 0; i--)
		{
		// If only one face has been selected, the there are constraints on the
		// one which of the remaining faces can be selected.  For all other cases
		// any remaining face is a valid selection.

		while (true)
			{
			pick = ((int) (96 * rnd->NextDouble())) % faceList->Count;
			face = *(__try_cast<Int32 *>(faceList->get_Item(pick)));
			if ((faceMap ^ m_cubeRules.faceBits[face]) != 0)
				{
				faceList->RemoveAt(pick);        // Remove selected face from list
				faceMap |= m_cubeRules.faceBits[face];  // Update included faces
				break;
				}
			}

		SAssembly * ta = new SAssembly;
		ta->face = face;

		// Randomly select a valid edge to mate to assembly

		do
			{
			ta->edge = ((int) (96 * rnd->NextDouble())) % NUM_EDGES;
			int chkBit = m_cubeRules.edgeBit[face, ta->edge];
			if ((chkBit & edgeMap) != 0)
				break;
			} while (showList->Count > 0);

		edgeMap |= m_cubeRules.edgeBits[face];  // Update included edges

		ta->x    = x;
		ta->y    = y;
		ta->bmp  = __try_cast<Bitmap *> (workList->get_Item(face));
		showList->Add(ta);
		}
		
	ShowUnfoldedView(showList);

	workList->Clear();
	faceList->Clear();
	}