path.h revision e3727c190ff3697e379586bb41c33b8e5929a08a
/*
* Path - Series of continuous curves
*
* Authors:
* MenTaLguY <mental@rydia.net>
* Marco Cecchetti <mrcekets at gmail.com>
*
* Copyright 2007-2008 authors
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*/
#ifndef SEEN_GEOM_PATH_H
#define SEEN_GEOM_PATH_H
#include "point.h"
#include "angle.h"
#include <iterator>
#include <algorithm>
#include "exception.h"
#include "d2.h"
#include "matrix.h"
#include "bezier.h"
#include "crossing.h"
#include "utils.h"
struct CurveHelpers {
};
virtual bool isDegenerate() const = 0;
//mental: review these
};
SBasisCurve();
return inner.valueAndDerivatives(t, n);
}
}
}
Curve *derivative() const {
}
};
template <unsigned required_degree>
}
// default copy
// default assign
for(unsigned d = 0; d < 2; d++)
}
for(unsigned d = 0; d < 2; d++)
}
for(unsigned d = 0; d < 2; d++)
}
// TODO: UUUUUUGGGLLY
}
//TODO: local
//TODO: implement next 3 natively
}
}
for(unsigned i = 0; i <= order; i++) {
}
}
}
}
}
return ret;
}
Curve *derivative() const {
if(order > 1)
else if (order == 1) {
}
}
std::vector<Point> pointAndDerivatives(Coord t, unsigned n) const { return inner.valueAndDerivatives(t, n); }
BezierCurve(Point c[]) {
for(unsigned i = 0; i <= order; i++) {
x[i] = c[i][X]; y[i] = c[i][Y];
}
}
};
// BezierCurve<0> is meaningless; specialize it out
template<> class BezierCurve<0> : public BezierCurve<1> { public: BezierCurve(); BezierCurve(Bezier x, Bezier y); };
{
{}
)
{
//assert( (ray(X) >= 0) && (ray(Y) >= 0) );
{
m_start_angle = m_end_angle = 0;
m_center = initialPoint();
}
else
{
}
}
{
}
{
return m_center[i];
}
{
return m_center;
}
Point initialPoint() const
{
return m_initial_point;
}
Point finalPoint() const
{
return m_final_point;
}
double start_angle() const
{
return m_start_angle;
}
double end_angle() const
{
return m_end_angle;
}
{
}
bool large_arc_flag() const
{
return m_large_arc;
}
bool sweep_flag() const
{
return m_sweep;
}
double rotation_angle() const
{
return m_rot_angle;
}
{
}
{
}
{
}
bool isDegenerate() const
{
}
// TODO: native implementation of the following methods
Rect boundsFast() const
{
}
Rect boundsExact() const
{
}
{
}
{
}
{
}
Curve *derivative() const
{
}
{
}
{
}
{
return p * m;
}
{
return arc_pair;
}
// the arc is the same but traversed in the opposite direction
{
return rarc;
}
double sweep_angle() const
{
if ( !sweep_flag() ) d = -d;
if ( d < 0 )
d += 2*M_PI;
return d;
}
bool m_large_arc, m_sweep;
double m_start_angle, m_end_angle;
}; // end class SVGEllipticalArc
{
BaseIterator() {}
// default construct
// default copy
}
}
BaseIterator &operator++() {
++impl_;
return *this;
}
BaseIterator operator++(int) {
++(*this);
return old;
}
};
{
DuplicatingIterator() {}
}
}
DuplicatingIterator &operator++() {
++impl_;
return *this;
}
DuplicatingIterator operator++(int) {
++(*this);
return old;
}
};
Path()
{
}
{
}
{
}
{
}
}
clear();
return *this;
}
const_iterator end_default() const {
}
Rect boundsFast() const;
Rect boundsExact() const;
unsigned i = 1;
// ignore that path is closed or open. pw<d2<>> is always open.
if (!it->isDegenerate()) {
}
}
return ret;
}
//Possible point of discontinuity?
}
return ret;
}
double i, f = modf(t, &i);
if(i == size() && f == 0) { i--; }
}
if(empty()) return 0;
double i, f = modf(t, &i);
if(i == size() && f == 0) { i--; }
}
for(unsigned i = 0; i <= size(); i++) {
}
return res;
}
void appendPortionTo(Path &p, double f, double t) const;
appendPortionTo(ret, f, t);
return ret;
}
//TODO: do we really delete?
}
return ret;
}
try {
} catch (...) {
}
}
{
try {
} catch (...) {
}
}
void clear() {
}
}
}
try {
} catch (...) {
}
}
{
try {
} catch (...) {
}
}
{
try {
} catch (...) {
}
}
{
try {
} catch (...) {
}
}
clear();
}
void appendNew(A a) {
}
void appendNew(A a, B b) {
}
void appendNew(A a, B b, C c) {
}
typename D>
void appendNew(A a, B b, C c, D d) {
}
void appendNew(A a, B b, C c, D d, E e) {
}
void appendNew(A a, B b, C c, D d, E e, F f) {
}
typename G>
void appendNew(A a, B b, C c, D d, E e, F f, G g) {
}
void appendNew(A a, B b, C c, D d, E e, F f, G g, H h) {
}
void appendNew(A a, B b, C c, D d, E e, F f, G g, H h, I i) {
}
bool closed_;
};
}
return ret;
}
/*
class PathPortion : public Curve {
Path *source;
double f, t;
boost::optional<Path> result;
public:
double from() const { return f; }
double to() const { return t; }
explicit PathPortion(Path *s, double fp, double tp) : source(s), f(fp), t(tp) {}
Curve *duplicate() const { return new PathPortion(*this); }
Point initialPoint() const { return source->pointAt(f); }
Point finalPoint() const { return source->pointAt(t); }
Path actualPath() {
if(!result) *result = source->portion(f, t);
return *result;
}
Rect boundsFast() const { return actualPath().boundsFast; }
Rect boundsExact() const { return actualPath().boundsFast; }
Rect boundsLocal(Interval i) const { throwNotImplemented(); }
std::vector<double> roots(double v, Dim2 d) const = 0;
virtual int winding(Point p) const { return root_winding(*this, p); }
virtual Curve *portion(double f, double t) const = 0;
virtual Curve *reverse() const { return portion(1, 0); }
virtual Crossings crossingsWith(Curve const & other) const;
virtual void setInitial(Point v) = 0;
virtual void setFinal(Point v) = 0;
virtual Curve *transformed(Matrix const &m) const = 0;
virtual Point pointAt(Coord t) const { return pointAndDerivatives(t, 1).front(); }
virtual Coord valueAt(Coord t, Dim2 d) const { return pointAt(t)[d]; }
virtual std::vector<Point> pointAndDerivatives(Coord t, unsigned n) const = 0;
virtual D2<SBasis> toSBasis() const = 0;
};
*/
}
template <>
{
a.swap(b);
}
}
#endif // SEEN_GEOM_PATH_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(substatement-open . 0))
indent-tabs-mode:nil
c-brace-offset:0
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=8:softtabstop=2 :