This version now includes the fluid control sources, however the Blender
[blender.git] / intern / elbeem / intern / mvmcoords.h
1 /******************************************************************************
2  *
3 // El'Beem - the visual lattice boltzmann freesurface simulator
4 // All code distributed as part of El'Beem is covered by the version 2 of the 
5 // GNU General Public License. See the file COPYING for details.  
6 //
7 // Copyright 2008 Nils Thuerey , Richard Keiser, Mark Pauly, Ulrich Ruede
8 //
9  *
10  * Mean Value Mesh Coords class
11  *
12  *****************************************************************************/
13
14 #ifndef MVMCOORDS_H
15 #define MVMCOORDS_H
16
17 #include "utilities.h"
18 #include "ntl_ray.h"
19 #include <vector>
20 #define mvmFloat double
21
22 // weight and triangle index
23 class mvmIndexWeight {
24         public:
25
26                 mvmIndexWeight() : weight(0.0) {}
27
28                 mvmIndexWeight(int const& i, mvmFloat const& w) :
29                         weight(w), index(i) {}
30
31                 // for sorting
32                 bool operator> (mvmIndexWeight const& w) const { return this->weight > w.weight; } 
33                 bool operator< (mvmIndexWeight const& w) const { return this->weight < w.weight; }
34
35                 mvmFloat weight;
36                 int index;
37 };
38
39 // transfer point with weights
40 class mvmTransferPoint {
41         public:
42                 //! position of transfer point
43                 ntlVec3Gfx lastpos;
44                 //! triangle weights
45                 std::vector<mvmIndexWeight> weights;
46 };
47
48
49 //! compute mvmcs
50 class MeanValueMeshCoords {
51
52         public:
53
54     MeanValueMeshCoords() {}
55     ~MeanValueMeshCoords() {
56         clear();
57     }
58
59     void clear();
60
61     void calculateMVMCs(std::vector<ntlVec3Gfx> &reference_vertices, 
62                                 std::vector<ntlTriangle> &tris, std::vector<ntlVec3Gfx> &points, gfxReal numweights);
63     
64     void transfer(std::vector<ntlVec3Gfx> &vertices, std::vector<ntlVec3Gfx>& displacements);
65
66         protected:
67
68     void computeWeights(std::vector<ntlVec3Gfx> &reference_vertices, 
69                                 std::vector<ntlTriangle> &tris, mvmTransferPoint& tds, gfxReal numweights);
70
71     std::vector<mvmTransferPoint> mVertices;
72     int mNumVerts;
73
74 };
75
76 #endif
77