v0.4.1
Fast, portable C library for geometry input/output
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
Data Structures | Enumerations | Functions
gmioAMF

Provides API to handle output operations with the AMF file format. More...

Data Structures

struct  gmio_amf_color
 Red, green, blue and alpha channels as numbers or formulas in [0,1]. More...
 
struct  gmio_amf_material
 
struct  gmio_amf_composite
 Proportion of the composition of another material. More...
 
struct  gmio_amf_vertex
 Vertex within a mesh. More...
 
struct  gmio_amf_edge
 Edge within a mesh, for curved triangles. More...
 
struct  gmio_amf_texmap
 
struct  gmio_amf_triangle
 
struct  gmio_amf_volume
 Closed volume of an object. More...
 
struct  gmio_amf_mesh
 Triangular mesh referencing a set of vertices. More...
 
struct  gmio_amf_object
 Volume or volumes of material. More...
 
struct  gmio_amf_constellation
 Combination of objects. More...
 
struct  gmio_amf_instance
 Position of an object in a constellation. More...
 
struct  gmio_amf_texture
 
struct  gmio_amf_object_mesh_element_index
 Index of an element(vertex, edge or volume) within a mesh. More...
 
struct  gmio_amf_document
 Provides an interface for accessing the underlying(hidden) user AMF data. More...
 
struct  gmio_amf_write_options
 Options of function gmio_amf_write() More...
 

Enumerations

enum  gmio_amf_volume_type
 
enum  gmio_amf_texture_type
 
enum  gmio_amf_unit
 Units supported by AMF. More...
 
enum  gmio_amf_document_element
 The direct elements of an AMF document(ie inside <amf>...</amf>) More...
 
enum  gmio_amf_mesh_element
 The direct elements of an AMF mesh(ie inside <mesh>...</mesh>) More...
 
enum  
 GMIO_AMF_ERROR_TAG Byte-mask to tag(identify) AMF-specific error codes More...
 
enum  gmio_amf_error
 Specific error codes reported by AMF read/write functions. More...
 

Functions

int gmio_amf_write (struct gmio_stream *stream, const struct gmio_amf_document *doc, const struct gmio_amf_write_options *opts)
 Writes AMF document to stream. More...
 
int gmio_amf_write_file (const char *filepath, const struct gmio_amf_document *doc, const struct gmio_amf_write_options *opts)
 Writes AMF document to stream. More...
 

Detailed Description

Provides API to handle output operations with the AMF file format.

In addition, the gmioAMF module has the following advatanges:

In this module, the name of all entities(structures, functions, ...) are prefixed with gmio_amf

Functions Structures
Write gmio_amf_write()
gmio_amf_write_file()
gmio_amf_document
gmio_amf_write_options

Data Structure Documentation

struct gmio_amf_metadata

