Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastián Barschkis <sebbas@sebbas.org>2020-02-19 20:58:09 +0300
committerSebastián Barschkis <sebbas@sebbas.org>2020-02-19 20:58:48 +0300
commit888d180164004d121511609da044ea86c3aa9cb0 (patch)
tree217442311b8023be7aa609344fbd312e28d0c2e7 /extern/mantaflow/preprocessed/fileio
parent04b7f052e14ee6ff09b5cc4c85a76c4c5a1b0383 (diff)
Fluid: Updated manta pp files
Updates in the files include: - New manta files now use an platform independent gzopen function - Adjusted argument name for vorticity
Diffstat (limited to 'extern/mantaflow/preprocessed/fileio')
-rw-r--r--extern/mantaflow/preprocessed/fileio/iogrids.cpp18
-rw-r--r--extern/mantaflow/preprocessed/fileio/iomeshes.cpp8
-rw-r--r--extern/mantaflow/preprocessed/fileio/ioparticles.cpp8
-rw-r--r--extern/mantaflow/preprocessed/fileio/ioutil.cpp45
-rw-r--r--extern/mantaflow/preprocessed/fileio/mantaio.h2
5 files changed, 64 insertions, 17 deletions
diff --git a/extern/mantaflow/preprocessed/fileio/iogrids.cpp b/extern/mantaflow/preprocessed/fileio/iogrids.cpp
index 2b8ee905f99..acd1bda5174 100644
--- a/extern/mantaflow/preprocessed/fileio/iogrids.cpp
+++ b/extern/mantaflow/preprocessed/fileio/iogrids.cpp
@@ -298,7 +298,7 @@ template<class T> void writeGridRaw(const string &name, Grid<T> *grid)
debMsg("writing grid " << grid->getName() << " to raw file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeGridRaw: can't open file " << name);
gzwrite(gzf, &((*grid)[0]), sizeof(T) * grid->getSizeX() * grid->getSizeY() * grid->getSizeZ());
@@ -313,7 +313,7 @@ template<class T> void readGridRaw(const string &name, Grid<T> *grid)
debMsg("reading grid " << grid->getName() << " from raw file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("readGridRaw: can't open file " << name);
@@ -350,7 +350,7 @@ void getUniFileSize(const string &name, int &x, int &y, int &z, int *t, std::str
{
x = y = z = 0;
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (gzf) {
char ID[5] = {0, 0, 0, 0, 0};
gzread(gzf, ID, 4);
@@ -499,7 +499,7 @@ template<class T> void writeGridUni(const string &name, Grid<T> *grid)
else
errMsg("writeGridUni: unknown element type");
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeGridUni: can't open file " << name);
@@ -527,7 +527,7 @@ template<class T> void readGridUni(const string &name, Grid<T> *grid)
debMsg("Reading grid " << grid->getName() << " from uni file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("readGridUni: can't open file " << name);
@@ -736,7 +736,7 @@ template<class T> void writeGrid4dUni(const string &name, Grid4d<T> *grid)
else
errMsg("writeGrid4dUni: unknown element type");
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeGrid4dUni: can't open file " << name);
@@ -778,7 +778,7 @@ void readGrid4dUni(
// optionally - reuse file handle, if valid one is passed in fileHandle pointer...
if ((!fileHandle) || (fileHandle && (*fileHandle == NULL))) {
- gzf = gzopen(name.c_str(), "rb");
+ gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("readGrid4dUni: can't open file " << name);
@@ -905,7 +905,7 @@ template<class T> void writeGrid4dRaw(const string &name, Grid4d<T> *grid)
debMsg("writing grid4d " << grid->getName() << " to raw file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeGrid4dRaw: can't open file " << name);
gzwrite(gzf,
@@ -922,7 +922,7 @@ template<class T> void readGrid4dRaw(const string &name, Grid4d<T> *grid)
debMsg("reading grid4d " << grid->getName() << " from raw file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("readGrid4dRaw: can't open file " << name);
diff --git a/extern/mantaflow/preprocessed/fileio/iomeshes.cpp b/extern/mantaflow/preprocessed/fileio/iomeshes.cpp
index 79a9e76da3f..906b849fffb 100644
--- a/extern/mantaflow/preprocessed/fileio/iomeshes.cpp
+++ b/extern/mantaflow/preprocessed/fileio/iomeshes.cpp
@@ -158,7 +158,7 @@ void readBobjFile(const string &name, Mesh *mesh, bool append)
const Real dx = mesh->getParent()->getDx();
const Vec3 gs = toVec3(mesh->getParent()->getGridSize());
- gzFile gzf = gzopen(name.c_str(), "rb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb1"); // do some compression
if (!gzf)
errMsg("readBobj: unable to open file");
@@ -213,7 +213,7 @@ void writeBobjFile(const string &name, Mesh *mesh)
const Real dx = mesh->getParent()->getDx();
const Vec3i gs = mesh->getParent()->getGridSize();
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeBobj: unable to open file");
@@ -412,7 +412,7 @@ template<class T> void readMdataUni(const std::string &name, MeshDataImpl<T> *md
debMsg("reading mesh data " << mdata->getName() << " from uni file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("can't open file " << name);
@@ -460,7 +460,7 @@ template<class T> void writeMdataUni(const std::string &name, MeshDataImpl<T> *m
MuTime stamp;
head.timestamp = stamp.time;
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("can't open file " << name);
gzwrite(gzf, ID, 4);
diff --git a/extern/mantaflow/preprocessed/fileio/ioparticles.cpp b/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
index a6cc7583327..2eab485beb3 100644
--- a/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
+++ b/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
@@ -176,7 +176,7 @@ void writeParticlesUni(const std::string &name, const BasicParticleSystem *parts
MuTime stamp;
head.timestamp = stamp.time;
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("can't open file " << name);
@@ -206,7 +206,7 @@ void readParticlesUni(const std::string &name, BasicParticleSystem *parts)
debMsg("reading particles " << parts->getName() << " from uni file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("can't open file " << name);
@@ -273,7 +273,7 @@ template<class T> void writePdataUni(const std::string &name, ParticleDataImpl<T
MuTime stamp;
head.timestamp = stamp.time;
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("can't open file " << name);
gzwrite(gzf, ID, 4);
@@ -299,7 +299,7 @@ template<class T> void readPdataUni(const std::string &name, ParticleDataImpl<T>
debMsg("reading particle data " << pdata->getName() << " from uni file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("can't open file " << name);
diff --git a/extern/mantaflow/preprocessed/fileio/ioutil.cpp b/extern/mantaflow/preprocessed/fileio/ioutil.cpp
new file mode 100644
index 00000000000..7c1682dfc5e
--- /dev/null
+++ b/extern/mantaflow/preprocessed/fileio/ioutil.cpp
@@ -0,0 +1,45 @@
+
+
+// DO NOT EDIT !
+// This file is generated using the MantaFlow preprocessor (prep generate).
+
+/******************************************************************************
+ *
+ * MantaFlow fluid solver framework
+ * Copyright 2011-2020 Tobias Pfaff, Nils Thuerey
+ *
+ * This program is free software, distributed under the terms of the
+ * Apache License, Version 2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Helper functions to handle file IO
+ *
+ ******************************************************************************/
+
+#include "mantaio.h"
+
+#if NO_ZLIB != 1
+extern "C" {
+# include <zlib.h>
+}
+
+namespace Manta {
+
+//! helper to handle non ascii filenames correctly, mainly problematic on windows
+void *safeGzopen(const char *filename, const char *mode)
+{
+ gzFile gzfile;
+# if defined(WIN32) || defined(_WIN32)
+ UTF16_ENCODE(filename);
+
+ // gzopen_w() is supported since zlib v1.2.7
+ gzfile = gzopen_w(filename_16, mode);
+ UTF16_UN_ENCODE(filename);
+# else
+ gzfile = gzopen(filename, mode);
+# endif
+ return gzfile;
+}
+#endif
+
+} // namespace
diff --git a/extern/mantaflow/preprocessed/fileio/mantaio.h b/extern/mantaflow/preprocessed/fileio/mantaio.h
index 8bb0a5af6a4..fbfe4bdd5d4 100644
--- a/extern/mantaflow/preprocessed/fileio/mantaio.h
+++ b/extern/mantaflow/preprocessed/fileio/mantaio.h
@@ -76,6 +76,8 @@ template<class T> void readMdataUni(const std::string &name, MeshDataImpl<T> *md
void getUniFileSize(
const std::string &name, int &x, int &y, int &z, int *t = NULL, std::string *info = NULL);
+void *safeGzopen(const char *filename, const char *mode);
+
} // namespace Manta
#endif