Poly2d Class

Poly2d is a collection of PolyPoint2d describing a, possibly closed, contour which can have bulged segments (segments that are circular arcs).
Public Class Poly2d 
Inherits Geometry2d 
Implements IEnumerable(Of Arc2d)
This language is not supported or no code example is available.
public class Poly2d : Geometry2d
IEnumerable<Arc2d>
This language is not supported or no code example is available.
public ref class Poly2d : public Geometry2d^, 
public IEnumerable<Arc2d^>^
This language is not supported or no code example is available.
JScript does not support generic types and methods.
This language is not supported or no code example is available.
Name Description
Public constructor Poly2d() Default constructor. Creates an empty, non closed poly.
Public constructor Poly2d(IEnumerable<Point2d>) Create an open poly from (copied) points. Same as creating an empty poly followed by Add():ing each point, but shorter.
Public constructor Poly2d(Poly2d) Copy constructor.
Public constructor Poly2d(params Point2d[]) Create an open poly from (copied) points. Same as creating an empty poly followed by Add():ing each point, but shorter.
Top
Name Description
Public property Area Gets the area of this polygon. If the polygon is open, it imagines a line segment from start to end point.
Public property Centroid Gets a new point, which represents the centroid of the polygon, as if the polygon was a solid plate. If the polygon is empty, an exception will be thrown.
Public property Closed Gets or sets the closed state of the poly. A closed poly has one more segment than an open...
Public property Direction Gets or sets the direction of this polygon. Clockwise or counter clockwise. See Direction enumeration for details.
Public property EdgeCount Gets the number of edges/segments in this poly.
Public property End Gets a reference to the last point in the polygon or sets it to a copy of a specified PolyPoint2d. If the poly is empty, an exception will be thrown.
Public property Extents Gets the polys bounding box.
Public property First Gets a reference to the first point in the poly.
Public property FirstEdge Returns a new arc representing the first edge in the poly
Public property Item(int) Gets a reference to a PolyPoint2d in the poly or sets it to a copy of a given point.
Public property Last Gets a reference to the last point in the poly.
Public property LastEdge Returns a new arc representing the last edge in the poly
Public property Length Gets the length of the polygon, that is the sum of lengths of each segment it contains.
Public property NodeCount Gets the number of nodes in the polygon.
Public property Open Same as !Closed
Public property Points Returns a reference to the list of PolyPoint2d:s held by the poly.
Public property SignedArea Gets the signed area for polygon. A counter clockwise polygon has posetive area, a clockwise has negative.
Public property SignedAreaOLD Gets the signed area for polygon. A counter clockwise polygon has posetive area, a clockwise has negative.
Public property Start Gets a reference to the first point in the polygon or sets it to a copy of a specified PolyPoint2d. If the poly is empty, an exception will be thrown.
Public property WireCentroid Gets the center of gravity for this poly as if it is a wire.
Top
Methods
 
