Functions

bool offler_read_file(offler_mesh *mesh, const char *filename)

Read the specified OFF file and store the data in mesh. This function allocates any necessary memory, which must be freed with free_mesh. Returns false if the file cannot be opened or memory cannot be allocated.

void offler_free_mesh(offler_mesh *mesh)

Free the memory associated with mesh, and, to keep the other members consistent, reset them as though newly defined by OFF_t mesh = {};.

void offler_write_file(offler_mesh *mesh, FILE *outfile, bool write_normals, bool write_colour, bool write_textures)

Write mesh to a .off file. If mesh contains normals and colours, then writing eacg of these can be suppressed. If it contains no normals and has_normals=true, then degenerate normals will be written for each vertex. If it contains no colours and has_colour=true, a (N)OFF file is created, with no colour data for the vertices.

dotty_aa_bounding_box offler_compute_aabb(const offler_mesh *mesh)

Compute the axis-aligned bounding box of mesh.

void offler_scale(offler_mesh *mesh, double scale_factor)

Scale the position of each vertex in the mesh by the provided scale_factor. A scale factor =1.0 causes no change, >1 causes growth, and <1 causes shrinkage.

void offler_swap_axes(offler_mesh *mesh, dotty_axis_pair to_swap)

Swap the specified axes of each vertex in mesh.

void offler_translate(offler_mesh *mesh, dotty_vector translation)

Update the position of each point in the mesh by adding translation.

void offler_export_normals(const offler_mesh *mesh, FILE *normal_file, char delimiter)

Export vertex normals to a delimiter-separated-variables file.

void offler_import_normals(offler_mesh *mesh, FILE *normal_file)

Import vertex normals from a delimiter-separated-variables file. The delimiter is assumed to be a single character.

void offler_export_colours(const offler_mesh *mesh, FILE *colour_file, char delimiter)

Export vertex colours (r, g, b, a) to a delimiter-separated-variables file.

bool offler_import_colours(offler_mesh *mesh, FILE *colour_file)

Import vertex colours (r, g, b, a) from a delimiter-separated-variables file. The delimiter is assumed to be a single character.

bool offler_add_fixed_colour(offler_mesh *mesh, offler_colour new_colour)

Set the colour of all vertices in mesh to new_colour.

void offler_calculate_face_normals(offler_mesh *mesh)

Calculate a face’s normal by taking the cross product of two of its sides. The consistency of the orientations is not considered.

bool offler_calculate_vertex_normals(offler_mesh *mesh)

Calculate vertex normals by taking a weighted sum of the surrounding face normals. The weights are inversely proportional to the distance between the vertex and the face’s barycentre.