53 std::vector<Component> &components,
55 const TT *triangulation,
56 const TID seed)
const {
58 const TID componentId = components.size();
60 std::stack<TID> stack;
62 labels[seed] = componentId;
67 float center[3] = {0, 0, 0};
69 while(!stack.empty()) {
70 const auto cIndex = stack.top();
73 id = std::max(cIndex,
id);
76 triangulation->getVertexPoint(cIndex, x, y, z);
83 size_t const nNeighbors
84 = triangulation->getVertexNeighborNumber(cIndex);
85 for(
size_t i = 0; i < nNeighbors; i++) {
87 triangulation->getVertexNeighbor(cIndex, i, nIndex);
88 if(labels[nIndex] == this->UNLABELED) {
89 labels[nIndex] = componentId;
99 components.resize(componentId + 1);
100 auto &c = components[componentId];
101 std::copy(center, center + 3, c.center);
111 const DT *featureMask =
nullptr,
112 const DT backgroundThreshold = 0)
const {
114 std::string
const msg
116 + std::string(featureMask
117 ? (
" with BT: " + std::to_string(backgroundThreshold))
121 for(TID i = 0; i < nVertices; i++)
122 componentIds[i] = featureMask[i] > backgroundThreshold
126 std::fill(componentIds, componentIds + nVertices, this->UNLABELED);
136 const TT *triangulation)
const {
138 TID
const nVertices = triangulation->getNumberOfVertices();
141 const std::string msg =
"Computing Connected Components";
144 for(TID i = 0; i < nVertices; i++)
145 if(componentIds[i] == this->UNLABELED)
146 this->computeFloodFill<TT>(
147 componentIds, components, triangulation, i);