4 #include "atomicentity.h"
10 * Holds the data that defines an arc.
19 ArcData(const Vector & center, double radius, double angle1, double angle2, bool reversed)
21 this->center = center;
22 this->radius = radius;
23 this->angle1 = angle1;
24 this->angle2 = angle2;
25 this->reversed = reversed;
30 center = Vector(false);
39 return (center.valid && radius > RS_TOLERANCE
40 && fabs(angle1 - angle2) > RS_TOLERANCE_ANGLE);
43 friend std::ostream & operator<<(std::ostream & os, const ArcData & ad)
45 os << "(" << ad.center
62 * Class for an arc entity. All angles are in Rad.
64 * @author Andrew Mustun
66 class Arc: public AtomicEntity
69 Arc(EntityContainer * parent, const ArcData & d);
72 virtual Entity * clone();
73 virtual RS2::EntityType rtti() const;
74 virtual bool isEdge() const;
75 ArcData getData() const;
76 virtual VectorSolutions getRefPoints();
77 void setData(ArcData d);
78 Vector getCenter() const;
79 void setCenter(const Vector & c);
80 double getRadius() const;
81 void setRadius(double r);
82 double getAngle1() const;
83 void setAngle1(double a1);
84 double getAngle2() const;
85 void setAngle2(double a2);
86 double getDirection1() const;
87 double getDirection2() const;
88 bool isReversed() const;
89 void setReversed(bool r);
90 virtual Vector getStartpoint() const;
91 virtual Vector getEndpoint() const;
92 virtual void moveStartpoint(const Vector & pos);
93 virtual void moveEndpoint(const Vector & pos);
94 virtual void trimStartpoint(const Vector & pos);
95 virtual void trimEndpoint(const Vector & pos);
96 virtual RS2::Ending getTrimPoint(const Vector & coord, const Vector & trimPoint);
97 virtual void reverse();
98 Vector getMiddlepoint() const;
99 double getAngleLength() const;
100 virtual double getLength();
101 double getBulge() const;
103 bool createFrom3P(const Vector & p1, const Vector & p2, const Vector & p3);
104 bool createFrom2PDirectionRadius(const Vector & startPoint, const Vector & endPoint, double direction1, double radius);
105 bool createFrom2PBulge(const Vector & startPoint, const Vector & endPoint, double bulge);
107 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
108 virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true, double * dist = NULL, Entity ** entity = NULL);
109 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
110 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
111 virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
112 virtual Vector getNearestDist(double distance, bool startp);
114 virtual double getDistanceToPoint(const Vector & coord, Entity * * entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
115 virtual void move(Vector offset);
116 virtual void rotate(Vector center, double angle);
117 virtual void scale(Vector center, Vector factor);
118 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
119 virtual void moveRef(const Vector & ref, const Vector & offset);
120 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
122 virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
124 friend std::ostream & operator<<(std::ostream & os, const Arc & a);
126 virtual void calculateEndpoints();
127 virtual void calculateBorders();
133 * Startpoint. This is redundant but stored for performance
138 * Endpoint. This is redundant but stored for performance