gmio_stl: API change in stl_io
This commit is contained in:
parent
0f04b296fb
commit
71bc14b6dc
@ -305,13 +305,12 @@ static void stl_write(const char* filepath, gmio_stl_format format)
|
||||
const aiMesh* sceneMesh = globalSceneHelper.scene->mMeshes[0];
|
||||
|
||||
gmio_stl_write_args write = {};
|
||||
write.format = format;
|
||||
write.mesh.cookie = sceneMesh;
|
||||
write.mesh.triangle_count = sceneMesh->mNumFaces;
|
||||
write.mesh.func_get_triangle = get_triangle;
|
||||
write.options.stla_float32_format = GMIO_FLOAT_TEXT_FORMAT_SHORTEST_UPPERCASE;
|
||||
write.options.stla_float32_prec = 7;
|
||||
const int error = gmio_stl_write_file(&write, filepath);
|
||||
const int error = gmio_stl_write_file(&write, format, filepath);
|
||||
if (error != GMIO_ERROR_OK)
|
||||
printf("gmio error: 0x%X\n", error);
|
||||
}
|
||||
|
@ -130,14 +130,13 @@ static void stl_readwrite_flush_triangles(struct stl_readwrite_conv* rw_conv)
|
||||
{
|
||||
struct gmio_stl_write_args write = {0};
|
||||
write.core = rw_conv->rwargs;
|
||||
write.format = rw_conv->out_format;
|
||||
write.mesh.cookie = &rw_conv->triangle_array[0];
|
||||
write.mesh.triangle_count = rw_conv->triangle_pos;
|
||||
write.mesh.func_get_triangle = &readwrite_get_triangle;
|
||||
write.options.stl_write_triangles_only = GMIO_TRUE;
|
||||
write.options.stla_float32_format = GMIO_FLOAT_TEXT_FORMAT_SCIENTIFIC_LOWERCASE;
|
||||
write.options.stla_float32_prec = 6;
|
||||
gmio_stl_write(&write);
|
||||
gmio_stl_write(&write, rw_conv->out_format);
|
||||
rw_conv->triangle_pos = 0;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ static void stl_read(const char* filepath)
|
||||
{
|
||||
stlMesh = new StlMesh_Mesh;
|
||||
gmio_stl_read_args read = {};
|
||||
args.mesh_creator = gmio_stl_hnd_occmesh_creator(stlMesh);
|
||||
read.mesh_creator = gmio_stl_hnd_occmesh_creator(stlMesh);
|
||||
int error = gmio_stl_read_file(&read, filepath);
|
||||
if (error != GMIO_ERROR_OK)
|
||||
printf("gmio error: 0x%X\n", error);
|
||||
@ -70,11 +70,10 @@ static void stl_write(const char* filepath, gmio_stl_format format)
|
||||
{
|
||||
const gmio_occ_stl_mesh_domain occ_mesh_domain(stlMesh);
|
||||
gmio_stl_write_args write = {};
|
||||
write.format = format;
|
||||
write.mesh = gmio_stl_occmesh(&occ_mesh_domain);
|
||||
write.options.stla_float32_format = GMIO_FLOAT_TEXT_FORMAT_SHORTEST_UPPERCASE;
|
||||
write.options.stla_float32_prec = 7;
|
||||
const int error = gmio_stl_write_file(&write, filepath);
|
||||
const int error = gmio_stl_write_file(&write, format, filepath);
|
||||
if (error != GMIO_ERROR_OK)
|
||||
printf("gmio error: 0x%X\n", error);
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ int gmio_stl_read(struct gmio_stl_read_args* args)
|
||||
{
|
||||
int error = GMIO_ERROR_OK;
|
||||
if (args != NULL) {
|
||||
const enum gmio_stl_format stl_format =
|
||||
const enum gmio_stl_format format =
|
||||
gmio_stl_get_format(&args->core.stream);
|
||||
|
||||
switch (stl_format) {
|
||||
switch (format) {
|
||||
case GMIO_STL_FORMAT_ASCII: {
|
||||
error = gmio_stla_read(args);
|
||||
break;
|
||||
@ -76,13 +76,14 @@ int gmio_stl_read_file(
|
||||
return error;
|
||||
}
|
||||
|
||||
int gmio_stl_write(struct gmio_stl_write_args* args)
|
||||
int gmio_stl_write(
|
||||
struct gmio_stl_write_args* args, enum gmio_stl_format format)
|
||||
{
|
||||
int error = GMIO_ERROR_OK;
|
||||
if (args != NULL) {
|
||||
struct gmio_memblock_helper mblock_helper =
|
||||
gmio_memblock_helper(&args->core.memblock);
|
||||
switch (args->format) {
|
||||
switch (format) {
|
||||
case GMIO_STL_FORMAT_ASCII: {
|
||||
error = gmio_stla_write(args);
|
||||
break;
|
||||
@ -108,14 +109,16 @@ int gmio_stl_write(struct gmio_stl_write_args* args)
|
||||
}
|
||||
|
||||
int gmio_stl_write_file(
|
||||
struct gmio_stl_write_args* args, const char* filepath)
|
||||
struct gmio_stl_write_args* args,
|
||||
enum gmio_stl_format format,
|
||||
const char* filepath)
|
||||
{
|
||||
int error = GMIO_ERROR_OK;
|
||||
if (args != NULL) {
|
||||
FILE* file = fopen(filepath, "wb");
|
||||
if (file != NULL) {
|
||||
args->core.stream = gmio_stream_stdio(file);
|
||||
error = gmio_stl_write(args);
|
||||
error = gmio_stl_write(args, format);
|
||||
fclose(file);
|
||||
}
|
||||
else {
|
||||
|
@ -70,7 +70,8 @@ int gmio_stlb_read(
|
||||
* \return Error code (see gmio_core/error.h and stl_error.h)
|
||||
*/
|
||||
GMIO_LIBSTL_EXPORT
|
||||
int gmio_stl_write(struct gmio_stl_write_args* args);
|
||||
int gmio_stl_write(
|
||||
struct gmio_stl_write_args* args, enum gmio_stl_format format);
|
||||
|
||||
/*! Writes STL mesh to stream
|
||||
*
|
||||
@ -84,7 +85,10 @@ int gmio_stl_write(struct gmio_stl_write_args* args);
|
||||
* \return Error code (see gmio_core/error.h and stl_error.h)
|
||||
*/
|
||||
GMIO_LIBSTL_EXPORT
|
||||
int gmio_stl_write_file(struct gmio_stl_write_args* args, const char* filepath);
|
||||
int gmio_stl_write_file(
|
||||
struct gmio_stl_write_args* args,
|
||||
enum gmio_stl_format format,
|
||||
const char* filepath);
|
||||
|
||||
/*! Writes STL binary header data to stream
|
||||
*
|
||||
|
@ -62,9 +62,6 @@ struct gmio_stl_write_args
|
||||
/*! Defines the mesh to output */
|
||||
struct gmio_stl_mesh mesh;
|
||||
|
||||
/*! STL format of the output */
|
||||
enum gmio_stl_format format;
|
||||
|
||||
/*! Options for the write operation, can be safely set to \c {0} to use
|
||||
* default values */
|
||||
struct gmio_stl_write_options options;
|
||||
|
@ -38,6 +38,7 @@ if(GMIO_BUILD_SHARED_LIBS)
|
||||
# exports all symbols)
|
||||
set(GMIO_TEST_CORE_SRC
|
||||
${GMIO_TEST_CORE_SRC}
|
||||
../src/gmio_core/internal/numeric_utils.c
|
||||
../src/gmio_core/internal/stringstream.c)
|
||||
endif()
|
||||
|
||||
@ -59,6 +60,7 @@ if(GMIO_BUILD_SHARED_LIBS)
|
||||
# See Note_1
|
||||
set(GMIO_TEST_STL_SRC
|
||||
${GMIO_TEST_STL_SRC}
|
||||
../src/gmio_core/internal/numeric_utils.c
|
||||
../src/gmio_stl/internal/stl_rw_common.c)
|
||||
endif()
|
||||
|
||||
|
@ -245,13 +245,13 @@ const char* test_stlb_write()
|
||||
struct gmio_stl_write_args write = {0};
|
||||
write.mesh = gmio_stl_data_mesh(&data);
|
||||
write.options.stlb_header_data = &data.header;
|
||||
write.format = GMIO_STL_FORMAT_BINARY_LE;
|
||||
error = gmio_stl_write_file(&write, model_filepath_out);
|
||||
error = gmio_stl_write_file(
|
||||
&write, GMIO_STL_FORMAT_BINARY_LE, model_filepath_out);
|
||||
UTEST_ASSERT(error == GMIO_ERROR_OK);
|
||||
|
||||
/* Big-endian version */
|
||||
write.format = GMIO_STL_FORMAT_BINARY_BE;
|
||||
error = gmio_stl_write_file(&write, model_filepath_out_be);
|
||||
error = gmio_stl_write_file(
|
||||
&write, GMIO_STL_FORMAT_BINARY_BE, model_filepath_out_be);
|
||||
}
|
||||
|
||||
/* Check input and output models are equal */
|
||||
@ -324,13 +324,14 @@ const char* test_stla_write()
|
||||
/* Write the model to STL ascii format */
|
||||
{
|
||||
struct gmio_stl_write_args write = {0};
|
||||
write.format = GMIO_STL_FORMAT_ASCII;
|
||||
write.mesh = gmio_stl_data_mesh(&data);
|
||||
gmio_stlb_header_to_printable_string(&data.header, &header_str[0], '_');
|
||||
write.options.stla_solid_name = &header_str[0];
|
||||
write.options.stla_float32_prec = 7;
|
||||
write.options.stla_float32_format = GMIO_FLOAT_TEXT_FORMAT_SHORTEST_LOWERCASE;
|
||||
error = gmio_stl_write_file(&write, model_filepath_out);
|
||||
write.options.stla_float32_format =
|
||||
GMIO_FLOAT_TEXT_FORMAT_SHORTEST_LOWERCASE;
|
||||
error = gmio_stl_write_file(
|
||||
&write, GMIO_STL_FORMAT_ASCII, model_filepath_out);
|
||||
UTEST_ASSERT(error == GMIO_ERROR_OK);
|
||||
}
|
||||
|
||||
@ -382,9 +383,13 @@ void generate_stlb_tests_models()
|
||||
data.tri_array.count = 1;
|
||||
write.mesh = gmio_stl_data_mesh(&data);
|
||||
|
||||
write.format = GMIO_STL_FORMAT_BINARY_LE;
|
||||
gmio_stl_write_file(&write, "models/solid_one_facet.le_stlb");
|
||||
write.format = GMIO_STL_FORMAT_BINARY_BE;
|
||||
gmio_stl_write_file(&write, "models/solid_one_facet.be_stlb");
|
||||
gmio_stl_write_file(
|
||||
&write,
|
||||
GMIO_STL_FORMAT_BINARY_LE,
|
||||
"models/solid_one_facet.le_stlb");
|
||||
gmio_stl_write_file(
|
||||
&write,
|
||||
GMIO_STL_FORMAT_BINARY_BE,
|
||||
"models/solid_one_facet.be_stlb");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user