Iobj Module

This module contains functions for operating on the IMOD object structure.

Header to include: iobj.h


Iobj *imodObjectNew()
Iobj *imodObjectsNew(int size)
void imodObjectDefault(Iobj *obj)
int imodObjectDelete(Iobj *obj)
int imodObjectsDelete(Iobj *obj, int size)
double imodObjectChecksum(Iobj *obj, int obNum)
int imodObjectCopy(Iobj *from, Iobj *to)
int imodObjectCopyClear(Iobj *from, Iobj *to)
Iobj *imodObjectDup(Iobj *obj)
Icont *imodObjectGetContour(Iobj *inObject, int inIndex)
Imesh *imodObjectGetMesh(Iobj *inObject, int inIndex)
int imodObjectAddMesh(Iobj *inObject, Imesh *inMesh)
int imodObjectSort(Iobj *obj)
float imodObjectVolume(Iobj *obj)
int imodel_object_centroid(Iobj *obj, Ipoint *rcp)
int imodObjectAddContour(Iobj *obj, Icont *ncont)
int imodObjectInsertContour(Iobj *obj, Icont *ncont, int index)
int imodObjectRemoveContour(Iobj *obj, int index)
void imodObjectCleanSurf(Iobj *obj)
int imodObjectSortSurf(Iobj *obj)
int imodObjectGetBBox(Iobj *obj, Ipoint *ll, Ipoint *ur)
void imodObjectGetColor(Iobj *inObject, float *outRed, float *outGreen, float *outBlue)
void imodObjectSetColor(Iobj *inObject, float inRed, float inGreen, float inBlue)
int imodObjectGetMaxContour(Iobj *inObject)
char *imodObjectGetName(Iobj *inObject)
int imodObjectSetName(Iobj *obj, char *inName)
Ilabel *imodObjectGetLabel(Iobj *obj)
Ilabel *imodObjectNewLabel(Iobj *obj)
int imodObjectGetValue(Iobj *inObject, int inValueType)
void imodObjectSetValue(Iobj *inObject, int inValueType, int inValue)

Iobj *imodObjectNew()

Allocates one new object initialized to default values; returns NULL if error.

Iobj *imodObjectsNew(int size)

Allocates an array of objects of length size, initialized to default values; returns NULL if error.

void imodObjectDefault(Iobj *obj)

Initializes the object obj to default values.

int imodObjectDelete(Iobj *obj)

Deletes the object obj, freeing all contour, mesh, and label data and the object structure itself.  Returns -1 if error.

int imodObjectsDelete(Iobj *obj, int size)

Deletes the array of objects of length size in obj, freeing all contour, mesh, and label data and the object array itself.  It cannot be used on part of an array.  Returns -1 if error.

double imodObjectChecksum(Iobj *obj, int obNum)

Computes a checksum from the coordinates, properties, and general storage information for object obj and its contours.

int imodObjectCopy(Iobj *from, Iobj *to)

Copies object structure from object from to object to.  Returns -1 if error.

int imodObjectCopyClear(Iobj *from, Iobj *to)

Copies object structure from object from to object to then sets pointers to NULL and contour and mesh sizes to 0.  Returns -1 if error.

Iobj *imodObjectDup(Iobj *obj)

Duplicates object obj, including all contour, mesh, and label data, and returns pointer to copy, or NULL if error.

Icont *imodObjectGetContour(Iobj *inObject, int inIndex)

Returns pointer to the contour at inIndex in object inObject, or NULL if error.

Imesh *imodObjectGetMesh(Iobj *inObject, int inIndex)

Returns pointer to the mesh at inIndex in the mesh array of object inObject, or NULL if error.

int imodObjectAddMesh(Iobj *inObject, Imesh *inMesh)

Adds the mesh pointed to by inMesh to the mesh array of object inObject. All pointers are transferred to the new mesh array element and no data are duplicated.  If inMesh was allocated, such as with imodMeshNew , it should be freed with free. Returns index of new array element or -1 if error.

int imodObjectSort(Iobj *obj)

Sorts the contours in object obj by their z values.  If the object contains time-dependent data, then the contours are sorted first by time then by z.  Returns non-zero for error.

float imodObjectVolume(Iobj *obj)

Returns volume of object obj,computed from contour areas, or zero for a non-closed contour object

