5 #include "rs_entitycontainer.h"
8 * Holds the data that defines a line.
14 * Default constructor. Leaves the data object uninitialized.
18 RS_SplineData(int degree, bool closed)
20 this->degree = degree;
21 this->closed = closed;
24 friend std::ostream & operator<<(std::ostream & os, const RS_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 RS_Spline: public RS_EntityContainer
48 RS_Spline(RS_EntityContainer * parent, const RS_SplineData & d);
51 virtual RS_Entity * clone();
52 virtual RS2::EntityType rtti() const;
53 virtual bool isEdge() const;
54 RS_SplineData getData() const;
55 void setDegree(int deg);
57 int getNumberOfKnots();
58 int getNumberOfControlPoints();
60 void setClosed(bool c);
62 virtual VectorSolutions getRefPoints();
63 virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
64 virtual Vector getNearestSelectedRef(const Vector & coord, double * dist = NULL);
68 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
69 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
70 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
71 virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
73 virtual void addControlPoint(const Vector & v);
74 virtual void removeLastControlPoint();
76 virtual void move(Vector offset);
77 virtual void rotate(Vector center, double angle);
78 virtual void scale(Vector center, Vector factor);
79 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
80 virtual void moveRef(const Vector & ref, const Vector & offset);
82 // virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
83 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
84 // Q3ValueList<Vector> getControlPoints();
85 QList<Vector> getControlPoints();
87 friend std::ostream & operator<<(std::ostream & os, const RS_Spline & l);
89 virtual void calculateBorders();
91 static void rbasis(int c, double t, int npts, int x[], double h[], double r[]);
92 static void knot(int num, int order, int knotVector[]);
93 static void rbspline(int npts, int k, int p1, double b[], double h[], double p[]);
94 static void knotu(int num, int order, int knotVector[]);
95 static void rbsplinu(int npts, int k, int p1, double b[], double h[], double p[]);