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

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


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

/******************************************************************************
 *
 * MantaFlow fluid solver framework
 * Copyright 2020 Sebastian Barschkis, 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
 *
 * General functions that make use of functions from other io files.
 *
 ******************************************************************************/

#include "mantaio.h"

using namespace std;

namespace Manta {

int load(const string &name, std::vector<PbClass *> &objects, float worldSize = 1.0)
{
  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 == ".raw")
    return readGridsRaw(name, &objects);
  else if (ext == ".uni")
    return readGridsUni(name, &objects);
  else if (ext == ".vol")
    return readGridsVol(name, &objects);
  if (ext == ".vdb")
    return readObjectsVDB(name, &objects, worldSize);
  else if (ext == ".npz")
    return readGridsNumpy(name, &objects);
  else if (ext == ".txt")
    return readGridsTxt(name, &objects);
  else
    errMsg("file '" + name + "' filetype not supported");
  return 0;
}
static PyObject *_W_0(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
  try {
    PbArgs _args(_linargs, _kwds);
    FluidSolver *parent = _args.obtainParent();
    bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
    pbPreparePlugin(parent, "load", !noTiming);
    PyObject *_retval = 0;
    {
      ArgLocker _lock;
      const string &name = _args.get<string>("name", 0, &_lock);
      std::vector<PbClass *> &objects = *_args.getPtr<std::vector<PbClass *>>(
          "objects", 1, &_lock);
      float worldSize = _args.getOpt<float>("worldSize", 2, 1.0, &_lock);
      _retval = toPy(load(name, objects, worldSize));
      _args.check();
    }
    pbFinalizePlugin(parent, "load", !noTiming);
    return _retval;
  }
  catch (std::exception &e) {
    pbSetError("load", e.what());
    return 0;
  }
}
static const Pb::Register _RP_load("", "load", _W_0);
extern "C" {
void PbRegister_load()
{
  KEEP_UNUSED(_RP_load);
}
}

int save(const string &name,
         std::vector<PbClass *> &objects,
         float worldSize = 1.0,
         bool skipDeletedParts = false,
         int compression = COMPRESSION_ZIP,
         bool precisionHalf = true)
{
  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 == ".raw")
    return writeGridsRaw(name, &objects);
  else if (ext == ".uni")
    return writeGridsUni(name, &objects);
  else if (ext == ".vol")
    return writeGridsVol(name, &objects);
  if (ext == ".vdb")
    return writeObjectsVDB(
        name, &objects, worldSize, skipDeletedParts, compression, precisionHalf);
  else if (ext == ".npz")
    return writeGridsNumpy(name, &objects);
  else if (ext == ".txt")
    return writeGridsTxt(name, &objects);
  else
    errMsg("file '" + name + "' filetype not supported");
  return 0;
}
static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
  try {
    PbArgs _args(_linargs, _kwds);
    FluidSolver *parent = _args.obtainParent();
    bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
    pbPreparePlugin(parent, "save", !noTiming);
    PyObject *_retval = 0;
    {
      ArgLocker _lock;
      const string &name = _args.get<string>("name", 0, &_lock);
      std::vector<PbClass *> &objects = *_args.getPtr<std::vector<PbClass *>>(
          "objects", 1, &_lock);
      float worldSize = _args.getOpt<float>("worldSize", 2, 1.0, &_lock);
      bool skipDeletedParts = _args.getOpt<bool>("skipDeletedParts", 3, false, &_lock);
      int compression = _args.getOpt<int>("compression", 4, COMPRESSION_ZIP, &_lock);
      bool precisionHalf = _args.getOpt<bool>("precisionHalf", 5, true, &_lock);
      _retval = toPy(save(name, objects, worldSize, skipDeletedParts, compression, precisionHalf));
      _args.check();
    }
    pbFinalizePlugin(parent, "save", !noTiming);
    return _retval;
  }
  catch (std::exception &e) {
    pbSetError("save", e.what());
    return 0;
  }
}
static const Pb::Register _RP_save("", "save", _W_1);
extern "C" {
void PbRegister_save()
{
  KEEP_UNUSED(_RP_save);
}
}

}  // namespace Manta