Triangulation Functions

Functions for creating, modifying, and querying 3D triangulation objects.

General

MTK_Triangulation_Close()

Close triangulation and release any memory used.

Note:  This does not save any changes.

Signature
int MTK_Triangulation_Close(MTK_Triangulation* triang);
Parameters

triang: Pointer to an MTK_Triangulation struct.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_IsValid()

Checks triangulation to confirm that it is a valid, usable triangulation.

Signature
int MTK_Triangulation_IsValid(MTK_Triangulation* triang);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

Returns
  • 1: MTK_Triangulation is valid.

  • 0: MTK_Triangulation is not valid.

  • -1: Error (message retrievable with MTK_API_GetError).

MTK_Triangulation_New()

Create a blank triangulation that values can be set to.

Note:  This call does not create an actual file.

Signature
MTK_Triangulation* MTK_Triangulation_New();
Parameters (None)
Returns
  • Pointer to an empty MTK_Triangulation struct (success).

  • Null pointer (failure).

MTK_Triangulation_Open()

Open triangulation file. Note that this can open both modern Vulcan triangulations and Vulcan 7.x triangulations.

Signature
MTK_Triangulation* MTK_Triangulation_Open(const char* name);
Parameters

name: Triangulation filename.

Returns
  • Pointer to an empty MTK_Triangulation struct (success).

  • Null pointer (failure).

Geometry

MTK_Triangulation_AddPoint()

Add the next point in the triangulation.

