Class Polygon
A polygon represented as a planar straight line graph.
Inheritance
Inherited Members
Namespace: UnityEngine.Experimental.U2D.TriangleNet.Geometry
Syntax
public class Polygon : IPolygon
Constructors
Polygon()
Initializes a new instance of the Polygon class.
Declaration
public Polygon()
Polygon(Int32)
Initializes a new instance of the Polygon class.
Declaration
public Polygon(int capacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | The default capacity for the points list. |
Polygon(Int32, Boolean)
Initializes a new instance of the Polygon class.
Declaration
public Polygon(int capacity, bool markers)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | The default capacity for the points list. |
System.Boolean | markers | Use point and segment markers. |
Properties
Count
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
HasPointMarkers
Gets or sets a value indicating whether the vertices have marks or not.
Declaration
public bool HasPointMarkers { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Implements
HasSegmentMarkers
Gets or sets a value indicating whether the segments have marks or not.
Declaration
public bool HasSegmentMarkers { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Implements
Holes
Gets a list of points defining the holes of the polygon.
Declaration
public List<Point> Holes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Point> |
Implements
Points
Gets the vertices of the polygon.
Declaration
public List<Vertex> Points { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Vertex> |
Implements
Regions
Gets a list of pointers defining the regions of the polygon.
Declaration
public List<RegionPointer> Regions { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<RegionPointer> |
Implements
Segments
Gets the segments of the polygon.
Declaration
public List<ISegment> Segments { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<ISegment> |
Implements
Methods
Add(Contour, Boolean)
Add a contour to the polygon.
Declaration
public void Add(Contour contour, bool hole = false)
Parameters
Type | Name | Description |
---|---|---|
Contour | contour | The contour to insert. |
System.Boolean | hole | Treat contour as a hole. |
Implements
Add(Contour, Point)
Add a contour to the polygon.
Declaration
public void Add(Contour contour, Point hole)
Parameters
Type | Name | Description |
---|---|---|
Contour | contour | The contour to insert. |
Point | hole | Point inside the contour, making it a hole. |
Implements
Add(ISegment, Boolean)
Add a segment to the polygon.
Declaration
public void Add(ISegment segment, bool insert = false)
Parameters
Type | Name | Description |
---|---|---|
ISegment | segment | The segment to insert. |
System.Boolean | insert | If true, both endpoints will be added to the points list. |
Implements
Add(ISegment, Int32)
Add a segment to the polygon.
Declaration
public void Add(ISegment segment, int index)
Parameters
Type | Name | Description |
---|---|---|
ISegment | segment | The segment to insert. |
System.Int32 | index | The index of the segment endpoint to add to the points list (must be 0 or 1). |
Implements
Add(Vertex)
Add a vertex to the polygon.
Declaration
public void Add(Vertex vertex)
Parameters
Type | Name | Description |
---|---|---|
Vertex | vertex | The vertex to insert. |
Implements
AddContour(IEnumerable<Vertex>, Int32, Boolean, Boolean)
Declaration
[Obsolete("Use polygon.Add(contour) method instead.")]
public void AddContour(IEnumerable<Vertex> points, int marker = 0, bool hole = false, bool convex = false)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Vertex> | points | |
System.Int32 | marker | |
System.Boolean | hole | |
System.Boolean | convex |
Implements
AddContour(IEnumerable<Vertex>, Int32, Point)
Declaration
[Obsolete("Use polygon.Add(contour) method instead.")]
public void AddContour(IEnumerable<Vertex> points, int marker, Point hole)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Vertex> | points | |
System.Int32 | marker | |
Point | hole |
Implements
Bounds()
Compute the bounds of the polygon.
Declaration
public Rectangle Bounds()
Returns
Type | Description |
---|---|
Rectangle | Rectangle defining an axis-aligned bounding box. |