MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / buildQueue

Method buildQueue

ImagePlay/src/IPProcessGrid.cpp:67–129  ·  view source on GitHub ↗

breath first search

Source from the content-addressed store, hash-verified

65
66//breath first search
67void IPProcessGrid::buildQueue()
68{
69 qDebug() << "IPProcessGrid::buildQueue";
70 QQueue<IPProcessStep*> tmpQueue;
71 _processList.clear();
72
73 // find source processes
74 int branchID = 0;
75 for(auto it = _scene->steps()->begin(); it < _scene->steps()->end(); ++it)
76 {
77 IPProcessStep* step = (IPProcessStep*) *it;
78 IPLProcess* process = step->process();
79
80 // attach property changed event handler
81 process->registerPropertyChangedEventHandler(this);
82 process->registerOutputsChangedEventHandler(this);
83
84 if(process->isSource())
85 {
86 step->setTreeDepth(0);
87 step->setBranchID(branchID++);
88 _processList.push_back(step);
89 tmpQueue.enqueue(step);
90 }
91 }
92
93 // add all other process steps with BFS
94 int counter = 0;
95 int limit = 100;
96 while(!tmpQueue.isEmpty() && counter < limit)
97 {
98 IPProcessStep* step = tmpQueue.dequeue();
99
100 for(auto it = step->edgesOut()->begin(); it < step->edgesOut()->end(); ++it)
101 {
102 IPProcessEdge* edge = (IPProcessEdge*) *it;
103 IPProcessStep* nextStep = edge->to();
104
105 // set depth
106 nextStep->setTreeDepth(step->treeDepth()+1);
107
108 // set branch ID
109 nextStep->setBranchID(step->branchID());
110
111 // add to queue and list
112 tmpQueue.enqueue(nextStep);
113
114 // unique
115 if(!_processList.contains(nextStep))
116 {
117 _processList.push_back(nextStep);
118 }
119 }
120 }
121
122 // sort by depth
123 qSort(_processList.begin(), _processList.end(), IPProcessGrid::sortTreeDepthLessThan);
124

Callers

nothing calls this directly

Calls 15

stepsMethod · 0.80
setTreeDepthMethod · 0.80
setBranchIDMethod · 0.80
edgesOutMethod · 0.80
toMethod · 0.80
treeDepthMethod · 0.80
branchIDMethod · 0.80
containsMethod · 0.80
sortTabsMethod · 0.80
imageViewerMethod · 0.80

Tested by

no test coverage detected