diff --git a/benchs/bench_assimp/main.cpp b/benchs/bench_assimp/main.cpp index 50e6fff..a349ad7 100644 --- a/benchs/bench_assimp/main.cpp +++ b/benchs/bench_assimp/main.cpp @@ -145,8 +145,6 @@ static void gmio_assimp_end_solid(void* cookie) static void bench_gmio_stl_read(const char* filepath) { - gmio_buffer_t buffer = gmio_buffer_malloc(256 * 1024); - aiScene* scene = new aiScene; gmio_stl_mesh_creator_t mesh_creator = { 0 }; mesh_creator.cookie = scene; @@ -155,11 +153,9 @@ static void bench_gmio_stl_read(const char* filepath) mesh_creator.add_triangle_func = gmio_assimp_add_triangle; mesh_creator.end_solid_func = gmio_assimp_end_solid; - int error = gmio_stl_read_file(filepath, &buffer, &mesh_creator); + int error = gmio_stl_read_file(filepath, &mesh_creator); if (error != GMIO_ERROR_OK) printf("GeomIO error: 0x%X\n", error); - - gmio_buffer_deallocate(&buffer); } int main(int argc, char** argv) diff --git a/benchs/bench_gmio/main.c b/benchs/bench_gmio/main.c index 7f1f72f..6ecf9dc 100644 --- a/benchs/bench_gmio/main.c +++ b/benchs/bench_gmio/main.c @@ -19,19 +19,15 @@ static void dummy_process_triangle(void* cookie, static void bench_gmio_stl_read(const char* filepath) { - gmio_buffer_t buffer = gmio_buffer_malloc(512 * 1024); my_igeom_t cookie = { 0 }; gmio_stl_mesh_creator_t mesh_creator = { 0 }; int error = GMIO_ERROR_OK; mesh_creator.cookie = &cookie; mesh_creator.add_triangle_func = dummy_process_triangle; - - error = gmio_stl_read_file(filepath, &buffer, &mesh_creator); + error = gmio_stl_read_file(filepath, &mesh_creator); if (error != GMIO_ERROR_OK) printf("GeomIO error: 0x%X\n", error); - - gmio_buffer_deallocate(&buffer); } int main(int argc, char** argv) diff --git a/benchs/bench_occ/main.cpp b/benchs/bench_occ/main.cpp index 14e9cba..624b5ca 100644 --- a/benchs/bench_occ/main.cpp +++ b/benchs/bench_occ/main.cpp @@ -15,13 +15,11 @@ static void bench_occ_RWStl_ReadFile(const char* filepath) static void bench_gmio_stl_read(const char* filepath) { - gmio_buffer_t buffer = gmio_buffer_malloc(256 * 1024); Handle_StlMesh_Mesh mesh = new StlMesh_Mesh; gmio_stl_mesh_creator_t mesh_creator = gmio_stl_occmesh_creator(mesh); - int error = gmio_stl_read_file(filepath, &buffer, &mesh_creator); + int error = gmio_stl_read_file(filepath, &mesh_creator); if (error != GMIO_ERROR_OK) printf("GeomIO error: 0x%X\n", error); - gmio_buffer_deallocate(&buffer); } int main(int argc, char** argv) diff --git a/src/gmio_stl/stl_io.c b/src/gmio_stl/stl_io.c index 1bba65e..ba95391 100644 --- a/src/gmio_stl/stl_io.c +++ b/src/gmio_stl/stl_io.c @@ -24,7 +24,6 @@ int gmio_stl_read_file( const char* filepath, - gmio_buffer_t* buffer, gmio_stl_mesh_creator_t* creator) { int error = GMIO_ERROR_OK; @@ -33,13 +32,12 @@ int gmio_stl_read_file( file = fopen(filepath, "rb"); if (file != NULL) { gmio_transfer_t trsf = { 0 }; - trsf.stream = gmio_stream_stdio(file); - if (buffer != NULL) - trsf.buffer = *buffer; + trsf.buffer = gmio_buffer_default(); error = gmio_stl_read(&trsf, creator); fclose(file); + gmio_buffer_deallocate(&trsf.buffer); } else { error = GMIO_ERROR_UNKNOWN; diff --git a/src/gmio_stl/stl_io.h b/src/gmio_stl/stl_io.h index 2821c84..7876a4c 100644 --- a/src/gmio_stl/stl_io.h +++ b/src/gmio_stl/stl_io.h @@ -21,6 +21,7 @@ #define GMIO_STL_IO_H #include "stl_global.h" +#include "stl_format.h" #include "stl_mesh.h" #include "stl_mesh_creator.h" #include "../gmio_core/buffer.h" @@ -34,14 +35,17 @@ GMIO_C_LINKAGE_BEGIN * \param filepath Path to the STL file. A stream is opened with fopen() so * the string has to be encoded using the system's charset (locale-8bit) * \param creator Defines the callbacks for the mesh creation - * \param buffer The memory block used by stream operations + * + * Internally, it uses: + * \li the builtin stream wrapper around FILE* (see gmio_stream_stdio()) + * \li the global default function to construct a temporary gmio_buffer + * object (see gmio_buffer_default()) * * \return Error code (see error.h and stl_error.h) */ GMIO_LIBSTL_EXPORT int gmio_stl_read_file( const char* filepath, - gmio_buffer_t* buffer, gmio_stl_mesh_creator_t* creator); /*! Reads STL data from stream, format is automatically guessed