7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 20:59:17 +00:00

Name shortening and line-break reduction.

This commit is contained in:
Jeff Young 2022-10-21 13:48:45 +01:00
parent 209ff933e7
commit d16b23d16e
57 changed files with 555 additions and 706 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -367,11 +367,10 @@ private:
void buildPadOutlineAsSegments( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer, int aWidth );
// Helper functions to create poly contours
void buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aCornerBuffer,
int aWidth) const;
void buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aBuffer, int aWidth) const;
void transformFPShapesToPolygon( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer ) const;
void transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aBuffer ) const;
public:
static CUSTOM_COLORS_LIST g_SilkscreenColors;

View File

@ -94,7 +94,7 @@ void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContaine
int margin = attrs.m_StrokeWidth * 1.5 +
GetKnockoutTextMargin( attrs.m_Size, attrs.m_StrokeWidth );
aText->TransformBoundingBoxWithClearanceToPolygon( &finalPoly, margin );
aText->TransformBoundingBoxToPolygon( &finalPoly, margin );
finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
@ -328,7 +328,7 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
PAD dummy( *aPad );
dummy.SetSize( wxSize( dummySize.x, dummySize.y ) );
dummy.TransformShapeWithClearanceToPolygon( poly, aLayer, 0, maxError, ERROR_INSIDE );
dummy.TransformShapeToPolygon( poly, aLayer, 0, maxError, ERROR_INSIDE );
clearance = { 0, 0 };
}
else
@ -622,8 +622,8 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
{
SHAPE_POLY_SET polyList;
aShape->TransformShapeWithClearanceToPolygon( polyList, UNDEFINED_LAYER, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
aShape->TransformShapeToPolygon( polyList, UNDEFINED_LAYER, 0, ARC_HIGH_DEF,
ERROR_INSIDE );
polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
@ -671,8 +671,8 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
{
SHAPE_POLY_SET polyList;
aShape->TransformShapeWithClearanceToPolygon( polyList, UNDEFINED_LAYER, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
aShape->TransformShapeToPolygon( polyList, UNDEFINED_LAYER, 0, ARC_HIGH_DEF,
ERROR_INSIDE );
if( polyList.IsEmpty() ) // Just for caution
break;
@ -682,7 +682,7 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
break;
default:
wxFAIL_MSG( wxT( "BOARD_ADAPTER::addShapeWithClearance no implementation for " )
wxFAIL_MSG( wxT( "BOARD_ADAPTER::addShape no implementation for " )
+ aShape->SHAPE_T_asString() );
break;
}

View File

@ -153,6 +153,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
trackList.clear();
trackList.reserve( m_board->Tracks().size() );
int maxError = m_board->GetDesignSettings().m_MaxError;
for( PCB_TRACK* track : m_board->Tracks() )
{
if( !Is3dLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
@ -183,30 +185,30 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
m_averageViaHoleDiameter /= (float)m_viaCount;
// Prepare copper layers index and containers
std::vector<PCB_LAYER_ID> layer_id;
layer_id.clear();
layer_id.reserve( m_copperLayersCount );
std::vector<PCB_LAYER_ID> layer_ids;
layer_ids.clear();
layer_ids.reserve( m_copperLayersCount );
for( unsigned i = 0; i < arrayDim( cu_seq ); ++i )
cu_seq[i] = ToLAYER_ID( B_Cu - i );
for( LSEQ cu = cu_set.Seq( cu_seq, arrayDim( cu_seq ) ); cu; ++cu )
{
const PCB_LAYER_ID curr_layer_id = *cu;
const PCB_LAYER_ID layer = *cu;
if( !Is3dLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
if( !Is3dLayerEnabled( layer ) ) // Skip non enabled layers
continue;
layer_id.push_back( curr_layer_id );
layer_ids.push_back( layer );
BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
m_layerMap[curr_layer_id] = layerContainer;
m_layerMap[layer] = layerContainer;
if( m_Cfg->m_Render.opengl_copper_thickness
&& m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
{
SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET;
m_layers_poly[curr_layer_id] = layerPoly;
m_layers_poly[layer] = layerPoly;
}
}
@ -224,27 +226,22 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
aStatusReporter->Report( _( "Create tracks and vias" ) );
// Create tracks as objects and add it to container
for( PCB_LAYER_ID curr_layer_id : layer_id )
for( PCB_LAYER_ID layer : layer_ids )
{
wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
// Add track segments shapes and via annulus shapes
unsigned int nTracks = trackList.size();
for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
for( const PCB_TRACK* track : trackList )
{
const PCB_TRACK *track = trackList[trackIdx];
// NOTE: Vias can be on multiple layers
if( !track->IsOnLayer( curr_layer_id ) )
if( !track->IsOnLayer( layer ) )
continue;
// Skip vias annulus when not connected on this layer (if removing is enabled)
const PCB_VIA *via = dyn_cast< const PCB_VIA*>( track );
if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
if( via && IsCopperLayer( layer ) && !via->FlashLayer( layer ) )
continue;
// Add object item to layer container
@ -253,7 +250,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
// Create VIAS and THTs objects and add it to holes containers
for( PCB_LAYER_ID curr_layer_id : layer_id )
for( PCB_LAYER_ID layer : layer_ids )
{
// ADD TRACKS
unsigned int nTracks = trackList.size();
@ -262,7 +259,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
const PCB_TRACK *track = trackList[trackIdx];
if( !track->IsOnLayer( curr_layer_id ) )
if( !track->IsOnLayer( layer ) )
continue;
// ADD VIAS and THT
@ -287,16 +284,16 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
BVH_CONTAINER_2D *layerHoleContainer = nullptr;
// Check if the layer is already created
if( m_layerHoleMap.find( curr_layer_id ) == m_layerHoleMap.end() )
if( m_layerHoleMap.find( layer ) == m_layerHoleMap.end() )
{
// not found, create a new container
layerHoleContainer = new BVH_CONTAINER_2D;
m_layerHoleMap[curr_layer_id] = layerHoleContainer;
m_layerHoleMap[layer] = layerHoleContainer;
}
else
{
// found
layerHoleContainer = m_layerHoleMap[curr_layer_id];
layerHoleContainer = m_layerHoleMap[layer];
}
// Add a hole for this layer
@ -304,7 +301,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
hole_inner_radius + thickness,
*track ) );
}
else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
else if( layer == layer_ids[0] ) // it only adds once the THT holes
{
// Add through hole object
m_throughHoleOds.Add( new FILLED_CIRCLE_2D( via_center,
@ -329,7 +326,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
// Create VIAS and THTs objects and add it to holes containers
for( PCB_LAYER_ID curr_layer_id : layer_id )
for( PCB_LAYER_ID layer : layer_ids )
{
// ADD TRACKS
const unsigned int nTracks = trackList.size();
@ -338,7 +335,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
const PCB_TRACK *track = trackList[trackIdx];
if( !track->IsOnLayer( curr_layer_id ) )
if( !track->IsOnLayer( layer ) )
continue;
// ADD VIAS and THT
@ -356,40 +353,37 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
SHAPE_POLY_SET *layerInnerHolesPoly = nullptr;
// Check if the layer is already created
if( m_layerHoleOdPolys.find( curr_layer_id ) ==
m_layerHoleOdPolys.end() )
if( m_layerHoleOdPolys.find( layer ) == m_layerHoleOdPolys.end() )
{
// not found, create a new container
layerOuterHolesPoly = new SHAPE_POLY_SET;
m_layerHoleOdPolys[curr_layer_id] = layerOuterHolesPoly;
m_layerHoleOdPolys[layer] = layerOuterHolesPoly;
wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) ==
m_layerHoleIdPolys.end() );
wxASSERT( m_layerHoleIdPolys.find( layer ) == m_layerHoleIdPolys.end() );
layerInnerHolesPoly = new SHAPE_POLY_SET;
m_layerHoleIdPolys[curr_layer_id] = layerInnerHolesPoly;
m_layerHoleIdPolys[layer] = layerInnerHolesPoly;
}
else
{
// found
layerOuterHolesPoly = m_layerHoleOdPolys[curr_layer_id];
layerOuterHolesPoly = m_layerHoleOdPolys[layer];
wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) !=
m_layerHoleIdPolys.end() );
wxASSERT( m_layerHoleIdPolys.find( layer ) != m_layerHoleIdPolys.end() );
layerInnerHolesPoly = m_layerHoleIdPolys[curr_layer_id];
layerInnerHolesPoly = m_layerHoleIdPolys[layer];
}
const int holediameter = via->GetDrillValue();
const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
hole_outer_radius, maxError, ERROR_INSIDE );
TransformCircleToPolygon( *layerInnerHolesPoly, via->GetStart(),
holediameter / 2, ARC_HIGH_DEF, ERROR_INSIDE );
holediameter / 2, maxError, ERROR_INSIDE );
}
else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
else if( layer == layer_ids[0] ) // it only adds once the THT holes
{
const int holediameter = via->GetDrillValue();
const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
@ -397,17 +391,16 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Add through hole contours
TransformCircleToPolygon( m_throughHoleOdPolys, via->GetStart(),
hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
hole_outer_radius, maxError, ERROR_INSIDE );
// Add same thing for vias only
TransformCircleToPolygon( m_throughHoleViaOdPolys, via->GetStart(),
hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
hole_outer_radius, maxError, ERROR_INSIDE );
if( m_Cfg->m_Render.clip_silk_on_via_annulus && m_Cfg->m_Render.realistic )
{
TransformCircleToPolygon( m_throughHoleAnnularRingPolys, via->GetStart(),
hole_outer_ring_radius, ARC_HIGH_DEF,
ERROR_INSIDE );
hole_outer_ring_radius, maxError, ERROR_INSIDE );
}
}
}
@ -417,11 +410,11 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Creates vertical outline contours of the tracks and add it to the poly of the layer
if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
{
for( PCB_LAYER_ID curr_layer_id : layer_id )
for( PCB_LAYER_ID layer : layer_ids )
{
wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
// ADD TRACKS
unsigned int nTracks = trackList.size();
@ -430,18 +423,17 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
const PCB_TRACK *track = trackList[trackIdx];
if( !track->IsOnLayer( curr_layer_id ) )
if( !track->IsOnLayer( layer ) )
continue;
// Skip vias annulus when not connected on this layer (if removing is enabled)
const PCB_VIA *via = dyn_cast<const PCB_VIA*>( track );
if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
if( via && !via->FlashLayer( layer ) && IsCopperLayer( layer ) )
continue;
// Add the track/via contour
track->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
track->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
}
}
}
@ -493,24 +485,24 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
if( m_Cfg->m_Render.clip_silk_on_via_annulus && m_Cfg->m_Render.realistic )
{
pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys,
inflate, ARC_HIGH_DEF, ERROR_INSIDE );
pad->TransformHoleToPolygon( m_throughHoleAnnularRingPolys, inflate, maxError,
ERROR_INSIDE );
}
pad->TransformHoleWithClearanceToPolygon( m_throughHoleOdPolys, inflate,
ARC_HIGH_DEF, ERROR_INSIDE );
pad->TransformHoleToPolygon( m_throughHoleOdPolys, inflate, maxError,
ERROR_INSIDE );
}
else
{
// If not plated, no copper.
if( m_Cfg->m_Render.clip_silk_on_via_annulus && m_Cfg->m_Render.realistic )
{
pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
pad->TransformHoleToPolygon( m_throughHoleAnnularRingPolys, 0, maxError,
ERROR_INSIDE );
}
pad->TransformHoleWithClearanceToPolygon( m_nonPlatedThroughHoleOdPolys, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
pad->TransformHoleToPolygon( m_nonPlatedThroughHoleOdPolys, 0, maxError,
ERROR_INSIDE );
}
}
}
@ -519,22 +511,21 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
&& m_Cfg->m_Render.realistic;
// Add footprints PADs objects to containers
for( PCB_LAYER_ID curr_layer_id : layer_id )
for( PCB_LAYER_ID layer : layer_ids )
{
wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
// ADD PADS
for( FOOTPRINT* footprint : m_board->Footprints() )
{
// Note: NPTH pads are not drawn on copper layers when the pad has the same shape
// as its hole
addPads( footprint, layerContainer, curr_layer_id, true, renderPlatedPadsAsPlated,
false );
addPads( footprint, layerContainer, layer, true, renderPlatedPadsAsPlated, false );
// Micro-wave footprints may have items on copper layers
addFootprintShapes( footprint, layerContainer, curr_layer_id );
addFootprintShapes( footprint, layerContainer, layer );
}
}
@ -554,23 +545,21 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Add footprints PADs poly contours (vertical outlines)
if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
{
for( PCB_LAYER_ID curr_layer_id : layer_id )
for( PCB_LAYER_ID layer : layer_ids )
{
wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
// Add pads to polygon list
for( FOOTPRINT* footprint : m_board->Footprints() )
{
// Note: NPTH pads are not drawn on copper layers when the pad has same shape as
// its hole
footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id,
0, ARC_HIGH_DEF, ERROR_INSIDE,
true, renderPlatedPadsAsPlated,
false );
footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE,
true, renderPlatedPadsAsPlated, false );
transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
transformFPShapesToPolySet( footprint, layer, *layerPoly );
}
}
@ -579,28 +568,26 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// ADD PLATED PADS contours
for( FOOTPRINT* footprint : m_board->Footprints() )
{
footprint->TransformPadsWithClearanceToPolygon( *m_frontPlatedPadPolys, F_Cu,
0, ARC_HIGH_DEF, ERROR_INSIDE,
true, false, true );
footprint->TransformPadsToPolySet( *m_frontPlatedPadPolys, F_Cu, 0, maxError,
ERROR_INSIDE, true, false, true );
footprint->TransformPadsWithClearanceToPolygon( *m_backPlatedPadPolys, B_Cu,
0, ARC_HIGH_DEF, ERROR_INSIDE,
true, false, true );
footprint->TransformPadsToPolySet( *m_backPlatedPadPolys, B_Cu, 0, maxError,
ERROR_INSIDE, true, false, true );
}
}
}
// Add graphic item on copper layers to object containers
for( PCB_LAYER_ID curr_layer_id : layer_id )
for( PCB_LAYER_ID layer : layer_ids )
{
wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
// Add graphic items on copper layers (texts and other graphics)
for( BOARD_ITEM* item : m_board->Drawings() )
{
if( !item->IsOnLayer( curr_layer_id ) )
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
@ -637,31 +624,29 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Add graphic item on copper layers to poly contours (vertical outlines)
if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
{
for( PCB_LAYER_ID cur_layer_id : layer_id )
for( PCB_LAYER_ID layer : layer_ids )
{
wxASSERT( m_layers_poly.find( cur_layer_id ) != m_layers_poly.end() );
wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
SHAPE_POLY_SET *layerPoly = m_layers_poly[cur_layer_id];
SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
// Add graphic items on copper layers (texts and other )
for( BOARD_ITEM* item : m_board->Drawings() )
{
if( !item->IsOnLayer( cur_layer_id ) )
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
{
case PCB_SHAPE_T:
item->TransformShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
break;
case PCB_TEXT_T:
{
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
text->TransformTextShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
text->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
break;
}
@ -669,8 +654,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
textbox->TransformTextShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
textbox->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
break;
}
@ -782,18 +766,18 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
}
std::vector< PCB_LAYER_ID > &selected_layer_id = layer_id;
std::vector< PCB_LAYER_ID > layer_id_without_F_and_B;
std::vector<PCB_LAYER_ID> &selected_layer_id = layer_ids;
std::vector<PCB_LAYER_ID> layer_id_without_F_and_B;
if( renderPlatedPadsAsPlated )
{
layer_id_without_F_and_B.clear();
layer_id_without_F_and_B.reserve( layer_id.size() );
layer_id_without_F_and_B.reserve( layer_ids.size() );
for( size_t i = 0; i < layer_id.size(); ++i )
for( PCB_LAYER_ID layer: layer_ids )
{
if( ( layer_id[i] != F_Cu ) && ( layer_id[i] != B_Cu ) )
layer_id_without_F_and_B.push_back( layer_id[i] );
if( layer != F_Cu && layer != B_Cu )
layer_id_without_F_and_B.push_back( layer );
}
selected_layer_id = layer_id_without_F_and_B;
@ -845,7 +829,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( aStatusReporter )
aStatusReporter->Report( _( "Simplify holes contours" ) );
for( PCB_LAYER_ID layer : layer_id )
for( PCB_LAYER_ID layer : layer_ids )
{
if( m_layerHoleOdPolys.find( layer ) != m_layerHoleOdPolys.end() )
{
@ -881,7 +865,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
bool buildVerticalWallsForTechLayers = m_Cfg->m_Render.opengl_copper_thickness
&& m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL;
static const PCB_LAYER_ID teckLayerList[] = {
static const PCB_LAYER_ID techLayerList[] = {
B_Adhes,
F_Adhes,
B_Paste,
@ -901,31 +885,28 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
};
// User layers are not drawn here, only technical layers
for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, arrayDim( teckLayerList ) );
for( LSEQ seq = LSET::AllNonCuMask().Seq( techLayerList, arrayDim( techLayerList ) );
seq;
++seq )
{
const PCB_LAYER_ID curr_layer_id = *seq;
const PCB_LAYER_ID layer = *seq;
if( !Is3dLayerEnabled( curr_layer_id ) )
if( !Is3dLayerEnabled( layer ) )
continue;
if( aStatusReporter )
{
aStatusReporter->Report( wxString::Format( _( "Build Tech layer %d" ),
(int) curr_layer_id ) );
}
aStatusReporter->Report( wxString::Format( _( "Build Tech layer %d" ), (int) layer ) );
BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
m_layerMap[curr_layer_id] = layerContainer;
m_layerMap[layer] = layerContainer;
SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
m_layers_poly[curr_layer_id] = layerPoly;
m_layers_poly[layer] = layerPoly;
// Add drawing objects
for( BOARD_ITEM* item : m_board->Drawings() )
{
if( !item->IsOnLayer( curr_layer_id ) )
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
@ -961,22 +942,20 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
for( BOARD_ITEM* item : m_board->Drawings() )
{
if( !item->IsOnLayer( curr_layer_id ) )
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
{
case PCB_SHAPE_T:
item->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
break;
case PCB_TEXT_T:
{
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
text->TransformTextShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
text->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
break;
}
@ -984,8 +963,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
textbox->TransformTextShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
textbox->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
break;
}
@ -998,13 +976,13 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Add footprints tech layers - objects
for( FOOTPRINT* footprint : m_board->Footprints() )
{
if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) )
if( layer == F_SilkS || layer == B_SilkS )
{
int linewidth = m_board->GetDesignSettings().m_LineThickness[ LAYER_CLASS_SILK ];
for( PAD* pad : footprint->Pads() )
{
if( !pad->IsOnLayer( curr_layer_id ) )
if( !pad->IsOnLayer( layer ) )
continue;
buildPadOutlineAsSegments( pad, layerContainer, linewidth );
@ -1012,10 +990,10 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
else
{
addPads( footprint, layerContainer, curr_layer_id, false, false, false );
addPads( footprint, layerContainer, layer, false, false, false );
}
addFootprintShapes( footprint, layerContainer, curr_layer_id );
addFootprintShapes( footprint, layerContainer, layer );
}
@ -1024,13 +1002,13 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
for( FOOTPRINT* footprint : m_board->Footprints() )
{
if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) )
if( layer == F_SilkS || layer == B_SilkS )
{
int linewidth = m_board->GetDesignSettings().m_LineThickness[ LAYER_CLASS_SILK ];
for( PAD* pad : footprint->Pads() )
{
if( !pad->IsOnLayer( curr_layer_id ) )
if( !pad->IsOnLayer( layer ) )
continue;
buildPadOutlineAsPolygon( pad, *layerPoly, linewidth );
@ -1038,16 +1016,14 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
else
{
footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
}
// On tech layers, use a poor circle approximation, only for texts (stroke font)
footprint->TransformFPTextWithClearanceToPolygonSet( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
footprint->TransformFPTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
// Add the remaining things with dynamic seg count for circles
transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
transformFPShapesToPolySet( footprint, layer, *layerPoly );
}
}
@ -1056,8 +1032,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
for( ZONE* zone : m_board->Zones() )
{
if( zone->IsOnLayer( curr_layer_id ) )
addSolidAreasShapes( zone, layerContainer, curr_layer_id );
if( zone->IsOnLayer( layer ) )
addSolidAreasShapes( zone, layerContainer, layer );
}
if( buildVerticalWallsForTechLayers )
@ -1065,8 +1041,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
for( ZONE* zone : m_board->Zones() )
{
if( zone->IsOnLayer( curr_layer_id ) )
zone->TransformSolidAreasShapesToPolygon( curr_layer_id, *layerPoly );
if( zone->IsOnLayer( layer ) )
zone->TransformSolidAreasShapesToPolygon( layer, *layerPoly );
}
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -29,6 +29,7 @@
*/
#include "board_adapter.h"
#include <board_design_settings.h>
#include <convert_basic_shapes_to_polygon.h>
#include <fp_shape.h>
#include <footprint.h>
@ -37,13 +38,15 @@
/*
* This is used to draw pad outlines on silk layers.
*/
void BOARD_ADAPTER::buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aCornerBuffer,
void BOARD_ADAPTER::buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aBuffer,
int aWidth ) const
{
int maxError = m_board->GetDesignSettings().m_MaxError;
if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
{
TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(), aPad->GetSize().x / 2, aWidth,
ARC_HIGH_DEF, ERROR_INSIDE );
TransformRingToPolygon( aBuffer, aPad->ShapePos(), aPad->GetSize().x / 2, aWidth, maxError,
ERROR_INSIDE );
return;
}
@ -56,14 +59,16 @@ void BOARD_ADAPTER::buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& a
const VECTOR2I& a = path.CPoint( ii );
const VECTOR2I& b = path.CPoint( ii + 1 );
TransformOvalToPolygon( aCornerBuffer, a, b, aWidth, ARC_HIGH_DEF, ERROR_INSIDE );
TransformOvalToPolygon( aBuffer, a, b, aWidth, maxError, ERROR_INSIDE );
}
}
void BOARD_ADAPTER::transformFPShapesToPolygon( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer ) const
void BOARD_ADAPTER::transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aBuffer ) const
{
int maxError = m_board->GetDesignSettings().m_MaxError;
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
{
if( item->Type() == PCB_FP_SHAPE_T )
@ -71,20 +76,14 @@ void BOARD_ADAPTER::transformFPShapesToPolygon( const FOOTPRINT* aFootprint, PCB
FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
if( shape->GetLayer() == aLayer )
{
shape->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
shape->TransformShapeToPolygon( aBuffer, aLayer, 0, maxError, ERROR_INSIDE );
}
else if( BaseType( item->Type() ) == PCB_DIMENSION_T )
{
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( item );
if( dimension->GetLayer() == aLayer )
{
dimension->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
dimension->TransformShapeToPolygon( aBuffer, aLayer, 0, maxError, ERROR_INSIDE );
}
}
}

View File

@ -825,11 +825,10 @@ void RENDER_3D_OPENGL::generateViasAndPads()
if( !hasHole )
continue;
pad->TransformHoleWithClearanceToPolygon( tht_outer_holes_poly,
platingThickness,
ARC_HIGH_DEF, ERROR_INSIDE );
pad->TransformHoleWithClearanceToPolygon( tht_inner_holes_poly, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
pad->TransformHoleToPolygon( tht_outer_holes_poly, platingThickness,
ARC_HIGH_DEF, ERROR_INSIDE );
pad->TransformHoleToPolygon( tht_inner_holes_poly, 0, ARC_HIGH_DEF,
ERROR_INSIDE );
}
}
}

View File

@ -1491,30 +1491,26 @@ int EDA_SHAPE::Compare( const EDA_SHAPE* aOther ) const
}
void EDA_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
int aClearanceValue,
int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth ) const
void EDA_SHAPE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
ERROR_LOC aErrorLoc, bool ignoreLineWidth ) const
{
int width = ignoreLineWidth ? 0 : GetWidth();
width += 2 * aClearanceValue;
width += 2 * aClearance;
switch( m_shape )
{
case SHAPE_T::CIRCLE:
{
int r = GetRadius();
if( IsFilled() )
{
TransformCircleToPolygon( aCornerBuffer, getCenter(), GetRadius() + width / 2, aError,
aErrorLoc );
}
TransformCircleToPolygon( aBuffer, getCenter(), r + width / 2, aError, aErrorLoc );
else
{
TransformRingToPolygon( aCornerBuffer, getCenter(), GetRadius(), width, aError,
aErrorLoc );
}
TransformRingToPolygon( aBuffer, getCenter(), r, width, aError, aErrorLoc );
break;
}
case SHAPE_T::RECT:
{
@ -1522,31 +1518,30 @@ void EDA_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
if( IsFilled() || IsAnnotationProxy() )
{
aCornerBuffer.NewOutline();
aBuffer.NewOutline();
for( const VECTOR2I& pt : pts )
aCornerBuffer.Append( pt );
aBuffer.Append( pt );
}
if( width > 0 || !IsFilled() )
{
// Add in segments
TransformOvalToPolygon( aCornerBuffer, pts[0], pts[1], width, aError, aErrorLoc );
TransformOvalToPolygon( aCornerBuffer, pts[1], pts[2], width, aError, aErrorLoc );
TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError, aErrorLoc );
TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aError, aErrorLoc );
}
break;
}
case SHAPE_T::ARC:
TransformArcToPolygon( aCornerBuffer, GetStart(), GetArcMid(), GetEnd(), width, aError,
aErrorLoc );
TransformArcToPolygon( aBuffer, GetStart(), GetArcMid(), GetEnd(), width, aError, aErrorLoc );
break;
case SHAPE_T::SEGMENT:
TransformOvalToPolygon( aCornerBuffer, GetStart(), GetEnd(), width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, GetStart(), GetEnd(), width, aError, aErrorLoc );
break;
case SHAPE_T::POLY:
@ -1570,10 +1565,10 @@ void EDA_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
if( IsFilled() )
{
aCornerBuffer.NewOutline();
aBuffer.NewOutline();
for( const VECTOR2I& point : poly )
aCornerBuffer.Append( point.x, point.y );
aBuffer.Append( point.x, point.y );
}
if( width > 0 || !IsFilled() )
@ -1583,7 +1578,7 @@ void EDA_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
for( const VECTOR2I& pt2 : poly )
{
if( pt2 != pt1 )
TransformOvalToPolygon( aCornerBuffer, pt1, pt2, width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, pt1, pt2, width, aError, aErrorLoc );
pt1 = pt2;
}
@ -1600,10 +1595,7 @@ void EDA_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
converter.GetPoly( poly, GetWidth() );
for( unsigned ii = 1; ii < poly.size(); ii++ )
{
TransformOvalToPolygon( aCornerBuffer, poly[ii - 1], poly[ii], width, aError,
aErrorLoc );
}
TransformOvalToPolygon( aBuffer, poly[ii - 1], poly[ii], width, aError, aErrorLoc );
break;
}

View File

@ -936,22 +936,20 @@ int EDA_TEXT::Compare( const EDA_TEXT* aOther ) const
}
void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCornerBuffer,
int aClearanceValue ) const
void EDA_TEXT::TransformBoundingBoxToPolygon( SHAPE_POLY_SET* aBuffer, int aClearance ) const
{
if( GetText().Length() == 0 )
return;
VECTOR2I corners[4]; // Buffer of polygon corners
BOX2I rect = GetTextBox();
VECTOR2I corners[4]; // Buffer of polygon corners
BOX2I rect = GetTextBox();
// TrueType bounding boxes aren't guaranteed to include all descenders, diacriticals, etc.
// Since we use this for zone knockouts and DRC, we need something more accurate.
if( GetDrawFont()->IsOutline() )
rect = GetEffectiveTextShape( false, false )->BBox();
rect.Inflate( aClearanceValue );
rect.Inflate( aClearance );
corners[0].x = rect.GetOrigin().x;
corners[0].y = rect.GetOrigin().y;
@ -962,13 +960,13 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn
corners[3].y = corners[2].y;
corners[3].x = corners[0].x;
aCornerBuffer->NewOutline();
aBuffer->NewOutline();
for( VECTOR2I& corner : corners )
{
RotatePoint( corner, GetDrawPos(), GetDrawRotation() );
aCornerBuffer->Append( corner.x, corner.y );
aBuffer->Append( corner.x, corner.y );
}
}