int imodel_object_centroid(Iobj *obj, Ipoint *rcp)

Returns centroid of object obj into the point rcp.  For closed-contour objects, computes centroid of area enclosed by each contour and forms the overall centroid from that.  For open-contour objects, computes the centroid of each contour line from the segments along the line, then forms an overall centroid from that.  Does not work for scattered point objects.  Does not account for Z-scaling.  Returns 1 for error computing a contour centroid or if there are no contours.

int imodObjectAddContour(Iobj *obj, Icont *ncont)

Adds contour ncont to the end of the contour array of object obj. Pointers are copied so no data are duplicated.  If ncont was allocated, such as with imodContourNew , it should be freed with free. Returns index of new contour or -1 if error.

int imodObjectInsertContour(Iobj *obj, Icont *ncont, int index)

Inserts contour ncont at position index into the contour array of object obj.  Pointers are copied so no data are duplicated.  If ncont was allocated, such as with imodContourNew , it should be freed with free.  Returns index of new contour or -1 if error.

int imodObjectRemoveContour(Iobj *obj, int index)

Removes the contour at index from object obj without deleting the contour data; this is thus appropriate after adding the contour to another object with imodObjectAddContour.  Returns 1 if error.

void imodObjectCleanSurf(Iobj *obj)

Updates surface information for object obj by removing labels for surfaces that no longer exist and recomputing the maximum surface number.

int imodObjectSortSurf(Iobj *obj)

Analyzes the mesh of object obj to determine which contours are connected by the mesh and assigns a separate surface number to each set of separately connected contours.  Returns 1 if there is no mesh information, 2 for memory error, or 3 for an unsupported feature in a contourless mesh (see imeshSortSurfaces.)

int imodObjectGetBBox(Iobj *obj, Ipoint *ll, Ipoint *ur)

Finds the minimum and maximum coordinates of all contours in object obj and returns them in points ll and ur, respectively.  If there are no contours but there are meshes, it finds the bounding box from all meshes instead.  Returns -1 for an error (including no non-empty contours or meshes), 0 for values from contours, or 1 for values from meshes.

void imodObjectGetColor(Iobj *inObject, float *outRed, float *outGreen, float *outBlue)

Returns color values of object inObject.

void imodObjectSetColor(Iobj *inObject, float inRed, float inGreen, float inBlue)

Sets the color of object inObject to the given values.

int imodObjectGetMaxContour(Iobj *inObject)

Returns number of contours in object inObject (not the maximum contour index).

char *imodObjectGetName(Iobj *inObject)

Returns pointer to object name.

int imodObjectSetName(Iobj *obj, char *inName)

Sets name of object obj to inName.  Returns 1 if the string is truncated to IOBJ_STRSIZE - 1 (63).

Ilabel *imodObjectGetLabel(Iobj *obj)

Returns a pointer to the label element of object obj, or NULL if the label or obj is NULL.

Ilabel *imodObjectNewLabel(Iobj *obj)

Makes a new, empty label element in ojbect obj, deleting an existing one if any, and returns a pointer to the new label.  Returns NULL if label allocation failed or obj is NULL.

int imodObjectGetValue(Iobj *inObject, int inValueType)

Returns one value for inObject; possible values for inValueType are IobjMaxContour, IobjLineWidth, IobjLineWidth2, IobjPointSize, IobjMaxMesh, IobjMaxSurface, IobjSymType, IobjSymSize, IobjSymFlags, IobjFlagClosed, IobjFlagConnected, IobjFlagFilled, IobjFlagDraw, IobjFlagMesh, IobjFlagLine, IobjFlagTime, IobjFlagExtraInModv, and IobjFlagPntOnSec.  IobjFlagConnected is 0 for scattered point objects.

void imodObjectSetValue(Iobj *inObject, int inValueType, int inValue)

Sets one value for inObject to inValue; possible values for inValueType are IobjLineWidth, IobjLineWidth2, IobjPointSize, IobjSymType, IobjSymSize, IobjSymFlags, IobjFlagClosed, IobjFlagConnected, IobjFlagFilled, IobjFlagDraw, IobjFlagMesh, IobjFlagLine, IobjFlagExtraInModv (for drawing an extra object in model view window), and IobjFlagPntOnSec.