| 25 | constexpr int cMaxPolyD = 14'941'836; |
| 26 | |
| 27 | std::array<PointDegree, 8> getPointDegrees( const std::array<PreciseVertCoords, 8> & vs ) |
| 28 | { |
| 29 | struct VertN |
| 30 | { |
| 31 | VertId v; |
| 32 | int n = 0; |
| 33 | }; |
| 34 | std::array<VertN, 8> as; |
| 35 | for ( int i = 0; i < 8; ++i ) |
| 36 | as[i] = { vs[i].id, i }; |
| 37 | std::sort( begin( as ), end( as ), []( const auto & a, const auto & b ) { return a.v < b.v; } ); |
| 38 | |
| 39 | std::array<PointDegree, 8> res; |
| 40 | int d = 1; |
| 41 | constexpr int maxD = INT_MAX / 9; |
| 42 | static_assert( maxD > cMaxPolyD ); |
| 43 | constexpr int preMaxD = maxD / 27; |
| 44 | for ( int i = 0; i < 8; ++i ) |
| 45 | { |
| 46 | const auto n = as[i].n; |
| 47 | res[n] = { vs[n].pt, d }; |
| 48 | if ( i < 7 && as[i].v < as[i+1].v ) // skip to support triangles with shared vertices |
| 49 | { |
| 50 | if ( d <= preMaxD ) |
| 51 | d *= 27; // normal power up |
| 52 | else if ( d <= maxD ) |
| 53 | d = maxD; // to avoid integer overflow in orient3dPoly, assuming that such huge powers will never be necessary |
| 54 | } |
| 55 | } |
| 56 | return res; |
| 57 | } |
| 58 | |
| 59 | // 128 bits are enough to store all coefficients in ( orient3d(ta,s[0])*orient3d(tb,s[1]) - orient3d(tb,s[0])*orient3d(ta,s[1]) ) |
| 60 | // except for degree 0, which is computed separately. |
no test coverage detected