MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / processSelfSubtasks

Function processSelfSubtasks

source/MRMesh/MRProcessSelfTreeSubtasks.cpp:7–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5{
6
7void processSelfSubtasks(
8 const AABBTree& tree,
9 std::vector<NodeNode>& subtasks,
10 std::vector<NodeNode>& nextSubtasks, /*/< may be same as subtasks */
11 std::function<Processing( const NodeNode& )> processLeaf,
12 std::function<Processing( const Box3f& lBox, const Box3f& rBox )> processNodes )
13{
14 while ( !subtasks.empty() )
15 {
16 const auto s = subtasks.back();
17 subtasks.pop_back();
18 const auto& aNode = tree[s.aNode];
19 const auto& bNode = tree[s.bNode];
20
21 if ( s.aNode == s.bNode )
22 {
23 if ( !aNode.leaf() )
24 {
25 nextSubtasks.push_back( { aNode.l, aNode.l } );
26 nextSubtasks.push_back( { aNode.r, aNode.r } );
27 nextSubtasks.push_back( { aNode.l, aNode.r } );
28 }
29 continue;
30 }
31
32 const auto processNode = processNodes( aNode.box, bNode.box );
33 if ( processNode == Processing::Stop )
34 continue;
35
36 if ( aNode.leaf() && bNode.leaf() )
37 {
38 if ( processLeaf( s ) == Processing::Stop )
39 return;
40 continue;
41 }
42
43 if ( !aNode.leaf() && ( bNode.leaf() || aNode.box.volume() >= bNode.box.volume() ) )
44 {
45 // split aNode
46 nextSubtasks.push_back( { aNode.l, s.bNode } );
47 nextSubtasks.push_back( { aNode.r, s.bNode } );
48 }
49 else
50 {
51 assert( !bNode.leaf() );
52 // split bNode
53 nextSubtasks.push_back( { s.aNode, bNode.l } );
54 nextSubtasks.push_back( { s.aNode, bNode.r } );
55 }
56 }
57}
58
59}

Callers 2

Calls 5

pop_backMethod · 0.80
push_backMethod · 0.80
emptyMethod · 0.45
leafMethod · 0.45
volumeMethod · 0.45

Tested by

no test coverage detected