Addition information about an element(eg name, description, ...

Data Fields
const char * type UTF8-encoded.
const char * data UTF8-encoded.
struct gmio_amf_color

Red, green, blue and alpha channels as numbers or formulas in [0,1].

Data Fields
double r
double g
double b
double a
const char * r_formula
const char * g_formula
const char * b_formula
const char * a_formula
struct gmio_amf_material
Data Fields
uint32_t id
struct gmio_amf_color color
uint32_t composite_count
uint32_t metadata_count
struct gmio_amf_composite

Proportion of the composition of another material.

The proportion can be specified as a formula(with value_formula) or as a constant mixing(with value)

Data Fields
uint32_t materialid
double value Governs the percent of material.
const char * value_formula
struct gmio_amf_vertex

Vertex within a mesh.

Data Fields
struct gmio_vec3d coords
bool has_normal
struct gmio_vec3d normal
bool has_color
struct gmio_amf_color color
uint32_t metadata_count
struct gmio_amf_edge

Edge within a mesh, for curved triangles.

Data Fields
uint32_t v1
uint32_t v2
struct gmio_vec3d d1
struct gmio_vec3d d2
struct gmio_amf_texmap
Data Fields
uint32_t rtexid
uint32_t gtexid
uint32_t btexid
uint32_t atexid
struct gmio_vec3d utex
struct gmio_vec3d vtex
bool has_wtex
struct gmio_vec3d wtex
struct gmio_amf_triangle
Data Fields
uint32_t v1
uint32_t v2
uint32_t v3
bool has_texmap
struct gmio_amf_texmap texmap
bool has_color
struct gmio_amf_color color
struct gmio_amf_volume

Closed volume of an object.

Data Fields
uint32_t materialid
enum gmio_amf_volume_type type
uint32_t triangle_count Should be >= 4.
uint32_t metadata_count
bool has_color
struct gmio_amf_color color
struct gmio_amf_mesh

Triangular mesh referencing a set of vertices.

Data Fields
uint32_t vertex_count
uint32_t edge_count
uint32_t volume_count
struct gmio_amf_object

Volume or volumes of material.

Data Fields
uint32_t id
uint32_t mesh_count
uint32_t metadata_count
bool has_color
struct gmio_amf_color color
struct gmio_amf_constellation

Combination of objects.

Data Fields
uint32_t id
uint32_t instance_count Should be >= 2.
uint32_t metadata_count
struct gmio_amf_instance

Position of an object in a constellation.

Data Fields
uint32_t objectid
struct gmio_vec3d delta
struct gmio_vec3d rot Coordinates in degrees (-360 <= coord < 360)
struct gmio_amf_texture
Data Fields
uint32_t id
uint32_t width
uint32_t height
uint32_t depth
bool tiled
enum gmio_amf_texture_type type
struct gmio_memblock binary_data Will be converted to base64.
struct gmio_amf_object_mesh_element_index

Index of an element(vertex, edge or volume) within a mesh.

Data Fields
uint32_t object_index Index of the object that owns the mesh.
uint32_t mesh_index Index of the mesh that owns element.
uint32_t value Index of the inner element.
enum gmio_amf_mesh_element element_type Type of the inner element.
struct gmio_amf_write_options

Options of function gmio_amf_write()

Initialising gmio_amf_write_options with {0} (or {} in C++) is the convenient way to set default values(passing NULL to gmio_amf_write() has the same effect).

Data Fields
struct gmio_memblock stream_memblock Used by the stream to bufferize I/O operations.

If null, then a temporary memblock is created with the global default constructor function

See also
gmio_memblock_isnull()
gmio_memblock_default()
struct gmio_task_iface task_iface Optional interface by which the I/O operation can be controlled.
enum gmio_float_text_format float64_format The format used when writting double values as strings.

Defaults to GMIO_FLOAT_TEXT_FORMAT_DECIMAL_LOWERCASE when calling gmio_amf_write() with options==NULL

uint8_t float64_prec The maximum number of significant digits when writting double values.

Defaults to 16 when calling gmio_amf_write() with options==NULL

bool create_zip_archive Flag to write AMF document in ZIP archive containing one file entry.
const char * zip_entry_filename Filename of the single AMF entry within the ZIP archive.

Applicable only if create_zip_archive==true

uint16_t zip_entry_filename_len Filename length of the single AMF entry within the ZIP archive.

Applicable only if create_zip_archive==true

bool dont_use_zip64_extensions Flag to disable use of the Zip64 format extensions.

Applicable only if create_zip_archive==true

struct gmio_zlib_compress_options z_compress_options Options for the zlib(deflate) compression.

Applicable only if create_zip_archive==true

Enumeration Type Documentation

Enumerator
GMIO_AMF_VOLUME_TYPE_OBJECT 
GMIO_AMF_VOLUME_TYPE_SUPPORT 
Enumerator
GMIO_AMF_TEXTURE_TYPE_GRAYSCALE 

Units supported by AMF.

Enumerator
GMIO_AMF_UNIT_UNKNOWN 
GMIO_AMF_UNIT_MILLIMETER 
GMIO_AMF_UNIT_INCH 
GMIO_AMF_UNIT_FEET 
GMIO_AMF_UNIT_METER 
GMIO_AMF_UNIT_MICRON 

The direct elements of an AMF document(ie inside <amf>...</amf>)

Enumerator
GMIO_AMF_DOCUMENT_ELEMENT_OBJECT 
GMIO_AMF_DOCUMENT_ELEMENT_MATERIAL 
GMIO_AMF_DOCUMENT_ELEMENT_TEXTURE 
GMIO_AMF_DOCUMENT_ELEMENT_CONSTELLATION 
GMIO_AMF_DOCUMENT_ELEMENT_METADATA 

The direct elements of an AMF mesh(ie inside <mesh>...</mesh>)

Enumerator
GMIO_AMF_MESH_ELEMENT_VERTEX 
GMIO_AMF_MESH_ELEMENT_EDGE 
GMIO_AMF_MESH_ELEMENT_VOLUME 
anonymous enum

GMIO_AMF_ERROR_TAG Byte-mask to tag(identify) AMF-specific error codes

Enumerator
GMIO_AMF_ERROR_TAG 

Specific error codes reported by AMF read/write functions.

Enumerator
GMIO_AMF_ERROR_NULL_DOCUMENT 

The input gmio_amf_document is NULL.

GMIO_AMF_ERROR_NULL_FUNC_GET_DOCUMENT_ELEMENT 

Function pointer gmio_amf_document::func_get_document_element is NULL.

GMIO_AMF_ERROR_NULL_FUNC_GET_CONSTELLATION_INSTANCE 

Function pointer gmio_amf_document::func_get_constellation_instance is NULL.

GMIO_AMF_ERROR_NULL_FUNC_GET_OBJECT_MESH 

Function pointer gmio_amf_document::func_get_object_mesh is NULL.

GMIO_AMF_ERROR_NULL_FUNC_GET_OBJECT_MESH_ELEMENT 

Function pointer gmio_amf_document::func_get_object_mesh_element is NULL.

GMIO_AMF_ERROR_NULL_FUNC_GET_OBJECT_MESH_VOLUME_TRIANGLE 

Function pointer gmio_amf_document::func_get_object_mesh_volume_triangle is NULL.

GMIO_AMF_ERROR_NULL_FUNC_GET_DOCUMENT_ELEMENT_METADATA 

Function pointer gmio_amf_document::func_get_document_element_metadata is NULL while some gmio_amf_material::metadata_count > 0.

GMIO_AMF_ERROR_NULL_FUNC_GET_MATERIAL_COMPOSITE 

Function pointer gmio_amf_document::func_get_material_composite is NULL while some gmio_amf_material::composite_count > 0.

GMIO_AMF_ERROR_NULL_FUNC_GET_OBJECT_MESH_ELEMENT_METADATA 

Function pointer gmio_amf_document::func_get_object_mesh_element_metadata is NULL while some metadata is attached to a mesh element.

Function Documentation

int gmio_amf_write ( struct gmio_stream stream,
const struct gmio_amf_document doc,
const struct gmio_amf_write_options opts 
)

Writes AMF document to stream.

When gmio_amf_write_options::create_zip_archive is ON then a compressed ZIP archive is written on the fly. At the end it will contains a single file entry containing the AMF document.
In case of compression the first half of the memory pointed to by gmio_amf_write_options::stream_memblock is used internally as a stream buffer and the second half is employed as a compression buffer for zlib.

If specified, gmio_amf_write_options::task_iface::func_is_stop_requested is checked each time the gmio_amf_write_options::stream_memblock is about to be flushed to the stream.

Precondition
stream != NULL
doc != NULL

options may be NULL in this case default values are used

Returns
Error code (see gmio_core/error.h and amf_error.h)
See also
gmio_amf_write_file()
int gmio_amf_write_file ( const char *  filepath,
const struct gmio_amf_document doc,
const struct gmio_amf_write_options opts 
)

Writes AMF document to stream.

This is just a facility function over gmio_amf_write(). The internal stream object is created to read file at filepath

In case gmio_amf_write_options::create_zip_archive is ON and zip_entry_filename is NULL or empty then the ZIP entry filename is automatically set to the basename of filepath suffixed by .amf

Precondition
filepath != NULL
The file is opened with fopen() so filepath shall follow the file name specifications of the running environment
doc != NULL
Returns
Error code (see gmio_core/error.h and amf_error.h)
See also
gmio_amf_write(), gmio_stream_stdio(FILE*)
Fougue © 2017