25 #include <math/vector2d.h>
27 #include <geometry/direction45.h>
28 #include <geometry/seg.h>
29 #include <geometry/shape.h>
30 #include <geometry/shape_line_chain.h>
58 #define PNS_HULL_MARGIN 10
60 class LINE :
public ITEM
63 typedef std::vector<SEGMENT*> SEGMENT_REFS;
85 m_width( aBase.m_width )
88 m_layers = aBase.m_layers;
94 static inline bool ClassOf(
const ITEM* aItem )
96 return aItem && LINE_T == aItem->
Kind();
102 LINE& operator=(
const LINE& aOther );
144 return m_line.
CPoint( aIdx );
178 m_segmentRefs.push_back( aSeg );
185 return m_segmentRefs;
188 bool IsLinked()
const
190 return m_segmentRefs.size() != 0;
193 bool IsLinkedChecked()
const
201 return std::find( m_segmentRefs.begin(), m_segmentRefs.end(),
202 aSeg ) != m_segmentRefs.end();
205 SEGMENT* GetLink(
int aIndex )
const
207 return m_segmentRefs[aIndex];
216 return m_segmentRefs.size();
245 bool Is45Degree()
const;
250 bool EndsWithVia()
const {
return m_hasVia; }
252 void AppendVia(
const VIA& aVia );
253 void RemoveVia() { m_hasVia =
false; }
255 const VIA& Via()
const {
return m_via; }
257 virtual void Mark(
int aMarker )
override;
258 virtual void Unmark(
int aMarker = -1 )
override;
259 virtual int Marker()
const override;
261 void DragSegment(
const VECTOR2I& aP,
int aIndex,
int aSnappingThreshold = 0,
bool aFreeAngle =
false );
262 void DragCorner(
const VECTOR2I& aP,
int aIndex,
int aSnappingThreshold = 0,
bool aFreeAngle =
false );
264 void SetRank(
int aRank )
override;
265 int Rank()
const override;
267 bool HasLoops()
const;
268 bool HasLockedSegments()
const;
270 OPT_BOX2I ChangedArea(
const LINE* aOther )
const;
274 void dragSegment45(
const VECTOR2I& aP,
int aIndex,
int aSnappingThreshold );
275 void dragCorner45(
const VECTOR2I& aP,
int aIndex,
int aSnappingThreshold );
276 void dragSegmentFree(
const VECTOR2I& aP,
int aIndex,
int aSnappingThreshold );
277 void dragCornerFree(
const VECTOR2I& aP,
int aIndex,
int aSnappingThreshold );
280 int aIndex,
int aThreshold)
const;
283 int aIndex,
int aThreshold )
const;
286 void copyLinks(
const LINE* aParent ) ;
290 SEGMENT_REFS m_segmentRefs;
307 #endif // __PNS_LINE_H
Definition: pns_line.h:61
void SetWidth(int aWidth)
Sets the width of all segments in the chain.
Definition: shape_line_chain.h:183
bool Walkaround(SHAPE_LINE_CHAIN aObstacle, SHAPE_LINE_CHAIN &aPre, SHAPE_LINE_CHAIN &aWalk, SHAPE_LINE_CHAIN &aPost, bool aCw) const
Calculates a line thightly wrapping a convex hull of an obstacle object (aObstacle).
void LinkSegment(SEGMENT *aSeg)
Adds a reference to a segment registered in a NODE that is a part of this line.
Definition: pns_line.h:176
int CountCorners(int aAngles) const
Returns the number of corners of angles specified by mask aAngles.
const SHAPE_LINE_CHAIN & CLine() const
Const accessor to the underlying shape
Definition: pns_line.h:124
Definition: pns_segment.h:39
int SegmentCount() const
Function SegmentCount()
Definition: shape_line_chain.h:203
const SEG CSegment(int aIndex) const
Function CSegment()
Definition: shape_line_chain.h:250
const VECTOR2I & CPoint(int aIdx) const
Returns the aIdx-th point of the line
Definition: pns_line.h:142
void SetShape(const SHAPE_LINE_CHAIN &aLine)
Assigns a shape to the line (a polyline/line chain)
Definition: pns_line.h:105
virtual LINE * Clone() const override
Function Clone()
void Reverse()
Reverses the point/vertex order
const LINE ClipToNearestObstacle(NODE *aNode) const
Clips the line to the nearest obstacle, traversing from the line's start vertex (0).
void SetWidth(int aWidth)
Sets line width
Definition: pns_line.h:154
void ClipVertexRange(int aStart, int aEnd)
Clips the line to a given range of vertices.
int PointCount() const
Returns the number of points in the line
Definition: pns_line.h:136
const SHAPE * Shape() const override
Returns the shape of the line
Definition: pns_line.h:112
int PointCount() const
Function PointCount()
Definition: shape_line_chain.h:218
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
Definition: shape_line_chain.h:285
bool ContainsSegment(SEGMENT *aSeg) const
Checks if the segment aSeg is a part of the line.
Definition: pns_line.h:199
Class ITEM.
Definition: pns_item.h:55
void ClearSegmentLinks()
Erases the linking information. Used to detach the line from the owning node.
SEGMENT_REFS & LinkedSegments()
Returns the list of segments from the owning node that constitute this line (or NULL if the line is n...
Definition: pns_line.h:183
SHAPE_LINE_CHAIN & Line()
Modifiable accessor to the underlying shape
Definition: pns_line.h:118
void ShowLinks() const
Prints out all linked segments
Class NODE.
Definition: pns_node.h:138
Class SHAPE_LINE_CHAIN.
Definition: shape_line_chain.h:50
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:123
Class SHAPE.
Definition: shape.h:59
LINE(const LINE &aBase, const SHAPE_LINE_CHAIN &aLine)
Constructor Copies properties (net, layers, etc.) from a base line and replaces the shape by another.
Definition: pns_line.h:82
int LinkCount() const
Returns the number of segments that were assembled together to form this line.
Definition: pns_line.h:214
bool CompareGeometry(const LINE &aOther)
Returns true if the line is geometrically identical as line aOther
LINE()
Constructor Makes an empty line.
Definition: pns_line.h:69
int Width() const
Returns line width
Definition: pns_line.h:161
int SegmentCount() const
Returns the number of segments in the line
Definition: pns_line.h:130
const SEG CSegment(int aIdx) const
Returns the aIdx-th segment of the line
Definition: pns_line.h:148