int halfplane(lines &v, points &res) { sort(v.begin(), v.end(), cmpang); deque<line> q; deque<point> ans; q.push_back(v[0]); for (int i = 1; i < int(v.size()); i ++) { if (dcmp(v[i].ang - v[i - 1].ang) == 0) continue; while(ans.size() && !onleft(ans.back(), v[i])) { ans.pop_back(); q.pop_back(); } while(ans.size() && !onleft(ans.front(), v[i])) { ans.pop_front(); q.pop_front(); } ans.push_back(interpoint(q.back(), v[i])); q.push_back(v[i]); } while(ans.size() && !onleft(ans.back(), q.front())) { ans.pop_back(); q.pop_back(); } while(ans.size() && !onleft(ans.front(), q.back())) { ans.pop_front(); q.pop_front(); } ans.push_back(interpoint(q.back(), q.front())); res = points(ans.begin(), ans.end()); return ans.size(); //you must use the size to assure an empty set, area dont has the accuracy we need }
task4_6::solution::solution( const lines& calulator_lines ) { for (size_t i = 0; i < calulator_lines.size(); ++i) { try { calculator_.CalculateExpression(calulator_lines[i]); } catch (std::logic_error& e) { std::stringstream msg; msg << e.what() << "(line: " << i << ')'; throw std::logic_error(msg.str()); } } }