View File

@ -297,21 +297,18 @@ public:
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
/**
* Convert the item shape to a closed polygon.
* Convert the item shape to a closed polygon. Circles and arcs are approximated by segments.
*
* Used in filling zones calculations. Circles and arcs are approximated by segments.
*
* @param aCornerBuffer a buffer to store the polygon.
* @param aClearanceValue the clearance around the pad.
* @param aBuffer a buffer to store the polygon.
* @param aClearance the clearance around the pad.
* @param aError the maximum deviation from true circle.
* @param aErrorLoc should the approximation error be placed outside or inside the polygon?
* @param ignoreLineWidth used for edge cut items where the line width is only
* for visualization.
*/
virtual void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearanceValue,
int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth = false ) const;
virtual void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
int aClearance, int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth = false ) const;
struct ptr_cmp
{

View File

@ -297,20 +297,17 @@ public:
double GetLength() const;
/**
* Convert the shape to a closed polygon.
* Convert the shape to a closed polygon. Circles and arcs are approximated by segments.
*
* Used in filling zones calculations. Circles and arcs are approximated by segments.
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aClearanceValue is the clearance around the pad.
* @param aBuffer is a buffer to store the polygon.
* @param aClearance is the clearance around the pad.
* @param aError is the maximum deviation from a true arc.
* @param aErrorLoc whether any approximation error shoule be placed inside or outside
* @param ignoreLineWidth is used for edge cut items where the line width is only
* for visualization
* @param ignoreLineWidth is used for edge cut items where the line width is only for
* visualization
*/
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearanceValue,
int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth ) const;
void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
ERROR_LOC aErrorLoc, bool ignoreLineWidth = false ) const;
int Compare( const EDA_SHAPE* aOther ) const;

