Rename FougDataX to gmio (GeoMetry Input/Output)

This commit is contained in:
Hugues Delorme 2014-03-28 16:33:35 +01:00
parent db04be340a
commit 085644a5e5
68 changed files with 1183 additions and 1190 deletions

View File

@ -4,17 +4,17 @@ include(CheckIncludeFiles)
include(CheckFunctionExists) include(CheckFunctionExists)
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
project(fougdatax C) project(gmio C)
#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) #set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Options # Options
option(BUILD_SHARED_LIBS "Build shared libraries (DLL)" ON) option(BUILD_SHARED_LIBS "Build shared libraries (DLL)" ON)
option(BUILD_STRICT_C90 "Build with strict conformance to C90 standard, if disabled FougDataX can use C99 features (eg. fabsf(), strtof(), ...)" ON) option(BUILD_STRICT_C90 "Build with strict conformance to C90 standard, if disabled, C99 features can be used (eg. fabsf(), strtof(), ...)" ON)
option(BUILD_WITH_LIBSTL "Build the libSTL module" ON) option(BUILD_WITH_LIBSTL "Build the libSTL module" ON)
# Add core source files # Add core source files
file(GLOB ALL_SRC_FILES src/datax_core/* src/datax_core/internal/*) file(GLOB ALL_SRC_FILES src/gmio_core/* src/gmio_core/internal/*)
set(ALL_SRC_FILES ${ALL_SRC_FILES}) set(ALL_SRC_FILES ${ALL_SRC_FILES})
# Have <stdint.h> ? # Have <stdint.h> ?
@ -39,7 +39,7 @@ elseif(MSVC)
FOUG_HAVE_MSVC_BUILTIN_BSWAP_FUNC) FOUG_HAVE_MSVC_BUILTIN_BSWAP_FUNC)
endif() endif()
configure_file(src/datax_core/config.h.cmake config.h @ONLY) configure_file(src/gmio_core/config.h.cmake config.h @ONLY)
include_directories(${CMAKE_BINARY_DIR}) # For generated "config.h" include_directories(${CMAKE_BINARY_DIR}) # For generated "config.h"
# Specific flags for GCC # Specific flags for GCC
@ -65,40 +65,40 @@ if(BUILD_SHARED_LIBS)
endif() endif()
# Declare installs # Declare installs
install(FILES ${CMAKE_BINARY_DIR}/config.h DESTINATION include/datax_core) install(FILES ${CMAKE_BINARY_DIR}/config.h DESTINATION include/gmio_core)
file(GLOB C_CORE_HEADERS src/datax_core/*.h) file(GLOB C_CORE_HEADERS src/gmio_core/*.h)
install(FILES ${C_CORE_HEADERS} DESTINATION include/datax_core) install(FILES ${C_CORE_HEADERS} DESTINATION include/gmio_core)
# Module libSTL # Module libSTL
if(BUILD_WITH_LIBSTL) if(BUILD_WITH_LIBSTL)
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
add_definitions(-DFOUG_DATAX_LIBSTL_DLL add_definitions(-DGMIO_LIBSTL_DLL
-DFOUG_DATAX_LIBSTL_MAKE_DLL) -DGMIO_LIBSTL_MAKE_DLL)
endif() endif()
file(GLOB ALL_LIBSTL_SRC_FILES src/datax_stl/* src/datax_stl/internal/*) file(GLOB ALL_LIBSTL_SRC_FILES src/gmio_stl/* src/gmio_stl/internal/*)
set(ALL_SRC_FILES ${ALL_SRC_FILES} ${ALL_LIBSTL_SRC_FILES}) set(ALL_SRC_FILES ${ALL_SRC_FILES} ${ALL_LIBSTL_SRC_FILES})
endif() endif()
file(GLOB C_LIBSTL_HEADERS src/datax_stl/*.h) file(GLOB C_LIBSTL_HEADERS src/gmio_stl/*.h)
install(FILES ${C_LIBSTL_HEADERS} DESTINATION include/datax_stl) install(FILES ${C_LIBSTL_HEADERS} DESTINATION include/gmio_stl)
# Common for support modules # Common for support modules
install(FILES src/datax_support/support_global.h DESTINATION include/datax_support) install(FILES src/gmio_support/support_global.h DESTINATION include/gmio_support)
# Qt support # Qt support
install(FILES src/datax_support/qt_stream.h DESTINATION include/datax_support) install(FILES src/gmio_support/qt_stream.h DESTINATION include/gmio_support)
install(FILES src/datax_support/qt_stream.cpp DESTINATION src/datax_support) install(FILES src/gmio_support/qt_stream.cpp DESTINATION src/gmio_support)
# OpenCASCADE support # OpenCASCADE support
install(FILES src/datax_support/occ_libstl.h DESTINATION include/datax_support) install(FILES src/gmio_support/occ_libstl.h DESTINATION include/gmio_support)
install(FILES src/datax_support/occ_libstl.cpp DESTINATION src/datax_support) install(FILES src/gmio_support/occ_libstl.cpp DESTINATION src/gmio_support)
# Installs for target # Installs for target
add_library(fougdatax ${ALL_SRC_FILES}) add_library(gmio ${ALL_SRC_FILES})
install(TARGETS fougdatax install(TARGETS gmio
RUNTIME DESTINATION lib RUNTIME DESTINATION lib
LIBRARY DESTINATION lib LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib) ARCHIVE DESTINATION lib)
@ -118,8 +118,8 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
add_executable(test_internal EXCLUDE_FROM_ALL tests/stream_buffer.c add_executable(test_internal EXCLUDE_FROM_ALL tests/stream_buffer.c
tests/test_internal.c tests/test_internal.c
src/datax_core/stream.c src/gmio_core/stream.c
src/datax_core/internal/ascii_parse.c) src/gmio_core/internal/ascii_parse.c)
add_executable(test_platform EXCLUDE_FROM_ALL tests/test_platform.c) add_executable(test_platform EXCLUDE_FROM_ALL tests/test_platform.c)
add_test(test_internal test_internal) add_test(test_internal test_internal)
add_test(test_platform test_platform) add_test(test_platform test_platform)

View File

@ -26,7 +26,7 @@ DOXYFILE_ENCODING = UTF-8
# identify the project. Note that if you do not use Doxywizard you need # identify the project. Note that if you do not use Doxywizard you need
# to put quotes around the project name if it contains spaces. # to put quotes around the project name if it contains spaces.
PROJECT_NAME = FougDataX PROJECT_NAME = gmio (GeoMetry Input/Output) Library
# The PROJECT_NUMBER tag can be used to enter a project or revision number. # The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
@ -38,7 +38,7 @@ PROJECT_NUMBER = 0.1.0
# for a project that appears at the top of each page and should give viewer # for a project that appears at the top of each page and should give viewer
# a quick idea about the purpose of the project. Keep the description short. # a quick idea about the purpose of the project. Keep the description short.
PROJECT_BRIEF = "Fast, portable Data eXchange" PROJECT_BRIEF = "Fast, portable geometry input/output"
# With the PROJECT_LOGO tag one can specify an logo or icon that is # With the PROJECT_LOGO tag one can specify an logo or icon that is
# included in the documentation. The maximum height of the logo should not # included in the documentation. The maximum height of the logo should not
@ -128,7 +128,7 @@ FULL_PATH_NAMES = YES
# If left blank the directory from which doxygen is run is used as the # If left blank the directory from which doxygen is run is used as the
# path to strip. # path to strip.
STRIP_FROM_PATH = /home/cerf/dev/projects/fougue/foug_datax/src STRIP_FROM_PATH = /home/cerf/dev/projects/fougue/gmio/src
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
# the path mentioned in the documentation of a class, which tells # the path mentioned in the documentation of a class, which tells
@ -1502,12 +1502,12 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator # undefined via #undef or recursively expanded use the := operator
# instead of the = operator. # instead of the = operator.
PREDEFINED = FOUG_LIB_EXPORT= \ PREDEFINED = GMIO_LIB_EXPORT= \
FOUG_LIBSUPPORT_EXPORT= \ GMIO_LIBSUPPORT_EXPORT= \
FOUG_DATAX_LIBSTL_EXPORT= \ GMIO_LIBSTL_EXPORT= \
FOUG_C_LINKAGE_BEGIN= \ GMIO_C_LINKAGE_BEGIN= \
FOUG_C_LINKAGE_END= \ GMIO_C_LINKAGE_END= \
FOUG_HAVE_STDINT_H=1 GMIO_HAVE_STDINT_H=1
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded. # this tag can be used to specify a list of macro names that should be expanded.
@ -1544,7 +1544,7 @@ TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create # When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads. # a tag file that is based on the input files it reads.
GENERATE_TAGFILE = fougdatax.tags GENERATE_TAGFILE = gmio.tags
# If the ALLEXTERNALS tag is set to YES all external classes will be listed # If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes # in the class index. If set to NO only the inherited external classes

View File

@ -3,41 +3,35 @@
\mainpage \mainpage
\section intro_sec INTRODUCTION \section intro_sec Introduction
This is FougDataX v0.1 This is gmio library v0.1
Check source code at : https://github.com/fougsys/fougdatax Check source code at : https://github.com/fougsys/gmio
FougDataX is a fast and portable C library for data exchange. gmio is a fast and portable C library for data exchange.
\section build_sec BUILDING FougDataX \section build_sec BUILDING gmio library
FougDataX can be built with qmake or cmake. The gmio library can be built with qmake or cmake.
<b>With qmake :</b> <b>With qmake :</b>
\code \code
.../fougdatax$ cd qmake .../gmio$ cd qmake
.../fougdatax$ qmake PREFIX_DIR=../gcc-linux64 .../gmio$ qmake PREFIX_DIR=../gcc-linux64
.../fougdatax$ make all .../gmio$ make all
.../fougdatax$ make install .../gmio$ make install
\endcode \endcode
If you want static libraries (instead of DLLs) just add "CONFIG+=staticlib" to the qmake command : If you want static libraries (instead of DLLs) just add "CONFIG+=staticlib" to the qmake command :
\code \code
.../fougdatax$ qmake PREFIX_DIR=../gcc-linux64 CONFIG+=staticlib .../gmio$ qmake PREFIX_DIR=../gcc-linux64 CONFIG+=staticlib
\endcode \endcode
If you want Qt and OpenCascade support inside the library use this qmake command : Note that on Windows, qmake complains about deprecated support of backslash '\' characters.
\code So you may have to escape backslashes like C:\\path\\to\\opencascade or simply use Unix separators
.../fougdatax$ qmake PREFIX_DIR=../gcc-linux64 "DATAX+=qt_support occ_support" CASCADE_ROOT=/path/to/occ instead C:/path/to/opencascade
\endcode
Note that on Windows, qmake complains about deprecated support of
backslash '\' characters.
So you may have to escape backslashes like C:\\path\\to\\opencascade
or simply use Unix separators instead C:/path/to/opencascade
<b>With CMake :</b> <b>With CMake :</b>
@ -46,16 +40,16 @@ or simply use Unix separators instead C:/path/to/opencascade
\section reportbug_sec HOW TO REPORT A BUG \section reportbug_sec HOW TO REPORT A BUG
If you think you have found a bug in FougDataX, we would like to hear If you think you have found a bug in gmio, we would like to hear
about it so that we can fix it. The FougTools bug tracking system is about it so that we can fix it. The gmio bug tracking system is
open to the public at https://github.com/fougsys/fougdatax/issues. open to the public at https://github.com/fougsys/gmio/issues.
Before reporting a bug, please use the bug-tracker's search functions Before reporting a bug, please use the bug-tracker's search functions
to see if the issue is already known. to see if the issue is already known.
Always include the following information in your bug report: the name Always include the following information in your bug report: the name
and version number of your compiler; the name and version number of and version number of your compiler; the name and version number of
your operating system; the version of FougDataX you are using, and your operating system; the version of gmio you are using, and
what configure options it was compiled with. what configure options it was compiled with.
If the problem you are reporting is only visible at run-time, try to If the problem you are reporting is only visible at run-time, try to

View File

@ -1,24 +1,24 @@
#ifndef FOUG_CONFIG_H #ifndef GMIO_CONFIG_H
#define FOUG_CONFIG_H #define GMIO_CONFIG_H
#ifdef __GNUC__ #ifdef __GNUC__
# ifndef FOUG_HAVE_GCC_BUILTIN_BSWAP_FUNC # ifndef GMIO_HAVE_GCC_BUILTIN_BSWAP_FUNC
# define FOUG_HAVE_GCC_BUILTIN_BSWAP_FUNC # define GMIO_HAVE_GCC_BUILTIN_BSWAP_FUNC
# endif # endif
# ifndef FOUG_HAVE_STDINT_H # ifndef GMIO_HAVE_STDINT_H
# define FOUG_HAVE_STDINT_H # define GMIO_HAVE_STDINT_H
# endif # endif
#endif /* __GNUC__ */ #endif /* __GNUC__ */
#ifdef _MSC_VER #ifdef _MSC_VER
# ifndef FOUG_HAVE_MSVC_BUILTIN_BSWAP_FUNC # ifndef GMIO_HAVE_MSVC_BUILTIN_BSWAP_FUNC
# define FOUG_HAVE_MSVC_BUILTIN_BSWAP_FUNC # define GMIO_HAVE_MSVC_BUILTIN_BSWAP_FUNC
# endif # endif
# if !defined(FOUG_HAVE_STDINT_H) && _MSV_VER >= 1600 /* Visual C++ 2010 */ # if !defined(GMIO_HAVE_STDINT_H) && _MSV_VER >= 1600 /* Visual C++ 2010 */
# define FOUG_HAVE_STDINT_H # define GMIO_HAVE_STDINT_H
# endif # endif
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#endif /* FOUG_CONFIG_H */ #endif /* GMIO_CONFIG_H */

View File

@ -1,122 +0,0 @@
isEmpty(PREFIX_DIR) {
PREFIX_DIR = ..
}
include(config.pri)
message($$PREFIX_DIR)
TEMPLATE = lib
TARGET = fougdatax$$TARGET_SUFFIX
DESTDIR = $$PREFIX_DIR/lib
QT =
DATAX += stl
dll:DEFINES += FOUG_LIB_DLL \
FOUG_LIB_MAKE_DLL
INCLUDEPATH += $$PWD/../src
#*g++*:QMAKE_CXXFLAGS_RELEASE -= -O2
#*g++*:QMAKE_CXXFLAGS_RELEASE += -O3
HEADERS += \
config.h \
../src/datax_core/endian.h \
../src/datax_core/error.h \
../src/datax_core/global.h \
../src/datax_core/memory.h \
../src/datax_core/stream.h \
../src/datax_core/task_control.h \
../src/datax_core/transfer.h \
\
../src/datax_core/internal/convert.h \
../src/datax_core/internal/ascii_parse.h \
../src/datax_core/internal/byte_swap.h \
../src/datax_core/internal/byte_codec.h
SOURCES += \
../src/datax_core/endian.c \
../src/datax_core/error.c \
../src/datax_core/stream.c \
../src/datax_core/task_control.c \
\
../src/datax_core/internal/convert.c \
../src/datax_core/internal/ascii_parse.c
*-g++*:QMAKE_CFLAGS += -ansi -pedantic-errors
*-msvc*:QMAKE_CFLAGS += -TC
global_inc.path = $$PREFIX_DIR/include/datax
global_inc.files = config.h ../src/*.h
INSTALLS += global_inc
# libSTL
contains(DATAX, stl) {
dll:DEFINES += FOUG_DATAX_LIBSTL_DLL \
FOUG_DATAX_LIBSTL_MAKE_DLL
#DEFINES += FOUG_STLB_READWRITE_ALIGNSAFE
HEADERS += \
../src/datax_stl/stl_error.h \
../src/datax_stl/stl_format.h \
../src/datax_stl/stl_geom.h \
../src/datax_stl/stl_geom_creator.h \
../src/datax_stl/stl_global.h \
../src/datax_stl/stl_io.h \
../src/datax_stl/stl_triangle.h \
\
../src/datax_stl/internal/stlb_byte_swap.h \
../src/datax_stl/internal/stl_rw_common.h
SOURCES += \
../src/datax_stl/stl_format.c \
../src/datax_stl/stla_read.c \
../src/datax_stl/stla_write.c \
../src/datax_stl/stlb_read.c \
../src/datax_stl/stlb_write.c \
\
../src/datax_stl/internal/stlb_byte_swap.c \
../src/datax_stl/internal/stl_rw_common.c
libstl_inc.path = $$PREFIX_DIR/include/datax_stl
libstl_inc.files = ../src/datax_stl/*.h
INSTALLS += libstl_inc
} # contains(DATAX, stl)
# libSupport
HAS_SUPPORT = $$find(DATAX, support)
!isEmpty(HAS_SUPPORT) {
HEADERS += ../src/support/support_global.h
dll:DEFINES += FOUG_LIBSUPPORT_DLL \
FOUG_LIBSUPPORT_MAKE_DLL
support_inc.path = $$PREFIX_DIR/include/datax/support
support_inc.files = ../src/datax_support/support_global.h
INSTALLS += support_inc
} # !isEmpty(HAS_SUPPORT)
# qt_support
contains(DATAX, qt_support) {
qt_support_inc.path = $$PREFIX_DIR/include/datax_support
qt_support_inc.files = ../src/datax_support/qt_stream.h
INSTALLS += qt_support_inc
} # contains(DATAX, qt_support)
# occ_support
contains(DATAX, occ_support) {
occ_support_inc.path = $$PREFIX_DIR/include/datax_support
occ_support_inc.files = ../src/datax_support/occ_libstl.h
INSTALLS += occ_support_inc
} # contains(DATAX, occ_support)
#VER_MAJ = 0
#VER_MIN = 1
#VER_PAT = 0
OTHER_FILES += \
../doc/main_page.cpp \
../doc/Doxyfile \
\
../src/datax_core/config.h.cmake

121
qmake/gmio.pro Normal file
View File

@ -0,0 +1,121 @@
isEmpty(PREFIX_DIR) {
PREFIX_DIR = ..
}
include(config.pri)
message($$PREFIX_DIR)
TEMPLATE = lib
TARGET = gmio$$TARGET_SUFFIX
DESTDIR = $$PREFIX_DIR/lib
QT =
GMIO += stl
dll:DEFINES += GMIO_LIB_DLL \
GMIO_LIB_MAKE_DLL
INCLUDEPATH += $$PWD/../src
#*g++*:QMAKE_CXXFLAGS_RELEASE -= -O2
#*g++*:QMAKE_CXXFLAGS_RELEASE += -O3
HEADERS += \
config.h \
../src/gmio_core/endian.h \
../src/gmio_core/error.h \
../src/gmio_core/global.h \
../src/gmio_core/memory.h \
../src/gmio_core/stream.h \
../src/gmio_core/task_control.h \
../src/gmio_core/transfer.h \
\
../src/gmio_core/internal/convert.h \
../src/gmio_core/internal/ascii_parse.h \
../src/gmio_core/internal/byte_swap.h \
../src/gmio_core/internal/byte_codec.h
SOURCES += \
../src/gmio_core/endian.c \
../src/gmio_core/error.c \
../src/gmio_core/stream.c \
../src/gmio_core/task_control.c \
\
../src/gmio_core/internal/convert.c \
../src/gmio_core/internal/ascii_parse.c
*-g++*:QMAKE_CFLAGS += -ansi -pedantic-errors
*-msvc*:QMAKE_CFLAGS += -TC
global_inc.path = $$PREFIX_DIR/include/gmio_core
global_inc.files = config.h ../src/*.h
INSTALLS += global_inc
# libSTL
contains(GMIO, stl) {
dll:DEFINES += GMIO_LIBSTL_DLL \
GMIO_LIBSTL_MAKE_DLL
HEADERS += \
../src/gmio_stl/stl_error.h \
../src/gmio_stl/stl_format.h \
../src/gmio_stl/stl_geom.h \
../src/gmio_stl/stl_geom_creator.h \
../src/gmio_stl/stl_global.h \
../src/gmio_stl/stl_io.h \
../src/gmio_stl/stl_triangle.h \
\
../src/gmio_stl/internal/stlb_byte_swap.h \
../src/gmio_stl/internal/stl_rw_common.h
SOURCES += \
../src/gmio_stl/stl_format.c \
../src/gmio_stl/stla_read.c \
../src/gmio_stl/stla_write.c \
../src/gmio_stl/stlb_read.c \
../src/gmio_stl/stlb_write.c \
\
../src/gmio_stl/internal/stlb_byte_swap.c \
../src/gmio_stl/internal/stl_rw_common.c
libstl_inc.path = $$PREFIX_DIR/include/gmio_stl
libstl_inc.files = ../src/gmio_stl/*.h
INSTALLS += libstl_inc
} # contains(GMIO, stl)
# libSupport
HAS_SUPPORT = $$find(GMIO, support)
!isEmpty(HAS_SUPPORT) {
HEADERS += ../src/support/support_global.h
dll:DEFINES += GMIO_LIBSUPPORT_DLL \
GMIO_LIBSUPPORT_MAKE_DLL
support_inc.path = $$PREFIX_DIR/include/gmio/support
support_inc.files = ../src/gmio_support/support_global.h
INSTALLS += support_inc
} # !isEmpty(HAS_SUPPORT)
# qt_support
contains(GMIO, qt_support) {
qt_support_inc.path = $$PREFIX_DIR/include/gmio_support
qt_support_inc.files = ../src/gmio_support/qt_stream.h
INSTALLS += qt_support_inc
} # contains(GMIO, qt_support)
# occ_support
contains(GMIO, occ_support) {
occ_support_inc.path = $$PREFIX_DIR/include/gmio_support
occ_support_inc.files = ../src/gmio_support/occ_libstl.h
INSTALLS += occ_support_inc
} # contains(GMIO, occ_support)
#VER_MAJ = 0
#VER_MIN = 1
#VER_PAT = 0
OTHER_FILES += \
../doc/main_page.cpp \
../doc/Doxyfile \
\
../src/gmio_core/config.h.cmake

View File

@ -1,24 +0,0 @@
#ifndef FOUG_C_ENDIAN_H
#define FOUG_C_ENDIAN_H
#include "global.h"
FOUG_C_LINKAGE_BEGIN
/*! This enum identifies endian representations of numbers */
enum foug_endianness
{
FOUG_LITTLE_ENDIAN,
FOUG_BIG_ENDIAN,
FOUG_MIDDLE_ENDIAN,
FOUG_OTHER_ENDIAN
};
typedef enum foug_endianness foug_endianness_t;
/*! Returns endianness (byte order) of the host's CPU architecture */
FOUG_LIB_EXPORT foug_endianness_t foug_host_endianness();
FOUG_C_LINKAGE_END
#endif /* FOUG_ENDIAN_H */

View File

@ -1,11 +0,0 @@
#include "error.h"
foug_bool_t foug_datax_no_error(int code)
{
return code == FOUG_DATAX_NO_ERROR;
}
foug_bool_t foug_datax_error(int code)
{
return code != FOUG_DATAX_NO_ERROR;
}

View File

@ -1,40 +0,0 @@
#ifndef FOUG_DATAX_C_ERROR_H
#define FOUG_DATAX_C_ERROR_H
#include "global.h"
FOUG_C_LINKAGE_BEGIN
/*! This enum defines common errors */
enum foug_datax_error
{
/*! No error occurred, success */
FOUG_DATAX_NO_ERROR = 0,
/*! Pointer on argument foug_transfer_t is NULL */
FOUG_DATAX_NULL_TRANSFER_ERROR = -1,
/*! Pointer on argument buffer is NULL */
FOUG_DATAX_NULL_BUFFER_ERROR = -2,
/*! Argument buffer's size is too small */
FOUG_DATAX_INVALID_BUFFER_SIZE_ERROR = -3,
/*! An error occurred with the argument foug_stream_t (check foug_stream_error()) */
FOUG_DATAX_STREAM_ERROR = -4,
/*! Operation was stopped by user (foug_task_control::handle_progress_func() returned FOUG_FALSE) */
FOUG_DATAX_TASK_STOPPED_ERROR = -5
};
typedef enum foug_datax_error foug_datax_error_t;
/*! Returns true if \p code == FOUG_DATAX_NO_ERROR */
FOUG_LIB_EXPORT foug_bool_t foug_datax_no_error(int code);
/*! Returns true if \p code != FOUG_DATAX_NO_ERROR */
FOUG_LIB_EXPORT foug_bool_t foug_datax_error(int code);
FOUG_C_LINKAGE_END
#endif /* FOUG_DATAX_C_ERROR_H */

View File

@ -1,33 +0,0 @@
#ifndef FOUG_INTERNAL_ASCII_PARSE_H
#define FOUG_INTERNAL_ASCII_PARSE_H
#include "../global.h"
#include "../stream.h"
typedef struct
{
char* ptr; /*!< Buffer contents */
size_t len; /*!< Size(length) of current contents */
size_t max_len; /*!< Maximum contents size(length) */
} foug_ascii_string_buffer_t;
typedef struct
{
foug_stream_t* stream;
foug_ascii_string_buffer_t buffer;
size_t buffer_pos; /*!< Position indicator in buffer */
void* cookie;
void (*stream_read_hook)(void*, const foug_ascii_string_buffer_t*);
} foug_ascii_stream_fwd_iterator_t;
void foug_ascii_stream_fwd_iterator_init(foug_ascii_stream_fwd_iterator_t* it);
char* foug_current_char(const foug_ascii_stream_fwd_iterator_t* it);
void foug_skip_spaces(foug_ascii_stream_fwd_iterator_t* it);
int foug_eat_word(foug_ascii_stream_fwd_iterator_t* it, foug_ascii_string_buffer_t* buffer);
int foug_get_real32(const char* str, foug_real32_t* value_ptr);
char* foug_next_char(foug_ascii_stream_fwd_iterator_t* it);
foug_bool_t foug_checked_next_chars(foug_ascii_stream_fwd_iterator_t* it, const char* str);
#endif /* FOUG_INTERNAL_ASCII_PARSE_H */

View File

@ -1,15 +0,0 @@
#include "convert.h"
foug_real32_t foug_convert_real32(uint32_t val)
{
foug_uint32_float_t conv;
conv.as_uint32 = val;
return conv.as_float;
}
uint32_t foug_convert_uint32(foug_real32_t val)
{
foug_uint32_float_t conv;
conv.as_float = val;
return conv.as_uint32;
}

View File

@ -1,15 +0,0 @@
#ifndef FOUG_INTERNAL_CONVERT_H
#define FOUG_INTERNAL_CONVERT_H
#include "../global.h"
typedef union
{
uint32_t as_uint32;
float as_float;
} foug_uint32_float_t;
foug_real32_t foug_convert_real32(uint32_t val);
uint32_t foug_convert_uint32(foug_real32_t val);
#endif /* FOUG_INTERNAL_CONVERT_H */

View File

@ -1,45 +0,0 @@
#include "stl_rw_common.h"
#include "../../datax_core/error.h"
#include "../stl_error.h"
foug_bool_t foug_check_transfer(int *error, const foug_transfer_t* trsf)
{
if (trsf == NULL) {
*error = FOUG_DATAX_NULL_TRANSFER_ERROR;
}
else {
if (trsf->buffer == NULL)
*error = FOUG_DATAX_NULL_BUFFER_ERROR;
else if (trsf->buffer_size == 0)
*error = FOUG_DATAX_INVALID_BUFFER_SIZE_ERROR;
}
return foug_datax_no_error(*error);
}
foug_bool_t foug_stl_check_geom(int *error, const foug_stl_geom_t* geom)
{
if (geom == NULL
|| (geom->triangle_count > 0 && geom->get_triangle_func == NULL))
{
*error = FOUG_STL_WRITE_NULL_GET_TRIANGLE_FUNC_ERROR;
}
return foug_datax_no_error(*error);
}
foug_bool_t foug_stlb_check_params(int *error,
const foug_transfer_t *trsf,
foug_endianness_t byte_order)
{
if (!foug_check_transfer(error, trsf))
return FOUG_FALSE;
if (trsf->buffer_size < FOUG_STLB_MIN_CONTENTS_SIZE)
*error = FOUG_DATAX_INVALID_BUFFER_SIZE_ERROR;
if (byte_order != FOUG_LITTLE_ENDIAN && byte_order != FOUG_BIG_ENDIAN)
*error = FOUG_STLB_UNSUPPORTED_BYTE_ORDER_ERROR;
return foug_datax_no_error(*error);
}

View File

@ -1,25 +0,0 @@
#ifndef FOUG_INTERNAL_STL_RW_COMMON_H
#define FOUG_INTERNAL_STL_RW_COMMON_H
#include "../../datax_core/global.h"
#include "../../datax_core/endian.h"
#include "../../datax_core/transfer.h"
#include "../stl_geom.h"
#include "../stl_triangle.h"
typedef struct
{
uint32_t facet_count;
uint32_t i_facet_offset;
void (*fix_endian_func)(foug_stl_triangle_t*);
} foug_stlb_readwrite_helper;
foug_bool_t foug_check_transfer(int* error, const foug_transfer_t* trsf);
foug_bool_t foug_stl_check_geom(int* error, const foug_stl_geom_t* geom);
foug_bool_t foug_stlb_check_params(int* error,
const foug_transfer_t* trsf,
foug_endianness_t byte_order);
#endif /* FOUG_INTERNAL_STLB_RW_COMMON_H */

View File

@ -1,14 +0,0 @@
#include "stlb_byte_swap.h"
#include "../../datax_core/internal/byte_swap.h"
void foug_stl_triangle_bswap(foug_stl_triangle_t* triangle)
{
int i;
uint32_t* uintcoord_ptr = (uint32_t*)&(triangle->normal.x);
for (i = 0; i < 12; ++i)
*(uintcoord_ptr + i) = foug_uint32_bswap(*(uintcoord_ptr + i));
if (triangle->attribute_byte_count != 0)
triangle->attribute_byte_count = foug_uint16_bswap(triangle->attribute_byte_count);
}

View File

@ -1,9 +0,0 @@
#ifndef FOUG_INTERNAL_STLB_BYTE_SWAP_H
#define FOUG_INTERNAL_STLB_BYTE_SWAP_H
#include "../../datax_core/global.h"
#include "../stl_triangle.h"
void foug_stl_triangle_bswap(foug_stl_triangle_t* triangle);
#endif /* FOUG_INTERNAL_STLB_BYTE_SWAP_H */

View File

@ -1,35 +0,0 @@
#ifndef FOUG_LIBSTL_STL_ERROR_H
#define FOUG_LIBSTL_STL_ERROR_H
/*! A byte-mask to tag(identify) STL-specific error codes */
#define FOUG_STL_ERROR_TAG 0x11000000
/*! This enum defines the various error codes reported by STL read/write functions */
enum foug_stl_error
{
/*! Common STL write error indicating foug_stl_geom::get_triangle_func() pointer is NULL */
FOUG_STL_WRITE_NULL_GET_TRIANGLE_FUNC_ERROR = FOUG_STL_ERROR_TAG + 1,
/* Specific error codes returned by STL_ascii read function */
/*! Parsing error occured in foug_stla_read() due to malformed STL ascii input */
FOUG_STLA_READ_PARSE_ERROR = FOUG_STL_ERROR_TAG + 100,
/*! Invalid max number of decimal significants digits for foug_stla_write(), must be in [1..9] */
FOUG_STLA_WRITE_INVALID_REAL32_PREC_ERROR = FOUG_STL_ERROR_TAG + 101,
/* Specific error codes returned by STL_binary read/write functions */
/*! The byte order argument supplied is not supported, must be little or big endian */
FOUG_STLB_UNSUPPORTED_BYTE_ORDER_ERROR = FOUG_STL_ERROR_TAG + 300,
/*! Error occured when reading header data in foug_stlb_read() */
FOUG_STLB_READ_HEADER_WRONG_SIZE_ERROR = FOUG_STL_ERROR_TAG + 301,
/*! Error occured when reading facet count in foug_stlb_read() */
FOUG_STLB_READ_FACET_COUNT_ERROR = FOUG_STL_ERROR_TAG + 302
};
typedef enum foug_stl_error foug_stl_error_t;
#endif /* FOUG_LIBSTL_STL_ERROR_H */

View File

@ -1,25 +0,0 @@
#ifndef FOUG_LIBSTL_FORMAT_H
#define FOUG_LIBSTL_FORMAT_H
#include "stl_global.h"
#include "../datax_core/stream.h"
FOUG_C_LINKAGE_BEGIN
/*! This enums defines the various STL formats */
enum foug_stl_format
{
FOUG_STL_ASCII_FORMAT, /*!< STL ASCII (text) */
FOUG_STL_BINARY_LE_FORMAT, /*!< STL binary (little-endian) */
FOUG_STL_BINARY_BE_FORMAT, /*!< STL binary (big-endian) */
FOUG_STL_UNKNOWN_FORMAT
};
typedef enum foug_stl_format foug_stl_format_t;
FOUG_DATAX_LIBSTL_EXPORT
foug_stl_format_t foug_stl_get_format(foug_stream_t* stream, size_t data_size);
FOUG_C_LINKAGE_END
#endif /* FOUG_LIBSTL_FORMAT_H */

View File

@ -1,20 +0,0 @@
#ifndef FOUG_DATAX_C_LIBSTL_STLB_GLOBAL_H
#define FOUG_DATAX_C_LIBSTL_STLB_GLOBAL_H
#include "../datax_core/global.h"
#ifdef FOUG_DATAX_LIBSTL_DLL
# ifdef FOUG_DATAX_LIBSTL_MAKE_DLL
# define FOUG_DATAX_LIBSTL_EXPORT FOUG_DECL_EXPORT
# else
# define FOUG_DATAX_LIBSTL_EXPORT FOUG_DECL_IMPORT
# endif /* FOUG_DATAX_LIBSTL_MAKE_DLL */
#else
# define FOUG_DATAX_LIBSTL_EXPORT
#endif /* FOUG_DATAX_LIBSTL_DLL */
/* STLB */
#define FOUG_STLB_HEADER_SIZE 80
#define FOUG_STLB_MIN_CONTENTS_SIZE 284
#endif /* FOUG_DATAX_C_LIBSTL_STLB_GLOBAL_H */

View File

@ -1,44 +0,0 @@
#ifndef FOUG_DATAX_LIBSTL_STL_IO_H
#define FOUG_DATAX_LIBSTL_STL_IO_H
#include "stl_global.h"
#include "stl_geom.h"
#include "stl_geom_creator.h"
#include "../datax_core/endian.h"
#include "../datax_core/transfer.h"
FOUG_C_LINKAGE_BEGIN
/*
* STL ascii
*/
/*! Read geometry from STL ascii stream */
FOUG_DATAX_LIBSTL_EXPORT int foug_stla_read(foug_stl_geom_creator_t* creator,
foug_transfer_t* trsf,
size_t data_size_hint);
/*! Write geometry in the STL ascii format */
FOUG_DATAX_LIBSTL_EXPORT int foug_stla_write(const foug_stl_geom_t* geom,
foug_transfer_t* trsf,
const char* solid_name,
uint8_t real32_prec);
/*
* STL binary
*/
/*! Read geometry from STL binary stream */
FOUG_DATAX_LIBSTL_EXPORT int foug_stlb_read(foug_stl_geom_creator_t* creator,
foug_transfer_t* trsf,
foug_endianness_t byte_order);
/*! Write geometry in the STL binary format */
FOUG_DATAX_LIBSTL_EXPORT int foug_stlb_write(const foug_stl_geom_t* geom,
foug_transfer_t* trsf,
const uint8_t* header_data,
foug_endianness_t byte_order);
FOUG_C_LINKAGE_END
#endif /* FOUG_DATAX_LIBSTL_STL_IO_H */

View File

@ -1,37 +0,0 @@
#ifndef FOUG_DATAX_C_LIBSTL_TRIANGLE_H
#define FOUG_DATAX_C_LIBSTL_TRIANGLE_H
#include "stl_global.h"
/*! Cartesian coordinate entity in 3D space, specifically tailored for STL needs (single-float) */
struct foug_stl_coords
{
foug_real32_t x;
foug_real32_t y;
foug_real32_t z;
};
typedef struct foug_stl_coords foug_stl_coords_t;
/*! STL mesh triangle defined three geometric vertices and an orientation(normal) */
struct foug_stl_triangle
{
foug_stl_coords_t normal;
foug_stl_coords_t v1;
foug_stl_coords_t v2;
foug_stl_coords_t v3;
uint16_t attribute_byte_count; /*!< Useful only for STL binary format */
};
typedef struct foug_stl_triangle foug_stl_triangle_t;
/*! Compact size of a foug_stl_coords_t object */
#define FOUG_STL_COORDS_RAWSIZE (3 * sizeof(foug_real32_t))
/*! Compact size of a foug_stl_triangle_t object for STL ascii format */
#define FOUG_STLA_TRIANGLE_RAWSIZE (4 * FOUG_STL_COORDS_RAWSIZE)
/*! Compact size of a foug_stl_triangle_t object for STL binary format */
#define FOUG_STLB_TRIANGLE_RAWSIZE (FOUG_STLA_TRIANGLE_RAWSIZE + sizeof(uint16_t))
#endif /* FOUG_DATAX_C_LIBSTL_TRIANGLE_H */

View File

@ -1,121 +0,0 @@
#include "stl_io.h"
#include "stl_error.h"
#include "internal/stl_rw_common.h"
#include "internal/stlb_byte_swap.h"
#include "../datax_core/endian.h"
#include "../datax_core/error.h"
#include "../datax_core/internal/convert.h"
#include "../datax_core/internal/byte_swap.h"
#include <string.h>
FOUG_INLINE static void read_triangle_memcpy(const uint8_t* buffer,
foug_stl_triangle_t* triangle)
{
/* *triangle = *((foug_stl_triangle_t*)(buffer)); */
memcpy(triangle, buffer, FOUG_STLB_TRIANGLE_RAWSIZE);
}
static void foug_stlb_read_facets(foug_stl_geom_creator_t* creator,
const uint8_t* buffer,
const foug_stlb_readwrite_helper* rparams)
{
const uint32_t facet_count = rparams->facet_count;
const uint32_t i_facet_offset = rparams->i_facet_offset;
foug_stl_triangle_t triangle;
uint32_t buffer_offset = 0;
uint32_t i_facet = 0;
if (creator == NULL || creator->add_triangle_func == NULL)
return;
for (i_facet = 0; i_facet < facet_count; ++i_facet) {
/* Decode data */
read_triangle_memcpy(buffer + buffer_offset, &triangle);
buffer_offset += FOUG_STLB_TRIANGLE_RAWSIZE;
if (rparams->fix_endian_func != NULL)
rparams->fix_endian_func(&triangle);
/* Declare triangle */
creator->add_triangle_func(creator->cookie, i_facet_offset + i_facet, &triangle);
}
}
int foug_stlb_read(foug_stl_geom_creator_t *creator,
foug_transfer_t* trsf,
foug_endianness_t byte_order)
{
const foug_endianness_t host_byte_order = foug_host_endianness();
foug_stlb_readwrite_helper rparams;
uint8_t header_data[FOUG_STLB_HEADER_SIZE];
uint32_t total_facet_count = 0; /* Count of facets as declared in the stream */
int error = FOUG_DATAX_NO_ERROR; /* Helper variable to store function result error code */
/* Check validity of input parameters */
if (!foug_stlb_check_params(&error, trsf, byte_order))
return error;
/* Initialize rparams */
memset(&rparams, 0, sizeof(foug_stlb_readwrite_helper));
if (host_byte_order != byte_order)
rparams.fix_endian_func = foug_stl_triangle_bswap;
/* Read header */
if (foug_stream_read(&trsf->stream, header_data, 1, FOUG_STLB_HEADER_SIZE)
!= FOUG_STLB_HEADER_SIZE)
{
return FOUG_STLB_READ_HEADER_WRONG_SIZE_ERROR;
}
/* Read facet count */
if (foug_stream_read(&trsf->stream, trsf->buffer, sizeof(uint32_t), 1) != 1)
return FOUG_STLB_READ_FACET_COUNT_ERROR;
memcpy(&total_facet_count, trsf->buffer, sizeof(uint32_t));
if (host_byte_order != byte_order)
total_facet_count = foug_uint32_bswap(total_facet_count);
/* Callback to notify triangle count and header data */
if (creator != NULL && creator->binary_begin_solid_func != NULL)
creator->binary_begin_solid_func(creator->cookie, total_facet_count, header_data);
/* Read triangles */
while (foug_datax_no_error(error)
&& rparams.i_facet_offset < total_facet_count)
{
rparams.facet_count = foug_stream_read(&trsf->stream,
trsf->buffer,
FOUG_STLB_TRIANGLE_RAWSIZE,
trsf->buffer_size / FOUG_STLB_TRIANGLE_RAWSIZE);
if (foug_stream_error(&trsf->stream) != 0)
error = FOUG_DATAX_STREAM_ERROR;
else if (rparams.facet_count > 0)
error = FOUG_DATAX_NO_ERROR;
else
break; /* Exit if no facet to read */
if (foug_datax_no_error(error)) {
uint8_t progress_pc;
foug_stlb_read_facets(creator, trsf->buffer, &rparams);
rparams.i_facet_offset += rparams.facet_count;
progress_pc = foug_percentage(0, total_facet_count, rparams.i_facet_offset);
if (!foug_task_control_handle_progress(&trsf->task_control, progress_pc))
error = FOUG_DATAX_TASK_STOPPED_ERROR;
}
} /* end while */
if (foug_datax_no_error(error)
&& creator != NULL
&& creator->end_solid_func != NULL)
{
creator->end_solid_func(creator->cookie);
}
if (foug_datax_no_error(error) && rparams.i_facet_offset != total_facet_count)
error = FOUG_STLB_READ_FACET_COUNT_ERROR;
return error;
}

View File

@ -1,33 +0,0 @@
#ifndef FOUG_SUPPORT_OCC_LIBSTL_H
#define FOUG_SUPPORT_OCC_LIBSTL_H
#include "support_global.h"
#include <Handle_StlMesh_Mesh.hxx>
struct foug_stl_geom;
struct foug_stl_geom_creator;
class FOUG_LIBSUPPORT_EXPORT foug_OccStlMeshDomain
{
public:
foug_OccStlMeshDomain(const Handle_StlMesh_Mesh& stlMesh, int domId = 1);
const Handle_StlMesh_Mesh& mesh() const;
void setMesh(const Handle_StlMesh_Mesh& stlMesh);
int domainId() const;
void setDomainId(int domId);
private:
Handle_StlMesh_Mesh m_mesh;
int m_domainId;
};
FOUG_LIBSUPPORT_EXPORT
void foug_stl_occmesh_geom(foug_stl_geom* geom,
const foug_OccStlMeshDomain& meshCookie);
FOUG_LIBSUPPORT_EXPORT
void foug_stl_occmesh_geom_creator(foug_stl_geom_creator* creator,
const Handle_StlMesh_Mesh& mesh);
#endif /* FOUG_SUPPORT_OCC_LIBSTL_H */

View File

@ -1,11 +0,0 @@
#ifndef FOUG_SUPPORT_QT_STREAM_H
#define FOUG_SUPPORT_QT_STREAM_H
#include "support_global.h"
struct foug_stream;
class QIODevice;
FOUG_LIBSUPPORT_EXPORT
void foug_stream_set_qiodevice(struct foug_stream* stream, QIODevice* device);
#endif /* FOUG_SUPPORT_QT_STREAM_H */

View File

@ -1,16 +0,0 @@
#ifndef FOUG_C_SUPPORT_GLOBAL_H
#define FOUG_C_SUPPORT_GLOBAL_H
#include "../datax_core/global.h"
#ifdef FOUG_LIBSUPPORT_DLL
# ifdef FOUG_LIBSUPPORT_MAKE_DLL
# define FOUG_LIBSUPPORT_EXPORT FOUG_DECL_EXPORT
# else
# define FOUG_LIBSUPPORT_EXPORT FOUG_DECL_IMPORT
# endif /* FOUG_LIBSUPPORT_MAKE_DLL */
#else
# define FOUG_LIBSUPPORT_EXPORT
#endif /* FOUG_LIBSUPPORT_DLL */
#endif /* FOUG_C_SUPPORT_GLOBAL_H */

View File

@ -8,20 +8,20 @@ typedef union
{ {
uint32_t integer; uint32_t integer;
uint8_t bytes[4]; uint8_t bytes[4];
} _internal_foug_int_bytes_32_convert_t; } _internal_gmio_int_bytes_32_convert_t;
foug_endianness_t foug_host_endianness() gmio_endianness_t gmio_host_endianness()
{ {
_internal_foug_int_bytes_32_convert_t conv; _internal_gmio_int_bytes_32_convert_t conv;
conv.integer = 0x01020408; conv.integer = 0x01020408;
if (conv.bytes[0] == 0x08 && conv.bytes[3] == 0x01) if (conv.bytes[0] == 0x08 && conv.bytes[3] == 0x01)
return FOUG_LITTLE_ENDIAN; return GMIO_LITTLE_ENDIAN;
else if (conv.bytes[0] == 0x01 && conv.bytes[3] == 0x08) else if (conv.bytes[0] == 0x01 && conv.bytes[3] == 0x08)
return FOUG_BIG_ENDIAN; return GMIO_BIG_ENDIAN;
else if (conv.bytes[1] == 0x08 && conv.bytes[2] == 0x01) else if (conv.bytes[1] == 0x08 && conv.bytes[2] == 0x01)
return FOUG_MIDDLE_ENDIAN; return GMIO_MIDDLE_ENDIAN;
else else
return FOUG_OTHER_ENDIAN; return GMIO_OTHER_ENDIAN;
} }

24
src/gmio_core/endian.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef GMIO_ENDIAN_H
#define GMIO_ENDIAN_H
#include "global.h"
GMIO_C_LINKAGE_BEGIN
/*! This enum identifies endian representations of numbers */
enum gmio_endianness
{
GMIO_LITTLE_ENDIAN,
GMIO_BIG_ENDIAN,
GMIO_MIDDLE_ENDIAN,
GMIO_OTHER_ENDIAN
};
typedef enum gmio_endianness gmio_endianness_t;
/*! Returns endianness (byte order) of the host's CPU architecture */
GMIO_LIB_EXPORT gmio_endianness_t gmio_host_endianness();
GMIO_C_LINKAGE_END
#endif /* GMIO_ENDIAN_H */

11
src/gmio_core/error.c Normal file
View File

@ -0,0 +1,11 @@
#include "error.h"
gmio_bool_t gmio_no_error(int code)
{
return code == GMIO_NO_ERROR;
}
gmio_bool_t gmio_error(int code)
{
return code != GMIO_NO_ERROR;
}

40
src/gmio_core/error.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef GMIO_ERROR_H
#define GMIO_ERROR_H
#include "global.h"
GMIO_C_LINKAGE_BEGIN
/*! This enum defines common errors */
enum gmio_error
{
/*! No error occurred, success */
GMIO_NO_ERROR = 0,
/*! Pointer on argument gmio_transfer_t is NULL */
GMIO_NULL_TRANSFER_ERROR = -1,
/*! Pointer on argument buffer is NULL */
GMIO_NULL_BUFFER_ERROR = -2,
/*! Argument buffer's size is too small */
GMIO_INVALID_BUFFER_SIZE_ERROR = -3,
/*! An error occurred with the argument gmio_stream_t (check gmio_stream_error()) */
GMIO_STREAM_ERROR = -4,
/*! Operation was stopped by user (gmio_task_control::handle_progress_func() returned GMIO_FALSE) */
GMIO_TASK_STOPPED_ERROR = -5
};
typedef enum gmio_error gmio_error_t;
/*! Returns true if \p code == GMIO_NO_ERROR */
GMIO_LIB_EXPORT gmio_bool_t gmio_no_error(int code);
/*! Returns true if \p code != GMIO_NO_ERROR */
GMIO_LIB_EXPORT gmio_bool_t gmio_error(int code);
GMIO_C_LINKAGE_END
#endif /* GMIO_ERROR_H */

View File

@ -1,31 +1,31 @@
#ifndef FOUG_C_GLOBAL_H #ifndef GMIO_GLOBAL_H
#define FOUG_C_GLOBAL_H #define GMIO_GLOBAL_H
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) \ #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) \
|| defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
# define FOUG_DECL_EXPORT __declspec(dllexport) # define GMIO_DECL_EXPORT __declspec(dllexport)
# define FOUG_DECL_IMPORT __declspec(dllimport) # define GMIO_DECL_IMPORT __declspec(dllimport)
#else #else
# define FOUG_DECL_EXPORT # define GMIO_DECL_EXPORT
# define FOUG_DECL_IMPORT # define GMIO_DECL_IMPORT
#endif /* WIN */ #endif /* WIN */
#ifdef FOUG_LIB_DLL #ifdef GMIO_LIB_DLL
# ifdef FOUG_LIB_MAKE_DLL # ifdef GMIO_LIB_MAKE_DLL
# define FOUG_LIB_EXPORT FOUG_DECL_EXPORT # define GMIO_LIB_EXPORT GMIO_DECL_EXPORT
# else # else
# define FOUG_LIB_EXPORT FOUG_DECL_IMPORT # define GMIO_LIB_EXPORT GMIO_DECL_IMPORT
# endif /* FOUG_LIB_MAKE_DLL */ # endif /* GMIO_LIB_MAKE_DLL */
#else #else
# define FOUG_LIB_EXPORT # define GMIO_LIB_EXPORT
#endif /* FOUG_LIB_DLL */ #endif /* GMIO_LIB_DLL */
/* "config.h" is generated by cmake, it should reside in the out-of-source build dir. /* "config.h" is generated by cmake, it should reside in the out-of-source build dir.
* In CMakeFiles.txt, the directory where resides "config.h" is added to the include path list * In CMakeFiles.txt, the directory where resides "config.h" is added to the include path list
*/ */
#include "config.h" #include "config.h"
#ifdef FOUG_HAVE_STDINT_H #ifdef GMIO_HAVE_STDINT_H
# include <stdint.h> # include <stdint.h>
#else #else
typedef char int8_t; typedef char int8_t;
@ -45,40 +45,40 @@ typedef long long int64_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
# endif*/ /* _MSC_VER */ # endif*/ /* _MSC_VER */
#endif /* FOUG_USE_STDINT_H */ #endif /* GMIO_USE_STDINT_H */
/*! Typedef for boolean type */ /*! Typedef for boolean type */
typedef int foug_bool_t; typedef int gmio_bool_t;
/*! This enum defines true/false boolean values */ /*! This enum defines true/false boolean values */
enum foug_bool_value enum gmio_bool_value
{ {
FOUG_FALSE = 0, GMIO_FALSE = 0,
FOUG_TRUE = 1 GMIO_TRUE = 1
}; };
/*! Typedef for 32bit real type (float) */ /*! Typedef for 32bit real type (float) */
typedef float foug_real32_t; typedef float gmio_real32_t;
/*! Typedef for 64bit real type (double) */ /*! Typedef for 64bit real type (double) */
typedef double foug_real64_t; typedef double gmio_real64_t;
#ifndef FOUG_INLINE #ifndef GMIO_INLINE
# if defined(__GNUC__) # if defined(__GNUC__)
# define FOUG_INLINE __inline__ /* Compatible with C90 */ # define GMIO_INLINE __inline__ /* Compatible with C90 */
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# define FOUG_INLINE __inline # define GMIO_INLINE __inline
# else # else
# define FOUG_INLINE # define GMIO_INLINE
# endif # endif
#endif /* !FOUG_INLINE */ #endif /* !GMIO_INLINE */
#ifdef __cplusplus #ifdef __cplusplus
# define FOUG_C_LINKAGE_BEGIN extern "C" { # define GMIO_C_LINKAGE_BEGIN extern "C" {
# define FOUG_C_LINKAGE_END } # define GMIO_C_LINKAGE_END }
#else #else
# define FOUG_C_LINKAGE_BEGIN # define GMIO_C_LINKAGE_BEGIN
# define FOUG_C_LINKAGE_END # define GMIO_C_LINKAGE_END
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* FOUG_C_GLOBAL_H */ #endif /* GMIO_GLOBAL_H */

