This commit is contained in:
enricoturri1966 2020-10-12 11:47:25 +02:00
commit a633979d85
3 changed files with 10 additions and 10 deletions

View file

@ -28,7 +28,7 @@
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
#include <boost/nowide/cstdio.hpp> #include <boost/nowide/cstdio.hpp>
#include <boost/detail/endian.hpp> #include <boost/predef/other/endian.h>
#include "stl.h" #include "stl.h"
@ -36,9 +36,9 @@
#error "SEEK_SET not defined" #error "SEEK_SET not defined"
#endif #endif
#ifndef BOOST_LITTLE_ENDIAN #if BOOST_ENDIAN_BIG_BYTE
extern void stl_internal_reverse_quads(char *buf, size_t cnt); extern void stl_internal_reverse_quads(char *buf, size_t cnt);
#endif /* BOOST_LITTLE_ENDIAN */ #endif /* BOOST_ENDIAN_BIG_BYTE */
static FILE* stl_open_count_facets(stl_file *stl, const char *file) static FILE* stl_open_count_facets(stl_file *stl, const char *file)
{ {
@ -89,10 +89,10 @@ static FILE* stl_open_count_facets(stl_file *stl, const char *file)
// Read the int following the header. This should contain # of facets. // Read the int following the header. This should contain # of facets.
uint32_t header_num_facets; uint32_t header_num_facets;
bool header_num_faces_read = fread(&header_num_facets, sizeof(uint32_t), 1, fp) != 0; bool header_num_faces_read = fread(&header_num_facets, sizeof(uint32_t), 1, fp) != 0;
#ifndef BOOST_LITTLE_ENDIAN #if BOOST_ENDIAN_BIG_BYTE
// Convert from little endian to big endian. // Convert from little endian to big endian.
stl_internal_reverse_quads((char*)&header_num_facets, 4); stl_internal_reverse_quads((char*)&header_num_facets, 4);
#endif /* BOOST_LITTLE_ENDIAN */ #endif /* BOOST_ENDIAN_BIG_BYTE */
if (! header_num_faces_read || num_facets != header_num_facets) if (! header_num_faces_read || num_facets != header_num_facets)
BOOST_LOG_TRIVIAL(info) << "stl_open_count_facets: Warning: File size doesn't match number of facets in the header: " << file; BOOST_LOG_TRIVIAL(info) << "stl_open_count_facets: Warning: File size doesn't match number of facets in the header: " << file;
} }
@ -158,10 +158,10 @@ static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first)
// Read a single facet from a binary .STL file. We assume little-endian architecture! // Read a single facet from a binary .STL file. We assume little-endian architecture!
if (fread(&facet, 1, SIZEOF_STL_FACET, fp) != SIZEOF_STL_FACET) if (fread(&facet, 1, SIZEOF_STL_FACET, fp) != SIZEOF_STL_FACET)
return false; return false;
#ifndef BOOST_LITTLE_ENDIAN #if BOOST_ENDIAN_BIG_BYTE
// Convert the loaded little endian data to big endian. // Convert the loaded little endian data to big endian.
stl_internal_reverse_quads((char*)&facet, 48); stl_internal_reverse_quads((char*)&facet, 48);
#endif /* BOOST_LITTLE_ENDIAN */ #endif /* BOOST_ENDIAN_BIG_BYTE */
} else { } else {
// Read a single facet from an ASCII .STL file // Read a single facet from an ASCII .STL file
// skip solid/endsolid // skip solid/endsolid

View file

@ -1855,10 +1855,10 @@ void ObjectList::append_menu_item_scale_selection_to_fit_print_volume(wxMenu* me
void ObjectList::append_menu_items_convert_unit(wxMenu* menu) void ObjectList::append_menu_items_convert_unit(wxMenu* menu)
{ {
append_menu_item(menu, wxID_ANY, _L("Convert from imperial unit"), _L("Convert from imperial unit"), append_menu_item(menu, wxID_ANY, _L("Convert from imperial units"), _L("Convert from imperial units"),
[](wxCommandEvent&) { wxGetApp().plater()->convert_unit(true); }, "", menu); [](wxCommandEvent&) { wxGetApp().plater()->convert_unit(true); }, "", menu);
append_menu_item(menu, wxID_ANY, _L("Convert to imperial unit"), _L("Convert to imperial unit"), append_menu_item(menu, wxID_ANY, _L("Revert conversion from imperial units"), _L("Revert conversion from imperial units"),
[](wxCommandEvent&) { wxGetApp().plater()->convert_unit(false); }, "", menu); [](wxCommandEvent&) { wxGetApp().plater()->convert_unit(false); }, "", menu);
} }

View file

@ -4850,7 +4850,7 @@ void Plater::convert_unit(bool from_imperial_unit)
if (obj_idxs.empty() && volume_idxs.empty()) if (obj_idxs.empty() && volume_idxs.empty())
return; return;
TakeSnapshot snapshot(this, from_imperial_unit ? _L("Convert from imperial units") : _L("Convert to imperial units")); TakeSnapshot snapshot(this, from_imperial_unit ? _L("Convert from imperial units") : _L("Revert conversion from imperial units"));
wxBusyCursor wait; wxBusyCursor wait;
ModelObjectPtrs objects; ModelObjectPtrs objects;