-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathComponentMatch.cpp
More file actions
69 lines (54 loc) · 1.86 KB
/
Copy pathComponentMatch.cpp
File metadata and controls
69 lines (54 loc) · 1.86 KB
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
#include "ComponentMatch.h"
ComponentMatch::ComponentMatch(MeshComponent* originalComponent, MeshComponent* derivComponent) {
originalComp = originalComponent;
derivativeComp = derivComponent;
//CALCULATE THE COST OF THIS MATCHING
cost = 0.0;
//If both are vertices just compute the geometric cost
if(originalComp->type==MeshComponent::VERTEX && originalComp->type==MeshComponent::VERTEX){
addGeometricCost();
}
else if( (originalComp->type!=MeshComponent::EMPTY && derivComponent->type==MeshComponent::EMPTY)
|| (derivComponent->type!=MeshComponent::EMPTY && originalComp->type==MeshComponent::EMPTY)){
//this is an unmatched pairing, e.g. vert with no match in the other geometry
double costUnmatched = 1.0;
cost = costUnmatched;
}
color.r= (rand() % 10)/10.0;
color.g= (rand() % 10)/10.0;
color.b= (rand() % 10)/10.0;
}
ComponentMatch::ComponentMatch() {
}
void ComponentMatch::addAdjacencyCost() {
double adjCost = 0.0;
cost += adjCost;
}
void ComponentMatch::addGeometricCost() {
//Geometric cost = cost of position difference + cost of orientation diff(wrt normals of adjacent faces)
//1-Cost of position difference = d/(d+1)
MPoint vertA = originalComp->pos;
MPoint vertB = derivativeComp->pos;
double distance= vertA.distanceTo(vertB);
double costP = distance/(distance+1);
//2 - TODO Cost of orientation, need adjacent face data which we don't have at the moment
double costO=0.0;
cost += costP + costO;
}
Match ComponentMatch::getMatches() {
Match match;
match.originalComp = originalComp;
match.derivativeComp = derivativeComp;
return match;
}
double ComponentMatch::getCost() {
return cost;
}
bool ComponentMatch::isEqualTo(ComponentMatch* other){
//TO DO - expand for faces case as well
if(originalComp->isEqualTo(other->originalComp) &&
(derivativeComp->isEqualTo(other->derivativeComp))){
return true;
}
return false;
}