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".
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-03-05 01:25:51 +08:00
|
|
|
/*! \file stl_io.h
|
|
|
|
* STL read/write functions
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/* ========================================================================
|
2014-03-28 23:33:35 +08:00
|
|
|
* STL ascii
|
2015-03-03 18:35:15 +08:00
|
|
|
* ======================================================================== */
|
2014-03-28 23:33:35 +08:00
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/*! Options for gmio_stla_read()
|
2014-11-21 18:41:29 +08:00
|
|
|
*
|
2015-03-13 17:32:18 +08:00
|
|
|
* Possible other options in the future:
|
2015-03-02 23:49:52 +08:00
|
|
|
* - flag to force locale ?
|
|
|
|
* - case sensitive/insensitive ?
|
2014-11-21 18:41:29 +08:00
|
|
|
*/
|
|
|
|
struct gmio_stla_read_options
|
|
|
|
{
|
2015-03-13 17:32:18 +08:00
|
|
|
/*! Hint about the total size (in bytes) of the STL ascii data to be read
|
|
|
|
* from stream
|
|
|
|
*
|
|
|
|
* \p stream_size is passed to gmio_transfer::handle_progress_func() as
|
|
|
|
* the \p max_value argument.
|
|
|
|
*
|
|
|
|
* It's defaulted to \c 0 if options argument is set to NULL (when
|
|
|
|
* calling gmio_stla_read())
|
|
|
|
*/
|
|
|
|
size_t stream_size;
|
2014-11-21 18:41:29 +08:00
|
|
|
};
|
|
|
|
typedef struct gmio_stla_read_options gmio_stla_read_options_t;
|
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/*! Reads geometry from STL ascii stream
|
2014-11-21 18:41:29 +08:00
|
|
|
*
|
|
|
|
* \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-13 17:32:18 +08:00
|
|
|
const gmio_stla_read_options_t* options);
|
2014-11-21 18:41:29 +08:00
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/*! Options for gmio_stla_write() */
|
2014-11-21 18:41:29 +08:00
|
|
|
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
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/*! Writes geometry in the STL ascii format
|
2014-11-21 18:41:29 +08:00
|
|
|
*
|
|
|
|
* \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
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/* ========================================================================
|
2014-03-28 23:33:35 +08:00
|
|
|
* STL binary
|
2015-03-03 18:35:15 +08:00
|
|
|
* ======================================================================== */
|
2014-11-21 18:41:29 +08:00
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/*! Options for gmio_stlb_read() */
|
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
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/*! Reads 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
|
|
|
|
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/*! Options for gmio_stlb_write() */
|
2014-11-21 18:41:29 +08:00
|
|
|
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
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/*! Writes 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 */
|