View File

@ -4,24 +4,24 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
void foug_ascii_stream_fwd_iterator_init(foug_ascii_stream_fwd_iterator_t *it) void gmio_ascii_stream_fwd_iterator_init(gmio_ascii_stream_fwd_iterator_t *it)
{ {
/* Trick: declaring the buffer exhausted will actually trigger the first call to /* Trick: declaring the buffer exhausted will actually trigger the first call to
* foug_stream_read() inside foug_next_char() * gmio_stream_read() inside gmio_next_char()
*/ */
it->buffer.len = 0; it->buffer.len = 0;
it->buffer_pos = it->buffer.max_len; it->buffer_pos = it->buffer.max_len;
foug_next_char(it); gmio_next_char(it);
} }
char *foug_current_char(const foug_ascii_stream_fwd_iterator_t *it) char *gmio_current_char(const gmio_ascii_stream_fwd_iterator_t *it)
{ {
if (it != NULL && it->buffer_pos < it->buffer.len) if (it != NULL && it->buffer_pos < it->buffer.len)
return it->buffer.ptr + it->buffer_pos; return it->buffer.ptr + it->buffer_pos;
return NULL; return NULL;
} }
char *foug_next_char(foug_ascii_stream_fwd_iterator_t *it) char *gmio_next_char(gmio_ascii_stream_fwd_iterator_t *it)
{ {
if (it == NULL) if (it == NULL)
return NULL; return NULL;
@ -31,13 +31,13 @@ char *foug_next_char(foug_ascii_stream_fwd_iterator_t *it)
return it->buffer.ptr + it->buffer_pos; return it->buffer.ptr + it->buffer_pos;
} }
else { else {
if (foug_stream_error(it->stream) != 0 || foug_stream_at_end(it->stream)) if (gmio_stream_error(it->stream) != 0 || gmio_stream_at_end(it->stream))
return NULL; return NULL;
/* Read next chunk of data */ /* Read next chunk of data */
it->buffer_pos = 0; it->buffer_pos = 0;
it->buffer.len = foug_stream_read(it->stream, it->buffer.ptr, sizeof(char), it->buffer.max_len); it->buffer.len = gmio_stream_read(it->stream, it->buffer.ptr, sizeof(char), it->buffer.max_len);
if (foug_stream_error(it->stream) == 0) { if (gmio_stream_error(it->stream) == 0) {
if (it->stream_read_hook != NULL) if (it->stream_read_hook != NULL)
it->stream_read_hook(it->cookie, &it->buffer); it->stream_read_hook(it->cookie, &it->buffer);
return it->buffer.ptr; return it->buffer.ptr;
@ -47,14 +47,14 @@ char *foug_next_char(foug_ascii_stream_fwd_iterator_t *it)
return NULL; return NULL;
} }
void foug_skip_spaces(foug_ascii_stream_fwd_iterator_t *it) void gmio_skip_spaces(gmio_ascii_stream_fwd_iterator_t *it)
{ {
const char* curr_char = foug_current_char(it); const char* curr_char = gmio_current_char(it);
while (curr_char != NULL && isspace(*curr_char)) while (curr_char != NULL && isspace(*curr_char))
curr_char = foug_next_char(it); curr_char = gmio_next_char(it);
} }
int foug_eat_word(foug_ascii_stream_fwd_iterator_t *it, foug_ascii_string_buffer_t *buffer) int gmio_eat_word(gmio_ascii_stream_fwd_iterator_t *it, gmio_ascii_string_buffer_t *buffer)
{ {
const char* stream_curr_char = NULL; const char* stream_curr_char = NULL;
int isspace_res = 0; int isspace_res = 0;
@ -64,14 +64,14 @@ int foug_eat_word(foug_ascii_stream_fwd_iterator_t *it, foug_ascii_string_buffer
return -1; return -1;
buffer->len = 0; buffer->len = 0;
foug_skip_spaces(it); gmio_skip_spaces(it);
stream_curr_char = foug_current_char(it); stream_curr_char = gmio_current_char(it);
while (i < buffer->max_len && stream_curr_char != NULL && isspace_res == 0) { while (i < buffer->max_len && stream_curr_char != NULL && isspace_res == 0) {
isspace_res = isspace(*stream_curr_char); isspace_res = isspace(*stream_curr_char);
if (isspace_res == 0) { if (isspace_res == 0) {
buffer->ptr[i] = *stream_curr_char; buffer->ptr[i] = *stream_curr_char;
stream_curr_char = foug_next_char(it); stream_curr_char = gmio_next_char(it);
++i; ++i;
} }
} }
@ -79,21 +79,21 @@ int foug_eat_word(foug_ascii_stream_fwd_iterator_t *it, foug_ascii_string_buffer
if (i < buffer->max_len) { if (i < buffer->max_len) {
buffer->ptr[i] = 0; /* End string with terminating null byte */ buffer->ptr[i] = 0; /* End string with terminating null byte */
buffer->len = i; buffer->len = i;
if (stream_curr_char != NULL || foug_stream_at_end(it->stream)) if (stream_curr_char != NULL || gmio_stream_at_end(it->stream))
return 0; return 0;
return -2; return -2;
} }
return -3; return -3;
} }
int foug_get_real32(const char *str, foug_real32_t *value_ptr) int gmio_get_real32(const char *str, gmio_real32_t *value_ptr)
{ {
char* end_ptr; /* for strtod() */ char* end_ptr; /* for strtod() */
#ifdef FOUG_HAVE_STRTOF_FUNC #ifdef GMIO_HAVE_STRTOF_FUNC
*value_ptr = strtof(str, &end_ptr); /* Requires C99 */ *value_ptr = strtof(str, &end_ptr); /* Requires C99 */
#else #else
*value_ptr = (foug_real32_t)strtod(str, &end_ptr); *value_ptr = (gmio_real32_t)strtod(str, &end_ptr);
#endif #endif
if (end_ptr == str || errno == ERANGE) if (end_ptr == str || errno == ERANGE)
@ -102,14 +102,14 @@ int foug_get_real32(const char *str, foug_real32_t *value_ptr)
return 0; return 0;
} }
foug_bool_t foug_checked_next_chars(foug_ascii_stream_fwd_iterator_t *it, const char *str) gmio_bool_t gmio_checked_next_chars(gmio_ascii_stream_fwd_iterator_t *it, const char *str)
{ {
size_t pos = 0; size_t pos = 0;
const char* curr_char = foug_current_char(it); const char* curr_char = gmio_current_char(it);
foug_bool_t same = curr_char != NULL && *curr_char == *str; gmio_bool_t same = curr_char != NULL && *curr_char == *str;
while (same) { while (same) {
curr_char = foug_next_char(it); curr_char = gmio_next_char(it);
same = curr_char != NULL && *curr_char == str[++pos]; same = curr_char != NULL && *curr_char == str[++pos];
} }

View File

@ -0,0 +1,33 @@
#ifndef GMIO_INTERNAL_ASCII_PARSE_H
#define GMIO_INTERNAL_ASCII_PARSE_H
#include "../global.h"
#include "../stream.h"
typedef struct
{
char* ptr; /*!< Buffer contents */
size_t len; /*!< Size(length) of current contents */
size_t max_len; /*!< Maximum contents size(length) */
} gmio_ascii_string_buffer_t;
typedef struct
{
gmio_stream_t* stream;
gmio_ascii_string_buffer_t buffer;
size_t buffer_pos; /*!< Position indicator in buffer */
void* cookie;
void (*stream_read_hook)(void*, const gmio_ascii_string_buffer_t*);
} gmio_ascii_stream_fwd_iterator_t;
void gmio_ascii_stream_fwd_iterator_init(gmio_ascii_stream_fwd_iterator_t* it);
char* gmio_current_char(const gmio_ascii_stream_fwd_iterator_t* it);
void gmio_skip_spaces(gmio_ascii_stream_fwd_iterator_t* it);
int gmio_eat_word(gmio_ascii_stream_fwd_iterator_t* it, gmio_ascii_string_buffer_t* buffer);
int gmio_get_real32(const char* str, gmio_real32_t* value_ptr);
char* gmio_next_char(gmio_ascii_stream_fwd_iterator_t* it);
gmio_bool_t gmio_checked_next_chars(gmio_ascii_stream_fwd_iterator_t* it, const char* str);
#endif /* GMIO_INTERNAL_ASCII_PARSE_H */

View File

@ -6,7 +6,7 @@
#include "../global.h" #include "../global.h"
/*! Read a 16bit integer from memory-location \p bytes (little-endian byte order) */ /*! Read a 16bit integer from memory-location \p bytes (little-endian byte order) */
FOUG_INLINE static uint16_t foug_decode_uint16_le(const uint8_t* bytes) GMIO_INLINE static uint16_t gmio_decode_uint16_le(const uint8_t* bytes)
{ {
/* |0 |1 | */ /* |0 |1 | */
/* |BB|AA| -> 0xAABB */ /* |BB|AA| -> 0xAABB */
@ -14,7 +14,7 @@ FOUG_INLINE static uint16_t foug_decode_uint16_le(const uint8_t* bytes)
} }
/*! Read a 16bit integer from memory-location \p bytes (big-endian byte order) */ /*! Read a 16bit integer from memory-location \p bytes (big-endian byte order) */
FOUG_INLINE static uint16_t foug_decode_uint16_be(const uint8_t* bytes) GMIO_INLINE static uint16_t gmio_decode_uint16_be(const uint8_t* bytes)
{ {
/* |0 |1 | */ /* |0 |1 | */
/* |AA|BB| -> 0xAABB */ /* |AA|BB| -> 0xAABB */
@ -22,35 +22,35 @@ FOUG_INLINE static uint16_t foug_decode_uint16_be(const uint8_t* bytes)
} }
/*! Write 16bit integer \p val to the memory location at \p bytes in little-endian byte order */ /*! Write 16bit integer \p val to the memory location at \p bytes in little-endian byte order */
FOUG_INLINE static void foug_encode_uint16_le(uint16_t val, uint8_t* bytes) GMIO_INLINE static void gmio_encode_uint16_le(uint16_t val, uint8_t* bytes)
{ {
bytes[0] = val & 0xFF; bytes[0] = val & 0xFF;
bytes[1] = (val >> 8) & 0xFF; bytes[1] = (val >> 8) & 0xFF;
} }
/*! Read a 32bit integer from memory-location \p bytes (little-endian byte order) */ /*! Read a 32bit integer from memory-location \p bytes (little-endian byte order) */
FOUG_INLINE static uint32_t foug_decode_uint32_le(const uint8_t* bytes) GMIO_INLINE static uint32_t gmio_decode_uint32_le(const uint8_t* bytes)
{ {
/* |DD|CC|BB|AA| -> 0xAABBCCDD */ /* |DD|CC|BB|AA| -> 0xAABBCCDD */
return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
} }
/*! Read a 32bit integer from memory-location \p bytes (mixed-endian byte order) */ /*! Read a 32bit integer from memory-location \p bytes (mixed-endian byte order) */
FOUG_INLINE static uint32_t foug_decode_uint32_me(const uint8_t* bytes) GMIO_INLINE static uint32_t gmio_decode_uint32_me(const uint8_t* bytes)
{ {
/* |DD|CC|BB|AA| -> 0xCCDDAABB */ /* |DD|CC|BB|AA| -> 0xCCDDAABB */
return (bytes[0] << 16) | (bytes[1] << 24) | (bytes[3] << 8) | bytes[2]; return (bytes[0] << 16) | (bytes[1] << 24) | (bytes[3] << 8) | bytes[2];
} }
/*! Read a 32bit integer from memory-location \p bytes (big-endian byte order) */ /*! Read a 32bit integer from memory-location \p bytes (big-endian byte order) */
FOUG_INLINE static uint32_t foug_decode_uint32_be(const uint8_t* bytes) GMIO_INLINE static uint32_t gmio_decode_uint32_be(const uint8_t* bytes)
{ {
/* |DD|CC|BB|AA| -> 0xDDCCBBAA */ /* |DD|CC|BB|AA| -> 0xDDCCBBAA */
return bytes[3] | (bytes[2] << 8) | (bytes[1] << 16) | (bytes[0] << 24); return bytes[3] | (bytes[2] << 8) | (bytes[1] << 16) | (bytes[0] << 24);
} }
/*! Write 32bit integer \p val to the memory location at \p bytes in little-endian byte order */ /*! Write 32bit integer \p val to the memory location at \p bytes in little-endian byte order */
FOUG_INLINE static void foug_encode_uint32_le(uint32_t val, uint8_t* bytes) GMIO_INLINE static void gmio_encode_uint32_le(uint32_t val, uint8_t* bytes)
{ {
bytes[0] = val & 0xFF; bytes[0] = val & 0xFF;
bytes[1] = (val >> 8) & 0xFF; bytes[1] = (val >> 8) & 0xFF;
@ -59,7 +59,7 @@ FOUG_INLINE static void foug_encode_uint32_le(uint32_t val, uint8_t* bytes)
} }
/*! Write 32bit integer \p val to the memory location at \p bytes in big-endian byte order */ /*! Write 32bit integer \p val to the memory location at \p bytes in big-endian byte order */
FOUG_INLINE static void foug_encode_uint32_be(uint32_t val, uint8_t* bytes) GMIO_INLINE static void gmio_encode_uint32_be(uint32_t val, uint8_t* bytes)
{ {
bytes[0] = (val >> 24) & 0xFF; bytes[0] = (val >> 24) & 0xFF;
bytes[1] = (val >> 16) & 0xFF; bytes[1] = (val >> 16) & 0xFF;

View File

@ -5,16 +5,16 @@
#include "../global.h" #include "../global.h"
#ifdef FOUG_HAVE_MSVC_BUILTIN_BSWAP_FUNC #ifdef GMIO_HAVE_MSVC_BUILTIN_BSWAP_FUNC
# include <stdlib.h> # include <stdlib.h>
#endif #endif
/*! Returns \p val with the order of bytes reversed, uses compiler builtin functions if available */ /*! Returns \p val with the order of bytes reversed, uses compiler builtin functions if available */
FOUG_INLINE static uint16_t foug_uint16_bswap(uint16_t val) GMIO_INLINE static uint16_t gmio_uint16_bswap(uint16_t val)
{ {
#ifdef FOUG_HAVE_GCC_BUILTIN_BSWAP16_FUNC #ifdef GMIO_HAVE_GCC_BUILTIN_BSWAP16_FUNC
return __builtin_bswap16(val); return __builtin_bswap16(val);
#elif defined(FOUG_HAVE_MSVC_BUILTIN_BSWAP_FUNC) #elif defined(GMIO_HAVE_MSVC_BUILTIN_BSWAP_FUNC)
return _byteswap_ushort(val); return _byteswap_ushort(val);
#else #else
return ((val & 0x00FF) << 8) | ((val >> 8) & 0x00FF); return ((val & 0x00FF) << 8) | ((val >> 8) & 0x00FF);
@ -22,11 +22,11 @@ FOUG_INLINE static uint16_t foug_uint16_bswap(uint16_t val)
} }
/*! Returns \p val with the order of bytes reversed, uses compiler builtin functions if available */ /*! Returns \p val with the order of bytes reversed, uses compiler builtin functions if available */
FOUG_INLINE static uint32_t foug_uint32_bswap(uint32_t val) GMIO_INLINE static uint32_t gmio_uint32_bswap(uint32_t val)
{ {
#ifdef FOUG_HAVE_GCC_BUILTIN_BSWAP32_FUNC #ifdef GMIO_HAVE_GCC_BUILTIN_BSWAP32_FUNC
return __builtin_bswap32(val); return __builtin_bswap32(val);
#elif defined(FOUG_HAVE_MSVC_BUILTIN_BSWAP_FUNC) #elif defined(GMIO_HAVE_MSVC_BUILTIN_BSWAP_FUNC)
return _byteswap_ulong(val); return _byteswap_ulong(val);
#else #else
return return

View File

@ -0,0 +1,15 @@
#include "convert.h"
gmio_real32_t gmio_convert_real32(uint32_t val)
{
gmio_uint32_float_t conv;
conv.as_uint32 = val;
return conv.as_float;
}
uint32_t gmio_convert_uint32(gmio_real32_t val)
{
gmio_uint32_float_t conv;
conv.as_float = val;
return conv.as_uint32;
}

View File

@ -0,0 +1,15 @@
#ifndef GMIO_INTERNAL_CONVERT_H
#define GMIO_INTERNAL_CONVERT_H
#include "../global.h"
typedef union
{
uint32_t as_uint32;
float as_float;
} gmio_uint32_float_t;
gmio_real32_t gmio_convert_real32(uint32_t val);
uint32_t gmio_convert_uint32(gmio_real32_t val);
#endif /* GMIO_INTERNAL_CONVERT_H */

View File

@ -1,12 +1,12 @@
#ifndef FOUG_C_MEMORY_H #ifndef GMIO_MEMORY_H
#define FOUG_C_MEMORY_H #define GMIO_MEMORY_H
#include <string.h> #include <string.h>
/*! Type alias for "pointer on function that allocates memory" (like standard malloc()) */ /*! Type alias for "pointer on function that allocates memory" (like standard malloc()) */
typedef void* (*foug_malloc_func_t)(size_t); typedef void* (*gmio_malloc_func_t)(size_t);
/*! Type alias for "pointer on function that frees memory" (like standard free()) */ /*! Type alias for "pointer on function that frees memory" (like standard free()) */
typedef void (*foug_free_func_t)(void*); typedef void (*gmio_free_func_t)(void*);
#endif /* FOUG_C_MEMORY_H */ #endif /* GMIO_MEMORY_H */

View File

@ -4,7 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
/*! \struct foug_stream /*! \struct gmio_stream
* *
* \details This is pretty much the same as [custom streams] * \details This is pretty much the same as [custom streams]
* (http://www.gnu.org/software/libc/manual/html_mono/libc.html#Custom-Streams) in the GNU C Library * (http://www.gnu.org/software/libc/manual/html_mono/libc.html#Custom-Streams) in the GNU C Library
@ -13,16 +13,16 @@
* implemented by defining hook functions that know how to read/write the data. * implemented by defining hook functions that know how to read/write the data.
*/ */
/*! \var foug_bool_t (*foug_stream::at_end_func)(void*) /*! \var gmio_bool_t (*gmio_stream::at_end_func)(void*)
* *
* Checks whether the end-of-stream indicator associated with stream pointed by \p cookie is set, * Checks whether the end-of-stream indicator associated with stream pointed by \p cookie is set,
* returning FOUG_TRUE if is. * returning GMIO_TRUE if is.
* *
* The function should behaves like C standard [feof()] * The function should behaves like C standard [feof()]
* (http://pubs.opengroup.org/onlinepubs/007904975/functions/feof.html) * (http://pubs.opengroup.org/onlinepubs/007904975/functions/feof.html)
*/ */
/*! \var int (*foug_stream::error_func)(void*) /*! \var int (*gmio_stream::error_func)(void*)
* *
* Checks if the error indicator associated with stream pointed by \p cookie is set, returning * Checks if the error indicator associated with stream pointed by \p cookie is set, returning
* a value different from zero if it is. * a value different from zero if it is.
@ -31,7 +31,7 @@
* (http://pubs.opengroup.org/onlinepubs/007904975/functions/ferror.html) * (http://pubs.opengroup.org/onlinepubs/007904975/functions/ferror.html)
*/ */
/*! \var size_t (*foug_stream::read_func)(void*, void*, size_t, size_t) /*! \var size_t (*gmio_stream::read_func)(void*, void*, size_t, size_t)
* *
* Reads an array of \p count elements, each one with a size of \p size bytes, from the stream * Reads an array of \p count elements, each one with a size of \p size bytes, from the stream
* pointed by \p cookie and stores them in the block of memory specified by \p ptr * pointed by \p cookie and stores them in the block of memory specified by \p ptr
@ -42,7 +42,7 @@
* \returns The total number of elements successfully read * \returns The total number of elements successfully read
*/ */
/*! \var size_t (*foug_stream::write_func)(void*, const void*, size_t, size_t); /*! \var size_t (*gmio_stream::write_func)(void*, const void*, size_t, size_t);
* *
* Writes an array of \p count elements, each one with a size of \p size bytes, from the * Writes an array of \p count elements, each one with a size of \p size bytes, from the
* block of memory pointed by \p ptr to the current position in the stream pointed by \p cookie * block of memory pointed by \p ptr to the current position in the stream pointed by \p cookie
@ -55,22 +55,22 @@
void foug_stream_set_null(foug_stream_t* stream) void gmio_stream_set_null(gmio_stream_t* stream)
{ {
memset(stream, 0, sizeof(foug_stream_t)); memset(stream, 0, sizeof(gmio_stream_t));
} }
static foug_bool_t foug_stream_stdio_at_end(void* cookie) static gmio_bool_t gmio_stream_stdio_at_end(void* cookie)
{ {
return feof((FILE*) cookie); return feof((FILE*) cookie);
} }
static int foug_stream_stdio_error(void* cookie) static int gmio_stream_stdio_error(void* cookie)
{ {
return ferror((FILE*) cookie); return ferror((FILE*) cookie);
} }
static size_t foug_stream_stdio_read(void* cookie, static size_t gmio_stream_stdio_read(void* cookie,
void* ptr, void* ptr,
size_t item_size, size_t item_size,
size_t item_count) size_t item_count)
@ -78,7 +78,7 @@ static size_t foug_stream_stdio_read(void* cookie,
return fread(ptr, item_size, item_count, (FILE*) cookie); return fread(ptr, item_size, item_count, (FILE*) cookie);
} }
static size_t foug_stream_stdio_write(void* cookie, static size_t gmio_stream_stdio_write(void* cookie,
const void* ptr, const void* ptr,
size_t item_size, size_t item_size,
size_t item_count) size_t item_count)
@ -86,13 +86,13 @@ static size_t foug_stream_stdio_write(void* cookie,
return fwrite(ptr, item_size, item_count, (FILE*) cookie); return fwrite(ptr, item_size, item_count, (FILE*) cookie);
} }
void foug_stream_set_stdio(foug_stream_t* stream, FILE* file) void gmio_stream_set_stdio(gmio_stream_t* stream, FILE* file)
{ {
stream->cookie = file; stream->cookie = file;
stream->at_end_func = foug_stream_stdio_at_end; stream->at_end_func = gmio_stream_stdio_at_end;
stream->error_func = foug_stream_stdio_error; stream->error_func = gmio_stream_stdio_error;
stream->read_func = foug_stream_stdio_read; stream->read_func = gmio_stream_stdio_read;
stream->write_func = foug_stream_stdio_write; stream->write_func = gmio_stream_stdio_write;
} }
/*! \details Basically the same as : /*! \details Basically the same as :
@ -100,7 +100,7 @@ void foug_stream_set_stdio(foug_stream_t* stream, FILE* file)
* stream->at_end_func(stream->cookie) * stream->at_end_func(stream->cookie)
* \endcode * \endcode
*/ */
foug_bool_t foug_stream_at_end(foug_stream_t* stream) gmio_bool_t gmio_stream_at_end(gmio_stream_t* stream)
{ {
if (stream != NULL && stream->at_end_func != NULL) if (stream != NULL && stream->at_end_func != NULL)
return stream->at_end_func(stream->cookie); return stream->at_end_func(stream->cookie);
@ -112,7 +112,7 @@ foug_bool_t foug_stream_at_end(foug_stream_t* stream)
* stream->error_func(stream->cookie) * stream->error_func(stream->cookie)
* \endcode * \endcode
*/ */
int foug_stream_error(foug_stream_t* stream) int gmio_stream_error(gmio_stream_t* stream)
{ {
if (stream != NULL && stream->error_func != NULL) if (stream != NULL && stream->error_func != NULL)
return stream->error_func(stream->cookie); return stream->error_func(stream->cookie);
@ -124,7 +124,7 @@ int foug_stream_error(foug_stream_t* stream)
* stream->read_func(stream->cookie) * stream->read_func(stream->cookie)
* \endcode * \endcode
*/ */
size_t foug_stream_read(foug_stream_t* stream, void *ptr, size_t size, size_t count) size_t gmio_stream_read(gmio_stream_t* stream, void *ptr, size_t size, size_t count)
{ {
if (stream != NULL && stream->read_func != NULL) if (stream != NULL && stream->read_func != NULL)
return stream->read_func(stream->cookie, ptr, size, count); return stream->read_func(stream->cookie, ptr, size, count);
@ -136,7 +136,7 @@ size_t foug_stream_read(foug_stream_t* stream, void *ptr, size_t size, size_t co
* stream->write_func(stream->cookie) * stream->write_func(stream->cookie)
* \endcode * \endcode
*/ */
size_t foug_stream_write(foug_stream_t* stream, const void *ptr, size_t size, size_t count) size_t gmio_stream_write(gmio_stream_t* stream, const void *ptr, size_t size, size_t count)
{ {
if (stream != NULL && stream->write_func != NULL) if (stream != NULL && stream->write_func != NULL)
return stream->write_func(stream->cookie, ptr, size, count); return stream->write_func(stream->cookie, ptr, size, count);

View File

@ -1,21 +1,21 @@
#ifndef FOUG_C_STREAM_H #ifndef GMIO_STREAM_H
#define FOUG_C_STREAM_H #define GMIO_STREAM_H
#include "global.h" #include "global.h"
#include <stdio.h> #include <stdio.h>
FOUG_C_LINKAGE_BEGIN GMIO_C_LINKAGE_BEGIN
/*! Stream that can get input from an arbitrary data source or can write output to an arbitrary /*! Stream that can get input from an arbitrary data source or can write output to an arbitrary
* data sink * data sink
*/ */
struct foug_stream struct gmio_stream
{ {
/*! Opaque pointer on the user stream, passed as first argument to hook functions */ /*! Opaque pointer on the user stream, passed as first argument to hook functions */
void* cookie; void* cookie;
/*! Pointer on a function that checks end-of-stream indicator */ /*! Pointer on a function that checks end-of-stream indicator */
foug_bool_t (*at_end_func)(void* cookie); gmio_bool_t (*at_end_func)(void* cookie);
/*! Pointer on a function that checks error indicator */ /*! Pointer on a function that checks error indicator */
int (*error_func)(void* cookie); int (*error_func)(void* cookie);
@ -27,36 +27,36 @@ struct foug_stream
size_t (*write_func)(void* cookie, const void* ptr, size_t size, size_t count); size_t (*write_func)(void* cookie, const void* ptr, size_t size, size_t count);
}; };
typedef struct foug_stream foug_stream_t; typedef struct gmio_stream gmio_stream_t;
/* Initialization */ /* Initialization */
/*! Installs a null stream */ /*! Installs a null stream */
FOUG_LIB_EXPORT void foug_stream_set_null(foug_stream_t* stream); GMIO_LIB_EXPORT void gmio_stream_set_null(gmio_stream_t* stream);
/*! Configures \p stream for standard FILE* (cookie will hold \p file) */ /*! Configures \p stream for standard FILE* (cookie will hold \p file) */
FOUG_LIB_EXPORT void foug_stream_set_stdio(foug_stream_t* stream, FILE* file); GMIO_LIB_EXPORT void gmio_stream_set_stdio(gmio_stream_t* stream, FILE* file);
/* Services */ /* Services */
/*! Safe and convenient function for foug_stream::at_end_func() */ /*! Safe and convenient function for gmio_stream::at_end_func() */
FOUG_LIB_EXPORT foug_bool_t foug_stream_at_end(foug_stream_t* stream); GMIO_LIB_EXPORT gmio_bool_t gmio_stream_at_end(gmio_stream_t* stream);
/*! Safe and convenient function for foug_stream::error_func() */ /*! Safe and convenient function for gmio_stream::error_func() */
FOUG_LIB_EXPORT int foug_stream_error(foug_stream_t* stream); GMIO_LIB_EXPORT int gmio_stream_error(gmio_stream_t* stream);
/*! Safe and convenient function for foug_stream::read_func() */ /*! Safe and convenient function for gmio_stream::read_func() */
FOUG_LIB_EXPORT size_t foug_stream_read(foug_stream_t* stream, GMIO_LIB_EXPORT size_t gmio_stream_read(gmio_stream_t* stream,
void* ptr, void* ptr,
size_t size, size_t size,
size_t count); size_t count);
/*! Safe and convenient function for foug_stream::write_func() */ /*! Safe and convenient function for gmio_stream::write_func() */
FOUG_LIB_EXPORT size_t foug_stream_write(foug_stream_t* stream, GMIO_LIB_EXPORT size_t gmio_stream_write(gmio_stream_t* stream,
const void* ptr, const void* ptr,
size_t size, size_t size,
size_t count); size_t count);
FOUG_C_LINKAGE_END GMIO_C_LINKAGE_END
#endif /* FOUG_C_STREAM_H */ #endif /* GMIO_STREAM_H */

View File

@ -3,11 +3,11 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
/*! \var foug_bool_t (*foug_task_control::handle_progress_func)(void*, uint8_t) /*! \var gmio_bool_t (*gmio_task_control::handle_progress_func)(void*, uint8_t)
* *
* Frequent example of hook functions is update of a UI progress bar * Frequent example of hook functions is update of a UI progress bar
* *
* The return value is important : it is used as an interruption request status. If FOUG_TRUE then * The return value is important : it is used as an interruption request status. If GMIO_TRUE then
* the current task can continue, otherwise it should abort as soon as possible. * the current task can continue, otherwise it should abort as soon as possible.
*/ */
@ -17,7 +17,7 @@
* ctrl->handle_progress_func(ctrl->cookie, progress_pc) * ctrl->handle_progress_func(ctrl->cookie, progress_pc)
* \endcode * \endcode
*/ */
foug_bool_t foug_task_control_handle_progress(foug_task_control_t* ctrl, uint8_t progress_pc) gmio_bool_t gmio_task_control_handle_progress(gmio_task_control_t* ctrl, uint8_t progress_pc)
{ {
if (ctrl != NULL && ctrl->handle_progress_func != NULL) if (ctrl != NULL && ctrl->handle_progress_func != NULL)
return ctrl->handle_progress_func(ctrl->cookie, progress_pc); return ctrl->handle_progress_func(ctrl->cookie, progress_pc);
@ -27,7 +27,7 @@ foug_bool_t foug_task_control_handle_progress(foug_task_control_t* ctrl, uint8_t
/*! \details \p value is assumed to be relative to the interval (range) defined by /*! \details \p value is assumed to be relative to the interval (range) defined by
* [ \p range_min , \p range_max ] * [ \p range_min , \p range_max ]
*/ */
uint8_t foug_percentage(size_t range_min, size_t range_max, size_t value) uint8_t gmio_percentage(size_t range_min, size_t range_max, size_t value)
{ {
if (value >= range_max) if (value >= range_max)
return 100; return 100;

View File

@ -1,33 +1,33 @@
#ifndef FOUG_C_TASK_CONTROL_H #ifndef GMIO_TASK_CONTROL_H
#define FOUG_C_TASK_CONTROL_H #define GMIO_TASK_CONTROL_H
#include "global.h" #include "global.h"
#include "memory.h" #include "memory.h"
FOUG_C_LINKAGE_BEGIN GMIO_C_LINKAGE_BEGIN
/*! Provides control over a general task. /*! Provides control over a general task.
* *
* "Control" here means task progress handling and interruption request (abort). * "Control" here means task progress handling and interruption request (abort).
*/ */
struct foug_task_control struct gmio_task_control
{ {
/*! Opaque pointer on a user task object, passed as first argument to hook functions */ /*! Opaque pointer on a user task object, passed as first argument to hook functions */
void* cookie; void* cookie;
/*! Pointer on a function that that does something with progress value \p progress */ /*! Pointer on a function that that does something with progress value \p progress */
foug_bool_t (*handle_progress_func)(void* cookie, uint8_t progress); gmio_bool_t (*handle_progress_func)(void* cookie, uint8_t progress);
}; };
typedef struct foug_task_control foug_task_control_t; typedef struct gmio_task_control gmio_task_control_t;
/*! Safe and convenient function for foug_task_control::handle_progress_func() */ /*! Safe and convenient function for gmio_task_control::handle_progress_func() */
FOUG_LIB_EXPORT foug_bool_t foug_task_control_handle_progress(foug_task_control_t* ctrl, GMIO_LIB_EXPORT gmio_bool_t gmio_task_control_handle_progress(gmio_task_control_t* ctrl,
uint8_t progress_pc); uint8_t progress_pc);
/*! Utility function that converts \p value as a percentage */ /*! Utility function that converts \p value as a percentage */
FOUG_LIB_EXPORT uint8_t foug_percentage(size_t range_min, size_t range_max, size_t value); GMIO_LIB_EXPORT uint8_t gmio_percentage(size_t range_min, size_t range_max, size_t value);
FOUG_C_LINKAGE_END GMIO_C_LINKAGE_END
#endif /* FOUG_C_TASK_CONTROL_H */ #endif /* GMIO_TASK_CONTROL_H */

View File

@ -1,26 +1,26 @@
#ifndef FOUG_C_TRANSFER_H #ifndef GMIO_TRANSFER_H
#define FOUG_C_TRANSFER_H #define GMIO_TRANSFER_H
#include "global.h" #include "global.h"
#include "stream.h" #include "stream.h"
#include "task_control.h" #include "task_control.h"
/*! Defines data required for any transfer(read/write) operation */ /*! Defines data required for any transfer(read/write) operation */
struct foug_transfer struct gmio_transfer
{ {
/*! The stream to be used for I/O */ /*! The stream to be used for I/O */
foug_stream_t stream; gmio_stream_t stream;
/*! The optional control object used to handle progress of the transfer */ /*! The optional control object used to handle progress of the transfer */
foug_task_control_t task_control; gmio_task_control_t task_control;
/*! Pointer on a user memory area used by the transfer as a buffer for stream optimization */ /*! Pointer on a user memory area used by the transfer as a buffer for stream optimization */
void* buffer; void* buffer;
/*! Size (in bytes) of the buffer memoru */ /*! Size (in bytes) of the memory buffer */
size_t buffer_size; size_t buffer_size;
}; };
typedef struct foug_transfer foug_transfer_t; typedef struct gmio_transfer gmio_transfer_t;
#endif /* FOUG_C_TRANSFER_H */ #endif /* GMIO_TRANSFER_H */

View File

@ -0,0 +1,45 @@
#include "stl_rw_common.h"
#include "../../gmio_core/error.h"
#include "../stl_error.h"
gmio_bool_t gmio_check_transfer(int *error, const gmio_transfer_t* trsf)
{
if (trsf == NULL) {
*error = GMIO_NULL_TRANSFER_ERROR;
}
else {
if (trsf->buffer == NULL)
*error = GMIO_NULL_BUFFER_ERROR;
else if (trsf->buffer_size == 0)
*error = GMIO_INVALID_BUFFER_SIZE_ERROR;
}
return gmio_no_error(*error);
}
gmio_bool_t gmio_stl_check_geom(int *error, const gmio_stl_geom_t* geom)
{
if (geom == NULL
|| (geom->triangle_count > 0 && geom->get_triangle_func == NULL))
{
*error = GMIO_STL_WRITE_NULL_GET_TRIANGLE_FUNC_ERROR;
}
return gmio_no_error(*error);
}
gmio_bool_t gmio_stlb_check_params(int *error,
const gmio_transfer_t *trsf,
gmio_endianness_t byte_order)
{
if (!gmio_check_transfer(error, trsf))
return GMIO_FALSE;
if (trsf->buffer_size < GMIO_STLB_MIN_CONTENTS_SIZE)
*error = GMIO_INVALID_BUFFER_SIZE_ERROR;
if (byte_order != GMIO_LITTLE_ENDIAN && byte_order != GMIO_BIG_ENDIAN)
*error = GMIO_STLB_UNSUPPORTED_BYTE_ORDER_ERROR;
return gmio_no_error(*error);
}

View File

@ -0,0 +1,25 @@
#ifndef GMIO_INTERNAL_STL_RW_COMMON_H
#define GMIO_INTERNAL_STL_RW_COMMON_H
#include "../../gmio_core/global.h"
#include "../../gmio_core/endian.h"
#include "../../gmio_core/transfer.h"
#include "../stl_geom.h"
#include "../stl_triangle.h"
typedef struct
{
uint32_t facet_count;
uint32_t i_facet_offset;
void (*fix_endian_func)(gmio_stl_triangle_t*);
} gmio_stlb_readwrite_helper;
gmio_bool_t gmio_check_transfer(int* error, const gmio_transfer_t* trsf);
gmio_bool_t gmio_stl_check_geom(int* error, const gmio_stl_geom_t* geom);
gmio_bool_t gmio_stlb_check_params(int* error,
const gmio_transfer_t* trsf,
gmio_endianness_t byte_order);
#endif /* GMIO_INTERNAL_STLB_RW_COMMON_H */

View File

@ -0,0 +1,14 @@
#include "stlb_byte_swap.h"
#include "../../gmio_core/internal/byte_swap.h"
void gmio_stl_triangle_bswap(gmio_stl_triangle_t* triangle)
{
int i;
uint32_t* uintcoord_ptr = (uint32_t*)&(triangle->normal.x);
for (i = 0; i < 12; ++i)
*(uintcoord_ptr + i) = gmio_uint32_bswap(*(uintcoord_ptr + i));
if (triangle->attribute_byte_count != 0)
triangle->attribute_byte_count = gmio_uint16_bswap(triangle->attribute_byte_count);
}

View File

@ -0,0 +1,9 @@
#ifndef GMIO_INTERNAL_STLB_BYTE_SWAP_H
#define GMIO_INTERNAL_STLB_BYTE_SWAP_H
#include "../../gmio_core/global.h"
#include "../stl_triangle.h"
void gmio_stl_triangle_bswap(gmio_stl_triangle_t* triangle);
#endif /* GMIO_INTERNAL_STLB_BYTE_SWAP_H */

35
src/gmio_stl/stl_error.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef GMIO_LIBSTL_STL_ERROR_H
#define GMIO_LIBSTL_STL_ERROR_H
/*! A byte-mask to tag(identify) STL-specific error codes */
#define GMIO_STL_ERROR_TAG 0x11000000
/*! This enum defines the various error codes reported by STL read/write functions */
enum gmio_stl_error
{
/*! Common STL write error indicating gmio_stl_geom::get_triangle_func() pointer is NULL */
GMIO_STL_WRITE_NULL_GET_TRIANGLE_FUNC_ERROR = GMIO_STL_ERROR_TAG + 1,
/* Specific error codes returned by STL_ascii read function */
/*! Parsing error occured in gmio_stla_read() due to malformed STL ascii input */
GMIO_STLA_READ_PARSE_ERROR = GMIO_STL_ERROR_TAG + 100,
/*! Invalid max number of decimal significants digits for gmio_stla_write(), must be in [1..9] */
GMIO_STLA_WRITE_INVALID_REAL32_PREC_ERROR = GMIO_STL_ERROR_TAG + 101,
/* Specific error codes returned by STL_binary read/write functions */
/*! The byte order argument supplied is not supported, must be little or big endian */
GMIO_STLB_UNSUPPORTED_BYTE_ORDER_ERROR = GMIO_STL_ERROR_TAG + 300,
/*! Error occured when reading header data in gmio_stlb_read() */
GMIO_STLB_READ_HEADER_WRONG_SIZE_ERROR = GMIO_STL_ERROR_TAG + 301,
/*! Error occured when reading facet count in gmio_stlb_read() */
GMIO_STLB_READ_FACET_COUNT_ERROR = GMIO_STL_ERROR_TAG + 302
};
typedef enum gmio_stl_error gmio_stl_error_t;
#endif /* GMIO_LIBSTL_STL_ERROR_H */

View File

@ -2,14 +2,14 @@
#include "stl_triangle.h" #include "stl_triangle.h"
#include "../datax_core/endian.h" #include "../gmio_core/endian.h"
#include "../datax_core/internal/byte_codec.h" #include "../gmio_core/internal/byte_codec.h"
#include "../datax_core/internal/byte_swap.h" #include "../gmio_core/internal/byte_swap.h"
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#define _INTERNAL_FOUG_FIXED_BUFFER_SIZE 512 #define _INTERNAL_GMIO_FIXED_BUFFER_SIZE 512
/*! \brief Returns the format of the STL data in \p stream /*! \brief Returns the format of the STL data in \p stream
* *
@ -19,34 +19,34 @@
* Parameter \p data_size must provide the total size (in bytes) of the stream data (e.g. file * Parameter \p data_size must provide the total size (in bytes) of the stream data (e.g. file
* size), it is required to guess endianness in case of binary format. * size), it is required to guess endianness in case of binary format.
* *
* Returns FOUG_STL_UNKNOWN_FORMAT in case of error. * Returns GMIO_STL_UNKNOWN_FORMAT in case of error.
*/ */
foug_stl_format_t foug_stl_get_format(foug_stream_t *stream, size_t data_size) gmio_stl_format_t gmio_stl_get_format(gmio_stream_t *stream, size_t data_size)
{ {
char fixed_buffer[_INTERNAL_FOUG_FIXED_BUFFER_SIZE]; char fixed_buffer[_INTERNAL_GMIO_FIXED_BUFFER_SIZE];
size_t read_size = 0; size_t read_size = 0;
if (stream == NULL || data_size == 0) if (stream == NULL || data_size == 0)
return FOUG_STL_UNKNOWN_FORMAT; return GMIO_STL_UNKNOWN_FORMAT;
/* Read a chunk of bytes from stream, then try to find format from that */ /* Read a chunk of bytes from stream, then try to find format from that */
memset(fixed_buffer, 0, _INTERNAL_FOUG_FIXED_BUFFER_SIZE); memset(fixed_buffer, 0, _INTERNAL_GMIO_FIXED_BUFFER_SIZE);
read_size = foug_stream_read(stream, &fixed_buffer, 1, _INTERNAL_FOUG_FIXED_BUFFER_SIZE); read_size = gmio_stream_read(stream, &fixed_buffer, 1, _INTERNAL_GMIO_FIXED_BUFFER_SIZE);
read_size = read_size < _INTERNAL_FOUG_FIXED_BUFFER_SIZE ? read_size : read_size = read_size < _INTERNAL_GMIO_FIXED_BUFFER_SIZE ? read_size :
_INTERNAL_FOUG_FIXED_BUFFER_SIZE; _INTERNAL_GMIO_FIXED_BUFFER_SIZE;
/* Binary STL ? */ /* Binary STL ? */
if (read_size >= (FOUG_STLB_HEADER_SIZE + 4)) { if (read_size >= (GMIO_STLB_HEADER_SIZE + 4)) {
/* Try with little-endian format */ /* Try with little-endian format */
uint32_t facet_count = foug_decode_uint32_le((const uint8_t*)fixed_buffer + 80); uint32_t facet_count = gmio_decode_uint32_le((const uint8_t*)fixed_buffer + 80);
if ((FOUG_STLB_HEADER_SIZE + 4 + facet_count*FOUG_STLB_TRIANGLE_RAWSIZE) == data_size) if ((GMIO_STLB_HEADER_SIZE + 4 + facet_count*GMIO_STLB_TRIANGLE_RAWSIZE) == data_size)
return FOUG_STL_BINARY_LE_FORMAT; return GMIO_STL_BINARY_LE_FORMAT;
/* Try with byte-reverted facet count */ /* Try with byte-reverted facet count */
facet_count = foug_uint32_bswap(facet_count); facet_count = gmio_uint32_bswap(facet_count);
if ((FOUG_STLB_HEADER_SIZE + 4 + facet_count*FOUG_STLB_TRIANGLE_RAWSIZE) == data_size) if ((GMIO_STLB_HEADER_SIZE + 4 + facet_count*GMIO_STLB_TRIANGLE_RAWSIZE) == data_size)
return FOUG_STL_BINARY_BE_FORMAT; return GMIO_STL_BINARY_BE_FORMAT;
} }
/* ASCII STL ? */ /* ASCII STL ? */
@ -57,13 +57,13 @@ foug_stl_format_t foug_stl_get_format(foug_stream_t *stream, size_t data_size)
++pos; ++pos;
/* Next token (if exists) must match "solid " */ /* Next token (if exists) must match "solid " */
if (pos < _INTERNAL_FOUG_FIXED_BUFFER_SIZE if (pos < _INTERNAL_GMIO_FIXED_BUFFER_SIZE
&& strncmp(fixed_buffer + pos, "solid ", 6) == 0) && strncmp(fixed_buffer + pos, "solid ", 6) == 0)
{ {
return FOUG_STL_ASCII_FORMAT; return GMIO_STL_ASCII_FORMAT;
} }
} }
/* Fallback case */ /* Fallback case */
return FOUG_STL_UNKNOWN_FORMAT; return GMIO_STL_UNKNOWN_FORMAT;
} }

25
src/gmio_stl/stl_format.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef GMIO_LIBSTL_FORMAT_H
#define GMIO_LIBSTL_FORMAT_H
#include "stl_global.h"
#include "../gmio_core/stream.h"
GMIO_C_LINKAGE_BEGIN
/*! This enums defines the various STL formats */
enum gmio_stl_format
{
GMIO_STL_ASCII_FORMAT, /*!< STL ASCII (text) */
GMIO_STL_BINARY_LE_FORMAT, /*!< STL binary (little-endian) */
GMIO_STL_BINARY_BE_FORMAT, /*!< STL binary (big-endian) */
GMIO_STL_UNKNOWN_FORMAT
};
typedef enum gmio_stl_format gmio_stl_format_t;
GMIO_LIBSTL_EXPORT
gmio_stl_format_t gmio_stl_get_format(gmio_stream_t* stream, size_t data_size);
GMIO_C_LINKAGE_END
#endif /* GMIO_LIBSTL_FORMAT_H */

View File

@ -1,11 +1,11 @@
#ifndef FOUG_LIBSTL_STL_GEOM_H #ifndef GMIO_LIBSTL_STL_GEOM_H
#define FOUG_LIBSTL_STL_GEOM_H #define GMIO_LIBSTL_STL_GEOM_H
#include "stl_global.h" #include "stl_global.h"
#include "stl_triangle.h" #include "stl_triangle.h"
/*! Provides an interface for accessing the underlying(hidden) user mesh */ /*! Provides an interface for accessing the underlying(hidden) user mesh */
struct foug_stl_geom struct gmio_stl_geom
{ {
/*! Opaque pointer on the user mesh, passed as first argument to hook functions */ /*! Opaque pointer on the user mesh, passed as first argument to hook functions */
const void* cookie; const void* cookie;
@ -14,9 +14,9 @@ struct foug_stl_geom
uint32_t triangle_count; uint32_t triangle_count;
/*! Pointer on a function that stores the mesh triangle of index \p tri_id into \p triangle */ /*! Pointer on a function that stores the mesh triangle of index \p tri_id into \p triangle */
void (*get_triangle_func)(const void* cookie, uint32_t tri_id, foug_stl_triangle_t* triangle); void (*get_triangle_func)(const void* cookie, uint32_t tri_id, gmio_stl_triangle_t* triangle);
}; };
typedef struct foug_stl_geom foug_stl_geom_t; typedef struct gmio_stl_geom gmio_stl_geom_t;
#endif /* FOUG_LIBSTL_STL_GEOM_H */ #endif /* GMIO_LIBSTL_STL_GEOM_H */

View File

@ -1,11 +1,11 @@
#ifndef FOUG_LIBSTL_STL_GEOM_CREATOR_H #ifndef GMIO_LIBSTL_STL_GEOM_CREATOR_H
#define FOUG_LIBSTL_STL_GEOM_CREATOR_H #define GMIO_LIBSTL_STL_GEOM_CREATOR_H
#include "stl_global.h" #include "stl_global.h"
#include "stl_triangle.h" #include "stl_triangle.h"
/*! Provides an interface for the creation of the underlying(hidden) user mesh */ /*! Provides an interface for the creation of the underlying(hidden) user mesh */
struct foug_stl_geom_creator struct gmio_stl_geom_creator
{ {
/*! Opaque pointer on the user mesh, passed as first argument to hook functions */ /*! Opaque pointer on the user mesh, passed as first argument to hook functions */
void* cookie; void* cookie;
@ -14,13 +14,13 @@ struct foug_stl_geom_creator
/*! Pointer on a function that handles declaration of a solid of name \p solid_name . /*! Pointer on a function that handles declaration of a solid of name \p solid_name .
* *
* This optional function is useful only with STL ascii (ie. foug_stla_read()) * This optional function is useful only with STL ascii (ie. gmio_stla_read())
*/ */
void (*ascii_begin_solid_func)(void* cookie, const char* solid_name); void (*ascii_begin_solid_func)(void* cookie, const char* solid_name);
/*! Pointer on a function that handles declaration of a mesh with \p tri_count number of triangles. /*! Pointer on a function that handles declaration of a mesh with \p tri_count number of triangles.
* *
* This optional function is useful only with STL binary (ie. foug_stlb_read()). * This optional function is useful only with STL binary (ie. gmio_stlb_read()).
* *
* The argument \p header contains the header data(80 bytes) * The argument \p header contains the header data(80 bytes)
*/ */
@ -29,11 +29,11 @@ struct foug_stl_geom_creator
/*! Pointer on a function that adds a triangle to the user mesh. /*! Pointer on a function that adds a triangle to the user mesh.
* *
* The argument \p triangle is the triangle to be added, note that * The argument \p triangle is the triangle to be added, note that
* foug_stl_triangle_t::attribute_byte_count is meaningless for STL ascii. * gmio_stl_triangle_t::attribute_byte_count is meaningless for STL ascii.
* *
* The argument \p tri_id is the index of the mesh triangle * The argument \p tri_id is the index of the mesh triangle
*/ */
void (*add_triangle_func)(void* cookie, uint32_t tri_id, const foug_stl_triangle_t* triangle); void (*add_triangle_func)(void* cookie, uint32_t tri_id, const gmio_stl_triangle_t* triangle);
/*! Pointer on a function that finalizes creation of the user mesh. /*! Pointer on a function that finalizes creation of the user mesh.
* *
@ -43,6 +43,6 @@ struct foug_stl_geom_creator
void (*end_solid_func)(void* cookie); void (*end_solid_func)(void* cookie);
}; };
typedef struct foug_stl_geom_creator foug_stl_geom_creator_t; typedef struct gmio_stl_geom_creator gmio_stl_geom_creator_t;
#endif /* FOUG_LIBSTL_STL_GEOM_CREATOR_H */ #endif /* GMIO_LIBSTL_STL_GEOM_CREATOR_H */

20
src/gmio_stl/stl_global.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef GMIO_LIBSTL_GLOBAL_H
#define GMIO_LIBSTL_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
# define GMIO_LIBSTL_EXPORT
#endif /* GMIO_LIBSTL_DLL */
/* STLB */
#define GMIO_STLB_HEADER_SIZE 80
#define GMIO_STLB_MIN_CONTENTS_SIZE 284
#endif /* GMIO_LIBSTL_GLOBAL_H */

44
src/gmio_stl/stl_io.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef GMIO_LIBSTL_STL_IO_H
#define GMIO_LIBSTL_STL_IO_H
#include "stl_global.h"
#include "stl_geom.h"
#include "stl_geom_creator.h"
#include "../gmio_core/endian.h"
#include "../gmio_core/transfer.h"
GMIO_C_LINKAGE_BEGIN
/*
* STL ascii
*/
/*! Read geometry from STL ascii stream */
GMIO_LIBSTL_EXPORT int gmio_stla_read(gmio_stl_geom_creator_t* creator,
gmio_transfer_t* trsf,
size_t data_size_hint);
/*! Write geometry in the STL ascii format */
GMIO_LIBSTL_EXPORT int gmio_stla_write(const gmio_stl_geom_t* geom,
gmio_transfer_t* trsf,
const char* solid_name,
uint8_t real32_prec);
/*
* STL binary
*/
/*! Read geometry from STL binary stream */
GMIO_LIBSTL_EXPORT int gmio_stlb_read(gmio_stl_geom_creator_t* creator,
gmio_transfer_t* trsf,
gmio_endianness_t byte_order);
/*! Write geometry in the STL binary format */
GMIO_LIBSTL_EXPORT int gmio_stlb_write(const gmio_stl_geom_t* geom,
gmio_transfer_t* trsf,
const uint8_t* header_data,
gmio_endianness_t byte_order);
GMIO_C_LINKAGE_END
#endif /* GMIO_LIBSTL_STL_IO_H */

View File

@ -0,0 +1,37 @@
#ifndef GMIO_LIBSTL_TRIANGLE_H
#define GMIO_LIBSTL_TRIANGLE_H
#include "stl_global.h"
/*! Cartesian coordinate entity in 3D space, specifically tailored for STL needs (single-float) */
struct gmio_stl_coords
{
gmio_real32_t x;
gmio_real32_t y;
gmio_real32_t z;
};
typedef struct gmio_stl_coords gmio_stl_coords_t;
/*! STL mesh triangle defined three geometric vertices and an orientation(normal) */
struct gmio_stl_triangle
{
gmio_stl_coords_t normal;
gmio_stl_coords_t v1;
gmio_stl_coords_t v2;
gmio_stl_coords_t v3;
uint16_t attribute_byte_count; /*!< Useful only for STL binary format */
};
typedef struct gmio_stl_triangle gmio_stl_triangle_t;
/*! Compact size of a gmio_stl_coords_t object */
#define GMIO_STL_COORDS_RAWSIZE (3 * sizeof(gmio_real32_t))
/*! Compact size of a gmio_stl_triangle_t object for STL ascii format */
#define GMIO_STLA_TRIANGLE_RAWSIZE (4 * GMIO_STL_COORDS_RAWSIZE)
/*! Compact size of a gmio_stl_triangle_t object for STL binary format */
#define GMIO_STLB_TRIANGLE_RAWSIZE (GMIO_STLA_TRIANGLE_RAWSIZE + sizeof(uint16_t))
#endif /* GMIO_LIBSTL_TRIANGLE_H */

View File

@ -3,8 +3,8 @@
#include "stl_error.h" #include "stl_error.h"
#include "internal/stl_rw_common.h" #include "internal/stl_rw_common.h"
#include "../datax_core/error.h" #include "../gmio_core/error.h"
#include "../datax_core/internal/ascii_parse.h" #include "../gmio_core/internal/ascii_parse.h"
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
@ -58,16 +58,16 @@
* *
*/ */
/* foug_stream_fwd_iterator_stla_cookie */ /* gmio_stream_fwd_iterator_stla_cookie */
typedef struct typedef struct
{ {
foug_task_control_t* task_control; gmio_task_control_t* task_control;
size_t stream_data_size; size_t stream_data_size;
size_t stream_offset; size_t stream_offset;
foug_bool_t is_stop_requested; gmio_bool_t is_stop_requested;
} _internal_foug_fwd_iterator_cookie_t; } _internal_gmio_fwd_iterator_cookie_t;
/* foug_stla_token */ /* gmio_stla_token */
typedef enum typedef enum
{ {
ENDFACET_token, ENDFACET_token,
@ -83,60 +83,60 @@ typedef enum
VERTEX_token, VERTEX_token,
empty_token, empty_token,
unknown_token unknown_token
} foug_stla_token_t; } gmio_stla_token_t;
/* foug_stla_parse_data */ /* gmio_stla_parse_data */
typedef struct typedef struct
{ {
foug_stla_token_t token; gmio_stla_token_t token;
foug_bool_t error; gmio_bool_t error;
foug_ascii_stream_fwd_iterator_t stream_iterator; gmio_ascii_stream_fwd_iterator_t stream_iterator;
_internal_foug_fwd_iterator_cookie_t stream_iterator_cookie; _internal_gmio_fwd_iterator_cookie_t stream_iterator_cookie;
foug_ascii_string_buffer_t string_buffer; gmio_ascii_string_buffer_t string_buffer;
foug_stl_geom_creator_t* creator; gmio_stl_geom_creator_t* creator;
} foug_stla_parse_data_t; } gmio_stla_parse_data_t;
static void foug_stream_fwd_iterator_stla_read_hook(void* cookie, static void gmio_stream_fwd_iterator_stla_read_hook(void* cookie,
const foug_ascii_string_buffer_t* buffer) const gmio_ascii_string_buffer_t* buffer)
{ {
_internal_foug_fwd_iterator_cookie_t* tcookie = (_internal_foug_fwd_iterator_cookie_t*)(cookie); _internal_gmio_fwd_iterator_cookie_t* tcookie = (_internal_gmio_fwd_iterator_cookie_t*)(cookie);
foug_task_control_t* ctrl = tcookie != NULL ? tcookie->task_control : NULL; gmio_task_control_t* ctrl = tcookie != NULL ? tcookie->task_control : NULL;
if (ctrl != NULL) { if (ctrl != NULL) {
const uint8_t progress_pc = foug_percentage(0, tcookie->stream_data_size, tcookie->stream_offset); const uint8_t progress_pc = gmio_percentage(0, tcookie->stream_data_size, tcookie->stream_offset);
tcookie->is_stop_requested = !foug_task_control_handle_progress(ctrl, progress_pc); tcookie->is_stop_requested = !gmio_task_control_handle_progress(ctrl, progress_pc);
} }
if (tcookie != NULL) if (tcookie != NULL)
tcookie->stream_offset += buffer->len; tcookie->stream_offset += buffer->len;
} }
FOUG_INLINE static foug_bool_t parsing_can_continue(const foug_stla_parse_data_t* data) GMIO_INLINE static gmio_bool_t parsing_can_continue(const gmio_stla_parse_data_t* data)
{ {
if (data->error || data->stream_iterator_cookie.is_stop_requested) if (data->error || data->stream_iterator_cookie.is_stop_requested)
return 0; return 0;
return 1; return 1;
} }
FOUG_INLINE static const char* current_token_as_identifier(const foug_stla_parse_data_t* data) GMIO_INLINE static const char* current_token_as_identifier(const gmio_stla_parse_data_t* data)
{ {
return data->token == ID_token ? data->string_buffer.ptr : ""; return data->token == ID_token ? data->string_buffer.ptr : "";
} }
FOUG_INLINE static int get_current_token_as_real32(const foug_stla_parse_data_t* data, GMIO_INLINE static int get_current_token_as_real32(const gmio_stla_parse_data_t* data,
foug_real32_t* value_ptr) gmio_real32_t* value_ptr)
{ {
if (data->token == FLOAT_token) if (data->token == FLOAT_token)
return foug_get_real32(data->string_buffer.ptr, value_ptr); return gmio_get_real32(data->string_buffer.ptr, value_ptr);
return -3; return -3;
} }
FOUG_INLINE static void parsing_error(foug_stla_parse_data_t* data) GMIO_INLINE static void parsing_error(gmio_stla_parse_data_t* data)
{ {
data->error = 1; data->error = 1;
data->token = unknown_token; data->token = unknown_token;
printf("parsing_error, token: %s\n", data->string_buffer.ptr); printf("parsing_error, token: %s\n", data->string_buffer.ptr);
} }
static foug_stla_token_t parsing_find_token(const foug_ascii_string_buffer_t* str_buffer) static gmio_stla_token_t parsing_find_token(const gmio_ascii_string_buffer_t* str_buffer)
{ {
const char* word = str_buffer->ptr; const char* word = str_buffer->ptr;
const size_t word_len = str_buffer->len; const size_t word_len = str_buffer->len;
@ -204,12 +204,12 @@ static foug_stla_token_t parsing_find_token(const foug_ascii_string_buffer_t* st
return ID_token; return ID_token;
} }
static void parsing_advance(foug_stla_parse_data_t* data) static void parsing_advance(gmio_stla_parse_data_t* data)
{ {
if (!parsing_can_continue(data)) if (!parsing_can_continue(data))
return; return;
if (foug_eat_word(&data->stream_iterator, &data->string_buffer) == 0) if (gmio_eat_word(&data->stream_iterator, &data->string_buffer) == 0)
data->token = parsing_find_token(&data->string_buffer); data->token = parsing_find_token(&data->string_buffer);
else else
data->token = unknown_token; data->token = unknown_token;
@ -218,7 +218,7 @@ static void parsing_advance(foug_stla_parse_data_t* data)
parsing_error(data); parsing_error(data);
} }
static void parsing_eat_token(foug_stla_token_t token, foug_stla_parse_data_t* data) static void parsing_eat_token(gmio_stla_token_t token, gmio_stla_parse_data_t* data)
{ {
if (!parsing_can_continue(data)) if (!parsing_can_continue(data))
return; return;
@ -229,7 +229,7 @@ static void parsing_eat_token(foug_stla_token_t token, foug_stla_parse_data_t* d
parsing_error(data); parsing_error(data);
} }
static void parse_solidname_beg(foug_stla_parse_data_t* data) static void parse_solidname_beg(gmio_stla_parse_data_t* data)
{ {
if (!parsing_can_continue(data)) if (!parsing_can_continue(data))
return; return;
@ -244,7 +244,7 @@ static void parse_solidname_beg(foug_stla_parse_data_t* data)
} }
} }
static void parse_solidname_end(foug_stla_parse_data_t* data) static void parse_solidname_end(gmio_stla_parse_data_t* data)
{ {
if (!parsing_can_continue(data)) if (!parsing_can_continue(data))
return; return;
@ -259,7 +259,7 @@ static void parse_solidname_end(foug_stla_parse_data_t* data)
} }
} }
static void parse_beginsolid(foug_stla_parse_data_t* data) static void parse_beginsolid(gmio_stla_parse_data_t* data)
{ {
if (!parsing_can_continue(data)) if (!parsing_can_continue(data))
return; return;
@ -284,7 +284,7 @@ static void parse_beginsolid(foug_stla_parse_data_t* data)
} /* end switch */ } /* end switch */
} }
static void parse_endsolid(foug_stla_parse_data_t* data) static void parse_endsolid(gmio_stla_parse_data_t* data)
{ {
if (!parsing_can_continue(data)) if (!parsing_can_continue(data))
return; return;
@ -308,7 +308,7 @@ static void parse_endsolid(foug_stla_parse_data_t* data)
} /* end switch */ } /* end switch */
} }
static void parse_xyz_coords(foug_stla_parse_data_t* data, foug_stl_coords_t* coords) static void parse_xyz_coords(gmio_stla_parse_data_t* data, gmio_stl_coords_t* coords)
{ {
if (!parsing_can_continue(data)) if (!parsing_can_continue(data))
return; return;
@ -331,7 +331,7 @@ static void parse_xyz_coords(foug_stla_parse_data_t* data, foug_stl_coords_t* co
} /* end switch */ } /* end switch */
} }
static void parse_facet(foug_stla_parse_data_t* data, foug_stl_triangle_t* facet) static void parse_facet(gmio_stla_parse_data_t* data, gmio_stl_triangle_t* facet)
{ {
parsing_eat_token(FACET_token, data); parsing_eat_token(FACET_token, data);
parsing_eat_token(NORMAL_token, data); parsing_eat_token(NORMAL_token, data);
@ -351,10 +351,10 @@ static void parse_facet(foug_stla_parse_data_t* data, foug_stl_triangle_t* facet
parsing_eat_token(ENDFACET_token, data); parsing_eat_token(ENDFACET_token, data);
} }
static void parse_facets(foug_stla_parse_data_t* data) static void parse_facets(gmio_stla_parse_data_t* data)
{ {
uint32_t i_facet_offset = 0; uint32_t i_facet_offset = 0;
foug_stl_triangle_t facet; gmio_stl_triangle_t facet;
while (data->token == FACET_token && parsing_can_continue(data)) { while (data->token == FACET_token && parsing_can_continue(data)) {
parse_facet(data, &facet); parse_facet(data, &facet);
@ -364,7 +364,7 @@ static void parse_facets(foug_stla_parse_data_t* data)
} }
} }
static void parse_solid(foug_stla_parse_data_t* data) static void parse_solid(gmio_stla_parse_data_t* data)
{ {
if (!parsing_can_continue(data)) if (!parsing_can_continue(data))
return; return;
@ -379,18 +379,18 @@ static void parse_solid(foug_stla_parse_data_t* data)
} }
} }
#define FOUG_STLA_READ_STRING_BUFFER_LEN 512 #define GMIO_STLA_READ_STRING_BUFFER_LEN 512
int foug_stla_read(foug_stl_geom_creator_t *creator, int gmio_stla_read(gmio_stl_geom_creator_t *creator,
foug_transfer_t *trsf, gmio_transfer_t *trsf,
size_t data_size_hint) size_t data_size_hint)
{ {
char fixed_buffer[FOUG_STLA_READ_STRING_BUFFER_LEN]; char fixed_buffer[GMIO_STLA_READ_STRING_BUFFER_LEN];
foug_stla_parse_data_t parse_data; gmio_stla_parse_data_t parse_data;
{ /* Check validity of input parameters */ { /* Check validity of input parameters */
int error = FOUG_DATAX_NO_ERROR; int error = GMIO_NO_ERROR;
if (!foug_check_transfer(&error, trsf)) if (!gmio_check_transfer(&error, trsf))
return error; return error;
} }
@ -406,12 +406,12 @@ int foug_stla_read(foug_stl_geom_creator_t *creator,
parse_data.stream_iterator.buffer.ptr = trsf->buffer; parse_data.stream_iterator.buffer.ptr = trsf->buffer;
parse_data.stream_iterator.buffer.max_len = trsf->buffer_size; parse_data.stream_iterator.buffer.max_len = trsf->buffer_size;
parse_data.stream_iterator.cookie = &parse_data.stream_iterator_cookie; parse_data.stream_iterator.cookie = &parse_data.stream_iterator_cookie;
parse_data.stream_iterator.stream_read_hook = foug_stream_fwd_iterator_stla_read_hook; parse_data.stream_iterator.stream_read_hook = gmio_stream_fwd_iterator_stla_read_hook;
foug_ascii_stream_fwd_iterator_init(&parse_data.stream_iterator); gmio_ascii_stream_fwd_iterator_init(&parse_data.stream_iterator);
parse_data.string_buffer.ptr = &fixed_buffer[0]; parse_data.string_buffer.ptr = &fixed_buffer[0];
parse_data.string_buffer.len = 0; parse_data.string_buffer.len = 0;
parse_data.string_buffer.max_len = FOUG_STLA_READ_STRING_BUFFER_LEN; parse_data.string_buffer.max_len = GMIO_STLA_READ_STRING_BUFFER_LEN;
parse_data.creator = creator; parse_data.creator = creator;
@ -419,7 +419,7 @@ int foug_stla_read(foug_stl_geom_creator_t *creator,
parse_solid(&parse_data); parse_solid(&parse_data);
if (parse_data.error) if (parse_data.error)
return FOUG_STLA_READ_PARSE_ERROR; return GMIO_STLA_READ_PARSE_ERROR;
return parse_data.stream_iterator_cookie.is_stop_requested ? FOUG_DATAX_TASK_STOPPED_ERROR : return parse_data.stream_iterator_cookie.is_stop_requested ? GMIO_TASK_STOPPED_ERROR :
FOUG_DATAX_NO_ERROR; GMIO_NO_ERROR;
} }

View File

@ -3,7 +3,7 @@
#include "internal/stl_rw_common.h" #include "internal/stl_rw_common.h"
#include "stl_error.h" #include "stl_error.h"
#include "../datax_core/error.h" #include "../gmio_core/error.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -26,18 +26,18 @@
* Total with EOL(2 chars) = 307 + 7*2 = 321 * Total with EOL(2 chars) = 307 + 7*2 = 321
*/ */
#define FOUG_STLA_FACET_SIZE 321 #define GMIO_STLA_FACET_SIZE 321
#define FOUG_STLA_FACET_SIZE_P2 512 #define GMIO_STLA_FACET_SIZE_P2 512
#define FOUG_STLA_SOLID_NAME_MAX_LEN 512 #define GMIO_STLA_SOLID_NAME_MAX_LEN 512
static char* foug_write_string(char* buffer, const char* str) static char* gmio_write_string(char* buffer, const char* str)
{ {
const char* safe_str = str != NULL ? str : ""; const char* safe_str = str != NULL ? str : "";
strcpy(buffer, safe_str); strcpy(buffer, safe_str);
return buffer + strlen(safe_str); return buffer + strlen(safe_str);
} }
static char* foug_write_string_eol(char* buffer, const char* str) static char* gmio_write_string_eol(char* buffer, const char* str)
{ {
const char* safe_str = str != NULL ? str : ""; const char* safe_str = str != NULL ? str : "";
const size_t len = strlen(safe_str); const size_t len = strlen(safe_str);
@ -46,19 +46,19 @@ static char* foug_write_string_eol(char* buffer, const char* str)
return buffer + len + 1; return buffer + len + 1;
} }
static char* foug_write_eol(char* buffer) static char* gmio_write_eol(char* buffer)
{ {
*buffer = '\n'; *buffer = '\n';
return buffer + 1; return buffer + 1;
} }
/*static char* foug_write_space(char* buffer) /*static char* gmio_write_space(char* buffer)
{ {
*buffer = ' '; *buffer = ' ';
return buffer + 1; return buffer + 1;
}*/ }*/
static char* foug_write_nspaces(char* buffer, int n) static char* gmio_write_nspaces(char* buffer, int n)
{ {
const int offset = n; const int offset = n;
while (n > 0) while (n > 0)
@ -66,7 +66,7 @@ static char* foug_write_nspaces(char* buffer, int n)
return buffer + offset; return buffer + offset;
} }
static char* foug_write_stdio_format(char* buffer, uint8_t prec) static char* gmio_write_stdio_format(char* buffer, uint8_t prec)
{ {
int prec_len = 0; int prec_len = 0;
@ -77,26 +77,26 @@ static char* foug_write_stdio_format(char* buffer, uint8_t prec)
return buffer + 3 + prec_len; return buffer + 3 + prec_len;
} }
/*static char* foug_write_real32_string(char* buffer, const char* format, foug_real32_t val) /*static char* gmio_write_real32_string(char* buffer, const char* format, gmio_real32_t val)
{ {
return buffer + sprintf(buffer, format, val); return buffer + sprintf(buffer, format, val);
}*/ }*/
static char* foug_write_coords(char* buffer, static char* gmio_write_coords(char* buffer,
const char* coords_format, const char* coords_format,
const foug_stl_coords_t* coords) const gmio_stl_coords_t* coords)
{ {
return buffer + sprintf(buffer, coords_format, coords->x, coords->y, coords->z); return buffer + sprintf(buffer, coords_format, coords->x, coords->y, coords->z);
} }
static foug_bool_t foug_transfer_flush_buffer(foug_transfer_t* trsf, size_t n) static gmio_bool_t gmio_transfer_flush_buffer(gmio_transfer_t* trsf, size_t n)
{ {
return foug_stream_write(&trsf->stream, trsf->buffer, sizeof(char), n) == n; return gmio_stream_write(&trsf->stream, trsf->buffer, sizeof(char), n) == n;
} }
#define _FOUG_INTERNAL_MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2)) #define _GMIO_INTERNAL_MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2))
/*! \fn int foug_stla_write(foug_stl_geom_t*, foug_transfer_t*, const char*, uint8_t) /*! \fn int gmio_stla_write(gmio_stl_geom_t*, gmio_transfer_t*, const char*, uint8_t)
* *
* \param geom Defines the custom geometry to write * \param geom Defines the custom geometry to write
* \param trsf Defines needed objects (stream, buffer, ...) for the writing operation * \param trsf Defines needed objects (stream, buffer, ...) for the writing operation
@ -105,102 +105,102 @@ static foug_bool_t foug_transfer_flush_buffer(foug_transfer_t* trsf, size_t n)
* *
* \return Error code * \return Error code
* *
* \retval FOUG_DATAX_NO_ERROR If operation successful * \retval GMIO_NO_ERROR If operation successful
*/ */
int foug_stla_write(const foug_stl_geom_t* geom, int gmio_stla_write(const gmio_stl_geom_t* geom,
foug_transfer_t* trsf, gmio_transfer_t* trsf,
const char* solid_name, const char* solid_name,
uint8_t real32_prec) uint8_t real32_prec)
{ {
const uint32_t total_facet_count = geom != NULL ? geom->triangle_count : 0; const uint32_t total_facet_count = geom != NULL ? geom->triangle_count : 0;
uint32_t written_facet_count = 0; uint32_t written_facet_count = 0;
const uint32_t buffer_facet_count = trsf != NULL ? trsf->buffer_size / FOUG_STLA_FACET_SIZE_P2 : 0; const uint32_t buffer_facet_count = trsf != NULL ? trsf->buffer_size / GMIO_STLA_FACET_SIZE_P2 : 0;
uint32_t ifacet = 0; uint32_t ifacet = 0;
char* buffer_iterator = trsf != NULL ? trsf->buffer : NULL; char* buffer_iterator = trsf != NULL ? trsf->buffer : NULL;
char coords_format[64]; char coords_format[64];
int error = FOUG_DATAX_NO_ERROR; int error = GMIO_NO_ERROR;
/* Check validity of input parameters */ /* Check validity of input parameters */
foug_check_transfer(&error, trsf); gmio_check_transfer(&error, trsf);
foug_stl_check_geom(&error, geom); gmio_stl_check_geom(&error, geom);
if (real32_prec == 0 || real32_prec > 9) if (real32_prec == 0 || real32_prec > 9)
error = FOUG_STLA_WRITE_INVALID_REAL32_PREC_ERROR; error = GMIO_STLA_WRITE_INVALID_REAL32_PREC_ERROR;
if (trsf->buffer_size < FOUG_STLA_FACET_SIZE_P2) if (trsf->buffer_size < GMIO_STLA_FACET_SIZE_P2)
error = FOUG_DATAX_INVALID_BUFFER_SIZE_ERROR; error = GMIO_INVALID_BUFFER_SIZE_ERROR;
if (foug_datax_error(error)) if (gmio_error(error))
return error; return error;
{ /* Create XYZ coords format string (for normal and vertex coords) */ { /* Create XYZ coords format string (for normal and vertex coords) */
char* coords_format_iterator = coords_format; char* coords_format_iterator = coords_format;
coords_format_iterator = foug_write_stdio_format(coords_format_iterator, real32_prec); coords_format_iterator = gmio_write_stdio_format(coords_format_iterator, real32_prec);
coords_format_iterator = foug_write_nspaces(coords_format_iterator, 2); coords_format_iterator = gmio_write_nspaces(coords_format_iterator, 2);
coords_format_iterator = foug_write_stdio_format(coords_format_iterator, real32_prec); coords_format_iterator = gmio_write_stdio_format(coords_format_iterator, real32_prec);
coords_format_iterator = foug_write_nspaces(coords_format_iterator, 2); coords_format_iterator = gmio_write_nspaces(coords_format_iterator, 2);
coords_format_iterator = foug_write_stdio_format(coords_format_iterator, real32_prec); coords_format_iterator = gmio_write_stdio_format(coords_format_iterator, real32_prec);
*coords_format_iterator = 0; /* Write terminating null byte */ *coords_format_iterator = 0; /* Write terminating null byte */
/* TODO: check the "format" string can contain the given precision */ /* TODO: check the "format" string can contain the given precision */
} }
/* Write solid declaration */ /* Write solid declaration */
{ {
buffer_iterator = foug_write_string(buffer_iterator, "solid "); buffer_iterator = gmio_write_string(buffer_iterator, "solid ");
buffer_iterator = foug_write_string_eol(buffer_iterator, solid_name); buffer_iterator = gmio_write_string_eol(buffer_iterator, solid_name);
if (!foug_transfer_flush_buffer(trsf, buffer_iterator - (char*)trsf->buffer)) if (!gmio_transfer_flush_buffer(trsf, buffer_iterator - (char*)trsf->buffer))
return FOUG_DATAX_STREAM_ERROR; return GMIO_STREAM_ERROR;
} }
/* Write solid's facets */ /* Write solid's facets */
for (ifacet = 0; for (ifacet = 0;
ifacet < total_facet_count && foug_datax_no_error(error); ifacet < total_facet_count && gmio_no_error(error);
ifacet += buffer_facet_count) ifacet += buffer_facet_count)
{ {
const uint32_t clamped_facet_count = _FOUG_INTERNAL_MIN(ifacet + buffer_facet_count, const uint32_t clamped_facet_count = _GMIO_INTERNAL_MIN(ifacet + buffer_facet_count,
total_facet_count); total_facet_count);
foug_stl_triangle_t tri; gmio_stl_triangle_t tri;
uint32_t ibuffer_facet; uint32_t ibuffer_facet;
/* Writing of facets is buffered */ /* Writing of facets is buffered */
buffer_iterator = trsf->buffer; buffer_iterator = trsf->buffer;
for (ibuffer_facet = ifacet; ibuffer_facet < clamped_facet_count; ++ibuffer_facet) { for (ibuffer_facet = ifacet; ibuffer_facet < clamped_facet_count; ++ibuffer_facet) {
geom->get_triangle_func(geom->cookie, ibuffer_facet, &tri); geom->get_triangle_func(geom->cookie, ibuffer_facet, &tri);
buffer_iterator = foug_write_string(buffer_iterator, "facet normal "); buffer_iterator = gmio_write_string(buffer_iterator, "facet normal ");
buffer_iterator = foug_write_coords(buffer_iterator, coords_format, &tri.normal); buffer_iterator = gmio_write_coords(buffer_iterator, coords_format, &tri.normal);
buffer_iterator = foug_write_eol(buffer_iterator); buffer_iterator = gmio_write_eol(buffer_iterator);
buffer_iterator = foug_write_string_eol(buffer_iterator, " outer loop"); buffer_iterator = gmio_write_string_eol(buffer_iterator, " outer loop");
buffer_iterator = foug_write_string(buffer_iterator, " vertex "); buffer_iterator = gmio_write_string(buffer_iterator, " vertex ");
buffer_iterator = foug_write_coords(buffer_iterator, coords_format, &tri.v1); buffer_iterator = gmio_write_coords(buffer_iterator, coords_format, &tri.v1);
buffer_iterator = foug_write_eol(buffer_iterator); buffer_iterator = gmio_write_eol(buffer_iterator);
buffer_iterator = foug_write_string(buffer_iterator, " vertex "); buffer_iterator = gmio_write_string(buffer_iterator, " vertex ");
buffer_iterator = foug_write_coords(buffer_iterator, coords_format, &tri.v2); buffer_iterator = gmio_write_coords(buffer_iterator, coords_format, &tri.v2);
buffer_iterator = foug_write_eol(buffer_iterator); buffer_iterator = gmio_write_eol(buffer_iterator);
buffer_iterator = foug_write_string(buffer_iterator, " vertex "); buffer_iterator = gmio_write_string(buffer_iterator, " vertex ");
buffer_iterator = foug_write_coords(buffer_iterator, coords_format, &tri.v3); buffer_iterator = gmio_write_coords(buffer_iterator, coords_format, &tri.v3);
buffer_iterator = foug_write_eol(buffer_iterator); buffer_iterator = gmio_write_eol(buffer_iterator);
buffer_iterator = foug_write_string_eol(buffer_iterator, " endloop"); buffer_iterator = gmio_write_string_eol(buffer_iterator, " endloop");
buffer_iterator = foug_write_string_eol(buffer_iterator, "endfacet"); buffer_iterator = gmio_write_string_eol(buffer_iterator, "endfacet");
} /* end for (ibuffer_facet) */ } /* end for (ibuffer_facet) */
if (!foug_transfer_flush_buffer(trsf, buffer_iterator - (char*)trsf->buffer)) if (!gmio_transfer_flush_buffer(trsf, buffer_iterator - (char*)trsf->buffer))
error = FOUG_DATAX_STREAM_ERROR; error = GMIO_STREAM_ERROR;
/* Task control */ /* Task control */
if (foug_datax_no_error(error) && trsf->task_control.handle_progress_func != NULL) { if (gmio_no_error(error) && trsf->task_control.handle_progress_func != NULL) {
uint32_t percentage = 0; uint32_t percentage = 0;
written_facet_count += buffer_facet_count; written_facet_count += buffer_facet_count;
percentage = foug_percentage(0, total_facet_count, written_facet_count); percentage = gmio_percentage(0, total_facet_count, written_facet_count);
if (!foug_task_control_handle_progress(&trsf->task_control, percentage)) if (!gmio_task_control_handle_progress(&trsf->task_control, percentage))
error = FOUG_DATAX_TASK_STOPPED_ERROR; error = GMIO_TASK_STOPPED_ERROR;
} }
} /* end for (ifacet) */ } /* end for (ifacet) */
/* Write end of solid */ /* Write end of solid */
if (foug_datax_no_error(error)) { if (gmio_no_error(error)) {
buffer_iterator = foug_write_string(trsf->buffer, "endsolid "); buffer_iterator = gmio_write_string(trsf->buffer, "endsolid ");
buffer_iterator = foug_write_string_eol(buffer_iterator, solid_name); buffer_iterator = gmio_write_string_eol(buffer_iterator, solid_name);
if (!foug_transfer_flush_buffer(trsf, buffer_iterator - (char*)trsf->buffer)) if (!gmio_transfer_flush_buffer(trsf, buffer_iterator - (char*)trsf->buffer))
error = FOUG_DATAX_STREAM_ERROR; error = GMIO_STREAM_ERROR;
} }
return error; return error;

121
src/gmio_stl/stlb_read.c Normal file
View File

@ -0,0 +1,121 @@
#include "stl_io.h"
#include "stl_error.h"
#include "internal/stl_rw_common.h"
#include "internal/stlb_byte_swap.h"
#include "../gmio_core/endian.h"
#include "../gmio_core/error.h"
#include "../gmio_core/internal/convert.h"
#include "../gmio_core/internal/byte_swap.h"
#include <string.h>
GMIO_INLINE static void read_triangle_memcpy(const uint8_t* buffer,
gmio_stl_triangle_t* triangle)
{
/* *triangle = *((gmio_stl_triangle_t*)(buffer)); */
memcpy(triangle, buffer, GMIO_STLB_TRIANGLE_RAWSIZE);
}
static void gmio_stlb_read_facets(gmio_stl_geom_creator_t* creator,
const uint8_t* buffer,
const gmio_stlb_readwrite_helper* rparams)
{
const uint32_t facet_count = rparams->facet_count;
const uint32_t i_facet_offset = rparams->i_facet_offset;
gmio_stl_triangle_t triangle;
uint32_t buffer_offset = 0;
uint32_t i_facet = 0;
if (creator == NULL || creator->add_triangle_func == NULL)
return;
for (i_facet = 0; i_facet < facet_count; ++i_facet) {
/* Decode data */
read_triangle_memcpy(buffer + buffer_offset, &triangle);
buffer_offset += GMIO_STLB_TRIANGLE_RAWSIZE;
if (rparams->fix_endian_func != NULL)
rparams->fix_endian_func(&triangle);
/* Declare triangle */
creator->add_triangle_func(creator->cookie, i_facet_offset + i_facet, &triangle);
}
}
int gmio_stlb_read(gmio_stl_geom_creator_t *creator,
gmio_transfer_t* trsf,
gmio_endianness_t byte_order)
{
const gmio_endianness_t host_byte_order = gmio_host_endianness();
gmio_stlb_readwrite_helper rparams;
uint8_t header_data[GMIO_STLB_HEADER_SIZE];
uint32_t total_facet_count = 0; /* Count of facets as declared in the stream */
int error = GMIO_NO_ERROR; /* Helper variable to store function result error code */
/* Check validity of input parameters */
if (!gmio_stlb_check_params(&error, trsf, byte_order))
return error;
/* Initialize rparams */
memset(&rparams, 0, sizeof(gmio_stlb_readwrite_helper));
if (host_byte_order != byte_order)
rparams.fix_endian_func = gmio_stl_triangle_bswap;
/* Read header */
if (gmio_stream_read(&trsf->stream, header_data, 1, GMIO_STLB_HEADER_SIZE)
!= GMIO_STLB_HEADER_SIZE)
{
return GMIO_STLB_READ_HEADER_WRONG_SIZE_ERROR;
}
/* Read facet count */
if (gmio_stream_read(&trsf->stream, trsf->buffer, sizeof(uint32_t), 1) != 1)
return GMIO_STLB_READ_FACET_COUNT_ERROR;
memcpy(&total_facet_count, trsf->buffer, sizeof(uint32_t));
if (host_byte_order != byte_order)
total_facet_count = gmio_uint32_bswap(total_facet_count);
/* Callback to notify triangle count and header data */
if (creator != NULL && creator->binary_begin_solid_func != NULL)
creator->binary_begin_solid_func(creator->cookie, total_facet_count, header_data);
/* Read triangles */
while (gmio_no_error(error)
&& rparams.i_facet_offset < total_facet_count)
{
rparams.facet_count = gmio_stream_read(&trsf->stream,
trsf->buffer,
GMIO_STLB_TRIANGLE_RAWSIZE,
trsf->buffer_size / GMIO_STLB_TRIANGLE_RAWSIZE);
if (gmio_stream_error(&trsf->stream) != 0)
error = GMIO_STREAM_ERROR;
else if (rparams.facet_count > 0)
error = GMIO_NO_ERROR;
else
break; /* Exit if no facet to read */
if (gmio_no_error(error)) {
uint8_t progress_pc;
gmio_stlb_read_facets(creator, trsf->buffer, &rparams);
rparams.i_facet_offset += rparams.facet_count;
progress_pc = gmio_percentage(0, total_facet_count, rparams.i_facet_offset);
if (!gmio_task_control_handle_progress(&trsf->task_control, progress_pc))
error = GMIO_TASK_STOPPED_ERROR;
}
} /* end while */
if (gmio_no_error(error)
&& creator != NULL
&& creator->end_solid_func != NULL)
{
creator->end_solid_func(creator->cookie);
}
if (gmio_no_error(error) && rparams.i_facet_offset != total_facet_count)
error = GMIO_STLB_READ_FACET_COUNT_ERROR;
return error;
}

View File

@ -4,25 +4,25 @@
#include "internal/stl_rw_common.h" #include "internal/stl_rw_common.h"
#include "internal/stlb_byte_swap.h" #include "internal/stlb_byte_swap.h"
#include "../datax_core/endian.h" #include "../gmio_core/endian.h"
#include "../datax_core/error.h" #include "../gmio_core/error.h"
#include "../datax_core/internal/byte_codec.h" #include "../gmio_core/internal/byte_codec.h"
#include <string.h> #include <string.h>
FOUG_INLINE static void write_triangle_memcpy(const foug_stl_triangle_t* triangle, GMIO_INLINE static void write_triangle_memcpy(const gmio_stl_triangle_t* triangle,
uint8_t* buffer) uint8_t* buffer)
{ {
memcpy(buffer, triangle, FOUG_STLB_TRIANGLE_RAWSIZE); memcpy(buffer, triangle, GMIO_STLB_TRIANGLE_RAWSIZE);
} }
static void foug_stlb_write_facets(const foug_stl_geom_t* geom, static void gmio_stlb_write_facets(const gmio_stl_geom_t* geom,
uint8_t* buffer, uint8_t* buffer,
const foug_stlb_readwrite_helper* wparams) const gmio_stlb_readwrite_helper* wparams)
{ {
const uint32_t facet_count = wparams->facet_count; const uint32_t facet_count = wparams->facet_count;
const uint32_t i_facet_offset = wparams->i_facet_offset; const uint32_t i_facet_offset = wparams->i_facet_offset;
foug_stl_triangle_t triangle; gmio_stl_triangle_t triangle;
uint32_t buffer_offset = 0; uint32_t buffer_offset = 0;
uint32_t i_facet = 0; uint32_t i_facet = 0;
@ -38,74 +38,74 @@ static void foug_stlb_write_facets(const foug_stl_geom_t* geom,
write_triangle_memcpy(&triangle, buffer + buffer_offset); write_triangle_memcpy(&triangle, buffer + buffer_offset);
buffer_offset += FOUG_STLB_TRIANGLE_RAWSIZE; buffer_offset += GMIO_STLB_TRIANGLE_RAWSIZE;
} /* end for */ } /* end for */
} }
int foug_stlb_write(const foug_stl_geom_t *geom, int gmio_stlb_write(const gmio_stl_geom_t *geom,
foug_transfer_t* trsf, gmio_transfer_t* trsf,
const uint8_t *header_data, const uint8_t *header_data,
foug_endianness_t byte_order) gmio_endianness_t byte_order)
{ {
foug_stlb_readwrite_helper wparams; gmio_stlb_readwrite_helper wparams;
const uint32_t facet_count = geom != NULL ? geom->triangle_count : 0; const uint32_t facet_count = geom != NULL ? geom->triangle_count : 0;
uint32_t i_facet = 0; uint32_t i_facet = 0;
int error = FOUG_DATAX_NO_ERROR; int error = GMIO_NO_ERROR;
/* Check validity of input parameters */ /* Check validity of input parameters */
foug_stl_check_geom(&error, geom); gmio_stl_check_geom(&error, geom);
foug_stlb_check_params(&error, trsf, byte_order); gmio_stlb_check_params(&error, trsf, byte_order);
if (foug_datax_error(error)) if (gmio_error(error))
return error; return error;
/* Initialize wparams */ /* Initialize wparams */
memset(&wparams, 0, sizeof(foug_stlb_readwrite_helper)); memset(&wparams, 0, sizeof(gmio_stlb_readwrite_helper));
if (foug_host_endianness() != byte_order) if (gmio_host_endianness() != byte_order)
wparams.fix_endian_func = foug_stl_triangle_bswap; wparams.fix_endian_func = gmio_stl_triangle_bswap;
wparams.facet_count = trsf->buffer_size / FOUG_STLB_TRIANGLE_RAWSIZE; wparams.facet_count = trsf->buffer_size / GMIO_STLB_TRIANGLE_RAWSIZE;
/* Write header */ /* Write header */
if (header_data == NULL) { if (header_data == NULL) {
/* Use buffer to store an empty header (filled with zeroes) */ /* Use buffer to store an empty header (filled with zeroes) */
memset(trsf->buffer, 0, FOUG_STLB_HEADER_SIZE); memset(trsf->buffer, 0, GMIO_STLB_HEADER_SIZE);
header_data = (const uint8_t*)trsf->buffer; header_data = (const uint8_t*)trsf->buffer;
} }
if (foug_stream_write(&trsf->stream, header_data, FOUG_STLB_HEADER_SIZE, 1) != 1) if (gmio_stream_write(&trsf->stream, header_data, GMIO_STLB_HEADER_SIZE, 1) != 1)
return FOUG_DATAX_STREAM_ERROR; return GMIO_STREAM_ERROR;
/* Write facet count */ /* Write facet count */
if (byte_order == FOUG_LITTLE_ENDIAN) if (byte_order == GMIO_LITTLE_ENDIAN)
foug_encode_uint32_le(facet_count, trsf->buffer); gmio_encode_uint32_le(facet_count, trsf->buffer);
else else
foug_encode_uint32_be(facet_count, trsf->buffer); gmio_encode_uint32_be(facet_count, trsf->buffer);
if (foug_stream_write(&trsf->stream, trsf->buffer, sizeof(uint32_t), 1) != 1) if (gmio_stream_write(&trsf->stream, trsf->buffer, sizeof(uint32_t), 1) != 1)
return FOUG_DATAX_STREAM_ERROR; return GMIO_STREAM_ERROR;
/* Write triangles */ /* Write triangles */
for (i_facet = 0; for (i_facet = 0;
i_facet < facet_count && foug_datax_no_error(error); i_facet < facet_count && gmio_no_error(error);
i_facet += wparams.facet_count) i_facet += wparams.facet_count)
{ {
/* Write to buffer */ /* Write to buffer */
if (wparams.facet_count > (facet_count - wparams.i_facet_offset)) if (wparams.facet_count > (facet_count - wparams.i_facet_offset))
wparams.facet_count = facet_count - wparams.i_facet_offset; wparams.facet_count = facet_count - wparams.i_facet_offset;
foug_stlb_write_facets(geom, trsf->buffer, &wparams); gmio_stlb_write_facets(geom, trsf->buffer, &wparams);
wparams.i_facet_offset += wparams.facet_count; wparams.i_facet_offset += wparams.facet_count;
/* Write buffer to stream */ /* Write buffer to stream */
if (foug_stream_write(&trsf->stream, trsf->buffer, FOUG_STLB_TRIANGLE_RAWSIZE, wparams.facet_count) if (gmio_stream_write(&trsf->stream, trsf->buffer, GMIO_STLB_TRIANGLE_RAWSIZE, wparams.facet_count)
!= wparams.facet_count) != wparams.facet_count)
{ {
error = FOUG_DATAX_STREAM_ERROR; error = GMIO_STREAM_ERROR;
} }
/* Task control */ /* Task control */
if (foug_datax_no_error(error) if (gmio_no_error(error)
&& !foug_task_control_handle_progress(&trsf->task_control, && !gmio_task_control_handle_progress(&trsf->task_control,
foug_percentage(0, facet_count, i_facet + 1))) gmio_percentage(0, facet_count, i_facet + 1)))
{ {
error = FOUG_DATAX_TASK_STOPPED_ERROR; error = GMIO_TASK_STOPPED_ERROR;
} }
} /* end for */ } /* end for */

View File

@ -1,7 +1,7 @@
#include <datax_support/occ_libstl.h> #include <gmio_support/occ_libstl.h>
#include <datax_stl/stl_geom.h> #include <gmio_stl/stl_geom.h>
#include <datax_stl/stl_geom_creator.h> #include <gmio_stl/stl_geom_creator.h>
#include <cstring> #include <cstring>
#include <StlMesh_Mesh.hxx> #include <StlMesh_Mesh.hxx>
@ -20,7 +20,7 @@ static StlMesh_Mesh* occMeshPtr(const Handle_StlMesh_Mesh& mesh)
static void occmesh_add_triangle(void* cookie, static void occmesh_add_triangle(void* cookie,
uint32_t tri_id, uint32_t tri_id,
const foug_stl_triangle_t* tri) const gmio_stl_triangle_t* tri)
{ {
StlMesh_Mesh* mesh = static_cast<StlMesh_Mesh*>(cookie); StlMesh_Mesh* mesh = static_cast<StlMesh_Mesh*>(cookie);
if (tri_id == 0) if (tri_id == 0)
@ -33,9 +33,9 @@ static void occmesh_add_triangle(void* cookie,
static void occmesh_get_triangle(const void* cookie, static void occmesh_get_triangle(const void* cookie,
uint32_t tri_id, uint32_t tri_id,
foug_stl_triangle_t* triangle) gmio_stl_triangle_t* triangle)
{ {
const foug_OccStlMeshDomain* meshCookie = static_cast<const foug_OccStlMeshDomain*>(cookie); const gmio_OccStlMeshDomain* meshCookie = static_cast<const gmio_OccStlMeshDomain*>(cookie);
const StlMesh_SequenceOfMeshTriangle& occTriangles = meshCookie->mesh()->Triangles(meshCookie->domainId()); const StlMesh_SequenceOfMeshTriangle& occTriangles = meshCookie->mesh()->Triangles(meshCookie->domainId());
const Handle_StlMesh_MeshTriangle& occTri = occTriangles.Value(tri_id + 1); const Handle_StlMesh_MeshTriangle& occTri = occTriangles.Value(tri_id + 1);
Standard_Integer v1; Standard_Integer v1;
@ -68,45 +68,45 @@ static void occmesh_get_triangle(const void* cookie,
} // namespace internal } // namespace internal
void foug_stl_occmesh_geom(foug_stl_geom_t *geom, void gmio_stl_occmesh_geom(gmio_stl_geom_t *geom,
const foug_OccStlMeshDomain &meshCookie) const gmio_OccStlMeshDomain &meshCookie)
{ {
std::memset(geom, 0, sizeof(foug_stl_geom_t)); std::memset(geom, 0, sizeof(gmio_stl_geom_t));
geom->cookie = &meshCookie; geom->cookie = &meshCookie;
geom->triangle_count = meshCookie.mesh()->NbTriangles(meshCookie.domainId()); geom->triangle_count = meshCookie.mesh()->NbTriangles(meshCookie.domainId());
geom->get_triangle_func = internal::occmesh_get_triangle; geom->get_triangle_func = internal::occmesh_get_triangle;
} }
void foug_stl_occmesh_geom_creator(foug_stl_geom_creator_t *creator, void gmio_stl_occmesh_geom_creator(gmio_stl_geom_creator_t *creator,
const Handle_StlMesh_Mesh &mesh) const Handle_StlMesh_Mesh &mesh)
{ {
std::memset(creator, 0, sizeof(foug_stl_geom_creator_t)); std::memset(creator, 0, sizeof(gmio_stl_geom_creator_t));
creator->cookie = internal::occMeshPtr(mesh); creator->cookie = internal::occMeshPtr(mesh);
creator->add_triangle_func = internal::occmesh_add_triangle; creator->add_triangle_func = internal::occmesh_add_triangle;
} }
foug_OccStlMeshDomain::foug_OccStlMeshDomain(const Handle_StlMesh_Mesh &stlMesh, int domId) gmio_OccStlMeshDomain::gmio_OccStlMeshDomain(const Handle_StlMesh_Mesh &stlMesh, int domId)
: m_mesh(stlMesh), : m_mesh(stlMesh),
m_domainId(domId) m_domainId(domId)
{ {
} }
const Handle_StlMesh_Mesh &foug_OccStlMeshDomain::mesh() const const Handle_StlMesh_Mesh &gmio_OccStlMeshDomain::mesh() const
{ {
return m_mesh; return m_mesh;
} }
void foug_OccStlMeshDomain::setMesh(const Handle_StlMesh_Mesh &stlMesh) void gmio_OccStlMeshDomain::setMesh(const Handle_StlMesh_Mesh &stlMesh)
{ {
m_mesh = stlMesh; m_mesh = stlMesh;
} }
int foug_OccStlMeshDomain::domainId() const int gmio_OccStlMeshDomain::domainId() const
{ {
return m_domainId; return m_domainId;
} }
void foug_OccStlMeshDomain::setDomainId(int domId) void gmio_OccStlMeshDomain::setDomainId(int domId)
{ {
m_domainId = domId; m_domainId = domId;
} }

View File

@ -0,0 +1,33 @@
#ifndef GMIO_SUPPORT_OCC_LIBSTL_H
#define GMIO_SUPPORT_OCC_LIBSTL_H
#include "support_global.h"
#include <Handle_StlMesh_Mesh.hxx>
struct gmio_stl_geom;
struct gmio_stl_geom_creator;
class GMIO_LIBSUPPORT_EXPORT gmio_OccStlMeshDomain
{
public:
gmio_OccStlMeshDomain(const Handle_StlMesh_Mesh& stlMesh, int domId = 1);
const Handle_StlMesh_Mesh& mesh() const;
void setMesh(const Handle_StlMesh_Mesh& stlMesh);
int domainId() const;
void setDomainId(int domId);
private:
Handle_StlMesh_Mesh m_mesh;
int m_domainId;
};
GMIO_LIBSUPPORT_EXPORT
void gmio_stl_occmesh_geom(gmio_stl_geom* geom,
const gmio_OccStlMeshDomain& meshCookie);
GMIO_LIBSUPPORT_EXPORT
void gmio_stl_occmesh_geom_creator(gmio_stl_geom_creator* creator,
const Handle_StlMesh_Mesh& mesh);
#endif /* GMIO_SUPPORT_OCC_LIBSTL_H */

View File

@ -1,16 +1,16 @@
#include <datax_support/qt_stream.h> #include <gmio_support/qt_stream.h>
#include <datax_core/stream.h> #include <gmio_core/stream.h>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QIODevice> #include <QtCore/QIODevice>
static foug_bool_t foug_stream_qiodevice_at_end(void* cookie) static gmio_bool_t gmio_stream_qiodevice_at_end(void* cookie)
{ {
return static_cast<QIODevice*>(cookie)->atEnd(); return static_cast<QIODevice*>(cookie)->atEnd();
} }
static int foug_stream_qiodevice_error(void* cookie) static int gmio_stream_qiodevice_error(void* cookie)
{ {
const QIODevice* device = static_cast<QIODevice*>(cookie); const QIODevice* device = static_cast<QIODevice*>(cookie);
const QFile* file = dynamic_cast<const QFile*>(device); const QFile* file = dynamic_cast<const QFile*>(device);
@ -24,7 +24,7 @@ static int foug_stream_qiodevice_error(void* cookie)
return 0; return 0;
} }
static size_t foug_stream_qiodevice_read(void* cookie, static size_t gmio_stream_qiodevice_read(void* cookie,
void* ptr, void* ptr,
size_t item_size, size_t item_size,
size_t item_count) size_t item_count)
@ -34,7 +34,7 @@ static size_t foug_stream_qiodevice_read(void* cookie,
return c / item_size; return c / item_size;
} }
static size_t foug_stream_qiodevice_write(void* cookie, static size_t gmio_stream_qiodevice_write(void* cookie,
const void* ptr, const void* ptr,
size_t item_size, size_t item_size,
size_t item_count) size_t item_count)
@ -44,11 +44,11 @@ static size_t foug_stream_qiodevice_write(void* cookie,
return c / item_size; return c / item_size;
} }
void foug_stream_set_qiodevice(foug_stream_t* stream, QIODevice* device) void gmio_stream_set_qiodevice(gmio_stream_t* stream, QIODevice* device)
{ {
stream->cookie = device; stream->cookie = device;
stream->at_end_func = foug_stream_qiodevice_at_end; stream->at_end_func = gmio_stream_qiodevice_at_end;
stream->error_func = foug_stream_qiodevice_error; stream->error_func = gmio_stream_qiodevice_error;
stream->read_func = foug_stream_qiodevice_read; stream->read_func = gmio_stream_qiodevice_read;
stream->write_func = foug_stream_qiodevice_write; stream->write_func = gmio_stream_qiodevice_write;
} }

View File

@ -0,0 +1,11 @@
#ifndef GMIO_SUPPORT_QT_STREAM_H
#define GMIO_SUPPORT_QT_STREAM_H
#include "support_global.h"
struct gmio_stream;
class QIODevice;
GMIO_LIBSUPPORT_EXPORT
void gmio_stream_set_qiodevice(struct gmio_stream* stream, QIODevice* device);
#endif /* GMIO_SUPPORT_QT_STREAM_H */

View File

@ -0,0 +1,16 @@
#ifndef GMIO_C_SUPPORT_GLOBAL_H
#define GMIO_C_SUPPORT_GLOBAL_H
#include "../datax_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_C_SUPPORT_GLOBAL_H */

View File

@ -2,25 +2,25 @@
#include <string.h> #include <string.h>
static foug_bool_t foug_stream_buffer_at_end(void* cookie) static gmio_bool_t gmio_stream_buffer_at_end(void* cookie)
{ {
const foug_buffer_t* buff = (const foug_buffer_t*)cookie; const gmio_buffer_t* buff = (const gmio_buffer_t*)cookie;
return buff->pos >= buff->len; return buff->pos >= buff->len;
} }
static int foug_stream_buffer_error(void* cookie) static int gmio_stream_buffer_error(void* cookie)
{ {
const foug_buffer_t* buff = (const foug_buffer_t*)cookie; const gmio_buffer_t* buff = (const gmio_buffer_t*)cookie;
return buff == NULL || buff->pos > buff->len; return buff == NULL || buff->pos > buff->len;
} }
static size_t foug_stream_buffer_read(void* cookie, static size_t gmio_stream_buffer_read(void* cookie,
void* ptr, void* ptr,
size_t item_size, size_t item_size,
size_t item_count) size_t item_count)
{ {
if (item_size > 0 && item_count > 0) { if (item_size > 0 && item_count > 0) {
foug_buffer_t* buff = (foug_buffer_t*)cookie; gmio_buffer_t* buff = (gmio_buffer_t*)cookie;
const size_t buff_remaining_size = buff->len - buff->pos; const size_t buff_remaining_size = buff->len - buff->pos;
const size_t wanted_read_size = item_size * item_count; const size_t wanted_read_size = item_size * item_count;
const size_t next_read_size = wanted_read_size <= buff_remaining_size ? wanted_read_size : const size_t next_read_size = wanted_read_size <= buff_remaining_size ? wanted_read_size :
@ -36,13 +36,13 @@ static size_t foug_stream_buffer_read(void* cookie,
} }
} }
static size_t foug_stream_buffer_write(void* cookie, static size_t gmio_stream_buffer_write(void* cookie,
const void* ptr, const void* ptr,
size_t item_size, size_t item_size,
size_t item_count) size_t item_count)
{ {
if (item_size > 0 && item_count > 0) { if (item_size > 0 && item_count > 0) {
foug_buffer_t* buff = (foug_buffer_t*)cookie; gmio_buffer_t* buff = (gmio_buffer_t*)cookie;
const size_t buff_remaining_size = buff->len - buff->pos; const size_t buff_remaining_size = buff->len - buff->pos;
const size_t wanted_write_size = item_size * item_count; const size_t wanted_write_size = item_size * item_count;
const size_t next_write_size = wanted_write_size <= buff_remaining_size ? wanted_write_size : const size_t next_write_size = wanted_write_size <= buff_remaining_size ? wanted_write_size :
@ -58,11 +58,11 @@ static size_t foug_stream_buffer_write(void* cookie,
} }
} }
void foug_stream_set_buffer(foug_stream_t *stream, foug_buffer_t *buff) void gmio_stream_set_buffer(gmio_stream_t *stream, gmio_buffer_t *buff)
{ {
stream->cookie = buff; stream->cookie = buff;
stream->at_end_func = foug_stream_buffer_at_end; stream->at_end_func = gmio_stream_buffer_at_end;
stream->error_func = foug_stream_buffer_error; stream->error_func = gmio_stream_buffer_error;
stream->read_func = foug_stream_buffer_read; stream->read_func = gmio_stream_buffer_read;
stream->write_func = foug_stream_buffer_write; stream->write_func = gmio_stream_buffer_write;
} }

View File

@ -1,15 +1,15 @@
#ifndef FOUG_STREAM_BUFFER_H #ifndef GMIO_STREAM_BUFFER_H
#define FOUG_STREAM_BUFFER_H #define GMIO_STREAM_BUFFER_H
#include "../src/datax_core/stream.h" #include "../src/gmio_core/stream.h"
typedef struct typedef struct
{ {
void* ptr; void* ptr;
size_t len; size_t len;
size_t pos; size_t pos;
} foug_buffer_t; } gmio_buffer_t;
void foug_stream_set_buffer(foug_stream_t* stream, foug_buffer_t* buff); void gmio_stream_set_buffer(gmio_stream_t* stream, gmio_buffer_t* buff);
#endif /* FOUG_STREAM_BUFFER_H */ #endif /* GMIO_STREAM_BUFFER_H */

View File

@ -1,8 +1,8 @@
#include "utest_lib.h" #include "utest_lib.h"
#include "../src/datax_core/internal/ascii_parse.h" #include "../src/gmio_core/internal/ascii_parse.h"
#include "../src/datax_core/internal/byte_swap.h" #include "../src/gmio_core/internal/byte_swap.h"
#include "../src/datax_core/internal/byte_codec.h" #include "../src/gmio_core/internal/byte_codec.h"
#include "stream_buffer.h" #include "stream_buffer.h"
@ -11,8 +11,8 @@
const char* test_internal__byte_swap() const char* test_internal__byte_swap()
{ {
UTEST_ASSERT(foug_uint16_bswap(0x1122) == 0x2211); UTEST_ASSERT(gmio_uint16_bswap(0x1122) == 0x2211);
UTEST_ASSERT(foug_uint32_bswap(0x11223344) == 0x44332211); UTEST_ASSERT(gmio_uint32_bswap(0x11223344) == 0x44332211);
return NULL; return NULL;
} }
@ -20,19 +20,19 @@ const char* test_internal__byte_codec()
{ {
{ /* decode */ { /* decode */
const uint8_t data[] = { 0x11, 0x22, 0x33, 0x44 }; const uint8_t data[] = { 0x11, 0x22, 0x33, 0x44 };
UTEST_ASSERT(foug_decode_uint16_le(data) == 0x2211); UTEST_ASSERT(gmio_decode_uint16_le(data) == 0x2211);
UTEST_ASSERT(foug_decode_uint16_be(data) == 0x1122); UTEST_ASSERT(gmio_decode_uint16_be(data) == 0x1122);
UTEST_ASSERT(foug_decode_uint32_le(data) == 0x44332211); UTEST_ASSERT(gmio_decode_uint32_le(data) == 0x44332211);
UTEST_ASSERT(foug_decode_uint32_be(data) == 0x11223344); UTEST_ASSERT(gmio_decode_uint32_be(data) == 0x11223344);
} }
{ /* encode */ { /* encode */
uint8_t data[] = { 0, 0, 0, 0 }; uint8_t data[] = { 0, 0, 0, 0 };
foug_encode_uint16_le(0x1122, data); gmio_encode_uint16_le(0x1122, data);
UTEST_ASSERT(data[0] == 0x22 && data[1] == 0x11); UTEST_ASSERT(data[0] == 0x22 && data[1] == 0x11);
foug_encode_uint32_le(0x11223344, data); gmio_encode_uint32_le(0x11223344, data);
UTEST_ASSERT(data[0] == 0x44 && data[1] == 0x33 && data[2] == 0x22 && data[3] == 0x11); UTEST_ASSERT(data[0] == 0x44 && data[1] == 0x33 && data[2] == 0x22 && data[3] == 0x11);
foug_encode_uint32_be(0x11223344, data); gmio_encode_uint32_be(0x11223344, data);
UTEST_ASSERT(data[3] == 0x44 && data[2] == 0x33 && data[1] == 0x22 && data[0] == 0x11); UTEST_ASSERT(data[3] == 0x44 && data[2] == 0x33 && data[1] == 0x22 && data[0] == 0x11);
} }
@ -47,59 +47,59 @@ const char* test_internal__ascii_parse()
"pi : 3.1415926535897932384626433832795"; "pi : 3.1415926535897932384626433832795";
{ {
foug_buffer_t buff; gmio_buffer_t buff;
foug_stream_t stream; gmio_stream_t stream;
char small_fwd_it_str[4]; char small_fwd_it_str[4];
char fwd_it_str[32]; char fwd_it_str[32];
foug_ascii_stream_fwd_iterator_t fwd_it; gmio_ascii_stream_fwd_iterator_t fwd_it;
char copy_str[128]; char copy_str[128];
foug_ascii_string_buffer_t copy_strbuff; gmio_ascii_string_buffer_t copy_strbuff;
buff.ptr = text; buff.ptr = text;
buff.len = strlen(text); buff.len = strlen(text);
buff.pos = 0; buff.pos = 0;
foug_stream_set_buffer(&stream, &buff); gmio_stream_set_buffer(&stream, &buff);
memset(&fwd_it, 0, sizeof(foug_ascii_stream_fwd_iterator_t)); memset(&fwd_it, 0, sizeof(gmio_ascii_stream_fwd_iterator_t));
fwd_it.stream = &stream; fwd_it.stream = &stream;
fwd_it.buffer.ptr = fwd_it_str; fwd_it.buffer.ptr = fwd_it_str;
fwd_it.buffer.max_len = sizeof(fwd_it_str); fwd_it.buffer.max_len = sizeof(fwd_it_str);
foug_ascii_stream_fwd_iterator_init(&fwd_it); gmio_ascii_stream_fwd_iterator_init(&fwd_it);
copy_strbuff.ptr = copy_str; copy_strbuff.ptr = copy_str;
copy_strbuff.max_len = sizeof(copy_str); copy_strbuff.max_len = sizeof(copy_str);
UTEST_ASSERT(foug_current_char(&fwd_it) != NULL); UTEST_ASSERT(gmio_current_char(&fwd_it) != NULL);
UTEST_ASSERT(*foug_current_char(&fwd_it) == 'U'); UTEST_ASSERT(*gmio_current_char(&fwd_it) == 'U');
UTEST_ASSERT(foug_eat_word(&fwd_it, &copy_strbuff) == 0); UTEST_ASSERT(gmio_eat_word(&fwd_it, &copy_strbuff) == 0);
/* printf("\ncopy_strbuff.ptr = \"%s\"\n", copy_strbuff.ptr); */ /* printf("\ncopy_strbuff.ptr = \"%s\"\n", copy_strbuff.ptr); */
UTEST_ASSERT(strcmp(copy_strbuff.ptr, "Une") == 0); UTEST_ASSERT(strcmp(copy_strbuff.ptr, "Une") == 0);
UTEST_ASSERT(foug_eat_word(&fwd_it, &copy_strbuff) == 0); UTEST_ASSERT(gmio_eat_word(&fwd_it, &copy_strbuff) == 0);
UTEST_ASSERT(strcmp(copy_strbuff.ptr, "citation,") == 0); UTEST_ASSERT(strcmp(copy_strbuff.ptr, "citation,") == 0);
UTEST_ASSERT(foug_eat_word(&fwd_it, &copy_strbuff) == 0); UTEST_ASSERT(gmio_eat_word(&fwd_it, &copy_strbuff) == 0);
UTEST_ASSERT(strcmp(copy_strbuff.ptr, "o") == 0); UTEST_ASSERT(strcmp(copy_strbuff.ptr, "o") == 0);
UTEST_ASSERT(foug_eat_word(&fwd_it, &copy_strbuff) == 0); UTEST_ASSERT(gmio_eat_word(&fwd_it, &copy_strbuff) == 0);
UTEST_ASSERT(strcmp(copy_strbuff.ptr, "je") == 0); UTEST_ASSERT(strcmp(copy_strbuff.ptr, "je") == 0);
foug_skip_spaces(&fwd_it); gmio_skip_spaces(&fwd_it);
UTEST_ASSERT(foug_next_char(&fwd_it) != NULL); UTEST_ASSERT(gmio_next_char(&fwd_it) != NULL);
UTEST_ASSERT(*foug_current_char(&fwd_it) == 'r'); UTEST_ASSERT(*gmio_current_char(&fwd_it) == 'r');
/* Test with very small string buffer */ /* Test with very small string buffer */
buff.pos = 0; buff.pos = 0;
fwd_it.buffer.ptr = small_fwd_it_str; fwd_it.buffer.ptr = small_fwd_it_str;
fwd_it.buffer.max_len = sizeof(small_fwd_it_str); fwd_it.buffer.max_len = sizeof(small_fwd_it_str);
foug_ascii_stream_fwd_iterator_init(&fwd_it); gmio_ascii_stream_fwd_iterator_init(&fwd_it);
UTEST_ASSERT(*foug_current_char(&fwd_it) == 'U'); UTEST_ASSERT(*gmio_current_char(&fwd_it) == 'U');
UTEST_ASSERT(foug_eat_word(&fwd_it, &copy_strbuff) == 0); UTEST_ASSERT(gmio_eat_word(&fwd_it, &copy_strbuff) == 0);
UTEST_ASSERT(foug_eat_word(&fwd_it, &copy_strbuff) == 0); UTEST_ASSERT(gmio_eat_word(&fwd_it, &copy_strbuff) == 0);
UTEST_ASSERT(strcmp(copy_strbuff.ptr, "citation,") == 0); UTEST_ASSERT(strcmp(copy_strbuff.ptr, "citation,") == 0);
} }

View File

@ -1,23 +1,23 @@
#include "utest_lib.h" #include "utest_lib.h"
#include "../src/datax_core/global.h" #include "../src/gmio_core/global.h"
#include "../src/datax_stl/stl_triangle.h" #include "../src/gmio_stl/stl_triangle.h"
#include <stddef.h> #include <stddef.h>
const char* test_platform__alignment() const char* test_platform__alignment()
{ {
UTEST_ASSERT(offsetof(foug_stl_coords_t, x) == 0); UTEST_ASSERT(offsetof(gmio_stl_coords_t, x) == 0);
UTEST_ASSERT(offsetof(foug_stl_coords_t, y) == 4); UTEST_ASSERT(offsetof(gmio_stl_coords_t, y) == 4);
UTEST_ASSERT(offsetof(foug_stl_coords_t, z) == 8); UTEST_ASSERT(offsetof(gmio_stl_coords_t, z) == 8);
UTEST_ASSERT(sizeof(foug_stl_coords_t) == FOUG_STL_COORDS_RAWSIZE); UTEST_ASSERT(sizeof(gmio_stl_coords_t) == GMIO_STL_COORDS_RAWSIZE);
UTEST_ASSERT(offsetof(foug_stl_triangle_t, normal) == 0); UTEST_ASSERT(offsetof(gmio_stl_triangle_t, normal) == 0);
UTEST_ASSERT(offsetof(foug_stl_triangle_t, v1) == FOUG_STL_COORDS_RAWSIZE); UTEST_ASSERT(offsetof(gmio_stl_triangle_t, v1) == GMIO_STL_COORDS_RAWSIZE);
UTEST_ASSERT(offsetof(foug_stl_triangle_t, v2) == 2*FOUG_STL_COORDS_RAWSIZE); UTEST_ASSERT(offsetof(gmio_stl_triangle_t, v2) == 2*GMIO_STL_COORDS_RAWSIZE);
UTEST_ASSERT(offsetof(foug_stl_triangle_t, v3) == 3*FOUG_STL_COORDS_RAWSIZE); UTEST_ASSERT(offsetof(gmio_stl_triangle_t, v3) == 3*GMIO_STL_COORDS_RAWSIZE);
UTEST_ASSERT(offsetof(foug_stl_triangle_t, attribute_byte_count) == 4*FOUG_STL_COORDS_RAWSIZE); UTEST_ASSERT(offsetof(gmio_stl_triangle_t, attribute_byte_count) == 4*GMIO_STL_COORDS_RAWSIZE);
UTEST_ASSERT(sizeof(foug_stl_triangle_t) >= FOUG_STLB_TRIANGLE_RAWSIZE); UTEST_ASSERT(sizeof(gmio_stl_triangle_t) >= GMIO_STLB_TRIANGLE_RAWSIZE);
return NULL; return NULL;
} }
@ -33,8 +33,8 @@ const char* test_platform__global_h()
UTEST_ASSERT(sizeof(int32_t) == 4); UTEST_ASSERT(sizeof(int32_t) == 4);
UTEST_ASSERT(sizeof(uint32_t) == 4); UTEST_ASSERT(sizeof(uint32_t) == 4);
UTEST_ASSERT(sizeof(foug_real32_t) == 4); UTEST_ASSERT(sizeof(gmio_real32_t) == 4);
UTEST_ASSERT(sizeof(foug_real64_t) == 8); UTEST_ASSERT(sizeof(gmio_real64_t) == 8);
return NULL; return NULL;
} }