View File

@ -225,12 +225,11 @@ public:
* Used in filling zones calculations
* Circles and arcs are approximated by segments
*
* @param aCornerBuffer a buffer to store the polygon.
* @param aClearanceValue the clearance around the text bounding box
* @param aBuffer a buffer to store the polygon.
* @param aClearance the clearance around the text bounding box
* to the real clearance value (usually near from 1.0).
*/
void TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCornerBuffer,
int aClearanceValue ) const;
void TransformBoundingBoxToPolygon( SHAPE_POLY_SET* aBuffer, int aClearance ) const;
/**
* build a list of segments (SHAPE_SEGMENT) to describe a text shape.

View File

@ -66,7 +66,7 @@ int ConvertArcToPolyline( SHAPE_LINE_CHAIN& aPolyline, VECTOR2I aCenter, int aRa
/**
* Convert a circle to a polygon, using multiple straight lines.
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aBuffer is a buffer to store the polygon.
* @param aCenter is the center of the circle.
* @param aRadius is the radius of the circle.
* @param aError is the internal units allowed for error approximation.
@ -74,13 +74,13 @@ int ConvertArcToPolyline( SHAPE_LINE_CHAIN& aPolyline, VECTOR2I aCenter, int aRa
* @param aMinSegCount is the min count of segments to approximate.
* Default = 0 to do not force a min count.
*/
void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aCornerBuffer, const VECTOR2I& aCenter,
int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount = 0 );
void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aBuffer, const VECTOR2I& aCenter, int aRadius,
int aError, ERROR_LOC aErrorLoc, int aMinSegCount = 0 );
/**
* Convert a circle to a polygon, using multiple straight lines.
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aBuffer is a buffer to store the polygon.
* @param aCenter is the center of the circle.
* @param aRadius is the radius of the circle.
* @param aError is the internal units allowed for error in approximation.
@ -88,7 +88,7 @@ void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aCornerBuffer, const VECTOR2I&
* @param aMinSegCount is the min count of segments to approximate.
* Default = 0 to do not force a min count.
*/
void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aCenter, int aRadius,
void TransformCircleToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aCenter, int aRadius,
int aError, ERROR_LOC aErrorLoc, int aMinSegCount = 0 );
@ -100,7 +100,7 @@ void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aC
* because multiple segments create a smaller area than the circle. The radius of the circle to
* approximate must be bigger ( radius*aCorrectionFactor) to create segments outside the circle.
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aBuffer is a buffer to store the polygon.
* @param aStart is the first point of the segment.
* @param aEnd is the second point of the segment.
* @param aWidth is the width of the segment.
@ -109,16 +109,15 @@ void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aC
* @param aMinSegCount is the min count of segments to approximate.
* Default = 0 to do not force a min count.
*/
void TransformOvalToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aStart,
const VECTOR2I& aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc,
int aMinSegCount = 0 );
void TransformOvalToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, const VECTOR2I& aEnd,
int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount = 0 );
/**
* Convert a rectangle or trapezoid to a polygon.
*
* This will generate at least 16 segments per circle (when using inflate).
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aBuffer is a buffer to store the polygon.
* @param aPosition is the coordinate of the center of the rectangle.
* @param aSize is the size of the rectangle.
* @param aDeltaX is the delta for trapezoids in X direction
@ -127,7 +126,7 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aSta
* @param aError is the IU allowed for error in approximation.
* @param aErrorLoc determines if the approximation error be placed outside or inside the polygon.
*/
void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aPosition,
void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aPosition,
const VECTOR2I& aSize, const EDA_ANGLE& aRotation, int aDeltaX,
int aDeltaY, int aInflate, int aError, ERROR_LOC aErrorLoc );
@ -137,7 +136,7 @@ void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I&
* Convert rounded corners arcs to multiple straight lines. This will generate at least
* 16 segments per circle.
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aBuffer is a buffer to store the polygon.
* @param aPosition is the coordinate of the center of the rectangle.
* @param aSize is the size of the rectangle.
* @param aCornerRadius is the radius of rounded corners (can be 0).
@ -154,16 +153,16 @@ void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I&
* @param aError is the IU allowed for error in approximation.
* @param aErrorLoc determines if the approximation error be placed outside or inside the polygon.
*/
void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aCornerBuffer,
const VECTOR2I& aPosition, const VECTOR2I& aSize,
const EDA_ANGLE& aRotation, int aCornerRadius,
double aChamferRatio, int aChamferCorners, int aInflate,
int aError, ERROR_LOC aErrorLoc );
void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aPosition,
const VECTOR2I& aSize, const EDA_ANGLE& aRotation,
int aCornerRadius, double aChamferRatio,
int aChamferCorners, int aInflate, int aError,
ERROR_LOC aErrorLoc );
/**
* Convert arc to multiple straight segments.
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aBuffer is a buffer to store the polygon.
* @param aCentre is the center of the arc or circle.
* @param aStart is the start point of the arc or a point on the circle.
* @param aArcAngle is the arc angle in 0.1 degrees. For a circle, aArcAngle = 3600.
@ -171,21 +170,20 @@ void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aCornerBuffer,
* @param aError is the internal units allowed for error in approximation.
* @param aErrorLoc determines if the approximation error be placed outside or inside the polygon.
*/
void TransformArcToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aStart,
const VECTOR2I& aMid, const VECTOR2I& aEnd, int aWidth, int aError,
ERROR_LOC aErrorLoc );
void TransformArcToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, const VECTOR2I& aMid,
const VECTOR2I& aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc );
/**
* Convert arcs to multiple straight segments.
*
* @param aCornerBuffer is a buffer to store the polygon.
* @param aBuffer is a buffer to store the polygon.
* @param aCentre is the center of the arc or circle.
* @param aRadius is the radius of the circle.
* @param aWidth is the width (thickness) of the ring.
* @param aError is the internal units allowed for error in approximation.
* @param aErrorLoc determines if the approximation error be placed outside or inside the polygon.
*/
void TransformRingToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aCentre, int aRadius,
void TransformRingToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aCentre, int aRadius,
int aWidth, int aError, ERROR_LOC aErrorLoc );
#endif // CONVERT_BASIC_SHAPES_TO_POLYGON_H

