2015-03-03 00:38:33 +08:00
|
|
|
/****************************************************************************
|
2015-05-28 15:40:24 +08:00
|
|
|
** gmio
|
2015-05-01 00:19:45 +08:00
|
|
|
** Copyright Fougue (2 Mar. 2015)
|
2015-07-13 17:42:03 +08:00
|
|
|
** contact@fougue.pro
|
2015-03-03 00:38:33 +08:00
|
|
|
**
|
|
|
|
** 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
|
2015-03-30 15:05:25 +08:00
|
|
|
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
2015-03-03 00:38:33 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
2015-03-05 01:25:51 +08:00
|
|
|
/*! \file stl_io.h
|
|
|
|
* STL read/write functions
|
2015-09-09 17:44:34 +08:00
|
|
|
*
|
|
|
|
* \addtogroup gmio_stl
|
|
|
|
* @{
|
2015-03-05 01:25:51 +08:00
|
|
|
*/
|
|
|
|
|
2015-04-02 16:41:41 +08:00
|
|
|
#ifndef GMIO_STL_IO_H
|
|
|
|
#define GMIO_STL_IO_H
|
2014-03-28 23:33:35 +08:00
|
|
|
|
|
|
|
#include "stl_global.h"
|
2016-01-29 19:47:01 +08:00
|
|
|
|
|
|
|
#include "stl_format.h"
|
|
|
|
#include "stl_io_options.h"
|
|
|
|
#include "stl_mesh.h"
|
|
|
|
#include "stl_mesh_creator.h"
|
|
|
|
#include "../gmio_core/stream.h"
|
2014-03-28 23:33:35 +08:00
|
|
|
#include "../gmio_core/endian.h"
|
2015-12-04 01:00:25 +08:00
|
|
|
|
2014-03-28 23:33:35 +08:00
|
|
|
GMIO_C_LINKAGE_BEGIN
|
|
|
|
|
2015-04-02 22:38:14 +08:00
|
|
|
/*! Reads STL mesh from stream, format is automatically guessed
|
2015-03-24 01:21:04 +08:00
|
|
|
*
|
2015-12-10 01:51:03 +08:00
|
|
|
* \return Error code (see gmio_core/error.h and stl_error.h)
|
2015-03-24 01:21:04 +08:00
|
|
|
*/
|
2016-03-07 23:43:51 +08:00
|
|
|
GMIO_LIBSTL_EXPORT
|
|
|
|
int gmio_stl_read(
|
2016-03-01 21:50:31 +08:00
|
|
|
struct gmio_stream* stream,
|
|
|
|
struct gmio_stl_mesh_creator* mesh_creator,
|
2016-01-29 19:47:01 +08:00
|
|
|
const struct gmio_stl_read_options* options);
|
2015-03-24 01:21:04 +08:00
|
|
|
|
2015-12-10 01:51:03 +08:00
|
|
|
/*! Reads STL mesh from a file, format is automatically guessed
|
2015-04-02 22:38:14 +08:00
|
|
|
*
|
2016-01-29 19:47:01 +08:00
|
|
|
* This is just a facility function over gmio_stl_read(). The internal stream
|
|
|
|
* object is created to read file at \p filepath (see gmio_stream_stdio(FILE*))
|
2015-04-02 22:38:14 +08:00
|
|
|
*
|
2015-12-10 01:51:03 +08:00
|
|
|
* The file is opened with fopen() so \p filepath shall follow the file name
|
|
|
|
* specifications of the running environment
|
2015-04-02 22:38:14 +08:00
|
|
|
*/
|
2016-03-07 23:43:51 +08:00
|
|
|
GMIO_LIBSTL_EXPORT
|
|
|
|
int gmio_stl_read_file(
|
2016-01-29 19:47:01 +08:00
|
|
|
const char* filepath,
|
2016-03-01 21:50:31 +08:00
|
|
|
struct gmio_stl_mesh_creator* mesh_creator,
|
2016-01-29 19:47:01 +08:00
|
|
|
const struct gmio_stl_read_options* options);
|
2014-03-28 23:33:35 +08:00
|
|
|
|
2015-03-03 18:35:15 +08:00
|
|
|
/*! Reads geometry from STL ascii stream
|
2015-03-24 01:21:04 +08:00
|
|
|
*
|
2015-12-10 01:51:03 +08:00
|
|
|
* \return Error code (see gmio_core/error.h and stl_error.h)
|
2014-11-21 18:41:29 +08:00
|
|
|
*/
|
2015-01-29 05:39:03 +08:00
|
|
|
GMIO_LIBSTL_EXPORT
|
2016-01-29 19:47:01 +08:00
|
|
|
int gmio_stla_read(
|
2016-03-01 21:50:31 +08:00
|
|
|
struct gmio_stream* stream,
|
|
|
|
struct gmio_stl_mesh_creator* mesh_creator,
|
2016-01-29 19:47:01 +08:00
|
|
|
const struct gmio_stl_read_options* options);
|
2015-05-28 22:19:07 +08:00
|
|
|
|
2015-03-13 19:19:19 +08:00
|
|
|
/*! Reads geometry from STL binary stream
|
|
|
|
*
|
2015-12-10 01:51:03 +08:00
|
|
|
* \return Error code (see gmio_core/error.h and stl_error.h)
|
2015-09-25 19:16:41 +08:00
|
|
|
* \retval GMIO_ERROR_INVALID_MEMBLOCK_SIZE
|
2016-01-29 19:47:01 +08:00
|
|
|
* if <tt>options->stream_memblock.size < GMIO_STLB_MIN_CONTENTS_SIZE</tt>
|
2015-03-13 19:19:19 +08:00
|
|
|
*/
|
2015-01-29 05:39:03 +08:00
|
|
|
GMIO_LIBSTL_EXPORT
|
2015-03-30 15:30:55 +08:00
|
|
|
int gmio_stlb_read(
|
2016-03-01 21:50:31 +08:00
|
|
|
struct gmio_stream* stream,
|
|
|
|
struct gmio_stl_mesh_creator* mesh_creator,
|
2016-01-29 19:47:01 +08:00
|
|
|
enum gmio_endianness byte_order,
|
|
|
|
const struct gmio_stl_read_options* options);
|
2015-12-10 01:51:03 +08:00
|
|
|
|
|
|
|
/*! Writes STL mesh to stream
|
|
|
|
*
|
|
|
|
* \return Error code (see gmio_core/error.h and stl_error.h)
|
|
|
|
*/
|
|
|
|
GMIO_LIBSTL_EXPORT
|
2015-12-17 19:31:30 +08:00
|
|
|
int gmio_stl_write(
|
2016-01-29 19:47:01 +08:00
|
|
|
enum gmio_stl_format format,
|
2016-03-01 21:50:31 +08:00
|
|
|
struct gmio_stream* stream,
|
|
|
|
const struct gmio_stl_mesh* mesh,
|
2016-01-29 19:47:01 +08:00
|
|
|
const struct gmio_stl_write_options* options);
|
2015-07-28 21:14:39 +08:00
|
|
|
|
2015-12-10 01:51:03 +08:00
|
|
|
/*! Writes STL mesh to stream
|
|
|
|
*
|
2016-01-29 19:47:01 +08:00
|
|
|
* This is just a facility function over gmio_stl_write(). The internal stream
|
|
|
|
* object is created to read file at \p filepath (see gmio_stream_stdio(FILE*))
|
2015-12-10 01:51:03 +08:00
|
|
|
*
|
|
|
|
* The file is opened with fopen() so \p filepath shall follow the file name
|
|
|
|
* specifications of the running environment
|
2015-07-28 21:14:39 +08:00
|
|
|
|
2015-12-10 01:51:03 +08:00
|
|
|
* \return Error code (see gmio_core/error.h and stl_error.h)
|
|
|
|
*/
|
|
|
|
GMIO_LIBSTL_EXPORT
|
2015-12-17 19:31:30 +08:00
|
|
|
int gmio_stl_write_file(
|
|
|
|
enum gmio_stl_format format,
|
2016-01-29 19:47:01 +08:00
|
|
|
const char* filepath,
|
2016-03-01 21:50:31 +08:00
|
|
|
const struct gmio_stl_mesh* mesh,
|
2016-01-29 19:47:01 +08:00
|
|
|
const struct gmio_stl_write_options* options);
|
2014-11-21 18:41:29 +08:00
|
|
|
|
2015-05-27 23:29:48 +08:00
|
|
|
/*! Writes STL binary header data to stream
|
|
|
|
*
|
|
|
|
* This functions only writes the 80-bytes header array and the count of facets
|
|
|
|
* in the mesh(with respect of the specified byte order).
|
|
|
|
*
|
|
|
|
* \return Error code (see error.h and stl_error.h)
|
|
|
|
*/
|
|
|
|
GMIO_LIBSTL_EXPORT
|
|
|
|
int gmio_stlb_write_header(
|
2015-07-28 21:14:39 +08:00
|
|
|
/*! Output stream where is written the header data */
|
2015-12-04 01:00:25 +08:00
|
|
|
struct gmio_stream* stream,
|
2015-07-28 21:14:39 +08:00
|
|
|
|
|
|
|
/*! Byte order of the output STL data */
|
2015-12-04 01:00:25 +08:00
|
|
|
enum gmio_endianness byte_order,
|
2015-07-28 21:14:39 +08:00
|
|
|
|
|
|
|
/*! 80-bytes array of header data, can be safely set to NULL to generate
|
|
|
|
* an array of zeroes */
|
2015-12-04 01:00:25 +08:00
|
|
|
const struct gmio_stlb_header* header,
|
2015-07-28 21:14:39 +08:00
|
|
|
|
|
|
|
/*! Total count of facets (triangles) in the mesh to be written */
|
|
|
|
uint32_t facet_count
|
|
|
|
);
|
2015-05-27 23:29:48 +08:00
|
|
|
|
2014-03-28 23:33:35 +08:00
|
|
|
GMIO_C_LINKAGE_END
|
|
|
|
|
2015-04-02 16:41:41 +08:00
|
|
|
#endif /* GMIO_STL_IO_H */
|
2015-09-09 17:44:34 +08:00
|
|
|
/*! @} */
|