예제 #1
0
int PointExplorer::explorePoint(int x, int y, const ColorClasses::Color col, int xMin, int yEnd, int yMin, int& run_end, int& explored_min_y, int& explored_max_y)
{
  int size = 0;
  const Image::Pixel* pixel3 = (*theImage)[y] + x;
  run_end = runDown(pixel3, x, y, col, yEnd, Drawings::ps_solid);
  explored_min_y = y;
  size = (run_end - y) * parameters.gridStepSize;
  if(col != ColorClasses::green)
  {
    explored_max_y = run_end - 1;
    if(!(run_end - y >= parameters.minSegSize[col]))
    {
      return -1;
    }
    const Image::Pixel* pixel1 = (*theImage)[explored_min_y] + x;
    const Image::Pixel* pixel2 = (*theImage)[explored_max_y] + x;
    for(x -= parameters.exploreStepSize, pixel1 -= parameters.exploreStepSize, pixel2 -= parameters.exploreStepSize;
      x > xMin;
      x -= parameters.exploreStepSize, pixel1 -= parameters.exploreStepSize, pixel2 -= parameters.exploreStepSize)
    {
      if(getColor(pixel1) == col)
      {
        const int expl_run_end = runUp(pixel1, x, explored_min_y, col, yMin, Drawings::ps_dot);
        if(expl_run_end < explored_min_y)
        {
          explored_min_y = expl_run_end + 1;
          pixel1 = (*theImage)[explored_min_y] + x;
        }
      }
      if(getColor(pixel2) == col)
      {
        const int expl_run_end = runDown(pixel2, x, explored_max_y, col, yEnd, Drawings::ps_dot);
        if(expl_run_end > explored_max_y)
        {
          explored_max_y = expl_run_end - 1;
          pixel2 = (*theImage)[explored_max_y] + x;
        }
      }
    }
  }
  else
  {
    explored_max_y = run_end;
  }
  return size;
}
int ProgramHandler::runProgram(int argCounter, char* argValues[])
{
	

	//==============IDE==============
	if (!ideGateway.handleIDEArguments(argCounter, argValues))
	{
		return 0;
	}

	//=============TEST=============
	if (ideGateway.doRunTest())
	{
		TestDown test;
		test.runAll();

		return 0;
	}

	//==============DOWN=============
	return runDown(ideGateway);
}