View File

@ -35,8 +35,8 @@
#include <trigo.h>
void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aCornerBuffer, const VECTOR2I& aCenter,
int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount )
void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aBuffer, const VECTOR2I& aCenter, int aRadius,
int aError, ERROR_LOC aErrorLoc, int aMinSegCount )
{
VECTOR2I corner_position;
int numSegs = GetArcToSegmentCount( aRadius, aError, FULL_CIRCLE );
@ -67,14 +67,14 @@ void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aCornerBuffer, const VECTOR2I&
corner_position.y = 0;
RotatePoint( corner_position, angle );
corner_position += aCenter;
aCornerBuffer.Append( corner_position.x, corner_position.y );
aBuffer.Append( corner_position.x, corner_position.y );
}
aCornerBuffer.SetClosed( true );
aBuffer.SetClosed( true );
}
void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aCenter, int aRadius,
void TransformCircleToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aCenter, int aRadius,
int aError, ERROR_LOC aErrorLoc, int aMinSegCount )
{
VECTOR2I corner_position;
@ -100,7 +100,7 @@ void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aC
radius += GetCircleToPolyCorrection( actual_delta_radius );
}
aCornerBuffer.NewOutline();
aBuffer.NewOutline();
for( EDA_ANGLE angle = ANGLE_0; angle < ANGLE_360; angle += delta )
{
@ -108,20 +108,19 @@ void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aC
corner_position.y = 0;
RotatePoint( corner_position, angle );
corner_position += aCenter;
aCornerBuffer.Append( corner_position.x, corner_position.y );
aBuffer.Append( corner_position.x, corner_position.y );
}
// Finish circle
corner_position.x = radius;
corner_position.y = 0;
corner_position += aCenter;
aCornerBuffer.Append( corner_position.x, corner_position.y );
aBuffer.Append( corner_position.x, corner_position.y );
}
void TransformOvalToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aStart,
const VECTOR2I& aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc,
int aMinSegCount )
void TransformOvalToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, const VECTOR2I& aEnd,
int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount )
{
// To build the polygonal shape outside the actual shape, we use a bigger
// radius to build rounded ends.
@ -219,7 +218,7 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aSta
polyshape.Rotate( -delta_angle );
polyshape.Move( startp );
aCornerBuffer.Append( polyshape);
aBuffer.Append( polyshape);
}
@ -373,7 +372,7 @@ void CornerListRemoveDuplicates( std::vector<ROUNDED_CORNER>& aCorners )
}
void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aPosition,
void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aPosition,
const VECTOR2I& aSize, const EDA_ANGLE& aRotation, int aDeltaX,
int aDeltaY, int aInflate, int aError, ERROR_LOC aErrorLoc )
{
@ -442,11 +441,11 @@ void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I&
outline.Rotate( aRotation );
outline.Move( VECTOR2I( aPosition ) );
aCornerBuffer.Append( outline );
aBuffer.Append( outline );
}
void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aPosition,
void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aPosition,
const VECTOR2I& aSize, const EDA_ANGLE& aRotation,
int aCornerRadius, double aChamferRatio,
int aChamferCorners, int aInflate, int aError,
@ -509,7 +508,7 @@ void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aCornerBuffer, const
outline.Rotate( aRotation );
outline.Move( aPosition );
aCornerBuffer.Append( outline );
aBuffer.Append( outline );
}
@ -574,9 +573,8 @@ int ConvertArcToPolyline( SHAPE_LINE_CHAIN& aPolyline, VECTOR2I aCenter, int aRa
}
void TransformArcToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aStart,
const VECTOR2I& aMid, const VECTOR2I& aEnd, int aWidth,
int aError, ERROR_LOC aErrorLoc )
void TransformArcToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, const VECTOR2I& aMid,
const VECTOR2I& aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc )
{
SEG startToEnd( aStart, aEnd );
int distanceToMid = startToEnd.Distance( aMid );
@ -584,8 +582,7 @@ void TransformArcToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aStar
if( distanceToMid <= 1 )
{
// Not an arc but essentially a straight line with a small error
TransformOvalToPolygon( aCornerBuffer, aStart, aEnd, aWidth + distanceToMid, aError,
aErrorLoc );
TransformOvalToPolygon( aBuffer, aStart, aEnd, aWidth + distanceToMid, aError, aErrorLoc );
return;
}
@ -635,11 +632,11 @@ void TransformArcToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aStar
-arc_angle, aError, errorLocInner );
}
aCornerBuffer.Append( polyshape );
aBuffer.Append( polyshape );
}
void TransformRingToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aCentre, int aRadius,
void TransformRingToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aCentre, int aRadius,
int aWidth, int aError, ERROR_LOC aErrorLoc )
{
int inner_radius = aRadius - ( aWidth / 2 );
@ -648,8 +645,7 @@ void TransformRingToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aCen
if( inner_radius <= 0 )
{
//In this case, the ring is just a circle (no hole inside)
TransformCircleToPolygon( aCornerBuffer, aCentre, aRadius + ( aWidth / 2 ), aError,
aErrorLoc );
TransformCircleToPolygon( aBuffer, aCentre, aRadius + ( aWidth / 2 ), aError, aErrorLoc );
return;
}
@ -665,5 +661,5 @@ void TransformRingToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aCen
aError, inner_err_loc );
buffer.Fracture( SHAPE_POLY_SET::PM_FAST );
aCornerBuffer.Append( buffer );
aBuffer.Append( buffer );
}

