Imodel Module

This module contains functions for operating on an IMOD model or on the object, contour, or point components of a specific model.

Header to include: imodel.h
(includes ilist.h and mcrfiles.h)

General Model Manipulation and Information


Imod *imodNew(void)
int imodDefault(Imod *model)
void imodDelete(Imod *imod)
void imodGetIndex(Imod *imod, int *object, int *contour, int *point)
void imodSetIndex(Imod *imod, int object, int contour, int point)
void imodel_maxpt(Imod *imod, Ipoint *pnt)
void imodel_minpt(Imod *imod, Ipoint *pnt)
void imodGetBoundingBox(Imod *imod, Ipoint *min, Ipoint *max)
int imodTransform(Imod *imod, Imat *mat)
int imodel_transform_slice(Imod *model, float *mat, int slice)
int imodel_model_clean(Imod *mod, int keepEmptyObjs)
char *imodUnits(Imod *mod)
int imodGetMaxTime(Imod *imod)
int imodChecksum(Imod *imod)
void imodCleanSurf(Imod *imod)
void imodFlipYZ(Imod *imod)
int imodSetRefImage(Imod *imod, MrcHeader *hdata)
int imodTransFromRefImage(Imod *imod, IrefImage *iref, Ipoint binScale)
void imodTransFromMats(Imod *imod, Imat *mat, Imat *matNorm, Imat *matClip)
int imodGetMaxObject(Imod *imod)
float imodGetZScale(Imod *imod)
float imodGetPixelSize(Imod *imod)
const char *imodGetFilename(Imod *imod)
int imodGetFlipped(Imod *imod)

Object-related Model Functions


int imodNewObject(Imod *mod)
int imodDeleteObject(Imod *mod, int index)
int imodMoveObject(Imod *imod, int obOld, int obNew)
int imodNextObject(Imod *imod)
int imodPrevObject(Imod *mod)
Iobj *imodObjectGet(Imod *imod)
Iobj *imodObjectGetFirst(Imod *imod)
Iobj *imodObjectGetNext(Imod *imod)

Contour-related Model Functions


int imodNewContour(Imod *mod)
void imodDelCurrentContour(Imod *imod)
int imodDeleteContour(Imod *mod, int index)
int imodPrevContour(Imod *mod)
int imodNextContour(Imod *imod)
Icont *imodContourGet(Imod *imod)
Icont *imodContourGetFirst(Imod *imod)
Icont *imodContourGetNext(Imod *imod)

Point-related Model Functions


int imodNewPoint(Imod *imod, Ipoint *point)
int imodInsertPoint(Imod *imod, Ipoint *point, int index)
int imodDeletePoint(Imod *imod)
int imodPrevPoint(Imod *mod)
int imodNextPoint(Imod *mod)
Ipoint *imodPointGet(Imod *imod)
Ipoint *imodPointGetFirst(Imod *imod)
Ipoint *imodPointGetNext(Imod *imod)

General Model Manipulation and Information

Imod *imodNew(void)

Allocates a new model structure and returns a pointer to it, or NULL if there is an error.  Initializes the model with imodDefault

int imodDefault(Imod *model)

Initializes model structure pointed to by model to default values and allocates an initial view (which will leak if this is called twice). Returns 0 (there are no errors)

void imodDelete(Imod *imod)

Deletes a model; frees all memory used in objects, views, and object views and frees the model itself.

void imodGetIndex(Imod *imod, int *object, int *contour, int *point)

Returns the current object, contour, and point indexes of the model in object, contour, and point

void imodSetIndex(Imod *imod, int object, int contour, int point)

Sets the current object, contour, and point indexes of the model with the values in object, contour, and point.  Indexes are checked for legality and if one is out of bounds it is set to -1.  If an index is -1, any index at a lower level is set to -1 also (e.g., point if contour is -1).

void imodel_maxpt(Imod *imod, Ipoint *pnt)

Returns the maximum coordinates of the model imod in pnt, or -1,-1,-1 if there are no points

void imodel_minpt(Imod *imod, Ipoint *pnt)

Returns the minimum coordinates of the model imod in pnt, or -1,-1,-1 if there are no points

void imodGetBoundingBox(Imod *imod, Ipoint *min, Ipoint *max)

Returns the minimum and maximum coordinates of the model imod in min and max, or -1,-1,-1 if there are no points

int imodTransform(Imod *imod, Imat *mat)

Transforms all contour points in model imod with the 3D transform in mat.  Returns -1 if error.

int imodel_transform_slice(Imod *model, float *mat, int slice)

Transforms all contour points in model with Z values that round to slice.  The 2D transformation in mat is applied to X and Y coordinates. Returns 0.

int imodel_model_clean(Imod *mod, int keepEmptyObjs)

Cleans model mod by removing empty contours, removing empty objects if keepEmptyObjs is 0, constraining points within the model xmax, ymax, and zmax values, and making all points have the same Z value as the first point for non-wild closed contours.  Returns 0.

char *imodUnits(Imod *mod)

Returns a string (e.g., "nm") for the pixel size units of model mod.

int imodGetMaxTime(Imod *imod)

Returns the maximum time (type) value of any contour in model imod.

int imodChecksum(Imod *imod)

Computes a checksum from the coordinates and most other features of model mod and returns the value.

void imodCleanSurf(Imod *imod)

