-
Notifications
You must be signed in to change notification settings - Fork 16
/
GeometricObject.cpp
117 lines (83 loc) · 2.42 KB
/
GeometricObject.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
////////////////////////////////////////////////////////////////////////////////////
// Copyright © Charalambos "Charis" Poullis, [email protected] //
// This work can only be used under an exclusive license of the author. //
////////////////////////////////////////////////////////////////////////////////////
#ifndef __GEOMETRIC_OBJECT_CPP__
#define __GEOMETRIC_OBJECT_CPP__
#include "GeometricObject.h"
#include "GeometryProcessing.h"
GeometricObject::GeometricObject(std::vector<Vector3f> const &_vertices,
std::vector<Vector3f> const &_normals,
std::vector<Vector2f> const &_tex_coords,
std::vector<Face *> const &_faces,
std::vector<Edge *> const &_edges):
vertices(_vertices),normals(_normals),texture_coords(_tex_coords),faces(_faces),edges(_edges) {
}
GeometricObject::~GeometricObject() {
vertices.clear();
normals.clear();
texture_coords.clear();
for (int i=0;i<edges.size();i++) {
delete edges[i];
}
edges.clear();
for (int i=0;i<faces.size();i++) {
delete faces[i];
}
faces.clear();
}
std::vector<Vector3f> GeometricObject::getVertices() const {
return vertices;
}
Vector3f GeometricObject::getVertexAt(int index) const {
if (index>=0 && index<vertices.size()) {
return vertices[index];
}
else {
std::cout << "here 4b: " << index << " out of " << vertices.size() << std::endl;
}
return Vector3f();
}
std::vector<Vector3f> GeometricObject::getNormals() const {
return normals;
}
Vector3f GeometricObject::getNormalAt(int index) const {
if (index>=0 && index<normals.size()) {
return normals[index];
}
return Vector3f();
}
std::vector<Vector2f> GeometricObject::getTextureCoords() const {
return texture_coords;
}
Vector2f GeometricObject::getTextureCoordAt(int index) const {
if (index>=0 && index<texture_coords.size()) {
return texture_coords[index];
}
return Vector2f();
}
std::vector<Face *> GeometricObject::getFaces() const {
return faces;
}
Face *GeometricObject::getFaceAt(int index) const {
if (index>=0 && index<faces.size()) {
return faces[index];
}
return 0x00;
}
std::vector<Edge *> GeometricObject::getEdges() const {
return edges;
}
Edge *GeometricObject::getEdgeAt(int index) const {
if (index>=0 && index<edges.size()) {
return edges[index];
}
return 0x00;
}
void GeometricObject::translate(Vector3f _translation) {
for (int i=0;i<vertices.size();i++) {
vertices[i] += _translation;
}
return;
}
#endif