Class PolySimplification2
2D Polyline/Polygon simplification.
This is a more complex approach than Polygon.Simplify(), which uses sequential vtx clustering and then runs douglas-peucker algorithm. That method can end up modifying long straight segments, which is not ideal in many contexts (eg manufacturing).
Strategy here is : 1) find runs of vertices that are very close to straight lines (default 0.01mm deviation tol) 2) find all straight segments longer than threshold distance (default 2mm) 3) discard vertices that deviate less than tolerance (default = 0.2mm) from sequential-points-segment, unless they are required to preserve straight segments
[TODO] currently doing greedy search in 1,3. Could do more optimal search. [TODO] currently measuring deviation of p1...pN-1 from line [p0,pN] for points [p0,p1,...pN]. could alternately fit best segment to p1...pN (p0 is already fixed). [TODO] 2d variant of variational shape segmentation?
Inherited Members
Namespace: g3
Assembly: cs.temp.dll.dll
Syntax
public class PolySimplification2
Constructors
PolySimplification2(Polygon2d)
Declaration
public PolySimplification2(Polygon2d polygon)
Parameters
| Type | Name | Description |
|---|---|---|
| Polygon2d | polygon |
PolySimplification2(PolyLine2d)
Declaration
public PolySimplification2(PolyLine2d polycurve)
Parameters
| Type | Name | Description |
|---|---|---|
| PolyLine2d | polycurve |
Fields
PreserveStraightSegLen
After collapsing straight lines, any segment longer than this distance is explicitly preserved
Declaration
public double PreserveStraightSegLen
Field Value
| Type | Description |
|---|---|
| Double |
Result
Declaration
public List<Vector2d> Result
Field Value
| Type | Description |
|---|---|
| List<Vector2d> |
SimplifyDeviationThreshold
we skip vertices that deviate less than this distance from the currently-accumulated line segment
Declaration
public double SimplifyDeviationThreshold
Field Value
| Type | Description |
|---|---|
| Double |
StraightLineDeviationThreshold
A series of points that deviates less than this distance from a line segment are considered 'on' that line
Declaration
public double StraightLineDeviationThreshold
Field Value
| Type | Description |
|---|---|
| Double |
Methods
Simplify()
Declaration
public void Simplify()
Simplify(GeneralPolygon2d, Double)
simplify outer and holes of a polygon solid with same thresholds
Declaration
public static void Simplify(GeneralPolygon2d solid, double deviationThresh)
Parameters
| Type | Name | Description |
|---|---|---|
| GeneralPolygon2d | solid | |
| Double | deviationThresh |