-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFace.cpp
executable file
·62 lines (54 loc) · 1.22 KB
/
Face.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
/*
* Face.cpp
*
*
* Created by Donald House on 2/18/11.
* Copyright 2011 Clemson University. All rights reserved.
*
*/
#include <cstdlib>
#include <iostream>
#include "Face.h"
using namespace std;
Face::Face(int g, int m){
nverts = maxverts = 0;
verts = NULL;
group = g;
material = m;
}
void Face::setGroup(int g){
group = g;
}
void Face::setMaterial(int m){
material = m;
}
void Face::addVert(int v, int n, int u){
if(maxverts == 0){
maxverts = 3;
verts = new int[maxverts][3];
}
else if(maxverts == nverts){
int (*newverts)[3];
newverts = new int[2 * maxverts][3];
for(int i = 0; i < maxverts; i++){
newverts[i][0] = verts[i][0];
newverts[i][1] = verts[i][1];
newverts[i][2] = verts[i][2];
}
delete []verts;
verts = newverts;
maxverts = 2 * maxverts;
}
verts[nverts][0] = v;
verts[nverts][1] = n;
verts[nverts][2] = u;
nverts++;
}
ostream& operator<< (ostream& os, const Face& f){
os << "[face: (" << f.nverts << ")";
for(int i = 0; i < f.nverts; i++)
os << " (" << f.verts[i][0] << ", " << f.verts[i][1] << ", " << f.verts[i][2] << ")";
os << ", group: " << f.group << ", material: " << f.material;
os << "]";
return os;
}