Inshaping: include/TriSparse.h Source File

Inshaping

Inshaping  0.1
TriSparse.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include<string>
4 #include<pcl/kdtree/kdtree_flann.h>
5 #include<Setting.h>
6 
7 #include<Normal.h>
8 #include<Common.h>
9 
10 #include<Convert.h>
11 
12 
13 namespace Inshape
14 {
17  class TriSparse
18  {
19  private:
20 
21  //----------��Ա����----//
22  ParamItem param;
23  bool doubleCheck;
24  unsigned n;
25  std::unordered_map<unsigned, unsigned> maping;
26  pcl::PointCloud<pcl::PointNormal>::Ptr body;
27  MyMeshPtr head;
28  Eigen::SparseMatrix<double> A;
29  Eigen::VectorXd B;
30 
31  //-------private ����----//
32 
33  //dimension 0-x,1-y,2-z
34  unsigned getIndex(unsigned old_index, int dimension);
35 
36  public:
38  pcl::PointCloud<pcl::PointNormal>::Ptr _body,
39  MyMeshPtr _head
40  ) :body(_body),
41  head(_head),
42  n((*_head).n_vertices()),
43  doubleCheck(false)
44  {
45  assert((*body).size() != 0);
46  assert(n != 0);
47  }
48 
49  //���ò��� void setParam(const double _THRESHOLD, const double _THETA, const double _LAMDA_MIN, const double _LAMDA_MAX, const double _ETA, bool _doubleCheck); void setParam(const ParamItem& _param, bool _doubleCheck); void printParam(); inline void setInput( pcl::PointCloud<pcl::PointNormal>::Ptr _body, MyMeshPtr _head) { body = _body; head = _head; n = (*_head).n_vertices(); } void setA(Eigen::SparseMatrix<double>& _A); void setB(Eigen::VectorXd& _B); void updateHead(pcl::PointCloud<pcl::PointXYZ>::Ptr& head_cloud); double getLAMDA(unsigned index); MyMesh& getHead() { return *head; } pcl::PointCloud<pcl::PointNormal>& getBody() { return *body; } std::unordered_map<unsigned, unsigned>& getMap() { return maping; } bool construct();//���������飬����֮ǰ��Ҫ�ȵ���setParam() bool solve(Eigen::VectorXd& x);//�ⷽ���� bool solveToCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud);//�����ֱ�ӱ�ɵ��� ~TriSparse() {}; //-------------------��̬����------------------// bool static solveTriSparse(Eigen::SparseMatrix<double>& A, Eigen::VectorXd& B, Eigen::VectorXd& x); //˫��У�飬����Ҫhead�����body������������head���Ǹ��� static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head_mesh, std::unordered_map<unsigned, unsigned>& maping, double threshold); //˫��У�飬����Ҫhead�����body������������head���Ǹ��� static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointXYZ>& from, pcl::PointCloud<pcl::PointNormal>& to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //���� body ���ƺ� head ������,Ȼ����һ��maping,�������ֵ threshold static void findNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void findNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & body, pcl::PointCloud<pcl::PointXYZ>& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void confirmNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & from, pcl::PointCloud<pcl::PointXYZ> & to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //�õ��Ƶĵ����滻mesh�Ķ��� static void updateMesh(MyMesh& mesh, pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud); }; /*@}*/ }
50  void setParam(const double _THRESHOLD, const double _THETA, const double _LAMDA_MIN, const double _LAMDA_MAX, const double _ETA, bool _doubleCheck);
51 
52  void setParam(const ParamItem& _param, bool _doubleCheck);
53 
54  void printParam();
55 
56  inline void setInput(
57  pcl::PointCloud<pcl::PointNormal>::Ptr _body,
58  MyMeshPtr _head)
59  {
60  body = _body;
61  head = _head;
62  n = (*_head).n_vertices();
63  }
64 
65  void setA(Eigen::SparseMatrix<double>& _A);
66 
67  void setB(Eigen::VectorXd& _B);
68 
69  void updateHead(pcl::PointCloud<pcl::PointXYZ>::Ptr& head_cloud);
70 
71  double getLAMDA(unsigned index);
72 
73  MyMesh& getHead() { return *head; }
74 
75  pcl::PointCloud<pcl::PointNormal>& getBody() { return *body; }
76 
77  std::unordered_map<unsigned, unsigned>& getMap() { return maping; }
78 
79  bool construct();//���������飬����֮ǰ��Ҫ�ȵ���setParam()
80 
81 
82  bool solve(Eigen::VectorXd& x);//�ⷽ���� bool solveToCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud);//�����ֱ�ӱ�ɵ��� ~TriSparse() {}; //-------------------��̬����------------------// bool static solveTriSparse(Eigen::SparseMatrix<double>& A, Eigen::VectorXd& B, Eigen::VectorXd& x); //˫��У�飬����Ҫhead�����body������������head���Ǹ��� static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head_mesh, std::unordered_map<unsigned, unsigned>& maping, double threshold); //˫��У�飬����Ҫhead�����body������������head���Ǹ��� static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointXYZ>& from, pcl::PointCloud<pcl::PointNormal>& to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //���� body ���ƺ� head ������,Ȼ����һ��maping,�������ֵ threshold static void findNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void findNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & body, pcl::PointCloud<pcl::PointXYZ>& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void confirmNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & from, pcl::PointCloud<pcl::PointXYZ> & to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //�õ��Ƶĵ����滻mesh�Ķ��� static void updateMesh(MyMesh& mesh, pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud); }; /*@}*/ }
83 
84  bool solveToCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud);//�����ֱ�ӱ�ɵ��� ~TriSparse() {}; //-------------------��̬����------------------// bool static solveTriSparse(Eigen::SparseMatrix<double>& A, Eigen::VectorXd& B, Eigen::VectorXd& x); //˫��У�飬����Ҫhead�����body������������head���Ǹ��� static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head_mesh, std::unordered_map<unsigned, unsigned>& maping, double threshold); //˫��У�飬����Ҫhead�����body������������head���Ǹ��� static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointXYZ>& from, pcl::PointCloud<pcl::PointNormal>& to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //���� body ���ƺ� head ������,Ȼ����һ��maping,�������ֵ threshold static void findNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void findNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & body, pcl::PointCloud<pcl::PointXYZ>& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void confirmNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & from, pcl::PointCloud<pcl::PointXYZ> & to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //�õ��Ƶĵ����滻mesh�Ķ��� static void updateMesh(MyMesh& mesh, pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud); }; /*@}*/ }
85 
86  ~TriSparse() {};
87 
88 
89  //-------------------��̬����------------------//
90 
91  bool static solveTriSparse(Eigen::SparseMatrix<double>& A, Eigen::VectorXd& B, Eigen::VectorXd& x);
92 
93 
94 
95  //˫��У�飬����Ҫhead�����body������������head���Ǹ��� static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head_mesh, std::unordered_map<unsigned, unsigned>& maping, double threshold); //˫��У�飬����Ҫhead�����body������������head���Ǹ��� static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointXYZ>& from, pcl::PointCloud<pcl::PointNormal>& to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //���� body ���ƺ� head ������,Ȼ����һ��maping,�������ֵ threshold static void findNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void findNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & body, pcl::PointCloud<pcl::PointXYZ>& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void confirmNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & from, pcl::PointCloud<pcl::PointXYZ> & to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //�õ��Ƶĵ����滻mesh�Ķ��� static void updateMesh(MyMesh& mesh, pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud); }; /*@}*/ }
96  static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head_mesh, std::unordered_map<unsigned, unsigned>& maping, double threshold);
97 
98  //˫��У�飬����Ҫhead�����body������������head���Ǹ��� static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointXYZ>& from, pcl::PointCloud<pcl::PointNormal>& to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //���� body ���ƺ� head ������,Ȼ����һ��maping,�������ֵ threshold static void findNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void findNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & body, pcl::PointCloud<pcl::PointXYZ>& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck); static void confirmNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & from, pcl::PointCloud<pcl::PointXYZ> & to, std::unordered_map<unsigned, unsigned>& maping, double threshold); //�õ��Ƶĵ����滻mesh�Ķ��� static void updateMesh(MyMesh& mesh, pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud); }; /*@}*/ }
99  static void confirmNearestNeighbor(pcl::PointCloud<pcl::PointXYZ>& from, pcl::PointCloud<pcl::PointNormal>& to, std::unordered_map<unsigned, unsigned>& maping, double threshold);
100 
101  //���� body ���ƺ� head ������,Ȼ����һ��maping,�������ֵ threshold
102  static void findNearestNeighbor(pcl::PointCloud<pcl::PointNormal>& body, MyMesh& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck);
103 
104  static void findNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & body, pcl::PointCloud<pcl::PointXYZ>& head, std::unordered_map<unsigned, unsigned>& maping, double threshold, bool doubleCheck);
105 
106  static void confirmNearestNeighbor2(pcl::PointCloud<pcl::PointXYZ> & from, pcl::PointCloud<pcl::PointXYZ> & to, std::unordered_map<unsigned, unsigned>& maping, double threshold);
107 
108  //�õ��Ƶĵ����滻mesh�Ķ��� static void updateMesh(MyMesh& mesh, pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud); }; /*@}*/ }
109  static void updateMesh(MyMesh& mesh, pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud);
110 
111  };
113 }
double getLAMDA(unsigned index)
static void findNearestNeighbor(pcl::PointCloud< pcl::PointNormal > &body, MyMesh &head, std::unordered_map< unsigned, unsigned > &maping, double threshold, bool doubleCheck)
MyMesh & getHead()
Definition: TriSparse.h:73
bool solve(Eigen::VectorXd &x)
Definition: AfterProcess.h:9
void updateHead(pcl::PointCloud< pcl::PointXYZ >::Ptr &head_cloud)
Definition: Setting.h:20
void setInput(pcl::PointCloud< pcl::PointNormal >::Ptr _body, MyMeshPtr _head)
Definition: TriSparse.h:56
~TriSparse()
Definition: TriSparse.h:86
static bool solveTriSparse(Eigen::SparseMatrix< double > &A, Eigen::VectorXd &B, Eigen::VectorXd &x)
static void confirmNearestNeighbor2(pcl::PointCloud< pcl::PointXYZ > &from, pcl::PointCloud< pcl::PointXYZ > &to, std::unordered_map< unsigned, unsigned > &maping, double threshold)
static void findNearestNeighbor2(pcl::PointCloud< pcl::PointXYZ > &body, pcl::PointCloud< pcl::PointXYZ > &head, std::unordered_map< unsigned, unsigned > &maping, double threshold, bool doubleCheck)
Definition: TriSparse.h:17
static void updateMesh(MyMesh &mesh, pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud)
std::unordered_map< unsigned, unsigned > & getMap()
Definition: TriSparse.h:77
bool solveToCloud(pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud)
pcl::PointCloud< pcl::PointNormal > & getBody()
Definition: TriSparse.h:75
static void confirmNearestNeighbor(pcl::PointCloud< pcl::PointNormal > &body, MyMesh &head_mesh, std::unordered_map< unsigned, unsigned > &maping, double threshold)
OpenMesh::PolyMesh_ArrayKernelT MyMesh
Definition: Common.h:23
void setB(Eigen::VectorXd &_B)
TriSparse(pcl::PointCloud< pcl::PointNormal >::Ptr _body, MyMeshPtr _head)
Definition: TriSparse.h:37
void setA(Eigen::SparseMatrix< double > &_A)
void setParam(const double _THRESHOLD, const double _THETA, const double _LAMDA_MIN, const double _LAMDA_MAX, const double _ETA, bool _doubleCheck)
std::shared_ptr< MyMesh > MyMeshPtr
Definition: Common.h:24
Generated by   doxygen 1.8.14