-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathedit_LaplaceDeformation.h
62 lines (47 loc) · 2.19 KB
/
edit_LaplaceDeformation.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
#pragma once
#include <vector>
#include <QObject>
#include <common/interfaces.h>
#include <vcg/space/deprecated_point3.h>
#include <eigenlib/Eigen/Dense>
class EditLaplaceDeformationPlugin : public QObject, public MeshEditInterface
{
Q_OBJECT
Q_INTERFACES(MeshEditInterface)
public:
Eigen::MatrixXf L, Ls, LsT, LsTLs, LsTbx, LsTby, LsTbz; // L: 原始laplace矩阵(方阵),LS: 加入了锚点(point_num + anchors, point_num)大小, T:转置
Eigen::VectorXf bx, by, bz;
Eigen::VectorXf vx_new, vy_new, vz_new;
std::vector<int> fixed_anchor_idx, move_anchor_idx; // 锚点分为固定点和移动点
std::vector<vcg::Point3f> move_anchor_coord; // 形变后移动锚点位置
std::vector<vcg::Point3f> Vertices;
std::vector<std::vector<int>> Faces;
std::vector<std::vector<int>> AdjacentVertices;
EditLaplaceDeformationPlugin();
virtual ~EditLaplaceDeformationPlugin() = default; // resharper C++
static const QString Info();
bool StartEdit(MeshModel &/*m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/) override; // resharper C++ 加了个 "override"
void EndEdit(MeshModel &/*m*/, GLArea * /*parent*/, MLSceneGLSharedDataContext* /*cont*/) override;
void Decorate(MeshModel &/*m*/, GLArea * /*parent*/, QPainter *p) override {};
void mousePressEvent(QMouseEvent *, MeshModel &, GLArea * ) override {};
void mouseMoveEvent(QMouseEvent *, MeshModel &, GLArea * ) override {};
void mouseReleaseEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea *) override {};
void keyReleaseEvent(QKeyEvent *, MeshModel &, GLArea *) override {};
void LaplaceDeformation(MeshModel&); // 依次调用下边函数
void toCaculateAdjacentVertices(CMeshO* cm);
void CalculateAdjacentVertices(CMeshO* cm);
void get_LsTLs_Matrix(); // 获取laplace矩阵以及LTLILT矩阵
void get_LsTb_Matrix(); // 获取 b 矩阵,x' = LTLILT * b
void setNewCoord(MeshModel&); // 更新模型坐标,anchor点单独按照形变计算
void suggestedRenderingData(MeshModel &, MLRenderingData& dt) override;
void ChimneyRotate(MeshModel &);
private:
QPoint cur;
QFont qFont;
bool haveToPick;
int pickmode;
CMeshO::FacePointer curFacePtr;
CMeshO::VertexPointer curVertPtr;
int pIndex;
GLArea * gla;
};