2016-03-02 00:05:52 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Example: redefine the callbacks of some gmio_stl_mesh_creator base object
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#include <gmio_core/error.h>
|
|
|
|
#include <gmio_stl/stl_io.h>
|
2016-04-15 19:05:36 +08:00
|
|
|
#include <gmio_support/stl_occ_mesh.h>
|
2016-03-08 00:48:33 +08:00
|
|
|
#include <StlMesh_Mesh.hxx>
|
2016-03-02 00:05:52 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
2016-03-14 22:53:22 +08:00
|
|
|
// Redefine gmio_stl_mesh_creator::func_begin_solid
|
2016-03-02 00:05:52 +08:00
|
|
|
void my_mesh_creator__begin_solid(
|
|
|
|
void* cookie, const gmio_stl_mesh_creator_infos* infos)
|
|
|
|
{
|
|
|
|
gmio_stl_mesh_creator* base_creator =
|
2016-06-29 22:52:32 +08:00
|
|
|
static_cast<gmio_stl_mesh_creator*>(cookie);
|
2016-03-02 00:05:52 +08:00
|
|
|
base_creator->func_begin_solid(base_creator->cookie, infos);
|
|
|
|
// Do something more ...
|
|
|
|
}
|
|
|
|
|
2016-03-14 22:53:22 +08:00
|
|
|
// Redefine gmio_stl_mesh_creator::func_add_triangle
|
2016-03-02 00:05:52 +08:00
|
|
|
void my_mesh_creator__add_triangle(
|
|
|
|
void* cookie, uint32_t tri_id, const gmio_stl_triangle* triangle)
|
|
|
|
{
|
|
|
|
gmio_stl_mesh_creator* base_creator =
|
2016-06-29 22:52:32 +08:00
|
|
|
static_cast<gmio_stl_mesh_creator*>(cookie);
|
2016-03-02 00:05:52 +08:00
|
|
|
base_creator->func_add_triangle(base_creator->cookie, tri_id, triangle);
|
|
|
|
// Do something more ...
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
if (argc > 1) {
|
|
|
|
const char* filepath = argv[1];
|
|
|
|
Handle_StlMesh_Mesh mesh = new StlMesh_Mesh;
|
2016-06-29 22:52:32 +08:00
|
|
|
gmio_stl_mesh_creator_occmesh base_creator(mesh);
|
2016-03-02 00:05:52 +08:00
|
|
|
gmio_stl_mesh_creator creator = {};
|
|
|
|
creator.cookie = &base_creator;
|
|
|
|
creator.func_begin_solid = my_mesh_creator__begin_solid;
|
|
|
|
creator.func_add_triangle = my_mesh_creator__add_triangle;
|
|
|
|
|
|
|
|
// Read, using default options(NULL)
|
|
|
|
error = gmio_stl_read_file(filepath, &creator, NULL);
|
|
|
|
if (error != GMIO_ERROR_OK)
|
|
|
|
std::cerr << "gmio error: 0x" << std::hex << error << std::endl;
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|