-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMeshPosition.cpp
70 lines (55 loc) · 1.46 KB
/
MeshPosition.cpp
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
// MeshPosition.cpp
// Copyright (c) 2009, Dan Heeks
// This program is released under the BSD license. See the file COPYING for details.
#include "stdafx.h"
#include "MeshPosition.h"
CMeshPosition::CMeshPosition(const CMeshPosition& p){
operator=(p);
}
CMeshPosition::CMeshPosition(const Point& v){
set_vertex(v);
}
CMeshPosition::CMeshPosition(int x, int y, int z){
m_x[0] = x;
m_x[1] = y;
m_x[2] = z;
}
const CMeshPosition& CMeshPosition::operator=(const CMeshPosition& p){
for(int i = 0; i<3; i++){
m_x[i] = p.m_x[i];
}
return *this;
}
bool CMeshPosition::operator<(const CMeshPosition& p)const{
for(int i = 0; i<3; i++){
if(m_x[i]<p.m_x[i])return true;
if(m_x[i]>p.m_x[i])return false;
}
return false;
}
bool CMeshPosition::operator>(const CMeshPosition& p)const{
for(int i = 0; i<3; i++){
if(m_x[i]>p.m_x[i])return true;
if(m_x[i]<p.m_x[i])return false;
}
return false;
}
bool CMeshPosition::operator==(const CMeshPosition& p)const{
for(int i = 0; i<3; i++){
if(m_x[i]!=p.m_x[i])return false;
}
return true;
}
Point CMeshPosition::vertex()const{
return Point(((double)m_x[0]) * MESH_POSITION_UNIT,
((double)m_x[1]) * MESH_POSITION_UNIT,
((double)m_x[2]) * MESH_POSITION_UNIT);
}
void CMeshPosition::set_vertex(const Point& v){
for(int i = 0; i<3; i++){
double x = v.GetPtr()[i] * ONE_OVER_MESH_POSITION_UNIT;
if(x<0)x -= 0.5;
else x += 0.5;
m_x[i] = (int)x;
}
}