-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrowing.cpp
More file actions
69 lines (58 loc) · 1.45 KB
/
growing.cpp
File metadata and controls
69 lines (58 loc) · 1.45 KB
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
#include "growing.h"
void RegionGrowing::initPatches(Face *face) {
GrowingPatch *p = new GrowingPatch;
p->center = calcCenter(face);
for (FaceHalfedgeIterator fheit(face); !fheit.end(); ++fheit) {
p->frontEdges.push_back(*fheit);
}
}
bool RegionGrowing::grow() {
for (size_t i = 0; i < m_patches.size(); ++i) {
GrowingPatch *patch = m_patches[i];
}
return true;
}
bool RegionGrowing::grow(GrowingPatch *patch) {
std::set<Face*, GrowingPatch> candidateFaces(*patch);
std::set<Halfedge*> candidateFrontHalfEdges;
for (size_t i = 0; i < patch->frontEdges.size(); ++i) {
Halfedge *he = patch->frontEdges[i];
Face *f0 = he->face();
Halfedge *ohe = he->twin();
if (!ohe) {
continue;
}
Face *f1 = ohe->face();
if (face2patchMap[f0]) {
candidateFrontHalfEdges.insert(he);
candidateFaces.insert(f0);
}
if (face2patchMap[f1]) {
candidateFrontHalfEdges.insert(ohe);
candidateFaces.insert(f1);
}
}
//update the map
for (auto f : candidateFaces) {
face2patchMap[f] = patch;
f->PropertyStr() = "rgb=(1 0 0)";
}
if (!candidateFrontHalfEdges.empty()) {
patch->frontEdges.clear();
//update the front edge;
for (auto he : candidateFrontHalfEdges) {
Face *f0 = he->face();
Halfedge *ohe = he->twin();
if (ohe) {
Face *f1 = ohe->face();
if (!face2patchMap[f0]) {
patch->frontEdges.push_back(he);
}
if (!face2patchMap[f1]) {
patch->frontEdges.push_back(ohe);
}
}
}
}
return true;
}