2004-09-30 02:27:42 +02:00
|
|
|
#include <GL/glew.h>
|
2004-09-17 17:25:59 +02:00
|
|
|
#include "nexusmt.h"
|
|
|
|
#include <map>
|
|
|
|
#include <queue>
|
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
|
2004-09-17 17:25:59 +02:00
|
|
|
using namespace nxs;
|
2004-09-30 02:27:42 +02:00
|
|
|
using namespace vcg;
|
2004-09-17 17:25:59 +02:00
|
|
|
using namespace std;
|
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
/*void Policy::Visit(Node *node, std::queue<Node *> &qnode) {
|
2004-09-28 12:26:35 +02:00
|
|
|
std::vector<Node *>::iterator n;
|
|
|
|
for(n = node->in.begin(); n != node->in.end(); n++)
|
|
|
|
if(!(*n)->visited)
|
|
|
|
Visit(*n, qnode);
|
|
|
|
|
|
|
|
node->visited = true;
|
|
|
|
qnode.push(node);
|
|
|
|
}
|
|
|
|
|
2004-10-08 16:46:26 +02:00
|
|
|
bool FrustumPolicy::Expand(unsigned int patch, Nexus::PatchInfo &entry) {
|
2004-09-28 12:26:35 +02:00
|
|
|
if(entry.error == 0) return false;
|
|
|
|
float dist = Distance(entry.sphere, frustum.ViewPoint());
|
|
|
|
if(dist < 0) return true;
|
|
|
|
// dist = pow(dist, 1.2);
|
|
|
|
return entry.error > error * frustum.Resolution(dist);
|
2004-10-14 15:42:33 +02:00
|
|
|
} */
|
|
|
|
|
|
|
|
float FrustumMetric::GetError(Node *node) {
|
|
|
|
float max_error = 0;
|
|
|
|
std::vector<Frag>::iterator frag;
|
|
|
|
for(frag = node->frags.begin(); frag != node->frags.end(); frag++) {
|
|
|
|
vector<unsigned int>::iterator cell;
|
|
|
|
for(cell = (*frag).begin(); cell != (*frag).end(); cell++) {
|
|
|
|
Nexus::PatchInfo &entry = (*index)[*cell];
|
|
|
|
Sphere3f &sphere = entry.sphere;
|
|
|
|
float dist = Distance(sphere, frustum.ViewPoint());
|
|
|
|
if(dist < 0) break;
|
|
|
|
float error = entry.error/frustum.Resolution(dist);
|
|
|
|
if(frustum.IsOutside(sphere.Center(), sphere.Radius()))
|
|
|
|
error *= 4;
|
|
|
|
if(max_error < error) max_error = error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return max_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Policy::Init() {
|
|
|
|
ram_used = 0;
|
2004-09-28 12:26:35 +02:00
|
|
|
}
|
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
bool Policy::Expand(TNode &node) {
|
|
|
|
//expand if node error > target error
|
|
|
|
if(ram_used >= ram_size) return false;
|
|
|
|
//cerr << "Error: " << error << " node.error: " << node.error << endl;
|
|
|
|
return node.error > error;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Policy::NodeVisited(Node *node) {
|
|
|
|
//TODO write this a bit more elegant.
|
|
|
|
//first we process arcs removed:
|
|
|
|
|
|
|
|
for(unsigned int i = 0; i < node->out.size(); i++) {
|
|
|
|
assert(!(node->out[i]->visited));
|
|
|
|
Frag &frag = node->frags[i];
|
|
|
|
for(unsigned int k = 0; k < frag.size(); k++) {
|
|
|
|
unsigned int rr = frag.size();
|
|
|
|
unsigned int tmp = frag[k];
|
|
|
|
unsigned int sz = entries->size();
|
|
|
|
assert(tmp < sz);
|
|
|
|
PatchEntry &entry = (*entries)[frag[k]];
|
|
|
|
ram_used += entry.ram_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<Node *>::iterator from;
|
|
|
|
for(from = node->in.begin(); from != node->in.end(); from++) {
|
|
|
|
assert((*from)->visited);
|
|
|
|
vector<Frag> &frags = (*from)->frags;
|
|
|
|
for(unsigned int i = 0; i < frags.size(); i++) {
|
|
|
|
if((*from)->out[i] == node) {
|
|
|
|
vector<unsigned int> &frag = frags[i];
|
|
|
|
for(unsigned int k = 0; k < frag.size(); k++) {
|
|
|
|
PatchEntry &entry = (*entries)[frag[k]];
|
|
|
|
ram_used -= entry.ram_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-09-28 12:26:35 +02:00
|
|
|
|
2004-10-08 16:46:26 +02:00
|
|
|
NexusMt::NexusMt(): vbo(VBO_AUTO), vbo_size(0),
|
2004-10-14 15:42:33 +02:00
|
|
|
metric(NULL), mode(SMOOTH) {
|
|
|
|
metric = new FrustumMetric();
|
|
|
|
metric->index = &index;
|
|
|
|
policy.error = 4;
|
|
|
|
policy.ram_size = 64000000;
|
2004-09-30 02:27:42 +02:00
|
|
|
}
|
|
|
|
|
2004-10-08 16:46:26 +02:00
|
|
|
NexusMt::~NexusMt() {}
|
2004-10-04 18:49:54 +02:00
|
|
|
|
2004-10-10 19:19:42 +02:00
|
|
|
bool NexusMt::Load(const string &filename, bool readonly) {
|
|
|
|
if(!Nexus::Load(filename, readonly)) return false;
|
2004-09-30 02:27:42 +02:00
|
|
|
LoadHistory();
|
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
policy.entries = &patches.patches;
|
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
use_colors = false;
|
|
|
|
use_normals = false;
|
|
|
|
use_textures = false;
|
|
|
|
use_data = false;
|
|
|
|
|
|
|
|
SetComponent(COLOR, true);
|
|
|
|
SetComponent(NORMAL, true);
|
|
|
|
SetComponent(TEXTURE, true);
|
|
|
|
SetComponent(DATA, true);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NexusMt::InitGL() {
|
|
|
|
GLenum ret = glewInit();
|
|
|
|
if(ret != GLEW_OK) return false;
|
|
|
|
if(!GLEW_ARB_vertex_buffer_object)
|
|
|
|
vbo = VBO_OFF;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NexusMt::Render() {
|
|
|
|
Frustumf frustum;
|
|
|
|
frustum.GetView();
|
|
|
|
|
|
|
|
vector<unsigned int> cells;
|
2004-10-14 15:42:33 +02:00
|
|
|
metric->GetView();
|
|
|
|
policy.Init();
|
|
|
|
tri_total = 0;
|
|
|
|
tri_rendered = 0;
|
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
Extract(cells);
|
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
if(use_colors)
|
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
|
|
|
if(use_normals)
|
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
|
|
|
//TODO textures and data.
|
|
|
|
|
2004-10-09 16:46:47 +02:00
|
|
|
for(unsigned int i = 0; i < cells.size(); i++) {
|
2004-10-01 01:56:33 +02:00
|
|
|
unsigned int cell = cells[i];
|
2004-10-14 15:42:33 +02:00
|
|
|
Nexus::PatchInfo &entry = index[cell];
|
|
|
|
tri_total += entry.nface;
|
2004-09-30 02:27:42 +02:00
|
|
|
//frustum culling
|
2004-10-04 18:49:54 +02:00
|
|
|
if(frustum.IsOutside(entry.sphere.Center(), entry.sphere.Radius()))
|
|
|
|
continue;
|
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
tri_rendered += entry.nface;
|
|
|
|
|
2004-10-08 16:46:26 +02:00
|
|
|
Patch &patch = GetPatch(cell);
|
|
|
|
|
|
|
|
assert(patch.start);
|
2004-10-01 18:54:57 +02:00
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
glVertexPointer(3, GL_FLOAT, 0, patch.VertBegin());
|
|
|
|
if(use_colors)
|
|
|
|
glColorPointer(4, GL_UNSIGNED_BYTE, 0, patch.ColorBegin());
|
|
|
|
if(use_normals)
|
|
|
|
glNormalPointer(GL_SHORT, 8, patch.Norm16Begin());
|
2004-10-01 18:54:57 +02:00
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
switch(mode) {
|
|
|
|
case POINTS:
|
|
|
|
glDrawArrays(GL_POINTS, 0, patch.nv); break;
|
2004-10-01 01:56:33 +02:00
|
|
|
case DEBUG:
|
|
|
|
glColor3ub((cell * 27)%255, (cell * 37)%255, (cell * 87)%255);
|
2004-09-30 02:27:42 +02:00
|
|
|
case SMOOTH:
|
|
|
|
if(signature & NXS_FACES)
|
|
|
|
glDrawElements(GL_TRIANGLES, patch.nf * 3,
|
|
|
|
GL_UNSIGNED_SHORT, patch.FaceBegin());
|
|
|
|
else if(signature & NXS_STRIP)
|
|
|
|
glDrawElements(GL_TRIANGLE_STRIP, patch.nf,
|
|
|
|
GL_UNSIGNED_SHORT, patch.FaceBegin());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cerr << "Unsupported rendering mode sorry\n";
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
|
|
|
}
|
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
void NexusMt::SetRamSize(unsigned int r_size) {
|
|
|
|
policy.ram_size = r_size/patches.chunk_size;
|
2004-09-30 02:27:42 +02:00
|
|
|
}
|
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
void NexusMt::SetMetric(NexusMt::MetricKind kind) {
|
|
|
|
//do nothing at the moment.
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void NexusMt::SetError(float error) {
|
|
|
|
policy.error = error;
|
2004-09-30 02:27:42 +02:00
|
|
|
}
|
|
|
|
|
2004-10-04 18:49:54 +02:00
|
|
|
void NexusMt::SetVbo(Vbo _vbo, unsigned int _vbo_size,
|
|
|
|
unsigned int _ram_size) {
|
2004-09-30 02:27:42 +02:00
|
|
|
vbo = _vbo;
|
|
|
|
if(!GLEW_ARB_vertex_buffer_object)
|
|
|
|
vbo = VBO_OFF;
|
|
|
|
vbo_size = _vbo_size;
|
2004-10-08 16:46:26 +02:00
|
|
|
patches.ram_size = _ram_size/chunk_size;
|
2004-09-30 02:27:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NexusMt::SetMode(Mode _mode) {
|
|
|
|
mode = _mode;
|
2004-10-09 16:46:47 +02:00
|
|
|
return true;
|
2004-09-30 02:27:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NexusMt::SetComponent(Component c, bool on) {
|
|
|
|
if(c == COLOR && (signature & NXS_COLORS))
|
|
|
|
use_colors = on;
|
|
|
|
if(c == NORMAL && (signature & NXS_NORMALS_SHORT))
|
|
|
|
use_normals = on;
|
|
|
|
if(c == TEXTURE && (signature & NXS_TEXTURES_SHORT))
|
|
|
|
use_textures = on;
|
|
|
|
if(c == DATA && (signature & NXS_DATA32))
|
|
|
|
use_data = on;
|
|
|
|
|
|
|
|
components = COLOR * use_colors + NORMAL * use_normals +
|
|
|
|
TEXTURE * use_textures + DATA * use_data;
|
2004-10-09 16:46:47 +02:00
|
|
|
return true;
|
2004-09-30 02:27:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NexusMt::SetComponents(unsigned int mask) {
|
2004-10-09 16:46:47 +02:00
|
|
|
SetComponent(COLOR, (mask & COLOR) != 0);
|
|
|
|
SetComponent(NORMAL, (mask & NORMAL) != 0);
|
|
|
|
SetComponent(TEXTURE, (mask & TEXTURE) != 0);
|
|
|
|
SetComponent(DATA, (mask & DATA) != 0);
|
2004-09-30 02:27:42 +02:00
|
|
|
|
|
|
|
components = mask;
|
|
|
|
|
|
|
|
if( ((mask & COLOR) && !(signature & NXS_COLORS)) ||
|
|
|
|
((mask & NORMAL) && !(signature & NXS_NORMALS_SHORT)) ||
|
|
|
|
((mask & TEXTURE) && !(signature & NXS_TEXTURES_SHORT)) ||
|
|
|
|
((mask & DATA) && !(signature & NXS_DATA32)) )
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-09-17 17:25:59 +02:00
|
|
|
void NexusMt::LoadHistory() {
|
|
|
|
//The last update erases everything.
|
|
|
|
assert(history[0].erased.size() == 0);
|
|
|
|
|
|
|
|
//maps cell -> node containing it
|
|
|
|
map<unsigned int, unsigned int> cell_node;
|
|
|
|
nodes.resize(history.size());
|
|
|
|
|
|
|
|
//building fragments and nodes.
|
|
|
|
unsigned int current_node = 0;
|
|
|
|
vector<Update>::iterator u;
|
|
|
|
for(u = history.begin(); u != history.end(); u++) {
|
|
|
|
|
|
|
|
Node &node = nodes[current_node];
|
|
|
|
node.error = 0;
|
|
|
|
|
|
|
|
//created cells belong to this node, we look also for max error.
|
|
|
|
for(unsigned int i = 0; i < (*u).created.size(); i++) {
|
|
|
|
unsigned int cell = (*u).created[i];
|
|
|
|
if(index[cell].error > node.error)
|
2004-10-09 16:46:47 +02:00
|
|
|
node.error = index[cell].error;
|
2004-09-17 17:25:59 +02:00
|
|
|
|
|
|
|
cell_node[cell] = current_node;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Every erased cell already belonged to a node.
|
|
|
|
//we record for each node its cells.
|
|
|
|
map<unsigned int, vector<unsigned int> > node_erased;
|
|
|
|
|
|
|
|
for(unsigned int i = 0; i < (*u).erased.size(); i++) {
|
|
|
|
unsigned int cell = (*u).erased[i];
|
|
|
|
assert(cell_node.count(cell));
|
|
|
|
node_erased[cell_node[cell]].push_back(cell);
|
|
|
|
}
|
|
|
|
|
|
|
|
//for every node with erased cells we build a frag and
|
|
|
|
//put the corresponding cells in it.
|
|
|
|
map<unsigned int, vector<unsigned int> >::iterator e;
|
|
|
|
for(e = node_erased.begin(); e != node_erased.end(); e++) {
|
|
|
|
//Build a new Frag.
|
|
|
|
Frag fr;
|
|
|
|
float max_err = -1;
|
|
|
|
|
|
|
|
//Fill it with erased cells.
|
|
|
|
vector<unsigned int> &cells = (*e).second;
|
|
|
|
vector<unsigned int>::iterator k;
|
|
|
|
for(k = cells.begin(); k != cells.end(); k++) {
|
2004-10-14 15:42:33 +02:00
|
|
|
unsigned int cell = (*k);
|
|
|
|
assert(cell < index.size());
|
|
|
|
fr.push_back(cell);
|
|
|
|
if(index[cell].error > max_err)
|
|
|
|
max_err = index[cell].error;
|
|
|
|
}
|
2004-09-17 17:25:59 +02:00
|
|
|
//Add the new Frag to the node.
|
|
|
|
unsigned int floor_node = (*e).first;
|
|
|
|
Node &oldnode = nodes[floor_node];
|
|
|
|
oldnode.frags.push_back(fr);
|
|
|
|
if(node.error < max_err)
|
2004-10-14 15:42:33 +02:00
|
|
|
node.error = max_err;
|
2004-09-17 17:25:59 +02:00
|
|
|
|
|
|
|
//Update in and out of the nodes.
|
|
|
|
node.in.push_back(&oldnode);
|
|
|
|
oldnode.out.push_back(&node);
|
|
|
|
}
|
|
|
|
current_node++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NexusMt::ClearHistory() {
|
|
|
|
nodes.clear();
|
|
|
|
}
|
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
/*void NexusMt::ExtractFixed(vector<unsigned int> &selected, float error) {
|
2004-09-17 17:25:59 +02:00
|
|
|
std::vector<Node>::iterator n;
|
|
|
|
for(n = nodes.begin(); n != nodes.end(); n++)
|
|
|
|
(*n).visited = false;
|
|
|
|
|
|
|
|
std::queue<Node *> qnodo;
|
|
|
|
qnodo.push(&nodes[0]);
|
|
|
|
nodes[0].visited = true;
|
|
|
|
|
|
|
|
for( ; !qnodo.empty(); qnodo.pop()) {
|
|
|
|
Node &node = *qnodo.front();
|
|
|
|
|
|
|
|
std::vector<Frag>::iterator fragment;
|
|
|
|
std::vector<Node *>::iterator on;
|
|
|
|
for(on = node.out.begin(), fragment = node.frags.begin();
|
2004-10-14 15:42:33 +02:00
|
|
|
on != node.out.end(); ++on, ++fragment) {
|
2004-09-17 17:25:59 +02:00
|
|
|
|
|
|
|
if((*on)->visited) continue;
|
|
|
|
|
|
|
|
if(error < (*on)->error) { //need to expand this node.
|
2004-10-14 15:42:33 +02:00
|
|
|
qnodo.push(*on);
|
|
|
|
(*on)->visited = 1;
|
2004-09-17 17:25:59 +02:00
|
|
|
} else {
|
2004-10-14 15:42:33 +02:00
|
|
|
vector<unsigned int>::iterator cell;
|
|
|
|
for(cell=(*fragment).begin(); cell != (*fragment).end(); ++cell)
|
|
|
|
selected.push_back(*cell);
|
2004-09-17 17:25:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-10-14 15:42:33 +02:00
|
|
|
} */
|
2004-09-28 12:26:35 +02:00
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
void NexusMt::Extract(std::vector<unsigned int> &selected) {
|
|
|
|
std::vector<Node>::iterator n;
|
|
|
|
for(n = nodes.begin(); n != nodes.end(); n++) {
|
|
|
|
(*n).visited = false;
|
|
|
|
(*n).pushed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<TNode> heap;
|
|
|
|
Node *root = &nodes[0];
|
|
|
|
VisitNode(root, heap);
|
|
|
|
|
|
|
|
while(heap.size()) {
|
|
|
|
pop_heap(heap.begin(), heap.end());
|
|
|
|
TNode tnode = heap.back();
|
|
|
|
heap.pop_back();
|
|
|
|
|
|
|
|
Node *node = tnode.node;
|
|
|
|
if(node->visited) continue;
|
|
|
|
|
|
|
|
bool expand = policy.Expand(tnode);
|
|
|
|
|
|
|
|
if(expand)
|
|
|
|
VisitNode(node, heap);
|
|
|
|
}
|
|
|
|
Select(selected);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*void NexusMt::Extract(std::vector<unsigned int> &selected, Policy *policy) {
|
2004-09-28 12:26:35 +02:00
|
|
|
std::vector<Node>::iterator n;
|
|
|
|
for(n = nodes.begin(); n != nodes.end(); n++)
|
|
|
|
(*n).visited = false;
|
|
|
|
|
|
|
|
std::queue<Node *> qnodo;
|
|
|
|
qnodo.push(&nodes[0]);
|
|
|
|
nodes[0].visited = true;
|
|
|
|
|
|
|
|
for( ; !qnodo.empty(); qnodo.pop()) {
|
|
|
|
Node &node = *qnodo.front();
|
|
|
|
|
|
|
|
std::vector<Frag>::iterator i;
|
|
|
|
std::vector<Node *>::iterator on;
|
|
|
|
for(i = node.frags.begin(), on = node.out.begin();
|
2004-10-14 15:42:33 +02:00
|
|
|
i != node.frags.end(); i++, on++) {
|
2004-09-28 12:26:35 +02:00
|
|
|
if((*on)->visited) continue;
|
|
|
|
Frag &frag = (*i);
|
|
|
|
std::vector<unsigned int>::iterator cell;
|
|
|
|
for(cell = frag.begin(); cell != frag.end(); cell++) {
|
2004-10-14 15:42:33 +02:00
|
|
|
if(policy->Expand(*cell, index[*cell]))
|
|
|
|
policy->Visit(*on, qnodo);
|
2004-09-28 12:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Select(selected);
|
2004-10-14 15:42:33 +02:00
|
|
|
}*/
|
2004-09-28 12:26:35 +02:00
|
|
|
|
|
|
|
void NexusMt::Select(vector<unsigned int> &selected) {
|
|
|
|
selected.clear();
|
|
|
|
std::vector<Node>::iterator i;
|
|
|
|
for(i = nodes.begin(); i != nodes.end(); i++) {
|
|
|
|
Node &node = *i;
|
|
|
|
if(!node.visited)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
std::vector<Node *>::iterator n;
|
|
|
|
std::vector<Frag>::iterator f;
|
|
|
|
for(n = node.out.begin(), f = node.frags.begin();
|
2004-10-14 15:42:33 +02:00
|
|
|
n != node.out.end(); n++, f++) {
|
2004-09-28 12:26:35 +02:00
|
|
|
if(!(*n)->visited || (*n)->error == 0) {
|
2004-10-14 15:42:33 +02:00
|
|
|
vector<unsigned int>::iterator c;
|
|
|
|
Frag &frag = (*f);
|
|
|
|
for(c = frag.begin(); c != frag.end(); c++)
|
|
|
|
selected.push_back(*c);
|
2004-09-28 12:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-10-04 18:49:54 +02:00
|
|
|
|
2004-10-14 15:42:33 +02:00
|
|
|
void NexusMt::PushNode(Node *node, vector<TNode> &heap) {
|
|
|
|
if(node->pushed) return;
|
|
|
|
|
|
|
|
float error = metric->GetError(node);
|
|
|
|
heap.push_back(TNode(node, error));
|
|
|
|
push_heap(heap.begin(), heap.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void NexusMt::VisitNode(Node *node, vector<TNode> &heap) {
|
|
|
|
if(node->visited) return;
|
|
|
|
|
|
|
|
vector<Node *>::iterator i;
|
|
|
|
for(i = node->in.begin(); i != node->in.end(); i++)
|
|
|
|
VisitNode(*i, heap);
|
|
|
|
|
|
|
|
for(i = node->out.begin(); i != node->out.end(); i++)
|
|
|
|
PushNode(*i, heap);
|
|
|
|
|
|
|
|
node->visited = true;
|
|
|
|
policy.NodeVisited(node);
|
|
|
|
}
|