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
|
/** \file
* \ingroup elbeem
*/
/******************************************************************************
*
// El'Beem - the visual lattice boltzmann freesurface simulator
// All code distributed as part of El'Beem is covered by the version 2 of the
// GNU General Public License. See the file COPYING for details.
//
// Copyright 2008 Nils Thuerey , Richard Keiser, Mark Pauly, Ulrich Ruede
//
*
* Mean Value Mesh Coords class
*
*****************************************************************************/
#ifndef MVMCOORDS_H
#define MVMCOORDS_H
#include "utilities.h"
#include "ntl_ray.h"
#include <vector>
#define mvmFloat double
#ifdef WIN32
#include "float.h"
#define isnan(n) _isnan(n)
#define finite _finite
#endif
#ifdef sun
#include "ieeefp.h"
#endif
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
// weight and triangle index
class mvmIndexWeight {
public:
mvmIndexWeight() : weight(0.0) {}
mvmIndexWeight(int const& i, mvmFloat const& w) :
weight(w), index(i) {}
// for sorting
bool operator> (mvmIndexWeight const& w) const { return this->weight > w.weight; }
bool operator< (mvmIndexWeight const& w) const { return this->weight < w.weight; }
mvmFloat weight;
int index;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:mvmIndexWeight")
#endif
};
// transfer point with weights
class mvmTransferPoint {
public:
//! position of transfer point
ntlVec3Gfx lastpos;
//! triangle weights
std::vector<mvmIndexWeight> weights;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:mvmTransferPoint")
#endif
};
//! compute mvmcs
class MeanValueMeshCoords {
public:
MeanValueMeshCoords() {}
~MeanValueMeshCoords() {
clear();
}
void clear();
void calculateMVMCs(std::vector<ntlVec3Gfx> &reference_vertices,
std::vector<ntlTriangle> &tris, std::vector<ntlVec3Gfx> &points, gfxReal numweights);
void transfer(std::vector<ntlVec3Gfx> &vertices, std::vector<ntlVec3Gfx>& displacements);
protected:
void computeWeights(std::vector<ntlVec3Gfx> &reference_vertices,
std::vector<ntlTriangle> &tris, mvmTransferPoint& tds, gfxReal numweights);
std::vector<mvmTransferPoint> mVertices;
int mNumVerts;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:MeanValueMeshCoords")
#endif
};
#endif
|