-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRigidAlignmentImpl.h
71 lines (62 loc) · 1.81 KB
/
RigidAlignmentImpl.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
#pragma once
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstring>
#include <map>
#include <iterator>
#include "Mesh.h"
#include "newuoa.h"
#include "Geom.h"
using namespace std;
class RigidAlignment
{
public:
RigidAlignment(void);
RigidAlignment(const char *landmarkDir, vector<char *> landmarkList, const char *sphere, const char *outdir = NULL, bool lmCoordType = false);
RigidAlignment(std::map<std::string, std::vector<int> > landmarksMap, const char *sphere, const char *outdir = NULL, bool lmCoordType = false);
~RigidAlignment(void);
float cost(float *coeff);
const float *rot(void);
void saveSphere(const char *dir);
void saveLM(const char *lm);
private:
void setup(const char *landmarkDir, vector<char *> landmarkList, const char *sphere);
void setup(std::map<std::string, std::vector<int> > landmarksMap, const char *sphere);
void setup3f(const char *landmarkDir, vector<char *> landmarkList, const char *sphere);
void readPoint(const char *filename);
void readPoint3f(const char *filename);
void optimization(void);
void update(void);
void updateAxis(const float phi, const float theta, const float *axis_old, float *axis_new);
float landmarkVariance(void);
private:
vector<vector<int> > m_point;
// vector<const char *> m_filename;
vector<string> m_filename;
Mesh *m_sphere;
char m_spherename[255];
float *m_rot;
int nIter = 0;
int m_nSubj;
int m_nLM;
// workspace
float *fpoint; // landmarks
float *fmean; // mean for landmarks
float *faxis; // center of subject
};
class cost_function
{
public:
cost_function (RigidAlignment *instance)
{
m_instance = instance;
}
double operator () (float *arg)
{
float cost = m_instance->cost(arg);
return (double)cost;
}
private:
RigidAlignment *m_instance;
};