/**
* \file
* \brief Bezier curve
*//*
* Authors:
* MenTaLguY <mental@rydia.net>
* Marco Cecchetti <mrcekets at gmail.com>
* Krzysztof KosiĆski <tweenk.pl@gmail.com>
*
* Copyright 2007-2011 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 LIB2GEOM_SEEN_BEZIER_CURVE_H
#define LIB2GEOM_SEEN_BEZIER_CURVE_H
{
BezierCurve() {}
/// @name Access and modify control points
/// @{
/** @brief Get the order of the Bezier curve.
* A Bezier curve has order() + 1 control points. */
/** @brief Get the number of control points. */
/** @brief Access control points of the curve.
* @param ix The (zero-based) index of the control point. Note that the caller is responsible for checking that this value is <= order().
* @return The control point. No-reference return, use setPoint() to modify control points. */
/** @brief Get the control points.
* @return Vector with order() + 1 control points. */
/** @brief Modify a control point.
* @param ix The zero-based index of the point to modify. Note that the caller is responsible for checking that this value is <= order().
* @param v The new value of the point */
}
/** @brief Set new control points.
* @param ps Vector which must contain order() + 1 points.
* Note that the caller is responsible for checking the size of this vector.
* @throws LogicalError Thrown when the size of the vector does not match the order. */
// must be virtual, because HLineSegment will need to redefine it
THROW_LOGICALERROR("BezierCurve::setPoints: incorrect number of points in vector");
for(unsigned i = 0; i <= order(); i++) {
}
}
/// @}
/// @name Construct a Bezier curve with runtime-determined order.
/// @{
/** @brief Construct a curve from a vector of control points.
* This will construct the appropriate specialization of BezierCurve (i.e. LineSegment,
* QuadraticBezier or Cubic Bezier) if the number of control points in the passed vector
* does not exceed 4. */
/// @}
// implementation of virtual methods goes here
virtual bool isDegenerate() const;
if (!i) return OptRect();
// TODO: UUUUUUGGGLLY
return OptRect();
}
}
}
}
for (unsigned i = 0; i < size(); ++i) {
}
}
for (unsigned i = 0; i < size(); ++i) {
inner[X][i] *= s[X];
inner[Y][i] *= s[Y];
}
}
for (unsigned i = 0; i < size(); ++i) {
setPoint(i, controlPoint(i) * m);
}
}
}
}
}
return inner.valueAndDerivatives(t, n);
}
};
{
template <unsigned required_degree>
/// @name Construct Bezier curves
/// @{
/** @brief Construct a Bezier curve of the specified order with all points zero. */
BezierCurveN() {
}
/** @brief Construct from 2D Bezier polynomial. */
inner = x;
}
/** @brief Construct from two 1D Bezier polynomials of the same order. */
}
/** @brief Construct a Bezier curve from a vector of its control points. */
for (unsigned d = 0; d < 2; ++d) {
for(unsigned i = 0; i <= ord; i++)
}
}
/** @brief Construct a linear segment from its endpoints. */
for(unsigned d = 0; d < 2; d++)
}
/** @brief Construct a quadratic Bezier curve from its control points. */
for(unsigned d = 0; d < 2; d++)
}
/** @brief Construct a cubic Bezier curve from its control points. */
for(unsigned d = 0; d < 2; d++)
}
// default copy
// default assign
/// @}
/** @brief Divide a Bezier curve into two curves
* @param t Time value
* @return Pair of Bezier curves \f$(\mathbf{D}, \mathbf{E})\f$ such that
* \f$\mathbf{D}[ [0,1] ] = \mathbf{C}[ [0,t] ]\f$ and
* \f$\mathbf{E}[ [0,1] ] = \mathbf{C}[ [t,1] ]\f$ */
}
return BezierCurve::isDegenerate();
}
return size() == 2;
}
}
if (degree == 1) {
} else {
}
}
if (degree == 1) {
} else {
}
}
}
// call super. this is implemented only to allow specializations
}
}
// call super. this is implemented only to allow specializations
}
};
// BezierCurveN<0> is meaningless; specialize it out
/** @brief Line segment.
* Line segments are Bezier curves of order 1. They have only two control points,
* the starting point and the ending point.
* @ingroup Curves */
/** @brief Quadratic (order 2) Bezier curve.
* @ingroup Curves */
/** @brief Cubic (order 3) Bezier curve.
* @ingroup Curves */
inline
}
// optimized specializations
}
}
}
} // end namespace Geom
#endif // LIB2GEOM_SEEN_BEZIER_CURVE_H
/*
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 :