Parsowanie listy punktów
string w postaci: (0,0), (0.01,0), (0.01,0.01) zamieniony na tablicę obiektów typu punkt (x,y)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
void TokenizeVectorOfPoints(std::vector<Point<2>>& pointsVector){ boost::regex re("(\\((.*?),(.*?)\\).*?)+"); std::string s = _project->heatTransferProbePoints; boost::sregex_iterator it(s.begin(), s.end(), re); boost::sregex_iterator end; for (; it != end; ++it) { double x, y; try { x = boost::lexical_cast<double>((*it)[2]); y = boost::lexical_cast<double>((*it)[3]); } catch (boost::bad_lexical_cast const&) { x = 0; y = 0; } pointsVector.emplace_back(Point<2>(x,y)); } } |
