diff --git a/src/gmio_stl/stla_stats.c b/src/gmio_stl/stla_stats.c new file mode 100644 index 0000000..3e90481 --- /dev/null +++ b/src/gmio_stl/stla_stats.c @@ -0,0 +1,46 @@ +/**************************************************************************** +** 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". +****************************************************************************/ + +#include "stla_stats.h" + +#include "../gmio_core/error.h" +#include "../gmio_core/internal/helper_stream.h" +#include "../gmio_core/internal/helper_transfer.h" +#include "../gmio_stl/internal/stl_rw_common.h" + +gmio_stla_stats_t gmio_stla_stats_get( + gmio_transfer_t* trsf, unsigned stat_flags, size_t size_limit) +{ + gmio_stla_stats_t stats = {0}; + void* mblock_ptr = trsf != NULL ? trsf->memblock.ptr : NULL; + const size_t mblock_size = trsf != NULL ? trsf->memblock.size : NULL; + int err = GMIO_ERROR_OK; + + /* Check validity of input transfer object */ + if (!gmio_check_transfer(&err, trsf)) + return stats; + + /*if (stat_flags != 0) { + while (gmio_no_error(err)) { + const size_t read_size = + gmio_stream_read(stream, buffer_ptr, 1, buffer_size); + const int stream_err = gmio_stream_error(trsf->stream); + + err = stream_err; + } + }*/ + + return stats; +} diff --git a/src/gmio_stl/stla_stats.h b/src/gmio_stl/stla_stats.h new file mode 100644 index 0000000..a4b72c6 --- /dev/null +++ b/src/gmio_stl/stla_stats.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** 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 stla_stats.h + * TODO: description + * + * \addtogroup gmio_stl + * @{ + */ + +#ifndef GMIO_STLA_STATS_H +#define GMIO_STLA_STATS_H + +#include "stl_global.h" + +#include "../gmio_core/transfer.h" +#include "../gmio_core/internal/helper_stream.h" + +#include + +/*! Statistics of some STL ascii solid */ +struct gmio_stla_stats +{ + /*! Count of facets(triangles) */ + uint32_t facet_count; + + /*! Average facet size in bytes(what's in between facet ... endfacet + * including the tags) */ + size_t average_facet_size; + + /*! Size of the STL ascii contents in bytes, including the "endsolid" tag */ + size_t size; +}; +typedef struct gmio_stla_stats gmio_stla_stats_t; + +/*! Flags(OR-combinations) for each STL ascii statistic */ +enum gmio_stla_stat_flag +{ + GMIO_STLA_STAT_FLAG_FACET_COUNT = 0x01, + GMIO_STLA_STAT_FLAG_AVERAGE_FACET_SIZE = 0x02, + GMIO_STLA_STAT_FLAG_SIZE = 0x04, + GMIO_STLA_STAT_FLAG_ALL = 0xFF +}; +typedef enum gmio_stla_stat gmio_stla_stat_t; + +GMIO_C_LINKAGE_BEGIN + +GMIO_LIBSTL_EXPORT +gmio_stla_stats_t gmio_stla_stats_get( + gmio_transfer_t* trsf, unsigned stat_flags, size_t size_limit); + +GMIO_C_LINKAGE_END + +#endif /* GMIO_STLA_STATS_H */ +/*! @} */