24#ifndef __SHAPE_SIMPLE_H
25#define __SHAPE_SIMPLE_H
27#include <geometry/seg.h>
28#include <geometry/shape.h>
29#include <geometry/shape_line_chain.h>
31#include <math/vector2d.h>
78 const BOX2I BBox(
int aClearance = 0 )
const override
80 return m_points.
BBox( aClearance );
104 return m_points.
CPoint( aIndex );
152 bool Collide(
const SEG& aSeg,
int aClearance = 0,
int* aActual =
nullptr,
153 VECTOR2I* aLocation =
nullptr )
const override
155 return m_points.
Collide( aSeg, aClearance, aActual, aLocation );
160 m_points.
Rotate( aAngle, aCenter );
163 void Move(
const VECTOR2I& aVector )
override
165 m_points.Move( aVector );
168 bool IsSolid()
const override
173 virtual const VECTOR2I GetPoint(
int aIndex )
const override {
return m_points.
CPoint(aIndex); }
174 virtual const SEG GetSegment(
int aIndex )
const override {
return m_points.
CSegment(aIndex); }
175 virtual size_t GetPointCount()
const override {
return m_points.
PointCount(); }
176 virtual size_t GetSegmentCount()
const override {
return m_points.
SegmentCount(); }
178 bool IsClosed()
const override
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Definition shape_line_chain.h:81
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
Definition shape_line_chain.h:256
int PointCount() const
Return the number of points (vertices) in this line chain.
Definition shape_line_chain.h:318
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if point aP lies closer to us than aClearance.
Definition shape_line_chain.cpp:354
void Clear()
Remove all points from the line chain.
Definition shape_line_chain.h:242
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Definition shape_line_chain.h:495
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Definition shape_line_chain.h:393
int SegmentCount() const
Return the number of segments in this line chain.
Definition shape_line_chain.h:295
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
Definition shape_line_chain.h:348
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Definition shape_line_chain.h:433
void Rotate(double aAngle, const VECTOR2I &aCenter=VECTOR2I(0, 0)) override
Rotate all vertices by a given angle.
Definition shape_line_chain.cpp:423
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition shape_simple.h:42
void Clear()
Remove all points from the polygon.
Definition shape_simple.h:72
const SHAPE_LINE_CHAIN & Vertices() const
Return the list of vertices defining this simple polygon.
Definition shape_simple.h:124
void Append(int aX, int aY)
Append a new point at the end of the polygon.
Definition shape_simple.h:135
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Definition shape_simple.h:158
SHAPE * Clone() const override
Return a dynamically allocated copy of the shape.
Definition shape_simple.h:64
const VECTOR2I & CPoint(int aIndex) const
Return a const reference to a given point in the polygon.
Definition shape_simple.h:102
int PointCount() const
Return the number of points (vertices) in this polygon.
Definition shape_simple.h:88
void Append(const VECTOR2I &aP)
Append a new point at the end of the polygon.
Definition shape_simple.h:146
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 point aP than aClearance,...
Definition shape_simple.h:152
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Definition shape_simple.h:78
const VECTOR2D CDPoint(int aIndex) const
Return a given point as a vector with elements of type double.
Definition shape_simple.h:113
SHAPE_SIMPLE()
Create an empty polygon.
Definition shape_simple.h:47
An abstract shape on 2D plane.
Definition shape.h:117