curve.cpp revision 89a8b4c50582aa7567eca66ae3f7a38d380e7f19
#define __CURVE_C__
/** \file
* Routines for SPCurve and for its Geom::PathVector
*/
/*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Johan Engelen
*
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
* Copyright (C) 2008 Johan Engelen
*
* Released under GNU GPL
*/
#include <glib/gmessages.h>
/* Constructors */
/**
* The returned curve's state is as if SPCurve::reset has just been called on it.
*/
: _refcount(1),
_pathv()
{
}
: _refcount(1),
{
}
SPCurve *
{
c->moveto(p);
for (int i=3; i>=0; i--) {
}
c->closepath_current();
return c;
}
{
}
/* Methods */
void
{
}
Geom::PathVector const &
SPCurve::get_pathvector() const
{
return _pathv;
}
/*
* Returns the number of segments of all paths summed
* This count includes the closing line segment of a closed path.
*/
SPCurve::get_segment_count() const
{
}
return nr;
}
/**
* Increase _refcount of curve.
*
* \todo should this be shared with other refcounting code?
*/
SPCurve *
{
_refcount += 1;
return this;
}
/**
* Decrease refcount of curve, with possible destruction.
*
* \todo should this be shared with other refcounting code?
*/
SPCurve *
{
_refcount -= 1;
if (_refcount < 1) {
delete this;
}
return NULL;
}
/**
* Create new curve from this curve's pathvector array.
*/
SPCurve *
{
}
/**
* Return new curve that is the concatenation of all curves in list.
*/
SPCurve *
{
new_curve->_pathv.insert( new_curve->_pathv.end(), c->get_pathvector().begin(), c->get_pathvector().end() );
}
return new_curve;
}
/**
* Returns a list of new curves corresponding to the subpaths in \a curve.
* 2geomified
*/
GSList *
{
for (Geom::PathVector::const_iterator path_it = _pathv.begin(); path_it != _pathv.end(); ++path_it) {
l = g_slist_prepend(l, newcurve);
}
return l;
}
/**
* Transform all paths in curve using matrix.
*/
void
{
_pathv *= m;
}
/**
* Set curve to empty curve.
* In more detail: this clears the internal pathvector from all its paths.
*/
void
{
}
/** Several consecutive movetos are ALLOWED
* Ref: http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
* (first subitem of the item about zero-length path segments) */
/**
* Calls SPCurve::moveto() with point made of given coordinates.
*/
void
{
}
/**
* Perform a moveto to a point, thus starting a new subpath.
*/
void
{
}
/**
* Calls SPCurve::lineto() with a point's coordinates.
*/
void
{
}
/**
* Adds a line to the current subpath.
*/
void
{
}
/**
* Calls SPCurve::curveto() with coordinates of three points.
*/
void
{
}
/**
* Adds a bezier segment to the current subpath.
*/
void
{
}
/**
* Close current subpath by possibly adding a line between start and end.
*/
void
{
}
/** Like SPCurve::closepath() but sets the end point of the last subpath
to the subpath start point instead of adding a new lineto.
Used for freehand drawing when the user draws back to the start point.
**/
void
{
}
/**
* True if no paths are in curve. If it only contains a path with only a moveto, the path is considered NON-empty
*/
bool
{
}
/**
* True iff all subpaths are closed.
* Returns false if the curve is empty.
*/
bool
{
if (is_empty()) {
return false;
} else {
bool closed = true;
closed = false;
break;
}
}
return closed;
}
}
/**
* Return last pathsegment (possibly the closing path segment) of the last path in PathVector or NULL.
* If the last path is empty (contains only a moveto), the function returns NULL
*/
SPCurve::last_segment() const
{
if (is_empty()) {
return NULL;
}
return NULL;
}
}
/**
* Return last path in PathVector or NULL.
*/
{
if (is_empty()) {
return NULL;
}
}
/**
* Return first pathsegment in PathVector or NULL.
* equal in functionality to SPCurve::first_bpath()
*/
SPCurve::first_segment() const
{
if (is_empty()) {
return NULL;
}
return NULL;
}
}
/**
* Return first path in PathVector or NULL.
*/
SPCurve::first_path() const
{
if (is_empty()) {
return NULL;
}
}
/**
* Return first point of first subpath or nothing when the path is empty.
*/
SPCurve::first_point() const
{
if (!is_empty()) {
}
return retval;
}
/**
* Return the second point of first subpath or _movePos if curve too short.
* If the pathvector is empty, this returns nothing. If the first path is only a moveto, this method
* returns the first point of the second path, if it exists. If there is no 2nd path, it returns the
* first point of the first path.
*/
SPCurve::second_point() const
{
if (!is_empty()) {
// first path is only a moveto
// check if there is second path
} else {
}
} else {
}
}
return retval;
}
/**
* TODO: fix comment: Return the second-last point of last subpath or _movePos if curve too short.
*/
SPCurve::penultimate_point() const
{
if (!is_empty()) {
}
return retval;
}
/**
* Return last point of last subpath or nothing when the curve is empty.
* If the last path is only a moveto, then return that point.
*/
SPCurve::last_point() const
{
if (!is_empty()) {
}
return retval;
}
/**
* Returns a *new* \a curve but drawn in the opposite direction.
* Should result in the same shape, but
* with all its markers drawn facing the other direction.
* Reverses the order of subpaths as well
**/
SPCurve *
SPCurve::create_reverse() const
{
return new_curve;
}
/**
* Append \a curve2 to \a this.
* If \a use_lineto is false, simply add all paths in \a curve2 to \a this;
* if \a use_lineto is true, combine \a this's last path and \a curve2's first path and add the rest of the paths in \a curve2 to \a this.
*/
void
bool use_lineto)
{
return;
if (use_lineto) {
} else {
}
}
} else {
for (Geom::PathVector::const_iterator it = curve2->_pathv.begin(); it != curve2->_pathv.end(); it++) {
}
}
}
/**
* Append \a c1 to \a this with possible fusing of close endpoints. If the end of this curve and the start of c1 are within tolerance distance,
* then the startpoint of c1 is moved to the end of this curve and the first subpath of c1 is appended to the last subpath of this curve.
* When one of the curves (this curve or the argument curve) is closed, the returned value is NULL; otherwise the returned value is this curve.
* When one of the curves is empty, this curves path becomes the non-empty path.
*/
SPCurve *
{
using Geom::X;
using Geom::Y;
return NULL;
}
return this;
}
if (this->is_empty()) {
return this;
}
{
// c1's first subpath can be appended to this curve's last subpath
}
} else {
}
return this;
}
/**
* Remove last segment of curve.
* (Only used once in /src/pen-context.cpp)
*/
void
{
if ( is_empty() )
return;
}
}
/**
* TODO: add comments about what this method does and what assumptions are made and requirements are put on SPCurve
*/
void
{
if (is_empty()) {
return;
}
g_error("SPCurve::stretch_endpoints - arclength <= 0");
throw;
}
Geom::Piecewise<Geom::D2<Geom::SBasis> > offsetpath = Geom::sectionize( Geom::D2<Geom::Piecewise<Geom::SBasis> >(offsetx, offsety) );
pwd2 += offsetpath;
}
/**
* sets start of first path to new_p0, and end of first path to new_p1
*/
void
{
if (is_empty()) {
return;
}
}
/**
* returns the number of nodes in a path, used for statusbar text when selecting an spcurve.
*/
SPCurve::nodes_in_path() const
{
nr++; // count last node (this works also for closed paths because although they don't have a 'last node', they do have an extra segment
}
return nr;
}
/**
* Adds p to the last point (and last handle if present) of the last path
*/
void
{
if (is_empty()) {
return;
}
// Move handle as well when the last segment is a cubic bezier segment:
// TODO: what to do for quadratic beziers?
if ( Geom::CubicBezier const *lastcube = dynamic_cast<Geom::CubicBezier const *>(&_pathv.back().back()) ) {
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :