MCPcopy Create free account
hub / github.com/colmap/colmap / BuildFaceAdjacency

Function BuildFaceAdjacency

src/colmap/mvs/texture_mapping.cc:155–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155FaceAdjacencyMap BuildFaceAdjacency(const PlyMesh& mesh) {
156 const size_t num_faces = mesh.faces.size();
157 std::unordered_map<uint64_t, std::vector<size_t>> edge_to_faces;
158 edge_to_faces.reserve(num_faces * 3);
159
160 for (size_t fi = 0; fi < num_faces; ++fi) {
161 const std::array<size_t, 3> idx = GetFaceIndices(mesh.faces[fi]);
162 for (int e = 0; e < 3; ++e) {
163 const uint64_t key = EdgeKey(idx[e], idx[(e + 1) % 3]);
164 edge_to_faces[key].push_back(fi);
165 }
166 }
167
168 FaceAdjacencyMap adjacency(num_faces);
169 for (const auto& [edge_key, face_list] : edge_to_faces) {
170 if (face_list.size() == 2) {
171 adjacency[face_list[0]].push_back(face_list[1]);
172 adjacency[face_list[1]].push_back(face_list[0]);
173 }
174 }
175
176 for (auto& neighbors : adjacency) {
177 std::sort(neighbors.begin(), neighbors.end());
178 neighbors.erase(std::unique(neighbors.begin(), neighbors.end()),
179 neighbors.end());
180 }
181
182 return adjacency;
183}
184
185#if defined(COLMAP_CGAL_ENABLED)
186

Callers 1

MeshTextureMappingFunction · 0.85

Calls 5

GetFaceIndicesFunction · 0.85
EdgeKeyFunction · 0.85
sizeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected