Triangulation Functions

Functions:

MTK_Triangulation_AddAttributeBoolean

int MTK_Triangulation_AddAttributeBoolean(
			MTK_Triangulation* triang,
			const char* name, const int& value
			);
			Version added: 9.0.0.64
		

Description

Add a boolean attribute to the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to be added (char*)

value

value of the added attribute (int)

Return Value

0

success

other

failure

MTK_Triangulation_AddAttributeDateDMY

int MTK_Triangulation_AddAttributeDateDMY(
			MTK_Triangulation* triang,
			const char* name, const int& year,
			const int& month, const int& day
			);
			Version added: 9.0.0.64
		

Description

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

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to be added (char*)

year

year of the added attribute (int)

month

month of the added attribute (int)

day

day of the added attribute (int)

Return Value

0

success

other

failure

MTK_Triangulation_AddAttributeDateMDY

int MTK_Triangulation_AddAttributeDateMDY(
			MTK_Triangulation* triang,
			const char* name, const int& year,
			const int& month, const int& day
			);
			Version added: 9.0.0.64
		

Description

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

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to be added (char*)

year

year of the added attribute (int)

month

month of the added attribute (int)

day

day of the added attribute (int)

Return Value

0

success

other

failure

MTK_Triangulation_AddAttributeDateYMD

int MTK_Triangulation_AddAttributeDateYMD(
			MTK_Triangulation* triang,
			const char* name, const int& year,
			const int& month, const int& day
			);
			Version added: 9.0.0.64
		

Description

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

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to be added (char*)

year

year of the added attribute (int)

month

month of the added attribute (int)

day

day of the added attribute (int)

Return Value

0

success

other

failure

MTK_Triangulation_AddAttributeDouble

int MTK_Triangulation_AddAttributeDouble(
			MTK_Triangulation* triang,
			const char* name, const double& value
			);
			Version added: 9.0.0.64
		

Description

Add a double attribute to the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to be added (char*)

value

value of the added attribute (double)

Return Value

0

success

other

failure

MTK_Triangulation_AddAttributeInt32

int MTK_Triangulation_AddAttributeInt32(
			MTK_Triangulation* triang,
			const char* name, const int& value
			);
			Version added: 9.0.0.64
		

Description

Add a 32-bit integer attribute to the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to be added (char*)

value

value of the added attribute (int)

Return Value

0

success

other

failure

MTK_Triangulation_AddAttributeInt64

int MTK_Triangulation_AddAttributeInt64(
			MTK_Triangulation* triang,
			const char* name,
			const long long& value
			);
			Version added: 9.0.0.64
		

Description

Add a 64-bit integer attribute to the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to be added (char*)

value

value of the added attribute (long long)

Return Value

0

success

other

failure

MTK_Triangulation_AddAttributeString

int MTK_Triangulation_AddAttributeString(
			MTK_Triangulation* triang,
			const char* name, const char* value
			);
			Version added: 9.0.0.64
		

Description

Add a string attribute to the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to be added (char*)

value

value of the added attribute (char*)

Return Value

0

success

other

failure

MTK_Triangulation_AddPoint

int MTK_Triangulation_AddPoint(
			MTK_Triangulation* triang,
			const double& x,
			const double& y,
			const double& z
			);
		

Description

Add the next point in the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

x

point x value (double)

y

point y value (double)

z

point z value (double)

Return Value

0

success

other

failure

MTK_Triangulation_AddTriangle

int MTK_Triangulation_AddTriangle(
			MTK_Triangulation* triang,
			const int& p0, const int& p1, const int& p2
			);
		

Description

Add the next triangle in the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

p0

point 0 index (int)

p1

point 1 index (int)

p2

point 2 index (int)

Return Value

0

success

other

failure

MTK_Triangulation_Close

int MTK_Triangulation_Close(MTK_Triangulation* triang);
		

Description

Close triangulation and release any memory used. Note: this does not save any changes.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

0

success

other

failure

See Also

MTK_Triangulation_Save

MTK_Triangulation_DeleteAttribute

