| 331 | |
| 332 | template <typename VectorType> |
| 333 | void safeCopy(const fl::span<const Point> &polyLine, VectorType *out) { |
| 334 | auto *first_out = out->data(); |
| 335 | // auto* last_out = first_out + mCount; |
| 336 | auto *other_first_out = polyLine.data(); |
| 337 | // auto* other_last_out = other_first_out + polyLine.size(); |
| 338 | const bool is_same = first_out == other_first_out; |
| 339 | if (is_same) { |
| 340 | return; |
| 341 | } |
| 342 | auto *last_out = first_out + mCount; |
| 343 | auto *other_last_out = other_first_out + polyLine.size(); |
| 344 | |
| 345 | const bool is_overlapping = |
| 346 | (first_out >= other_first_out && first_out < other_last_out) || |
| 347 | (other_first_out >= first_out && other_first_out < last_out); |
| 348 | |
| 349 | if (!is_overlapping) { |
| 350 | out->assign(polyLine.data(), polyLine.data() + polyLine.size()); |
| 351 | return; |
| 352 | } |
| 353 | |
| 354 | // allocate a temporary buffer |
| 355 | fl::vector_inlined<Point, 64> temp; |
| 356 | temp.assign(polyLine.begin(), polyLine.end()); |
| 357 | out->assign(temp.begin(), temp.end()); |
| 358 | return; |
| 359 | } |
| 360 | |
| 361 | u32 mCount = 10; |
| 362 | LineSimplifier<NumberT> mLineSimplifier; |