2015-03-03 00:38:33 +08:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** GeomIO Library
|
|
|
|
** Copyright FougSys (2 Mar. 2015)
|
|
|
|
** contact@fougsys.fr
|
|
|
|
**
|
|
|
|
** This software is a reusable library whose purpose is to provide complete
|
|
|
|
** I/O support for various CAD file formats (eg. STL)
|
|
|
|
**
|
|
|
|
** This software is governed by the CeCILL-B license under French law and
|
|
|
|
** abiding by the rules of distribution of free software. You can use,
|
|
|
|
** modify and/ or redistribute the software under the terms of the CeCILL-B
|
|
|
|
** license as circulated by CEA, CNRS and INRIA at the following URL
|
|
|
|
** "http://www.cecill.info".
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-03-28 23:33:35 +08:00
|
|
|
#ifndef GMIO_LIBSTL_STL_IO_H
|
|
|
|
#define GMIO_LIBSTL_STL_IO_H
|
|
|
|
|
|
|
|
#include "stl_global.h"
|
2014-03-31 21:52:04 +08:00
|
|
|
#include "stl_mesh.h"
|
|
|
|
#include "stl_mesh_creator.h"
|
2014-03-28 23:33:35 +08:00
|
|
|
#include "../gmio_core/endian.h"
|
|
|
|
#include "../gmio_core/transfer.h"
|
|
|
|
|
|
|
|
GMIO_C_LINKAGE_BEGIN
|
|
|
|
|
2014-11-21 18:41:29 +08:00
|
|
|
/* ============================================================================
|
2014-03-28 23:33:35 +08:00
|
|
|
* STL ascii
|
2014-11-21 18:41:29 +08:00
|
|
|
* ============================================================================
|
2014-03-28 23:33:35 +08:00
|
|
|
*/
|
|
|
|
|
2014-11-21 18:41:29 +08:00
|
|
|
/*! \brief Options for gmio_stla_read()
|
|
|
|
*
|
2015-03-02 23:49:52 +08:00
|
|
|
* No options yet, it just exists for future needs, which could possibly be:
|
|
|
|
* - flag to force locale ?
|
|
|
|
* - case sensitive/insensitive ?
|
2014-11-21 18:41:29 +08:00
|
|
|
*/
|
|
|
|
struct gmio_stla_read_options
|
|
|
|
{
|
2015-03-03 17:35:36 +08:00
|
|
|
void* dummy; /*!< Structs must have at least one member in strict ISO-C90 */
|
2014-11-21 18:41:29 +08:00
|
|
|
};
|
|
|
|
typedef struct gmio_stla_read_options gmio_stla_read_options_t;
|
|
|
|
|
|
|
|
/*! \brief Read geometry from STL ascii stream
|
|
|
|
*
|
|
|
|
* \p options should be always set to NULL (not used for the moment)
|
|
|
|
*/
|
2015-01-29 05:39:03 +08:00
|
|
|
GMIO_LIBSTL_EXPORT
|
|
|
|
int gmio_stla_read(gmio_stl_mesh_creator_t* creator,
|
|
|
|
gmio_transfer_t* trsf,
|
2015-03-02 23:49:52 +08:00
|
|
|
const gmio_stla_read_options_t* options /* NULL */);
|
2014-11-21 18:41:29 +08:00
|
|
|
|
|
|
|
/*! \brief Options for gmio_stla_write()
|
|
|
|
*/
|
|
|
|
struct gmio_stla_write_options
|
|
|
|
{
|
2015-03-03 17:35:36 +08:00
|
|
|
/*! May be NULL to generate default name */
|
|
|
|
const char* solid_name;
|
2014-11-21 18:41:29 +08:00
|
|
|
|
2015-03-03 17:35:36 +08:00
|
|
|
/*! The maximum number of significant digits(set to 9 if options == NULL) */
|
2015-03-03 17:44:45 +08:00
|
|
|
uint8_t float32_prec;
|
2014-11-21 18:41:29 +08:00
|
|
|
};
|
|
|
|
typedef struct gmio_stla_write_options gmio_stla_write_options_t;
|
2014-03-28 23:33:35 +08:00
|
|
|
|
2014-11-21 18:41:29 +08:00
|
|
|
/*! \brief Write geometry in the STL ascii format
|
|
|
|
*
|
|
|
|
* \param mesh Defines the mesh to write
|
|
|
|
* \param trsf Defines needed objects (stream, buffer, ...) for the writing
|
|
|
|
* operation
|
2015-03-02 23:49:52 +08:00
|
|
|
* \param options Options for the writing operation, can be set to NULL to
|
|
|
|
* use default values
|
2014-11-21 18:41:29 +08:00
|
|
|
*
|
|
|
|
* \return Error code
|
|
|
|
* \retval GMIO_NO_ERROR If operation successful
|
|
|
|
*/
|
2015-01-29 05:39:03 +08:00
|
|
|
GMIO_LIBSTL_EXPORT
|
|
|
|
int gmio_stla_write(const gmio_stl_mesh_t* mesh,
|
|
|
|
gmio_transfer_t* trsf,
|
|
|
|
const gmio_stla_write_options_t* options);
|
2014-03-28 23:33:35 +08:00
|
|
|
|
2014-11-21 18:41:29 +08:00
|
|
|
/* ============================================================================
|
2014-03-28 23:33:35 +08:00
|
|
|
* STL binary
|
2014-11-21 18:41:29 +08:00
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \brief Options for gmio_stlb_read()
|
2014-03-28 23:33:35 +08:00
|
|
|
*/
|
2014-11-21 18:41:29 +08:00
|
|
|
struct gmio_stlb_read_options
|
|
|
|
{
|
2015-03-03 17:35:36 +08:00
|
|
|
/*! Set to host byte order if not specified (ie. options == NULL) */
|
|
|
|
gmio_endianness_t byte_order;
|
2014-11-21 18:41:29 +08:00
|
|
|
};
|
|
|
|
typedef struct gmio_stlb_read_options gmio_stlb_read_options_t;
|
2014-03-28 23:33:35 +08:00
|
|
|
|
2014-11-21 18:41:29 +08:00
|
|
|
/*! \brief Read geometry from STL binary stream
|
|
|
|
*/
|
2015-01-29 05:39:03 +08:00
|
|
|
GMIO_LIBSTL_EXPORT
|
|
|
|
int gmio_stlb_read(gmio_stl_mesh_creator_t* creator,
|
|
|
|
gmio_transfer_t* trsf,
|
|
|
|
const gmio_stlb_read_options_t* options);
|
2014-11-21 18:41:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*! \brief Options for gmio_stlb_write()
|
|
|
|
*/
|
|
|
|
struct gmio_stlb_write_options
|
|
|
|
{
|
2015-03-03 17:35:36 +08:00
|
|
|
/*! Header data consisting of 80 bytes */
|
|
|
|
const uint8_t* header_data;
|
2014-11-21 18:41:29 +08:00
|
|
|
|
2015-03-03 17:35:36 +08:00
|
|
|
/*! Set to host byte order if not specified (ie. options == NULL) */
|
|
|
|
gmio_endianness_t byte_order;
|
2014-11-21 18:41:29 +08:00
|
|
|
};
|
|
|
|
typedef struct gmio_stlb_write_options gmio_stlb_write_options_t;
|
2014-03-28 23:33:35 +08:00
|
|
|
|
2014-11-21 18:41:29 +08:00
|
|
|
/*! \brief Write geometry in the STL binary format
|
|
|
|
*/
|
2015-01-29 05:39:03 +08:00
|
|
|
GMIO_LIBSTL_EXPORT
|
|
|
|
int gmio_stlb_write(const gmio_stl_mesh_t* mesh,
|
|
|
|
gmio_transfer_t* trsf,
|
|
|
|
const gmio_stlb_write_options_t* options);
|
2014-03-28 23:33:35 +08:00
|
|
|
|
|
|
|
GMIO_C_LINKAGE_END
|
|
|
|
|
|
|
|
#endif /* GMIO_LIBSTL_STL_IO_H */
|