diff --git a/3d-viewer/3d_canvas/board_adapter.cpp b/3d-viewer/3d_canvas/board_adapter.cpp index 1e59b479bf..11a7e2d2e9 100644 --- a/3d-viewer/3d_canvas/board_adapter.cpp +++ b/3d-viewer/3d_canvas/board_adapter.cpp @@ -253,9 +253,9 @@ bool BOARD_ADAPTER::ShouldModuleBeDisplayed( MODULE_ATTR_T aModuleAttributs ) co #define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM ) // for 35 um #define TECH_LAYER_THICKNESS KiROUND( 0.04 * IU_PER_MM ) -int BOARD_ADAPTER::GetCopperThicknessBIU() const noexcept +int BOARD_ADAPTER::GetHolePlatingThicknessBIU() const noexcept { - return COPPER_THICKNESS; + return m_board->GetDesignSettings().GetHolePlatingThickness(); } unsigned int BOARD_ADAPTER::GetNrSegmentsCircle( float aDiameter3DU ) const diff --git a/3d-viewer/3d_canvas/board_adapter.h b/3d-viewer/3d_canvas/board_adapter.h index e82a68e030..93bda08aa5 100644 --- a/3d-viewer/3d_canvas/board_adapter.h +++ b/3d-viewer/3d_canvas/board_adapter.h @@ -199,7 +199,7 @@ class BOARD_ADAPTER * @brief GetCopperThicknessBIU - Get the current copper layer thickness * @return thickness in board unities */ - int GetCopperThicknessBIU() const noexcept; + int GetHolePlatingThicknessBIU() const noexcept; /** * @brief GetBoardSizeBIU - Get the board size @@ -400,19 +400,16 @@ class BOARD_ADAPTER return m_through_holes_outer_ring; } - /** - * @brief GetThroughHole_Outer_poly - - * @return - */ const SHAPE_POLY_SET &GetThroughHole_Outer_poly() const noexcept { return m_through_outer_holes_poly; } - /** - * @brief GetThroughHole_Outer_poly_NPTH - - * @return - */ + const SHAPE_POLY_SET &GetThroughHole_Outer_Ring_poly() const noexcept + { + return m_through_outer_ring_holes_poly; + } + const SHAPE_POLY_SET &GetThroughHole_Outer_poly_NPTH() const noexcept { return m_through_outer_holes_poly_NPTH; @@ -427,40 +424,11 @@ class BOARD_ADAPTER return m_through_holes_vias_outer; } - /** - * @brief GetThroughHole_Vias_Outer_Ring - - * @return a container with via THT holes only, including annular ring size - */ - const CBVHCONTAINER2D& GetThroughHole_Vias_Outer_Ring() const noexcept - { - return m_through_holes_vias_outer_ring; - } - - /** - * @brief GetThroughHole_Vias_Inner - - * @return a container with via THT holes only - */ - const CBVHCONTAINER2D &GetThroughHole_Vias_Inner() const noexcept - { - return m_through_holes_vias_inner; - } - - /** - * @brief GetThroughHole_Vias_Outer_poly - - */ const SHAPE_POLY_SET &GetThroughHole_Vias_Outer_poly() const noexcept { return m_through_outer_holes_vias_poly; } - /** - * @brief GetThroughHole_Vias_Outer_Ring_poly - - */ - const SHAPE_POLY_SET& GetThroughHole_Vias_Outer_Ring_poly() const noexcept - { - return m_through_outer_ring_holes_vias_poly; - } - /** * @brief GetThroughHole_Inner - Get the ThroughHole container * @return a container with holes @@ -720,7 +688,7 @@ private: SHAPE_POLY_SET m_through_outer_holes_vias_poly; /// It contains polygon contours for through holes vias (outer annular ring) - SHAPE_POLY_SET m_through_outer_ring_holes_vias_poly; + SHAPE_POLY_SET m_through_outer_ring_holes_poly; /// PCB board outline polygon SHAPE_POLY_SET m_board_poly; @@ -753,10 +721,6 @@ private: /// the radius of the hole is inflated with the copper tickness CBVHCONTAINER2D m_through_holes_vias_outer; - /// It contains the list of throughHoles vias of the board, - /// the radius of the hole is inflated with the annular ring size - CBVHCONTAINER2D m_through_holes_vias_outer_ring; - /// It contains the list of throughHoles vias of the board, /// the radius of the hole CBVHCONTAINER2D m_through_holes_vias_inner; diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index 00909efa92..ee5bf39b32 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -111,13 +111,12 @@ void BOARD_ADAPTER::destroyLayers() m_through_holes_outer.Clear(); m_through_holes_outer_ring.Clear(); m_through_holes_vias_outer.Clear(); - m_through_holes_vias_outer_ring.Clear(); m_through_holes_vias_inner.Clear(); m_through_outer_holes_poly_NPTH.RemoveAllContours(); m_through_outer_holes_poly.RemoveAllContours(); m_through_outer_holes_vias_poly.RemoveAllContours(); - m_through_outer_ring_holes_vias_poly.RemoveAllContours(); + m_through_outer_ring_holes_poly.RemoveAllContours(); } @@ -319,10 +318,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) ) { - m_through_holes_outer_ring.Add( - new CFILLEDCIRCLE2D( via_center, ring_radius, *track ) ); - m_through_holes_vias_outer_ring.Add( - new CFILLEDCIRCLE2D( via_center, ring_radius, *track ) ); + m_through_holes_outer_ring.Add( new CFILLEDCIRCLE2D( via_center, + ring_radius, + *track ) ); } m_through_holes_inner.Add( new CFILLEDCIRCLE2D( via_center, @@ -391,7 +389,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } const int holediameter = via->GetDrillValue(); - const int hole_outer_radius = (holediameter / 2) + GetCopperThicknessBIU(); + const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThicknessBIU(); TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(), hole_outer_radius, ARC_HIGH_DEF ); @@ -402,7 +400,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes { const int holediameter = via->GetDrillValue(); - const int hole_outer_radius = (holediameter / 2)+ GetCopperThicknessBIU(); + const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThicknessBIU(); const int hole_outer_ring_radius = via->GetWidth() / 2.0f; // Add through hole contourns @@ -417,8 +415,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) ) { - TransformCircleToPolygon( m_through_outer_ring_holes_vias_poly, - via->GetStart(), hole_outer_ring_radius, ARC_HIGH_DEF ); + TransformCircleToPolygon( m_through_outer_ring_holes_poly, + via->GetStart(), hole_outer_ring_radius, ARC_HIGH_DEF ); } } } @@ -469,10 +467,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( !padHole.x ) // Not drilled pad like SMD pad continue; - // The hole in the body is inflated by copper thickness, - // if not plated, no copper + // The hole in the body is inflated by copper thickness, if not plated, no copper const int inflate = ( pad->GetAttribute () != PAD_ATTRIB_NPTH ) ? - GetCopperThicknessBIU() : 0; + GetHolePlatingThicknessBIU() : 0; m_stats_nr_holes++; m_stats_hole_med_diameter += ( ( pad->GetDrillSize().x + @@ -504,16 +501,22 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) continue; // The hole in the body is inflated by copper thickness. - const int inflate = GetCopperThicknessBIU(); + const int inflate = GetHolePlatingThicknessBIU(); if( pad->GetAttribute () != PAD_ATTRIB_NPTH ) { + if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) ) + pad->TransformHoleWithClearanceToPolygon( m_through_outer_ring_holes_poly, inflate ); + pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly, inflate ); } else { // If not plated, no copper. - pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly_NPTH, inflate ); + if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) ) + pad->TransformHoleWithClearanceToPolygon( m_through_outer_ring_holes_poly, 0 ); + + pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly_NPTH, 0 ); } } } @@ -877,7 +880,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) m_through_outer_holes_poly.Simplify( SHAPE_POLY_SET::PM_FAST ); m_through_outer_holes_poly_NPTH.Simplify( SHAPE_POLY_SET::PM_FAST ); m_through_outer_holes_vias_poly.Simplify( SHAPE_POLY_SET::PM_FAST ); - m_through_outer_ring_holes_vias_poly.Simplify( SHAPE_POLY_SET::PM_FAST ); + m_through_outer_ring_holes_poly.Simplify( SHAPE_POLY_SET::PM_FAST ); // Build Tech layers // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059 @@ -1070,7 +1073,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( !m_layers_holes2D.empty() ) { - for( auto& hole : m_layers_holes2D) + for( auto& hole : m_layers_holes2D ) hole.second->BuildBVH(); } diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp index c4c2ef4bb0..5bb657ba44 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp @@ -530,9 +530,9 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin if( m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) ) { - m_ogl_disp_list_through_holes_vias_outer_ring = generate_holes_display_list( - m_boardAdapter.GetThroughHole_Vias_Outer_Ring().GetList(), - m_boardAdapter.GetThroughHole_Vias_Outer_Ring_poly(), + m_ogl_disp_list_through_holes_outer_ring = generate_holes_display_list( + m_boardAdapter.GetThroughHole_Outer_Ring().GetList(), + m_boardAdapter.GetThroughHole_Outer_Ring_poly(), 1.0f, 0.0f, false ); @@ -802,7 +802,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() if( !hasHole ) continue; - const int copperThickness = m_boardAdapter.GetCopperThicknessBIU(); + const int copperThickness = m_boardAdapter.GetHolePlatingThicknessBIU(); pad->TransformHoleWithClearanceToPolygon( tht_outer_holes_poly, copperThickness, ARC_LOW_DEF ); diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp index f4f99457c9..1f3f7ae015 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp @@ -65,8 +65,8 @@ C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY( BOARD_ADAPTER& aAdapter, CCAMERA& m_ogl_disp_list_through_holes_outer_with_npth = NULL; m_ogl_disp_list_through_holes_outer = NULL; + m_ogl_disp_list_through_holes_outer_ring = NULL; m_ogl_disp_list_through_holes_vias_outer = NULL; - m_ogl_disp_list_through_holes_vias_outer_ring = NULL; //m_ogl_disp_list_through_holes_vias_inner = NULL; m_ogl_disp_list_via = NULL; m_ogl_disp_list_pads_holes = NULL; @@ -834,14 +834,14 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( { set_layer_material( layer_id ); - CLAYERS_OGL_DISP_LISTS* dispListThoughHolesOuter = + CLAYERS_OGL_DISP_LISTS* dispListThroughHolesOuter = ( m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && ( ( layer_id == B_SilkS ) || ( layer_id == F_SilkS ) ) ) ? - m_ogl_disp_list_through_holes_vias_outer_ring : - m_ogl_disp_list_through_holes_vias_outer; + m_ogl_disp_list_through_holes_outer_ring : + m_ogl_disp_list_through_holes_outer; - if( dispListThoughHolesOuter ) - dispListThoughHolesOuter->ApplyScalePosition( pLayerDispList->GetZBot(), + if( dispListThroughHolesOuter ) + dispListThroughHolesOuter->ApplyScalePosition( pLayerDispList->GetZBot(), pLayerDispList->GetZTop() - pLayerDispList->GetZBot() ); if( (!skipRenderHoles) && @@ -856,23 +856,23 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( const CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( layerMask_id ); pLayerDispList->DrawAllCameraCulledSubtractLayer( - pLayerDispListMask, - dispListThoughHolesOuter, - drawMiddleSegments ); + pLayerDispListMask, + dispListThroughHolesOuter, + drawMiddleSegments ); } else { - if( (!skipRenderHoles) && - dispListThoughHolesOuter && - ( ( layer_id == B_SilkS ) || ( layer_id == F_SilkS ) + if((!skipRenderHoles) && + dispListThroughHolesOuter && + ( ( layer_id == B_SilkS ) || ( layer_id == F_SilkS ) // Remove vias on SolderPaste can be added as an option in future // ( layer_id == B_Paste ) || ( layer_id == F_Paste ) ) ) ) { pLayerDispList->DrawAllCameraCulledSubtractLayer( - NULL, - dispListThoughHolesOuter, - drawMiddleSegments ); + NULL, + dispListThroughHolesOuter, + drawMiddleSegments ); } else { @@ -1147,8 +1147,8 @@ void C3D_RENDER_OGL_LEGACY::ogl_free_all_display_lists() delete m_ogl_disp_list_through_holes_vias_outer; m_ogl_disp_list_through_holes_vias_outer = 0; - delete m_ogl_disp_list_through_holes_vias_outer_ring; - m_ogl_disp_list_through_holes_vias_outer_ring = 0; + delete m_ogl_disp_list_through_holes_outer_ring; + m_ogl_disp_list_through_holes_outer_ring = 0; delete m_ogl_disp_list_via; m_ogl_disp_list_via = 0; diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h index 517c22f300..05d7b9b5b4 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h @@ -90,7 +90,7 @@ private: CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_outer_with_npth; CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_vias_outer; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_vias_outer_ring; + CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_outer_ring; //CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_vias_inner; // Not in use // This is for pads holes of the modules diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp index 1e90bcd64f..756caa1b60 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp @@ -1059,7 +1059,7 @@ void C3D_RENDER_RAYTRACING::insert3DViaHole( const VIA* aVia ) CRING2D *ring = new CRING2D( center, radiusBUI * m_boardAdapter.BiuTo3Dunits(), - ( radiusBUI + m_boardAdapter.GetCopperThicknessBIU() ) * + ( radiusBUI + m_boardAdapter.GetHolePlatingThicknessBIU() ) * m_boardAdapter.BiuTo3Dunits(), *aVia ); @@ -1110,11 +1110,11 @@ void C3D_RENDER_RAYTRACING::insert3DPadHole( const D_PAD* aPad ) SFVEC2F center = SFVEC2F( aPad->GetPosition().x * m_boardAdapter.BiuTo3Dunits(), -aPad->GetPosition().y * m_boardAdapter.BiuTo3Dunits() ); + int innerRadius = drillsize.x / 2; + int outerRadius = innerRadius + m_boardAdapter.GetHolePlatingThicknessBIU(); CRING2D *ring = new CRING2D( center, - ( drillsize.x / 2 ) * m_boardAdapter.BiuTo3Dunits(), - (( drillsize.x / 2 ) + - m_boardAdapter.GetCopperThicknessBIU() ) * - m_boardAdapter.BiuTo3Dunits(), + innerRadius * m_boardAdapter.BiuTo3Dunits(), + outerRadius * m_boardAdapter.BiuTo3Dunits(), *aPad ); m_containerWithObjectsToDelete.Add( ring ); @@ -1155,8 +1155,7 @@ void C3D_RENDER_RAYTRACING::insert3DPadHole( const D_PAD* aPad ) -start.y * m_boardAdapter.BiuTo3Dunits() ), SFVEC2F( end.x * m_boardAdapter.BiuTo3Dunits(), -end.y * m_boardAdapter.BiuTo3Dunits() ), - ( width + m_boardAdapter.GetCopperThicknessBIU() * 2 ) * - m_boardAdapter.BiuTo3Dunits(), + ( width + m_boardAdapter.GetHolePlatingThicknessBIU() * 2 ) * m_boardAdapter.BiuTo3Dunits(), *aPad ); // NOTE: the round segment width is the "diameter", so we double the thickness