-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vertex.cpp
59 lines (51 loc) · 1.12 KB
/
Vertex.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
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include "Vertex.h"
Vertex::Vertex(){}
Vertex::Vertex(float x, float y, float z){
this->init(x,y,z);
};
Vertex::Vertex(std::string &xyz){
std::istringstream ss(xyz);
std::string token;
float x;
float y;
float z;
std::getline(ss, token, ',');
x = std::stof(token);
std::getline(ss, token, ',');
y = std::stof(token);
std::getline(ss, token, ',');
z = std::stof(token);
this->init(x,y,z);
};
void Vertex::init(float x, float y, float z){
this->SetX(x);
this->SetY(y);
this->SetZ(z);
};
void Vertex::SetX(float x) {
this->x = x;
}
void Vertex::SetY(float y) {
this->y = y;
}
void Vertex::SetZ(float z) {
this->z = z;
}
float Vertex::GetX() const {
return x;
}
float Vertex::GetY() const {
return y;
}
float Vertex::GetZ() const {
return z;
}
std::ostream& operator<<(std::ostream& os, const Vertex &obj) {
os << "(" << std::fixed << std::setprecision(3) << obj.GetX() << "," << obj.GetY() << "," << obj.GetZ() << ")";
return os;
}