summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b6d9822)
raw | patch | inline | side by side (parent: b6d9822)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 23 Dec 2007 21:17:42 +0000 (21:17 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 23 Dec 2007 21:17:42 +0000 (21:17 +0000) |
diff --git a/src/2geom/bezier.h b/src/2geom/bezier.h
index 16b4d7446d1b942e1df3e827d9b406d2a580b6a7..bdc672a57545c25d100dc83dc8926d5588b51a8c 100644 (file)
--- a/src/2geom/bezier.h
+++ b/src/2geom/bezier.h
}
return true;
}
+ inline bool isConstant() const {
+ for(unsigned i = 1; i <= order(); i++) {
+ if(c_[i] != c_[0]) return false;
+ }
+ return true;
+ }
inline bool isFinite() const {
for(unsigned i = 0; i <= order(); i++) {
if(!is_finite(c_[i])) return false;
diff --git a/src/2geom/concepts.h b/src/2geom/concepts.h
index 92ec66c7f52d7f16d8de826214edc537cc845dd3..50cef4e4b34e2fd7f275678bea8c8621d8c8294b 100644 (file)
--- a/src/2geom/concepts.h
+++ b/src/2geom/concepts.h
void constraints() {
t = T(o);
b = t.isZero();
+ b = t.isConstant();
b = t.isFinite();
o = t.at0();
o = t.at1();
diff --git a/src/2geom/d2.h b/src/2geom/d2.h
index 47355eb6028625904bd181a19df8f0e9bb1f59ba..3becc813d3c983c1398deb6fcb0261c35d46d74c 100644 (file)
--- a/src/2geom/d2.h
+++ b/src/2geom/d2.h
boost::function_requires<FragmentConcept<T> >();
return f[X].isZero() && f[Y].isZero();
}
+ bool isConstant() const {
+ boost::function_requires<FragmentConcept<T> >();
+ return f[X].isConstant() && f[Y].isConstant();
+ }
bool isFinite() const {
boost::function_requires<FragmentConcept<T> >();
return f[X].isFinite() && f[Y].isFinite();
diff --git a/src/2geom/linear.h b/src/2geom/linear.h
index 2b346468c19767e42dc1be9b12fd83a1c6610363..32716b9d137432cac3e6fed4c45b45ff40eceba4 100644 (file)
--- a/src/2geom/linear.h
+++ b/src/2geom/linear.h
//IMPL: FragmentConcept
typedef double output_type;
inline bool isZero() const { return a[0] == 0 && a[1] == 0; }
+ inline bool isConstant() const { return a[0] == a[1]; }
inline bool isFinite() const { return is_finite(a[0]) && is_finite(a[1]); }
inline double at0() const { return a[0]; }
diff --git a/src/2geom/path.h b/src/2geom/path.h
index 3c536c1d8e0e3abefa67bbb91dd0ee9a7c0ba14d..72c5d50fa78379f7c77a8c82a0950908471cc753 100644 (file)
--- a/src/2geom/path.h
+++ b/src/2geom/path.h
virtual Point initialPoint() const = 0;
virtual Point finalPoint() const = 0;
+ virtual bool isDegenerate() const = 0;
+
virtual Curve *duplicate() const = 0;
virtual Rect boundsFast() const = 0;
Point initialPoint() const { return inner.at0(); }
Point finalPoint() const { return inner.at1(); }
+ bool isDegenerate() const { return inner.isConstant(); }
Point pointAt(Coord t) const { return inner.valueAt(t); }
std::vector<Point> pointAndDerivatives(Coord t, unsigned n) const {
return inner.valueAndDerivatives(t, n);
Point initialPoint() const { return inner.at0(); }
Point finalPoint() const { return inner.at1(); }
+ bool isDegenerate() const { return inner.isConstant(); }
+
void setInitial(Point v) { setPoint(0, v); }
void setFinal(Point v) { setPoint(1, v); }
//TODO: implement funcs
+ bool isDegenerate() const { return toSBasis().isConstant(); }
Rect boundsFast() const;
Rect boundsExact() const;
Rect boundsLocal(Interval i, unsigned deg) const;
ret.push_cut(0);
unsigned i = 1;
// ignore that path is closed or open. pw<d2<>> is always open.
- for(const_iterator it = begin(); it != end(); ++it, i++) {
- ret.push(it->toSBasis(), i);
+ for(const_iterator it = begin(); it != end(); ++it) {
+ if (!it->isDegenerate()) {
+ ret.push(it->toSBasis(), i++);
+ }
}
return ret;
}
diff --git a/src/2geom/sbasis.h b/src/2geom/sbasis.h
index acaa190a6471c38a40ac4d5d12c3d76eba2c7444..c7489e27dcd9115ad621c76fcb9666b41d5cf0cb 100644 (file)
--- a/src/2geom/sbasis.h
+++ b/src/2geom/sbasis.h
}
return true;
}
+ inline bool isConstant() const {
+ if (empty()) return true;
+ for (unsigned i = 0; i < size(); i++) {
+ if(!(*this)[i].isConstant()) return false;
+ }
+ return true;
+ }
+
bool isFinite() const;
inline double at0() const {
if(empty()) return 0; else return (*this)[0][0];