From 6b6e2e742ff4393a73e982e0a3d6dae934ad20f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastia=CC=81n=20Barschkis?= Date: Tue, 21 Jul 2020 15:22:21 +0200 Subject: Fluid: Updated Mantaflow source files Updated files include fixes for the mesh IO - read/write success was not propagated. --- extern/mantaflow/preprocessed/gitinfo.h | 2 +- extern/mantaflow/preprocessed/mesh.cpp | 28 ++++--- extern/mantaflow/preprocessed/mesh.h | 117 +++++++++++++-------------- extern/mantaflow/preprocessed/mesh.h.reg.cpp | 16 ++-- 4 files changed, 82 insertions(+), 81 deletions(-) (limited to 'extern') diff --git a/extern/mantaflow/preprocessed/gitinfo.h b/extern/mantaflow/preprocessed/gitinfo.h index 5763d31f7fb..3271a858911 100644 --- a/extern/mantaflow/preprocessed/gitinfo.h +++ b/extern/mantaflow/preprocessed/gitinfo.h @@ -1,3 +1,3 @@ -#define MANTA_GIT_VERSION "commit 78ecf1940765e45d8fc15b3304a622785a84939e" +#define MANTA_GIT_VERSION "commit 3370c2014ad7192041cb4fbed19ed74ae9725fb5" diff --git a/extern/mantaflow/preprocessed/mesh.cpp b/extern/mantaflow/preprocessed/mesh.cpp index 7a27b88ece7..6a9b0283bef 100644 --- a/extern/mantaflow/preprocessed/mesh.cpp +++ b/extern/mantaflow/preprocessed/mesh.cpp @@ -213,34 +213,36 @@ Mesh &Mesh::operator=(const Mesh &o) return *this; } -void Mesh::load(string name, bool append) +int Mesh::load(string name, bool append) { if (name.find_last_of('.') == string::npos) errMsg("file '" + name + "' does not have an extension"); string ext = name.substr(name.find_last_of('.')); if (ext == ".gz") // assume bobj gz - readBobjFile(name, this, append); + return readBobjFile(name, this, append); else if (ext == ".obj") - readObjFile(name, this, append); + return readObjFile(name, this, append); else errMsg("file '" + name + "' filetype not supported"); // dont always rebuild... // rebuildCorners(); // rebuildLookup(); + return 0; } -void Mesh::save(string name) +int Mesh::save(string name) { if (name.find_last_of('.') == string::npos) errMsg("file '" + name + "' does not have an extension"); string ext = name.substr(name.find_last_of('.')); if (ext == ".obj") - writeObjFile(name, this); + return writeObjFile(name, this); else if (ext == ".gz") - writeBobjFile(name, this); + return writeBobjFile(name, this); else errMsg("file '" + name + "' filetype not supported"); + return 0; } void Mesh::fromShape(Shape &shape, bool append) @@ -1379,30 +1381,32 @@ void Mesh::updateDataFields() } } -template void MeshDataImpl::load(string name) +template int MeshDataImpl::load(string name) { if (name.find_last_of('.') == string::npos) errMsg("file '" + name + "' does not have an extension"); string ext = name.substr(name.find_last_of('.')); if (ext == ".uni") - readMdataUni(name, this); + return readMdataUni(name, this); else if (ext == ".raw") // raw = uni for now - readMdataUni(name, this); + return readMdataUni(name, this); else errMsg("mesh data '" + name + "' filetype not supported for loading"); + return 0; } -template void MeshDataImpl::save(string name) +template int MeshDataImpl::save(string name) { if (name.find_last_of('.') == string::npos) errMsg("file '" + name + "' does not have an extension"); string ext = name.substr(name.find_last_of('.')); if (ext == ".uni") - writeMdataUni(name, this); + return writeMdataUni(name, this); else if (ext == ".raw") // raw = uni for now - writeMdataUni(name, this); + return writeMdataUni(name, this); else errMsg("mesh data '" + name + "' filetype not supported for saving"); + return 0; } // specializations diff --git a/extern/mantaflow/preprocessed/mesh.h b/extern/mantaflow/preprocessed/mesh.h index f49619515ce..4235b9508af 100644 --- a/extern/mantaflow/preprocessed/mesh.h +++ b/extern/mantaflow/preprocessed/mesh.h @@ -240,215 +240,214 @@ class Mesh : public PbClass { } } - void load(std::string name, bool append = false); + void fromShape(Shape &shape, bool append = false); static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); Mesh *pbo = dynamic_cast(Pb::objFromPy(_self)); bool noTiming = _args.getOpt("notiming", -1, 0); - pbPreparePlugin(pbo->getParent(), "Mesh::load", !noTiming); + pbPreparePlugin(pbo->getParent(), "Mesh::fromShape", !noTiming); PyObject *_retval = 0; { ArgLocker _lock; - std::string name = _args.get("name", 0, &_lock); + Shape &shape = *_args.getPtr("shape", 0, &_lock); bool append = _args.getOpt("append", 1, false, &_lock); pbo->_args.copy(_args); _retval = getPyNone(); - pbo->load(name, append); + pbo->fromShape(shape, append); pbo->_args.check(); } - pbFinalizePlugin(pbo->getParent(), "Mesh::load", !noTiming); + pbFinalizePlugin(pbo->getParent(), "Mesh::fromShape", !noTiming); return _retval; } catch (std::exception &e) { - pbSetError("Mesh::load", e.what()); + pbSetError("Mesh::fromShape", e.what()); return 0; } } - void fromShape(Shape &shape, bool append = false); + void advectInGrid(FlagGrid &flags, MACGrid &vel, int integrationMode); static PyObject *_W_3(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); Mesh *pbo = dynamic_cast(Pb::objFromPy(_self)); bool noTiming = _args.getOpt("notiming", -1, 0); - pbPreparePlugin(pbo->getParent(), "Mesh::fromShape", !noTiming); + pbPreparePlugin(pbo->getParent(), "Mesh::advectInGrid", !noTiming); PyObject *_retval = 0; { ArgLocker _lock; - Shape &shape = *_args.getPtr("shape", 0, &_lock); - bool append = _args.getOpt("append", 1, false, &_lock); + FlagGrid &flags = *_args.getPtr("flags", 0, &_lock); + MACGrid &vel = *_args.getPtr("vel", 1, &_lock); + int integrationMode = _args.get("integrationMode", 2, &_lock); pbo->_args.copy(_args); _retval = getPyNone(); - pbo->fromShape(shape, append); + pbo->advectInGrid(flags, vel, integrationMode); pbo->_args.check(); } - pbFinalizePlugin(pbo->getParent(), "Mesh::fromShape", !noTiming); + pbFinalizePlugin(pbo->getParent(), "Mesh::advectInGrid", !noTiming); return _retval; } catch (std::exception &e) { - pbSetError("Mesh::fromShape", e.what()); + pbSetError("Mesh::advectInGrid", e.what()); return 0; } } - void save(std::string name); + void scale(Vec3 s); static PyObject *_W_4(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); Mesh *pbo = dynamic_cast(Pb::objFromPy(_self)); bool noTiming = _args.getOpt("notiming", -1, 0); - pbPreparePlugin(pbo->getParent(), "Mesh::save", !noTiming); + pbPreparePlugin(pbo->getParent(), "Mesh::scale", !noTiming); PyObject *_retval = 0; { ArgLocker _lock; - std::string name = _args.get("name", 0, &_lock); + Vec3 s = _args.get("s", 0, &_lock); pbo->_args.copy(_args); _retval = getPyNone(); - pbo->save(name); + pbo->scale(s); pbo->_args.check(); } - pbFinalizePlugin(pbo->getParent(), "Mesh::save", !noTiming); + pbFinalizePlugin(pbo->getParent(), "Mesh::scale", !noTiming); return _retval; } catch (std::exception &e) { - pbSetError("Mesh::save", e.what()); + pbSetError("Mesh::scale", e.what()); return 0; } } - void advectInGrid(FlagGrid &flags, MACGrid &vel, int integrationMode); + void offset(Vec3 o); static PyObject *_W_5(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); Mesh *pbo = dynamic_cast(Pb::objFromPy(_self)); bool noTiming = _args.getOpt("notiming", -1, 0); - pbPreparePlugin(pbo->getParent(), "Mesh::advectInGrid", !noTiming); + pbPreparePlugin(pbo->getParent(), "Mesh::offset", !noTiming); PyObject *_retval = 0; { ArgLocker _lock; - FlagGrid &flags = *_args.getPtr("flags", 0, &_lock); - MACGrid &vel = *_args.getPtr("vel", 1, &_lock); - int integrationMode = _args.get("integrationMode", 2, &_lock); + Vec3 o = _args.get("o", 0, &_lock); pbo->_args.copy(_args); _retval = getPyNone(); - pbo->advectInGrid(flags, vel, integrationMode); + pbo->offset(o); pbo->_args.check(); } - pbFinalizePlugin(pbo->getParent(), "Mesh::advectInGrid", !noTiming); + pbFinalizePlugin(pbo->getParent(), "Mesh::offset", !noTiming); return _retval; } catch (std::exception &e) { - pbSetError("Mesh::advectInGrid", e.what()); + pbSetError("Mesh::offset", e.what()); return 0; } } - void scale(Vec3 s); + void rotate(Vec3 thetas); static PyObject *_W_6(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); Mesh *pbo = dynamic_cast(Pb::objFromPy(_self)); bool noTiming = _args.getOpt("notiming", -1, 0); - pbPreparePlugin(pbo->getParent(), "Mesh::scale", !noTiming); + pbPreparePlugin(pbo->getParent(), "Mesh::rotate", !noTiming); PyObject *_retval = 0; { ArgLocker _lock; - Vec3 s = _args.get("s", 0, &_lock); + Vec3 thetas = _args.get("thetas", 0, &_lock); pbo->_args.copy(_args); _retval = getPyNone(); - pbo->scale(s); + pbo->rotate(thetas); pbo->_args.check(); } - pbFinalizePlugin(pbo->getParent(), "Mesh::scale", !noTiming); + pbFinalizePlugin(pbo->getParent(), "Mesh::rotate", !noTiming); return _retval; } catch (std::exception &e) { - pbSetError("Mesh::scale", e.what()); + pbSetError("Mesh::rotate", e.what()); return 0; } } - void offset(Vec3 o); + void computeVelocity(Mesh &oldMesh, MACGrid &vel); static PyObject *_W_7(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); Mesh *pbo = dynamic_cast(Pb::objFromPy(_self)); bool noTiming = _args.getOpt("notiming", -1, 0); - pbPreparePlugin(pbo->getParent(), "Mesh::offset", !noTiming); + pbPreparePlugin(pbo->getParent(), "Mesh::computeVelocity", !noTiming); PyObject *_retval = 0; { ArgLocker _lock; - Vec3 o = _args.get("o", 0, &_lock); + Mesh &oldMesh = *_args.getPtr("oldMesh", 0, &_lock); + MACGrid &vel = *_args.getPtr("vel", 1, &_lock); pbo->_args.copy(_args); _retval = getPyNone(); - pbo->offset(o); + pbo->computeVelocity(oldMesh, vel); pbo->_args.check(); } - pbFinalizePlugin(pbo->getParent(), "Mesh::offset", !noTiming); + pbFinalizePlugin(pbo->getParent(), "Mesh::computeVelocity", !noTiming); return _retval; } catch (std::exception &e) { - pbSetError("Mesh::offset", e.what()); + pbSetError("Mesh::computeVelocity", e.what()); return 0; } } - void rotate(Vec3 thetas); + //! file io + int load(std::string name, bool append = false); static PyObject *_W_8(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); Mesh *pbo = dynamic_cast(Pb::objFromPy(_self)); bool noTiming = _args.getOpt("notiming", -1, 0); - pbPreparePlugin(pbo->getParent(), "Mesh::rotate", !noTiming); + pbPreparePlugin(pbo->getParent(), "Mesh::load", !noTiming); PyObject *_retval = 0; { ArgLocker _lock; - Vec3 thetas = _args.get("thetas", 0, &_lock); + std::string name = _args.get("name", 0, &_lock); + bool append = _args.getOpt("append", 1, false, &_lock); pbo->_args.copy(_args); - _retval = getPyNone(); - pbo->rotate(thetas); + _retval = toPy(pbo->load(name, append)); pbo->_args.check(); } - pbFinalizePlugin(pbo->getParent(), "Mesh::rotate", !noTiming); + pbFinalizePlugin(pbo->getParent(), "Mesh::load", !noTiming); return _retval; } catch (std::exception &e) { - pbSetError("Mesh::rotate", e.what()); + pbSetError("Mesh::load", e.what()); return 0; } } - void computeVelocity(Mesh &oldMesh, MACGrid &vel); + int save(std::string name); static PyObject *_W_9(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); Mesh *pbo = dynamic_cast(Pb::objFromPy(_self)); bool noTiming = _args.getOpt("notiming", -1, 0); - pbPreparePlugin(pbo->getParent(), "Mesh::computeVelocity", !noTiming); + pbPreparePlugin(pbo->getParent(), "Mesh::save", !noTiming); PyObject *_retval = 0; { ArgLocker _lock; - Mesh &oldMesh = *_args.getPtr("oldMesh", 0, &_lock); - MACGrid &vel = *_args.getPtr("vel", 1, &_lock); + std::string name = _args.get("name", 0, &_lock); pbo->_args.copy(_args); - _retval = getPyNone(); - pbo->computeVelocity(oldMesh, vel); + _retval = toPy(pbo->save(name)); pbo->_args.check(); } - pbFinalizePlugin(pbo->getParent(), "Mesh::computeVelocity", !noTiming); + pbFinalizePlugin(pbo->getParent(), "Mesh::save", !noTiming); return _retval; } catch (std::exception &e) { - pbSetError("Mesh::computeVelocity", e.what()); + pbSetError("Mesh::save", e.what()); return 0; } } @@ -1564,7 +1563,7 @@ template class MeshDataImpl : public MeshDataBase { } //! file io - void save(const std::string name); + int save(const std::string name); static PyObject *_W_41(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { @@ -1577,8 +1576,7 @@ template class MeshDataImpl : public MeshDataBase { ArgLocker _lock; const std::string name = _args.get("name", 0, &_lock); pbo->_args.copy(_args); - _retval = getPyNone(); - pbo->save(name); + _retval = toPy(pbo->save(name)); pbo->_args.check(); } pbFinalizePlugin(pbo->getParent(), "MeshDataImpl::save", !noTiming); @@ -1590,7 +1588,7 @@ template class MeshDataImpl : public MeshDataBase { } } - void load(const std::string name); + int load(const std::string name); static PyObject *_W_42(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { @@ -1603,8 +1601,7 @@ template class MeshDataImpl : public MeshDataBase { ArgLocker _lock; const std::string name = _args.get("name", 0, &_lock); pbo->_args.copy(_args); - _retval = getPyNone(); - pbo->load(name); + _retval = toPy(pbo->load(name)); pbo->_args.check(); } pbFinalizePlugin(pbo->getParent(), "MeshDataImpl::load", !noTiming); diff --git a/extern/mantaflow/preprocessed/mesh.h.reg.cpp b/extern/mantaflow/preprocessed/mesh.h.reg.cpp index b2ba3e22032..664e4c3ff6e 100644 --- a/extern/mantaflow/preprocessed/mesh.h.reg.cpp +++ b/extern/mantaflow/preprocessed/mesh.h.reg.cpp @@ -10,14 +10,14 @@ static const Pb::Register _R_12("Mesh", "Mesh", "PbClass"); template<> const char *Namify::S = "Mesh"; static const Pb::Register _R_13("Mesh", "Mesh", Mesh::_W_0); static const Pb::Register _R_14("Mesh", "clear", Mesh::_W_1); -static const Pb::Register _R_15("Mesh", "load", Mesh::_W_2); -static const Pb::Register _R_16("Mesh", "fromShape", Mesh::_W_3); -static const Pb::Register _R_17("Mesh", "save", Mesh::_W_4); -static const Pb::Register _R_18("Mesh", "advectInGrid", Mesh::_W_5); -static const Pb::Register _R_19("Mesh", "scale", Mesh::_W_6); -static const Pb::Register _R_20("Mesh", "offset", Mesh::_W_7); -static const Pb::Register _R_21("Mesh", "rotate", Mesh::_W_8); -static const Pb::Register _R_22("Mesh", "computeVelocity", Mesh::_W_9); +static const Pb::Register _R_15("Mesh", "fromShape", Mesh::_W_2); +static const Pb::Register _R_16("Mesh", "advectInGrid", Mesh::_W_3); +static const Pb::Register _R_17("Mesh", "scale", Mesh::_W_4); +static const Pb::Register _R_18("Mesh", "offset", Mesh::_W_5); +static const Pb::Register _R_19("Mesh", "rotate", Mesh::_W_6); +static const Pb::Register _R_20("Mesh", "computeVelocity", Mesh::_W_7); +static const Pb::Register _R_21("Mesh", "load", Mesh::_W_8); +static const Pb::Register _R_22("Mesh", "save", Mesh::_W_9); static const Pb::Register _R_23("Mesh", "computeLevelset", Mesh::_W_10); static const Pb::Register _R_24("Mesh", "getLevelset", Mesh::_W_11); static const Pb::Register _R_25("Mesh", "applyMeshToGrid", Mesh::_W_12); -- cgit v1.2.3