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

levelset.h « preprocessed « mantaflow « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: db542bb1fe61cccf4180fc16264d8bc1db8ba680 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276


// DO NOT EDIT !
// This file is generated using the MantaFlow preprocessor (prep generate).

/******************************************************************************
 *
 * MantaFlow fluid solver framework
 * Copyright 2011 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
 *
 * Levelset
 *
 ******************************************************************************/

#ifndef _LEVELSET_H_
#define _LEVELSET_H_

#include "grid.h"

namespace Manta {
class Mesh;

//! Special function for levelsets
class LevelsetGrid : public Grid<Real> {
 public:
  LevelsetGrid(FluidSolver *parent, bool show = true);
  static int _W_0(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    PbClass *obj = Pb::objFromPy(_self);
    if (obj)
      delete obj;
    try {
      PbArgs _args(_linargs, _kwds);
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(0, "LevelsetGrid::LevelsetGrid", !noTiming);
      {
        ArgLocker _lock;
        FluidSolver *parent = _args.getPtr<FluidSolver>("parent", 0, &_lock);
        bool show = _args.getOpt<bool>("show", 1, true, &_lock);
        obj = new LevelsetGrid(parent, show);
        obj->registerObject(_self, &_args);
        _args.check();
      }
      pbFinalizePlugin(obj->getParent(), "LevelsetGrid::LevelsetGrid", !noTiming);
      return 0;
    }
    catch (std::exception &e) {
      pbSetError("LevelsetGrid::LevelsetGrid", e.what());
      return -1;
    }
  }

  LevelsetGrid(FluidSolver *parent, Real *data, bool show = true);

  //! reconstruct the levelset using fast marching

  void reinitMarching(const FlagGrid &flags,
                      Real maxTime = 4.0,
                      MACGrid *velTransport = nullptr,
                      bool ignoreWalls = false,
                      bool correctOuterLayer = true,
                      int obstacleType = FlagGrid::TypeObstacle);
  static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      LevelsetGrid *pbo = dynamic_cast<LevelsetGrid *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "LevelsetGrid::reinitMarching", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        const FlagGrid &flags = *_args.getPtr<FlagGrid>("flags", 0, &_lock);
        Real maxTime = _args.getOpt<Real>("maxTime", 1, 4.0, &_lock);
        MACGrid *velTransport = _args.getPtrOpt<MACGrid>("velTransport", 2, nullptr, &_lock);
        bool ignoreWalls = _args.getOpt<bool>("ignoreWalls", 3, false, &_lock);
        bool correctOuterLayer = _args.getOpt<bool>("correctOuterLayer", 4, true, &_lock);
        int obstacleType = _args.getOpt<int>("obstacleType", 5, FlagGrid::TypeObstacle, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->reinitMarching(
            flags, maxTime, velTransport, ignoreWalls, correctOuterLayer, obstacleType);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "LevelsetGrid::reinitMarching", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("LevelsetGrid::reinitMarching", e.what());
      return 0;
    }
  }

  //! create a triangle mesh from the levelset isosurface
  void createMesh(Mesh &mesh);
  static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      LevelsetGrid *pbo = dynamic_cast<LevelsetGrid *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "LevelsetGrid::createMesh", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        Mesh &mesh = *_args.getPtr<Mesh>("mesh", 0, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->createMesh(mesh);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "LevelsetGrid::createMesh", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("LevelsetGrid::createMesh", e.what());
      return 0;
    }
  }

  //! union with another levelset
  void join(const LevelsetGrid &o);
  static PyObject *_W_3(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      LevelsetGrid *pbo = dynamic_cast<LevelsetGrid *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "LevelsetGrid::join", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        const LevelsetGrid &o = *_args.getPtr<LevelsetGrid>("o", 0, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->join(o);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "LevelsetGrid::join", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("LevelsetGrid::join", e.what());
      return 0;
    }
  }

  void subtract(const LevelsetGrid &o,
                const FlagGrid *flags = nullptr,
                const int subtractType = 0);
  static PyObject *_W_4(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      LevelsetGrid *pbo = dynamic_cast<LevelsetGrid *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "LevelsetGrid::subtract", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        const LevelsetGrid &o = *_args.getPtr<LevelsetGrid>("o", 0, &_lock);
        const FlagGrid *flags = _args.getPtrOpt<FlagGrid>("flags", 1, nullptr, &_lock);
        const int subtractType = _args.getOpt<int>("subtractType", 2, 0, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->subtract(o, flags, subtractType);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "LevelsetGrid::subtract", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("LevelsetGrid::subtract", e.what());
      return 0;
    }
  }

  //! initialize levelset from flags (+/- 0.5 heaviside)
  void initFromFlags(const FlagGrid &flags, bool ignoreWalls = false);
  static PyObject *_W_5(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      LevelsetGrid *pbo = dynamic_cast<LevelsetGrid *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "LevelsetGrid::initFromFlags", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        const FlagGrid &flags = *_args.getPtr<FlagGrid>("flags", 0, &_lock);
        bool ignoreWalls = _args.getOpt<bool>("ignoreWalls", 1, false, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->initFromFlags(flags, ignoreWalls);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "LevelsetGrid::initFromFlags", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("LevelsetGrid::initFromFlags", e.what());
      return 0;
    }
  }

  //! fill holes (pos cells enclosed by neg ones) up to given size with -0.5 (ie not preserving
  //! sdf)
  void fillHoles(int maxDepth = 10, int boundaryWidth = 1);
  static PyObject *_W_6(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      LevelsetGrid *pbo = dynamic_cast<LevelsetGrid *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "LevelsetGrid::fillHoles", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        int maxDepth = _args.getOpt<int>("maxDepth", 0, 10, &_lock);
        int boundaryWidth = _args.getOpt<int>("boundaryWidth", 1, 1, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->fillHoles(maxDepth, boundaryWidth);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "LevelsetGrid::fillHoles", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("LevelsetGrid::fillHoles", e.what());
      return 0;
    }
  }

  //! flood-fill the levelset to ensure that closed obstacles are filled inside
  void floodFill(const Real value = -0.5, const bool outside = true, const int boundaryWidth = 1);
  static PyObject *_W_7(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      LevelsetGrid *pbo = dynamic_cast<LevelsetGrid *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "LevelsetGrid::floodFill", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        const Real value = _args.getOpt<Real>("value", 0, -0.5, &_lock);
        const bool outside = _args.getOpt<bool>("outside", 1, true, &_lock);
        const int boundaryWidth = _args.getOpt<int>("boundaryWidth", 2, 1, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->floodFill(value, outside, boundaryWidth);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "LevelsetGrid::floodFill", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("LevelsetGrid::floodFill", e.what());
      return 0;
    }
  }

  static Real invalidTimeValue();
 public:
  PbArgs _args;
}
#define _C_LevelsetGrid
;

}  // namespace Manta
#endif