void LineString::setPoints(QList<Point*> points) { removePoints(); for (int i=0; i<points.size(); i++) { points.at(i)->setParentGeometry(this); } childPoints = points; }
/********************************************//** \brief Compute Inverse Fast Wavelet Transform (iFWT) on 1D array \param array : input array (1D) \param filter : name of the filter to use (from TransformationType enum) \param origLength : original length of the array so the result is cut at this length \param result : resulting transformed array \param stop : flag indicating if we need to stop the process or not \return boolean true if the execution is finished, false if the process has been stopped during the execution ***********************************************/ bool FWT::iFastWaveletTransf(const std::vector<float>& array, const TransformationType filter, const int origLength, std::vector<float>& result, bool* stop) { // Get filters std::deque<float> h, g; compute_wavelet_filters(filter, h, g); // Reverse filters std::deque<float> hRev = h; std::reverse(hRev.begin(), hRev.end()); std::deque<float> gRev = g; std::reverse(gRev.begin(), gRev.end()); std::vector<float> inv(array.begin(), array.end()); // iFWT int Jmax = log2((float)inv.size()) - 1; int Jmin = 0; for(int j = Jmin; j <= Jmax; ++j) { if(*stop) { return false; } std::vector<float> Coarse(&inv[0], &inv[pow(2., j)]); std::vector<float> Detail(&inv[pow(2., j)], &inv[pow(2.,j+1)]); // Get Coarse and Detail Coarse = cconv(upsampling(Coarse), hRev); Detail = cconv(upsampling(Detail), gRev); for(int k = 0; k < pow(2., j+1); ++k) { if(*stop) { return false; } inv[k] = Coarse[k] + Detail[k]; } } // Remove points so result is origLength length int N = pow(2, ceil(log2((float)origLength))) - origLength; removePoints(inv, N); result = inv; return true; }
LineString::~LineString() { removePoints(); }
/********************************************//** \brief Biorthogonal wavelet transformation \param array : input array (1D) \param filter : name of the filter to use (from TransformationType enum) \param dir : direction (1:forward, -1:backward) \param origLength : original Length useful when dir is -1 to cut result \return result of lifting step \param stop : flag indicating if we need to stop the process or not \param Jmin : minimum step \return boolean true if the execution is finished, false if the process has been stopped during the execution ***********************************************/ bool FWT::perform_wavelet_transform(const std::vector<float>& array, const TransformationType filter, const int dir, const int origLength, std::vector<float>& result, bool* stop, const int Jmin) { std::vector<float> data = array;//(array.begin(), array.end()); std::vector<float> res; // Get filters std::deque<float> h, g; compute_wavelet_filters(filter, h, g); // Make sure input is dyadic makeDyadic(data); // Number of lifting steps int n = data.size(); int m = (h.size() - 1) / 2; int Jmax = log2((float)n) - 1; switch(dir) { case 1 : // Forward { for(int j = Jmax; j >= Jmin; j--) { res.clear(); std::vector<float> x(&data[0], &data[pow(2., j+1)]); ; if(!forward_lifting_step(x, h, m, res, stop)) { return false; } for(int k = 0; k < pow(2., j+1); k++) { if(*stop) { return false; } data[k] = res[k]; } } break; } case -1 : // Backward { for(int j = Jmin; j <= Jmax; j++) { std::vector<float> x(&data[0], &data[pow(2., j+1)]); if(!backward_lifting_step(x, h, m, res, stop)) { return false; } for(int k = 0; k < pow(2., j+1); k++) { if(*stop) { return false; } data[k] = res[k]; } } // Remove N points at the end so it becames the same length as original int N = pow(2, ceil(log2((float)origLength))) - origLength; removePoints(data, N); break; } } result = data; return true; }