Ilabel Module

This module contains functions for working with labels that can associated with surfaces, contours and points. A label is a two-level entity, with a text string as part of the top level, and an unlimited number of text strings and integer values at the second level.

Header to include: imodel.h


Ilabel *imodLabelNew()
void imodLabelDelete(Ilabel *label)
Ilabel *imodLabelDup(Ilabel *label)
int imodLabelName(Ilabel *label, const char *val)
void imodLabelItemAdd(Ilabel *label, const char *val, int index)
void imodLabelItemMove(Ilabel *label, int to_index, int from_index)
void imodLabelItemDelete(Ilabel *label, int index)
const char *imodLabelNameGet(Ilabel *label)
const char *imodLabelItemGet(Ilabel *label, int index)
void imodLabelPrint(Ilabel *lab, FILE *fout)
int imodLabelWrite(Ilabel *lab, b3dUInt32 tag, FILE *fout)
Ilabel *imodLabelRead(FILE *fin, int *err)


Ilabel structure

Ilabel *imodLabelNew()

Create a new empty Ilabel structure.  Returns NULL for error.

void imodLabelDelete(Ilabel *label)

Deleteslabel, freeing all data.

Ilabel *imodLabelDup(Ilabel *label)

Duplicates label and returns the copy; returns NULL if error or if no existing label, i.e. label is NULL

int imodLabelName(Ilabel *label, const char *val)

Give label the title in val, i.e., set the name element of the Ilabel structure.  Returns 1 for label or val NULL, or 2 for memory allocation error.

void imodLabelItemAdd(Ilabel *label, const char *val, int index)

Adds a label item to label with the name given by val and the value given by index.  Replaces an existing label item with the same value of index.

void imodLabelItemMove(Ilabel *label, int to_index, int from_index)

Changes the index to to_index for any item in label that has index from_index.

void imodLabelItemDelete(Ilabel *label, int index)

Deletes the first label item in label that has index value equal to index.

const char *imodLabelNameGet(Ilabel *label)

Returns a pointer to the name element of label. Returns NULL if the label or the name is NULL.

const char *imodLabelItemGet(Ilabel *label, int index)

Returns a pointer to the name element of the first label item in label that has the index value index.  Returns NULL if none is found or the label is NULL or has no items.

void imodLabelPrint(Ilabel *lab, FILE *fout)

Prints the contour label lab and its items to file fout.

int imodLabelWrite(Ilabel *lab, b3dUInt32 tag, FILE *fout)

Writes a label lab with the chunk ID in tag to the model file fout.

Ilabel *imodLabelRead(FILE *fin, int *err)

Reads a label chunk from the model file fin.  Returns NULL and sets err to IMOD_ERROR_MEMORY for memory errors.

Ilabel structure

Label Data for Contours and points.
typedef struct
{
  b3dByte *name;     /* The name string for this item */
  b3dInt32  len;     /* Length of name string */
  b3dInt32 index;    /* A value associated with this label */
}IlabelItem;

typedef struct
{
  b3dByte       *name;   /* The name string for the label */
  b3dInt32         len;  /* Length of name */
  b3dInt32        nl;    /* Number of sub-label items */
  IlabelItem *label;     /* Array of items */
}Ilabel;