diff options
Diffstat (limited to 'extern/mantaflow/preprocessed/grid.h')
-rw-r--r-- | extern/mantaflow/preprocessed/grid.h | 102 |
1 files changed, 67 insertions, 35 deletions
diff --git a/extern/mantaflow/preprocessed/grid.h b/extern/mantaflow/preprocessed/grid.h index a7aac80891a..9bd4e5d72d9 100644 --- a/extern/mantaflow/preprocessed/grid.h +++ b/extern/mantaflow/preprocessed/grid.h @@ -355,6 +355,38 @@ class GridBase : public PbClass { return isInBounds(Vec3i(i, j, k), bnd); } +#ifdef BLENDER + //! expose name field to Python for Blender + void setName(const std::string &name) + { + mName = name; + } + static PyObject *_W_9(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + { + try { + PbArgs _args(_linargs, _kwds); + GridBase *pbo = dynamic_cast<GridBase *>(Pb::objFromPy(_self)); + bool noTiming = _args.getOpt<bool>("notiming", -1, 0); + pbPreparePlugin(pbo->getParent(), "GridBase::setName", !noTiming); + PyObject *_retval = 0; + { + ArgLocker _lock; + const std::string &name = _args.get<std::string>("name", 0, &_lock); + pbo->_args.copy(_args); + _retval = getPyNone(); + pbo->setName(name); + pbo->_args.check(); + } + pbFinalizePlugin(pbo->getParent(), "GridBase::setName", !noTiming); + return _retval; + } + catch (std::exception &e) { + pbSetError("GridBase::setName", e.what()); + return 0; + } + } + +#endif protected: GridType mType; Vec3i mSize; @@ -373,7 +405,7 @@ template<class T> class Grid : public GridBase { public: //! init new grid, values are set to zero Grid(FluidSolver *parent, bool show = true); - static int _W_9(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static int _W_10(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { PbClass *obj = Pb::objFromPy(_self); if (obj) @@ -410,7 +442,7 @@ template<class T> class Grid : public GridBase { typedef GridBase BASETYPE_GRID; int save(std::string name); - static PyObject *_W_10(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_11(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -435,7 +467,7 @@ template<class T> class Grid : public GridBase { } int load(std::string name); - static PyObject *_W_11(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_12(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -461,7 +493,7 @@ template<class T> class Grid : public GridBase { //! set all cells to zero void clear(); - static PyObject *_W_12(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_13(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -588,7 +620,7 @@ template<class T> class Grid : public GridBase { // Grid<T>& operator=(const Grid<T>& a); //! copy content from other grid (use this one instead of operator= !) Grid<T> ©From(const Grid<T> &a, bool copyType = true); - static PyObject *_W_13(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_14(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -618,7 +650,7 @@ template<class T> class Grid : public GridBase { //! get grid type int getGridType(); - static PyObject *_W_14(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_15(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -643,7 +675,7 @@ template<class T> class Grid : public GridBase { //! add/subtract other grid void add(const Grid<T> &a); - static PyObject *_W_15(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_16(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -669,7 +701,7 @@ template<class T> class Grid : public GridBase { } void sub(const Grid<T> &a); - static PyObject *_W_16(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_17(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -696,7 +728,7 @@ template<class T> class Grid : public GridBase { //! set all cells to constant value void setConst(T s); - static PyObject *_W_17(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_18(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -723,7 +755,7 @@ template<class T> class Grid : public GridBase { //! add constant to all grid cells void addConst(T s); - static PyObject *_W_18(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_19(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -750,7 +782,7 @@ template<class T> class Grid : public GridBase { //! add scaled other grid to current one (note, only "Real" factor, "T" type not supported here!) void addScaled(const Grid<T> &a, const T &factor); - static PyObject *_W_19(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_20(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -778,7 +810,7 @@ template<class T> class Grid : public GridBase { //! multiply contents of grid void mult(const Grid<T> &a); - static PyObject *_W_20(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_21(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -805,7 +837,7 @@ template<class T> class Grid : public GridBase { //! multiply each cell by a constant scalar value void multConst(T s); - static PyObject *_W_21(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_22(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -832,7 +864,7 @@ template<class T> class Grid : public GridBase { //! safely divide contents of grid (with zero check) Grid<T> &safeDivide(const Grid<T> &a); - static PyObject *_W_22(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_23(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -858,7 +890,7 @@ template<class T> class Grid : public GridBase { //! clamp content to range (for vec3, clamps each component separately) void clamp(Real min, Real max); - static PyObject *_W_23(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_24(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -886,7 +918,7 @@ template<class T> class Grid : public GridBase { //! reduce small values to zero void stomp(const T &threshold); - static PyObject *_W_24(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_25(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -913,7 +945,7 @@ template<class T> class Grid : public GridBase { //! permute grid axes, e.g. switch y with z (0,2,1) void permuteAxes(int axis0, int axis1, int axis2); - static PyObject *_W_25(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_26(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -942,7 +974,7 @@ template<class T> class Grid : public GridBase { //! permute grid axes, e.g. switch y with z (0,2,1) void permuteAxesCopyToGrid(int axis0, int axis1, int axis2, Grid<T> &out); - static PyObject *_W_26(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_27(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -972,7 +1004,7 @@ template<class T> class Grid : public GridBase { //! join other grid by either keeping min or max value at cell void join(const Grid<T> &a, bool keepMax = true); - static PyObject *_W_27(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_28(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1001,7 +1033,7 @@ template<class T> class Grid : public GridBase { // common compound operators //! get absolute max value in grid Real getMaxAbs() const; - static PyObject *_W_28(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_29(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1026,7 +1058,7 @@ template<class T> class Grid : public GridBase { //! get max value in grid Real getMax() const; - static PyObject *_W_29(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_30(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1051,7 +1083,7 @@ template<class T> class Grid : public GridBase { //! get min value in grid Real getMin() const; - static PyObject *_W_30(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_31(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1076,7 +1108,7 @@ template<class T> class Grid : public GridBase { //! calculate L1 norm of grid content Real getL1(int bnd = 0); - static PyObject *_W_31(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_32(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1102,7 +1134,7 @@ template<class T> class Grid : public GridBase { //! calculate L2 norm of grid content Real getL2(int bnd = 0); - static PyObject *_W_32(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_33(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1128,7 +1160,7 @@ template<class T> class Grid : public GridBase { //! set all boundary cells to constant value (Dirichlet) void setBound(T value, int boundaryWidth = 1); - static PyObject *_W_33(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_34(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1156,7 +1188,7 @@ template<class T> class Grid : public GridBase { //! set all boundary cells to last inner value (Neumann) void setBoundNeumann(int boundaryWidth = 1); - static PyObject *_W_34(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_35(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1183,7 +1215,7 @@ template<class T> class Grid : public GridBase { //! get data pointer of grid std::string getDataPointer(); - static PyObject *_W_35(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_36(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1208,7 +1240,7 @@ template<class T> class Grid : public GridBase { //! debugging helper, print grid from python. skip boundary of width bnd void printGrid(int zSlice = -1, bool printIndex = false, int bnd = 1); - static PyObject *_W_36(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_37(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1276,7 +1308,7 @@ class MACGrid : public Grid<Vec3> { { mType = (GridType)(TypeMAC | TypeVec3); } - static int _W_37(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static int _W_38(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { PbClass *obj = Pb::objFromPy(_self); if (obj) @@ -1358,7 +1390,7 @@ class MACGrid : public Grid<Vec3> { //! set all boundary cells of a MAC grid to certain value (Dirchlet). Respects staggered grid //! locations optionally, only set normal components void setBoundMAC(Vec3 value, int boundaryWidth, bool normalOnly = false); - static PyObject *_W_38(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_39(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1399,7 +1431,7 @@ class FlagGrid : public Grid<int> { { mType = (GridType)(TypeFlags | TypeInt); } - static int _W_39(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static int _W_40(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { PbClass *obj = Pb::objFromPy(_self); if (obj) @@ -1579,7 +1611,7 @@ class FlagGrid : public Grid<int> { const std::string &inflow = " ", const std::string &outflow = " ", Grid<Real> *phiWalls = 0x00); - static PyObject *_W_40(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_41(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1613,7 +1645,7 @@ class FlagGrid : public Grid<int> { //! set fluid flags inside levelset (liquids) void updateFromLevelset(LevelsetGrid &levelset); - static PyObject *_W_41(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_42(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1640,7 +1672,7 @@ class FlagGrid : public Grid<int> { //! set all cells (except obs/in/outflow) to type (fluid by default) void fillGrid(int type = TypeFluid); - static PyObject *_W_42(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_43(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); @@ -1669,7 +1701,7 @@ class FlagGrid : public Grid<int> { //! warning for large grids! only regular int returned (due to python interface) //! optionally creates mask in RealGrid (1 where flag matches, 0 otherwise) int countCells(int flag, int bnd = 0, Grid<Real> *mask = NULL); - static PyObject *_W_43(PyObject *_self, PyObject *_linargs, PyObject *_kwds) + static PyObject *_W_44(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { try { PbArgs _args(_linargs, _kwds); |