View File

@ -2202,22 +2202,19 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer,
if( !track->IsOnLayer( aLayer ) )
continue;
track->TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
track->TransformShapeToPolygon( aOutlines, aLayer, 0, maxError, ERROR_INSIDE );
}
// convert pads and other copper items in footprints
for( const FOOTPRINT* footprint : m_footprints )
{
footprint->TransformPadsWithClearanceToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
footprint->TransformPadsToPolySet( aOutlines, aLayer, 0, maxError, ERROR_INSIDE );
// Microwave footprints may have items on copper layers
footprint->TransformFPShapesWithClearanceToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE,
true, /* include text */
true, /* include shapes */
false /* include private items */ );
footprint->TransformFPShapesToPolySet( aOutlines, aLayer, 0, maxError, ERROR_INSIDE,
true, /* include text */
true, /* include shapes */
false /* include private items */ );
for( const ZONE* zone : footprint->Zones() )
{
@ -2244,16 +2241,14 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer,
case PCB_SHAPE_T:
{
const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( item );
shape->TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
shape->TransformShapeToPolygon( aOutlines, aLayer, 0, maxError, ERROR_INSIDE );
break;
}
case PCB_TEXT_T:
{
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
text->TransformTextShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
text->TransformTextToPolySet( aOutlines, aLayer, 0, maxError, ERROR_INSIDE );
break;
}
@ -2262,11 +2257,10 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer,
const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
// plot border
textbox->PCB_SHAPE::TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0,
maxError, ERROR_INSIDE );
textbox->PCB_SHAPE::TransformShapeToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
// plot text
textbox->TransformTextShapeWithClearanceToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
textbox->TransformTextToPolySet( aOutlines, aLayer, 0, maxError, ERROR_INSIDE );
break;
}