int MTK_Triangulation_DeleteAttribute(
			MTK_Triangulation* triang,
			const char* name
			);
			Version added: 9.0.0.64
		

Description

Delete the attribute with given name.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to be deleted (char*)

Return Value

0

success

other

failure

failure

MTK_Triangulation_GetAttributeAsBoolean

int MTK_Triangulation_GetAttributeAsBoolean(
			MTK_Triangulation* triang,
			const char* name, int* value
			);
			Version added: 9.0.0.64
		

Description

Get the attribute with specified name from the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to get (char*)

value

value of the attribute (int*)

Return Value

0

success

other

failure

MTK_Triangulation_GetAttributeAsDate

int MTK_Triangulation_GetAttributeAsDate(
			MTK_Triangulation* triang,
			const char* name, int* year, 
			int* month, int* day
			);
			Version added: 9.0.0.64
		

Description

Get the attribute with specified name from the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to get (char*)

year

year of the attribute (int*)

month

month of the attribute (int*)

day

day of the attribute (int*)

Return Value

0

success

other

failure

MTK_Triangulation_GetAttributeAsDouble

int MTK_Triangulation_GetAttributeAsDouble(
			MTK_Triangulation* triang,
			const char* name, double* value
			);
			Version added: 9.0.0.64
		

Description

Get the attribute with specified name from the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to get (char*)

value

value of the attribute (double*)

Return Value

0

success

other

failure

MTK_Triangulation_GetAttributeAsInt32

int MTK_Triangulation_GetAttributeAsInt32(
			MTK_Triangulation* triang,
			const char* name, int* value
			);
			Version added: 9.0.0.64
		

Description

Get the attribute with specified name from the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to get (char*)

value

value of the attribute (int*)

Return Value

0

success

other

failure

MTK_Triangulation_GetAttributeAsInt64

int MTK_Triangulation_GetAttributeAsInt64(
			MTK_Triangulation* triang,
			const char* name, long long* value
			);
			Version added: 9.0.0.64
		

Description

Get the attribute with specified name from the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to get (char*)

value

value of the attribute (long long*)

Return Value

0

success

other

failure

MTK_Triangulation_GetAttributeAsString

int MTK_Triangulation_GetAttributeAsString(
			MTK_Triangulation* triang,
			const char* name, char* value
			);
			Version added: 9.0.0.64
		

Description

Get the attribute with specified name from the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to get (char*)

value

buffer of size

MTK_BUFFER_SIZE

to receive the value of the attribute (char*)

Return Value

0

success

other

failure

MTK_Triangulation_GetAttributeNames

int MTK_Triangulation_GetAttributeNames(
			MTK_Triangulation* triang,
			char** names, int* count
			);
			Version added: 9.0.0.64
		

Description

Gets a list of current attribute names in the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

names

buffer of size MTK_BUFFER_SIZE * MTK_BUFFER_SIZE to receive the attribute name list (char**)

count

number of attribute names returned in buffer (int*)

Return Value

0

success

other

failure

MTK_Triangulation_GetAttributeType

int MTK_Triangulation_GetAttributeType(
			MTK_Triangulation* triang,
			const char* name,
			MTK_Triangulation_AttributeType* type
			);
			Version added: 9.0.0.64
		

Description

Get the specified attributes type.

Parameters

triang

pointer to an MTK_Triangulation struct

name

name of the attribute to get (char*)

type

attribute type (MTK_Triangulation_AttributeType*) (see below)

Return Value

0

success

other

failure

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_GetColour

int MTK_Triangulation_GetColour(
			MTK_Triangulation* triang,
			int* r, int* g, int* b
			);
		

Description

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

Parameters

triang

pointer to an MTK_Triangulation struct

r

red   (int*)

g

green (int*)

b

blue  (int*)

Return Value

0

success

other

failure

See Also

MTK_Triangulation_SetColour

MTK_Triangulation_GetPoint

int MTK_Triangulation_GetPoint(
			MTK_Triangulation* triang,
			const int& i, double* x, double* y, double* z
			);
		

Description

Get point located at specified index.

Parameters

triang

pointer to an MTK_Triangulation struct

i

point index (int)

x

