5 #include "entitycontainer.h"
8 * Holds the data that defines a line.
14 * Default constructor. Leaves the data object uninitialized.
18 SplineData(int degree, bool closed)
20 this->degree = degree;
21 this->closed = closed;
24 friend std::ostream & operator<<(std::ostream & os, const SplineData & ld)
26 os << "( degree: " << ld.degree << " closed: " << ld.closed << ")";
31 /** Degree of the spline (1, 2, 3) */
35 /** Control points of the spline. */
36 // Q3ValueList<Vector> controlPoints;
37 QList<Vector> controlPoints;
41 * Class for a spline entity.
43 * @author Andrew Mustun
45 class Spline: public EntityContainer
48 Spline(EntityContainer * parent, const SplineData & d);
51 virtual Entity * clone();
52 virtual RS2::EntityType rtti() const;
53 virtual bool isEdge() const;
54 SplineData getData() const;
55 void setDegree(int deg);
57 int getNumberOfKnots();
58 int getNumberOfControlPoints();
60 void setClosed(bool c);
61 virtual VectorSolutions getRefPoints();
62 virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
63 virtual Vector getNearestSelectedRef(const Vector & coord, double * dist = NULL);
65 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
66 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
67 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
68 virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
69 virtual void addControlPoint(const Vector & v);
70 virtual void removeLastControlPoint();
71 virtual void move(Vector offset);
72 virtual void rotate(Vector center, double angle);
73 virtual void scale(Vector center, Vector factor);
74 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
75 virtual void moveRef(const Vector & ref, const Vector & offset);
76 virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
77 QList<Vector> getControlPoints();
79 friend std::ostream & operator<<(std::ostream & os, const Spline & l);
81 virtual void calculateBorders();
83 static void rbasis(int c, double t, int npts, int x[], double h[], double r[]);
84 static void knot(int num, int order, int knotVector[]);
85 static void rbspline(int npts, int k, int p1, double b[], double h[], double p[]);
86 static void knotu(int num, int order, int knotVector[]);
87 static void rbsplinu(int npts, int k, int p1, double b[], double h[], double p[]);