Пример #1
0
// Main Threads does the Drawing
static void TMain(void)
{
	long n, xx, yy;
	HPEN hPen;
	HBRUSH hBrush;

	if(hDC = GetDC(hWnd))
	{
		time(&xx);
		xx = xx & 1023;
		for(n=0; n < xx; n++)
			(void) ranf();
		RandomizeABC();

		hBrush = CreateSolidBrush(RGB(CR, CG, CB));
		hPen = CreatePen(PS_NULL, 0, 0);
		SelectObject(hDC, hBrush);
		SelectObject(hDC, hPen);
		while(bThreadContinue)
		{
			WaitForInputIdle(hProcess, 1000);	// Höchstens 1s warten
			for(n = 0; n < N; n++)
			{
				Hop();
				x = x11;
				y = y11;
				xx = (long)(x * ZOOM);
				yy = (long)(y * ZOOM);
				Rectangle(hDC, xx, yy, xx+Width, yy+Width);
			}
		}
		ReleaseDC(hWnd, hDC);
	}
}
void Photon::HopDropSpinInTissue(MCMLModel * model) {
/* Set a step size, move the photon, drop some weight, 
  choose a new photon direction for propagation.
  When a step size is long enough for the photon to 
  hit an interface, this step is divided into two steps. 
  First, move the photon to the boundary free of 
  absorption or scattering, then decide whether the 
  photon is reflected or transmitted.
  Then move the photon in the current or transmission 
  medium with the unfinished stepsize to interaction 
  site.  If the unfinished stepsize is still too long, 
  repeat the above process. */

  StepSizeInTissue(model);
  if (HitBoundary(model)) {
    Hop();      // move to boundary plane
    CrossOrNot(model);
  } else {
    Hop();
    Drop(model);
    Spin(model->layerObj.layer[layer].g);
  }
}
void Photon::HopInGlass(MCMLModel * model) {
/* Move the photon packet in glass layer.
  Horizontal photons are killed because they will
  never interact with tissue again. */

  if (uz == 0.0)
  // horizontal photon in glass is killed
    dead = true;
  else {
    StepSizeInGlass(model);
    Hop();
    CrossOrNot(model);
  }
}
Пример #4
0
Hop
RouteParser::createHop(stringref str)
{
    if (str.empty()) {
        return Hop().addDirective(createErrorDirective("Failed to parse empty string."));
    }
    size_t len = str.size();
    if (len > 1 && str[0] == '?') {
        Hop hop = createHop(str.substr(1));
        hop.setIgnoreResult(true);
        return hop;
    }
    if (len > 4 && str.substr(0, 4) == "tcp/") {
        IHopDirective::SP tcp = createTcpDirective(str.substr(4));
        if (tcp.get() != nullptr) {
            return Hop().addDirective(tcp);
        }
    }
    if (len > 6 && str.substr(0, 6) == "route:") {
        return Hop().addDirective(createRouteDirective(str.substr(6)));
    }
    Hop ret;
    for (size_t from = 0, at = 0, depth = 0; at <= len; ++at) {
        if (at == len || (depth == 0 && str[at] == '/')) {
            if (depth > 0) {
                return Hop().addDirective(createErrorDirective(
                                "Unexpected token '': syntax error"));
            }
            ret.addDirective(createDirective(str.substr(from, at - from)));
            from = at + 1;
        } else if (isWhitespace(str[at]) && depth == 0) {
            return Hop().addDirective(createErrorDirective(
                            vespalib::make_string(
                                    "Failed to completely parse '%s'.",
                                    vespalib::string(str).c_str())));
        } else if (str[at] == '[') {
            ++depth;
        } else if (str[at] == ']') {
            if (depth == 0) {
                return Hop().addDirective(createErrorDirective(
                                "Unexpected token ']': syntax error"));
            }
            --depth;
        }
    }
    return ret;
}