www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 35181a4b2d16674530dcaf954bceeb32a3f5d8a9
parent 6b3bb44a4ae9881417ee191ff529a5069a2da90e
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Wed, 21 Dec 2011 18:18:51 +0100

Nettoyage de la sortie de debug.

Diffstat:
Mheap.cpp | 49++++++++++++++-----------------------------------
Mlod.cpp | 24++----------------------
Mrules/chose.cpp | 1-
Mtriangle.cpp | 8--------
Mtriangle.hh | 2--
5 files changed, 16 insertions(+), 68 deletions(-)

diff --git a/heap.cpp b/heap.cpp @@ -6,16 +6,14 @@ Heap::Heap() void Heap::setId(int id) { this->id = id; } void Heap::insert(int key, Chose* value) { - // std::cout << "INSERT " << (int)(value) << " into " << id << std::endl; - int _d_node = value->lod.heaps[id]; - if (_d_node <= lastNode && _d_node >= 0 && - buckets[getBucket(_d_node)][getIndex(_d_node)].value == value) { - std::cout << "ERROR ! Trying to insert " << (int)(value) - << " but it is already here " - << (int)(buckets[getBucket(_d_node)][getIndex(_d_node)].value) - << std::endl; + { // DEBUG + int _d_node = value->lod.heaps[id]; + if (_d_node <= lastNode && _d_node >= 0 && + buckets[getBucket(_d_node)][getIndex(_d_node)].value == value) { + std::cout << "ERROR ! Trying to insert " << (int)(value); + std::cout << " but it is already here." << std::endl; + } } - // std::cout << "ENTER insert" << std::endl; ++lastNode; if (getBucket(lastNode) > lastAllocatedBucket) { allocateBucket(); @@ -23,18 +21,19 @@ void Heap::insert(int key, Chose* value) { buckets[getBucket(lastNode)][getIndex(lastNode)].key = key; buckets[getBucket(lastNode)][getIndex(lastNode)].value = value; siftUp(lastNode); - // std::cout << "EXIT insert" << std::endl; } void handler(); int global = 0; void Heap::remove(Chose* value) { - // std::cout << "ENTER remove id=" << id << " " << (int)(value) << " " << value->lod.heaps[id] << "/" << lastNode << std::endl; int node = value->lod.heaps[id]; - if (buckets[getBucket(node)][getIndex(node)].value != value) { - std::cout << "ERROR ! Trying to remove " << (int)(value) - << " but found " << (int)(buckets[getBucket(node)][getIndex(node)].value) - << std::endl; + + { // DEBUG + if (buckets[getBucket(node)][getIndex(node)].value != value) { + std::cout << "ERROR ! Trying to remove " << (int)(value); + std::cout << " but found " << (int)(buckets[getBucket(node)][getIndex(node)].value); + std::cout << std::endl; + } } if (node == lastNode) { // On a supprimé le dernier noeud. @@ -42,7 +41,6 @@ void Heap::remove(Chose* value) { // + 1 pour garder au moins un bucket "en cache". if (getBucket(lastNode) + 1 < lastAllocatedBucket) freeBucket(); - std::cout << "Remove exit A"; return; } @@ -57,29 +55,14 @@ void Heap::remove(Chose* value) { } siftDown(node); - std::cout << "Remove exit B"; } Chose* Heap::popIfLessThan(int key) { - std::cout << "Enter Pop " << id << " lastNode=" << lastNode; - for (int i = 0; i <= lastNode; i++) - std::cout << " " - << (int)(buckets[getBucket(i)][getIndex(i)].key) << "_" - << (int)(buckets[getBucket(i)][getIndex(i)].value); - std::cout << std::endl; if (lastNode >= 0 && buckets[0][0].key < key) { Chose* ret = buckets[0][0].value; - std::cout << "Pop " << ret->lod.heaps[id] << std::endl; remove(ret); - std::cout << "Exit A Pop " << id << " lastNode=" << lastNode << " return=" << (int)(ret); - for (int i = 0; i <= lastNode; i++) - std::cout << " " - << (int)(buckets[getBucket(i)][getIndex(i)].key) << "_" - << (int)(buckets[getBucket(i)][getIndex(i)].value); - std::cout << std::endl; return ret; } - std::cout << "Exit B Pop " << id << " lastNode=" << lastNode << std::endl; return NULL; } @@ -100,13 +83,11 @@ void Heap::siftUp(int node) { // mettre à jour le champ lod.heaps[id] de l'ancien parent qu'on // vient de descendre. n->value->lod.heaps[id] = node; - // std::cout << "SET " << (int)(n->value) << " id=" << id << " to " << node << std::endl; node = p; } // après les break; qui sortent de la boucle, on a déjà actualisé // le pointeur `n` vers buckets[getBucket(node)][getIndex(node)]. n->value->lod.heaps[id] = node; - // std::cout << "SET " << (int)(n->value) << " id=" << id << " to " << node << std::endl; } void Heap::siftDown(int node) { @@ -136,13 +117,11 @@ void Heap::siftDown(int node) { // mettre à jour le champ lod.heaps[id] de l'ancien fils qu'on // vient de remonter. n->value->lod.heaps[id] = node; - // std::cout << "SET " << (int)(n->value) << " id=" << id << " to " << node << std::endl; node = (exchRight ? rc : lc); } // après les break; qui sortent de la boucle, on a déjà actualisé // le pointeur `n` vers buckets[getBucket(node)][getIndex(node)]. n->value->lod.heaps[id] = node; - // std::cout << "SET " << (int)(n->value) << " id=" << id << " to " << node << std::endl; } void Heap::allocateBucket() { diff --git a/lod.cpp b/lod.cpp @@ -20,10 +20,8 @@ void Lod::setCamera(Vertex newCamera) { Chose* c; int pos = NegateEven(camera[i>>1], i); while((c = merge[i].popIfLessThan(pos))) { - std::cout << "=== mer Pop " << (int)(c) << " from merge " << i << std::endl; for(int j = 0; j < 6; j++) { if(i == j) continue; - std::cout << "=== mer Remove " << (int)(c) << " from merge " << j << std::endl; merge[j].remove(c); // TODO } @@ -34,21 +32,15 @@ void Lod::setCamera(Vertex newCamera) { Chose* c; int pos = NegateOdd(camera[i>>1], i); while((c = split[2*i+1].popIfLessThan(pos))) { - std::cout << "=== soi Pop " << (int)(c) << " from split " << 2*i+1 << std::endl; - for (int a = 0; a < 18; a++) std::cout << (c->lod.heaps[a]) << " "; - std::cout << std::endl; if(c->inCounter == 5) { for(int j = 0; j < 6; j++) { if(i == j) continue; - std::cout << "=== soi1 Remove " << (int)(c)<<" from split "<< 2*j<<std::endl; split[2*j].remove(c); } - std::cout << "CALL doSplit FROM soi" << std::endl; doSplit(c); } else { c->inCounter++; - std::cout << "=== soi2 Insert " << (int)(c) << " into split " << 2*i << std::endl; split[2*i].insert(c->splitCube[i], c); } } @@ -59,16 +51,13 @@ void Lod::setCamera(Vertex newCamera) { Chose* c; int pos = NegateEven(camera[i>>1], i); while((c = split[2*i].popIfLessThan(pos))) { - std::cout << "=== sio Pop " << (int)(c) << " from split " << 2*i << std::endl; c->inCounter--; - std::cout << "=== sio Insert " << (int)(c) << " into split " << 2*i+1 << std::endl; split[2*i+1].insert(c->splitCube[i], c); } } } void Lod::doSplit(Chose* c) { - std::cout << "doSplit " << (int)(c) << std::endl; // TODO c->split(); std::vector<Chose*>::iterator it; @@ -77,37 +66,28 @@ void Lod::doSplit(Chose* c) { (*it)->updateAABB(); addSplitCube((*it)); } - std::cout << "END doSplit" << std::endl; } void Lod::addMergeCube(Chose* chose) { - for(int i = 0; i < 5; i++) { - std::cout << "+++ mer Insert " << (int)(chose) << " into merge " << i << std::endl; + for(int i = 0; i < 5; i++) merge[i].insert(NegateEven(chose->lod.mergeCube[i], i), chose); - } } void Lod::addSplitCube(Chose* chose) { - std::cout << "addSplitCube " << (int)chose << std::endl; chose->inCounter = 0; for(int i = 0; i < 6; i++) { if(NegateEven(chose->lod.splitCube[i] - camera[i>>1], i) >= 0) { chose->inCounter++; - std::cout << "+++ spl1 Insert " << (int)(chose) << " into split " << 2*i << std::endl; split[2*i].insert(NegateEven(chose->lod.splitCube[i],i), chose); - } - else { - std::cout << "+++ spl2 Insert " << (int)(chose) << " into split " << 2*i+1<<std::endl; + } else { split[2*i+1].insert(NegateOdd(chose->lod.splitCube[i],i), chose); } } // TODO : si chose->inCounter == 6, il faut le split immédiatement. if (chose->inCounter == 6) { for(int i = 0; i < 6; i++) { - std::cout << "+++ spl3 Remove " << (int)(chose) << " from split " << 2*i << std::endl; split[2*i].remove(chose); } - std::cout << "CALL doSplit FROM addSplitCube" << std::endl; doSplit(chose); } } diff --git a/rules/chose.cpp b/rules/chose.cpp @@ -1,7 +1,6 @@ #include "all_includes.hh" Chose::Chose() : seed(initialSeed), children() { - std::cout << "NEW CHOSE " << (int)(this) << std::endl; } void Chose::addChild(Chose* c) { diff --git a/triangle.cpp b/triangle.cpp @@ -13,14 +13,6 @@ Triangle::Triangle(Vertex v1, Vertex v2, Vertex v3, unsigned char r, unsigned ch : v1(v1), v2(v2), v3(v3), r(r), g(g), b(b), vnormal(normal(v1,v2,v3)) { } -std::ostream& operator<<(std::ostream& os, const Triangle* t) { - return os << *t; -} - -std::ostream& operator<<(std::ostream& os, const Triangle& t) { - return os << "Triangle " << t.v1 << "--" << t.v2 << "--" << t.v3 << "-- cycle"; -} - Vertex Triangle::normal(Vertex v1, Vertex v2, Vertex v3) { Vertex normal = (v1 - v2)*(v2 - v3); return normal / normal.norm(); diff --git a/triangle.hh b/triangle.hh @@ -14,8 +14,6 @@ class Triangle { Vertex vnormal; public : - friend std::ostream& operator<<(std::ostream& os, const Triangle* t); - friend std::ostream& operator<<(std::ostream& os, const Triangle& t); Triangle(); Triangle(Vertex v1, Vertex v2, Vertex v3); Triangle(Vertex v1, Vertex v2, Vertex v3, unsigned char r, unsigned char g, unsigned char b);