| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * callback interface for SVG path data | ||
| 3 | * | ||
| 4 | * Copyright 2007 MenTaLguY <mental@rydia.net> | ||
| 5 | * | ||
| 6 | * This library is free software; you can redistribute it and/or | ||
| 7 | * modify it either under the terms of the GNU Lesser General Public | ||
| 8 | * License version 2.1 as published by the Free Software Foundation | ||
| 9 | * (the "LGPL") or, at your option, under the terms of the Mozilla | ||
| 10 | * Public License Version 1.1 (the "MPL"). If you do not alter this | ||
| 11 | * notice, a recipient may use your version of this file under either | ||
| 12 | * the MPL or the LGPL. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the LGPL along with this library | ||
| 15 | * in the file COPYING-LGPL-2.1; if not, output to the Free Software | ||
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 17 | * You should have received a copy of the MPL along with this library | ||
| 18 | * in the file COPYING-MPL-1.1 | ||
| 19 | * | ||
| 20 | * The contents of this file are subject to the Mozilla Public License | ||
| 21 | * Version 1.1 (the "License"); you may not use this file except in | ||
| 22 | * compliance with the License. You may obtain a copy of the License at | ||
| 23 | * http://www.mozilla.org/MPL/ | ||
| 24 | * | ||
| 25 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY | ||
| 26 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for | ||
| 27 | * the specific language governing rights and limitations. | ||
| 28 | * | ||
| 29 | */ | ||
| 30 | |||
| 31 | #include <2geom/sbasis-to-bezier.h> | ||
| 32 | #include <2geom/path-sink.h> | ||
| 33 | #include <2geom/exception.h> | ||
| 34 | #include <2geom/circle.h> | ||
| 35 | #include <2geom/ellipse.h> | ||
| 36 | |||
| 37 | namespace Geom { | ||
| 38 | |||
| 39 | 25006 | void PathSink::feed(Curve const &c, bool moveto_initial) | |
| 40 | { | ||
| 41 | 25006 | c.feed(*this, moveto_initial); | |
| 42 | 25006 | } | |
| 43 | |||
| 44 | 28 | void PathSink::feed(Path const &path) { | |
| 45 |
1/2✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
|
28 | flush(); |
| 46 |
3/6✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 28 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 28 times.
✗ Branch 9 not taken.
|
28 | moveTo(path.front().initialPoint()); |
| 47 | |||
| 48 | // never output the closing segment to the sink | ||
| 49 |
2/4✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
|
28 | Path::const_iterator iter = path.begin(), last = path.end_open(); |
| 50 |
3/4✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✓ Branch 5 taken 28 times.
|
152 | for (; iter != last; ++iter) { |
| 51 |
2/4✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 124 times.
✗ Branch 5 not taken.
|
124 | iter->feed(*this, false); |
| 52 | } | ||
| 53 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 2 taken 8 times.
|
28 | if (path.closed()) { |
| 54 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | closePath(); |
| 55 | } | ||
| 56 |
1/2✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
|
28 | flush(); |
| 57 | 28 | } | |
| 58 | |||
| 59 | ✗ | void PathSink::feed(PathVector const &pv) { | |
| 60 | ✗ | for (const auto & i : pv) { | |
| 61 | ✗ | feed(i); | |
| 62 | } | ||
| 63 | ✗ | } | |
| 64 | |||
| 65 | ✗ | void PathSink::feed(Rect const &r) { | |
| 66 | ✗ | moveTo(r.corner(0)); | |
| 67 | ✗ | lineTo(r.corner(1)); | |
| 68 | ✗ | lineTo(r.corner(2)); | |
| 69 | ✗ | lineTo(r.corner(3)); | |
| 70 | ✗ | closePath(); | |
| 71 | ✗ | } | |
| 72 | |||
| 73 | ✗ | void PathSink::feed(Circle const &e) { | |
| 74 | ✗ | Coord r = e.radius(); | |
| 75 | ✗ | Point c = e.center(); | |
| 76 | ✗ | Point a = c + Point(0, +r); | |
| 77 | ✗ | Point b = c + Point(0, -r); | |
| 78 | |||
| 79 | ✗ | moveTo(a); | |
| 80 | ✗ | arcTo(r, r, 0, false, false, b); | |
| 81 | ✗ | arcTo(r, r, 0, false, false, a); | |
| 82 | ✗ | closePath(); | |
| 83 | ✗ | } | |
| 84 | |||
| 85 | ✗ | void PathSink::feed(Ellipse const &e) { | |
| 86 | ✗ | Point s = e.pointAt(0); | |
| 87 | ✗ | moveTo(s); | |
| 88 | ✗ | arcTo(e.ray(X), e.ray(Y), e.rotationAngle(), false, false, e.pointAt(M_PI)); | |
| 89 | ✗ | arcTo(e.ray(X), e.ray(Y), e.rotationAngle(), false, false, s); | |
| 90 | ✗ | closePath(); | |
| 91 | ✗ | } | |
| 92 | |||
| 93 | } | ||
| 94 | |||
| 95 | /* | ||
| 96 | Local Variables: | ||
| 97 | mode:c++ | ||
| 98 | c-file-style:"stroustrup" | ||
| 99 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
| 100 | indent-tabs-mode:nil | ||
| 101 | fill-column:99 | ||
| 102 | End: | ||
| 103 | */ | ||
| 104 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
| 105 |