QCAD
Open Source 2D CAD
RArc.h
Go to the documentation of this file.
1 
20 #ifndef RARC_H
21 #define RARC_H
22 
23 #include "../core_global.h"
24 
25 #include "RDirected.h"
26 #include "RShape.h"
27 #include "RVector.h"
28 
29 class RBox;
30 class RPolyline;
31 
41 class QCADCORE_EXPORT RArc: public RShape, public RDirected {
42 public:
43  RArc();
44  RArc(double cx, double cy, double radius, double startAngle,
45  double endAngle, bool reversed = false);
46  RArc(const RVector& center, double radius, double startAngle,
47  double endAngle, bool reversed = false);
48  virtual ~RArc();
49 
50  virtual RArc* clone() const {
51  return new RArc(*this);
52  }
53 
54  virtual void to2D();
55 
56  bool isValid() const;
57  bool isFullCircle() const;
58 
59  static RArc createFrom3Points(const RVector& startPoint,
60  const RVector& point,
61  const RVector& endPoint);
62  static RArc createFrom2PBulge(const RVector& startPoint,
63  const RVector& endPoint,
64  double bulge);
65  static RArc createTangential(const RVector& startPoint,
66  const RVector& pos,
67  double direction,
68  double radius);
69 
70  virtual RBox getBoundingBox() const;
71 
72  virtual QList<RVector> getEndPoints() const;
73  virtual QList<RVector> getMiddlePoints() const;
74  virtual QList<RVector> getCenterPoints() const;
75  virtual QList<RVector> getPointsWithDistanceToEnd(
76  double distance, RS::From from = RS::FromAny) const;
77 
78  virtual RVector getVectorTo(const RVector& point,
79  bool limited = true, double strictRange = RMAXDOUBLE) const;
80 
81  RVector getCenter() const;
82  void setCenter(const RVector& vector);
83  double getRadius() const;
84  void setRadius(double radius);
85  double getStartAngle() const;
86  void setStartAngle(double startAngle);
87  double getEndAngle() const;
88  void setEndAngle(double endAngle);
89  bool isReversed() const;
90  void setReversed(bool reversed);
91  double getAngleLength(bool allowForZeroLength = false) const;
92  bool isAngleWithinArc(double a) {
93  return RMath::isAngleBetween(a, startAngle, endAngle, reversed);
94  }
95 
96  double getDiameter() const;
97  void setDiameter(double d);
98  void setLength(double l);
99  double getArea() const;
100  void setArea(double a);
101 
102  double getDirection1() const;
103  double getDirection2() const;
104 
105  RS::Side getSideOfPoint(const RVector& point) const;
106 
107  double getSweep() const;
108  void setSweep(double s);
109  double getLength() const;
110 
111  virtual RVector getStartPoint() const;
112  virtual RVector getEndPoint() const;
113  virtual RVector getPointAtAngle(double a) const;
114  virtual double getAngleAt(double distance, RS::From from = RS::FromStart) const;
115  RVector getMiddlePoint() const;
116 
117  void moveStartPoint(const RVector& pos);
118  void moveEndPoint(const RVector& pos);
119  double getBulge() const;
120 
121  virtual bool move(const RVector& offset);
122  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
123  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
124  virtual bool mirror(const RLine& axis);
125  virtual bool reverse();
126  virtual bool stretch(const RPolyline& area, const RVector& offset);
127 
128  virtual QSharedPointer<RShape> getTransformed(const QTransform& transform) const;
129 
130  virtual RS::Ending getTrimEnd(const RVector& coord, const RVector& trimPoint);
131  virtual void trimStartPoint(const RVector& p);
132  virtual void trimEndPoint(const RVector& p);
133  virtual double getDistanceFromStart(const RVector& p) const;
134 
135  RPolyline approximateWithLines(double segmentLength);
136  RPolyline approximateWithLinesTan(double segmentLength);
137 
138 protected:
139  virtual void print(QDebug dbg) const;
140 
141 public:
151  double radius;
156  double startAngle;
161  double endAngle;
166  bool reversed;
167 };
168 
169 Q_DECLARE_METATYPE(const RArc*)
172 Q_DECLARE_METATYPE(QSharedPointer<RArc>)
173 Q_DECLARE_METATYPE(QSharedPointer<RArc>*)
174 
175 #endif
Represents a box e.g.
Definition: RBox.h:43
Ending
Entity ending.
Definition: RS.h:136
RVector center
Getter function for this property: getCenter.
Definition: RArc.h:146
virtual RVector getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const =0
virtual void to2D()=0
Flattens this shape to the X/Y plane.
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
virtual QList< RVector > getEndPoints() const =0
double radius
Getter function for this property: getRadius.
Definition: RArc.h:151
Low-level mathematical representation of an arc.
Definition: RArc.h:41
bool reversed
Getter function for this property: isReversed.
Definition: RArc.h:166
virtual double getDirection1() const =0
virtual RVector getEndPoint() const =0
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)=0
#define QCADCORE_EXPORT
Definition: core_global.h:10
virtual void trimStartPoint(const RVector &p)=0
virtual RS::Ending getTrimEnd(const RVector &coord, const RVector &trimPoint)=0
virtual double getLength() const =0
virtual RBox getBoundingBox() const =0
bool isAngleWithinArc(double a)
Definition: RArc.h:92
Start or end.
Definition: RS.h:187
Side
Side used for side of a point relativ to an entity (right hand or left hand side) ...
Definition: RS.h:129
virtual double getDistanceFromStart(const RVector &p) const
Definition: RDirected.h:61
virtual bool move(const RVector &offset)=0
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RShape.h:135
virtual bool stretch(const RBox &area, const RVector &offset)
Definition: RShape.cpp:1608
static bool isAngleBetween(double a, double a1, double a2, bool reversed)
Tests if angle a is between a1 and a2.
Definition: RMath.cpp:500
virtual QList< RVector > getPointsWithDistanceToEnd(double distance, RS::From from=RS::FromAny) const =0
Q_DECLARE_METATYPE(RMath *)
virtual void trimEndPoint(const RVector &p)=0
virtual QList< RVector > getMiddlePoints() const =0
#define RMAXDOUBLE
Definition: RMath.h:50
Definition: RS.h:185
virtual bool mirror(const RLine &axis)=0
Low-level mathematical representation of a line.
Definition: RLine.h:42
double startAngle
Getter function for this property: getStartAngle.
Definition: RArc.h:156
virtual RVector getStartPoint() const =0
virtual RArc * clone() const
Definition: RArc.h:50
virtual bool reverse()=0
virtual QSharedPointer< RShape > getTransformed(const QTransform &transform) const =0
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RDirected.h:36
double endAngle
Getter function for this property: getEndAngle.
Definition: RArc.h:161
From
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:184
virtual double getDirection2() const =0
virtual bool scale(double scaleFactor, const RVector &center=RVector())
Definition: RShape.cpp:1619
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual QList< RVector > getCenterPoints() const =0
virtual void print(QDebug dbg) const
Definition: RShape.cpp:1623
#define RDEFAULT_RVECTOR
Definition: RVector.h:37