curve.cpp revision c0537dcfe264414d52ad86579d57cb0cb2183dcb
#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.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>=1; i--) {
}
if (all_four_sides) {
// When _constrained_ snapping to a path, the 2geom::SimpleCrosser will be invoked which doesn't consider the closing segment.
// of a path. Consequently, in case we want to snap to for example the page border, we must provide all four sides of the
// rectangle explicitly
} else {
// ... instead of just three plus a closing segment
c->closepath();
}
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.
* Point p must be finite.
*/
void
{
}
/**
* Adds a line to the current subpath.
* Point p must be finite.
*/
void
{
}
/**
* Calls SPCurve::lineto( Geom::Point(x,y) )
*/
void
{
}
/**
* Adds a quadratic bezier segment to the current subpath.
* All points must be finite.
*/
void
{
}
/**
* Calls SPCurve::quadto( Geom::Point(x1,y1), Geom::Point(x2,y2) )
* All coordinates must be finite.
*/
void
{
}
/**
* Adds a bezier segment to the current subpath.
* All points must be finite.
*/
void
{
}
/**
* Calls SPCurve::curveto( Geom::Point(x0,y0), Geom::Point(x1,y1), Geom::Point(x2,y2) )
* All coordinates must be finite.
*/
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
{
if (_pathv.back().size() > 0 && dynamic_cast<Geom::LineSegment const *>(&_pathv.back().back_open())) {
} else {
}
}
/**
* 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;
}
/**
* Return the second-last point of last subpath or first point when that last subpath has only a moveto.
*/
SPCurve::penultimate_point() const
{
if (!is_empty()) {
} else {
}
}
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
(2:08:18 AM) Johan: basically, i convert the path to pw<d2>
(2:08:27 AM) Johan: then i calculate an offset path
(2:08:29 AM) Johan: to move the knots
(2:08:36 AM) Johan: then i add it
(2:08:40 AM) Johan: then convert back to path
If I remember correctly, this moves the firstpoint to new_p0, and the lastpoint to new_p1, and moves all nodes in between according to their arclength (interpolates the movement amount)
*/
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.
* Sum of nodes in all the paths. When a path is closed, and its closing line segment is of zero-length,
* this function will not count the closing knot double (so basically ignores the closing line segment when it has zero length)
*/
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
// do not count closing knot double for zero-length closing line segments
// however, if the path is only a moveto, and is closed, do not subtract 1 (otherwise the result will be zero nodes)
{
nr--;
}
}
}
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:fileencoding=utf-8:textwidth=99 :