-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphObj.cpp
76 lines (61 loc) · 1.72 KB
/
graphObj.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
71
72
73
74
75
76
#include "graphObj.h"
#include <iostream>
GraphObj::GraphObj(std::string name, type t) {
this->t = t;
this->name = name;
points = new std::list<point>();
normalizedPoints = new std::list<point>();
}
type GraphObj::getType() {
return this->t;
}
std::string GraphObj::getName() {
return this->name;
}
void GraphObj::changeName(std::string newName) {
this->name = newName;
}
void GraphObj::setPoints(std::list<point>* newPoints){
this->points = newPoints;
}
void GraphObj::setClippedPoints(std::list<point>* clipped) {
clippedPoints = clipped;
//std::cout << clippedPoints->size() << "/" << points->size() << "/" << name <<"\n";
}
std::list<point>* GraphObj::getPoints() {
return points;
}
std::list<point>* GraphObj::getClippedPoints() {
return clippedPoints;
}
std::list<point>* GraphObj::getNormalizedPoints() {
return normalizedPoints;
}
void GraphObj::transform(double matrix[4][4]){
std::list<point>* transformed = new std::list<point>();
// TODO genericTransform
for (std::list<point>::const_iterator it = points->begin();
it != points->end();
++it) {
transformed->push_back(Utils::transform(*it, matrix));
}
this->points->clear();
this->points = transformed;
}
void GraphObj::transformOnWindowRotation(double matrix[4][4]){
normalizedPoints = genericTransform(matrix);
}
std::list<point>* GraphObj::genericTransform(double matrix[4][4]){
point a;
std::list<point>* transformed = new std::list<point>();
for (std::list<point>::const_iterator it = points->begin();
it != points->end();
++it) {
a = *it;
std::cout << "antes:" << a.x << "," << a.y <<"\n";
a = Utils::transform(a, matrix);
std::cout << "depois:" << a.x << "," << a.y <<"\n";
transformed->push_back(a);
}
return transformed;
}