-
Notifications
You must be signed in to change notification settings - Fork 0
/
Group.cpp
executable file
·52 lines (43 loc) · 949 Bytes
/
Group.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
/*
* Group.cpp
*
*
* Created by Don House on 3/30/11.
* Copyright 2011 Clemson University. All rights reserved.
*
*/
#include "Group.h"
#include "MakeSpace.h"
using namespace std;
Group::Group(char *gname){
nfaces = maxfaces = 0;
faces = NULL;
name = NULL;
setName(gname);
}
void Group::setName(char *gname){
delete []name;
if(gname == NULL || strlen(gname) == 0)
name = NULL;
else{
name = new char[strlen(gname) + 1];
strcpy(name, gname);
}
}
bool Group::isNamed(char *gname){
if(name == NULL || gname == NULL)
return false;
return strcmp(gname, name) == 0;
}
void Group::addFace(int f){
if(maxfaces == nfaces)
faces = makespace <int> (maxfaces, faces);
faces[nfaces++] = f;
}
ostream& operator<< (ostream& os, const Group& g){
os << "[group " << g.name << ": (" << g.nfaces << ")";
for(int i = 0; i < g.nfaces; i++)
os << ", " << g.faces[i];
os << "]";
return os;
}