Show / Hide Table of Contents

    Class Mesh

    A triangle mesh.

    Inheritance
    System.Object
    Mesh
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Elements.Geometry
    Assembly: Hypar.Elements.dll
    Syntax
    [JsonConverter(typeof(MeshConverter))]
    public class Mesh

    Constructors

    Mesh()

    Construct an empty mesh.

    Declaration
    public Mesh()

    Mesh(Mesh)

    Create a new mesh from another mesh by copying vertices and triangles.

    Declaration
    public Mesh(Mesh mesh)
    Parameters
    Type Name Description
    Mesh mesh

    Mesh(IList<Vertex>, IList<Triangle>)

    Construct a mesh.

    Declaration
    [JsonConstructor]
    public Mesh(IList<Vertex> vertices, IList<Triangle> triangles)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vertex> vertices

    The vertices of the mesh.

    System.Collections.Generic.IList<Triangle> triangles

    The triangles of the mesh.

    Properties

    BoundingBox

    The mesh's bounding box.

    Declaration
    public BBox3 BoundingBox { get; }
    Property Value
    Type Description
    BBox3

    Triangles

    The mesh's triangles.

    Declaration
    [JsonProperty("Triangles", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
    public IList<Triangle> Triangles { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.IList<Triangle>

    Vertices

    The mesh's vertices.

    Declaration
    [JsonProperty("Vertices", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
    public IList<Vertex> Vertices { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.IList<Vertex>

    Methods

    AddTriangle(Triangle)

    Add a triangle to the mesh.

    Declaration
    public Triangle AddTriangle(Triangle t)
    Parameters
    Type Name Description
    Triangle t

    The triangle to add.

    Returns
    Type Description
    Triangle

    AddTriangle(Vertex, Vertex, Vertex)

    Add a triangle to the mesh.

    Declaration
    public Triangle AddTriangle(Vertex a, Vertex b, Vertex c)
    Parameters
    Type Name Description
    Vertex a

    The first vertex.

    Vertex b

    The second vertex.

    Vertex c

    The third vertex.

    Returns
    Type Description
    Triangle

    AddVertex(Vector3, UV, Vector3, Color, Boolean, Double)

    Add a vertex to the mesh.

    Declaration
    public Vertex AddVertex(Vector3 position, UV uv = default(UV), Vector3 normal = default(Vector3), Color color = default(Color), bool merge = false, double edgeAngle = 30)
    Parameters
    Type Name Description
    Vector3 position

    The position of the vertex.

    UV uv

    The texture coordinate of the vertex.

    Vector3 normal

    The vertex's normal.

    Color color

    The vertex's color.

    System.Boolean merge

    If true, and a vertex already exists with a position within Vector3.EPSILON, that vertex will be returned.

    System.Double edgeAngle

    If merge is true, vertices will be merged if the angle between them is less than edgeAngle.

    Returns
    Type Description
    Vertex

    The newly created vertex.

    AddVertex(Vertex)

    Add a vertex to the mesh.

    Declaration
    public Vertex AddVertex(Vertex v)
    Parameters
    Type Name Description
    Vertex v

    The vertex to add.

    Returns
    Type Description
    Vertex

    ComputeNormals()

    Compute the vertex normals by averaging the normals of the incident faces.

    Declaration
    public void ComputeNormals()

    FromSTL(String, Units.LengthUnit)

    Construct a mesh from an STL file.

    Declaration
    public static Mesh FromSTL(string stlPath, Units.LengthUnit unit = Units.LengthUnit.Millimeter)
    Parameters
    Type Name Description
    System.String stlPath

    The path to the STL file.

    Units.LengthUnit unit

    The length unit used in the file.

    Returns
    Type Description
    Mesh

    GetBuffers()

    Get all buffers required for rendering.

    Declaration
    public GraphicsBuffers GetBuffers()
    Returns
    Type Description
    GraphicsBuffers

    GetNakedBoundaries()

    Get the naked edges of this mesh as polylines

    Declaration
    public List<Polyline> GetNakedBoundaries()
    Returns
    Type Description
    System.Collections.Generic.List<Polyline>

    GetNakedEdges()

    Get the open edges of this mesh.

    Declaration
    public List<Line> GetNakedEdges()
    Returns
    Type Description
    System.Collections.Generic.List<Line>

    Intersects(Ray, out Vector3)

    Does the provided ray intersect this mesh mesh?

    Declaration
    public bool Intersects(Ray ray, out Vector3 intersection)
    Parameters
    Type Name Description
    Ray ray

    The Ray to intersect.

    Vector3 intersection

    The location of intersection.

    Returns
    Type Description
    System.Boolean

    True if an intersection result occurs. False if no intersection occurs.

    RemoveTriangle(Triangle)

    Removes the specified triangle from the mesh and updates the vertex-triangle relationships.

    Declaration
    public void RemoveTriangle(Triangle face)
    Parameters
    Type Name Description
    Triangle face

    The triangle to remove.

    Sphere(Double, Int32)

    A mesh sphere.

    Declaration
    public static Mesh Sphere(double radius, int divisions = 10)
    Parameters
    Type Name Description
    System.Double radius

    The radius of the sphere.

    System.Int32 divisions

    The number of tessellations of the sphere.

    Returns
    Type Description
    Mesh

    A mesh.

    ToString()

    Get a string representation of the mesh.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.Object.ToString()

    Volume()

    Calculate the volume of the mesh. This value will be inexact for open meshes.

    Declaration
    public double Volume()
    Returns
    Type Description
    System.Double

    The volume of the mesh.