Fixes the surface size information for all objects in model imod by determining the maximum surface number for the contours in each object.

void imodFlipYZ(Imod *imod)

Flip the model imod by exchanging Y and Z in contours and meshes.

int imodSetRefImage(Imod *imod, MrcHeader *hdata)

Sets the IrefImage structure refImage in imod with the image coordinate information in the MRC header hdata.  Returns 1 for memory error allocating the structure.

int imodTransFromRefImage(Imod *imod, IrefImage *iref, Ipoint binScale)

Transforms the model in imod according to the old and current shift, scale, and rotation in the IrefImage structure iref, with the additional scaling required for binning in each dimension specified in binScale. Returns 1 for memory errors.

void imodTransFromMats(Imod *imod, Imat *mat, Imat *matNorm, Imat *matClip)

Transforms the model in imod given three matrices: mat for transforming points, matNorm for transforming the mesh normals, and matClip for transforming clip plane normals.

int imodGetMaxObject(Imod *imod)

Get the number of objects in model imod (not the maximum object index).

float imodGetZScale(Imod *imod)

Get the Z scale in model imod

float imodGetPixelSize(Imod *imod)

Get the pixel size in model imod

const char *imodGetFilename(Imod *imod)

Get a pointer to the filename of model imod

int imodGetFlipped(Imod *imod)

Returns non-zero if model imod is flipped

Object-related Model Functions

int imodNewObject(Imod *mod)

Adds new object to end of object array in model mod. Color is automatically assigned from the collection of 35 stock colors. Returns 1 if error.

int imodDeleteObject(Imod *mod, int index)

Removes the object at the given index from the model mod. All contour data is deleted and object views are deleted.  The object array is packed down and reallocated or freed if there are no more objects. Returns -1 if there is an error.

int imodMoveObject(Imod *imod, int obOld, int obNew)

Moves an object from index obOld to index obNew in the model imod. Returns 1 if memory error.

int imodNextObject(Imod *imod)

Advances from the current object to the next object in the model imod, adjusting the index of the current contour and point to stay within bounds or setting them to -1 if appropriate.  Returns new object index or -1 if there is no model or objects.

int imodPrevObject(Imod *mod)

Moves from the current object to the previous object in the model mod, adjusting the index of the current contour and point to stay within bounds or setting them to -1 if appropriate.  Returns new object index or -1 if there is no model or objects.

Iobj *imodObjectGet(Imod *imod)

Returns a pointer to the current object in model imod, or NULL if no legal object is selected.

Iobj *imodObjectGetFirst(Imod *imod)

Sets first object in model imod as current object and returns pointer to it, or NULL if error.

Iobj *imodObjectGetNext(Imod *imod)

Advances the current object index by one in model imod and returns pointer to new current object, or NULL if error or if the existing current object is the last one in the model.

Contour-related Model Functions

int imodNewContour(Imod *mod)

Adds a new contour to the current object of the model mod.  It will inherit surface and open/closed properties from the current contour and become the new current contour.  Returns -1 if error.

void imodDelCurrentContour(Imod *imod)

Deletes the current contour of the model imod.

int imodDeleteContour(Imod *mod, int index)

Deletes the contour at index in the current object of the model mod, freeing all point, size, and label data and reducing the size of the contour array.  Sets the current contour and point index to -1 and returns the size of the current object or -1 if error.

int imodPrevContour(Imod *mod)

Moves the current contour index back by one in model mod.  If there is no current contour it selects the last one in the object.  Returns the current contour index or -1 for error.

int imodNextContour(Imod *imod)

Advances the current contour index forward by one in model mod.  If there is no current contour it selects the first one in the object.  Returns the current contour index or -1 for error.

Icont *imodContourGet(Imod *imod)

Returns a pointer to the current contour in model imod, or NULL if there is no current contour or the contour index is not legal.

Icont *imodContourGetFirst(Imod *imod)

Sets the current contour index to 0 in the current object in model imod and returns pointer to first contour, or NULL if there is no contour.

Icont *imodContourGetNext(Imod *imod)

Advances to the next contour in the current object of model imod and returns pointer to the contour, or NULL if there is none (error or end of object).

Point-related Model Functions

int imodNewPoint(Imod *imod, Ipoint *point)

Adds point to the end of the current contour in model imod. Returns new number of points in contour, or 0 for an error.

int imodInsertPoint(Imod *imod, Ipoint *point, int index)

Inserts point at position index into the current contour in model imod.  Returns new number of points in contour, or 0 for an error.

int imodDeletePoint(Imod *imod)

Deletes the current point in model imod, or the current contour if it is empty.  Returns size of current contour or -1 for error.

int imodPrevPoint(Imod *mod)

Moves the current point index back by one in model mod.  Returns the new current point index or -1 if no object or contour is selected.

int imodNextPoint(Imod *mod)

Advances the current point index forward by one in model mod.  Returns the new current point index or -1 if no object or contour is selected.

Ipoint *imodPointGet(Imod *imod)

Returns a pointer to the current point in model imod, or NULL if there is no current contour or current point.

Ipoint *imodPointGetFirst(Imod *imod)

Sets the current point index to 0 in the current contour in model imod and returns pointer to first point, or NULL if there is no current contour or point.

Ipoint *imodPointGetNext(Imod *imod)

Advances to the next point in the current contour of model imod and returns pointer to the point , or NULL if there is none (error or end of contour).