point x value (double*)

y

point y value (double*)

z

point z value (double*)

Return Value

0

success

other

failure

MTK_Triangulation_GetTexture

int MTK_Triangulation_GetTexture(MTK_Triangulation* triang, char* texture);
			Version added: 9.0.0.64
		

Description

Get the texture for the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

texture

buffer of size MTK_BUFFER_SIZE to receive the path of the texture (char*)

Return Value

0

success

other

failure

MTK_Triangulation_GetTranslucency

double MTK_Triangulation_GetTranslucency(MTK_Triangulation* triang);
		

Description

Get the translucency value.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

double

translucency on a percentage scale (0 is opaque)

-1

failed

MTK_Triangulation_GetTriangle

int MTK_Triangulation_GetTriangle(
			MTK_Triangulation* triang,
			const int& i, int* p0, int* p1, int* p2
			);
		

Description

Get triangle point index at specified index.

Parameters

triang

pointer to an MTK_Triangulation struct

i

triangle index (int)

p0

point 0 index  (int*)

p1

point 1 index  (int*)

p2

point 2 index  (int*)

Return Value

0

success

other

failure

MTK_Triangulation_GetVolume

int MTK_Triangulation_GetVolume(MTK_Triangulation* triang, double* volume);
			Version added: 9.0.0.1030
		

Description

Get the volume of the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

volume

the volume of the triangulation (double*)

Return Value

0

success

other

failure

See Also

MTK_Triangulation_IsSolid

MTK_Triangulation_IsConsistent

int MTK_Triangulation_IsConsistent(MTK_Triangulation* triang);
			Version added: 9.0.0.1030
		

Description

Get if a triangulation is consistent or not.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

1

The triangulation is consistent

0

The triangulation is not consistent

other

failure

See Also

MTK_Triangulation_IsSolid

MTK_Triangulation_IsCrossing

MTK_Triangulation_IsCrossing

int MTK_Triangulation_IsCrossing(MTK_Triangulation* triang);
			Version added: 9.0.0.1030
		

Description

Get if a triangulation contains crossing triangles or not.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

1

The triangulation contains crossing triangles

0

The triangulation does not contain crossing triangles

other

failure

See Also

MTK_Triangulation_IsSolid

MTK_Triangulation_IsConsistent

MTK_Triangulation_IsPointInside

int MTK_Triangulation_IsPointInside(
			MTK_Triangulation* triang,
			const double& x, const double& y, const double& z
			);
			Version added: 9.0.0.1030
		

Description

Get if a point is inside a triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

x

the point x value (double)

y

the point y value (double)

z

the point z value (double)

Return Value

1

The point is inside the triangulation

0

The point is not inside the triangulation

other

failure

See Also

MTK_Triangulation_IsSolid

MTK_Triangulation_IsPointOn

MTK_Triangulation_IsPointOn

int MTK_Triangulation_IsPointOn(
			MTK_Triangulation* triang,
			const double& x, const double& y, const double& z, const double& tol
			);
			Version added: 9.0.0.1030
		

Description

Get if a point is inside a triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

x

the point x value (double)

y

the point y value (double)

z

the point z value (double)

tol

the tolerance to use (double)

Return Value

1

The point is on the triangulation

0

The point is not on the triangulation

other

failure

See Also

MTK_Triangulation_IsPointInside

MTK_Triangulation_IsSolid

int MTK_Triangulation_IsSolid(MTK_Triangulation* triang);
			Version added: 9.0.0.1030
		

Description

Get if a triangulation is solid or not.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

1

The triangulation is solid

0

The triangulation is not solid

other

failure

See Also

MTK_Triangulation_GetVolume

MTK_Triangulation_IsConsistent

MTK_Triangulation_IsCrossing

MTK_Triangulation_IsSurface

int MTK_Triangulation_IsSurface(MTK_Triangulation* triang);
			Version added: 9.0.0.1030
		

Description

Get if a triangulation is a surface or not.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

1

The triangulation is a surface

0

The triangulation is not a surface

other

failure

See Also

MTK_Triangulation_IsSolid

MTK_Triangulation_IsTextured

