Tekla Open API

Detailed and full API reference helps you master Tekla Open API

This is the most recent version of Tekla Open API.
For older versions, please visit Tekla Warehouse.

Mesh Class

The Mesh class represents a mesh for drawing three-dimensional data.
Inheritance Hierarchy
SystemObject
  Tekla.Structures.Model.UIMesh

Namespace:  Tekla.Structures.Model.UI
Assembly:  Tekla.Structures.Model (in Tekla.Structures.Model.dll) Version: 2018.1.0.0 (2018.1.0.0)
Syntax
[SerializableAttribute]
public sealed class Mesh

The Mesh type exposes the following members.

Constructors
  Name Description
Public method Mesh
Creates a new empty mesh instance.
Public method Mesh(ArrayList, ArrayList, ArrayList)
Creates a new mesh instance with the given points, triangles and lines. Does not check the indices in the given triangles and lines array lists for correctness.
Top
Properties
  Name Description
Public property Lines
An array list of indices (as integers) pointing to the points array list. Two consecutive indices always represent a single line.
Public property Points
An array list of point objects representing the mesh points.
Public property Triangles
An array list of indices (as integers) pointing to the points array list. Three consecutive indices always represent a single triangle.
Top
Methods
  Name Description
Public method AddLine
Adds a new line in the mesh.
Public method AddPoint
Adds a new point in the mesh.
Public method AddTriangle
Adds a new triangle in the mesh.
Top
Examples
using Tekla.Structures.Model.UI;
using Tekla.Structures.Geometry3d;
using System;

public class ConeMesh
{
    private Mesh _mesh;

    public Mesh Mesh
    {
        get { return _mesh; }
    }

    public ConeMesh(Point center, double height, double radius, int segmentCount)
    {
        _mesh = new Mesh();
        Point centerTop = new Point(center);
        centerTop.Z = centerTop.Z + height;
        _mesh.Points.Add(centerTop);

        double x = center.X + radius * Math.Cos(0.0);
        double y = center.Y + radius * Math.Sin(0.0);
        double z = center.Z;

        Point p = new Point(x, y, z);
        _mesh.AddPoint(p);
        _mesh.AddLine(0, 1);

        for (int i = 1; i < segmentCount; i++)
        {
            x = center.X + radius * Math.Cos(i * (2 * Math.PI) / segmentCount);
            y = center.Y + radius * Math.Sin(i * (2 * Math.PI) / segmentCount);
            z = center.Z;

            p = new Point(x, y, z);

            _mesh.AddPoint(p);
            _mesh.AddTriangle(0, i, i + 1);
            _mesh.AddLine(0, i + 1);
            _mesh.AddLine(i, i + 1);
        }

        _mesh.AddTriangle(0, segmentCount, 1);
        _mesh.AddLine(segmentCount, 1);
    }
}

public class Example
{
       public void Example1()
       {
           GraphicsDrawer drawer = new GraphicsDrawer();
           ConeMesh cone = new ConeMesh(new Point(0.0, 0.0, 0.0), 5000.0, 5000.0, 100);

           drawer.DrawMeshSurface(cone.Mesh, new Color(1.0, 0.0, 0.0, 1.0));
           drawer.DrawMeshLines(cone.Mesh, new Color(0.0, 0.0, 1.0));
       }
}
See Also