26#ifndef __SHAPE_SEGMENT_H
27#define __SHAPE_SEGMENT_H
64 const BOX2I BBox(
int aClearance = 0 )
const override
74 bool Collide(
const SHAPE* aShape,
int aClearance = 0,
int* aActual =
nullptr,
75 VECTOR2I* aLocation =
nullptr )
const override
80 bool Collide(
const SEG& aSeg,
int aClearance = 0,
int* aActual =
nullptr,
81 VECTOR2I* aLocation =
nullptr )
const override
83 if( aSeg.
A == aSeg.
B )
84 return Collide( aSeg.
A, aClearance, aActual, aLocation );
86 int min_dist = (
m_width + 1 ) / 2 + aClearance;
89 if( dist_sq == 0 || dist_sq <
SEG::Square( min_dist ) )
95 *aActual = std::max( 0, (
int) sqrt( dist_sq ) - (
m_width + 1 ) / 2 );
104 VECTOR2I* aLocation =
nullptr )
const override
106 int min_dist = (
m_width + 1 ) / 2 + aClearance;
109 if( dist_sq == 0 || dist_sq <
SEG::Square( min_dist ) )
115 *aActual = std::max( 0, (
int) sqrt( dist_sq ) - (
m_width + 1 ) / 2 );
162 virtual const std::string
Format(
bool aCplusPlus =
true )
const override;
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
ecoord SquaredDistance(const SEG &aSeg) const
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
static SEG::ecoord Square(int a)
Represent a set of closed polygons.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
const SEG & GetSeg() const
bool IsSolid() const override
bool Is45Degree(EDA_ANGLE aTollerance=EDA_ANGLE(1.0, DEGREES_T)) const
SHAPE_SEGMENT(const VECTOR2I &aA, const VECTOR2I &aB, int aWidth=0)
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
SHAPE * Clone() const override
Return a dynamically allocated copy of the shape.
bool Collide(const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance,...
SHAPE_SEGMENT(const SEG &aSeg, int aWidth=0)
void Move(const VECTOR2I &aVector) override
virtual const std::string Format(bool aCplusPlus=true) const override
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aError, ERROR_LOC aErrorLoc) const override
Fills a SHAPE_POLY_SET with a polygon representation of this shape.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
void SetSeg(const SEG &aSeg)
bool Collide(const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
void SetWidth(int aWidth)
bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
An abstract shape on 2D plane.
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
VECTOR2I::extended_type ecoord
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.