forked from Toolchefs/harmonicDeformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.h
107 lines (67 loc) · 1.83 KB
/
grid.h
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
#pragma once
#include <vector>
#include <map>
#include <tbb/blocked_range.h>
#include <tbb/queuing_mutex.h>
#include "mathUtils.h"
#include "intersect.h"
#ifdef MAYA
#include <maya/MProgressWindow.h>
#include <maya/MString.h>
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
#endif
namespace tc
{
class Cell;
class Grid;
class ParallelSolver
{
public:
ParallelSolver(Grid& g, const std::vector<Vector>& pts,
unsigned int iter
) : grid(g), points(pts), iteration(iter)
{}
~ParallelSolver(){}
void operator()(const tbb::blocked_range<size_t>& range) const;
private:
Grid& grid;
const std::vector<Vector>& points;
unsigned int iteration;
#ifdef MAYA
static tbb::queuing_mutex m_mutex;
#endif
};
class Grid
{
public:
Grid();
Grid(double cellDimension);
~Grid();
inline void setThreshold(double value) { m_threshold = value; }
bool addBoundary(const std::vector<Vector>& points, const std::vector<unsigned int>& faceVtx, const std::vector<unsigned int> numVtxPerFace);
void solveLaplace(const std::vector<Vector>& points, unsigned int iteration = 50);
void parallelSolveLaplace(const std::vector<Vector>& points, unsigned int iteration = 50);
const Cell& getCell(const Vector& pt);
double getWeight(const Vector& pt, unsigned int p);
std::vector<std::map<unsigned int, double> > getWeights(const std::vector<Vector>& points);
std::string serialise();
bool deserialise(const std::string& data);
public:
int linearCellCords(unsigned int x, unsigned int y, unsigned int z);
void interpWeights(double a, double b, double f, double& wOut);
public:
std::vector<Cell> m_grid;
double m_cellDimension;
std::pair<Vector, Vector> m_boundingBox;
unsigned int m_xDim;
unsigned int m_yDim;
unsigned int m_zDim;
friend class ParallelSolver;
double m_threshold;
};
}