summaryrefslogtreecommitdiffstats
path: root/src/2geom
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-08-08 17:27:51 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-08-08 17:27:51 +0000
commit60d3113d1f022a3de7cf04c7979d4751b3fe21f6 (patch)
treeca33e2a9a1af6b5911598fa1c6a1d77087b71dd2 /src/2geom
parentMinor cleanups (diff)
parentAdd a constrained snap method that takes multiple constraints. This reduces t... (diff)
downloadinkscape-60d3113d1f022a3de7cf04c7979d4751b3fe21f6.tar.gz
inkscape-60d3113d1f022a3de7cf04c7979d4751b3fe21f6.zip
merge from trunk
(bzr r9508.1.52)
Diffstat (limited to 'src/2geom')
-rw-r--r--src/2geom/circle.cpp17
-rw-r--r--src/2geom/circle.h10
-rw-r--r--src/2geom/sbasis-to-bezier.cpp4
3 files changed, 30 insertions, 1 deletions
diff --git a/src/2geom/circle.cpp b/src/2geom/circle.cpp
index c3cea0ae7..00b91de12 100644
--- a/src/2geom/circle.cpp
+++ b/src/2geom/circle.cpp
@@ -97,6 +97,23 @@ Circle::arc(Point const& initial, Point const& inner, Point const& final,
return e.arc(initial, inner, final, _svg_compliant);
}
+void
+Circle::getPath(std::vector<Path> &path_out) {
+ Path pb;
+
+ D2<SBasis> B;
+ Linear bo = Linear(0, 2 * M_PI);
+
+ B[0] = cos(bo,4);
+ B[1] = sin(bo,4);
+
+ B = B * m_ray + m_centre;
+
+ pb.append(SBasisCurve(B));
+
+ path_out.push_back(pb);
+}
+
} // end namespace Geom
diff --git a/src/2geom/circle.h b/src/2geom/circle.h
index 27d4fcc3f..c346b8c8f 100644
--- a/src/2geom/circle.h
+++ b/src/2geom/circle.h
@@ -38,7 +38,7 @@
#include <2geom/point.h>
#include <2geom/exception.h>
-
+#include <2geom/path.h>
namespace Geom
{
@@ -56,6 +56,11 @@ class Circle
{
}
+ Circle(Point center, double r)
+ : m_centre(center), m_ray(r)
+ {
+ }
+
Circle(double A, double B, double C, double D)
{
set(A, B, C, D);
@@ -86,6 +91,9 @@ class Circle
arc(Point const& initial, Point const& inner, Point const& final,
bool _svg_compliant = true);
+ void
+ getPath(std::vector<Path> &path_out);
+
Point center() const
{
return m_centre;
diff --git a/src/2geom/sbasis-to-bezier.cpp b/src/2geom/sbasis-to-bezier.cpp
index ce5bf89bc..0a5441254 100644
--- a/src/2geom/sbasis-to-bezier.cpp
+++ b/src/2geom/sbasis-to-bezier.cpp
@@ -99,6 +99,10 @@ int sgn(unsigned int j, unsigned int k)
*/
void sbasis_to_bezier (Bezier & bz, SBasis const& sb, size_t sz)
{
+ if (sb.size() == 0) {
+ THROW_RANGEERROR("size of sb is too small");
+ }
+
size_t q, n;
bool even;
if (sz == 0)