Horizon
|
#include <algorithm>
#include <bitset>
#include <math.h>
#include <type_traits>
#include <convert_basic_shapes_to_polygon.h>
#include <geometry/geometry_utils.h>
#include <geometry/shape_line_chain.h>
#include <geometry/shape_poly_set.h>
#include <math/util.h>
#include <math/vector2d.h>
#include <trigo.h>
Classes | |
struct | ROUNDED_CORNER |
Functions | |
void | TransformCircleToPolygon (SHAPE_LINE_CHAIN &aCornerBuffer, const wxPoint &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount) |
Convert a circle to a polygon, using multiple straight lines. | |
void | TransformCircleToPolygon (SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount) |
Convert a circle to a polygon, using multiple straight lines. | |
void | TransformOvalToPolygon (SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount) |
Convert a oblong shape to a polygon, using multiple segments. | |
void | CornerListToPolygon (SHAPE_POLY_SET &outline, std::vector< ROUNDED_CORNER > &aCorners, int aInflate, int aError, ERROR_LOC aErrorLoc) |
void | CornerListRemoveDuplicates (std::vector< ROUNDED_CORNER > &aCorners) |
void | TransformTrapezoidToPolygon (SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aDeltaX, int aDeltaY, int aInflate, int aError, ERROR_LOC aErrorLoc) |
Convert a rectangle or trapezoid to a polygon. | |
void | TransformRoundChamferedRectToPolygon (SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aInflate, int aError, ERROR_LOC aErrorLoc) |
Convert a rectangle with rounded corners and/or chamfered corners to a polygon. | |
int | ConvertArcToPolyline (SHAPE_LINE_CHAIN &aPolyline, VECTOR2I aCenter, int aRadius, double aStartAngleDeg, double aArcAngleDeg, double aAccuracy, ERROR_LOC aErrorLoc) |
Generate a polyline to approximate a arc. | |
void | TransformArcToPolygon (SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc) |
Convert arc to multiple straight segments. | |
void | TransformRingToPolygon (SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aCentre, int aRadius, int aWidth, int aError, ERROR_LOC aErrorLoc) |
Convert arcs to multiple straight segments. | |
int ConvertArcToPolyline | ( | SHAPE_LINE_CHAIN & | aPolyline, |
VECTOR2I | aCenter, | ||
int | aRadius, | ||
double | aStartAngleDeg, | ||
double | aArcAngleDeg, | ||
double | aAccuracy, | ||
ERROR_LOC | aErrorLoc | ||
) |
Generate a polyline to approximate a arc.
aPolyline | is a buffer to store the polyline. |
aCenter | is the center of the arc. |
aRadius | is the radius of the arc. |
aStartAngleDeg | is the starting point (in degrees) of the arc. |
aArcAngleDeg | is the angle (in degrees) of the arc. |
aError | is the internal units allowed for error approximation. |
aErrorLoc | determines if the approximation error be placed outside or inside the polygon. |
void TransformArcToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
const wxPoint & | aStart, | ||
const wxPoint & | aMid, | ||
const wxPoint & | aEnd, | ||
int | aWidth, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
Convert arc to multiple straight segments.
aCornerBuffer | is a buffer to store the polygon. |
aCentre | is the center of the arc or circle. |
aStart | is the start point of the arc or a point on the circle. |
aArcAngle | is the arc angle in 0.1 degrees. For a circle, aArcAngle = 3600. |
aWidth | is the width (thickness) of the line. |
aError | is the internal units allowed for error in approximation. |
aErrorLoc | determines if the approximation error be placed outside or inside the polygon. |
We start by making rounded ends on the arc
void TransformCircleToPolygon | ( | SHAPE_LINE_CHAIN & | aCornerBuffer, |
const wxPoint & | aCenter, | ||
int | aRadius, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc, | ||
int | aMinSegCount = 0 |
||
) |
Convert a circle to a polygon, using multiple straight lines.
aCornerBuffer | is a buffer to store the polygon. |
aCenter | is the center of the circle. |
aRadius | is the radius of the circle. |
aError | is the internal units allowed for error approximation. |
aErrorLoc | determines if the approximation error be placed outside or inside the polygon. |
aMinSegCount | is the min count of segments to approximate. Default = 0 to do not force a min count. |
void TransformCircleToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
const wxPoint & | aCenter, | ||
int | aRadius, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc, | ||
int | aMinSegCount = 0 |
||
) |
Convert a circle to a polygon, using multiple straight lines.
aCornerBuffer | is a buffer to store the polygon. |
aCenter | is the center of the circle. |
aRadius | is the radius of the circle. |
aError | is the internal units allowed for error in approximation. |
aErrorLoc | determines if the approximation error be placed outside or inside the polygon. |
aMinSegCount | is the min count of segments to approximate. Default = 0 to do not force a min count. |
void TransformOvalToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
const wxPoint & | aStart, | ||
const wxPoint & | aEnd, | ||
int | aWidth, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc, | ||
int | aMinSegCount = 0 |
||
) |
Convert a oblong shape to a polygon, using multiple segments.
It is similar to TransformRoundedEndsSegmentToPolygon, but the polygon is outside the actual oblong shape (a segment with rounded ends). It is suitable to create oblong clearance areas because multiple segments create a smaller area than the circle. The radius of the circle to approximate must be bigger ( radius*aCorrectionFactor) to create segments outside the circle.
aCornerBuffer | is a buffer to store the polygon. |
aStart | is the first point of the segment. |
aEnd | is the second point of the segment. |
aWidth | is the width of the segment. |
aError | is the internal units allowed for error in approximation. |
aErrorLoc | determines if the approximation error be placed outside or inside the polygon. |
aMinSegCount | is the min count of segments to approximate. Default = 0 to do not force a min count. |
void TransformRingToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
const wxPoint & | aCentre, | ||
int | aRadius, | ||
int | aWidth, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
Convert arcs to multiple straight segments.
aCornerBuffer | is a buffer to store the polygon. |
aCentre | is the center of the arc or circle. |
aRadius | is the radius of the circle. |
aWidth | is the width (thickness) of the ring. |
aError | is the internal units allowed for error in approximation. |
aErrorLoc | determines if the approximation error be placed outside or inside the polygon. |
void TransformRoundChamferedRectToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
const wxPoint & | aPosition, | ||
const wxSize & | aSize, | ||
double | aRotation, | ||
int | aCornerRadius, | ||
double | aChamferRatio, | ||
int | aChamferCorners, | ||
int | aInflate, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
Convert a rectangle with rounded corners and/or chamfered corners to a polygon.
Convert rounded corners arcs to multiple straight lines. This will generate at least 16 segments per circle.
aCornerBuffer | is a buffer to store the polygon. |
aPosition | is the coordinate of the center of the rectangle. |
aSize | is the size of the rectangle. |
aCornerRadius | is the radius of rounded corners (can be 0). |
aRotation | is the rotation in 0.1 degrees of the rectangle. |
aChamferRatio | is the ratio between smaller rect side and chamfer value. |
aChamferCorners | is the identifier of the corners to chamfer:
|
aInflate | is the (positive) shape inflation or 0 |
aError | is the IU allowed for error in approximation. |
aErrorLoc | determines if the approximation error be placed outside or inside the polygon. |
void TransformTrapezoidToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
const wxPoint & | aPosition, | ||
const wxSize & | aSize, | ||
double | aRotation, | ||
int | aDeltaX, | ||
int | aDeltaY, | ||
int | aInflate, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
Convert a rectangle or trapezoid to a polygon.
This will generate at least 16 segments per circle (when using inflate).
aCornerBuffer | is a buffer to store the polygon. |
aPosition | is the coordinate of the center of the rectangle. |
aSize | is the size of the rectangle. |
aDeltaX | is the delta for trapezoids in X direction |
aDeltaY | is the delta for trapezoids in Y direction |
aInflate | is the (positive) shape inflation or 0 |
aError | is the IU allowed for error in approximation. |
aErrorLoc | determines if the approximation error be placed outside or inside the polygon. |