1 
2 //
3 // This source file is part of appleseed.
4 // Visit https://appleseedhq.net/ for additional information and resources.
5 //
6 // This software is released under the MIT license.
7 //
8 // Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited
9 // Copyright (c) 2014-2018 Francois Beaune, The appleseedhq Organization
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining a copy
12 // of this software and associated documentation files (the "Software"), to deal
13 // in the Software without restriction, including without limitation the rights
14 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 // copies of the Software, and to permit persons to whom the Software is
16 // furnished to do so, subject to the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be included in
19 // all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 // THE SOFTWARE.
28 //
29 
30 #pragma once
31 
32 // appleseed.foundation headers.
33 #include "foundation/math/voxelgrid.h"
34 
35 // Standard headers.
36 #include <cstddef>
37 #include <memory>
38 
39 namespace renderer
40 {
41 
42 //
43 // The voxel grid used for rendering.
44 //
45 
46 typedef foundation::VoxelGrid3<float, double> VoxelGrid;
47 
48 
49 //
50 // A structure to keep track of the channels in a voxel grid.
51 //
52 
53 struct FluidChannels
54 {
55     static const size_t NotPresent = ~size_t(0);
56 
57     size_t  m_color_index;
58     size_t  m_density_index;
59     size_t  m_temperature_index;
60     size_t  m_fuel_index;
61     size_t  m_falloff_index;
62     size_t  m_pressure_index;
63     size_t  m_coordinates_index;
64     size_t  m_velocity_index;
65 
66     // Constructor, initializes all channel indices to NotPresent.
67     FluidChannels();
68 };
69 
70 
71 //
72 // Voxel grid I/O.
73 //
74 
75 // Read a fluid file created by 3Delight for Maya.
76 std::unique_ptr<VoxelGrid> read_fluid_file(
77     const char*         filename,
78     FluidChannels&      channels);
79 
80 // Write a voxel grid to disk in a human-readable format.
81 void write_voxel_grid(
82     const char*         filename,
83     const VoxelGrid&    grid);
84 
85 }   // namespace renderer
86