2015-09-25 22:26:08 +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".
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-12-10 01:51:03 +08:00
|
|
|
#include "stl_infos.h"
|
2015-09-25 22:26:08 +08:00
|
|
|
|
|
|
|
#include "../gmio_core/error.h"
|
2015-12-17 19:03:45 +08:00
|
|
|
#include "../gmio_core/internal/helper_memblock.h"
|
2015-12-18 22:30:50 +08:00
|
|
|
#include "../gmio_core/internal/helper_stream.h"
|
2015-12-17 19:03:45 +08:00
|
|
|
#include "stl_error.h"
|
|
|
|
#include "internal/stla_infos_get.h"
|
|
|
|
#include "internal/stlb_infos_get.h"
|
2015-12-04 01:00:25 +08:00
|
|
|
|
2015-12-10 01:51:03 +08:00
|
|
|
int gmio_stl_infos_get(
|
|
|
|
struct gmio_stl_infos_get_args* args,
|
2015-12-17 19:03:45 +08:00
|
|
|
enum gmio_stl_format format,
|
2015-12-10 01:51:03 +08:00
|
|
|
unsigned flags)
|
2015-09-25 22:26:08 +08:00
|
|
|
{
|
2015-12-10 01:51:03 +08:00
|
|
|
int error = GMIO_ERROR_OK;
|
2015-12-17 19:03:45 +08:00
|
|
|
struct gmio_memblock_helper mblock_helper =
|
|
|
|
gmio_memblock_helper(&args->stream_memblock);
|
2015-12-18 22:30:50 +08:00
|
|
|
const struct gmio_streampos begin_streampos =
|
|
|
|
gmio_streampos(&args->stream, NULL);
|
2015-12-17 19:03:45 +08:00
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case GMIO_STL_FORMAT_ASCII:
|
|
|
|
error = gmio_stla_infos_get(args, flags);
|
|
|
|
break;
|
|
|
|
case GMIO_STL_FORMAT_BINARY_LE:
|
|
|
|
error = gmio_stlb_infos_get(args, GMIO_ENDIANNESS_LITTLE, flags);
|
|
|
|
break;
|
|
|
|
case GMIO_STL_FORMAT_BINARY_BE:
|
|
|
|
error = gmio_stlb_infos_get(args, GMIO_ENDIANNESS_BIG, flags);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = GMIO_STL_ERROR_UNKNOWN_FORMAT;
|
|
|
|
break;
|
2015-12-04 01:00:25 +08:00
|
|
|
}
|
2015-12-17 19:03:45 +08:00
|
|
|
gmio_memblock_helper_release(&mblock_helper);
|
2015-12-18 22:30:50 +08:00
|
|
|
gmio_stream_set_pos(&args->stream, &begin_streampos);
|
2015-09-25 22:26:08 +08:00
|
|
|
|
2015-12-17 19:03:45 +08:00
|
|
|
return error;
|
2015-09-25 22:26:08 +08:00
|
|
|
}
|