From d9626d720ed5ed57ab33e0c4d07b341a112586e1 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Tue, 1 Jul 2014 10:28:29 +0000 Subject: [PATCH] Harmless clang warnings --- .../edit_quality/common/transferfunction.cpp | 689 +++++++++--------- 1 file changed, 346 insertions(+), 343 deletions(-) diff --git a/src/meshlabplugins/edit_quality/common/transferfunction.cpp b/src/meshlabplugins/edit_quality/common/transferfunction.cpp index 4ac85dca0..96de83ff5 100644 --- a/src/meshlabplugins/edit_quality/common/transferfunction.cpp +++ b/src/meshlabplugins/edit_quality/common/transferfunction.cpp @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * @@ -57,31 +57,31 @@ bool TfKeyPCompare(TF_KEY*k1, TF_KEY*k2) TfChannel::TfChannel() { #ifdef NOW_TESTING - this->testInitChannel(); + this->testInitChannel(); #endif } TfChannel::TfChannel(TF_CHANNELS type) : _type(type) { #ifdef NOW_TESTING - this->testInitChannel(); + this->testInitChannel(); #endif } TfChannel::~TfChannel(void) { - //destroying TF_KEYs - KEY_LISTiterator it; - TF_KEY *k = 0; - for (it=KEYS.begin(); it!=KEYS.end(); it++) - { - k = *it; - delete k; - k = 0; - } + //destroying TF_KEYs + KEY_LISTiterator it; + TF_KEY *k = 0; + for (it=KEYS.begin(); it!=KEYS.end(); it++) + { + k = *it; + delete k; + k = 0; + } - //resetting keys list - KEYS.clear(); + //resetting keys list + KEYS.clear(); } //sets the type of the channel (channel code, defined using a TF_CHANNELS list member) @@ -96,58 +96,58 @@ TF_CHANNELS TfChannel::getType() //returns a pointer to the key just added TF_KEY* TfChannel::addKey(float xVal, float yVal) { - assert(xVal>=0.0f); - assert(yVal>=0.0f); - return this->addKey(new TF_KEY(xVal, yVal)); + assert(xVal>=0.0f); + assert(yVal>=0.0f); + return this->addKey(new TF_KEY(xVal, yVal)); } //adds to the keys list a new keys with fields passed to the method //returns a pointer to the key just added TF_KEY* TfChannel::addKey(TF_KEY *newKey) { - assert(newKey->x>=0); - assert(newKey->y>=0); - //inserting the key in the correct position - //x value order is kept - for (KEY_LISTiterator it=KEYS.begin(); it!=KEYS.end(); it++) - { - if ( (*it)->x >= newKey->x ) - { - KEYS.insert(it, newKey); - return newKey; - } - } + assert(newKey->x>=0); + assert(newKey->y>=0); + //inserting the key in the correct position + //x value order is kept + for (KEY_LISTiterator it=KEYS.begin(); it!=KEYS.end(); it++) + { + if ( (*it)->x >= newKey->x ) + { + KEYS.insert(it, newKey); + return newKey; + } + } - //greatest x ever - //adding new key at the end of the list - KEYS.push_back(newKey); - return newKey; + //greatest x ever + //adding new key at the end of the list + KEYS.push_back(newKey); + return newKey; } //removes from keys list the key at index keyIdx void TfChannel::removeKey(int keyIdx) { - KEY_LISTiterator it = KEYS.begin(); - if ((keyIdx >= 0) && (keyIdx<(int)KEYS.size())) - { - it += (keyIdx * TF_KEYsize); - delete *it; - KEYS.erase(it); - } + KEY_LISTiterator it = KEYS.begin(); + if ((keyIdx >= 0) && (keyIdx<(int)KEYS.size())) + { + it += (keyIdx * TF_KEYsize); + delete *it; + KEYS.erase(it); + } } //removes from keys list the key pointer is toRemoveKey void TfChannel::removeKey(TF_KEY *toRemoveKey) { - //searching key in the list... - for (KEY_LISTiterator it=KEYS.begin(); it!=KEYS.end(); it++) - if ( (*it) == toRemoveKey ) - { - //found it. Deleting - delete *it; - KEYS.erase(it); - break; - } + //searching key in the list... + for (KEY_LISTiterator it=KEYS.begin(); it!=KEYS.end(); it++) + if ( (*it) == toRemoveKey ) + { + //found it. Deleting + delete *it; + KEYS.erase(it); + break; + } } //returns the value (as float) of the transfer function for a certain channel in a given point (xVal) @@ -155,41 +155,43 @@ void TfChannel::removeKey(TF_KEY *toRemoveKey) //else linear interpolation is effected and the resulting value is returned float TfChannel::getChannelValuef(float xVal) { - float result = 0.0f; + float result = 0.0f; - //if a x_position is known x, its key value is returned immediately - for (KEY_LISTiterator it=KEYS.begin(); it!=KEYS.end(); it++) - if ( (*it)->x >= xVal ) - if ( (*it)->x == xVal ) - return (*it)->y; - else - { - //xVal is not the x of a key... - //the returning value will be obtained through linear interpolation between closest x-value keys in the list + //if a x_position is known x, its key value is returned immediately + for (KEY_LISTiterator it=KEYS.begin(); it!=KEYS.end(); it++) + if ( (*it)->x >= xVal ) + { + if ( (*it)->x == xVal ) + return (*it)->y; + else + { + //xVal is not the x of a key... + //the returning value will be obtained through linear interpolation between closest x-value keys in the list - //acquiring position of right key - float x2 = (*it)->x; - float y2 = (*it)->y; - it--; + //acquiring position of right key + float x2 = (*it)->x; + float y2 = (*it)->y; + it--; - //acquiring position of left key - float x1 = (*it)->x; - float y1 = (*it)->y; + //acquiring position of left key + float x1 = (*it)->x; + float y1 = (*it)->y; - if (( x1 < xVal ) && ( x2 > xVal) ) - { - //applying linear interpolation between two keys values + if (( x1 < xVal ) && ( x2 > xVal) ) + { + //applying linear interpolation between two keys values - //angular coefficient for interpolating line - float m = (y2-y1) / (x2-x1); + //angular coefficient for interpolating line + float m = (y2-y1) / (x2-x1); - //returning f(x) value for x in the interpolating line - result = m * (xVal - x1) + y1; - } - break; - } + //returning f(x) value for x in the interpolating line + result = m * (xVal - x1) + y1; + } + break; + } + } - return result; + return result; } //returns the value (as unsigned char) of the transfer function for a certain channel in a given point (xVal) @@ -201,15 +203,15 @@ UINT8 TfChannel::getChannelValueb(float xVal) //returns true if the key has x=0.0 bool TfChannel::isHead(TF_KEY *key) { - assert(key!=0); - return ( key->x == 0.0f ); + assert(key!=0); + return ( key->x == 0.0f ); } //returns true if the key has x=1.0 bool TfChannel::isTail(TF_KEY *key) { - assert(key!=0); - return ( key->x == 1.0f ); + assert(key!=0); + return ( key->x == 1.0f ); } //this method is called by TFHandle and is used to update the TfHandle position from graphics to logical level. @@ -220,21 +222,21 @@ void TfChannel::updateKeysOrder() //operator redefinition. Returns the key in the key list whose x-value equals xVal TF_KEY* TfChannel::operator [](float xVal) { - //looking in the list for the key with the proper x - for (KEY_LISTiterator it=KEYS.begin(); it!=KEYS.end(); it++) - if ( (*it)->x == xVal ) - return (*it); + //looking in the list for the key with the proper x + for (KEY_LISTiterator it=KEYS.begin(); it!=KEYS.end(); it++) + if ( (*it)->x == xVal ) + return (*it); - return 0; + return 0; } //operator redefinition. Returns the key in the key list whose index equals i TF_KEY* TfChannel::operator [](int i) { - if ((i >= 0) && (i<(int)KEYS.size())) - return KEYS[i]; + if ((i >= 0) && (i<(int)KEYS.size())) + return KEYS[i]; - return 0; + return 0; } //CODE USED FOR TESTING (define NOW_TESTING macro to use it) @@ -242,26 +244,26 @@ TF_KEY* TfChannel::operator [](int i) //addes random key to channel void TfChannel::testInitChannel() { - int num_of_keys = (rand() % 10) + 1; - float rand_x = 0.0f; - float rand_y = 0.0f; - float offset = 0.0f; + int num_of_keys = (rand() % 10) + 1; + float rand_x = 0.0f; + float rand_y = 0.0f; + float offset = 0.0f; - //first node\key = 0 - this->addKey(0.0f, 0.0f, 0.0f); - for (int i=0; i (1.0f-rand_y)) - offset = (1.0f-rand_y); - this->addKey(rand_x, - rand_y, - rand_y + offset); - } + //first node\key = 0 + this->addKey(0.0f, 0.0f, 0.0f); + for (int i=0; i (1.0f-rand_y)) + offset = (1.0f-rand_y); + this->addKey(rand_x, + rand_y, + rand_y + offset); + } - this->addKey(1.0f, 0.0f, 0.0f); + this->addKey(1.0f, 0.0f, 0.0f); } #endif @@ -279,165 +281,165 @@ QString TransferFunction::defaultTFs[NUMBER_OF_DEFAULT_TF]; TransferFunction::TransferFunction(void) { - this->initTF(); + this->initTF(); } //this overloaded constructor configures the Transfer Function object according to the transfer function code passed to it //(the code passed must be an item of the DEFAULT_TRANSFER_FUNCTIONS values list) TransferFunction::TransferFunction(DEFAULT_TRANSFER_FUNCTIONS code) { - this->initTF(); + this->initTF(); - switch(code) - { - case GREY_SCALE_TF: - _channels[RED_CHANNEL].addKey(0.0f,0.0f); - _channels[RED_CHANNEL].addKey(1.0f,1.0f); - _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(1.0f,1.0f); - _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(1.0f,1.0f); - break; - case MESHLAB_RGB_TF: - _channels[RED_CHANNEL].addKey(0.0f,0.0f); - _channels[RED_CHANNEL].addKey(0.125f,0.0f); - _channels[RED_CHANNEL].addKey(0.375f,0.0f); - _channels[RED_CHANNEL].addKey(0.625f,1.0f); - _channels[RED_CHANNEL].addKey(0.875f,1.0f); - _channels[RED_CHANNEL].addKey(1.0f,0.5f); + switch(code) + { + case GREY_SCALE_TF: + _channels[RED_CHANNEL].addKey(0.0f,0.0f); + _channels[RED_CHANNEL].addKey(1.0f,1.0f); + _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(1.0f,1.0f); + _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(1.0f,1.0f); + break; + case MESHLAB_RGB_TF: + _channels[RED_CHANNEL].addKey(0.0f,0.0f); + _channels[RED_CHANNEL].addKey(0.125f,0.0f); + _channels[RED_CHANNEL].addKey(0.375f,0.0f); + _channels[RED_CHANNEL].addKey(0.625f,1.0f); + _channels[RED_CHANNEL].addKey(0.875f,1.0f); + _channels[RED_CHANNEL].addKey(1.0f,0.5f); - _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(0.125f,0.0f); - _channels[GREEN_CHANNEL].addKey(0.375f,1.0f); - _channels[GREEN_CHANNEL].addKey(0.625f,1.0f); - _channels[GREEN_CHANNEL].addKey(0.875f,0.0f); - _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(0.125f,0.0f); + _channels[GREEN_CHANNEL].addKey(0.375f,1.0f); + _channels[GREEN_CHANNEL].addKey(0.625f,1.0f); + _channels[GREEN_CHANNEL].addKey(0.875f,0.0f); + _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(0.0f,0.5f); - _channels[BLUE_CHANNEL].addKey(0.125f,1.0f); - _channels[BLUE_CHANNEL].addKey(0.375f,1.0f); - _channels[BLUE_CHANNEL].addKey(0.625f,0.0f); - _channels[BLUE_CHANNEL].addKey(0.875f,0.0f); - _channels[BLUE_CHANNEL].addKey(1.0f,0.0f); - break; - case RGB_TF: - _channels[RED_CHANNEL].addKey(0.0f,1.0f); - _channels[RED_CHANNEL].addKey(0.5f,0.0f); - _channels[RED_CHANNEL].addKey(1.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(0.5f,1.0f); - _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(0.5f,0.0f); - _channels[BLUE_CHANNEL].addKey(1.0f,1.0f); - break; - case FRENCH_RGB_TF: - _channels[RED_CHANNEL].addKey(0.0f,1.0f); - _channels[RED_CHANNEL].addKey(0.5f,1.0f); - _channels[RED_CHANNEL].addKey(1.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(0.0f,0.5f); + _channels[BLUE_CHANNEL].addKey(0.125f,1.0f); + _channels[BLUE_CHANNEL].addKey(0.375f,1.0f); + _channels[BLUE_CHANNEL].addKey(0.625f,0.0f); + _channels[BLUE_CHANNEL].addKey(0.875f,0.0f); + _channels[BLUE_CHANNEL].addKey(1.0f,0.0f); + break; + case RGB_TF: + _channels[RED_CHANNEL].addKey(0.0f,1.0f); + _channels[RED_CHANNEL].addKey(0.5f,0.0f); + _channels[RED_CHANNEL].addKey(1.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(0.5f,1.0f); + _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(0.5f,0.0f); + _channels[BLUE_CHANNEL].addKey(1.0f,1.0f); + break; + case FRENCH_RGB_TF: + _channels[RED_CHANNEL].addKey(0.0f,1.0f); + _channels[RED_CHANNEL].addKey(0.5f,1.0f); + _channels[RED_CHANNEL].addKey(1.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(0.5f,1.0f); - _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(0.5f,1.0f); + _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(0.5f,1.0f); - _channels[BLUE_CHANNEL].addKey(1.0f,1.0f); - break; + _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(0.5f,1.0f); + _channels[BLUE_CHANNEL].addKey(1.0f,1.0f); + break; - case RED_SCALE_TF: - _channels[RED_CHANNEL].addKey(0.0f,0.0f); - _channels[RED_CHANNEL].addKey(1.0f,1.0f); - _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(1.0f,0.0f); - break; - case GREEN_SCALE_TF: - _channels[RED_CHANNEL].addKey(0.0f,0.0f); - _channels[RED_CHANNEL].addKey(1.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(1.0f,1.0f); - _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(1.0f,0.0f); - break; - case BLUE_SCALE_TF: - _channels[RED_CHANNEL].addKey(0.0f,0.0f); - _channels[RED_CHANNEL].addKey(1.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); - _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); - _channels[BLUE_CHANNEL].addKey(1.0f,1.0f); - break; - case FLAT_TF: - default: - _channels[RED_CHANNEL].addKey(0.0f,0.5f); - _channels[RED_CHANNEL].addKey(1.0f,0.5f); - _channels[GREEN_CHANNEL].addKey(0.0f,0.5f); - _channels[GREEN_CHANNEL].addKey(1.0f,0.5f); - _channels[BLUE_CHANNEL].addKey(0.0f,0.5f); - _channels[BLUE_CHANNEL].addKey(1.0f,0.5f); - break; - case SAW_4_TF: - for(int i=0;i<4;++i) - { - _channels[RED_CHANNEL].addKey(0.25f*i, 0.0f); - _channels[RED_CHANNEL].addKey(0.25f*(i+1)-0.0001,1.0f); - _channels[GREEN_CHANNEL].addKey(0.25f*i, 0.0f); - _channels[GREEN_CHANNEL].addKey(0.25f*(i+1)-0.0001,1.0f); - _channels[BLUE_CHANNEL].addKey(0.25f*i, 0.0f); - _channels[BLUE_CHANNEL].addKey(0.25f*(i+1)-0.0001,1.0f); - } break; - case SAW_8_TF: - for(int i=0;i<8;++i) - { - _channels[RED_CHANNEL].addKey(0.125f*i, 0.0f); - _channels[RED_CHANNEL].addKey(0.125f*(i+1)-0.0001,1.0f); - _channels[GREEN_CHANNEL].addKey(0.125f*i, 0.0f); - _channels[GREEN_CHANNEL].addKey(0.125f*(i+1)-0.0001,1.0f); - _channels[BLUE_CHANNEL].addKey(0.125f*i, 0.0f); - _channels[BLUE_CHANNEL].addKey(0.125f*(i+1)-0.0001,1.0f); - } break; - } + case RED_SCALE_TF: + _channels[RED_CHANNEL].addKey(0.0f,0.0f); + _channels[RED_CHANNEL].addKey(1.0f,1.0f); + _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(1.0f,0.0f); + break; + case GREEN_SCALE_TF: + _channels[RED_CHANNEL].addKey(0.0f,0.0f); + _channels[RED_CHANNEL].addKey(1.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(1.0f,1.0f); + _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(1.0f,0.0f); + break; + case BLUE_SCALE_TF: + _channels[RED_CHANNEL].addKey(0.0f,0.0f); + _channels[RED_CHANNEL].addKey(1.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(0.0f,0.0f); + _channels[GREEN_CHANNEL].addKey(1.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(0.0f,0.0f); + _channels[BLUE_CHANNEL].addKey(1.0f,1.0f); + break; + case FLAT_TF: + default: + _channels[RED_CHANNEL].addKey(0.0f,0.5f); + _channels[RED_CHANNEL].addKey(1.0f,0.5f); + _channels[GREEN_CHANNEL].addKey(0.0f,0.5f); + _channels[GREEN_CHANNEL].addKey(1.0f,0.5f); + _channels[BLUE_CHANNEL].addKey(0.0f,0.5f); + _channels[BLUE_CHANNEL].addKey(1.0f,0.5f); + break; + case SAW_4_TF: + for(int i=0;i<4;++i) + { + _channels[RED_CHANNEL].addKey(0.25f*i, 0.0f); + _channels[RED_CHANNEL].addKey(0.25f*(i+1)-0.0001,1.0f); + _channels[GREEN_CHANNEL].addKey(0.25f*i, 0.0f); + _channels[GREEN_CHANNEL].addKey(0.25f*(i+1)-0.0001,1.0f); + _channels[BLUE_CHANNEL].addKey(0.25f*i, 0.0f); + _channels[BLUE_CHANNEL].addKey(0.25f*(i+1)-0.0001,1.0f); + } break; + case SAW_8_TF: + for(int i=0;i<8;++i) + { + _channels[RED_CHANNEL].addKey(0.125f*i, 0.0f); + _channels[RED_CHANNEL].addKey(0.125f*(i+1)-0.0001,1.0f); + _channels[GREEN_CHANNEL].addKey(0.125f*i, 0.0f); + _channels[GREEN_CHANNEL].addKey(0.125f*(i+1)-0.0001,1.0f); + _channels[BLUE_CHANNEL].addKey(0.125f*i, 0.0f); + _channels[BLUE_CHANNEL].addKey(0.125f*(i+1)-0.0001,1.0f); + } break; + } } //this overloaded constructor configures the Transfer Function using the info present in an external CSV file TransferFunction::TransferFunction(QString fileName) { - this->initTF(); + this->initTF(); - QFile inFile( fileName ); + QFile inFile( fileName ); - if ( !inFile.open(QIODevice::ReadOnly | QIODevice::Text)) - return; + if ( !inFile.open(QIODevice::ReadOnly | QIODevice::Text)) + return; - QTextStream inStream( &inFile ); - QString line; - QStringList splittedString; + QTextStream inStream( &inFile ); + QString line; + QStringList splittedString; - //each not-commented line of the file represent the values to build-up a channel - int channel_code = 0; - do - { - line = inStream.readLine(); + //each not-commented line of the file represent the values to build-up a channel + int channel_code = 0; + do + { + line = inStream.readLine(); - //if a line is a comment, it's not processed. imply ignoring it! - if ( !line.startsWith(CSV_FILE_COMMENT) ) - { - //a channel line found. Splitting it to find the values - splittedString = line.split(CSV_FILE_SEPARATOR, QString::SkipEmptyParts); - assert( (splittedString.size() % 2) == 0 ); + //if a line is a comment, it's not processed. imply ignoring it! + if ( !line.startsWith(CSV_FILE_COMMENT) ) + { + //a channel line found. Splitting it to find the values + splittedString = line.split(CSV_FILE_SEPARATOR, QString::SkipEmptyParts); + assert( (splittedString.size() % 2) == 0 ); - //for each couple of values a key is built and added to the current channel - for ( int i=0; i result ) - result = _channels[i].size(); + int result = 0; + for (int i=0; i result ) + result = _channels[i].size(); - return result; + return result; } //Builds the color band by setting the proper color for each item //returns a pointer to the color band built QColor* TransferFunction::buildColorBand() { - float relative_pos = 0.0f; - for (int i=0; i maxQuality) - percentageQuality = 1.0f; - else - // calcultating relative quality and applying exponential function: rel(Q)^exp, exp=2*midHandleRelPos - percentageQuality = pow( (absoluteQuality - minQuality) / (maxQuality - minQuality) , (float)(2.0f*midRelativeQuality)); + if (absoluteQuality < minQuality) + percentageQuality = 0.0f; + else + if (absoluteQuality > maxQuality) + percentageQuality = 1.0f; + else + // calcultating relative quality and applying exponential function: rel(Q)^exp, exp=2*midHandleRelPos + percentageQuality = pow( (absoluteQuality - minQuality) / (maxQuality - minQuality) , (float)(2.0f*midRelativeQuality)); - currentColor = getColorByQuality(percentageQuality); - - if (brightness!=1.0f) //Applying brightness to each color channel, 0x << CSV_FILE_SEPARATOR << val->y << CSV_FILE_SEPARATOR; - } - //one channel-per-row - outStream << endl; - } + TF_KEY *val = 0; + //for each channel... + for ( int i=0; ix << CSV_FILE_SEPARATOR << val->y << CSV_FILE_SEPARATOR; + } + //one channel-per-row + outStream << endl; + } - //saving equalizer info too (only one line is needed) - outStream << CSV_FILE_COMMENT << "THE FOLLOWING 4 VALUES REPRESENT EQUALIZER SETTINGS - the first and the third values represent respectively the minimum and the maximum quality values used in histogram, the second one represent the position (in percentage) of the middle quality, and the last one represent the level of brightness as a floating point number (0 copletely dark, 1 original brightness, 2 completely white)" << endl; - outStream << info.minQualityVal << CSV_FILE_SEPARATOR << info.midQualityPercentage << CSV_FILE_SEPARATOR << info.maxQualityVal << CSV_FILE_SEPARATOR << info.brightness << CSV_FILE_SEPARATOR << endl; + //saving equalizer info too (only one line is needed) + outStream << CSV_FILE_COMMENT << "THE FOLLOWING 4 VALUES REPRESENT EQUALIZER SETTINGS - the first and the third values represent respectively the minimum and the maximum quality values used in histogram, the second one represent the position (in percentage) of the middle quality, and the last one represent the level of brightness as a floating point number (0 copletely dark, 1 original brightness, 2 completely white)" << endl; + outStream << info.minQualityVal << CSV_FILE_SEPARATOR << info.midQualityPercentage << CSV_FILE_SEPARATOR << info.maxQualityVal << CSV_FILE_SEPARATOR << info.brightness << CSV_FILE_SEPARATOR << endl; - outFile.close(); + outFile.close(); - return fileName; + return fileName; } //"moving" the channel identified by ch_code to first plane. //This operation simply implies the circular shift of the channel_order pivot indexes untill the selected channel code is in the last position of the array void TransferFunction::moveChannelAhead(TF_CHANNELS ch_code) { - int ch_code_int = (int)ch_code; - assert( (ch_code_int>=0) && (ch_code_int=0) && (ch_code_int=1; i--) - //_channels_order[i] = _channels_order[i-1] % (NUMBER_OF_CHANNELS -1); - _channels_order[i] = _channels_order[i-1]; + int tmp = 0; + do + { + tmp = _channels_order[NUMBER_OF_CHANNELS-1]; + for (int i=NUMBER_OF_CHANNELS-1; i>=1; i--) + //_channels_order[i] = _channels_order[i-1] % (NUMBER_OF_CHANNELS -1); + _channels_order[i] = _channels_order[i-1]; - _channels_order[0] = tmp; - } while( _channels_order[NUMBER_OF_CHANNELS-1] != ch_code_int ); + _channels_order[0] = tmp; + } while( _channels_order[NUMBER_OF_CHANNELS-1] != ch_code_int ); }