Curve
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
public class Curve : Geometry
{
internal ICurveEntity CurveEntity => HostImpl as ICurveEntity;
public double Length => CurveEntity.Length;
public bool IsPlanar => CurveEntity.IsPlanar;
public bool IsClosed => CurveEntity.IsClosed;
public Point StartPoint => Point.Wrap(CurveEntity.StartPoint, true);
public Point EndPoint => Point.Wrap(CurveEntity.EndPoint, true);
public Vector Normal => Vector.Wrap(CurveEntity.Normal, true);
internal Curve(ICurveEntity host, bool persist)
: base(host, persist)
{
}
public override string ToString()
{
return "Curve(StartPoint = " + StartPoint + ", EndPoint = " + EndPoint + ")";
}
internal static void InitType()
{
Geometry.RegisterHostType(typeof(ICurveEntity), (IGeometryEntity host, bool persist) => new Curve(host as ICurveEntity, persist));
}
internal static Curve Wrap(ICurveEntity host, bool persist = true)
{
return Geometry.Wrap(host, false, null) as Curve;
}
internal static Curve[] Wrap(ICurveEntity[] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static Curve[][] Wrap(ICurveEntity[][] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static ICurveEntity[][] Unwrap(Curve[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ICurveEntity[] Unwrap(Curve[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ICurveEntity[] Unwrap(IEnumerable<Curve> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static ICurveEntity Unwrap(Curve o)
{
return o.CurveEntity;
}
public static Curve ByParameterLineOnSurface(Surface baseSurface, UV startParams, UV endParams)
{
return Wrap(HostFactory.Factory.CurveByParameterLineOnSurface(Surface.Unwrap(baseSurface), UV.Unwrap(startParams), UV.Unwrap(endParams)), true);
}
public static Curve ByBlendBetweenCurves(Curve curve1, Curve curve2, bool endOrStart1 = true, bool endOrStart2 = false)
{
return Wrap(HostFactory.Factory.CurveByBlendBetweenCurves(Unwrap(curve1), Unwrap(curve2), endOrStart1, endOrStart2), true);
}
public static Curve ByIsoCurveOnSurface(Surface baseSurface, int direction = 0, double parameter = 0)
{
return Wrap(HostFactory.Factory.CurveByIsoCurveOnSurface(Surface.Unwrap(baseSurface), direction, parameter), true);
}
public Point PointAtParameter(double param = 0)
{
return Point.Wrap(CurveEntity.PointAtParameter(param), true);
}
public Vector TangentAtParameter(double param = 0)
{
return Vector.Wrap(CurveEntity.TangentAtParameter(param), true);
}
public Vector NormalAtParameter(double param = 0)
{
return Vector.Wrap(CurveEntity.NormalAtParameter(param), true);
}
public CoordinateSystem CoordinateSystemAtParameter(double param = 0)
{
return CoordinateSystem.Wrap(CurveEntity.CoordinateSystemAtParameter(param), true);
}
public CoordinateSystem HorizontalFrameAtParameter(double param = 0)
{
return CoordinateSystem.Wrap(CurveEntity.HorizontalFrameAtParameter(param), true);
}
public Plane PlaneAtParameter(double param = 0)
{
return Plane.Wrap(CurveEntity.PlaneAtParameter(param), true);
}
public Point PointAtDistance(double distance = 0)
{
return Point.Wrap(CurveEntity.PointAtDistance(distance), true);
}
public CoordinateSystem CoordinateSystemAtDistance(double distance = 0)
{
return CoordinateSystem.Wrap(CurveEntity.CoordinateSystemAtDistance(distance), true);
}
public Plane PlaneAtDistance(double distance = 0)
{
return Plane.Wrap(CurveEntity.PlaneAtDistance(distance), true);
}
public double DistanceAtParameter(double param = 0)
{
return CurveEntity.DistanceAtParameter(param);
}
public double ParameterAtDistance(double distance = 0)
{
return CurveEntity.ParameterAtDistance(distance);
}
public double ParameterAtChordLength(double distance = 0.5, double location = 0, bool forward = true)
{
return CurveEntity.ParameterAtChordLength(distance, location, forward);
}
public double StartParameter()
{
return CurveEntity.StartParameter();
}
public double EndParameter()
{
return CurveEntity.EndParameter();
}
public double LengthBetweenParameters(double startParam = 0, double endParam = 1)
{
return CurveEntity.LengthBetweenParameters(startParam, endParam);
}
public double ParameterAtPoint(Point point)
{
return CurveEntity.ParameterAtPoint(Point.Unwrap(point));
}
public Curve Reverse()
{
return Wrap(CurveEntity.Reverse(), true);
}
public Curve Offset(double distance = 1)
{
return Wrap(CurveEntity.Offset(distance), true);
}
public Curve PullOntoPlane(Plane plane)
{
return Wrap(CurveEntity.PullOntoPlane(Plane.Unwrap(plane)), true);
}
public Curve PullOntoSurface(Surface surface)
{
return Wrap(CurveEntity.PullOntoSurface(Surface.Unwrap(surface)), true);
}
public Curve[] DivideEqually(int divisions = 10)
{
return Wrap(CurveEntity.DivideEqually(divisions), true);
}
public Curve[] DivideByDistance(int divisions = 10)
{
return Wrap(CurveEntity.DivideByDistance(divisions), true);
}
public Curve[] DivideByLengthFromParameter(double length = 1, double parameter = 0)
{
return Wrap(CurveEntity.DivideByLengthFromParameter(length, parameter), true);
}
public Curve[] DivideByDistanceFromParameter(double distance = 1, double parameter = 0)
{
return Wrap(CurveEntity.DivideByDistanceFromParameter(distance, parameter), true);
}
public Curve ParameterTrimStart(double startParameter = 0)
{
return Wrap(CurveEntity.ParameterTrimStart(startParameter), true);
}
public Curve ParameterTrimEnd(double endParameter = 1)
{
return Wrap(CurveEntity.ParameterTrimEnd(endParameter), true);
}
public Curve ParameterTrim(double startParameter = 0, double endParameter = 1)
{
return Wrap(CurveEntity.ParameterTrim(startParameter, endParameter), true);
}
public Curve[] ParameterTrimInterior(double startParameter = 0, double endParameter = 1)
{
return Wrap(CurveEntity.ParameterTrimInterior(startParameter, endParameter), true);
}
public Curve[] ParameterTrimSegments(double[] parameters)
{
return Wrap(CurveEntity.ParameterTrimSegments(parameters), true);
}
public Curve[] ParameterTrimSegments(double[] parameters, bool discardEvenSegments = false)
{
return Wrap(CurveEntity.ParameterTrimSegments(parameters, discardEvenSegments), true);
}
public Curve[] ParameterSplit(double parameter = 0.5)
{
return Wrap(CurveEntity.ParameterSplit(parameter), true);
}
public Curve[] ParameterSplit(double[] parameters)
{
return Wrap(CurveEntity.ParameterSplit(parameters), true);
}
public PolyCurve Join(Curve curve)
{
return PolyCurve.Wrap(CurveEntity.Join(Unwrap(curve)), true);
}
public PolyCurve Join(IEnumerable<Curve> curves)
{
return PolyCurve.Wrap(CurveEntity.Join(Unwrap(curves)), true);
}
public Surface Extrude(double distance = 1)
{
return Surface.Wrap(CurveEntity.Extrude(distance), true);
}
public Surface Extrude([DefaultArgument("Vector.ByCoordinates(0, 0, 1)")] Vector direction)
{
return Surface.Wrap(CurveEntity.Extrude(Vector.Unwrap(direction)), true);
}
public Surface Extrude([DefaultArgument("Vector.ByCoordinates(0, 0, 1)")] Vector direction, double distance = 1)
{
return Surface.Wrap(CurveEntity.Extrude(Vector.Unwrap(direction), distance), true);
}
public Solid ExtrudeAsSolid(double distance = 1)
{
return Solid.Wrap(CurveEntity.ExtrudeAsSolid(distance), true);
}
public Solid ExtrudeAsSolid([DefaultArgument("Vector.ByCoordinates(0, 0, 1)")] Vector direction)
{
return Solid.Wrap(CurveEntity.ExtrudeAsSolid(Vector.Unwrap(direction)), true);
}
public Solid ExtrudeAsSolid([DefaultArgument("Vector.ByCoordinates(0, 0, 1)")] Vector direction, double distance = 1)
{
return Solid.Wrap(CurveEntity.ExtrudeAsSolid(Vector.Unwrap(direction), distance), true);
}
public Curve Extend(double distance, Point pickSide)
{
return Wrap(CurveEntity.Extend(distance, Point.Unwrap(pickSide)), true);
}
public Curve ExtendStart(double distance = 1)
{
return Wrap(CurveEntity.ExtendStart(distance), true);
}
public Curve ExtendEnd(double distance = 1)
{
return Wrap(CurveEntity.ExtendEnd(distance), true);
}
public Curve[] ApproximateWithArcAndLineSegments()
{
return Wrap(CurveEntity.ApproximateWithArcAndLineSegments(), true);
}
public NurbsCurve ToNurbsCurve()
{
return NurbsCurve.Wrap(CurveEntity.ToNurbsCurve(), true);
}
public Surface Patch()
{
return Surface.Wrap(CurveEntity.Patch(), true);
}
public Geometry[] Project(Geometry baseGeometry, Vector projectionDirection)
{
return Geometry.Wrap(CurveEntity.Project(Geometry.Unwrap(baseGeometry), Vector.Unwrap(projectionDirection)));
}
public Surface SweepAsSurface(Curve path)
{
return Surface.Wrap(CurveEntity.SweepAsSurface(Unwrap(path)), true);
}
public Solid SweepAsSolid(Curve path)
{
return Solid.Wrap(CurveEntity.SweepAsSolid(Unwrap(path)), true);
}
public Curve Simplify(double tolerance)
{
return Wrap(CurveEntity.Simplify(tolerance), true);
}
}
}