| 18 | |
| 19 | template<size_t N> |
| 20 | std::array<PointDegree, N> getPointDegrees( const std::array<PreciseVertCoords2, N> & vs ) |
| 21 | { |
| 22 | struct VertN |
| 23 | { |
| 24 | VertId v; |
| 25 | int n = 0; |
| 26 | }; |
| 27 | std::array<VertN, N> as; |
| 28 | for ( int i = 0; i < N; ++i ) |
| 29 | as[i] = { vs[i].id, i }; |
| 30 | std::sort( begin( as ), end( as ), []( const auto & a, const auto & b ) { return a.v < b.v; } ); |
| 31 | |
| 32 | std::array<PointDegree, N> res; |
| 33 | int d = 1; |
| 34 | for ( int i = 0; i < N; ++i ) |
| 35 | { |
| 36 | assert( i == 0 || as[i-1].v < as[i].v ); // no duplicate vertices are permitted |
| 37 | const auto n = as[i].n; |
| 38 | res[n] = { vs[n].pt, d }; |
| 39 | d *= 9; |
| 40 | } |
| 41 | return res; |
| 42 | } |
| 43 | |
| 44 | // std::int64_t is enough to store all coefficients in ( ccw(sa,s[0])*ccw(sb,s[1]) - ccw(sb,s[0])*ccw(sa,s[1]) ) except for degree 0, which is computed separately. |
| 45 | template<int M> |
no test coverage detected