| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // This file is part of Bembel, the higher order C++ boundary element library. | ||
| 2 | // | ||
| 3 | // Copyright (C) 2022 see <http://www.bembel.eu> | ||
| 4 | // | ||
| 5 | // It was written as part of a cooperation of J. Doelz, H. Harbrecht, S. Kurz, | ||
| 6 | // M. Multerer, S. Schoeps, and F. Wolf at Technische Universitaet Darmstadt, | ||
| 7 | // Universitaet Basel, and Universita della Svizzera italiana, Lugano. This | ||
| 8 | // source code is subject to the GNU General Public License version 3 and | ||
| 9 | // provided WITHOUT ANY WARRANTY, see <http://www.bembel.eu> for further | ||
| 10 | // information. | ||
| 11 | |||
| 12 | #ifndef BEMBEL_SRC_DUFFYTRICK_COMPAREELEMENTS_HPP_ | ||
| 13 | #define BEMBEL_SRC_DUFFYTRICK_COMPAREELEMENTS_HPP_ | ||
| 14 | |||
| 15 | namespace Bembel { | ||
| 16 | namespace DuffyTrick { | ||
| 17 | /** | ||
| 18 | * \ingroup DuffyTrick | ||
| 19 | * \brief Compares two elements for similarities and determines, how the | ||
| 20 | *elements have to be rotated to move the similarity to the first vertices_ or | ||
| 21 | *edge | ||
| 22 | */ | ||
| 23 | 39524 | Eigen::Vector3i compareElements(const ElementTreeNode &e1, | |
| 24 | const ElementTreeNode &e2, double *dist) { | ||
| 25 | 39524 | Eigen::Vector3i retval; | |
| 26 | 39524 | retval.setZero(); | |
| 27 | // check if the two elements are identical and directly return; | ||
| 28 |
2/2✓ Branch 2 taken 638 times.
✓ Branch 3 taken 38886 times.
|
39524 | if (std::addressof(e1) == std::addressof(e2)) { |
| 29 |
3/6✓ Branch 1 taken 638 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 638 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 638 times.
✗ Branch 8 not taken.
|
638 | retval << 4, 4, 2; |
| 30 | 638 | *dist = 0; | |
| 31 | 638 | return retval; | |
| 32 | } else { | ||
| 33 | // if they are not identical, check if they have a positive distance | ||
| 34 | // check for common vertices | ||
| 35 |
1/2✓ Branch 2 taken 38886 times.
✗ Branch 3 not taken.
|
38886 | *dist = (e1.midpoint_ - e2.midpoint_).norm() - e1.radius_ - e2.radius_; |
| 36 |
2/2✓ Branch 0 taken 34368 times.
✓ Branch 1 taken 4518 times.
|
38886 | *dist = *dist >= 0 ? *dist : 0; |
| 37 | // check if elements are distinct and return now | ||
| 38 |
2/2✓ Branch 0 taken 30360 times.
✓ Branch 1 taken 8526 times.
|
38886 | if (*dist > .5 / (1 << e1.level_)) { |
| 39 |
3/6✓ Branch 1 taken 30360 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 30360 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 30360 times.
✗ Branch 8 not taken.
|
30360 | retval << 4, 4, 0; |
| 40 | 30360 | return retval; | |
| 41 | // otherwise check for common edge/vertex. Note that there is a | ||
| 42 | // short circuit: either two elements share a single edge or | ||
| 43 | // single point. everything else will break the code | ||
| 44 | } else { | ||
| 45 |
2/2✓ Branch 0 taken 24978 times.
✓ Branch 1 taken 3702 times.
|
28680 | for (auto rot1 = 0; rot1 < 4; ++rot1) |
| 46 |
2/2✓ Branch 0 taken 92046 times.
✓ Branch 1 taken 20154 times.
|
112200 | for (auto rot2 = 0; rot2 < 4; ++rot2) |
| 47 | // check for common vertices_ | ||
| 48 |
2/2✓ Branch 2 taken 4824 times.
✓ Branch 3 taken 87222 times.
|
92046 | if (e1.vertices_[rot1] == e2.vertices_[rot2]) { |
| 49 | // if there is a common vertices_, check for common edge | ||
| 50 |
2/2✓ Branch 2 taken 630 times.
✓ Branch 3 taken 4194 times.
|
4824 | if (e1.vertices_[3] == e2.vertices_[(rot2 + 1) % 4]) { |
| 51 |
3/6✓ Branch 1 taken 630 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 630 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 630 times.
✗ Branch 8 not taken.
|
630 | retval << 3, rot2, 3; |
| 52 | 4824 | return retval; | |
| 53 |
2/2✓ Branch 1 taken 1890 times.
✓ Branch 2 taken 2304 times.
|
8388 | } else if (e1.vertices_[(rot1 + 1) % 4] == |
| 54 | 4194 | e2.vertices_[(rot2 + 3) % 4]) { | |
| 55 |
3/6✓ Branch 1 taken 1890 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1890 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1890 times.
✗ Branch 8 not taken.
|
1890 | retval << rot1, (rot2 + 3) % 4, 3; |
| 56 | 1890 | return retval; | |
| 57 | } else { | ||
| 58 |
3/6✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2304 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2304 times.
✗ Branch 8 not taken.
|
2304 | retval << rot1, rot2, 4; |
| 59 | 2304 | return retval; | |
| 60 | } | ||
| 61 | } | ||
| 62 |
3/6✓ Branch 1 taken 3702 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3702 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3702 times.
✗ Branch 8 not taken.
|
3702 | retval << 4, 4, 0; |
| 63 | 3702 | return retval; | |
| 64 | } | ||
| 65 | } | ||
| 66 | // if you ended up here, something went terribly wrong | ||
| 67 | retval << 4, 4, -1; | ||
| 68 | return retval; | ||
| 69 | } | ||
| 70 | } // namespace DuffyTrick | ||
| 71 | } // namespace Bembel | ||
| 72 | |||
| 73 | #endif // BEMBEL_SRC_DUFFYTRICK_COMPAREELEMENTS_HPP_ | ||
| 74 |