Signature
int MTK_Triangulation_AddPoint(
    MTK_Triangulation* triang,
    const double& x, const double& y, const double& z
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • x: Point x value.

  • y: Point y value.

  • z: Point z value.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_AddTriangle()

Add the next triangle in the triangulation.

Signature
int MTK_Triangulation_AddTriangle(
    MTK_Triangulation* triang,
    const int& p0, const int& p1, const int& p2
    );
Parameters
  • triang: pointer to an MTK_Triangulation struct.

  • p0: point 0 index.

  • p1: point 1 index.

  • p2: point 2 index.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_NumPoints()

Get number of points in triangulation.

Signature
int MTK_Triangulation_NumPoints(MTK_Triangulation* triang);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

Returns
  • int: Number of triangulation points.

  • -1: Failed.

MTK_Triangulation_NumTriangles()

Get number of triangles in triangulation.

Signature
int MTK_Triangulation_NumTriangles(MTK_Triangulation* triang);
Parameters

triang: Pointer to an MTK_Triangulation struct.

Returns
  • int: Number of triangulation triangles.

  • -1: Failed.

MTK_Triangulation_GetPoint()

Get point located at specified index.

Signature
int MTK_Triangulation_GetPoint(
    MTK_Triangulation* triang,
    const int& i,
    double* x, double* y, double* z
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • i: Point index.

  • x: Point x value.

  • y: Point y value.

  • z: Point z value.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetTriangle()

Get triangle point index at specified index.

Signature
int MTK_Triangulation_GetTriangle(
    MTK_Triangulation* triang,
    const int& i,
    int* p0, int* p1, int* p2
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • i: Triangle index.

  • p0: Point 0 index.

  • p1: Point 1 index.

  • p2: Point 2 index.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetVolume()

Get the volume of the triangulation.

Signature
int MTK_Triangulation_GetVolume(
    MTK_Triangulation* triang, double* volume);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • volume: The volume of the triangulation.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_IsPointInside()

Get if a point is inside a triangulation.

Signature
int MTK_Triangulation_IsPointInside(
    MTK_Triangulation* triang,
    const double& x, const double& y, const double& z
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • x: The point x value.

  • y: The point y value.

  • z: The point z value.

Returns
  • 1: The point is inside the triangulation.

  • 0: The point is not inside the triangulation.

  • other: Failure.

MTK_Triangulation_IsPointOn()

Get if a point is on a triangulation.

Signature
int MTK_Triangulation_IsPointOn(
    MTK_Triangulation* triang,
    const double& x, const double& y, const double& z,
    const double& tol
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • x: The point x value.

  • y: The point y value.

  • z: The point z value.

  • tol: The tolerance to use.

Returns
  • 1: The point is on the triangulation.

  • 0: The point is not on the triangulation.

  • other: Failure.

Consistency and validation

MTK_Triangulation_IsConsistent()

Get if a triangulation is consistent or not.

Signature
int MTK_Triangulation_IsConsistent(
    MTK_Triangulation* triang);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

Returns
  • 1: The triangulation is consistent.

  • 0: The triangulation is not consistent.

  • other: Failure.

MTK_Triangulation_IsCrossing()

Get if a triangulation contains crossing triangles or not.

Signature
int MTK_Triangulation_IsCrossing(
    MTK_Triangulation* triang);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

Returns
  • 1: The triangulation contains crossing triangles.

  • 0: The triangulation does not contain crossing triangles.

  • other: Failure.

MTK_Triangulation_IsSolid()

Get if a triangulation is solid or not.

Signature
int MTK_Triangulation_IsSolid(
    MTK_Triangulation* triang);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

Returns
  • 1: The triangulation is solid.

  • 0: The triangulation is not solid.

  • other: Failure.

MTK_Triangulation_IsSurface()

Get if a triangulation is a surface or not.

Signature
int MTK_Triangulation_IsSurface(
    MTK_Triangulation* triang);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

Returns
  • 1: The triangulation is a surface.

  • 0: The triangulation is not a surface.

  • other: Failure.

Colour and texture

MTK_Triangulation_GetColour()

Get the RGB colour (0 to 255) of a triangulation.

Signature
int MTK_Triangulation_GetColour(
    MTK_Triangulation* triang,
    int* r, int* g, int* b
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • r: Red.

  • g: Green.

  • b: Blue.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetTexture()

Get the texture for the triangulation.

Signature
int MTK_Triangulation_GetTexture(
    MTK_Triangulation* triang, char* texture);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • texture: Buffer of size MTK_BUFFER_SIZE to receive the path of the texture.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetTranslucency()

Get the translucency value.

Signature
double MTK_Triangulation_GetTranslucency(
    MTK_Triangulation* triang);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

Returns
  • double: Translucency on a percentage scale (0 is opaque).

  • -1: Failed.

MTK_Triangulation_IsTextured()

Determine if triangulation texture is enabled.

Signature
int MTK_Triangulation_IsTextured(
    MTK_Triangulation* triang);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

Returns
  • 1: Texture is enabled.

  • 0: Texture is not enabled.

  • -1: Failed.

MTK_Triangulation_IsTranslucent()

Determine if translucency is on or off.

Signature
int MTK_Triangulation_IsTranslucent(
    MTK_Triangulation* triang);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

Returns
  • 1: Translucency enabled.

  • 0: Translucency not enabled.

  • -1: Failed.

MTK_Triangulation_SetColour()

Set the RGB colour (0 to 255) of a triangulation.

Signature
int MTK_Triangulation_SetColour(
    MTK_Triangulation* triang,
    const int& r, const int& g, const int& b
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • r: Red.

  • g: Green.

  • b: Blue.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_SetTexture()

Set the texture of the triangulation.

Signature
int MTK_Triangulation_SetTexture(
    MTK_Triangulation* triang,
    const char* texture, const int& enabled
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • texture: Path of the texture to use.

  • enabled: Whether to turn the texture on or off.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_SetTranslucency()

Set the translucency of the triangulation.

Signature
int MTK_Triangulation_SetTranslucency(
    MTK_Triangulation* triang,
    const double& value, const int& enabled
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • value: Percentage of how translucent the triangulation is (0 is opaque).

  • enabled: Whether translucency is on or off.

Returns

0 on success; any other value indicates failure.

Attributes

MTK_Triangulation_AttributeType (enum)

Enumeration of attribute types.

enum MTK_Triangulation_AttributeType 
{
    TRI_ATTRIBUTE_UNDEFINED,
    TRI_ATTRIBUTE_INT32,
    TRI_ATTRIBUTE_INT64,
    TRI_ATTRIBUTE_BOOLEAN,
    TRI_ATTRIBUTE_DOUBLE,
    TRI_ATTRIBUTE_STRING,
    TRI_ATTRIBUTE_DATE_YMD,
    TRI_ATTRIBUTE_DATE_DMY,
    TRI_ATTRIBUTE_DATE_MDY
};

MTK_Triangulation_AddAttributeBoolean()

Add a boolean attribute to the triangulation.

Signature
int MTK_Triangulation_AddAttributeBoolean(
    MTK_Triangulation* triang,
    const char* name,
    const int& value
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to be added.

  • value: Value of the added attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_AddAttributeDateDMY()

Add a DD-MM-YYYY formatted date attribute to triangulation.

Signature
int MTK_Triangulation_AddAttributeDateDMY(
    MTK_Triangulation* triang,
    const char* name,
    const int& year,
    const int& month,
    const int& day
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to be added.

  • year: Year of the added attribute.

  • month: Month of the added attribute.

  • day: Day of the added attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_AddAttributeDateMDY()

Add a MM-DD-YYYY formatted date attribute to triangulation.

Signature
int MTK_Triangulation_AddAttributeDateMDY(
    MTK_Triangulation* triang,
    const char* name,
    const int& year,
    const int& month,
    const int& day
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to be added.

  • year: Year of the added attribute.

  • month: Month of the added attribute.

  • day: Day of the added attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_AddAttributeDateYMD()

Add a YYYY-MM-DD formatted date attribute to triangulation.

Signature
int MTK_Triangulation_AddAttributeDateYMD(
    MTK_Triangulation* triang,
    const char* name,
    const int& year,
    const int& month,
    const int& day
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to be added.

  • year: Year of the added attribute.

  • month: Month of the added attribute.

  • day: Day of the added attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_AddAttributeDouble()

Add a double attribute to the triangulation.

Signature
int MTK_Triangulation_AddAttributeDouble(
    MTK_Triangulation* triang,
    const char* name,
    const double& value
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to be added.

  • value: Value of the added attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_AddAttributeInt32()

Add a 32-bit integer attribute to the triangulation.

Signature
int MTK_Triangulation_AddAttributeInt32(
    MTK_Triangulation* triang,
    const char* name,
    const int& value
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to be added.

  • value: Value of the added attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_AddAttributeInt64()

Add a 64-bit integer attribute to the triangulation.

Signature
int MTK_Triangulation_AddAttributeInt64(
    MTK_Triangulation* triang,
    const char* name,
    const long long& value
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to be added.

  • value: Value of the added attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_AddAttributeString()

Add a string attribute to the triangulation.

Signature
int MTK_Triangulation_AddAttributeString(
    MTK_Triangulation* triang,
    const char* name,
    const char* value
    );
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to be added.

  • value: Value of the added attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_DeleteAttribute()

Delete the attribute with given name.

Signature
int MTK_Triangulation_DeleteAttribute(
    MTK_Triangulation* triang, const char* name);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to be deleted.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetAttributeAsBoolean()

Get the attribute with specified name from the triangulation.

Signature
int MTK_Triangulation_GetAttributeAsBoolean(
    MTK_Triangulation* triang,
    const char* name,
    int* value
    );
Parameters
  • triang: pointer to an MTK_Triangulation struct.

  • name: name of the attribute to get.

  • value: value of the attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetAttributeAsDate()

Get the attribute with specified name from the triangulation.

Signature
int MTK_Triangulation_GetAttributeAsDate(
    MTK_Triangulation* triang,
    const char* name,
    int* year, int* month, int* day);
Parameters
  • triang: Pointer to an MTK_Triangulation struct.

  • name: Name of the attribute to get.

  • year: Year of the attribute.

  • month: Month of the attribute.

  • day: Day of the attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetAttributeAsDouble()

Get the attribute with specified name from the triangulation.

Signature
int MTK_Triangulation_GetAttributeAsDouble(
    MTK_Triangulation* triang,
    const char* name, double* value
    );
Parameters
  • triang: pointer to an MTK_Triangulation struct.

  • name: name of the attribute to get.

  • value: value of the attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetAttributeAsInt32()

Get the attribute with specified name from the triangulation.

Signature
int MTK_Triangulation_GetAttributeAsInt32(
    MTK_Triangulation* triang,
    const char* name, int* value
    );
Parameters
  • triang: pointer to an MTK_Triangulation struct.

  • name: name of the attribute to get.

  • value: value of the attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetAttributeAsInt64()

Get the attribute with specified name from the triangulation.

Signature
int MTK_Triangulation_GetAttributeAsInt64(
    MTK_Triangulation* triang,
    const char* name, long long* value
    );
Parameters
  • triang: pointer to an MTK_Triangulation struct.

  • name: name of the attribute to get.

  • value: value of the attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetAttributeAsString()

Get the attribute with specified name from the triangulation.

Signature
int MTK_Triangulation_GetAttributeAsString(
    MTK_Triangulation* triang,
    const char* name, char* value
    );
Parameters
  • triang: pointer to an MTK_Triangulation struct.

  • name: name of the attribute to get.

  • value: buffer of size MTK_BUFFER_SIZE to receive the value of the attribute.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetAttributeNames()

Gets a list of current attribute names in the triangulation.

Signature
int MTK_Triangulation_GetAttributeNames(
    MTK_Triangulation* triang,
    char** names, int* count
    );
Parameters
  • triang: pointer to an MTK_Triangulation struct.

  • names: buffer of size MTK_BUFFER_SIZE * MTK_BUFFER_SIZE to receive the attribute name list.

  • count: number of attribute names returned in buffer.

Returns

0 on success; any other value indicates failure.

MTK_Triangulation_GetAttributeType()

Get the specified attribute's type.

Signature
int MTK_Triangulation_GetAttributeType(
    MTK_Triangulation* triang,
    const char* name, MTK_Triangulation_AttributeType* type
    );
Parameters
Returns

0 on success; any other value indicates failure.