gmio_stl: simplify façade API for stl_io.h

This commit is contained in:
Hugues Delorme 2015-04-02 15:36:57 +02:00
parent 692c2d7f58
commit 69d68a4ba9
5 changed files with 11 additions and 19 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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