58    template <
typename VectorType>
 
   63    template <
typename VectorType>
 
   66        VectorType &poly = *_poly;
 
   67        keep.assign(poly.size(), 1);
 
   68        const int n = poly.size();
 
   73        for (
int i = 1; i + 1 < n; ++i) {
 
   79            while (L >= 0 && !
keep[L])
 
   83            while (R < n && !
keep[R])
 
   90            NumberT dx = poly[R].x - poly[L].x;
 
   91            NumberT dy = poly[R].y - poly[L].y;
 
   92            NumberT vx = poly[i].x - poly[L].x;
 
   93            NumberT vy = poly[i].y - poly[L].y;
 
   94            NumberT len2 = dx * dx + dy * dy;
 
   97                    ? ((dx * vy - dy * vx) * (dx * vy - dy * vx) / len2)
 
   98                    : (vx * vx + vy * vy);
 
  109            poly.erase(poly.begin() + bestIdx);
 
 
  115        span<Point> slice(polyLine->data(), polyLine->size());
 
 
  119    template <
typename VectorType>
 
  131        int n = polyLine.
size();
 
  155            const bool has_interior = (i1 - i0) > 1;
 
  164            NumberT maxDist2 = 0;
 
  166            for (
int i = i0 + 1; i < i1; ++i) {
 
  182            if (maxDist2 > minDist2) {
 
  188                for (
int i = i0 + 1; i < i1; ++i) {
 
  197        for (
int i = 0; i < n; ++i) {
 
 
  215        NumberT dx = b.
x - a.
x;
 
  216        NumberT dy = b.
y - a.
y;
 
  218        NumberT vx = pt.
x - a.
x;
 
  219        NumberT vy = pt.
y - a.
y;
 
  222        NumberT len2 = dx * dx + dy * dy;
 
  223        if (len2 <= NumberT(0)) {
 
  225            return vx * vx + vy * vy;
 
  229        NumberT cross = dx * vy - dy * vx;
 
  231        return (cross * cross) / len2;
 
 
 
  244    template <
typename VectorType = fl::vector<Po
int>>
 
  246        return simplify(*polyLine, polyLine);
 
 
  249    template <
typename VectorType = fl::vector<Po
int>>
 
  259            if (polyLine.
size() > 0) {
 
  262            if (polyLine.
size() > 1) {
 
  265            out->assign(temp.
begin(), temp.
end());
 
  270        NumberT max = est_max_dist;
 
  271        NumberT mid = (min + max) / 2.0f;
 
  274            auto diff = max - min;
 
  275            const bool done = (diff < 0.01f);
 
  280            fl::size n = out->size();
 
  302                while (out->size() > 
mCount) {
 
  309            if (out->size() < 
mCount) {
 
  314            mid = (min + max) / 2.0f;
 
 
  321        if (polyLine.
size() < 2)
 
  324        const Point &first = polyLine[0];
 
  325        const Point &last = polyLine[polyLine.
size() - 1];
 
  326        NumberT dx = last.
x - first.
x;
 
  327        NumberT dy = last.
y - first.
y;
 
  328        return sqrt(dx * dx + dy * dy);
 
 
  331    template <
typename VectorType>
 
  333        auto *first_out = out->data();
 
  335        auto *other_first_out = polyLine.
data();
 
  337        const bool is_same = first_out == other_first_out;
 
  341        auto *last_out = first_out + 
mCount;
 
  342        auto *other_last_out = other_first_out + polyLine.
size();
 
  344        const bool is_overlapping =
 
  345            (first_out >= other_first_out && first_out < other_last_out) ||
 
  346            (other_first_out >= first_out && other_first_out < last_out);
 
  348        if (!is_overlapping) {
 
  349            out->assign(polyLine.
data(), polyLine.
data() + polyLine.
size());
 
  356        out->assign(temp.
begin(), temp.
end());
 
 
 
void push_back(const T &value)
void assign(fl::size new_cap, const T &value)
void simplify(const fl::span< const Point > &polyLine, fl::vector< Point > *out)
void simplifyT(const fl::span< const Point > &polyLine, VectorType *out)
void simplifyInplace(fl::vector< Point > *polyline)
LineSimplifier & operator=(LineSimplifier &&other)=default
LineSimplifier & operator=(const LineSimplifier &other)=default
void simplify(const fl::span< Point > &polyLine, VectorType *out)
static NumberT PerpendicularDistance2(const Point &pt, const Point &a, const Point &b)
void simplifyInplaceT(VectorType *polyLine)
void setMinimumDistance(NumberT eps)
void simplifyInternal(const fl::span< const Point > &polyLine)
LineSimplifier(NumberT e)
fl::vector< Point > VectorPoint
LineSimplifier(const LineSimplifier &other)=default
static void removeOneLeastError(VectorType *_poly)
fl::vector_inlined< fl::pair< int, int >, 64 > indexStack
LineSimplifier(LineSimplifier &&other)=default
fl::vec2< NumberT > Point
void simplifyInplace(VectorType *polyLine)
LineSimplifierExact()=default
void simplifyInplace(VectorType *polyLine)
void simplify(const fl::span< const Point > &polyLine, VectorType *out)
LineSimplifierExact(int count)
void safeCopy(const fl::span< const Point > &polyLine, VectorType *out)
LineSimplifier< NumberT > mLineSimplifier
static NumberT estimateMaxDistance(const fl::span< const Point > &polyLine)
InlinedVector< T, INLINED_SIZE > vector_inlined
HeapVector< T, Allocator > vector
FixedVector< T, INLINED_SIZE > vector_fixed