int MTK_Triangulation_IsTextured(MTK_Triangulation* triang);
			Version added: 9.0.0.64
		

Description

Determine if triangulation texture is enabled.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

1

Texture is enabled

0

Texture is not enabled

-1

failed

MTK_Triangulation_IsTranslucent

int MTK_Triangulation_IsTranslucent(MTK_Triangulation* triang);
		

Description

Determine if translucency is on or off.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

1

translucency enabled

0

translucency not enabled

-1

failed

MTK_Triangulation_IsValid

int MTK_Triangulation_IsValid(MTK_Triangulation* triang);
		

Description

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

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

1

if the MTK_Triangulation is valid

0

if it is not valid

-1

if there is an error, and the error message can be retrieved with MTK_API_GetError.

Example

// MTK_Triangulation_IsValid Example
#include <stdio.h>
#include "mtkExportedApi_ReadWrite.h"
int main()
{
	// Some initialisation stuff here
	MTK_Triangulation *triang;
	triang = MTK_Triangulation_Open("triangulation.00t");
	if (!triang)
	{
		char error[256];
		MTK_API_GetError(error);
		printf(%s\n", error);
		return 1;
	}
	int validity = MTK_Triangulation_IsValid(triang);
	if (validity == -1)
	{
		// The same error stuff from above
	}
	if (validity == 1)
	{
		printf("The triangulation is valid\n");
	}
	else
	{
		printf("The triangulation is not valid\n");
	}
	return 0;
}

MTK_Triangulation_New

MTK_Triangulation* MTK_Triangulation_New();
		

Description

Create a blank triangulation that values can be set to. Note: this does not create an actual file.

Parameters

None

Return Value

Pointer to an empty MTK_Triangulation struct

success

Null pointer

failure

See Also

MTK_Triangulation_Save

MTK_Triangulation_NumPoints

int MTK_Triangulation_NumPoints(MTK_Triangulation* triang);
		

Description

Get number of points in triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

int

number of triangulation points (int)

-1

failed

MTK_Triangulation_NumTriangles

int MTK_Triangulation_NumTriangles(MTK_Triangulation* triang);
		

Description

Get number of triangles in triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

Return Value

int

number of triangulation triangles (int)

-1

failed

MTK_Triangulation_Open

MTK_Triangulation* MTK_Triangulation_Open(const char* name);
		

Description

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

Parameters

name

triangulation filename (const char*)

Return Value

Pointer to an empty MTK_Triangulation struct

success

Null pointer

failure

MTK_Triangulation_Save

int MTK_Triangulation_Save(MTK_Triangulation* triang, const char* name);
		

Description

Save the triangulation to a file. Note that this will save the triangulation in the modern format. The Vulcan SDK does not support saving triangulations in the Vulcan 7.x format.

Parameters

triang

pointer to an MTK_Triangulation struct

name

triangulation name (const char*)

Return Value

0

success

other

failure

MTK_Triangulation_SetColour

int MTK_Triangulation_SetColour(
			MTK_Triangulation* triang,
			const int& r, const int& g, const int& b
			);
		

Description

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

Parameters

triang

pointer to an MTK_Triangulation struct

r

red (int)

g

green (int)

b

blue (int)

Return Value

0

success

other

failure

See Also

MTK_Triangulation_GetColour

MTK_Triangulation_SetTexture

int MTK_Triangulation_SetTexture(
			MTK_Triangulation* triang,
			const char* texture, const int& enabled
			);
			Version added: 9.0.0.64
		

Description

Set the texture of the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

texture

buffer of the path of the texture to use for the triangulation (const char*)

enabled

whether to turn the texture on or off (int)

Return Value

0

success

other

failure

MTK_Triangulation_SetTranslucency

int MTK_Triangulation_SetTranslucency(
			MTK_Triangulation* triang,
			const double& value, const int& enabled
			);
		

Description

Set the translucency of the triangulation.

Parameters

triang

pointer to an MTK_Triangulation struct

value

the percentage of how translucent the triangulation is (0 is opaque)

enabled

whether translucency is on or off

Return Value

0

success

other

failure