31#include <geometry/seg.h>
32#include <math/vector2d.h>
55static inline wxString SHAPE_TYPE_asString( SHAPE_TYPE a )
59 case SH_RECT:
return wxT(
"SH_RECT" );
60 case SH_SEGMENT:
return wxT(
"SH_SEGMENT" );
61 case SH_LINE_CHAIN:
return wxT(
"SH_LINE_CHAIN" );
62 case SH_CIRCLE:
return wxT(
"SH_CIRCLE" );
63 case SH_SIMPLE:
return wxT(
"SH_SIMPLE" );
64 case SH_POLY_SET:
return wxT(
"SH_POLY_SET" );
65 case SH_COMPOUND:
return wxT(
"SH_COMPOUND" );
66 case SH_ARC:
return wxT(
"SH_ARC" );
67 case SH_NULL:
return wxT(
"SH_NULL" );
68 case SH_POLY_SET_TRIANGLE:
return wxT(
"SH_POLY_SET_TRIANGLE" );
99 virtual bool HasIndexableSubshapes()
const
104 virtual size_t GetIndexableSubshapeCount()
const {
return 0; }
106 virtual void GetIndexableSubshapes( std::vector<SHAPE*>& aSubshapes ) { }
166 VECTOR2I* aLocation =
nullptr )
const
168 return Collide(
SEG( aP, aP ), aClearance, aActual, aLocation );
186 virtual bool Collide(
const SHAPE* aShape,
int aClearance = 0,
int* aActual =
nullptr,
187 VECTOR2I* aLocation =
nullptr )
const;
199 virtual bool Collide(
const SEG& aSeg,
int aClearance = 0,
int* aActual =
nullptr,
200 VECTOR2I* aLocation =
nullptr )
const = 0;
209 virtual const BOX2I BBox(
int aClearance = 0 )
const = 0;
218 return BBox( 0 ).Centre();
227 virtual void Move(
const VECTOR2I& aVector ) = 0;
229 virtual bool IsSolid()
const = 0;
231 virtual bool Parse( std::stringstream& aStream );
233 virtual const std::string Format( )
const;
236 typedef VECTOR2I::extended_type ecoord;
261 virtual bool Collide(
const VECTOR2I& aP,
int aClearance = 0,
int* aActual =
nullptr,
262 VECTOR2I* aLocation =
nullptr )
const override;
274 virtual bool Collide(
const SEG& aSeg,
int aClearance = 0,
int* aActual =
nullptr,
275 VECTOR2I* aLocation =
nullptr )
const override;
277 SEG::ecoord SquaredDistance(
const VECTOR2I& aP,
bool aOutlineOnly =
false )
const;
288 bool PointInside(
const VECTOR2I& aPt,
int aAccuracy = 0,
bool aUseBBoxCache =
false )
const;
306 virtual const VECTOR2I GetPoint(
int aIndex )
const = 0;
307 virtual const SEG GetSegment(
int aIndex )
const = 0;
308 virtual size_t GetPointCount()
const = 0;
309 virtual size_t GetSegmentCount()
const = 0;
310 virtual bool IsClosed()
const = 0;
312 virtual BOX2I* GetCachedBBox()
const {
return nullptr; }
SHAPE_BASE(SHAPE_TYPE aType)
Create an empty shape of type aType.
Definition shape.h:82
SHAPE_TYPE m_type
< type of our shape
Definition shape.h:110
SHAPE_TYPE Type() const
Return the type of the shape.
Definition shape.h:94
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const
Check if point aP lies inside a polygon (any type) defined by the line chain.
Definition shape_line_chain.cpp:1535
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:301
bool PointOnEdge(const VECTOR2I &aP, int aAccuracy=0) const
Check if point aP lies on an edge or vertex of the line chain.
Definition shape_line_chain.cpp:1587
int EdgeContainingPoint(const VECTOR2I &aP, int aAccuracy=0) const
Check if point aP lies on an edge or vertex of the line chain.
Definition shape_line_chain.cpp:1593
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
An abstract shape on 2D plane.
Definition shape.h:117
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,...
Definition shape.h:165
virtual VECTOR2I Centre() const
Compute a center-of-mass of the shape.
Definition shape.h:216
SHAPE(SHAPE_TYPE aType)
Create an empty shape of type aType.
Definition shape.h:127
static const int MIN_PRECISION_IU
This is the minimum precision for all the points in a shape.
Definition shape.h:122
bool IsNull() const
Return true if the shape is a null shape.
Definition shape.h:150
virtual SHAPE * Clone() const
Return a dynamically allocated copy of the shape.
Definition shape.h:139
virtual bool Collide(const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const =0
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance,...
virtual const BOX2I BBox(int aClearance=0) const =0
Compute a bounding box of the shape, with a margin of aClearance a collision.
virtual void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 })=0
Definition wx_compat.h:13