BoundingBox
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
public class BoundingBox : DesignScriptEntity
{
internal IBoundingBoxEntity BoundingBoxEntity => HostImpl as IBoundingBoxEntity;
public Point MinPoint => Point.Wrap(BoundingBoxEntity.get_MinPoint(), true);
public Point MaxPoint => Point.Wrap(BoundingBoxEntity.get_MaxPoint(), true);
[IsVisibleInDynamoLibrary(false)]
public CoordinateSystem ContextCoordinateSystem {
get {
return CoordinateSystem.Wrap(BoundingBoxEntity.get_ContextCoordinateSystem(), true);
}
}
internal BoundingBox(IBoundingBoxEntity host, bool persist)
: base(host, persist)
{
}
public override string ToString()
{
return "BoundingBox(MinPoint = " + MinPoint + ", MaxPoint = " + MaxPoint + ", ContextCoordinateSystem = " + ContextCoordinateSystem + ")";
}
protected override bool Equals(DesignScriptEntity other)
{
if (base.Equals(other))
return true;
BoundingBox boundingBox = other as BoundingBox;
if (boundingBox == null)
return false;
if (boundingBox.MinPoint.Equals(MinPoint))
return boundingBox.MaxPoint.Equals(MaxPoint);
return false;
}
protected override int ComputeHashCode()
{
return (17 * 23 + MinPoint.GetHashCode()) * 23 + MaxPoint.GetHashCode();
}
internal static BoundingBox Wrap(IBoundingBoxEntity host, bool persist = true)
{
if (host == null)
return null;
return new BoundingBox(host, persist);
}
internal static BoundingBox[] Wrap(IBoundingBoxEntity[] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static BoundingBox[][] Wrap(IBoundingBoxEntity[][] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static IBoundingBoxEntity[][] Unwrap(BoundingBox[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IBoundingBoxEntity[] Unwrap(BoundingBox[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IBoundingBoxEntity[] Unwrap(IEnumerable<BoundingBox> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IBoundingBoxEntity Unwrap(BoundingBox o)
{
return o.BoundingBoxEntity;
}
[SupressImportIntoVM]
[Obsolete("This method is deprecated, use BoundingBoxByGeometry(IGeometryEntity[] geom) instead")]
public static BoundingBox ByGeometry(Geometry geom)
{
return Wrap(HostFactory.Factory.BoundingBoxByGeometry(Geometry.Unwrap(geom)), true);
}
public static BoundingBox ByGeometry(IEnumerable<Geometry> geom)
{
return Wrap(HostFactory.Factory.BoundingBoxByGeometry(Geometry.Unwrap(geom)), true);
}
[IsVisibleInDynamoLibrary(false)]
public static BoundingBox ByGeometryCoordinateSystem(Geometry geom, [DefaultArgument("CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem cs)
{
return Wrap(HostFactory.Factory.BoundingBoxByGeometryCoordinateSystem(Geometry.Unwrap(geom), CoordinateSystem.Unwrap(cs)), true);
}
[IsVisibleInDynamoLibrary(false)]
public static BoundingBox ByGeometryCoordinateSystem(IEnumerable<Geometry> geom, [DefaultArgument("CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem cs)
{
return Wrap(HostFactory.Factory.BoundingBoxByGeometryCoordinateSystem(Geometry.Unwrap(geom), CoordinateSystem.Unwrap(cs)), true);
}
public static BoundingBox ByCorners([DefaultArgument("Point.ByCoordinates(0, 0, 0)")] Point min, [DefaultArgument("Point.ByCoordinates(1, 1, 1)")] Point max)
{
return Wrap(HostFactory.Factory.BoundingBoxByCorners(Point.Unwrap(min), Point.Unwrap(max)), true);
}
[IsVisibleInDynamoLibrary(false)]
public static BoundingBox ByCornersCoordinateSystem([DefaultArgument("Point.ByCoordinates(0, 0, 0)")] Point min, [DefaultArgument("Point.ByCoordinates(1, 1, 1)")] Point max, [DefaultArgument("CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem cs)
{
return Wrap(HostFactory.Factory.BoundingBoxByCornersCoordinateSystem(Point.Unwrap(min), Point.Unwrap(max), CoordinateSystem.Unwrap(cs)), true);
}
public BoundingBox Intersection(BoundingBox other)
{
return Wrap(BoundingBoxEntity.Intersection(Unwrap(other)), true);
}
public bool Intersects(BoundingBox other)
{
return BoundingBoxEntity.Intersects(Unwrap(other));
}
public bool IsEmpty()
{
return BoundingBoxEntity.IsEmpty();
}
public bool Contains(Point point)
{
return BoundingBoxEntity.Contains(Point.Unwrap(point));
}
public Cuboid ToCuboid()
{
return Cuboid.Wrap(BoundingBoxEntity.ToCuboid(), true);
}
public PolySurface ToPolySurface()
{
return PolySurface.Wrap(BoundingBoxEntity.ToPolySurface(), true);
}
}
}