Optimized BuildLevels.
This commit is contained in:
parent
5fb9d84548
commit
2f2053878b
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.5 2005/02/08 12:43:03 ponchio
|
||||||
|
Added copyright
|
||||||
|
|
||||||
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -325,7 +328,7 @@ bool History::UpdatesToQuick() {
|
||||||
return LoadPointers();
|
return LoadPointers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::BuildLevels(map<unsigned int, unsigned int> &levels) {
|
void History::BuildLevels(vector<int> &levels) {
|
||||||
levels.clear();
|
levels.clear();
|
||||||
if(buffer) {
|
if(buffer) {
|
||||||
//Saved in quick mode:
|
//Saved in quick mode:
|
||||||
|
|
@ -336,7 +339,8 @@ void History::BuildLevels(map<unsigned int, unsigned int> &levels) {
|
||||||
if(node != nodes) { //not root
|
if(node != nodes) { //not root
|
||||||
Link *inlink = node->in_begin();
|
Link *inlink = node->in_begin();
|
||||||
unsigned int p = inlink->begin()->patch;
|
unsigned int p = inlink->begin()->patch;
|
||||||
assert(levels.count(p));
|
assert(p < levels.size());
|
||||||
|
assert(p >= 0);
|
||||||
current = levels[p]+1;
|
current = levels[p]+1;
|
||||||
}
|
}
|
||||||
for(l = node->out_begin(); l != node->out_end(); l++) {
|
for(l = node->out_begin(); l != node->out_end(); l++) {
|
||||||
|
|
@ -344,12 +348,12 @@ void History::BuildLevels(map<unsigned int, unsigned int> &levels) {
|
||||||
Link::iterator c;
|
Link::iterator c;
|
||||||
for(c = link.begin(); c != link.end(); c++) {
|
for(c = link.begin(); c != link.end(); c++) {
|
||||||
unsigned int p = (*c).patch;
|
unsigned int p = (*c).patch;
|
||||||
|
while(p >= levels.size()) levels.push_back(-1);
|
||||||
levels[p] = current;
|
levels[p] = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cerr << "updates.size: " << updates.size() << endl;
|
|
||||||
//Saved in updates mode:
|
//Saved in updates mode:
|
||||||
for(unsigned int i = 0; i < updates.size(); i++) {
|
for(unsigned int i = 0; i < updates.size(); i++) {
|
||||||
Update &u = updates[i];
|
Update &u = updates[i];
|
||||||
|
|
@ -357,7 +361,9 @@ void History::BuildLevels(map<unsigned int, unsigned int> &levels) {
|
||||||
if(!u.erased.size()) current = 0;
|
if(!u.erased.size()) current = 0;
|
||||||
else current = levels[u.erased[0]] + 1;
|
else current = levels[u.erased[0]] + 1;
|
||||||
for(unsigned int i = 0; i < u.created.size(); i++) {
|
for(unsigned int i = 0; i < u.created.size(); i++) {
|
||||||
levels[u.created[i]] = current;
|
unsigned int p = u.created[i];
|
||||||
|
while(p >= levels.size()) levels.push_back(-1);
|
||||||
|
levels[p] = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.3 2005/02/08 12:43:03 ponchio
|
||||||
|
Added copyright
|
||||||
|
|
||||||
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -113,7 +116,7 @@ namespace nxs {
|
||||||
bool UpdatesToQuick();
|
bool UpdatesToQuick();
|
||||||
bool IsQuick() { return buffer != NULL; }
|
bool IsQuick() { return buffer != NULL; }
|
||||||
|
|
||||||
void BuildLevels(std::map<unsigned int, unsigned int> &levels);
|
void BuildLevels(std::vector<int> &levels);
|
||||||
|
|
||||||
int &quick() { return ((int *)buffer)[0]; }
|
int &quick() { return ((int *)buffer)[0]; }
|
||||||
int &n_nodes() { return ((int *)buffer)[1]; }
|
int &n_nodes() { return ((int *)buffer)[1]; }
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.17 2005/02/08 12:43:03 ponchio
|
||||||
|
Added copyright
|
||||||
|
|
||||||
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -81,7 +84,7 @@ void nxs::ComputeNormals(Nexus &nexus) {
|
||||||
tmpb.Flush();
|
tmpb.Flush();
|
||||||
|
|
||||||
|
|
||||||
map<unsigned int, unsigned int> levels;
|
vector<int> levels;
|
||||||
nexus.history.BuildLevels(levels);
|
nexus.history.BuildLevels(levels);
|
||||||
|
|
||||||
//first step normals in the same patch.
|
//first step normals in the same patch.
|
||||||
|
|
@ -90,7 +93,7 @@ void nxs::ComputeNormals(Nexus &nexus) {
|
||||||
vector<Point3f> normals;
|
vector<Point3f> normals;
|
||||||
|
|
||||||
for(unsigned int p = 0; p < nexus.size(); p++) {
|
for(unsigned int p = 0; p < nexus.size(); p++) {
|
||||||
unsigned int current_level = levels[p];
|
int current_level = levels[p];
|
||||||
report.Step(p);
|
report.Step(p);
|
||||||
Patch &patch = nexus.GetPatch(p);
|
Patch &patch = nexus.GetPatch(p);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue