/* make a table of all supported UPS types */ void list_ups() { int maxlen = 0, len; char buf[255], *c; struct upsdef *pups; for (pups = ups; pups; pups = pups->next) if ((len = strlen(pups->tag)) > maxlen) maxlen = len; snprintf(buf, sizeof buf, "%-*s", maxlen, "<ups-type>"); fprintf(stderr, "\n %s cablep. kill t powerok battok cableok\n", buf); for (c = buf; *c; c++) *c = '-'; fprintf(stderr, " %s---------------------------------------\n", buf); for (pups = ups; pups; pups = pups->next) { fprintf(stderr, " %-*s %s%s %s%s %2d %s%s %s%s %s%s\n", maxlen, pups->tag, str_neg(pups->cablepower.inverted), str_line(pups->cablepower.line), str_neg(pups->kill.inverted), str_line(pups->kill.line), pups->killtime, str_neg(pups->powerok.inverted), str_line(pups->powerok.line), str_neg(pups->battok.inverted), str_line(pups->battok.line), str_neg(pups->cableok.inverted), str_line(pups->cableok.line) ); } fprintf(stderr, " (/=active low, ---=unused)\n\n"); }
void uParserBed::_pushBackLine(char* line) { m_pIostream->putback('\n'); std::string str_line(line); for (int i = (int)(str_line.size()) - 1; i >= 0; i--) { m_pIostream->putback(line[i]); } }
void ReadCurve(std::ifstream & is, Curve_2 & cv) { // Read a line from the input file. char one_line[128]; skip_comments (is, one_line); std::string stringvalues(one_line); std::istringstream str_line (stringvalues, std::istringstream::in); // Get the arc type. // Supported types are: 'f' - Full ellipse (or circle). // 'e' - Elliptic arc (or circular arc). // 's' - Line segment. char type; bool is_circle = false; // Is this a circle. Rat_circle_2 circle; Rational r, s, t, u, v, w; // The conic coefficients. str_line >> type; // An ellipse (full ellipse or a partial ellipse): if (type == 'f' || type == 'F' || type == 'e' || type == 'E') { // Read the ellipse (using the format "a b x0 y0"): // // x - x0 2 y - y0 2 // ( -------- ) + ( -------- ) = 1 // a b // int a, b, x0, y0; str_line >> a >> b >> x0 >> y0; Rational a_sq = Rational(a*a); Rational b_sq = Rational(b*b); if (a == b) { is_circle = true; circle = Rat_circle_2 (Rat_point_2 (Rational(x0), Rational(y0)), Rational(a*b)); } else { r = b_sq; s = a_sq; t = 0; u = Rational(-2*x0*b_sq); v = Rational(-2*y0*a_sq); w = Rational(x0*x0*b_sq + y0*y0*a_sq - a_sq*b_sq); } if (type == 'f' || type == 'F') { // Create a full ellipse (or circle). if (is_circle) cv = Curve_2 (circle); else cv = Curve_2 (r, s, t, u, v, w); } else { // Read the endpointd of the arc. int x1, y1, x2, y2; str_line >> x1 >> y1 >> x2 >> y2; Point_2 source = Point_2 (Algebraic(x1), Algebraic(y1)); Point_2 target = Point_2 (Algebraic(x2), Algebraic(y2)); // Create the arc. Note that it is always clockwise oriented. if (is_circle) cv = Curve_2 (circle, CGAL::CLOCKWISE, source, target); else cv = Curve_2 (r, s, t, u, v, w, CGAL::CLOCKWISE, source, target); } }