-
Notifications
You must be signed in to change notification settings - Fork 23
/
FaceInfo.cpp
95 lines (79 loc) · 2.41 KB
/
FaceInfo.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
/*
Copyright (c) 2009-2022,
Ken Arroyo Ohori k.ohori@tudelft.nl
Hugo Ledoux h.ledoux@tudelft.nl
Martijn Meijers b.m.meijers@tudelft.nl
All rights reserved.
This file is part of pprepair: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Licensees holding a valid commercial license may use this file in
accordance with the commercial license agreement provided with
the software.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "FaceInfo.h"
FaceInfo::FaceInfo() {
tag = NULL;
}
FaceInfo::~FaceInfo() {
if (tag != NULL) {
if (tag->isMultiPolygonHandle()) {
delete tag;
}
}
}
bool FaceInfo::hasTag(PolygonHandle *handle) {
if (tag == NULL) return false;
if (tag->isMultiPolygonHandle()) return static_cast<MultiPolygonHandle *>(tag)->hasHandle(handle);
if (tag == handle) return true;
return false;
}
bool FaceInfo::hasNoTags() const {
if (tag == NULL) return true;
return false;
}
bool FaceInfo::hasOneTag() const {
if (tag == NULL) return false;
if (tag->isMultiPolygonHandle()) return false;
return true;
}
unsigned long FaceInfo::numberOfTags() const {
if (tag == NULL) return 0;
if (tag->isMultiPolygonHandle()) return static_cast<MultiPolygonHandle *>(tag)->numberOfHandles();
return 1;
}
void FaceInfo::addTag(PolygonHandle *handle) {
if (tag == NULL) tag = handle;
else if (hasTag(handle)) return;
else if (tag->isMultiPolygonHandle()) static_cast<MultiPolygonHandle *>(tag)->addHandle(handle);
else if (tag != handle) {
MultiPolygonHandle *multiTag = new MultiPolygonHandle(tag);
multiTag->addHandle(handle);
tag = multiTag;
}
}
void FaceInfo::removeAllTags() {
if (tag == NULL) return;
if (tag->isMultiPolygonHandle()) delete tag;
tag = NULL;
}
void FaceInfo::substituteTagsWith(PolygonHandle *handle) {
removeAllTags();
addTag(handle);
}
PolygonHandle * FaceInfo::getOneTag() const {
if (tag == NULL) return NULL;
if (tag->isMultiPolygonHandle()) {
return *static_cast<MultiPolygonHandle *>(tag)->getHandles()->begin();
} return tag;
}
PolygonHandle * FaceInfo::getTags() const {
return tag;
}
void FaceInfo::setTags(PolygonHandle *handle) {
tag = handle;
}