KiCad PCB EDA Suite
Loading...
Searching...
No Matches
polygon_generator.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) 2017 CERN
5 * @author Tomasz Wlostowski <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
25
27
29
30#include <board.h>
31#include <footprint.h>
32#include <pad.h>
33#include <pcb_track.h>
34#include <zone.h>
35
36
37void process( const BOARD_CONNECTED_ITEM* item, int net )
38{
39 if( item->GetNetCode() != net )
40 return;
41
42 SHAPE_POLY_SET pset;
43
45
46 SHAPE_FILE_IO shapeIo; // default = stdout
47 shapeIo.Write( &pset );
48}
49
50
55
56
57int polygon_gererator_main( int argc, char* argv[] )
58{
59 if( argc < 2 )
61
62 std::string filename;
63
64 if( argc > 1 )
65 filename = argv[1];
66
67 auto brd = KI_TEST::ReadBoardFromFileOrStream( filename );
68
69 if( !brd )
71
72 for( unsigned net = 0; net < brd->GetNetCount(); net++ )
73 {
74 for( PCB_TRACK* track : brd->Tracks() )
75 process( track, net );
76
77 for( FOOTPRINT* fp : brd->Footprints() )
78 {
79 for( PAD* pad : fp->Pads() )
80 process( pad, net );
81 }
82
83 for( ZONE* zone : brd->Zones() )
84 process( zone, net );
85 }
86
88}
89
90
92 "polygon_generator",
93 "Dump board geometry as a set of polygons",
95} );
@ ERROR_OUTSIDE
General utilities for PCB file IO for QA programs.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
int GetMaxError() const
Definition pad.h:61
Helper class for saving/loading shapes from a file.
void Write(const SHAPE *aShape, const std::string &aName="<noname>")
Represent a set of closed polygons.
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
static bool registered
@ UNDEFINED_LAYER
Definition layer_ids.h:57
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
@ OK
Tool exited OK.
@ TOOL_SPECIFIC
Tools can define their own statuses from here onwards.
@ BAD_CMDLINE
The command line was not correct for the tool.
static PGM_BASE * process
int polygon_gererator_main(int argc, char *argv[])
POLY_GEN_RET_CODES
@ LOAD_FAILED