2015-12-10 01:51:03 +08:00
|
|
|
/****************************************************************************
|
|
|
|
** gmio
|
|
|
|
** Copyright Fougue (2 Mar. 2015)
|
|
|
|
** contact@fougue.pro
|
|
|
|
**
|
|
|
|
** 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/licences/Licence_CeCILL-B_V1-en.html".
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/*! \file stl_infos.h
|
2016-01-29 19:47:01 +08:00
|
|
|
* Retrieval of STL infos from input stream
|
2015-12-10 01:51:03 +08:00
|
|
|
*
|
|
|
|
* \addtogroup gmio_stl
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GMIO_STL_INFOS_H
|
|
|
|
#define GMIO_STL_INFOS_H
|
|
|
|
|
|
|
|
#include "stl_global.h"
|
|
|
|
|
|
|
|
#include "../gmio_core/internal/helper_stream.h"
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include "stl_format.h"
|
|
|
|
#include "stlb_header.h"
|
|
|
|
|
2015-12-18 22:30:50 +08:00
|
|
|
/*! Informations retrieved by gmio_stl_infos_get() */
|
2015-12-10 01:51:03 +08:00
|
|
|
struct gmio_stl_infos
|
|
|
|
{
|
2016-01-29 19:47:01 +08:00
|
|
|
/*! STL format of the input stream */
|
2016-02-01 17:47:54 +08:00
|
|
|
enum gmio_stl_format format;
|
2016-01-29 19:47:01 +08:00
|
|
|
|
2015-12-10 01:51:03 +08:00
|
|
|
/*! Count of facets(triangles) */
|
|
|
|
uint32_t facet_count;
|
|
|
|
|
|
|
|
/*! Size of the STL data in bytes
|
|
|
|
*
|
|
|
|
* For STL ascii it includes the "endsolid" tag */
|
2015-12-17 19:03:45 +08:00
|
|
|
gmio_streamsize_t size;
|
2015-12-10 01:51:03 +08:00
|
|
|
|
2015-12-18 17:45:51 +08:00
|
|
|
/*! STL ascii only: name of the solid
|
|
|
|
*
|
2016-01-13 22:17:18 +08:00
|
|
|
* The pointer has to be set before calling gmio_stl_infos_get() */
|
2015-12-10 01:51:03 +08:00
|
|
|
char* stla_solidname;
|
|
|
|
|
2015-12-18 17:45:51 +08:00
|
|
|
/*! STL ascii only: maximum length(capacity) of stla_solidname
|
|
|
|
*
|
2016-01-13 22:17:18 +08:00
|
|
|
* The value has to be set before calling gmio_stl_infos_get()
|
2015-12-10 01:51:03 +08:00
|
|
|
*/
|
|
|
|
size_t stla_solidname_maxlen;
|
|
|
|
|
2015-12-18 17:45:51 +08:00
|
|
|
/*! STL binary only: header(80-bytes) of STL data */
|
2015-12-10 01:51:03 +08:00
|
|
|
struct gmio_stlb_header stlb_header;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! Flags(OR-combinations) for each STL info */
|
|
|
|
enum gmio_stl_info_flag
|
|
|
|
{
|
|
|
|
/*! -> gmio_stl_infos::facet_count */
|
|
|
|
GMIO_STL_INFO_FLAG_FACET_COUNT = 0x0001,
|
|
|
|
|
|
|
|
/*! -> gmio_stl_infos::size */
|
|
|
|
GMIO_STL_INFO_FLAG_SIZE = 0x0002,
|
|
|
|
|
|
|
|
/*! -> gmio_stl_infos::stla_solidname */
|
|
|
|
GMIO_STLA_INFO_FLAG_SOLIDNAME = 0x0004,
|
|
|
|
|
|
|
|
/*! -> gmio_stl_infos::stlb_header */
|
|
|
|
GMIO_STLB_INFO_FLAG_HEADER = 0x0008,
|
|
|
|
|
|
|
|
/*! -> gmio_stl_infos::stla_solidname or gmio_stl_infos::stlb_header */
|
|
|
|
GMIO_STL_INFO_FLAG_SOLIDNAME_OR_HEADER =
|
|
|
|
GMIO_STLA_INFO_FLAG_SOLIDNAME | GMIO_STLB_INFO_FLAG_HEADER,
|
|
|
|
|
2016-01-29 19:47:01 +08:00
|
|
|
/*! -> gmio_stl_infos::format */
|
|
|
|
GMIO_STL_INFO_FLAG_FORMAT = 0x0010,
|
|
|
|
|
2015-12-10 01:51:03 +08:00
|
|
|
/*! All infos */
|
|
|
|
GMIO_STL_INFO_FLAG_ALL = 0xFFFF
|
|
|
|
};
|
|
|
|
|
2016-03-11 19:43:30 +08:00
|
|
|
/*! Options of function gmio_stl_infos_get() */
|
2016-01-29 19:47:01 +08:00
|
|
|
struct gmio_stl_infos_get_options
|
2015-12-10 01:51:03 +08:00
|
|
|
{
|
2016-01-29 19:47:01 +08:00
|
|
|
/*! See gmio_core_readwrite_options::stream_memblock */
|
2015-12-17 19:03:45 +08:00
|
|
|
struct gmio_memblock stream_memblock;
|
2015-12-18 22:30:50 +08:00
|
|
|
|
2016-01-29 19:47:01 +08:00
|
|
|
/*! Assume STL input format, if GMIO_STL_FORMAT_UNKNOWN then it is
|
|
|
|
* automatically guessed */
|
|
|
|
enum gmio_stl_format format_hint;
|
|
|
|
|
2016-03-11 19:43:30 +08:00
|
|
|
/*! Restrict gmio_stl_infos_get() to not read further this limit(in bytes)
|
2016-01-29 19:47:01 +08:00
|
|
|
*
|
2016-03-11 19:43:30 +08:00
|
|
|
* \warning Not yet supported
|
2016-01-29 19:47:01 +08:00
|
|
|
*/
|
|
|
|
gmio_streamsize_t size_limit;
|
2015-12-10 01:51:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
GMIO_C_LINKAGE_BEGIN
|
|
|
|
|
2015-12-18 22:30:50 +08:00
|
|
|
/*! Finds informations about STL contents
|
2016-03-11 19:43:30 +08:00
|
|
|
*
|
|
|
|
* \p infos is an output parameter that will hold the retrieved infos
|
|
|
|
*
|
|
|
|
* \p flags is a bitor combination of \c gmio_stl_info_flag values and is used
|
|
|
|
* to select the infos to retrieve.
|
2015-12-18 22:30:50 +08:00
|
|
|
*
|
|
|
|
* \return Error code (see gmio_core/error.h and stl_error.h)
|
|
|
|
*/
|
2016-03-11 19:43:30 +08:00
|
|
|
GMIO_API int gmio_stl_infos_get(
|
2016-01-29 19:47:01 +08:00
|
|
|
struct gmio_stl_infos* infos,
|
2016-03-01 21:50:31 +08:00
|
|
|
struct gmio_stream* stream,
|
2016-03-11 19:43:30 +08:00
|
|
|
unsigned flags,
|
2016-01-29 19:47:01 +08:00
|
|
|
const struct gmio_stl_infos_get_options* options);
|
2015-12-10 01:51:03 +08:00
|
|
|
|
2016-03-11 19:43:30 +08:00
|
|
|
/*! Returns the size(in bytes) of the next STL ascii solid in \p stream
|
2016-02-24 23:43:40 +08:00
|
|
|
*
|
|
|
|
* It is a facade over gmio_stl_infos_get() for gmio_stl_infos::size only
|
2016-03-11 19:43:30 +08:00
|
|
|
*
|
|
|
|
* Pointer to this function can be given to
|
|
|
|
* gmio_stl_read_options::func_stla_get_streamsize() and is useful when
|
|
|
|
* reading in sequence multi solids in STL ascii. The stream can be cleanly
|
|
|
|
* advanced solid by solid after each call to gmio_stl_read()
|
2016-02-24 23:43:40 +08:00
|
|
|
*/
|
2016-03-11 19:43:30 +08:00
|
|
|
GMIO_API gmio_streamsize_t gmio_stla_infos_get_streamsize(
|
2016-02-24 23:43:40 +08:00
|
|
|
struct gmio_stream* stream,
|
|
|
|
struct gmio_memblock* stream_memblock);
|
|
|
|
|
2015-12-10 01:51:03 +08:00
|
|
|
GMIO_C_LINKAGE_END
|
|
|
|
|
|
|
|
#endif /* GMIO_STL_INFOS_H */
|
|
|
|
/*! @} */
|