From e6d802a5ffc5a13d59d4a21b2e94679ed0aeb8fe Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 15 Nov 2016 17:22:00 +0100 Subject: [PATCH] Fixed a 64bit compatiblity in admesh, fixed a typo in TriangleMesh::swap() --- xs/src/admesh/stl.h | 10 +++++++++- xs/src/libslic3r/TriangleMesh.cpp | 8 ++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/xs/src/admesh/stl.h b/xs/src/admesh/stl.h index 25fe770aa..3e498d929 100644 --- a/xs/src/admesh/stl.h +++ b/xs/src/admesh/stl.h @@ -24,6 +24,7 @@ #define __admesh_stl__ #include +#include #ifdef __cplusplus extern "C" { @@ -33,11 +34,15 @@ extern "C" { #define STL_MIN(A,B) ((A)<(B)? (A):(B)) #define ABS(X) ((X) < 0 ? -(X) : (X)) +// Size of the binary STL header, free form. #define LABEL_SIZE 80 +// Binary STL, length of the "number of faces" counter. #define NUM_FACET_SIZE 4 +// Binary STL, sizeof header + number of faces. #define HEADER_SIZE 84 #define STL_MIN_FILE_SIZE 284 #define ASCII_LINES_PER_FACET 7 +// Comparing an edge by memcmp, 2x3x4 bytes = 24 #define SIZEOF_EDGE_SORT 24 typedef struct { @@ -70,14 +75,17 @@ typedef struct { } stl_edge; typedef struct stl_hash_edge { - unsigned key[6]; + // Key of a hash edge: 2x binary copy of a floating point vertex. + uint32_t key[6]; int facet_number; int which_edge; struct stl_hash_edge *next; } stl_hash_edge; typedef struct { + // Index of a neighbor facet. int neighbor[3]; + // Index of an opposite vertex at the neighbor face. char which_vertex_not[3]; } stl_neighbors; diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp index 7c6e7fbce..5737747a2 100644 --- a/xs/src/libslic3r/TriangleMesh.cpp +++ b/xs/src/libslic3r/TriangleMesh.cpp @@ -58,12 +58,8 @@ TriangleMesh& TriangleMesh::operator= (TriangleMesh other) void TriangleMesh::swap(TriangleMesh &other) { - std::swap(this->stl, other.stl); - std::swap(this->repaired, other.repaired); - std::swap(this->stl.facet_start, other.stl.facet_start); - std::swap(this->stl.neighbors_start, other.stl.neighbors_start); - std::swap(this->stl.v_indices, other.stl.v_indices); - std::swap(this->stl.v_shared, other.stl.v_shared); + std::swap(this->stl, other.stl); + std::swap(this->repaired, other.repaired); } TriangleMesh::~TriangleMesh() {