2015-09-11 16:51:25 +08:00
|
|
|
/****************************************************************************
|
2017-01-27 01:05:12 +08:00
|
|
|
** Copyright (c) 2017, Fougue Ltd. <http://www.fougue.pro>
|
2016-07-05 18:46:22 +08:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
**
|
|
|
|
** 2. Redistributions in binary form must reproduce the above
|
|
|
|
** copyright notice, this list of conditions and the following
|
|
|
|
** disclaimer in the documentation and/or other materials provided
|
|
|
|
** with the distribution.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2015-09-11 16:51:25 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
2017-01-30 18:41:20 +08:00
|
|
|
#pragma once
|
2015-09-11 16:51:25 +08:00
|
|
|
|
|
|
|
#include "../src/gmio_core/global.h"
|
|
|
|
#include "../src/gmio_stl/stl_mesh.h"
|
|
|
|
#include "../src/gmio_stl/stl_mesh_creator.h"
|
|
|
|
#include "../src/gmio_stl/stl_triangle.h"
|
|
|
|
#include "../src/gmio_stl/stlb_header.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2016-01-27 00:03:58 +08:00
|
|
|
bool gmio_stl_triangle_equal(
|
2015-12-04 01:00:25 +08:00
|
|
|
const struct gmio_stl_triangle* lhs,
|
|
|
|
const struct gmio_stl_triangle* rhs,
|
2015-09-11 22:35:04 +08:00
|
|
|
uint32_t max_ulp_diff);
|
|
|
|
|
2015-09-11 16:51:25 +08:00
|
|
|
/*! Does binary STL header \p lhs compare equal to \p rhs ? */
|
2016-01-27 00:03:58 +08:00
|
|
|
GMIO_INLINE bool gmio_stlb_header_equal(
|
2015-12-04 01:00:25 +08:00
|
|
|
const struct gmio_stlb_header* lhs, const struct gmio_stlb_header* rhs)
|
2015-09-11 16:51:25 +08:00
|
|
|
{
|
|
|
|
return memcmp(lhs, rhs, GMIO_STLB_HEADER_SIZE) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! Callback for gmio_stl_mesh_creator::func_add_triangle that does
|
|
|
|
* nothing(ie "no operation") */
|
|
|
|
void gmio_stl_nop_add_triangle(
|
2015-12-04 01:00:25 +08:00
|
|
|
void* cookie, uint32_t tri_id, const struct gmio_stl_triangle* triangle);
|
2015-09-11 16:51:25 +08:00
|
|
|
|
2015-09-14 16:42:38 +08:00
|
|
|
/*! Callback for gmio_stl_mesh::func_get_triangle that does nothing */
|
|
|
|
void gmio_stl_nop_get_triangle(
|
2015-12-04 01:00:25 +08:00
|
|
|
const void* cookie, uint32_t tri_id, struct gmio_stl_triangle* triangle);
|
2015-09-14 16:42:38 +08:00
|
|
|
|
2015-09-11 16:51:25 +08:00
|
|
|
/*! Holds an array of STL triangles */
|
|
|
|
struct gmio_stl_triangle_array
|
|
|
|
{
|
2015-12-04 01:00:25 +08:00
|
|
|
struct gmio_stl_triangle* ptr;
|
2015-09-11 16:51:25 +08:00
|
|
|
uint32_t count;
|
2015-09-11 22:35:04 +08:00
|
|
|
uint32_t capacity;
|
2015-09-11 16:51:25 +08:00
|
|
|
};
|
|
|
|
|
2015-12-04 01:00:25 +08:00
|
|
|
/*! Returns an dynamically allocated array of struct gmio_stl_triangle
|
2015-09-14 23:30:22 +08:00
|
|
|
*
|
|
|
|
* Contents of the memory block beginnning at gmio_stl_triangle_array::ptr
|
|
|
|
* is initialized with zeroes
|
|
|
|
*/
|
2015-12-04 01:00:25 +08:00
|
|
|
struct gmio_stl_triangle_array gmio_stl_triangle_array_malloc(size_t tri_count);
|
2015-09-11 22:35:04 +08:00
|
|
|
|
2016-02-24 23:43:40 +08:00
|
|
|
void gmio_stl_triangle_array_free(struct gmio_stl_triangle_array* array);
|
|
|
|
|
2015-09-11 16:51:25 +08:00
|
|
|
/*! Holds complete STL data (usable for both binary and ascii formats) */
|
|
|
|
struct gmio_stl_data
|
|
|
|
{
|
2015-12-04 01:00:25 +08:00
|
|
|
struct gmio_stlb_header header;
|
2015-09-11 22:35:04 +08:00
|
|
|
char solid_name[1024];
|
2015-12-04 01:00:25 +08:00
|
|
|
struct gmio_stl_triangle_array tri_array;
|
2015-09-11 16:51:25 +08:00
|
|
|
};
|
|
|
|
|
2015-12-04 01:00:25 +08:00
|
|
|
struct gmio_stl_mesh_creator gmio_stl_data_mesh_creator(struct gmio_stl_data* data);
|
|
|
|
struct gmio_stl_mesh gmio_stl_data_mesh(const struct gmio_stl_data* data);
|