1 
2 
3 // DO NOT EDIT !
4 // This file is generated using the MantaFlow preprocessor (prep generate).
5 
6 /******************************************************************************
7  *
8  * MantaFlow fluid solver framework
9  * Copyright 2011 Tobias Pfaff, Nils Thuerey
10  *
11  * This program is free software, distributed under the terms of the
12  * Apache License, Version 2.0
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Loading and writing grids and meshes to disk
16  *
17  ******************************************************************************/
18 
19 #ifndef _FILEIO_H
20 #define _FILEIO_H
21 
22 #include <string>
23 
24 #include "manta.h"
25 
26 // OpenVDB compression flags
27 #define COMPRESSION_NONE 0
28 #define COMPRESSION_ZIP 1
29 #define COMPRESSION_BLOSC 2
30 
31 // OpenVDB precision flags
32 #define PRECISION_FULL 0
33 #define PRECISION_HALF 1
34 #define PRECISION_MINI 2
35 
36 namespace Manta {
37 
38 // Forward declations
39 class Mesh;
40 class FlagGrid;
41 class GridBase;
42 template<class T> class Grid;
43 template<class T> class Grid4d;
44 class BasicParticleSystem;
45 template<class T> class ParticleDataImpl;
46 template<class T> class MeshDataImpl;
47 
48 // Obj format
49 int writeObjFile(const std::string &name, Mesh *mesh);
50 int writeBobjFile(const std::string &name, Mesh *mesh);
51 int readObjFile(const std::string &name, Mesh *mesh, bool append);
52 int readBobjFile(const std::string &name, Mesh *mesh, bool append);
53 
54 // Other formats (Raw, Uni, Vol)
55 template<class T> int readGridUni(const std::string &name, Grid<T> *grid);
56 template<class T> int readGridRaw(const std::string &name, Grid<T> *grid);
57 template<class T> int readGridVol(const std::string &name, Grid<T> *grid);
58 int readGridsRaw(const std::string &name, std::vector<PbClass *> *grids);
59 int readGridsUni(const std::string &name, std::vector<PbClass *> *grids);
60 int readGridsVol(const std::string &name, std::vector<PbClass *> *grids);
61 int readGridsTxt(const std::string &name, std::vector<PbClass *> *grids);
62 
63 template<class T> int writeGridRaw(const std::string &name, Grid<T> *grid);
64 template<class T> int writeGridUni(const std::string &name, Grid<T> *grid);
65 template<class T> int writeGridVol(const std::string &name, Grid<T> *grid);
66 template<class T> int writeGridTxt(const std::string &name, Grid<T> *grid);
67 int writeGridsRaw(const std::string &name, std::vector<PbClass *> *grids);
68 int writeGridsUni(const std::string &name, std::vector<PbClass *> *grids);
69 int writeGridsVol(const std::string &name, std::vector<PbClass *> *grids);
70 int writeGridsTxt(const std::string &name, std::vector<PbClass *> *grids);
71 
72 // OpenVDB
73 int writeObjectsVDB(const std::string &filename,
74                     std::vector<PbClass *> *objects,
75                     float scale = 1.0,
76                     bool skipDeletedParts = false,
77                     int compression = COMPRESSION_ZIP,
78                     int precision = PRECISION_HALF);
79 int readObjectsVDB(const std::string &filename,
80                    std::vector<PbClass *> *objects,
81                    float scale = 1.0);
82 
83 // Numpy
84 template<class T> int writeGridNumpy(const std::string &name, Grid<T> *grid);
85 template<class T> int readGridNumpy(const std::string &name, Grid<T> *grid);
86 
87 int writeGridsNumpy(const std::string &name, std::vector<PbClass *> *grids);
88 int readGridsNumpy(const std::string &name, std::vector<PbClass *> *grids);
89 
90 // 4D Grids
91 template<class T> int writeGrid4dUni(const std::string &name, Grid4d<T> *grid);
92 template<class T>
93 int readGrid4dUni(const std::string &name,
94                   Grid4d<T> *grid,
95                   int readTslice = -1,
96                   Grid4d<T> *slice = NULL,
97                   void **fileHandle = NULL);
98 void readGrid4dUniCleanup(void **fileHandle);
99 template<class T> int writeGrid4dRaw(const std::string &name, Grid4d<T> *grid);
100 template<class T> int readGrid4dRaw(const std::string &name, Grid4d<T> *grid);
101 
102 // Particles + particle data
103 int writeParticlesUni(const std::string &name, const BasicParticleSystem *parts);
104 int readParticlesUni(const std::string &name, BasicParticleSystem *parts);
105 
106 template<class T> int writePdataUni(const std::string &name, ParticleDataImpl<T> *pdata);
107 template<class T> int readPdataUni(const std::string &name, ParticleDataImpl<T> *pdata);
108 
109 // Mesh data
110 template<class T> int writeMdataUni(const std::string &name, MeshDataImpl<T> *mdata);
111 template<class T> int readMdataUni(const std::string &name, MeshDataImpl<T> *mdata);
112 
113 // Helpers
114 void getUniFileSize(
115     const std::string &name, int &x, int &y, int &z, int *t = NULL, std::string *info = NULL);
116 void *safeGzopen(const char *filename, const char *mode);
117 #if OPENVDB == 1
118 template<class S, class T> void convertFrom(S &in, T *out);
119 template<class S, class T> void convertTo(S *out, T &in);
120 #endif
121 
122 }  // namespace Manta
123 
124 #endif
125