Name Description
Public method Add(Arc2d) Adds an arc segment last to the poly. If the arcs startpoint is further away than epsilon from the current endpoint of the poly a line segment is added between.
Public method Add(Line2d) Adds a line segment last to the poly. If the lines startpoint is further away than epsilon from the current endpoint of the poly a line segment is added between.
Public method Add(Point2d) Adds a copy of a point to the polygon.
Public method Add(Point2d, double) Creates a poly node from a point and a bulge factor.
Public method Add(Point2d, object) Adds a copy of a point to the polygon.
Public method Add(Poly2d, bool) Adds all points of a given polygon to this one.
Public method Add(PolyPoint2d) Adds a copy of a PolyPoint2d to the poly.
Public method Add(Vector2d) Adds a copy of the polys last point translated with a given vector last to the poly. If the poly is empty a point at 0,0 is added first.
Public method Add(double, double) Adds a point to the polygon given real numbers.
Public method Add(double, double, double) Adds a point to the polygon given real numbers and a bulge factor.
Public method AddRaw(PolyPoint2d) Adds a point directly to the polygon without copying it. Use with care if speed is needed.
Public method Arc(int) Extracts one segment of this poly as an Arc2d. If the poly contains less than two nodes, an exception is thrown.
Public method ArcFit(double) Returns a new poly, which is created by fitting arcs to this poly within a given tolerance. This can reduce the number of segments needed to describe this geometry.
Public method Static CalcOffsetExtendPoint(Arc2d, Arc2d, out Point2d, out Point2d, double, Point2d, bool, double) Calculates the extension points of a1 and a2 using maxdist for chamfer.
Public method Static CalcOffsetExtendPointSimple(Arc2d, Arc2d, double, Point2d) Calculates the extension intersection point of two arcs if the distance is shorter than maxdist.
Public method ChangeStart(int) Creates a new poly with a changed start point.
Public method Clean() Perform a default clean using Calc.Epsilon.
Public method Clean(double) Removes all edges in the poly whose length is less than the given tolerance. This function modifies the poly in-place.
Public method Clear() Removes all nodes from the poly and makes it open, just like a new default poly.
Public method Clip(Extents2d, out Poly2d) Clips the Poly2d to a specified clipping box. The result is a new Poly2d defining the part that is completely inside the clip box. The Poly2d must be closed and consist of only lines.
Public method ClosestNode(Point2d) Computes the index of the closest node in the poly from a given point. If the poly is empty, an exception will be thrown.
Public method ClosestNode(Point2d, out double) Computes the index of the closest node in the poly from a given point. If the poly is empty, an exception will be thrown.
Public method ClosestOuterCorner(Point2d, double, bool) Returns the closest oputer corner index from point pt
Public method ClosestPoint(Point2d) Computes a new point on the poly that is as close as possible to a given point. If the poly is empty, an exception will be thrown.
Public method ClosestSegment(Point2d) Computes the index of the closest segment in the poly from a given point. If the poly has less than two nodes (=0 segments), an exception will be thrown.
Public method ClosestSegment(Point2d, out double) Computes the index of the closest segment in the poly from a given point. If the poly has less than two nodes (=0 segments), an exception will be thrown.
Public method Contains(Point2d) Checks if a point is inside the poly. If the poly is open, an exception is thrown. The direction (CW/CCW) of the poly is not taken into account.
Public method Distance(Point2d) Computes the minimum distance from a point to the poly.
Public method DouglasPeucker(double) Creates a DouglasPeucker poly.
Public method Eval(double) Evaluates a point on the polygon given a parameter in the range 0-1 between the polygons endpoints. If the poly is closed, larger or smaller valus than this range wraps around the poly. If the poly is open, the point is on the extension of the start/end point.
Public method Eval(double, out double) Evaluates a point on the polygon given a parameter in the range 0-1 between the polygons endpoints. If the poly is closed, larger or smaller valus than this range wraps around the poly. If the poly is open, the point is on the extension of the start/end point. A tangent at the point found is computed as well.
Public method Flatten(double, FlattenMode) Computes a new polygon, containing only line segments. Arc segments are flattened using the given tolerance.
Public method GetCentralPoint() Calculates an optimal point that is most inside the poly
Public method GetCentralPoint(out double) Calculates an optimal point that is most inside the poly
Public method GetEnumerator() Returns an enumerator that iterates through the collection.
Public method GetX(double) Get X for a certain Y, works only on Y-monotone polys
Public method GetY(double) Get Y for a certain X, works only on X-monotone polys
Public method InsertNode(double) Inserts a node at pos and returns the index to the inserted node If the node allready exists the index is just returned
Public method IsCircular(double) Checks if a poly is a circle
Public method IsCircular(out Circle2d, double) Checks if a poly is a circle
Public method IsConvex() Checks if this polygon is convex.
Public method IsLongerThan(double) Checks if the length of this poly is longer than a given length. This is faster than checking if the length property is longer than a value, because it can break when the limit has been reached.
Public method IsOuterCorner(int, double, bool) Detects if a node in a poly is an outside corner. Poly is supposed to be closed and CCW.
Public method IsOuterCornerAtParam(double, double)
Public method IsShorterThan(double) Checks if the length of this poly is shorter than a given length. This is faster than checning if the length property is shorter than a value, because it can break when the limit has been reached.
Public method LineFit(double) Creates a new optimized poly with only lines.
Public method MakeYMonotone() Splits all arcs so that they are Y-monotone.
Public method Measure(double) Divides a poly into pieces with length dist The last piece might be shorter
Public method MeasureEdges(double) Creates a point list along the poly with distance dist. Works per edge so the actual distance can vary between edges.
Public method MergeArcs(double) Merges concecutive arcs within accuracy.
Public method Midpoint() The point splitting the poly in two polys of equal length.
Public method Mirror(Point2d, Point2d) Reflects the poly in-place over a line given with two points. Note that the polys direction inverts when reflecting it.
Public method Offset(List<Double>, double, bool) Offsets the poly with different distances for every segment. The gap is connected with an interpolated arc.
Public method Offset(double, OffsetGapType, double) Computes a new poly which is an offset of this poly. The offsetted segments can be joined with an arc or by extension. This function automatically removes trivial (zero length) segments in the result poly. The resulting poly will _not_ be trimmed and may contain loops. Use Union() or Trim() to remove such loops if needed.
Public method Offset(double, OffsetGapType, double, bool) Computes a new poly which is an offset of this poly. The offsetted segments can be joined with an arc or by extension. This function automatically removes trivial (zero length) segments in the result poly. The resulting poly will _not_ be trimmed and may contain loops. Use Union() or Trim() to remove such loops if needed.
Public method OffsetRound(double) Untrimmed offset with Arc gaptype
Public method OffsetUnion(double, OffsetGapType, double) Offsets a closed poly and trims it using a self union. See Offset(...) and Union(...) function for more details. If the poly is open the result is undefined or an exception is thrown.
Public method Param(Point2d) Computes a parameter on the poly in the range 0-1 where a given point resides. If the point is further away than 1e-4 from the poly, an exception is thrown. If the point is at a self intersection of the poly, the first(lowest) parameter is computed.
Public method Pop() Removes the last point in the poly. If the poly is empty, an exception will be thrown.
Public method Static ReportDebugPoly(Poly2d, int)
Public method Reverse() Reverses the polygon in-place. Note that all bulge factors will be inverted.
Public method Rotate(double) Rotates the poly in-place with a specified angle in radians.
Public method Rotate(double, Point2d) Rotates the poly in-place with a given angle around a specified point.
Public method Scale(double) Scales the poly in-place with a given factor. Factors larger then 1 gives a larger geometry and smaller than 1 gives a smaller.
Public method Scale(double, Point2d) Scales the poly in-place with a given factor using a specified scaling center. Factors larger then 1 gives a larger geometry and smaller than 1 gives a smaller.
Public method Shorten(double) Shortens an open poly with dist (must be positive). If not possible a copy of the poly is returned unchanged.
Public method ShortestSeg() Returns the length of the shortest segment
Public method Split(IEnumerable<Point2d>) Tries to split a polygon into a list of subpolygons using the given points. If a point does not lie on the polygon, it is ignored.
Public method Split(IEnumerable<Double>) Splits the polygon into sub-polygons at a list of parameters in the range 0-1. The parameter list does _not_ need to be sorted. Any points outside the polygon are ignored. If the number of points on the polygon is N, the number of polys returned is exactly N+1.
Public method Split(params Point2d[]) Tries to split a polygon into a list of subpolygons using the given points. If a point does not lie on the polygon, it is ignored.
Public method Split(params double[]) Splits the polygon into sub-polygons at a list of parameters in the range 0-1. The parameter list does _not_ need to be sorted.
Public method Split(double, out Poly2d, out Poly2d) Splits this poly at a given parameter. If this poly is closed, a single result with a poly open at that point is computed, otherwise two result polygons is computed.
Public method Stroke(double, LineCapMode, OffsetGapType, double) Returns a new poly that is a two-way offset of this poly, which for example is suitable when this poly is to be rasterized as a fat line. Line joins and end caps can be choosen. If the poly is closed, an exception will be thrown. The result is _not_ trimmed. See Union() function for this.
Public method SubPoly(double, double) Splits a poly at startparam and creates an open poly of paramlength If paramlength is negative direction is reversed Handles any parameters not just in 0-1
Public method Swell(double) Shortcut to Stroke(...) the poly with Round linecaps and round endcaps, that is the 'real' offset of the line (all points of the result has the given distance to the original line). The result is _not_ trimmed. See Union() function for this. If the poly is closed, an exception will be thrown.
Public method ToPoints() Returns the polys points as a list of Point2d
Public method ToRegion(double) Creates a region representing the poly exactly.
Public method ToString() Returns a new string that contains debug information for the poly.
Public method Transform(Matrix2d) Transforms the poly in-place with a matrix.
Public method Translate(double, double) Translates the poly in-place by a given delta x and delta y.
Public method TryClose(double) Tries to close the poly. Removes last point and sets closed=true.
Public method Union() Computes a self-union of this poly. This will for example remove loops created by an offset of a closed polygon. Note that clockwise polygons are seen as holes and will produce no results if union:ed.
Public method WriteAutoCADScript(StreamWriter, int) Appends text that can be loaded in AutoCAD as a script to a stream.
Top
Fields
 
Name Description
Public field Static DebugPolyCallback
Top

.NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

In this article

Definition