View File

@ -169,13 +169,11 @@ BOARD_ITEM* BOARD_ITEM::Duplicate() const
}
void BOARD_ITEM::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearanceValue,
int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth ) const
void BOARD_ITEM::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
int aClearance, int aError, ERROR_LOC aErrorLoc,
bool ignoreLineWidth ) const
{
wxASSERT_MSG( false, wxT( "Called TransformShapeWithClearanceToPolygon() on unsupported "
"BOARD_ITEM." ) );
wxASSERT_MSG( false, wxT( "Called TransformShapeToPolygon() on unsupported BOARD_ITEM." ) );
};

View File

@ -1269,8 +1269,8 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
int maxError = m_board->GetDesignSettings().m_MaxError;
SHAPE_POLY_SET padOutline;
m_dummyPad->TransformShapeWithClearanceToPolygon( padOutline, UNDEFINED_LAYER, 0,
maxError, ERROR_INSIDE );
m_dummyPad->TransformShapeToPolygon( padOutline, UNDEFINED_LAYER, 0, maxError,
ERROR_INSIDE );
if( !padOutline.Collide( m_dummyPad->GetPosition() ) )
{

View File

@ -188,8 +188,8 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run()
// Slow (but general purpose) method.
SHAPE_POLY_SET padOutline;
pad->TransformShapeWithClearanceToPolygon( padOutline, UNDEFINED_LAYER, 0,
maxError, ERROR_INSIDE );
pad->TransformShapeToPolygon( padOutline, UNDEFINED_LAYER, 0, maxError,
ERROR_INSIDE );
if( !padOutline.Collide( pad->GetPosition() ) )
{

View File

@ -679,8 +679,8 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
for( BOARD_ITEM* item : itemsPoly.Items )
{
item->TransformShapeWithClearanceToPolygon( itemsPoly.Poly, aLayer, 0,
ARC_HIGH_DEF, ERROR_OUTSIDE );
item->TransformShapeToPolygon( itemsPoly.Poly, aLayer, 0, ARC_HIGH_DEF,
ERROR_OUTSIDE );
}
itemsPoly.Poly.Fracture( SHAPE_POLY_SET::PM_FAST );

View File

@ -144,9 +144,8 @@ bool DRC_TEST_PROVIDER_SLIVER_CHECKER::Run()
}
else
{
item->TransformShapeWithClearanceToPolygon( poly, layer, 0,
ARC_LOW_DEF,
ERROR_OUTSIDE );
item->TransformShapeToPolygon( poly, layer, 0, ARC_LOW_DEF,
ERROR_OUTSIDE );
}
if( m_drcEngine->IsCancelled() )

View File

@ -135,8 +135,8 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::addItemToRTrees( BOARD_ITEM* aItem )
PAD* pad = static_cast<PAD*>( aItem );
int clearance = ( m_webWidth / 2 ) + pad->GetSolderMaskExpansion();
aItem->TransformShapeWithClearanceToPolygon( *solderMask->GetFill( layer ), layer,
clearance, m_maxError, ERROR_OUTSIDE );
aItem->TransformShapeToPolygon( *solderMask->GetFill( layer ), layer, clearance,
m_maxError, ERROR_OUTSIDE );
m_itemTree->Insert( aItem, layer, m_largestClearance );
}
@ -151,8 +151,8 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::addItemToRTrees( BOARD_ITEM* aItem )
PCB_VIA* via = static_cast<PCB_VIA*>( aItem );
int clearance = ( m_webWidth / 2 ) + via->GetSolderMaskExpansion();
via->TransformShapeWithClearanceToPolygon( *solderMask->GetFill( layer ), layer,
clearance, m_maxError, ERROR_OUTSIDE );
via->TransformShapeToPolygon( *solderMask->GetFill( layer ), layer, clearance,
m_maxError, ERROR_OUTSIDE );
m_itemTree->Insert( aItem, layer, m_largestClearance );
}
@ -164,9 +164,8 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::addItemToRTrees( BOARD_ITEM* aItem )
{
if( aItem->IsOnLayer( layer ) )
{
aItem->TransformShapeWithClearanceToPolygon( *solderMask->GetFill( layer ),
layer, m_webWidth / 2, m_maxError,
ERROR_OUTSIDE );
aItem->TransformShapeToPolygon( *solderMask->GetFill( layer ), layer,
m_webWidth / 2, m_maxError, ERROR_OUTSIDE );
m_itemTree->Insert( aItem, layer, m_largestClearance );
}

View File

@ -125,8 +125,7 @@ void DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer( ZONE* aZone, PCB_LAYER_I
continue;
SHAPE_POLY_SET padPoly;
pad->TransformShapeWithClearanceToPolygon( padPoly, aLayer, 0, ARC_LOW_DEF,
ERROR_OUTSIDE );
pad->TransformShapeToPolygon( padPoly, aLayer, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
SHAPE_LINE_CHAIN& padOutline = padPoly.Outline( 0 );
BOX2I padBBox( item_bbox );

View File

@ -934,8 +934,8 @@ SHAPE_POLY_SET FOOTPRINT::GetBoundingHull() const
if( item->Type() != PCB_FP_TEXT_T && item->Type() != PCB_BITMAP_T )
{
item->TransformShapeWithClearanceToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
ERROR_OUTSIDE );
item->TransformShapeToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
ERROR_OUTSIDE );
}
// We intentionally exclude footprint text from the bounding hull.
@ -943,10 +943,9 @@ SHAPE_POLY_SET FOOTPRINT::GetBoundingHull() const
for( PAD* pad : m_pads )
{
pad->TransformShapeWithClearanceToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
ERROR_OUTSIDE );
pad->TransformShapeToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
// In case hole is larger than pad
pad->TransformHoleWithClearanceToPolygon( rawPolys, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
pad->TransformHoleToPolygon( rawPolys, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
}
for( FP_ZONE* zone : m_fp_zones )
@ -2023,15 +2022,13 @@ double FOOTPRINT::GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLEC
{
const FP_TEXT* text = static_cast<const FP_TEXT*>( aItem );
text->TransformTextShapeWithClearanceToPolygon( poly, UNDEFINED_LAYER, textMargin,
ARC_LOW_DEF, ERROR_OUTSIDE );
text->TransformTextToPolySet( poly, UNDEFINED_LAYER, textMargin, ARC_LOW_DEF, ERROR_OUTSIDE );
}
else if( aItem->Type() == PCB_FP_TEXTBOX_T )
{
const FP_TEXTBOX* textbox = static_cast<const FP_TEXTBOX*>( aItem );
const FP_TEXTBOX* tb = static_cast<const FP_TEXTBOX*>( aItem );
textbox->TransformTextShapeWithClearanceToPolygon( poly, UNDEFINED_LAYER, textMargin,
ARC_LOW_DEF, ERROR_OUTSIDE );
tb->TransformTextToPolySet( poly, UNDEFINED_LAYER, textMargin, ARC_LOW_DEF, ERROR_OUTSIDE );
}
else if( aItem->Type() == PCB_SHAPE_T )
{
@ -2059,8 +2056,7 @@ double FOOTPRINT::GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLEC
}
default:
shape->TransformShapeWithClearanceToPolygon( poly, UNDEFINED_LAYER, 0,
ARC_LOW_DEF, ERROR_OUTSIDE );
shape->TransformShapeToPolygon( poly, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
}
}
else if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_ARC_T )
@ -2070,8 +2066,7 @@ double FOOTPRINT::GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLEC
}
else
{
aItem->TransformShapeWithClearanceToPolygon( poly, UNDEFINED_LAYER, 0,
ARC_LOW_DEF, ERROR_OUTSIDE );
aItem->TransformShapeToPolygon( poly, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
}
return polygonArea( poly );
@ -2085,14 +2080,13 @@ double FOOTPRINT::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const
SHAPE_POLY_SET footprintRegion( GetBoundingHull() );
SHAPE_POLY_SET coveredRegion;
TransformPadsWithClearanceToPolygon( coveredRegion, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
ERROR_OUTSIDE );
TransformPadsToPolySet( coveredRegion, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
TransformFPShapesWithClearanceToPolygon( coveredRegion, UNDEFINED_LAYER, textMargin,
ARC_LOW_DEF, ERROR_OUTSIDE,
true, /* include text */
false, /* include shapes */
false /* include private items */ );
TransformFPShapesToPolySet( coveredRegion, UNDEFINED_LAYER, textMargin, ARC_LOW_DEF,
ERROR_OUTSIDE,
true, /* include text */
false, /* include shapes */
false /* include private items */ );
for( int i = 0; i < aCollector.GetCount(); ++i )
{
@ -2105,8 +2099,8 @@ double FOOTPRINT::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const
case PCB_FP_SHAPE_T:
if( item->GetParent() != this )
{
item->TransformShapeWithClearanceToPolygon( coveredRegion, UNDEFINED_LAYER, 0,
ARC_LOW_DEF, ERROR_OUTSIDE );
item->TransformShapeToPolygon( coveredRegion, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
ERROR_OUTSIDE );
}
break;
@ -2116,8 +2110,8 @@ double FOOTPRINT::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const
case PCB_TRACE_T:
case PCB_ARC_T:
case PCB_VIA_T:
item->TransformShapeWithClearanceToPolygon( coveredRegion, UNDEFINED_LAYER, 0,
ARC_LOW_DEF, ERROR_OUTSIDE );
item->TransformShapeToPolygon( coveredRegion, UNDEFINED_LAYER, 0, ARC_LOW_DEF,
ERROR_OUTSIDE );
break;
case PCB_FOOTPRINT_T:
@ -2345,14 +2339,13 @@ void FOOTPRINT::CheckPads( const std::function<void( const PAD*, int,
PCB_LAYER_ID layer = lset.Seq().at( 0 );
SHAPE_POLY_SET padOutline;
pad->TransformShapeWithClearanceToPolygon( padOutline, layer, 0, ARC_HIGH_DEF,
ERROR_LOC::ERROR_INSIDE );
pad->TransformShapeToPolygon( padOutline, layer, 0, ARC_HIGH_DEF, ERROR_INSIDE );
std::shared_ptr<SHAPE_SEGMENT> hole = pad->GetEffectiveHoleShape();
SHAPE_POLY_SET holeOutline;
TransformOvalToPolygon( holeOutline, hole->GetSeg().A, hole->GetSeg().B,
hole->GetWidth(), ARC_HIGH_DEF, ERROR_LOC::ERROR_INSIDE );
hole->GetWidth(), ARC_HIGH_DEF, ERROR_INSIDE );
padOutline.BooleanSubtract( holeOutline, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
@ -2490,8 +2483,8 @@ void FOOTPRINT::CheckNetTies( const std::function<void( const BOARD_ITEM* aItem,
{
if( item->IsOnLayer( layer ) )
{
item->TransformShapeWithClearanceToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF, ERROR_OUTSIDE );
item->TransformShapeToPolygon( copperOutlines, layer, 0, ARC_HIGH_DEF,
ERROR_OUTSIDE );
}
}
@ -2679,12 +2672,10 @@ bool FOOTPRINT::cmp_zones::operator()( const FP_ZONE* aFirst, const FP_ZONE* aSe
#undef TEST
void FOOTPRINT::TransformPadsWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aMaxError, ERROR_LOC aErrorLoc,
bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
bool aSkipNonPlatedPads ) const
void FOOTPRINT::TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads,
bool aSkipNonPlatedPads ) const
{
for( const PAD* pad : m_pads )
{
@ -2728,10 +2719,9 @@ void FOOTPRINT::TransformPadsWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuff
break;
}
// Our standard TransformShapeWithClearanceToPolygon() routines can't handle differing
// x:y clearance values (which get generated when a relative paste margin is used with
// an oblong pad). So we apply this huge hack and fake a larger pad to run the transform
// on.
// Our standard TransformShapeToPolygon() routines can't handle differing x:y clearance
// values (which get generated when a relative paste margin is used with an oblong pad).
// So we apply this huge hack and fake a larger pad to run the transform on.
// Of course being a hack it falls down when dealing with custom shape pads (where the
// size is only the size of the anchor), so for those we punt and just use clearance.x.
@ -2745,24 +2735,20 @@ void FOOTPRINT::TransformPadsWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuff
PAD dummy( *pad );
dummy.SetSize( dummySize );
dummy.TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0,
aMaxError, aErrorLoc );
dummy.TransformShapeToPolygon( aBuffer, aLayer, 0, aMaxError, aErrorLoc );
}
else
{
pad->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, clearance.x,
aMaxError, aErrorLoc );
pad->TransformShapeToPolygon( aBuffer, aLayer, clearance.x, aMaxError, aErrorLoc );
}
}
}
void FOOTPRINT::TransformFPShapesWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc,
bool aIncludeText,
bool aIncludeShapes,
bool aIncludePrivateItems ) const
void FOOTPRINT::TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
int aClearance, int aError, ERROR_LOC aErrorLoc,
bool aIncludeText, bool aIncludeShapes,
bool aIncludePrivateItems ) const
{
std::vector<FP_TEXT*> texts; // List of FP_TEXT to convert
@ -2784,10 +2770,7 @@ void FOOTPRINT::TransformFPShapesWithClearanceToPolygon( SHAPE_POLY_SET& aCorner
FP_TEXTBOX* textbox = static_cast<FP_TEXTBOX*>( item );
if( aLayer != UNDEFINED_LAYER && textbox->GetLayer() == aLayer && textbox->IsVisible() )
{
textbox->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0,
aError, aErrorLoc, false );
}
textbox->TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
}
if( item->Type() == PCB_FP_SHAPE_T && aIncludeShapes )
@ -2795,10 +2778,7 @@ void FOOTPRINT::TransformFPShapesWithClearanceToPolygon( SHAPE_POLY_SET& aCorner
const FP_SHAPE* outline = static_cast<FP_SHAPE*>( item );
if( aLayer != UNDEFINED_LAYER && outline->GetLayer() == aLayer )
{
outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0,
aError, aErrorLoc );
}
outline->TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
}
}
@ -2812,10 +2792,7 @@ void FOOTPRINT::TransformFPShapesWithClearanceToPolygon( SHAPE_POLY_SET& aCorner
}
for( const FP_TEXT* text : texts )
{
text->TransformTextShapeWithClearanceToPolygon( aCornerBuffer, aLayer, aClearance,
aError, aErrorLoc );
}
text->TransformTextToPolySet( aBuffer, aLayer, aClearance, aError, aErrorLoc );
}

