diff --git a/3d-viewer/3d_canvas/board_adapter.h b/3d-viewer/3d_canvas/board_adapter.h index 33743e00de..32fbd96c6f 100644 --- a/3d-viewer/3d_canvas/board_adapter.h +++ b/3d-viewer/3d_canvas/board_adapter.h @@ -579,6 +579,7 @@ class BOARD_ADAPTER void createNewPadWithClearance( const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, + PCB_LAYER_ID aLayer, wxSize aClearanceValue ) const; COBJECT2D *createNewPadDrill( const D_PAD* aPad, int aInflateValue ); diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index 3836e25e34..6e0bc4ee3f 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -81,7 +81,7 @@ void addTextSegmToContainer( int x0, int y0, int xf, int yf, void* aData ) // Based on -// void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet +// void TEXTE_PCB::TransformShapeWithClearanceToPolygon // board_items_to_polygon_shape_transform.cpp void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const TEXTE_PCB* aText, CGENERICCONTAINER2D *aDstContainer, @@ -314,6 +314,7 @@ void BOARD_ADAPTER::createNewTrack( const TRACK* aTrack, CGENERICCONTAINER2D *aD void BOARD_ADAPTER::createNewPadWithClearance( const D_PAD* aPad, CGENERICCONTAINER2D *aDstContainer, + PCB_LAYER_ID aLayer, wxSize aClearanceValue ) const { SHAPE_POLY_SET poly; @@ -325,7 +326,7 @@ void BOARD_ADAPTER::createNewPadWithClearance( const D_PAD* aPad, // we fake a larger pad and run the general-purpose polygon builder on it. D_PAD dummy( *aPad ); dummy.SetSize( aPad->GetSize() + aClearanceValue + aClearanceValue ); - dummy.TransformShapeWithClearanceToPolygon( poly, 0 ); + dummy.TransformShapeWithClearanceToPolygon( poly, aLayer, 0 ); } else { @@ -508,7 +509,7 @@ void BOARD_ADAPTER::AddPadsShapesWithClearanceToContainer( const MODULE* aModule break; } - createNewPadWithClearance( pad, aDstContainer, margin ); + createNewPadWithClearance( pad, aDstContainer, aLayerId, margin ); } } @@ -648,7 +649,8 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDrawSe { SHAPE_POLY_SET polyList; - aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aClearanceValue ); + aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aLayerId, + aClearanceValue ); polyList.Simplify( SHAPE_POLY_SET::PM_FAST ); @@ -701,7 +703,7 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDrawSe { SHAPE_POLY_SET polyList; - aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aClearanceValue ); + aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aLayerId, aClearanceValue ); polyList.Simplify( SHAPE_POLY_SET::PM_FAST ); diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index d1bccd6ef1..fc533301f3 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -466,7 +466,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) continue; // Add the track/via contour - track->TransformShapeWithClearanceToPolygon( *layerPoly, 0 ); + track->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0 ); } } } @@ -681,7 +681,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) switch( item->Type() ) { case PCB_LINE_T: - ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( *layerPoly, 0 ); + ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( *layerPoly, + cur_layer_id, 0 ); break; case PCB_TEXT_T: @@ -960,7 +961,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) switch( item->Type() ) { case PCB_LINE_T: - ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( *layerPoly, 0 ); + ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( *layerPoly, + curr_layer_id, 0 ); break; case PCB_TEXT_T: diff --git a/3d-viewer/3d_canvas/create_layer_poly.cpp b/3d-viewer/3d_canvas/create_layer_poly.cpp index ab146c375e..477683faea 100644 --- a/3d-viewer/3d_canvas/create_layer_poly.cpp +++ b/3d-viewer/3d_canvas/create_layer_poly.cpp @@ -71,7 +71,7 @@ void BOARD_ADAPTER::transformGraphicModuleEdgeToPolygonSet( const MODULE *aModul EDGE_MODULE* outline = (EDGE_MODULE*) item; if( outline->GetLayer() == aLayer ) - outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, 0 ); + outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0 ); } } } diff --git a/include/class_board_item.h b/include/class_board_item.h index eb0959f49b..4580c823fe 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -356,7 +356,10 @@ public: * for visualization */ virtual void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, - int aClearanceValue, int aError = ARC_LOW_DEF, bool ignoreLineWidth = false ) const; + PCB_LAYER_ID aLayer, + int aClearanceValue, + int aError = ARC_LOW_DEF, + bool ignoreLineWidth = false ) const; struct ptr_cmp { diff --git a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp index 7f99c8bca7..fe93af43a3 100644 --- a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp +++ b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp @@ -1619,7 +1619,8 @@ void ALTIUM_PCB::ParseArcs6Data( zone->SetDoNotAllowFootprints( false ); zone->SetDoNotAllowCopperPour( true ); - ds.TransformShapeWithClearanceToPolygon( *zone->Outline(), 0, ARC_HIGH_DEF, false ); + ds.TransformShapeWithClearanceToPolygon( *zone->Outline(), klayer, 0, ARC_HIGH_DEF, + false ); zone->Outline()->Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); // the outline is not a single polygon! zone->SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE, @@ -2173,7 +2174,8 @@ void ALTIUM_PCB::ParseTracks6Data( zone->SetDoNotAllowFootprints( false ); zone->SetDoNotAllowCopperPour( true ); - ds.TransformShapeWithClearanceToPolygon( *zone->Outline(), 0, ARC_HIGH_DEF, false ); + ds.TransformShapeWithClearanceToPolygon( *zone->Outline(), klayer, 0, ARC_HIGH_DEF, + false ); zone->SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE, ZONE_CONTAINER::GetDefaultHatchPitch(), true ); diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 625842aa79..4b4752752c 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -73,7 +73,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_ if( !track->IsOnLayer( aLayer ) ) continue; - track->TransformShapeWithClearanceToPolygon( aOutlines, 0 ); + track->TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0 ); } // convert pads @@ -103,7 +103,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_ switch( item->Type() ) { case PCB_LINE_T: - ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( aOutlines, 0 ); + ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0 ); break; case PCB_TEXT_T: @@ -173,7 +173,7 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( PCB_LAYER_ID aLayer, break; } - pad->TransformShapeWithClearanceToPolygon( aCornerBuffer, clearance ); + pad->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, clearance ); } } @@ -209,7 +209,7 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( PCB_LAYER_ID aLaye EDGE_MODULE* outline = (EDGE_MODULE*) item; if( aLayer != UNDEFINED_LAYER && outline->GetLayer() == aLayer ) - outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, 0, aError ); + outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0, aError ); } } @@ -354,9 +354,13 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( SHAPE_POLY_SET& aCorner void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, + PCB_LAYER_ID aLayer, int aClearanceValue, int aError, bool ignoreLineWidth ) const { + if( aLayer != m_Layer ) + return; + int width = ignoreLineWidth ? 0 : m_Width; width += 2 * aClearanceValue; @@ -478,6 +482,7 @@ void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB void TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, + PCB_LAYER_ID aLayer, int aClearanceValue, int aError, bool ignoreLineWidth ) const { @@ -512,6 +517,7 @@ void TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, void D_PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, + PCB_LAYER_ID aLayer, int aClearanceValue, int aError, bool ignoreLineWidth ) const { @@ -614,7 +620,7 @@ void D_PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, case PAD_SHAPE_CUSTOM: { SHAPE_POLY_SET outline; - MergePrimitivesAsPolygon( &outline ); + MergePrimitivesAsPolygon( &outline, aLayer ); outline.Rotate( -DECIDEG2RAD( m_orient ) ); outline.Move( VECTOR2I( m_pos ) ); @@ -663,19 +669,15 @@ bool D_PAD::TransformHoleWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, void ZONE_CONTAINER::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, - int aClearanceValue, int aError, - bool ignoreLineWidth ) const + PCB_LAYER_ID aLayer, int aClearance, + int aError, bool ignoreLineWidth ) const { - // Now that zones are multilayer, we cannot implement this without a layer argument. - // But, at the time of adding multilayer zones, this is never called for zones anyway - // so let's just disable it and fail. - wxFAIL_MSG( "TransformShapeWithClearanceToPolygon is not supported for zones" ); + wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for zones." ); -#if 0 if( !m_FilledPolysList.count( aLayer ) ) return; aCornerBuffer = m_FilledPolysList.at( aLayer ); + aCornerBuffer.Inflate( aClearance, aError ); aCornerBuffer.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); -#endif } diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index 459b81ca2c..9a6a43b7db 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -132,6 +132,7 @@ void BOARD_ITEM::SwapData( BOARD_ITEM* aImage ) void BOARD_ITEM::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, + PCB_LAYER_ID aLayer, int aClearanceValue, int aError, bool ignoreLineWidth ) const { diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index 3192336a9b..621b438401 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -312,8 +312,9 @@ public: * @param ignoreLineWidth = used for edge cut items where the line width is only * for visualization */ - void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearanceValue, - int aError = ARC_HIGH_DEF, bool ignoreLineWidth = false ) const override; + void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, PCB_LAYER_ID aLayer, + int aClearanceValue, int aError = ARC_HIGH_DEF, + bool ignoreLineWidth = false ) const override; virtual wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 68d192e215..6680a9efc6 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -246,19 +246,19 @@ void D_PAD::SetChamferRectRatio( double aChamferScale ) } -const std::vector>& D_PAD::GetEffectiveShapes() const +const std::vector>& D_PAD::GetEffectiveShapes( PCB_LAYER_ID aLayer ) const { if( m_shapesDirty ) - BuildEffectiveShapes(); + BuildEffectiveShapes( aLayer ); return m_effectiveShapes; } -const std::shared_ptr& D_PAD::GetEffectivePolygon() const +const std::shared_ptr& D_PAD::GetEffectivePolygon( PCB_LAYER_ID aLayer ) const { if( m_shapesDirty ) - BuildEffectiveShapes(); + BuildEffectiveShapes( aLayer ); return m_effectivePolygon; } @@ -269,9 +269,9 @@ std::shared_ptr D_PAD::GetEffectiveShape( PCB_LAYER_ID aLayer ) const std::shared_ptr shape( new SHAPE_COMPOUND ); if( m_shapesDirty ) - BuildEffectiveShapes(); + BuildEffectiveShapes( aLayer ); - for( auto s : m_effectiveShapes ) + for( std::shared_ptr& s : m_effectiveShapes ) shape->AddShape( s->Clone() ); // fixme: use COMPOUND everywhere return shape; @@ -281,7 +281,7 @@ std::shared_ptr D_PAD::GetEffectiveShape( PCB_LAYER_ID aLayer ) const const SHAPE_SEGMENT* D_PAD::GetEffectiveHoleShape() const { if( m_shapesDirty ) - BuildEffectiveShapes(); + BuildEffectiveShapes( UNDEFINED_LAYER ); return m_effectiveHoleShape.get(); } @@ -290,13 +290,13 @@ const SHAPE_SEGMENT* D_PAD::GetEffectiveHoleShape() const int D_PAD::GetBoundingRadius() const { if( m_shapesDirty ) - BuildEffectiveShapes(); + BuildEffectiveShapes( UNDEFINED_LAYER ); return m_effectiveBoundingRadius; } -void D_PAD::BuildEffectiveShapes() const +void D_PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const { m_effectiveShapes.clear(); m_effectiveHoleShape = nullptr; @@ -420,10 +420,13 @@ void D_PAD::BuildEffectiveShapes() const // Polygon // m_effectivePolygon = std::make_shared(); - TransformShapeWithClearanceToPolygon( *m_effectivePolygon, 0 ); + TransformShapeWithClearanceToPolygon( *m_effectivePolygon, aLayer, 0 ); // Bounding box and radius // + // PADSTACKS TODO: these will both need to cycle through all layers to get the largest + // values.... + // m_effectiveBoundingRadius = 0; for( int cnt = 0; cnt < m_effectivePolygon->OutlineCount(); ++cnt ) @@ -468,7 +471,7 @@ void D_PAD::BuildEffectiveShapes() const const EDA_RECT D_PAD::GetBoundingBox() const { if( m_shapesDirty ) - BuildEffectiveShapes(); + BuildEffectiveShapes( UNDEFINED_LAYER ); return m_effectiveBoundingBox; } diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 5c0eba9b28..b951c589d7 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -260,7 +260,7 @@ public: * Merge all basic shapes to a SHAPE_POLY_SET * Note: The corners coordinates are relative to the pad position, orientation 0, */ - void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon ) const; + void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer ) const; /** * clear the basic shapes list @@ -367,8 +367,8 @@ public: * @param aMaxError = maximum error from true when converting arcs * @param ignoreLineWidth = used for edge cuts where the line width is only for visualization */ - void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearanceValue, - int aMaxError = ARC_HIGH_DEF, + void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, PCB_LAYER_ID aLayer, + int aClearanceValue, int aMaxError = ARC_HIGH_DEF, bool ignoreLineWidth = false ) const override; /** @@ -385,9 +385,9 @@ public: // @copydoc BOARD_ITEM::GetEffectiveShape virtual std::shared_ptr GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override; - const std::vector>& GetEffectiveShapes() const; + const std::vector>& GetEffectiveShapes( PCB_LAYER_ID = UNDEFINED_LAYER ) const; - const std::shared_ptr& GetEffectivePolygon() const; + const std::shared_ptr& GetEffectivePolygon( PCB_LAYER_ID = UNDEFINED_LAYER ) const; /** * Function GetEffectiveHoleShape @@ -604,7 +604,7 @@ public: * Rebuilds the effective shape cache (and bounding box and radius) for the pad and clears * the dirty bit. */ - void BuildEffectiveShapes() const; + void BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const; virtual void ViewGetLayers( int aLayers[], int& aCount ) const override; @@ -620,7 +620,8 @@ public: private: - void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError ) const; + void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer, + int aError ) const; private: wxString m_name; // Pad name (pin number in schematic) diff --git a/pcbnew/class_pcb_group.cpp b/pcbnew/class_pcb_group.cpp index 9d662001ac..688032fbaa 100644 --- a/pcbnew/class_pcb_group.cpp +++ b/pcbnew/class_pcb_group.cpp @@ -116,7 +116,9 @@ void PCB_GROUP::SwapData( BOARD_ITEM* aImage ) #if 0 void PCB_GROUP::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, - int aClearanceValue, int aError = ARC_LOW_DEF, bool ignoreLineWidth = false ) const + PCB_LAYER_ID aLayer, int aClearanceValue, + int aError = ARC_LOW_DEF, + bool ignoreLineWidth = false ) const { } const BOX2I PCB_GROUP::ViewBBox() const diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index c5ca09d99d..3c8d560545 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -164,8 +164,9 @@ public: * @param ignoreLineWidth = used for edge cut items where the line width is only * for visualization */ - void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearanceValue, - int aError = ARC_HIGH_DEF, bool ignoreLineWidth = false ) const override; + void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, PCB_LAYER_ID aLayer, + int aClearanceValue, int aError = ARC_HIGH_DEF, + bool ignoreLineWidth = false ) const override; /** * Function IsPointOnEnds * returns STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index b1adbb4d9a..e67ab58545 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -363,7 +363,7 @@ public: * @param ignoreLineWidth = used for edge cut items where the line width is only * for visualization */ - void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, + void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError = ARC_HIGH_DEF, bool ignoreLineWidth = false ) const override; diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 4ec9bde1cc..f9f3787885 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -1187,10 +1187,11 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK() } } + // PADSTACKS TODO: this will need to check each layer in the pad... if( m_dummyPad->GetShape() == PAD_SHAPE_CUSTOM ) { SHAPE_POLY_SET mergedPolygon; - m_dummyPad->MergePrimitivesAsPolygon( &mergedPolygon ); + m_dummyPad->MergePrimitivesAsPolygon( &mergedPolygon, UNDEFINED_LAYER ); if( mergedPolygon.OutlineCount() > 1 ) error_msgs.Add( _( "Incorrect pad shape: the shape must be equivalent to only one polygon" ) ); diff --git a/pcbnew/drc/drc_keepout_tester.cpp b/pcbnew/drc/drc_keepout_tester.cpp index ac549d5a65..76909f7555 100644 --- a/pcbnew/drc/drc_keepout_tester.cpp +++ b/pcbnew/drc/drc_keepout_tester.cpp @@ -298,7 +298,7 @@ bool DRC_KEEPOUT_TESTER::checkDrawings() continue; SHAPE_POLY_SET poly; - drawing->TransformShapeWithClearanceToPolygon( poly, 0 ); + drawing->TransformShapeWithClearanceToPolygon( poly, drawing->GetLayer(), 0 ); // Build the common area between footprint and the keepout area: poly.BooleanIntersection( *m_zone->Outline(), SHAPE_POLY_SET::PM_FAST ); diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index d31b01033f..1246f15773 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -585,7 +585,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ) fprintf( aFile, " POLYGON %g\n", pad->GetDrillSize().x / SCALE_FACTOR ); SHAPE_POLY_SET outline; - pad->MergePrimitivesAsPolygon( &outline ); + pad->MergePrimitivesAsPolygon( &outline, UNDEFINED_LAYER ); for( int jj = 0; jj < outline.OutlineCount(); ++jj ) { diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index 6aa8451353..e738eee8ce 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -1174,7 +1174,7 @@ static void export_vrml_padshape( MODEL_VRML& aModel, VRML_LAYER* aTinLayer, D_P { SHAPE_POLY_SET polySet; std::vector< wxRealPoint > cornerList; - aPad->MergePrimitivesAsPolygon( &polySet ); + aPad->MergePrimitivesAsPolygon( &polySet, UNDEFINED_LAYER ); for( int cnt = 0; cnt < polySet.OutlineCount(); ++cnt ) { diff --git a/pcbnew/pad_custom_shape_functions.cpp b/pcbnew/pad_custom_shape_functions.cpp index 1a33cbede5..10a135a025 100644 --- a/pcbnew/pad_custom_shape_functions.cpp +++ b/pcbnew/pad_custom_shape_functions.cpp @@ -175,12 +175,13 @@ void D_PAD::DeletePrimitivesList() } -void D_PAD::addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError ) const +void D_PAD::addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer, + int aError ) const { SHAPE_POLY_SET polyset; for( const std::shared_ptr& primitive : m_editPrimitives ) - primitive->TransformShapeWithClearanceToPolygon( polyset, 0, aError ); + primitive->TransformShapeWithClearanceToPolygon( polyset, aLayer, 0, aError ); polyset.Simplify( SHAPE_POLY_SET::PM_FAST ); @@ -192,7 +193,7 @@ void D_PAD::addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, int aErro } } -void D_PAD::MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon ) const +void D_PAD::MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer ) const { auto board = GetBoard(); int maxError = ARC_HIGH_DEF; @@ -219,14 +220,14 @@ void D_PAD::MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon ) const break; } - addPadPrimitivesToPolygon( aMergedPolygon, maxError ); + addPadPrimitivesToPolygon( aMergedPolygon, aLayer, maxError ); } bool D_PAD::GetBestAnchorPosition( VECTOR2I& aPos ) { SHAPE_POLY_SET poly; - addPadPrimitivesToPolygon( &poly, ARC_LOW_DEF ); + addPadPrimitivesToPolygon( &poly, UNDEFINED_LAYER, ARC_LOW_DEF ); if( poly.OutlineCount() > 1 ) return false; diff --git a/pcbnew/pcb_expr_evaluator.cpp b/pcbnew/pcb_expr_evaluator.cpp index 84fb057f2e..fa53e70eb7 100644 --- a/pcbnew/pcb_expr_evaluator.cpp +++ b/pcbnew/pcb_expr_evaluator.cpp @@ -131,7 +131,7 @@ static void insideCourtyard( LIBEVAL::CONTEXT* aCtx, void* self ) SHAPE_POLY_SET testPoly; - item->TransformShapeWithClearanceToPolygon( testPoly, 0 ); + item->TransformShapeWithClearanceToPolygon( testPoly, context->GetLayer(), 0 ); testPoly.BooleanIntersection( footprintCourtyard, SHAPE_POLY_SET::PM_FAST ); if( testPoly.OutlineCount() ) @@ -188,7 +188,7 @@ static void insideArea( LIBEVAL::CONTEXT* aCtx, void* self ) SHAPE_POLY_SET zonePoly = zone->GetFilledPolysList( context->GetLayer() ); SHAPE_POLY_SET testPoly; - item->TransformShapeWithClearanceToPolygon( testPoly, 0 ); + item->TransformShapeWithClearanceToPolygon( testPoly, context->GetLayer(), 0 ); testPoly.BooleanIntersection( zonePoly, SHAPE_POLY_SET::PM_FAST ); if( testPoly.OutlineCount() ) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index ff85891780..91923150b5 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -902,7 +902,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) else { SHAPE_POLY_SET polySet; - pad->TransformShapeWithClearanceToPolygon( polySet, margin.x ); + pad->TransformShapeWithClearanceToPolygon( polySet, ToLAYER_ID( aLayer ), margin.x ); m_gal->DrawPolygon( polySet ); } @@ -940,7 +940,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) else { SHAPE_POLY_SET polySet; - pad->TransformShapeWithClearanceToPolygon( polySet, clearance ); + pad->TransformShapeWithClearanceToPolygon( polySet, ToLAYER_ID( aLayer ), clearance ); m_gal->DrawPolygon( polySet ); } } diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 1091458712..24d7fbd7ab 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -339,7 +339,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, // so build a similar pad shape, and inflate/deflate the polygonal shape D_PAD dummy( *pad ); SHAPE_POLY_SET shape; - pad->MergePrimitivesAsPolygon( &shape ); + pad->MergePrimitivesAsPolygon( &shape, UNDEFINED_LAYER ); // Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate() // which can create bad shapes if margin.x is < 0 int maxError = aBoard->GetDesignSettings().m_MaxError; @@ -850,9 +850,9 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, continue; // add shapes with their exact mask layer size in initialPolys - via->TransformShapeWithClearanceToPolygon( initialPolys, via_clearance ); + via->TransformShapeWithClearanceToPolygon( initialPolys, layer, via_clearance ); // add shapes inflated by aMinThickness/2 in areas - via->TransformShapeWithClearanceToPolygon( areas, via_margin ); + via->TransformShapeWithClearanceToPolygon( areas, layer, via_margin ); } } diff --git a/pcbnew/specctra_import_export/specctra_export.cpp b/pcbnew/specctra_import_export/specctra_export.cpp index cac1f74f3e..02b7f89e75 100644 --- a/pcbnew/specctra_import_export/specctra_export.cpp +++ b/pcbnew/specctra_import_export/specctra_export.cpp @@ -535,7 +535,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) { std::vector polygonal_shape; SHAPE_POLY_SET pad_shape; - aPad->MergePrimitivesAsPolygon( &pad_shape ); + aPad->MergePrimitivesAsPolygon( &pad_shape, UNDEFINED_LAYER ); #ifdef EXPORT_CUSTOM_PADS_CONVEX_HULL BuildConvexHull( polygonal_shape, pad_shape ); diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index 5a9ba79e90..8269ee4000 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -607,7 +607,7 @@ void PAD_TOOL::recombinePad( D_PAD* aPad ) auto findNext = [&]( PCB_LAYER_ID aLayer ) -> EDGE_MODULE* { SHAPE_POLY_SET padPoly; - aPad->TransformShapeWithClearanceToPolygon( padPoly, 0 ); + aPad->TransformShapeWithClearanceToPolygon( padPoly, aLayer, 0 ); for( BOARD_ITEM* item : board()->GetFirstModule()->GraphicalItems() ) { @@ -620,7 +620,7 @@ void PAD_TOOL::recombinePad( D_PAD* aPad ) continue; SHAPE_POLY_SET drawPoly; - draw->TransformShapeWithClearanceToPolygon( drawPoly, 0 ); + draw->TransformShapeWithClearanceToPolygon( drawPoly, aLayer, 0 ); drawPoly.BooleanIntersection( padPoly, SHAPE_POLY_SET::PM_FAST ); if( !drawPoly.IsEmpty() ) @@ -657,7 +657,7 @@ void PAD_TOOL::recombinePad( D_PAD* aPad ) // to a polygon primitive SHAPE_POLY_SET existingOutline; int maxError = board()->GetDesignSettings().m_MaxError; - aPad->TransformShapeWithClearanceToPolygon( existingOutline, 0, maxError ); + aPad->TransformShapeWithClearanceToPolygon( existingOutline, layer, 0, maxError ); aPad->SetAnchorPadShape( PAD_SHAPE_CIRCLE ); wxSize minAnnulus( Millimeter2iu( 0.2 ), Millimeter2iu( 0.2 ) ); diff --git a/pcbnew/tracks_cleaner.cpp b/pcbnew/tracks_cleaner.cpp index b561edb5ce..d3f9f68509 100644 --- a/pcbnew/tracks_cleaner.cpp +++ b/pcbnew/tracks_cleaner.cpp @@ -331,7 +331,7 @@ void TRACKS_CLEANER::deleteTracksInPads() if( pad->HitTest( track->GetStart() ) && pad->HitTest( track->GetEnd() ) ) { SHAPE_POLY_SET poly; - track->TransformShapeWithClearanceToPolygon( poly, 0 ); + track->TransformShapeWithClearanceToPolygon( poly, track->GetLayer(), 0 ); poly.BooleanSubtract( *pad->GetEffectivePolygon(), SHAPE_POLY_SET::PM_FAST ); diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index a48cec319d..30bf3777f1 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -131,7 +131,7 @@ bool ZONE_FILLER::Fill( const std::vector& aZones, bool aCheck for( auto pad : module->Pads() ) { if( pad->IsDirty() ) - pad->BuildEffectiveShapes(); + pad->BuildEffectiveShapes( UNDEFINED_LAYER ); } } @@ -439,12 +439,12 @@ static void setupDummyPadForHole( const D_PAD* aPad, D_PAD& aDummyPad ) * Add a knockout for a pad. The knockout is 'aGap' larger than the pad (which might be * either the thermal clearance or the electrical clearance). */ -void ZONE_FILLER::addKnockout( D_PAD* aPad, int aGap, SHAPE_POLY_SET& aHoles ) +void ZONE_FILLER::addKnockout( D_PAD* aPad, PCB_LAYER_ID aLayer, int aGap, SHAPE_POLY_SET& aHoles ) { if( aPad->GetShape() == PAD_SHAPE_CUSTOM ) { SHAPE_POLY_SET poly; - aPad->TransformShapeWithClearanceToPolygon( poly, aGap, m_high_def ); + aPad->TransformShapeWithClearanceToPolygon( poly, aLayer, aGap, m_high_def ); // the pad shape in zone can be its convex hull or the shape itself if( aPad->GetCustomShapeInZoneOpt() == CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL ) @@ -467,9 +467,9 @@ void ZONE_FILLER::addKnockout( D_PAD* aPad, int aGap, SHAPE_POLY_SET& aHoles ) // small arcs) if( aPad->GetShape() == PAD_SHAPE_CIRCLE || aPad->GetShape() == PAD_SHAPE_OVAL || ( aPad->GetShape() == PAD_SHAPE_ROUNDRECT && aPad->GetRoundRectRadiusRatio() > 0.4 ) ) - aPad->TransformShapeWithClearanceToPolygon( aHoles, aGap, m_high_def ); + aPad->TransformShapeWithClearanceToPolygon( aHoles, aLayer, aGap, m_high_def ); else - aPad->TransformShapeWithClearanceToPolygon( aHoles, aGap, m_low_def ); + aPad->TransformShapeWithClearanceToPolygon( aHoles, aLayer, aGap, m_low_def ); } } @@ -478,15 +478,16 @@ void ZONE_FILLER::addKnockout( D_PAD* aPad, int aGap, SHAPE_POLY_SET& aHoles ) * Add a knockout for a graphic item. The knockout is 'aGap' larger than the item (which * might be either the electrical clearance or the board edge clearance). */ -void ZONE_FILLER::addKnockout( BOARD_ITEM* aItem, int aGap, bool aIgnoreLineWidth, - SHAPE_POLY_SET& aHoles ) +void ZONE_FILLER::addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap, + bool aIgnoreLineWidth, SHAPE_POLY_SET& aHoles ) { switch( aItem->Type() ) { case PCB_LINE_T: { DRAWSEGMENT* seg = (DRAWSEGMENT*) aItem; - seg->TransformShapeWithClearanceToPolygon( aHoles, aGap, m_high_def, aIgnoreLineWidth ); + seg->TransformShapeWithClearanceToPolygon( aHoles, aLayer, aGap, m_high_def, + aIgnoreLineWidth ); break; } case PCB_TEXT_T: @@ -498,7 +499,8 @@ void ZONE_FILLER::addKnockout( BOARD_ITEM* aItem, int aGap, bool aIgnoreLineWidt case PCB_MODULE_EDGE_T: { EDGE_MODULE* edge = (EDGE_MODULE*) aItem; - edge->TransformShapeWithClearanceToPolygon( aHoles, aGap, m_high_def, aIgnoreLineWidth ); + edge->TransformShapeWithClearanceToPolygon( aHoles, aLayer, aGap, m_high_def, + aIgnoreLineWidth ); break; } case PCB_MODULE_TEXT_T: @@ -550,7 +552,7 @@ void ZONE_FILLER::knockoutThermalReliefs( const ZONE_CONTAINER* aZone, PCB_LAYER pad = &dummypad; } - addKnockout( pad, aZone->GetThermalReliefGap( pad ), holes ); + addKnockout( pad, aLayer, aZone->GetThermalReliefGap( pad ), holes ); } } @@ -620,7 +622,7 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA else gap = aZone->GetClearance( aLayer, pad ); - addKnockout( pad, gap, aHoles ); + addKnockout( pad, aLayer, gap, aHoles ); } } } @@ -651,12 +653,12 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA } else { - via->TransformShapeWithClearanceToPolygon( aHoles, gap, m_low_def ); + via->TransformShapeWithClearanceToPolygon( aHoles, aLayer, gap, m_low_def ); } } else { - track->TransformShapeWithClearanceToPolygon( aHoles, gap, m_low_def ); + track->TransformShapeWithClearanceToPolygon( aHoles, aLayer, gap, m_low_def ); } } } @@ -676,7 +678,7 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA bool ignoreLineWidth = aItem->IsOnLayer( Edge_Cuts ); int gap = aZone->GetClearance( aLayer, aItem ); - addKnockout( aItem, gap, ignoreLineWidth, aHoles ); + addKnockout( aItem, aLayer, gap, ignoreLineWidth, aHoles ); } }; @@ -1291,7 +1293,8 @@ void ZONE_FILLER::addHatchFillTypeOnZone( const ZONE_CONTAINER* aZone, PCB_LAYER outline_margin - min_annulus ); clearance = std::max( 0, clearance - linethickness / 2 ); - pad->TransformShapeWithClearanceToPolygon( aprons, clearance, ARC_HIGH_DEF ); + pad->TransformShapeWithClearanceToPolygon( aprons, aLayer, clearance, + ARC_HIGH_DEF ); } } } diff --git a/pcbnew/zone_filler.h b/pcbnew/zone_filler.h index 066dc291dd..512324b7c2 100644 --- a/pcbnew/zone_filler.h +++ b/pcbnew/zone_filler.h @@ -47,9 +47,10 @@ public: private: - void addKnockout( D_PAD* aPad, int aGap, SHAPE_POLY_SET& aHoles ); + void addKnockout( D_PAD* aPad, PCB_LAYER_ID aLayer, int aGap, SHAPE_POLY_SET& aHoles ); - void addKnockout( BOARD_ITEM* aItem, int aGap, bool aIgnoreLineWidth, SHAPE_POLY_SET& aHoles ); + void addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap, bool aIgnoreLineWidth, + SHAPE_POLY_SET& aHoles ); void knockoutThermalReliefs( const ZONE_CONTAINER* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aFill ); diff --git a/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp b/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp index 34e983b43c..f91638797f 100644 --- a/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp +++ b/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp @@ -46,7 +46,7 @@ void process( const BOARD_CONNECTED_ITEM* item, int net ) SHAPE_POLY_SET pset; - item->TransformShapeWithClearanceToPolygon( pset, 1, ARC_HIGH_DEF ); + item->TransformShapeWithClearanceToPolygon( pset, UNDEFINED_LAYER, 1, ARC_HIGH_DEF ); SHAPE_FILE_IO shapeIo; // default = stdout shapeIo.Write( &pset );