altium: Parse keepout restrictions of tracks

This commit is contained in:
Thomas Pointhuber 2022-03-07 19:58:43 +01:00
parent 6196f2bdf0
commit a9ebb42ecd
5 changed files with 51 additions and 26 deletions

View File

@ -853,6 +853,16 @@ ATRACK6::ATRACK6( ALTIUM_PARSER& aReader )
end = aReader.ReadVector2I();
width = aReader.ReadKicadUnit();
if( aReader.GetRemainingSubrecordBytes() >= 13 )
{
aReader.Skip( 12 );
keepoutrestrictions = aReader.Read<uint8_t>();
}
else
{
keepoutrestrictions = is_keepout ? 0x1F : 0;
}
aReader.SkipSubrecord();
if( aReader.HasParsingError() )

View File

@ -656,6 +656,7 @@ struct ATRACK6
uint16_t net;
uint16_t component;
uint16_t subpolyindex;
uint8_t keepoutrestrictions;
VECTOR2I start;
VECTOR2I end;

View File

@ -2903,7 +2903,7 @@ void ALTIUM_PCB::ConvertTracks6ToBoardItem( const ATRACK6& aElem, const int aPri
shape.SetEnd( aElem.end );
shape.SetStroke( STROKE_PARAMS( aElem.width, PLOT_DASH_TYPE::SOLID ) );
HelperPcpShapeAsBoardKeepoutRegion( shape, aElem.layer );
HelperPcpShapeAsBoardKeepoutRegion( shape, aElem.layer, aElem.keepoutrestrictions );
}
else
{
@ -2947,7 +2947,8 @@ void ALTIUM_PCB::ConvertTracks6ToFootprintItem( FOOTPRINT* aFootprint, const ATR
shape.SetEnd( aElem.end );
shape.SetStroke( STROKE_PARAMS( aElem.width, PLOT_DASH_TYPE::SOLID ) );
HelperPcpShapeAsFootprintKeepoutRegion( aFootprint, shape, aElem.layer );
HelperPcpShapeAsFootprintKeepoutRegion( aFootprint, shape, aElem.layer,
aElem.keepoutrestrictions );
}
else
{
@ -3443,19 +3444,32 @@ void ALTIUM_PCB::HelperSetZoneLayers( ZONE* aZone, const ALTIUM_LAYER aAltiumLay
}
void ALTIUM_PCB::HelperPcpShapeAsBoardKeepoutRegion( const PCB_SHAPE& aShape,
ALTIUM_LAYER aAltiumLayer )
void ALTIUM_PCB::HelperSetZoneKeepoutRestrictions( ZONE* aZone, const uint8_t aKeepoutRestrictions )
{
bool keepoutRestrictionVia = ( aKeepoutRestrictions & 0x01 ) != 0;
bool keepoutRestrictionTrack = ( aKeepoutRestrictions & 0x02 ) != 0;
bool keepoutRestrictionCopper = ( aKeepoutRestrictions & 0x04 ) != 0;
bool keepoutRestrictionSMDPad = ( aKeepoutRestrictions & 0x08 ) != 0;
bool keepoutRestrictionTHPad = ( aKeepoutRestrictions & 0x10 ) != 0;
aZone->SetDoNotAllowVias( keepoutRestrictionVia );
aZone->SetDoNotAllowTracks( keepoutRestrictionTrack );
aZone->SetDoNotAllowCopperPour( keepoutRestrictionCopper );
aZone->SetDoNotAllowPads( keepoutRestrictionSMDPad && keepoutRestrictionTHPad );
aZone->SetDoNotAllowFootprints( false );
}
void ALTIUM_PCB::HelperPcpShapeAsBoardKeepoutRegion( const PCB_SHAPE& aShape,
const ALTIUM_LAYER aAltiumLayer,
const uint8_t aKeepoutRestrictions )
{
ZONE* zone = new ZONE( m_board );
zone->SetIsRuleArea( true );
zone->SetDoNotAllowTracks( false );
zone->SetDoNotAllowVias( false );
zone->SetDoNotAllowPads( false );
zone->SetDoNotAllowFootprints( false );
zone->SetDoNotAllowCopperPour( true );
HelperSetZoneLayers( zone, aAltiumLayer );
HelperSetZoneKeepoutRestrictions( zone, aKeepoutRestrictions );
aShape.EDA_SHAPE::TransformShapeWithClearanceToPolygon( *zone->Outline(), 0, ARC_HIGH_DEF,
ERROR_INSIDE, false );
@ -3467,20 +3481,17 @@ void ALTIUM_PCB::HelperPcpShapeAsBoardKeepoutRegion( const PCB_SHAPE& aShape,
}
void ALTIUM_PCB::HelperPcpShapeAsFootprintKeepoutRegion( FOOTPRINT* aFootprint,
const PCB_SHAPE& aShape,
ALTIUM_LAYER aAltiumLayer )
void ALTIUM_PCB::HelperPcpShapeAsFootprintKeepoutRegion( FOOTPRINT* aFootprint,
const PCB_SHAPE& aShape,
const ALTIUM_LAYER aAltiumLayer,
const uint8_t aKeepoutRestrictions )
{
FP_ZONE* zone = new FP_ZONE( aFootprint );
zone->SetIsRuleArea( true );
zone->SetDoNotAllowTracks( false );
zone->SetDoNotAllowVias( false );
zone->SetDoNotAllowPads( false );
zone->SetDoNotAllowFootprints( false );
zone->SetDoNotAllowCopperPour( true );
HelperSetZoneLayers( zone, aAltiumLayer );
HelperSetZoneKeepoutRestrictions( zone, aKeepoutRestrictions );
aShape.EDA_SHAPE::TransformShapeWithClearanceToPolygon( *zone->Outline(), 0, ARC_HIGH_DEF,
ERROR_INSIDE, false );

View File

@ -220,9 +220,13 @@ private:
void HelperCreateBoardOutline( const std::vector<ALTIUM_VERTICE>& aVertices );
void HelperSetZoneLayers( ZONE* aZone, const ALTIUM_LAYER aAltiumLayer );
void HelperPcpShapeAsBoardKeepoutRegion( const PCB_SHAPE& aShape, ALTIUM_LAYER aAltiumLayer );
void HelperSetZoneKeepoutRestrictions( ZONE* aZone, const uint8_t aKeepoutRestrictions );
void HelperPcpShapeAsBoardKeepoutRegion( const PCB_SHAPE& aShape,
const ALTIUM_LAYER aAltiumLayer,
const uint8_t aKeepoutRestrictions = 0x1F );
void HelperPcpShapeAsFootprintKeepoutRegion( FOOTPRINT* aFootprint, const PCB_SHAPE& aShape,
ALTIUM_LAYER aAltiumLayer );
const ALTIUM_LAYER aAltiumLayer,
const uint8_t aKeepoutRestrictions = 0x1F );
std::vector<std::pair<PCB_LAYER_ID, int>>
HelperGetSolderAndPasteMaskExpansions( const ALTIUM_RECORD aType, const int aPrimitiveIndex,

View File

@ -1,20 +1,19 @@
(footprint "KEEPOUT" (version 20220131) (generator pcbnew)
(footprint "KEEPOUT" (version 20220225) (generator pcbnew)
(layer "F.Cu")
(tedit 0)
(descr "Keepouyt via/track/copper/smd/th")
(fp_text reference "REF**" (at 0 0) (layer "F.SilkS")
(effects (font (size 1.27 1.27) (thickness 0.15)))
(tstamp d92cfbfa-da4b-4f63-8ad6-7bb6977d4f44)
(tstamp 050ccb9c-c92e-4885-96ad-3c8ee62baa70)
)
(fp_text value "KEEPOUT" (at 0 0) (layer "F.SilkS")
(effects (font (size 1.27 1.27) (thickness 0.15)))
(tstamp e6a27cb0-d090-4b8c-9a7b-e787b9ea11b6)
(tstamp df48a6c9-82c3-4d2f-b81e-04590b6597d8)
)
(zone (net 0) (net_name "") (layer "F.Cu") (tstamp 66f97120-6c7e-441a-9997-acbf3e610e6e) (hatch edge 0.508)
(zone (net 0) (net_name "") (layer "F.Cu") (tstamp 3655f956-9a76-438c-8e5d-c0f5921a3841) (hatch edge 0.508)
(connect_pads (clearance 0))
(min_thickness 0.254) (filled_areas_thickness no)
(keepout (tracks allowed) (vias allowed) (pads allowed ) (copperpour not_allowed) (footprints allowed))
(fill (thermal_gap 0.508) (thermal_bridge_width 0.508))
(keepout (tracks not_allowed) (vias not_allowed) (pads not_allowed ) (copperpour not_allowed) (footprints allowed))
(fill (thermal_gap 0.508) (thermal_bridge_width 0.508) (island_removal_mode 2) (island_area_min 10))
(polygon
(pts
(xy 5.140866 -0.479746)