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

movingobs.h « preprocessed « mantaflow « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0661ddf5b376426e0ca56f6d06f12b68258c29cb (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


// 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
 *
 * moving obstacles
 *
 ******************************************************************************/

#ifndef _MOVINGOBS_H
#define _MOVINGOBS_H

#include "shapes.h"
#include "particle.h"

namespace Manta {

//! Moving obstacle composed of basic shapes
class MovingObstacle : public PbClass {
 public:
  MovingObstacle(FluidSolver *parent, int emptyType = FlagGrid::TypeEmpty);
  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, "MovingObstacle::MovingObstacle", !noTiming);
      {
        ArgLocker _lock;
        FluidSolver *parent = _args.getPtr<FluidSolver>("parent", 0, &_lock);
        int emptyType = _args.getOpt<int>("emptyType", 1, FlagGrid::TypeEmpty, &_lock);
        obj = new MovingObstacle(parent, emptyType);
        obj->registerObject(_self, &_args);
        _args.check();
      }
      pbFinalizePlugin(obj->getParent(), "MovingObstacle::MovingObstacle", !noTiming);
      return 0;
    }
    catch (std::exception &e) {
      pbSetError("MovingObstacle::MovingObstacle", e.what());
      return -1;
    }
  }

  void add(Shape *shape);
  static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      MovingObstacle *pbo = dynamic_cast<MovingObstacle *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "MovingObstacle::add", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        Shape *shape = _args.getPtr<Shape>("shape", 0, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->add(shape);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "MovingObstacle::add", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("MovingObstacle::add", e.what());
      return 0;
    }
  }

  //! If t in [t0,t1], apply linear motion path from p0 to p1
  void moveLinear(Real t,
                  Real t0,
                  Real t1,
                  Vec3 p0,
                  Vec3 p1,
                  FlagGrid &flags,
                  MACGrid &vel,
                  bool smooth = true);
  static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      MovingObstacle *pbo = dynamic_cast<MovingObstacle *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "MovingObstacle::moveLinear", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        Real t = _args.get<Real>("t", 0, &_lock);
        Real t0 = _args.get<Real>("t0", 1, &_lock);
        Real t1 = _args.get<Real>("t1", 2, &_lock);
        Vec3 p0 = _args.get<Vec3>("p0", 3, &_lock);
        Vec3 p1 = _args.get<Vec3>("p1", 4, &_lock);
        FlagGrid &flags = *_args.getPtr<FlagGrid>("flags", 5, &_lock);
        MACGrid &vel = *_args.getPtr<MACGrid>("vel", 6, &_lock);
        bool smooth = _args.getOpt<bool>("smooth", 7, true, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->moveLinear(t, t0, t1, p0, p1, flags, vel, smooth);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "MovingObstacle::moveLinear", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("MovingObstacle::moveLinear", e.what());
      return 0;
    }
  }

  //! Compute levelset, and project FLIP particles outside obstacles
  void projectOutside(FlagGrid &flags, BasicParticleSystem &flip);
  static PyObject *_W_3(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
  {
    try {
      PbArgs _args(_linargs, _kwds);
      MovingObstacle *pbo = dynamic_cast<MovingObstacle *>(Pb::objFromPy(_self));
      bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
      pbPreparePlugin(pbo->getParent(), "MovingObstacle::projectOutside", !noTiming);
      PyObject *_retval = nullptr;
      {
        ArgLocker _lock;
        FlagGrid &flags = *_args.getPtr<FlagGrid>("flags", 0, &_lock);
        BasicParticleSystem &flip = *_args.getPtr<BasicParticleSystem>("flip", 1, &_lock);
        pbo->_args.copy(_args);
        _retval = getPyNone();
        pbo->projectOutside(flags, flip);
        pbo->_args.check();
      }
      pbFinalizePlugin(pbo->getParent(), "MovingObstacle::projectOutside", !noTiming);
      return _retval;
    }
    catch (std::exception &e) {
      pbSetError("MovingObstacle::projectOutside", e.what());
      return 0;
    }
  }

 protected:
  std::vector<Shape *> mShapes;
  int mEmptyType;
  int mID;
  static int sIDcnt;
 public:
  PbArgs _args;
}
#define _C_MovingObstacle
;

}  // namespace Manta
#endif