doxygen: add newline after \file
[blender.git] / intern / elbeem / intern / mvmcoords.h
1 /** \file
2  * \ingroup elbeem
3  */
4 /******************************************************************************
5  *
6 // El'Beem - the visual lattice boltzmann freesurface simulator
7 // All code distributed as part of El'Beem is covered by the version 2 of the 
8 // GNU General Public License. See the file COPYING for details.  
9 //
10 // Copyright 2008 Nils Thuerey , Richard Keiser, Mark Pauly, Ulrich Ruede
11 //
12  *
13  * Mean Value Mesh Coords class
14  *
15  *****************************************************************************/
16
17 #ifndef MVMCOORDS_H
18 #define MVMCOORDS_H
19
20 #include "utilities.h"
21 #include "ntl_ray.h"
22 #include <vector>
23 #define mvmFloat double
24
25 #ifdef WIN32
26 #include "float.h"
27 #define isnan(n) _isnan(n)
28 #define finite _finite
29 #endif
30
31 #ifdef sun
32 #include "ieeefp.h"
33 #endif
34
35 #ifdef WITH_CXX_GUARDEDALLOC
36 #  include "MEM_guardedalloc.h"
37 #endif
38
39 // weight and triangle index
40 class mvmIndexWeight {
41         public:
42
43                 mvmIndexWeight() : weight(0.0) {}
44
45                 mvmIndexWeight(int const& i, mvmFloat const& w) :
46                         weight(w), index(i) {}
47
48                 // for sorting
49                 bool operator> (mvmIndexWeight const& w) const { return this->weight > w.weight; } 
50                 bool operator< (mvmIndexWeight const& w) const { return this->weight < w.weight; }
51
52                 mvmFloat weight;
53                 int index;
54
55 private:
56 #ifdef WITH_CXX_GUARDEDALLOC
57         MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:mvmIndexWeight")
58 #endif
59 };
60
61 // transfer point with weights
62 class mvmTransferPoint {
63         public:
64                 //! position of transfer point
65                 ntlVec3Gfx lastpos;
66                 //! triangle weights
67                 std::vector<mvmIndexWeight> weights;
68
69 private:
70 #ifdef WITH_CXX_GUARDEDALLOC
71         MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:mvmTransferPoint")
72 #endif
73 };
74
75
76 //! compute mvmcs
77 class MeanValueMeshCoords {
78
79         public:
80
81     MeanValueMeshCoords() {}
82     ~MeanValueMeshCoords() {
83         clear();
84     }
85
86     void clear();
87
88     void calculateMVMCs(std::vector<ntlVec3Gfx> &reference_vertices, 
89                                 std::vector<ntlTriangle> &tris, std::vector<ntlVec3Gfx> &points, gfxReal numweights);
90     
91     void transfer(std::vector<ntlVec3Gfx> &vertices, std::vector<ntlVec3Gfx>& displacements);
92
93         protected:
94
95     void computeWeights(std::vector<ntlVec3Gfx> &reference_vertices, 
96                                 std::vector<ntlTriangle> &tris, mvmTransferPoint& tds, gfxReal numweights);
97
98     std::vector<mvmTransferPoint> mVertices;
99     int mNumVerts;
100
101 private:
102 #ifdef WITH_CXX_GUARDEDALLOC
103         MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:MeanValueMeshCoords")
104 #endif
105 };
106
107 #endif
108