SimplifyPaths

Delphifunction SimplifyPath(const path: TPath64; epsilon: double;
  isClosedPath: Boolean = true): TPath64; overload;

Delphifunction SimplifyPaths(const paths: TPaths64;
  epsilon: double; isClosedPath: Boolean = true): TPaths64; overload;

Delphifunction SimplifyPath(const path: TPathD;
  epsilon: double; isClosedPath: Boolean = true): TPathD; overload;

Delphifunction SimplifyPaths(const paths: TPathsD;
  epsilon: double; isClosedPath: Boolean = true): TPathsD; overload;


C++inline Path<T> SimplifyPath(const Path<T>& path, double epsilon,
 bool isClosedPath = true);

C++inline Paths<T> SimplifyPaths(const Paths<T>& path, double epsilon,
 bool isClosedPath = true);


C# public static Path64 SimplifyPath(Path64 path, double epsilon, bool isClosedPath = true);

C# public static Paths64 SimplifyPaths(Paths64 path, double epsilon, bool isClosedPath = true);

C# public static PathD SimplifyPath(PathD path, double epsilon, bool isClosedPath = true);

C# public static PathsD SimplifyPaths(PathsD path, double epsilon, bool isClosedPath = true);



This function removes vertices that are less than the specified epsilon distance from an imaginary line that passes through its 2 adjacent vertices. Logically, smaller epsilon values will be less aggressive in removing vertices than larger epsilon values.

This function is strongly recommended following offsetting (ie inflating/shrinking), especially when offsetting paths multiple times. Offsetting often creates tiny segments that don't improve path quality. Further these tiny segments can be at angles that have been affected by integer rounding. While these tiny segments are too small to be noticeable following a single offset procedure, they can degrade both the shape quality and the performance of subsequent offsets.

C++ Code Sample:
  #include "../../Clipper2Lib/clipper.h"
  #include "../../Utils/clipper.svg.h"
  #include "../../Utils/clipper.svg.utils.h"
  ...
  using namespace Clipper2Lib;
    
  int main()
  {
    SvgReader svg_reader;
    svg_reader.LoadFromFile("./rabbit.svg");
    PathsD p = svg_reader.GetPaths(), solution;

    while (p.size())
    {
      //copy each iteration of 'p' into solution until 'p' is no more
      solution.reserve(solution.size() + p.size());
      copy(p.begin(), p.end(), back_inserter(solution));
      
      p = InflatePaths(p, -2.5, JoinType::Round, EndType::Polygon);
      p = SimplifyPaths(p, 0.025);
    }

    SvgAddSolution(svg, solution, false);
    SvgSaveToFile(svg, "rabbit_offset.svg", 338, 540, 0);
  }  
  
    

See Also

InflatePaths