Repository navigation
SimplifyPaths
Seth Hillbrand edited this page Oct 29, 2026
·
2 revisions
Home › clipper.h › SimplifyPaths
inline Path<T> SimplifyPath(const Path<T>& path, double epsilon,
bool isClosedPath = true);
inline Paths<T> SimplifyPaths(const Paths<T>& 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 before offsetting (ie before inflating/shrinking) when paths may contain redundant segments. (See notes on redundant segments here.) And removing redundant segments is especially important when offsetting paths that have themselves been offset.
Example:
#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);
}Copyright © 2010-2025 Angus Johnson. Clipper2 is distributed under the Boost Software License.
Headers
- clipper.h
- clipper.core.h
- clipper.engine.h
- clipper.export.h
- clipper.minkowski.h
- clipper.offset.h
- clipper.rectclip.h
- clipper.triangulation.h
Classes
Data types and structure definitions
- ClipType
- EndType
- FillRule
- JoinType
- Path64
- PathD
- Paths64
- PathsD
- Point64
- PointD
- PointInPolygonResult
- Rect64
- RectD
- TriangulateResult
- ZCallback64
- ZCallbackD
Static Functions
- Area
- BooleanOp
- Difference
- InflatePaths
- Intersect
- IsPositive
- MakePath
- MinkowskiDiff
- MinkowskiSum
- PointInPolygon
- PolyTreeToPaths64
- PolyTreeToPathsD
- RectClip
- RectClipLines
- ReversePath
- SimplifyPaths
- TranslatePath
- Triangulate
- TrimCollinear
- Union
- XOR
Topics