Mesh
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
public class Mesh : DesignScriptEntity
{
internal IMeshEntity MeshEntity => HostImpl as IMeshEntity;
public IndexGroup[] FaceIndices => IndexGroup.Wrap(MeshEntity.get_FaceIndices(), true);
[Scaling()]
public Vector[] VertexNormals {
get {
return Vector.Wrap((from x in (IEnumerable<IVectorEntity>)MeshEntity.get_VertexNormals()
select x.Scale(1 / DesignScriptEntity.scaleFactor)).ToArray(), true);
}
}
public Point[] VertexPositions => Point.Wrap(MeshEntity.get_VertexPositions(), true);
internal Mesh(IMeshEntity host, bool persist)
: base(host, persist)
{
}
public override string ToString()
{
return "Mesh";
}
internal static Mesh Wrap(IMeshEntity host, bool persist = true)
{
if (host == null)
return null;
return new Mesh(host, persist);
}
internal static Mesh[] Wrap(IMeshEntity[] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static Mesh[][] Wrap(IMeshEntity[][] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static IMeshEntity[][] Unwrap(Mesh[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IMeshEntity[] Unwrap(Mesh[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IMeshEntity[] Unwrap(IEnumerable<Mesh> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IMeshEntity Unwrap(Mesh o)
{
return o.MeshEntity;
}
public static Mesh ByPointsFaceIndices(IEnumerable<Point> vertexPositions, IEnumerable<IndexGroup> indices)
{
return Wrap(HostFactory.Factory.MeshByPointsFaceIndices(Point.Unwrap(vertexPositions), IndexGroup.Unwrap(indices)), true);
}
}
}