Cuboid
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
public class Cuboid : Solid
{
internal ICuboidEntity CuboidEntity => HostImpl as ICuboidEntity;
public double Length => CuboidEntity.Length;
public double Width => CuboidEntity.Width;
public double Height => CuboidEntity.Height;
internal Cuboid(ICuboidEntity host, bool persist)
: base(host, persist)
{
}
public override string ToString()
{
return "Cuboid(Length = " + Length.ToString(GeometryExtension.DoublePrintFormat, CultureInfo.InvariantCulture) + ", Width = " + Width.ToString(GeometryExtension.DoublePrintFormat, CultureInfo.InvariantCulture) + ", Height = " + Height.ToString(GeometryExtension.DoublePrintFormat, CultureInfo.InvariantCulture) + ")";
}
internal new static void InitType()
{
Geometry.RegisterHostType(typeof(ICuboidEntity), (IGeometryEntity host, bool persist) => new Cuboid(host as ICuboidEntity, persist));
}
internal static Cuboid Wrap(ICuboidEntity host, bool persist = true)
{
return Geometry.Wrap(host, false, null) as Cuboid;
}
internal static Cuboid[] Wrap(ICuboidEntity[] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static Cuboid[][] Wrap(ICuboidEntity[][] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static ICuboidEntity[][] Unwrap(Cuboid[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ICuboidEntity[] Unwrap(Cuboid[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ICuboidEntity[] Unwrap(IEnumerable<Cuboid> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ICuboidEntity Unwrap(Cuboid o)
{
return o.CuboidEntity;
}
public static Cuboid ByLengths(double width = 1, double length = 1, double height = 1)
{
return Wrap(HostFactory.Factory.CuboidByLengths(width, length, height), true);
}
public static Cuboid ByLengths([DefaultArgument("Point.ByCoordinates(0, 0, 0)")] Point origin, double width = 1, double length = 1, double height = 1)
{
return Wrap(HostFactory.Factory.CuboidByLengths(Point.Unwrap(origin), width, length, height), true);
}
public static Cuboid ByLengths([DefaultArgument("CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem cs, double width = 1, double length = 1, double height = 1)
{
return Wrap(HostFactory.Factory.CuboidByLengths(CoordinateSystem.Unwrap(cs), width, length, height), true);
}
public static Cuboid ByCorners([DefaultArgument("Point.ByCoordinates(0, 0, 0)")] Point lowPoint, [DefaultArgument("Point.ByCoordinates(1, 1, 1)")] Point highPoint)
{
return Wrap(HostFactory.Factory.CuboidByCorners(Point.Unwrap(lowPoint), Point.Unwrap(highPoint)), true);
}
}
}