From b8af5e10620fe92f45c5e5003bfb6ef8d91e29bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Barschkis?= Date: Fri, 21 Feb 2020 15:29:32 +0100 Subject: Fluid: Updated manta pp files Updates include: - A fix from Jacques that changed the loop order in the mesh creation function (the fix speeds up the function significantly due to fewer cache misses). - Some of the grid copy helper functions are now multithreaded. - A fix for Windows file IO. Now it possible to load files with non ASCII characters on Windows too. --- extern/mantaflow/preprocessed/fileio/ioutil.cpp | 27 +++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'extern/mantaflow/preprocessed/fileio') diff --git a/extern/mantaflow/preprocessed/fileio/ioutil.cpp b/extern/mantaflow/preprocessed/fileio/ioutil.cpp index 0bbbc7b6d11..e04633c5634 100644 --- a/extern/mantaflow/preprocessed/fileio/ioutil.cpp +++ b/extern/mantaflow/preprocessed/fileio/ioutil.cpp @@ -23,21 +23,36 @@ extern "C" { # include } +# if defined(WIN32) || defined(_WIN32) +# include +# include +# endif + +using namespace std; + namespace Manta { -//! helper to handle non ascii filenames correctly, mainly problematic on windows +# if defined(WIN32) || defined(_WIN32) +static wstring stringToWstring(const char *str) +{ + const int length_wc = MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), NULL, 0); + wstring strWide(length_wc, 0); + MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), &strWide[0], length_wc); + return strWide; +} +# endif + void *safeGzopen(const char *filename, const char *mode) { gzFile gzfile; -# if 0 - UTF16_ENCODE(filename); - // gzopen_w() is supported since zlib v1.2.7 - gzfile = gzopen_w(filename_16, mode); - UTF16_UN_ENCODE(filename); +# if defined(WIN32) || defined(_WIN32) + wstring filenameWide = stringToWstring(filename); + gzfile = gzopen_w(filenameWide.c_str(), mode); # else gzfile = gzopen(filename, mode); # endif + return gzfile; } #endif -- cgit v1.2.3