KiCad PCB EDA Suite
polygon_generator.cpp File Reference
#include <geometry/shape_file_io.h>
#include <geometry/shape_line_chain.h>
#include <geometry/shape_poly_set.h>
#include <pcbnew_utils/board_file_utils.h>
#include <qa_utils/utility_registry.h>
#include <board.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_track.h>
#include <zone.h>

Go to the source code of this file.

Enumerations

enum  POLY_GEN_RET_CODES { LOAD_FAILED = KI_TEST::RET_CODES::TOOL_SPECIFIC }
 

Functions

void process (const BOARD_CONNECTED_ITEM *item, int net)
 
int polygon_gererator_main (int argc, char *argv[])
 

Variables

static bool registered
 

Enumeration Type Documentation

◆ POLY_GEN_RET_CODES

Enumerator
LOAD_FAILED 

Definition at line 56 of file polygon_generator.cpp.

57 {
59 };
Tools can define their own statuses from here onwards.

Function Documentation

◆ polygon_gererator_main()

int polygon_gererator_main ( int  argc,
char *  argv[] 
)

Definition at line 62 of file polygon_generator.cpp.

63 {
64  if( argc < 2 )
66 
67  std::string filename;
68 
69  if( argc > 1 )
70  filename = argv[1];
71 
72  auto brd = KI_TEST::ReadBoardFromFileOrStream( filename );
73 
74  if( !brd )
76 
77  for( unsigned net = 0; net < brd->GetNetCount(); net++ )
78  {
79  for( PCB_TRACK* track : brd->Tracks() )
80  process( track, net );
81 
82  for( FOOTPRINT* fp : brd->Footprints() )
83  {
84  for( PAD* pad : fp->Pads() )
85  process( pad, net );
86  }
87 
88  for( ZONE* zone : brd->Zones() )
89  process( zone, net );
90  }
91 
93 }
#define OK
The command line was not correct for the tool.
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
void process(const BOARD_CONNECTED_ITEM *item, int net)
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
Definition: pad.h:57

References KI_TEST::BAD_CMDLINE, LOAD_FAILED, OK, pad, process(), and KI_TEST::ReadBoardFromFileOrStream().

◆ process()

void process ( const BOARD_CONNECTED_ITEM item,
int  net 
)

Definition at line 41 of file polygon_generator.cpp.

42 {
43  if( item->GetNetCode() != net )
44  return;
45 
46  SHAPE_POLY_SET pset;
47 
48  item->TransformShapeWithClearanceToPolygon( pset, UNDEFINED_LAYER, 1, ARC_HIGH_DEF,
49  ERROR_OUTSIDE );
50 
51  SHAPE_FILE_IO shapeIo; // default = stdout
52  shapeIo.Write( &pset );
53 }
Helper class for saving/loading shapes from a file.
Definition: shape_file_io.h:39
Represent a set of closed polygons.
void Write(const SHAPE *aShape, const std::string &aName="<noname>")
virtual void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
Definition: board_item.cpp:142

References ERROR_OUTSIDE, BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_ITEM::TransformShapeWithClearanceToPolygon(), UNDEFINED_LAYER, and SHAPE_FILE_IO::Write().

Referenced by CONVERT_TOOL::makePolysFromSegs(), and polygon_gererator_main().

Variable Documentation

◆ registered

bool registered
static
Initial value:
"polygon_generator",
"Dump board geometry as a set of polygons",
} )
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
int polygon_gererator_main(int argc, char *argv[])

Definition at line 96 of file polygon_generator.cpp.