-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFace.cpp
More file actions
92 lines (67 loc) · 1.69 KB
/
Face.cpp
File metadata and controls
92 lines (67 loc) · 1.69 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "Face.h"
Face::Face(int nPointsInFace, vector<Point*> facePoints, int owner=-1, int neighbour=-1 )
: nPointsInFace_(nPointsInFace),
facePoints_(facePoints),
owner_(owner),
neighbour_(neighbour),
areaVector_({-2,-2,-2}),
centerOfMass_{-2,-2,-2},
area_(0),
weightingFactor_(0),
nonOrthogonalityAngle_(0)
{
computeFaceAreaVector();
}
Face::Face( )
{
}
void Face::setNeighbour(int neighbour)
{
neighbour_ = neighbour;
}
void Face::setOwner(int owner)
{
owner_ = owner;
}
void Face::computeFaceAreaVector()
{
//Creates two vectors from the center of mass and one of the points in the face
vector3 tmp_vec1 = facePoints_[0]->getPoint() - centerOfMass_;
vector3 tmp_vec2 = facePoints_[1]->getPoint() - centerOfMass_;
// Computes the face normal by doing the cross product of the products (this is not the faceAreaVector)
vector3 areaVector_tmp = (tmp_vec1^tmp_vec2);
// Computes the norm of the cross product between two vectors
double mag_vector_tmp = mag(areaVector_tmp);
// Calculates the faceAreaVector
areaVector_ = (areaVector_tmp/mag_vector_tmp)*area_;
}
void Face::setweightingFactor(double g_c)
{
weightingFactor_ = g_c;
}
int Face::getOwner() const
{
return owner_;
}
int Face::getNeighbour() const
{
return neighbour_;
}
vector3 Face::getCenterOfMass() const
{
return centerOfMass_;
}
vector3 Face::getFaceAreaVector() const
{
return areaVector_;
}
std::ostream& operator<<(std::ostream& os, const Face& p)
{
os << "[ " << std::endl;
for (unsigned int i= 0; i < p.facePoints_.size() ; i++)
{
os << *p.facePoints_[i];
}
os << "]" << std::endl;
return os;
}