diff --git a/include/geometry/shape_line_chain.h b/include/geometry/shape_line_chain.h index adcbef0248..7917b88571 100644 --- a/include/geometry/shape_line_chain.h +++ b/include/geometry/shape_line_chain.h @@ -74,15 +74,17 @@ public: * Constructor * Initializes an empty line chain. */ - SHAPE_LINE_CHAIN() : - SHAPE( SH_LINE_CHAIN ), m_closed( false ) + SHAPE_LINE_CHAIN() : SHAPE( SH_LINE_CHAIN ), m_closed( false ), m_width( 0 ) {} /** * Copy Constructor */ - SHAPE_LINE_CHAIN( const SHAPE_LINE_CHAIN& aShape ) : - SHAPE( SH_LINE_CHAIN ), m_points( aShape.m_points ), m_closed( aShape.m_closed ) + SHAPE_LINE_CHAIN( const SHAPE_LINE_CHAIN& aShape ) + : SHAPE( SH_LINE_CHAIN ), + m_points( aShape.m_points ), + m_closed( aShape.m_closed ), + m_width( aShape.m_width ) {} /** @@ -90,7 +92,7 @@ public: * Initializes a 2-point line chain (a single segment) */ SHAPE_LINE_CHAIN( const VECTOR2I& aA, const VECTOR2I& aB ) : - SHAPE( SH_LINE_CHAIN ), m_closed( false ) + SHAPE( SH_LINE_CHAIN ), m_closed( false ), m_width( 0 ) { m_points.resize( 2 ); m_points[0] = aA; @@ -98,7 +100,7 @@ public: } SHAPE_LINE_CHAIN( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC ) : - SHAPE( SH_LINE_CHAIN ), m_closed( false ) + SHAPE( SH_LINE_CHAIN ), m_closed( false ), m_width( 0 ) { m_points.resize( 3 ); m_points[0] = aA; @@ -107,7 +109,7 @@ public: } SHAPE_LINE_CHAIN( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC, const VECTOR2I& aD ) : - SHAPE( SH_LINE_CHAIN ), m_closed( false ) + SHAPE( SH_LINE_CHAIN ), m_closed( false ), m_width( 0 ) { m_points.resize( 4 ); m_points[0] = aA; @@ -119,7 +121,8 @@ public: SHAPE_LINE_CHAIN( const VECTOR2I* aV, int aCount ) : SHAPE( SH_LINE_CHAIN ), - m_closed( false ) + m_closed( false ), + m_width( 0 ) { m_points.resize( aCount ); @@ -127,9 +130,8 @@ public: m_points[i] = *aV++; } - SHAPE_LINE_CHAIN( const ClipperLib::Path& aPath ) : - SHAPE( SH_LINE_CHAIN ), - m_closed( true ) + SHAPE_LINE_CHAIN( const ClipperLib::Path& aPath ) + : SHAPE( SH_LINE_CHAIN ), m_closed( true ), m_width( 0 ) { m_points.reserve( aPath.size() ); @@ -174,6 +176,24 @@ public: return m_closed; } + /** + * Sets the width of all segments in the chain + * @param aWidth width in internal units + */ + void SetWidth( int aWidth ) + { + m_width = aWidth; + } + + /** + * Gets the current width of the segments in the chain + * @return width in internal units + */ + int Width() const + { + return m_width; + } + /** * Function SegmentCount() * @@ -299,8 +319,8 @@ public: BOX2I bbox; bbox.Compute( m_points ); - if( aClearance != 0 ) - bbox.Inflate( aClearance ); + if( aClearance != 0 || m_width != 0 ) + bbox.Inflate( aClearance + m_width ); return bbox; } @@ -684,6 +704,12 @@ private: /// is the line chain closed? bool m_closed; + /// Width of the segments (for BBox calculations in RTree) + /// TODO Adjust usage of SHAPE_LINE_CHAIN to account for where we need a width and where not + /// Alternatively, we could split the class into a LINE_CHAIN (no width) and SHAPE_LINE_CHAIN that derives from + /// SHAPE as well that does have a width. Not sure yet on the correct path. + int m_width; + /// cached bounding box BOX2I m_bbox; }; diff --git a/pcbnew/router/pns_line.h b/pcbnew/router/pns_line.h index c52f4343ae..b9c819462f 100644 --- a/pcbnew/router/pns_line.h +++ b/pcbnew/router/pns_line.h @@ -105,6 +105,7 @@ public: void SetShape( const SHAPE_LINE_CHAIN& aLine ) { m_line = aLine; + m_line.SetWidth( m_width ); } ///> Returns the shape of the line @@ -153,6 +154,7 @@ public: void SetWidth( int aWidth ) { m_width = aWidth; + m_line.SetWidth( aWidth ); } ///> Returns line width