Imesh *imodMeshNew(void)

Creates a new mesh structure and sets its properties to the default, or
returns NULL for an allocation error.

Imesh *imodMeshesNew(int size)

Creates an array of size mesh structures and sets their properties to the
default, or returns NULL for an error.

int imodMeshGetIndex(Imesh *mesh, int index)

Returns the value at index in the index list of mesh, or IMOD_MESH_END
if mesh is NULL or index is out of range.

int imodMeshGetMaxIndex(Imesh *mesh)

Returns the size of the index list in mesh, or 0 if mesh is NULL.

int imodMeshGetMaxVert(Imesh *mesh)

Returns the size of the vertex list in mesh, or 0 if mesh is NULL.

Ipoint *imodMeshGetVert(Imesh *mesh, int index)

Returns the point at index in the vertex list of mesh, or NULL
if mesh is NULL or index is out of range.

Ipoint *imodMeshGetVerts(Imesh *mesh)

Returns the vertex array in mesh, or NULL if there is none.

int imodMeshCopy(Imesh *from, Imesh *to)

copies a mesh structure from mesh from to mesh to. Returns -1 for
error.

Imesh *imodMeshDup(Imesh *mesh)

Returns a duplicate of mesh, including all data, or NULL for error.

int imodMeshDelete(Imesh *mesh)

Frees mesh, including all data that it contains. Returns -1 if mesh is
NULL.

int imodMeshesDelete(Imesh *mesh, int size)

Frees the array of size meshes in mesh, including all data that it
contains. Returns -1 if mesh is NULL.

int imodMeshAddIndex(Imesh *mesh, int index)

Adds index to the end of the index list of mesh, allocating one more
element for the index array. Returns -1 for allocation error.

void imodMeshDeleteIndex(Imesh *mesh, int index)

Deletes the item at index from the index lis of mesh

int imodMeshAddVert(Imesh *mesh, Ipoint *vert)

Adds vert to the end of the vertex array of mesh, allocating one more
element for the array. Returns -1 for allocation error.

int imodMeshNearestRes(Imesh *mesh, int size, int inres, int *outres)

Finds the nearest resolution to inres available in the array of meshes
of size size in mesh. Returns the resolution in outres. If there
are two equally distance resolutions (one below, one above), it returns
the resolution that is above inres. The return value is 0 if only one
resolution exists, 1 if more than one resolution exists, and -1 for error.

Returns values for indexing the mesh list for an old or new style POLYNORM
into listInc, vertBase, and normAdd. The return value is 1 if
startCode is IMOD_MESH_BGNPOLYNORM or IMOD_MESH_BGNPOLYNORM2, otherwise it
is 0. If i is the index of the start of a triangle, then:
index of vertex j is mesh->list[i + vertBase + j * listInc]
index of normal j is mesh->list[i + j * listInc] + normAdd

Imesh *imodel_mesh_add(Imesh *nmesh, Imesh *mray, int *size)

Adds a new mesh in nmesh to the array of meshes in mray. size
specifies the current number of meshes in mray and is returned with the
new number of meshes. Allocated data are transferred from nmesh to the
array but nmesh is not freed. Returns NULL for an error.

Contructs an interpolated contour at a Z plane between two other contours by finding
lines in a triangle mesh that cross that Z plane and using the points where the lines
cross the plane. listp is the list of mesh indices, vertp is the list of mesh
vertices; ntriang is the number of triangles in the polygon; firstv is the index of
the first vertex in listp, listInc is the step between successive vertex indices,
zadd is the Z value at which to interpolate, and cont is the contour to add points
to.

Imesh *imeshSortSurfaces(Imesh *mesh, int *newSize, int *error)

Sorts the input mesh in mesh into unconnected surfaces and returns a new array of
meshes, with surface numbers starting at 0 and equal to the index of the mesh in the
array. Returns the number of surfaces in newSize and an error code in error equal
to 1 for a NULL or empty input mesh, 2 for a memory allocation error, and 3 for an
unsupported feature. Only meshes with vertex-normal pairs, polygons starting
with IMOD_MESH_BGNBIGPOLY2, and even list indices are supported. The return value is
NULL for an error.

float imeshVolume(Imesh *mesh, Ipoint *scale, Ipoint *center)

Returns the volume enclosed by mesh in cubic pixels. If scale is
non-NULL, its z value specifies the Z scaling to apply. If center is
non-NULL, it will be taken as the center from which to calculate volumes of
tetraheda, in which case the routine will skip calculating the centroid of
the mesh. The volume will not be accurate unless the mesh is fully closed.

float imeshSurfaceArea(Imesh *mesh, Ipoint *scale)

Returns the surface area of mesh in square pixels. If scale is
non-NULL, its z value specifies the Z scaling to apply.

int imodMeshGetBBox(Imesh *mesh, Ipoint *ll, Ipoint *ur)

Calculates the full 3D bounding box of vertices in mesh and returns the
lower left, bottom coordinates in ll and the upper right, top coordinates
in ur. Returns -1 if error.

MeshParams *imeshParamsNew()

Allocates and returns a new MeshParams structure after setting it to
default values. Returns NULL for error.

void imeshParamsDefault(MeshParams *params)

Sets params to default values.

MeshParams *imeshParamsDup(MeshParams *params)

Returns a duplicate of the meshing parameters in params, including a cap
skip list, if any. Returns NULL for error or if params is NULL.

void imeshParamsDelete(MeshParams *params)

Frees the params structure and the capSkipZlist array if it is nonnull
and capSkipNz is nonzero.

int imeshCopySkipList(int *lfrom, int nfrom, int **lto, int *nto)

Copies the integer list in lfrom of size nfrom to a new list pointed
to by lto, returning the size in nto. Frees an existing list in lto
first if lto and nto are non-NULL, then allocates a new list with space
for three more values than nfrom. If lfrom is NULL, no new list is
allocated. Returns 1 for memory error.