Find frontmost object in v, along with the constant material behind it. Returns false if material behind the object is not constant. Requires moderately horrifying logic to figure things out properly, stolen from MPB. */
| 500 | Requires moderately horrifying logic to figure things out properly, |
| 501 | stolen from MPB. */ |
| 502 | static bool get_front_object(const meep::volume &v, geom_box_tree geometry_tree, vector3 &pcenter, |
| 503 | const geometric_object **o_front, vector3 &shiftby_front, |
| 504 | material_type &mat_front, material_type &mat_behind) { |
| 505 | vector3 p; |
| 506 | const geometric_object *o1 = 0, *o2 = 0; |
| 507 | vector3 shiftby1 = {0, 0, 0}, shiftby2 = {0, 0, 0}; |
| 508 | geom_box pixel; |
| 509 | material_type mat1, mat2; |
| 510 | int id1 = -1, id2 = -1; |
| 511 | const int num_neighbors[3] = {3, 5, 9}; |
| 512 | const int neighbors[3][9][3] = {{{0, 0, 0}, |
| 513 | {0, 0, -1}, |
| 514 | {0, 0, 1}, |
| 515 | {0, 0, 0}, |
| 516 | {0, 0, 0}, |
| 517 | {0, 0, 0}, |
| 518 | {0, 0, 0}, |
| 519 | {0, 0, 0}, |
| 520 | {0, 0, 0}}, |
| 521 | {{0, 0, 0}, |
| 522 | {-1, -1, 0}, |
| 523 | {1, 1, 0}, |
| 524 | {-1, 1, 0}, |
| 525 | {1, -1, 0}, |
| 526 | {0, 0, 0}, |
| 527 | {0, 0, 0}, |
| 528 | {0, 0, 0}, |
| 529 | {0, 0, 0}}, |
| 530 | {{0, 0, 0}, |
| 531 | {1, 1, 1}, |
| 532 | {1, 1, -1}, |
| 533 | {1, -1, 1}, |
| 534 | {1, -1, -1}, |
| 535 | {-1, 1, 1}, |
| 536 | {-1, 1, -1}, |
| 537 | {-1, -1, 1}, |
| 538 | {-1, -1, -1}}}; |
| 539 | pixel = gv2box(v); |
| 540 | pcenter = p = vec_to_vector3(v.center()); |
| 541 | double d1, d2, d3; |
| 542 | d1 = (pixel.high.x - pixel.low.x) * 0.5; |
| 543 | d2 = (pixel.high.y - pixel.low.y) * 0.5; |
| 544 | d3 = (pixel.high.z - pixel.low.z) * 0.5; |
| 545 | for (int i = 0; i < num_neighbors[dimensions - 1]; ++i) { |
| 546 | const geometric_object *o; |
| 547 | material_type mat; |
| 548 | vector3 q, shiftby; |
| 549 | int id; |
| 550 | q.x = p.x + neighbors[dimensions - 1][i][0] * d1; |
| 551 | q.y = p.y + neighbors[dimensions - 1][i][1] * d2; |
| 552 | q.z = p.z + neighbors[dimensions - 1][i][2] * d3; |
| 553 | o = object_of_point_in_tree(q, geometry_tree, &shiftby, &id); |
| 554 | if ((id == id1 && vector3_equal(shiftby, shiftby1)) || |
| 555 | (id == id2 && vector3_equal(shiftby, shiftby2))) |
| 556 | continue; |
| 557 | mat = (o && o->material.which_subclass != MTS::MATERIAL_TYPE_SELF) ? o->material |
| 558 | : default_material; |
| 559 | if (id1 == -1) { |
no test coverage detected