KiCad PCB EDA Suite
create_layer_poly.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
31 #include "board_adapter.h"
33 #include <class_edge_mod.h>
34 #include <class_module.h>
35 
36 
38  SHAPE_POLY_SET& aCornerBuffer,
39  int aWidth ) const
40 {
41  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
42  {
43  TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(), aPad->GetSize().x / 2,
44  ARC_HIGH_DEF, aWidth );
45  return;
46  }
47 
48  // For other shapes, add outlines as thick segments in polygon buffer
49  const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
50  const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
51 
52  for( int ii = 0; ii < path.PointCount(); ++ii )
53  {
54  const VECTOR2I& a = path.CPoint( ii );
55  const VECTOR2I& b = path.CPoint( ii + 1 );
56 
57  TransformSegmentToPolygon( aCornerBuffer, wxPoint( a.x, a.y ), wxPoint( b.x, b.y ),
58  ARC_HIGH_DEF, aWidth );
59  }
60 }
61 
62 
64  PCB_LAYER_ID aLayer,
65  SHAPE_POLY_SET& aCornerBuffer ) const
66 {
67  for( BOARD_ITEM* item : aModule->GraphicalItems() )
68  {
69  if( item->Type() == PCB_MODULE_EDGE_T )
70  {
71  EDGE_MODULE* outline = (EDGE_MODULE*) item;
72 
73  if( outline->GetLayer() == aLayer )
74  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0 );
75  }
76  }
77 }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID=UNDEFINED_LAYER) const
Definition: class_pad.cpp:258
DRAWINGS & GraphicalItems()
Definition: class_module.h:183
int PointCount() const
Function PointCount()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
const VECTOR2I & CPoint(int aIndex) const
Function Point()
PCB_LAYER_ID
A quick note on layer IDs:
SHAPE_POLY_SET.
void buildPadShapeThickOutlineAsPolygon(const D_PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
void transformGraphicModuleEdgeToPolygonSet(const MODULE *aModule, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer) const
SHAPE_LINE_CHAIN.
wxPoint ShapePos() const
Definition: class_pad.cpp:608
void TransformSegmentToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aError, int aWidth)
Function TransformRoundedEndsSegmentToPolygon convert a segment with rounded ends to a polygon Conver...
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aError, int aWidth)
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segme...
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:157
const wxSize & GetSize() const
Definition: class_pad.h:224
EDGE_MODULE class definition.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...