void reduce( long pruningThreshold ) { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) this.children[id].reduce( pruningThreshold ); if ( this.quantizeError <= pruningThreshold ) prune(); else { // Find minimum pruning threshold. if ( this.uniqueCount > 0 ) this.cube.numColors++; if ( this.quantizeError < this.cube.nextThreshold ) this.cube.nextThreshold = this.quantizeError; } }
void prune() { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) this.children[id].prune(); // Merge color statistics into parent. this.parent.uniqueCount += this.uniqueCount; this.parent.totalRed += this.totalRed; this.parent.totalGreen += this.totalGreen; this.parent.totalBlue += this.totalBlue; this.parent.totalAlpha += this.totalAlpha; this.parent.children[this.id] = null; this.parent.numChildren--; this.cube.numNodes--; }
void pruneLevel() { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) this.children[id].pruneLevel(); if ( this.level == this.cube.depth ) prune(); }
void pruneToCubeDepth() { // Traverse any children. if ( this.numChildren > 0 ) for ( int id = 0; id < MAX_CHILDREN; id++ ) if ( this.children[id] != null ) this.children[id].pruneToCubeDepth(); if ( this.level > this.cube.depth ) prune(); }