mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-25 17:51:10 -06:00
admesh: Fixed a problem in loading an STL when compiled with
Visual Studio 2013. Added multiple compile time checks for data sizes and alignment. The library STL import is not big endian safe, so added a test for endianity, modified STL export to a faster little endian only.
This commit is contained in:
parent
9772584d78
commit
2085a482c7
3 changed files with 24 additions and 72 deletions
|
|
@ -25,6 +25,12 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <boost/predef/detail/endian_compat.h>
|
||||
|
||||
#ifndef BOOST_LITTLE_ENDIAN
|
||||
#error "admesh works correctly on little endian machines only!"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -51,12 +57,16 @@ typedef struct {
|
|||
float z;
|
||||
} stl_vertex;
|
||||
|
||||
static_assert(sizeof(stl_vertex) == 12, "size of stl_vertex incorrect");
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} stl_normal;
|
||||
|
||||
static_assert(sizeof(stl_normal) == 12, "size of stl_normal incorrect");
|
||||
|
||||
typedef char stl_extra[2];
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -66,6 +76,11 @@ typedef struct {
|
|||
} stl_facet;
|
||||
#define SIZEOF_STL_FACET 50
|
||||
|
||||
static_assert(offsetof(stl_facet, normal) == 0, "stl_facet.normal has correct offset");
|
||||
static_assert(offsetof(stl_facet, vertex) == 12, "stl_facet.vertex has correct offset");
|
||||
static_assert(offsetof(stl_facet, extra ) == 48, "stl_facet.extra has correct offset");
|
||||
static_assert(sizeof(stl_facet) >= SIZEOF_STL_FACET, "size of stl_facet incorrect");
|
||||
|
||||
typedef enum {binary, ascii, inmemory} stl_type;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -85,6 +100,8 @@ typedef struct stl_hash_edge {
|
|||
struct stl_hash_edge *next;
|
||||
} stl_hash_edge;
|
||||
|
||||
static_assert(offsetof(stl_hash_edge, facet_number) == SIZEOF_EDGE_SORT, "size of stl_hash_edge.key incorrect");
|
||||
|
||||
typedef struct {
|
||||
// Index of a neighbor facet.
|
||||
int neighbor[3];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue