Skip to content

Commit

Permalink
fix: Non-GND solid regions are missing after conversion #17
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Feb 4, 2020
1 parent 31e8d0a commit 408b36e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/board.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('convertSolidRegion', () => {
'gge40',
'0'
],
[]
['L3_2']
)
).toEqual([
'zone',
Expand Down Expand Up @@ -458,7 +458,7 @@ describe('convertLib()', () => {
]);
});

it('should not crash if SOLIDREGION contains an arc (issue #20)', () => {
it('should not crash if SOLIDREGION contains an arc (issue #15)', () => {
const input =
'LIB~4401~3164~package`IEC_HIGHVOLTAGE_SMALL`~~~gge846~1~~~0~#@$#@$SOLIDREGION~3~~M 4513.5 3294 A 12.125 12.125 0 0 1 4495.5 3294 Z ~solid~gge636~~~~0';

Expand Down
45 changes: 32 additions & 13 deletions src/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,23 +424,42 @@ export function convertCopperArea(args: string[], nets: string[]) {

export function convertSolidRegion(args: string[], nets: string[]) {
const [layerId, net, path, type, id, locked] = args;
if (type !== 'cutout') {
console.warn(`Warning: unsupported SOLIDREGION type ${type}`);
return null;
}
const polygonPoints = pathToPolygon(path);
const netId = nets.indexOf(net);
if (!polygonPoints) {
return null;
}
return [
'zone',
['net', 0],
['net_name', ''],
['hatch', 'edge', 0.508],
['layer', getLayerName(layerId)],
['keepout', ['tracks', 'not_allowed'], ['vias', 'not_allowed'], ['copperpour', 'not_allowed']],
['polygon', ['pts', ...polygonPoints]]
];
switch (type) {
case 'cutout':
return [
'zone',
['net', netId],
['net_name', ''],
['hatch', 'edge', 0.508],
['layer', getLayerName(layerId)],
[
'keepout',
['tracks', 'not_allowed'],
['vias', 'not_allowed'],
['copperpour', 'not_allowed']
],
['polygon', ['pts', ...polygonPoints]]
];

case 'solid':
return [
'gr_poly',
// Unfortunately, KiCad does not support net for gr_poly
// ['net', netId],
['pts', ...polygonPoints],
['layer', getLayerName(layerId)],
['width', 0]
];

default:
console.warn(`Warning: unsupported SOLIDREGION type ${type}`);
return null;
}
}

function convertShape(shape: string, nets: string[]) {
Expand Down

0 comments on commit 408b36e

Please sign in to comment.