Polygon
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
public class Polygon : PolyCurve
{
internal IPolygonEntity PolygonEntity => HostImpl as IPolygonEntity;
public Point[] Points => Point.Wrap(PolygonEntity.get_Points(), true);
[Scaling()]
public double PlaneDeviation {
get {
return PolygonEntity.get_PlaneDeviation() * DesignScriptEntity.scaleFactor;
}
}
internal Polygon(IPolygonEntity host, bool persist)
: base(host, persist)
{
}
public override string ToString()
{
return "Polygon";
}
internal new static void InitType()
{
Geometry.RegisterHostType(typeof(IPolygonEntity), (IGeometryEntity host, bool persist) => new Polygon(host as IPolygonEntity, persist));
}
internal static Polygon Wrap(IPolygonEntity host, bool persist = true)
{
return Geometry.Wrap(host, false, null) as Polygon;
}
internal static Polygon[] Wrap(IPolygonEntity[] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static Polygon[][] Wrap(IPolygonEntity[][] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static IPolygonEntity[][] Unwrap(Polygon[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IPolygonEntity[] Unwrap(Polygon[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IPolygonEntity[] Unwrap(IEnumerable<Polygon> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IPolygonEntity Unwrap(Polygon o)
{
return o.PolygonEntity;
}
public static Polygon ByPoints(IEnumerable<Point> points)
{
return Wrap(HostFactory.Factory.PolygonByPoints(Point.Unwrap(points)), true);
}
public static Polygon RegularPolygon(Circle circle, int numberSides = 5)
{
return Wrap(HostFactory.Factory.PolygonRegularPolygon(Circle.Unwrap(circle), numberSides), true);
}
public Point[] Corners()
{
return Point.Wrap(PolygonEntity.Corners(), true);
}
public Point Center()
{
return Point.Wrap(PolygonEntity.Center(), true);
}
public Point[] SelfIntersections()
{
return Point.Wrap(PolygonEntity.SelfIntersections(), true);
}
public bool ContainmentTest(Point point)
{
return PolygonEntity.ContainmentTest(Point.Unwrap(point));
}
}
}