MCPcopy Create free account
hub / github.com/comaps/comaps / FlattenBuildingParts

Function FlattenBuildingParts

generator/hierarchy.cpp:295–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295void FlattenBuildingParts(HierarchyLinker::Node::Ptrs & trees)
296{
297 for (auto & tree : trees)
298 {
299 CHECK(!tree->HasParent(), ());
300
301 std::vector<std::pair<hierarchy::HierarchyLinker::Node::Ptr, hierarchy::HierarchyLinker::Node::Ptr>>
302 buildingPartsTrees;
303
304 static auto const & buildingPartChecker = ftypes::IsBuildingPartChecker::Instance();
305 std::function<void(hierarchy::HierarchyLinker::Node::Ptr const &)> visit;
306 visit = [&](auto const & n)
307 {
308 if (buildingPartChecker(n->GetData().GetTypes()))
309 {
310 CHECK(n->HasParent(), ());
311 auto building = n->GetParent();
312 buildingPartsTrees.emplace_back(building, n);
313 return;
314 }
315
316 CHECK(!buildingPartChecker(n->GetData().GetTypes()), ());
317 for (auto const & ch : n->GetChildren())
318 visit(ch);
319 };
320
321 visit(tree);
322
323 for (auto const & buildingAndParts : buildingPartsTrees)
324 {
325 Unlink(buildingAndParts.second, buildingAndParts.first);
326 tree_node::PostOrderVisit(buildingAndParts.second, [&](auto const & buildingPartNode)
327 {
328 CHECK(buildingPartChecker(buildingPartNode->GetData().GetTypes()), ());
329 buildingPartNode->RemoveChildren();
330 tree_node::Link(buildingPartNode, buildingAndParts.first);
331 });
332 }
333 }
334}
335} // namespace hierarchy
336} // namespace generator

Callers 2

ProcessMethod · 0.85
UNIT_CLASS_TESTFunction · 0.85

Calls 10

UnlinkFunction · 0.85
PostOrderVisitFunction · 0.85
GetChildrenMethod · 0.80
RemoveChildrenMethod · 0.80
LinkFunction · 0.50
HasParentMethod · 0.45
GetTypesMethod · 0.45
GetDataMethod · 0.45
GetParentMethod · 0.45
emplace_backMethod · 0.45

Tested by 1

UNIT_CLASS_TESTFunction · 0.68