API simplification, more homogeneous

This commit is contained in:
Hugues Delorme 2016-03-11 12:43:30 +01:00
parent e4492f92f9
commit d5133928c4
26 changed files with 108 additions and 134 deletions

View File

@ -105,7 +105,7 @@ static void readwrite_begin_solid(
* procedure (in gmio_stl_mesh_creator::func_end_solid() callback) * procedure (in gmio_stl_mesh_creator::func_end_solid() callback)
*/ */
const enum gmio_endianness byte_order = to_byte_order(rw_conv->out_format); const enum gmio_endianness byte_order = to_byte_order(rw_conv->out_format);
gmio_stlb_write_header(stream, byte_order, NULL, 0); gmio_stlb_header_write(stream, byte_order, NULL, 0);
} }
} }
else { else {
@ -113,7 +113,7 @@ static void readwrite_begin_solid(
stream->func_write(stream->cookie, "solid\n", 1, 6); stream->func_write(stream->cookie, "solid\n", 1, 6);
} }
else { else {
gmio_stlb_write_header( gmio_stlb_header_write(
stream, stream,
to_byte_order(rw_conv->out_format), to_byte_order(rw_conv->out_format),
infos->stlb_header, infos->stlb_header,
@ -172,7 +172,7 @@ static void readwrite_end_solid(void* cookie)
/* The total facet count has to be written because it wasn't known at /* The total facet count has to be written because it wasn't known at
* the beginning of the read procedure */ * the beginning of the read procedure */
stream->func_set_pos(stream->cookie, &rw_conv->out_stream_pos_begin); stream->func_set_pos(stream->cookie, &rw_conv->out_stream_pos_begin);
gmio_stlb_write_header( gmio_stlb_header_write(
stream, byte_order, NULL, rw_conv->total_triangle_count); stream, byte_order, NULL, rw_conv->total_triangle_count);
} }
} }
@ -191,7 +191,7 @@ static void bmk_gmio_stl_readwrite_conv(const void* filepath)
if (infile != NULL) { if (infile != NULL) {
instream = gmio_stream_stdio(infile); instream = gmio_stream_stdio(infile);
rw_conv.in_format = gmio_stl_get_format(&instream); rw_conv.in_format = gmio_stl_format_probe(&instream);
} }
if (outfile != NULL) { if (outfile != NULL) {
rw_conv.stream = gmio_stream_stdio(outfile); rw_conv.stream = gmio_stream_stdio(outfile);

View File

@ -30,8 +30,8 @@ include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For cmake generated hea
# Enable DLL generation (export symbols) # Enable DLL generation (export symbols)
if(GMIO_BUILD_SHARED_LIBS) if(GMIO_BUILD_SHARED_LIBS)
add_definitions(-DGMIO_LIB_DLL add_definitions(-DGMIO_DLL
-DGMIO_LIB_MAKE_DLL) -DGMIO_MAKING_DLL)
if(MSVC) if(MSVC)
configure_file(gmio_core/gmio.rc.cmake gmio_core/gmio.rc @ONLY) configure_file(gmio_core/gmio.rc.cmake gmio_core/gmio.rc @ONLY)
set(GMIO_SRC_FILES ${GMIO_SRC_FILES} ${CMAKE_BINARY_DIR}/src/gmio_core/gmio.rc) set(GMIO_SRC_FILES ${GMIO_SRC_FILES} ${CMAKE_BINARY_DIR}/src/gmio_core/gmio.rc)
@ -46,10 +46,10 @@ file(GLOB GMIO_CORE_HEADERS gmio_core/*.h)
install(FILES ${GMIO_CORE_HEADERS} DESTINATION include/gmio_core) install(FILES ${GMIO_CORE_HEADERS} DESTINATION include/gmio_core)
# Module libSTL # Module libSTL
if(GMIO_BUILD_SHARED_LIBS) #if(GMIO_BUILD_SHARED_LIBS)
add_definitions(-DGMIO_LIBSTL_DLL # add_definitions(-DGMIO_STL_DLL
-DGMIO_LIBSTL_MAKE_DLL) # -DGMIO_STL_MAKING_DLL)
endif() #endif()
file(GLOB GMIO_LIBSTL_SRC_FILES gmio_stl/* gmio_stl/internal/*) file(GLOB GMIO_LIBSTL_SRC_FILES gmio_stl/* gmio_stl/internal/*)
set(GMIO_SRC_FILES ${GMIO_SRC_FILES} ${GMIO_LIBSTL_SRC_FILES}) set(GMIO_SRC_FILES ${GMIO_SRC_FILES} ${GMIO_LIBSTL_SRC_FILES})

View File

@ -55,7 +55,7 @@ enum gmio_endianness
GMIO_C_LINKAGE_BEGIN GMIO_C_LINKAGE_BEGIN
/*! Returns endianness (byte order) of the host's CPU architecture */ /*! Returns endianness (byte order) of the host's CPU architecture */
GMIO_LIB_EXPORT enum gmio_endianness gmio_host_endianness(); GMIO_API enum gmio_endianness gmio_host_endianness();
GMIO_C_LINKAGE_END GMIO_C_LINKAGE_END

View File

@ -63,17 +63,17 @@
# define GMIO_DECL_IMPORT # define GMIO_DECL_IMPORT
#endif #endif
/* GMIO_LIB_EXPORT */ /* GMIO_API */
#ifdef GMIO_LIB_DLL #ifdef GMIO_DLL
# ifdef GMIO_LIB_MAKE_DLL # ifdef GMIO_MAKING_DLL
# define GMIO_LIB_EXPORT GMIO_DECL_EXPORT # define GMIO_API GMIO_DECL_EXPORT
# else # else
# define GMIO_LIB_EXPORT GMIO_DECL_IMPORT # define GMIO_API GMIO_DECL_IMPORT
# endif /* GMIO_LIB_MAKE_DLL */ # endif /* GMIO_MAKING_DLL */
#else #else
/*! Expands either to GMIO_DECL_EXPORT or GMIO_DECL_IMPORT when respectively /*! Expands either to GMIO_DECL_EXPORT or GMIO_DECL_IMPORT when respectively
* compiling/using the DLL */ * compiling/using the DLL */
# define GMIO_LIB_EXPORT # define GMIO_API
#endif #endif
/* Typedefs for specific width integers */ /* Typedefs for specific width integers */

View File

@ -44,32 +44,26 @@ struct gmio_memblock
GMIO_C_LINKAGE_BEGIN GMIO_C_LINKAGE_BEGIN
/*! Returns true if \p mblock is NULL or points to null/void memory */ /*! Returns true if \p mblock is NULL or points to null/void memory */
GMIO_LIB_EXPORT GMIO_API bool gmio_memblock_isnull(const struct gmio_memblock* mblock);
bool gmio_memblock_isnull(const struct gmio_memblock* mblock);
/*! Returns an initialized gmio_memblock object /*! Returns an initialized gmio_memblock object
* *
* If \p ptr is NULL then gmio_memblock::size is forced to \c 0 * If \p ptr is NULL then gmio_memblock::size is forced to \c 0
*/ */
GMIO_LIB_EXPORT GMIO_API struct gmio_memblock gmio_memblock(
struct gmio_memblock gmio_memblock(
void* ptr, size_t size, void (*func_deallocate)(void*)); void* ptr, size_t size, void (*func_deallocate)(void*));
/*! Returns a gmio_memblock object allocated with standard \c malloc() */ /*! Returns a gmio_memblock object allocated with standard \c malloc() */
GMIO_LIB_EXPORT GMIO_API struct gmio_memblock gmio_memblock_malloc(size_t size);
struct gmio_memblock gmio_memblock_malloc(size_t size);
/*! Returns a gmio_memblock object allocated with standard \c calloc() */ /*! Returns a gmio_memblock object allocated with standard \c calloc() */
GMIO_LIB_EXPORT GMIO_API struct gmio_memblock gmio_memblock_calloc(size_t num, size_t size);
struct gmio_memblock gmio_memblock_calloc(size_t num, size_t size);
/*! Returns a gmio_memblock object allocated with standard \c realloc() */ /*! Returns a gmio_memblock object allocated with standard \c realloc() */
GMIO_LIB_EXPORT GMIO_API struct gmio_memblock gmio_memblock_realloc(void* ptr, size_t size);
struct gmio_memblock gmio_memblock_realloc(void* ptr, size_t size);
/*! Safe and convenient call to gmio_memblock::func_deallocate() */ /*! Safe and convenient call to gmio_memblock::func_deallocate() */
GMIO_LIB_EXPORT GMIO_API void gmio_memblock_deallocate(struct gmio_memblock* mblock);
void gmio_memblock_deallocate(struct gmio_memblock* mblock);
/*! Typedef for a pointer to a function that creates an allocated mblock /*! Typedef for a pointer to a function that creates an allocated mblock
* *
@ -85,21 +79,18 @@ typedef struct gmio_memblock (*gmio_memblock_constructor_func_t)();
* *
* This function is not thread-safe. * This function is not thread-safe.
*/ */
GMIO_LIB_EXPORT GMIO_API void gmio_memblock_set_default_constructor(
void gmio_memblock_set_default_constructor(
gmio_memblock_constructor_func_t ctor); gmio_memblock_constructor_func_t ctor);
/*! Returns the currently installed function to construct gmio_memblock objects /*! Returns the currently installed function to construct gmio_memblock objects
* *
* It is initialized to <tt>gmio_memblock_malloc(128KB)</tt> * It is initialized to <tt>gmio_memblock_malloc(128KB)</tt>
*/ */
GMIO_LIB_EXPORT GMIO_API gmio_memblock_constructor_func_t gmio_memblock_default_constructor();
gmio_memblock_constructor_func_t gmio_memblock_default_constructor();
/*! Returns a gmio_memblock object created using the function /*! Returns a gmio_memblock object created using the function
* gmio_memblock_default_constructor() */ * gmio_memblock_default_constructor() */
GMIO_LIB_EXPORT GMIO_API struct gmio_memblock gmio_memblock_default();
struct gmio_memblock gmio_memblock_default();
GMIO_C_LINKAGE_END GMIO_C_LINKAGE_END

View File

@ -28,12 +28,25 @@
#include "streampos.h" #include "streampos.h"
#include <stdio.h> #include <stdio.h>
#ifdef GMIO_HAVE_INT64_TYPE #ifndef DOXYGEN
# ifdef GMIO_HAVE_INT64_TYPE
typedef int64_t gmio_streamsize_t; typedef int64_t gmio_streamsize_t;
typedef int64_t gmio_streamoffset_t; typedef int64_t gmio_streamoffset_t;
#else # else
typedef long gmio_streamsize_t; typedef long gmio_streamsize_t;
typedef long gmio_streamoffset_t; typedef long gmio_streamoffset_t;
# endif
#else
/*! Type able to represent the size(in bytes) of a stream
*
* It can be int64_t or long depending on the compiler support
*/
typedef int64_or_long gmio_streamsize_t;
/*! Type able to represent the offset position within a stream
*
* It can be int64_t or long depending on the compiler support
*/
typedef int64_or_long gmio_streamoffset_t;
#endif #endif
/*! Stream that can get input from an arbitrary data source or can write /*! Stream that can get input from an arbitrary data source or can write
@ -126,10 +139,10 @@ GMIO_C_LINKAGE_BEGIN
/* Initialization */ /* Initialization */
/*! Returns a null stream */ /*! Returns a null stream */
GMIO_LIB_EXPORT struct gmio_stream gmio_stream_null(); GMIO_API struct gmio_stream gmio_stream_null();
/*! Returns a stream for standard FILE* (cookie will hold \p file) */ /*! Returns a stream for standard FILE* (cookie will hold \p file) */
GMIO_LIB_EXPORT struct gmio_stream gmio_stream_stdio(FILE* file); GMIO_API struct gmio_stream gmio_stream_stdio(FILE* file);
GMIO_C_LINKAGE_END GMIO_C_LINKAGE_END

View File

@ -25,7 +25,8 @@
#include "global.h" #include "global.h"
/*! Size of the byte array gmio_streampos::cookie */ /*! \c GMIO_STREAMPOS_COOKIE_SIZE
* Size of the byte array gmio_streampos::cookie */
enum { GMIO_STREAMPOS_COOKIE_SIZE = 32 /* bytes */ }; enum { GMIO_STREAMPOS_COOKIE_SIZE = 32 /* bytes */ };
/*! Specifies a position within a stream /*! Specifies a position within a stream

View File

@ -25,7 +25,7 @@
#include "global.h" #include "global.h"
/*! Defines an interface through which any task can be controlled */ /*! Defines an interface through which a task can be controlled */
struct gmio_task_iface struct gmio_task_iface
{ {
/*! Optional opaque pointer on a user task object, passed as first /*! Optional opaque pointer on a user task object, passed as first

View File

@ -122,7 +122,7 @@ int gmio_stlb_write(
goto label_end; goto label_end;
if (!write_triangles_only) { if (!write_triangles_only) {
error = gmio_stlb_write_header(stream, byte_order, header, facet_count); error = gmio_stlb_header_write(stream, byte_order, header, facet_count);
if (gmio_error(error)) if (gmio_error(error))
goto label_end; goto label_end;
} }

View File

@ -23,7 +23,8 @@
#ifndef GMIO_STL_ERROR_H #ifndef GMIO_STL_ERROR_H
#define GMIO_STL_ERROR_H #define GMIO_STL_ERROR_H
/*! A byte-mask to tag(identify) STL-specific error codes */ /*! \c GMIO_STL_ERROR_TAG
* Byte-mask to tag(identify) STL-specific error codes */
enum { GMIO_STL_ERROR_TAG = 0x11000000 }; enum { GMIO_STL_ERROR_TAG = 0x11000000 };
/*! This enum defines the various error codes reported by STL read/write /*! This enum defines the various error codes reported by STL read/write

View File

@ -116,7 +116,7 @@ static bool gmio_is_stl_ascii(const char* buff, size_t buff_len)
return false; return false;
} }
enum gmio_stl_format gmio_stl_get_format(struct gmio_stream *stream) enum gmio_stl_format gmio_stl_format_probe(struct gmio_stream *stream)
{ {
char buff[GMIO_FIXED_BUFFER_SIZE] = {0}; char buff[GMIO_FIXED_BUFFER_SIZE] = {0};
size_t read_size = 0; size_t read_size = 0;
@ -155,14 +155,14 @@ enum gmio_stl_format gmio_stl_get_format(struct gmio_stream *stream)
return GMIO_STL_FORMAT_UNKNOWN; return GMIO_STL_FORMAT_UNKNOWN;
} }
enum gmio_stl_format gmio_stl_get_format_file(const char* filepath) enum gmio_stl_format gmio_stl_format_probe_file(const char* filepath)
{ {
enum gmio_stl_format format = GMIO_STL_FORMAT_UNKNOWN; enum gmio_stl_format format = GMIO_STL_FORMAT_UNKNOWN;
FILE* file = fopen(filepath, "rb"); FILE* file = fopen(filepath, "rb");
if (file != NULL) { if (file != NULL) {
struct gmio_stream stream = gmio_stream_stdio(file); struct gmio_stream stream = gmio_stream_stdio(file);
format = gmio_stl_get_format(&stream); format = gmio_stl_format_probe(&stream);
fclose(file); fclose(file);
} }
return format; return format;

View File

@ -26,7 +26,8 @@
#include "stl_global.h" #include "stl_global.h"
#include "../gmio_core/stream.h" #include "../gmio_core/stream.h"
/*! A byte-mask to tag(identify) STL binary formats */ /*! \c GMIO_STL_FORMAT_TAG_BINARY
* Byte-mask to tag(identify) STL binary formats */
enum { GMIO_STL_FORMAT_TAG_BINARY = 0x10 }; enum { GMIO_STL_FORMAT_TAG_BINARY = 0x10 };
/*! This enums defines the various STL formats */ /*! This enums defines the various STL formats */
@ -53,19 +54,17 @@ GMIO_C_LINKAGE_BEGIN
* *
* \retval GMIO_STL_FORMAT_UNKNOWN in case of error. * \retval GMIO_STL_FORMAT_UNKNOWN in case of error.
*/ */
GMIO_LIBSTL_EXPORT GMIO_API enum gmio_stl_format gmio_stl_format_probe(struct gmio_stream* stream);
enum gmio_stl_format gmio_stl_get_format(struct gmio_stream* stream);
/*! Returns the format of the STL data in file at location \p filepath /*! Returns the format of the STL data in file at location \p filepath
* *
* This function is a wrapper around gmio_stl_get_format() * This function is a wrapper around gmio_stl_format_probe()
* *
* \param filepath Path to the STL file. A stream is opened with fopen() so * \param filepath Path to the STL file. A stream is opened with \c fopen() so
* the string shall follow the file name specifications of the running * the string shall follow the file name specifications of the running
* environment * environment
*/ */
GMIO_LIBSTL_EXPORT GMIO_API enum gmio_stl_format gmio_stl_format_probe_file(const char* filepath);
enum gmio_stl_format gmio_stl_get_format_file(const char* filepath);
GMIO_C_LINKAGE_END GMIO_C_LINKAGE_END

View File

@ -28,17 +28,5 @@
#include "../gmio_core/global.h" #include "../gmio_core/global.h"
#ifdef GMIO_LIBSTL_DLL
# ifdef GMIO_LIBSTL_MAKE_DLL
# define GMIO_LIBSTL_EXPORT GMIO_DECL_EXPORT
# else
# define GMIO_LIBSTL_EXPORT GMIO_DECL_IMPORT
# endif /* GMIO_DATAX_LIBSTL_MAKE_DLL */
#else
/*! Expands either to GMIO_DECL_EXPORT or GMIO_DECL_IMPORT when respectively
* compiling/using the DLL */
# define GMIO_LIBSTL_EXPORT
#endif /* GMIO_LIBSTL_DLL */
#endif /* GMIO_STL_GLOBAL_H */ #endif /* GMIO_STL_GLOBAL_H */
/*! @} */ /*! @} */

View File

@ -43,7 +43,7 @@ int gmio_stl_infos_get(
/* Guess format when left unspecified */ /* Guess format when left unspecified */
if (format == GMIO_STL_FORMAT_UNKNOWN) { if (format == GMIO_STL_FORMAT_UNKNOWN) {
format = gmio_stl_get_format(stream); format = gmio_stl_format_probe(stream);
if (format == GMIO_STL_FORMAT_UNKNOWN) { if (format == GMIO_STL_FORMAT_UNKNOWN) {
error = GMIO_STL_ERROR_UNKNOWN_FORMAT; error = GMIO_STL_ERROR_UNKNOWN_FORMAT;
goto label_end; goto label_end;

View File

@ -87,7 +87,7 @@ enum gmio_stl_info_flag
GMIO_STL_INFO_FLAG_ALL = 0xFFFF GMIO_STL_INFO_FLAG_ALL = 0xFFFF
}; };
/*! Optional parameters of gmio_stl_infos_get() */ /*! Options of function gmio_stl_infos_get() */
struct gmio_stl_infos_get_options struct gmio_stl_infos_get_options
{ {
/*! See gmio_core_readwrite_options::stream_memblock */ /*! See gmio_core_readwrite_options::stream_memblock */
@ -97,9 +97,9 @@ struct gmio_stl_infos_get_options
* automatically guessed */ * automatically guessed */
enum gmio_stl_format format_hint; enum gmio_stl_format format_hint;
/*! Restrict gmio_stl_infos_get() to not read further this limit /*! Restrict gmio_stl_infos_get() to not read further this limit(in bytes)
* *
* Not yet supported * \warning Not yet supported
*/ */
gmio_streamsize_t size_limit; gmio_streamsize_t size_limit;
}; };
@ -107,22 +107,30 @@ struct gmio_stl_infos_get_options
GMIO_C_LINKAGE_BEGIN GMIO_C_LINKAGE_BEGIN
/*! Finds informations about STL contents /*! Finds informations about STL contents
*
* \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.
* *
* \return Error code (see gmio_core/error.h and stl_error.h) * \return Error code (see gmio_core/error.h and stl_error.h)
*/ */
GMIO_LIBSTL_EXPORT GMIO_API int gmio_stl_infos_get(
int gmio_stl_infos_get(
struct gmio_stl_infos* infos, struct gmio_stl_infos* infos,
struct gmio_stream* stream, struct gmio_stream* stream,
unsigned flags, /*!< Bitor combination of gmio_stl_info_flag values */ unsigned flags,
const struct gmio_stl_infos_get_options* options); const struct gmio_stl_infos_get_options* options);
/*! Returns the size(in bytes) of next STL ascii solid in \p stream /*! Returns the size(in bytes) of the next STL ascii solid in \p stream
* *
* It is a facade over gmio_stl_infos_get() for gmio_stl_infos::size only * It is a facade over gmio_stl_infos_get() for gmio_stl_infos::size only
*
* 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()
*/ */
GMIO_LIBSTL_EXPORT GMIO_API gmio_streamsize_t gmio_stla_infos_get_streamsize(
gmio_streamsize_t gmio_stla_infos_get_streamsize(
struct gmio_stream* stream, struct gmio_stream* stream,
struct gmio_memblock* stream_memblock); struct gmio_memblock* stream_memblock);

View File

@ -28,7 +28,7 @@ int gmio_stl_read(
struct gmio_stl_mesh_creator* mesh_creator, struct gmio_stl_mesh_creator* mesh_creator,
const struct gmio_stl_read_options* options) const struct gmio_stl_read_options* options)
{ {
const enum gmio_stl_format format = gmio_stl_get_format(stream); const enum gmio_stl_format format = gmio_stl_format_probe(stream);
switch (format) { switch (format) {
case GMIO_STL_FORMAT_ASCII: case GMIO_STL_FORMAT_ASCII:
return gmio_stla_read(stream, mesh_creator, options); return gmio_stla_read(stream, mesh_creator, options);
@ -96,7 +96,7 @@ int gmio_stl_write_file(
static const struct gmio_stlb_header internal_stlb_zero_header = {0}; static const struct gmio_stlb_header internal_stlb_zero_header = {0};
int gmio_stlb_write_header( int gmio_stlb_header_write(
struct gmio_stream *stream, struct gmio_stream *stream,
enum gmio_endianness byte_order, enum gmio_endianness byte_order,
const struct gmio_stlb_header *header, const struct gmio_stlb_header *header,

View File

@ -38,8 +38,7 @@ GMIO_C_LINKAGE_BEGIN
* *
* \return Error code (see gmio_core/error.h and stl_error.h) * \return Error code (see gmio_core/error.h and stl_error.h)
*/ */
GMIO_LIBSTL_EXPORT GMIO_API int gmio_stl_read(
int gmio_stl_read(
struct gmio_stream* stream, struct gmio_stream* stream,
struct gmio_stl_mesh_creator* mesh_creator, struct gmio_stl_mesh_creator* mesh_creator,
const struct gmio_stl_read_options* options); const struct gmio_stl_read_options* options);
@ -49,33 +48,30 @@ int gmio_stl_read(
* This is just a facility function over gmio_stl_read(). The internal stream * 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*)) * object is created to read file at \p filepath (see gmio_stream_stdio(FILE*))
* *
* The file is opened with fopen() so \p filepath shall follow the file name * The file is opened with \c fopen() so \p filepath shall follow the file name
* specifications of the running environment * specifications of the running environment
*/ */
GMIO_LIBSTL_EXPORT GMIO_API int gmio_stl_read_file(
int gmio_stl_read_file(
const char* filepath, const char* filepath,
struct gmio_stl_mesh_creator* mesh_creator, struct gmio_stl_mesh_creator* mesh_creator,
const struct gmio_stl_read_options* options); const struct gmio_stl_read_options* options);
/*! Reads geometry from STL ascii stream /*! Reads mesh from STL ascii stream
* *
* \return Error code (see gmio_core/error.h and stl_error.h) * \return Error code (see gmio_core/error.h and stl_error.h)
*/ */
GMIO_LIBSTL_EXPORT GMIO_API int gmio_stla_read(
int gmio_stla_read(
struct gmio_stream* stream, struct gmio_stream* stream,
struct gmio_stl_mesh_creator* mesh_creator, struct gmio_stl_mesh_creator* mesh_creator,
const struct gmio_stl_read_options* options); const struct gmio_stl_read_options* options);
/*! Reads geometry from STL binary stream /*! Reads mesh from STL binary stream
* *
* \return Error code (see gmio_core/error.h and stl_error.h) * \return Error code (see gmio_core/error.h and stl_error.h)
* \retval GMIO_ERROR_INVALID_MEMBLOCK_SIZE * \retval GMIO_ERROR_INVALID_MEMBLOCK_SIZE
* if <tt>options->stream_memblock.size < GMIO_STLB_MIN_CONTENTS_SIZE</tt> * if <tt>options->stream_memblock.size < GMIO_STLB_MIN_CONTENTS_SIZE</tt>
*/ */
GMIO_LIBSTL_EXPORT GMIO_API int gmio_stlb_read(
int gmio_stlb_read(
struct gmio_stream* stream, struct gmio_stream* stream,
struct gmio_stl_mesh_creator* mesh_creator, struct gmio_stl_mesh_creator* mesh_creator,
enum gmio_endianness byte_order, enum gmio_endianness byte_order,
@ -85,8 +81,7 @@ int gmio_stlb_read(
* *
* \return Error code (see gmio_core/error.h and stl_error.h) * \return Error code (see gmio_core/error.h and stl_error.h)
*/ */
GMIO_LIBSTL_EXPORT GMIO_API int gmio_stl_write(
int gmio_stl_write(
enum gmio_stl_format format, enum gmio_stl_format format,
struct gmio_stream* stream, struct gmio_stream* stream,
const struct gmio_stl_mesh* mesh, const struct gmio_stl_mesh* mesh,
@ -97,13 +92,12 @@ int gmio_stl_write(
* This is just a facility function over gmio_stl_write(). The internal stream * 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*)) * object is created to read file at \p filepath (see gmio_stream_stdio(FILE*))
* *
* The file is opened with fopen() so \p filepath shall follow the file name * The file is opened with \c fopen() so \p filepath shall follow the file name
* specifications of the running environment * specifications of the running environment
* \return Error code (see gmio_core/error.h and stl_error.h) * \return Error code (see gmio_core/error.h and stl_error.h)
*/ */
GMIO_LIBSTL_EXPORT GMIO_API int gmio_stl_write_file(
int gmio_stl_write_file(
enum gmio_stl_format format, enum gmio_stl_format format,
const char* filepath, const char* filepath,
const struct gmio_stl_mesh* mesh, const struct gmio_stl_mesh* mesh,
@ -114,21 +108,14 @@ int gmio_stl_write_file(
* This functions only writes the 80-bytes header array and the count of facets * This functions only writes the 80-bytes header array and the count of facets
* in the mesh(with respect of the specified byte order). * in the mesh(with respect of the specified byte order).
* *
* \p header Can be safely set to \c NULL to generate an array of zeroes
*
* \return Error code (see error.h and stl_error.h) * \return Error code (see error.h and stl_error.h)
*/ */
GMIO_LIBSTL_EXPORT GMIO_API int gmio_stlb_header_write(
int gmio_stlb_write_header(
/*! Output stream where is written the header data */
struct gmio_stream* stream, struct gmio_stream* stream,
/*! Byte order of the output STL data */
enum gmio_endianness byte_order, enum gmio_endianness byte_order,
/*! 80-bytes array of header data, can be safely set to NULL to generate
* an array of zeroes */
const struct gmio_stlb_header* header, const struct gmio_stlb_header* header,
/*! Total count of facets (triangles) in the mesh to be written */
uint32_t facet_count uint32_t facet_count
); );

View File

@ -30,6 +30,7 @@
#include "../gmio_core/task_iface.h" #include "../gmio_core/task_iface.h"
#include "../gmio_core/text_format.h" #include "../gmio_core/text_format.h"
/*! Options of function gmio_stl_read() */
struct gmio_stl_read_options struct gmio_stl_read_options
{ {
/*! Used by the stream to bufferize I/O operations /*! Used by the stream to bufferize I/O operations
@ -50,13 +51,15 @@ struct gmio_stl_read_options
* *
* The resulting stream size is passed to * The resulting stream size is passed to
* gmio_task_iface::func_handle_progress() as the \p max_value argument. * gmio_task_iface::func_handle_progress() as the \p max_value argument.
*
* \sa gmio_stla_infos_get_streamsize()
*/ */
gmio_streamsize_t (*func_stla_get_streamsize)( gmio_streamsize_t (*func_stla_get_streamsize)(
struct gmio_stream* stream, struct gmio_stream* stream,
struct gmio_memblock* stream_memblock); struct gmio_memblock* stream_memblock);
}; };
/*! Options for gmio_stl_write() */ /*! Options of function gmio_stl_write() */
struct gmio_stl_write_options struct gmio_stl_write_options
{ {
/*! See gmio_stl_read_options::stream_memblock */ /*! See gmio_stl_read_options::stream_memblock */

View File

@ -32,7 +32,7 @@
#include <stddef.h> #include <stddef.h>
/*! Informations about the STL stream, used in /*! Informations about the STL stream, used in
* gmio_stl_mesh_creator::begin_solid() */ * gmio_stl_mesh_creator::func_begin_solid() */
struct gmio_stl_mesh_creator_infos struct gmio_stl_mesh_creator_infos
{ {
/*! Format of the input STL mesh */ /*! Format of the input STL mesh */

View File

@ -39,8 +39,7 @@ struct gmio_stl_triangle
GMIO_C_LINKAGE_BEGIN GMIO_C_LINKAGE_BEGIN
/*! Computes the normal vector of triangle \p tri */ /*! Computes the normal vector of triangle \p tri */
GMIO_LIBSTL_EXPORT GMIO_API void gmio_stl_triangle_compute_normal(struct gmio_stl_triangle* tri);
void gmio_stl_triangle_compute_normal(struct gmio_stl_triangle* tri);
GMIO_C_LINKAGE_END GMIO_C_LINKAGE_END

View File

@ -41,8 +41,7 @@ GMIO_C_LINKAGE_BEGIN
* If the length of \p str is less than \c GMIO_STLB_HEADER_SIZE then the * If the length of \p str is less than \c GMIO_STLB_HEADER_SIZE then the
* remaining bytes are filled with zeroes. * remaining bytes are filled with zeroes.
*/ */
GMIO_LIBSTL_EXPORT GMIO_API struct gmio_stlb_header gmio_stlb_header_str(const char* str);
struct gmio_stlb_header gmio_stlb_header_str(const char* str);
/*! Copies \p header into C string \p str /*! Copies \p header into C string \p str
* *
@ -50,8 +49,7 @@ struct gmio_stlb_header gmio_stlb_header_str(const char* str);
* \p str must be at least \c GMIO_STLB_HEADER_SIZE+1 long, a terminating null * \p str must be at least \c GMIO_STLB_HEADER_SIZE+1 long, a terminating null
* character ('\0') is copied at position \c GMIO_STLB_HEADER_SIZE * character ('\0') is copied at position \c GMIO_STLB_HEADER_SIZE
*/ */
GMIO_LIBSTL_EXPORT GMIO_API void gmio_stlb_header_to_printable_str(
void gmio_stlb_header_to_printable_str(
const struct gmio_stlb_header* header, char* str, char replacement); const struct gmio_stlb_header* header, char* str, char replacement);
GMIO_C_LINKAGE_END GMIO_C_LINKAGE_END

View File

@ -45,7 +45,7 @@ class TColgp_SequenceOfXYZ;
* *
* You don't have to use API of this class, it's intended to gmio_stl_mesh() * You don't have to use API of this class, it's intended to gmio_stl_mesh()
*/ */
struct GMIO_LIBSUPPORT_EXPORT gmio_stl_occmesh_iterator struct gmio_stl_occmesh_iterator
{ {
gmio_stl_occmesh_iterator(); gmio_stl_occmesh_iterator();
explicit gmio_stl_occmesh_iterator(const StlMesh_Mesh* mesh); explicit gmio_stl_occmesh_iterator(const StlMesh_Mesh* mesh);
@ -81,7 +81,6 @@ private:
* gmio_stl_write_file(stl_format, filepath, &mesh, &options); * gmio_stl_write_file(stl_format, filepath, &mesh, &options);
* \endcode * \endcode
*/ */
GMIO_LIBSUPPORT_EXPORT
gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_iterator& it); gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_iterator& it);
/*! Returns a gmio_stl_mesh_creator that will build a new domain in a /*! Returns a gmio_stl_mesh_creator that will build a new domain in a
@ -89,7 +88,6 @@ gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_iterator& it);
* *
* The creator's cookie will point \p mesh * The creator's cookie will point \p mesh
*/ */
GMIO_LIBSUPPORT_EXPORT
gmio_stl_mesh_creator gmio_stl_occmesh_creator(StlMesh_Mesh* mesh); gmio_stl_mesh_creator gmio_stl_occmesh_creator(StlMesh_Mesh* mesh);
/*! Same as gmio_stl_occmesh_creator(StlMesh_Mesh*) but takes a handle /*! Same as gmio_stl_occmesh_creator(StlMesh_Mesh*) but takes a handle
@ -97,7 +95,6 @@ gmio_stl_mesh_creator gmio_stl_occmesh_creator(StlMesh_Mesh* mesh);
* The creator's cookie will point to the internal data(ie StlMesh_Mesh*) of * The creator's cookie will point to the internal data(ie StlMesh_Mesh*) of
* handle \p hnd * handle \p hnd
*/ */
GMIO_LIBSUPPORT_EXPORT
gmio_stl_mesh_creator gmio_stl_occmesh_creator(const Handle_StlMesh_Mesh& hnd); gmio_stl_mesh_creator gmio_stl_occmesh_creator(const Handle_StlMesh_Mesh& hnd);

View File

@ -36,7 +36,6 @@ class QIODevice;
QT_END_NAMESPACE QT_END_NAMESPACE
/*! Returns a gmio_stream for \c QIODevice* (cookie will hold \p device) */ /*! Returns a gmio_stream for \c QIODevice* (cookie will hold \p device) */
GMIO_LIBSUPPORT_EXPORT
struct gmio_stream gmio_stream_qiodevice( struct gmio_stream gmio_stream_qiodevice(
#ifndef DOXYGEN #ifndef DOXYGEN
QT_PREPEND_NAMESPACE(QIODevice)* device QT_PREPEND_NAMESPACE(QIODevice)* device

View File

@ -28,15 +28,5 @@
#include "../gmio_core/global.h" #include "../gmio_core/global.h"
#ifdef GMIO_LIBSUPPORT_DLL
# ifdef GMIO_LIBSUPPORT_MAKE_DLL
# define GMIO_LIBSUPPORT_EXPORT GMIO_DECL_EXPORT
# else
# define GMIO_LIBSUPPORT_EXPORT GMIO_DECL_IMPORT
# endif /* GMIO_LIBSUPPORT_MAKE_DLL */
#else
# define GMIO_LIBSUPPORT_EXPORT
#endif /* GMIO_LIBSUPPORT_DLL */
#endif /* GMIO_SUPPORT_GLOBAL_H */ #endif /* GMIO_SUPPORT_GLOBAL_H */
/*! @} */ /*! @} */

View File

@ -30,7 +30,7 @@ const char* test_stl_read_multi_solid();
const char* test_stla_write(); const char* test_stla_write();
const char* test_stlb_read(); const char* test_stlb_read();
const char* test_stlb_write(); const char* test_stlb_write();
const char* test_stlb_write_header(); const char* test_stlb_header_write();
const char* test_stlb_header_str(); const char* test_stlb_header_str();
const char* test_stlb_header_to_printable_str(); const char* test_stlb_header_to_printable_str();
@ -63,7 +63,7 @@ const char* all_tests()
UTEST_RUN(test_stla_write); UTEST_RUN(test_stla_write);
UTEST_RUN(test_stlb_read); UTEST_RUN(test_stlb_read);
UTEST_RUN(test_stlb_write); UTEST_RUN(test_stlb_write);
UTEST_RUN(test_stlb_write_header); UTEST_RUN(test_stlb_header_write);
UTEST_RUN(test_stlb_header_str); UTEST_RUN(test_stlb_header_str);
UTEST_RUN(test_stlb_header_to_printable_str); UTEST_RUN(test_stlb_header_to_printable_str);

View File

@ -64,7 +64,7 @@ const char* test_stl_read()
while (testcase != stl_read_testcases_ptr_end()) { while (testcase != stl_read_testcases_ptr_end()) {
const enum gmio_stl_format format = const enum gmio_stl_format format =
gmio_stl_get_format_file(testcase->filepath); gmio_stl_format_probe_file(testcase->filepath);
const int err = const int err =
gmio_stl_read_file(testcase->filepath, &mesh_creator, NULL); gmio_stl_read_file(testcase->filepath, &mesh_creator, NULL);
@ -128,7 +128,7 @@ const char* test_stlb_read()
return NULL; return NULL;
} }
const char* test_stlb_write_header() const char* test_stlb_header_write()
{ {
const char* filepath = "temp/solid.stlb"; const char* filepath = "temp/solid.stlb";
struct gmio_stlb_header header = {0}; struct gmio_stlb_header header = {0};
@ -141,7 +141,7 @@ const char* test_stlb_write_header()
memcpy(&header, memcpy(&header,
header_str, header_str,
GMIO_MIN(GMIO_STLB_HEADER_SIZE, strlen(header_str))); GMIO_MIN(GMIO_STLB_HEADER_SIZE, strlen(header_str)));
error = gmio_stlb_write_header( error = gmio_stlb_header_write(
&stream, GMIO_ENDIANNESS_LITTLE, &header, 0); &stream, GMIO_ENDIANNESS_LITTLE, &header, 0);
fclose(outfile); fclose(outfile);
UTEST_COMPARE_INT(GMIO_ERROR_OK, error); UTEST_COMPARE_INT(GMIO_ERROR_OK, error);
@ -346,7 +346,7 @@ void generate_stlb_tests_models()
{ {
FILE* outfile = fopen(filepath_stlb_empty, "wb"); FILE* outfile = fopen(filepath_stlb_empty, "wb");
struct gmio_stream stream = gmio_stream_stdio(outfile); struct gmio_stream stream = gmio_stream_stdio(outfile);
gmio_stlb_write_header(&stream, GMIO_ENDIANNESS_LITTLE, NULL, 0); gmio_stlb_header_write(&stream, GMIO_ENDIANNESS_LITTLE, NULL, 0);
fclose(outfile); fclose(outfile);
} }
@ -400,7 +400,7 @@ void generate_stlb_tests_models()
FILE* outfile = fopen(filepath_stlb_header_nofacets, "wb"); FILE* outfile = fopen(filepath_stlb_header_nofacets, "wb");
struct gmio_stream ostream = gmio_stream_stdio(outfile); struct gmio_stream ostream = gmio_stream_stdio(outfile);
const struct gmio_stlb_header header = {0}; const struct gmio_stlb_header header = {0};
gmio_stlb_write_header(&ostream, GMIO_ENDIANNESS_LITTLE, &header, 100); gmio_stlb_header_write(&ostream, GMIO_ENDIANNESS_LITTLE, &header, 100);
fclose(outfile); fclose(outfile);
} }
} }