View File

@ -425,13 +425,13 @@ public:
/**
* Generate pads shapes on layer \a aLayer as polygons and adds these polygons to
* \a aCornerBuffer.
* \a aBuffer.
*
* Useful to generate a polygonal representation of a footprint in 3D view and plot functions,
* when a full polygonal approach is needed.
*
* @param aLayer is the layer to consider, or #UNDEFINED_LAYER to consider all layers.
* @param aCornerBuffer i the buffer to store polygons.
* @param aBuffer i the buffer to store polygons.
* @param aClearance is an additional size to add to pad shapes.
* @param aMaxError is the maximum deviation from true for arcs.
* @param aSkipNPTHPadsWihNoCopper if true, do not add a NPTH pad shape, if the shape has
@ -443,44 +443,39 @@ public:
* @param aSkipPlatedPads is used on 3D-Viewer to extract plated and non-plated pads.
* @param aSkipNonPlatedPads is used on 3D-Viewer to extract plated and plated pads.
*/
void TransformPadsWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aMaxError, ERROR_LOC aErrorLoc,
bool aSkipNPTHPadsWihNoCopper = false,
bool aSkipPlatedPads = false,
bool aSkipNonPlatedPads = false ) const;
void TransformPadsToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
int aMaxError, ERROR_LOC aErrorLoc,
bool aSkipNPTHPadsWihNoCopper = false,
bool aSkipPlatedPads = false,
bool aSkipNonPlatedPads = false ) const;
/**
* Generate shapes of graphic items (outlines) on layer \a aLayer as polygons and adds these
* polygons to \a aCornerBuffer.
* polygons to \a aBuffer.
*
* Useful to generate a polygonal representation of a footprint in 3D view and plot functions,
* when a full polygonal approach is needed.
*
* @param aLayer is the layer to consider, or #UNDEFINED_LAYER to consider all.
* @param aCornerBuffer is the buffer to store polygons.
* @param aBuffer is the buffer to store polygons.
* @param aClearance is a value to inflate shapes.
* @param aError is the maximum error between true arc and polygon approximation.
* @param aIncludeText set to true to transform text shapes.
* @param aIncludeShapes set to true to transform footprint shapes.
*/
void TransformFPShapesWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc,
bool aIncludeText = true,
bool aIncludeShapes = true,
bool aIncludePrivateItems = false ) const;
void TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc,
bool aIncludeText = true,
bool aIncludeShapes = true,
bool aIncludePrivateItems = false ) const;
/**
* This function is the same as TransformGraphicShapesWithClearanceToPolygonSet
* but only generate text.
* This function is the same as TransformFPShapesToPolySet but only generates text.
*/
void TransformFPTextWithClearanceToPolygonSet( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc ) const
void TransformFPTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc ) const
{
TransformFPShapesWithClearanceToPolygon( aCornerBuffer, aLayer, aClearance, aError,
aErrorLoc, true, false );
TransformFPShapesToPolySet( aBuffer, aLayer, aClearance, aError, aErrorLoc, true, false );
}
/**

View File

@ -450,9 +450,8 @@ std::shared_ptr<SHAPE> FP_TEXT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING
}
void FP_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc ) const
void FP_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc ) const
{
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
KIFONT::FONT* font = GetDrawFont();
@ -469,8 +468,8 @@ void FP_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB
// Stroke callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
{
TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth+ ( 2 * aClearance ),
aError, ERROR_INSIDE );
TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth + ( 2 * aClearance ), aError,
ERROR_INSIDE );
},
// Triangulation callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
@ -487,19 +486,17 @@ void FP_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB
font->Draw( &callback_gal, GetShownText(), GetTextPos(), attrs );
buffer.Simplify( SHAPE_POLY_SET::PM_FAST );
aCornerBuffer.Append( buffer );
aBuffer.Append( buffer );
}
void FP_TEXT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc,
bool aIgnoreLineWidth ) const
void FP_TEXT::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const
{
SHAPE_POLY_SET buffer;
EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( &buffer, aClearance );
aCornerBuffer.Append( buffer );
EDA_TEXT::TransformBoundingBoxToPolygon( &buffer, aClearance );
aBuffer.Append( buffer );
}

View File

@ -155,13 +155,12 @@ public:
return TextHitTest( aRect, aContained, aAccuracy );
}
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, PCB_LAYER_ID aLayer,
int aClearance, int aError, ERROR_LOC aErrorLoc,
bool aIgnoreLineWidth ) const override;
void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc,
bool aIgnoreLineWidth ) const override;
void TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearanceValue,
int aError, ERROR_LOC aErrorLoc ) const;
void TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc ) const;
// @copydoc BOARD_ITEM::GetEffectiveShape
std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,

View File

@ -440,9 +440,8 @@ std::shared_ptr<SHAPE> FP_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASH
}
void FP_TEXTBOX::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc ) const
void FP_TEXTBOX::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
int aClearance, int aError, ERROR_LOC aErrorLoc ) const
{
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
KIFONT::FONT* font = GetDrawFont();
@ -459,8 +458,8 @@ void FP_TEXTBOX::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCorn
// Stroke callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
{
TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth + ( 2 * aClearance ),
aError, ERROR_INSIDE );
TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth + ( 2 * aClearance ), aError,
ERROR_INSIDE );
},
// Triangulation callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
@ -477,34 +476,33 @@ void FP_TEXTBOX::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCorn
font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs );
buffer.Simplify( SHAPE_POLY_SET::PM_FAST );
aCornerBuffer.Append( buffer );
aBuffer.Append( buffer );
}
void FP_TEXTBOX::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
PCB_LAYER_ID aLayer, int aClearance,
int aError, ERROR_LOC aErrorLoc,
bool aIgnoreLineWidth ) const
void FP_TEXTBOX::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
int aClearance, int aError, ERROR_LOC aErrorLoc,
bool aIgnoreLineWidth ) const
{
// Don't use FP_SHAPE::TransformShapeWithClearanceToPolygon. We want to treat the
// textbox as filled even if there's no background colour.
// Don't use FP_SHAPE::TransformShapeToPolygon. We want to treat the textbox as filled even
// if there's no background colour.
std::vector<VECTOR2I> pts = GetRectCorners();
aCornerBuffer.NewOutline();
aBuffer.NewOutline();
for( const VECTOR2I& pt : pts )
aCornerBuffer.Append( pt );
aBuffer.Append( pt );
int width = GetWidth() + ( 2 * aClearance );
if( width > 0 )
{
// Add in segments
TransformOvalToPolygon( aCornerBuffer, pts[0], pts[1], width, aError, aErrorLoc );
TransformOvalToPolygon( aCornerBuffer, pts[1], pts[2], width, aError, aErrorLoc );
TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError, aErrorLoc );
TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aError, aErrorLoc );
TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aError, aErrorLoc );
}
}

Some files were not shown because too many files have changed in this diff Show More