#include #include SpacialTransform::~SpacialTransform() { } BOOL SpacialTransform::transform(Array &srcVector,Array &dstVector,WORD sizeFactor) { int inverseFactor((100.00/(float)sizeFactor)*100.00); int outSegment(inverseFactor); int inSegment(100); int nextDestIndex(0); int accumulator(0); mNextInputIndex=-1; dstVector.size((srcVector.size()*sizeFactor)/100.00); if(!nextInput(srcVector))return FALSE; while(TRUE) { if(outSegment<=inSegment) { accumulator+=((inSegment*mCurrentValue)+((100-inSegment)*mNextValue))*outSegment; inSegment-=outSegment; outSegment=inverseFactor; accumulator*=(float)sizeFactor*.000001; if(nextDestIndex>=dstVector.size())break; dstVector[nextDestIndex++]=accumulator; accumulator=0; } else { accumulator+=((inSegment*mCurrentValue)+((100-inSegment)*mNextValue))*inSegment; outSegment-=inSegment; inSegment=100; if(!nextInput(srcVector))break; } } return false; } BOOL SpacialTransform::nextInput(Array &srcVector) { if(++mNextInputIndex>=srcVector.size())return FALSE; mCurrentValue=srcVector[mNextInputIndex]; if(mNextInputIndex+1>=srcVector.size())mNextValue=mCurrentValue; else mNextValue=srcVector[mNextInputIndex+1]; return TRUE; }