#include "bbstdGetIntervalNumberFromIntervalList.h" #include "bbstdPackage.h" namespace bbstd { BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,GetIntervalNumberFromIntervalList) BBTK_BLACK_BOX_IMPLEMENTATION(GetIntervalNumberFromIntervalList,bbtk::AtomicBlackBox); void GetIntervalNumberFromIntervalList::Process() { // Sets the default value, in the case of an inexisting value in the intervals. bbSetOutputIntervalNumber(bbGetInputErrorValue()); bool found = false; // Looks for the first interval containing the input value. for (int i = 0; i < (int) bbGetInputIntervalList().size() - 1; i++) { if (found == false) { if (bbGetInputValue() >= bbGetInputIntervalList()[i] && bbGetInputValue() < bbGetInputIntervalList()[i+1]) { bbSetOutputIntervalNumber(i); found = true; } } } } void GetIntervalNumberFromIntervalList::bbUserSetDefaultValues() { bbSetInputErrorValue(-1.0); } void GetIntervalNumberFromIntervalList::bbUserInitializeProcessing() { } void GetIntervalNumberFromIntervalList::bbUserFinalizeProcessing() { } } // EO namespace bbstd