26#ifndef __SHAPE_SEGMENT_H
27#define __SHAPE_SEGMENT_H
66 const BOX2I BBox(
int aClearance = 0 )
const override
76 bool Collide(
const SHAPE* aShape,
int aClearance = 0,
int* aActual =
nullptr,
77 VECTOR2I* aLocation =
nullptr )
const override
82 bool Collide(
const SEG& aSeg,
int aClearance = 0,
int* aActual =
nullptr,
83 VECTOR2I* aLocation =
nullptr )
const override
85 if( aSeg.
A == aSeg.
B )
86 return Collide( aSeg.
A, aClearance, aActual, aLocation );
88 int min_dist = (
m_width + 1 ) / 2 + aClearance;
91 if( dist_sq == 0 || dist_sq <
SEG::Square( min_dist ) )
94 *aLocation =
m_seg.NearestPoint( aSeg );
97 *aActual = std::max( 0, (
int) sqrt( dist_sq ) - (
m_width + 1 ) / 2 );
106 VECTOR2I* aLocation =
nullptr )
const override
108 int min_dist = (
m_width + 1 ) / 2 + aClearance;
111 if( dist_sq == 0 || dist_sq <
SEG::Square( min_dist ) )
114 *aLocation =
m_seg.NearestPoint( aP );
117 *aActual = std::max( 0, (
int) sqrt( dist_sq ) - (
m_width + 1 ) / 2 );
158 return m_seg.Center();
185 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.
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
VECTOR2I GetEnd() const override
EDA_ANGLE GetAngle() const
bool Is45Degree(EDA_ANGLE aTollerance=EDA_ANGLE(1.0, DEGREES_T)) const
SHAPE_SEGMENT(const VECTOR2I &aA, const VECTOR2I &aB, int aWidth=0)
VECTOR2I GetStart() const override
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.
int GetWidth() const override
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
int GetTotalLength() const
Get the total length of the segment, from tip to tip.
void SetWidth(int aWidth) override
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,...
static SHAPE_SEGMENT BySizeAndCenter(const VECTOR2I &aSize, const VECTOR2I &aCenter, const EDA_ANGLE &aRotation)
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,...
VECTOR2I GetCenter() const
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
SHAPE(SHAPE_TYPE aType)
Create an empty shape of type aType.
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.
VECTOR2< int32_t > VECTOR2I