KiCad PCB EDA Suite
BOARD_ADAPTER Class Reference

Helper class to handle information needed to display 3D board. More...

#include <board_adapter.h>

Public Member Functions

 BOARD_ADAPTER ()
 
 ~BOARD_ADAPTER ()
 
void Set3dCacheManager (S3D_CACHE *aCachePointer) noexcept
 Update the cache manager pointer. More...
 
S3D_CACHEGet3dCacheManager () const noexcept
 Return the 3D cache manager pointer. More...
 
bool GetFlag (DISPLAY3D_FLG aFlag) const
 Get a configuration status of a flag. More...
 
void SetFlag (DISPLAY3D_FLG aFlag, bool aState)
 Set the status of a flag. More...
 
bool Is3dLayerEnabled (PCB_LAYER_ID aLayer) const
 Check if a layer is enabled. More...
 
bool IsFootprintShown (FOOTPRINT_ATTR_T aFPAttributes) const
 Test if footprint should be displayed in relation to attributes and the flags. More...
 
void SetBoard (BOARD *aBoard) noexcept
 Set current board to be rendered. More...
 
const BOARDGetBoard () const noexcept
 Get current board to be rendered. More...
 
void SetColorSettings (COLOR_SETTINGS *aSettings) noexcept
 
void InitSettings (REPORTER *aStatusReporter, REPORTER *aWarningReporter)
 Function to be called by the render when it need to reload the settings for the board. More...
 
double BiuTo3dUnits () const noexcept
 Board integer units To 3D units. More...
 
const BBOX_3DGetBBox () const noexcept
 Get the board outling bounding box. More...
 
float GetEpoxyThickness () const noexcept
 Get the current epoxy thickness. More...
 
float GetNonCopperLayerThickness () const noexcept
 Get the current non copper layers thickness. More...
 
float GetCopperThickness () const noexcept
 Get the current copper layer thickness. More...
 
int GetHolePlatingThickness () const noexcept
 Get the current copper layer thickness. More...
 
wxSize GetBoardSize () const noexcept
 Get the board size. More...
 
wxPoint GetBoardPos () const noexcept
 Get the board center. More...
 
const SFVEC3FGetBoardCenter () const noexcept
 The board center position in 3D units. More...
 
float GetFootprintZPos (bool aIsFlipped) const
 Get the position of the footprint in 3d integer units considering if it is flipped or not. More...
 
GRID3D_TYPE GetGridType () const noexcept
 Get the current grid. More...
 
void SetGridType (GRID3D_TYPE aGridType) noexcept
 Set the current grid. More...
 
ANTIALIASING_MODE GetAntiAliasingMode () const
 Get the current antialiasing mode value. More...
 
void SetAntiAliasingMode (ANTIALIASING_MODE aAAmode)
 Set the current antialiasing mode value. More...
 
void SetRenderEngine (RENDER_ENGINE aRenderEngine) noexcept
 
RENDER_ENGINE GetRenderEngine () const noexcept
 
void SetMaterialMode (MATERIAL_MODE aMaterialMode) noexcept
 
MATERIAL_MODE GetMaterialMode () const noexcept
 
const SHAPE_POLY_SETGetBoardPoly () const noexcept
 Get the current polygon of the epoxy board. More...
 
SFVEC4F GetLayerColor (PCB_LAYER_ID aLayerId) const
 Get the technical color of a layer. More...
 
SFVEC4F GetItemColor (int aItemId) const
 Get the technical color of a layer. More...
 
SFVEC4F GetColor (const COLOR4D &aColor) const
 
float GetLayerTopZPos (PCB_LAYER_ID aLayerId) const noexcept
 Get the top z position. More...
 
float GetLayerBottomZPos (PCB_LAYER_ID aLayerId) const noexcept
 Get the bottom z position. More...
 
const MAP_CONTAINER_2D_BASEGetLayerMap () const noexcept
 Get the map of containers that have the objects per layer. More...
 
const BVH_CONTAINER_2DGetPlatedPadsFront () const noexcept
 
const BVH_CONTAINER_2DGetPlatedPadsBack () const noexcept
 
const MAP_CONTAINER_2D_BASEGetLayerHoleMap () const noexcept
 Get the map of container that have the holes per layer. More...
 
const BVH_CONTAINER_2DGetThroughHoleOds () const noexcept
 Get the inflated through hole outside diameters container. More...
 
const BVH_CONTAINER_2DGetThroughHoleAnnularRings () const noexcept
 Get the through hole annular rings container. More...
 
const SHAPE_POLY_SETGetThroughHoleOdPolys () const noexcept
 Get through hole outside diameter 2D polygons. More...
 
const SHAPE_POLY_SETGetThroughHoleAnnularRingPolys () const noexcept
 
const SHAPE_POLY_SETGetOuterNonPlatedThroughHolePoly () const noexcept
 
const BVH_CONTAINER_2DGetThroughHoleViaOds () const noexcept
 
const SHAPE_POLY_SETGetThroughHoleViaOdPolys () const noexcept
 
const BVH_CONTAINER_2DGetThroughHoleIds () const noexcept
 Get the through hole inner diameter container. More...
 
unsigned int GetViaCount () const noexcept
 Get number of vias in this board. More...
 
unsigned int GetHoleCount () const noexcept
 Get number of holes in this board. More...
 
float GetAverageViaHoleDiameter () const noexcept
 Thee average diameter of the via holes. More...
 
float GetAverageHoleDiameter () const noexcept
 Average diameter of through holes. More...
 
float GetAverageTrackWidth () const noexcept
 Average width of the tracks. More...
 
unsigned int GetCircleSegmentCount (float aDiameter3DU) const
 
unsigned int GetCircleSegmentCount (int aDiameterBIU) const
 
const MAP_POLYGetPolyMap () const noexcept
 Get map of polygon's layers. More...
 
const SHAPE_POLY_SETGetFrontPlatedPadPolys ()
 
const SHAPE_POLY_SETGetBackPlatedPadPolys ()
 
const MAP_POLYGetHoleIdPolysMap () const noexcept
 
const MAP_POLYGetHoleOdPolysMap () const noexcept
 

Public Attributes

SFVEC4F m_BgColorBot
 background bottom color More...
 
SFVEC4F m_BgColorTop
 background top color More...
 
SFVEC4F m_BoardBodyColor
 in realistic mode: FR4 board color More...
 
SFVEC4F m_SolderMaskColorBot
 in realistic mode: solder mask color ( bot ) More...
 
SFVEC4F m_SolderMaskColorTop
 in realistic mode: solder mask color ( top ) More...
 
SFVEC4F m_SolderPasteColor
 in realistic mode: solder paste color More...
 
SFVEC4F m_SilkScreenColorBot
 in realistic mode: SilkScreen color ( bot ) More...
 
SFVEC4F m_SilkScreenColorTop
 in realistic mode: SilkScreen color ( top ) More...
 
SFVEC4F m_CopperColor
 in realistic mode: copper color More...
 
SFVEC3F m_OpenGlSelectionColor
 
SFVEC3F m_RtCameraLightColor
 
SFVEC3F m_RtLightColorTop
 
SFVEC3F m_RtLightColorBottom
 
std::vector< SFVEC3Fm_RtLightColor
 
std::vector< SFVEC2Fm_RtLightSphericalCoords
 
int m_RtShadowSampleCount
 
int m_RtReflectionSampleCount
 
int m_RtRefractionSampleCount
 
int m_RtRecursiveReflectionCount
 
int m_RtRecursiveRefractionCount
 
float m_RtSpreadShadows
 
float m_RtSpreadReflections
 
float m_RtSpreadRefractions
 

Static Public Attributes

static CUSTOM_COLORS_LIST g_SilkscreenColors
 
static CUSTOM_COLORS_LIST g_MaskColors
 
static CUSTOM_COLORS_LIST g_PasteColors
 
static CUSTOM_COLORS_LIST g_FinishColors
 
static CUSTOM_COLORS_LIST g_BoardColors
 
static KIGFX::COLOR4D g_DefaultBackgroundTop
 
static KIGFX::COLOR4D g_DefaultBackgroundBot
 
static KIGFX::COLOR4D g_DefaultSilkscreen
 
static KIGFX::COLOR4D g_DefaultSolderMask
 
static KIGFX::COLOR4D g_DefaultSolderPaste
 
static KIGFX::COLOR4D g_DefaultSurfaceFinish
 
static KIGFX::COLOR4D g_DefaultBoardBody
 

Private Member Functions

bool createBoardPolygon (wxString *aErrorMsg)
 Create the board outline polygon. More...
 
void createLayers (REPORTER *aStatusReporter)
 
void destroyLayers ()
 
void createTrack (const PCB_TRACK *aTrack, CONTAINER_2D_BASE *aDstContainer, int aClearanceValue)
 
void createPadWithClearance (const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, const wxSize &aClearanceValue) const
 
OBJECT_2DcreatePadWithDrill (const PAD *aPad, int aInflateValue)
 
void addPadsWithClearance (const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
 
void addFootprintShapesWithClearance (const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue)
 
void addShapeWithClearance (const PCB_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void addShapeWithClearance (const PCB_SHAPE *aShape, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void addShapeWithClearance (const PCB_DIMENSION_BASE *aDimension, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void addSolidAreasShapes (const ZONE *aZoneContainer, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
 
void transformArcToSegments (const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM &aBoardItem)
 
void buildPadOutlineAsSegments (const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, int aWidth)
 
void buildPadOutlineAsPolygon (const PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
 
void transformFPShapesToPolygon (const FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer) const
 

Private Attributes

BOARDm_board
 
S3D_CACHEm_3dModelManager
 
COLOR_SETTINGSm_colors
 
std::vector< bool > m_drawFlags
 
GRID3D_TYPE m_gridType
 
RENDER_ENGINE m_renderEngine
 
MATERIAL_MODE m_materialMode
 
ANTIALIASING_MODE m_antiAliasingMode
 
wxPoint m_boardPos
 Board center position in board internal units. More...
 
wxSize m_boardSize
 Board size in board internal units. More...
 
SFVEC3F m_boardCenter
 3D center position of the board in 3D units. More...
 
BBOX_3D m_boardBoundingBox
 3D bounding box of the board in 3D units. More...
 
MAP_POLY m_layers_poly
 
SHAPE_POLY_SETm_frontPlatedPadPolys
 
SHAPE_POLY_SETm_backPlatedPadPolys
 Polygon contours for hole outer diameters for each layer. More...
 
MAP_POLY m_layerHoleOdPolys
 Polygon contours for hole inner diameters for each layer. More...
 
MAP_POLY m_layerHoleIdPolys
 Polygon contours for non plated through hole outer diameters. More...
 
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys
 Polygon contours for through hole outer diameters. More...
 
SHAPE_POLY_SET m_throughHoleOdPolys
 Polygon contours for through holes via outer diameters. More...
 
SHAPE_POLY_SET m_throughHoleViaOdPolys
 Polygon contours for through hole via annular rings. More...
 
SHAPE_POLY_SET m_throughHoleAnnularRingPolys
 
SHAPE_POLY_SET m_board_poly
 Board outline polygon. More...
 
MAP_CONTAINER_2D_BASE m_layerMap
 2D elements for each layer. More...
 
BVH_CONTAINER_2Dm_platedPadsFront
 
BVH_CONTAINER_2Dm_platedPadsBack
 The holes per each layer. More...
 
MAP_CONTAINER_2D_BASE m_layerHoleMap
 List of through holes with the radius of the hole inflated with the copper thickness. More...
 
BVH_CONTAINER_2D m_throughHoleOds
 List of plated through hole annular rings. More...
 
BVH_CONTAINER_2D m_throughHoleAnnularRings
 List of through hole inner diameters. More...
 
BVH_CONTAINER_2D m_throughHoleIds
 List of through hole vias with the radius of the hole inflated with the copper thickness. More...
 
BVH_CONTAINER_2D m_throughHoleViaOds
 List of through hole via inner diameters. More...
 
BVH_CONTAINER_2D m_throughHoleViaIds
 Number of copper layers actually used by the board. More...
 
unsigned int m_copperLayersCount
 Scale factor to convert board internal units to 3D units normalized between -1.0 and 1.0. More...
 
double m_biuTo3Dunits
 Top (End) Z position of each layer in 3D units. More...
 
std::array< float, PCB_LAYER_ID_COUNTm_layerZcoordTop
 Bottom (Start) Z position of each layer in 3D units. More...
 
std::array< float, PCB_LAYER_ID_COUNTm_layerZcoordBottom
 Copper thickness in 3D units. More...
 
float m_copperThickness3DU
 Epoxy thickness in 3D units. More...
 
float m_epoxyThickness3DU
 Non copper layers thickness in 3D units. More...
 
float m_nonCopperLayerThickness3DU
 solder paste layers thickness in 3D units. More...
 
float m_solderPasteLayerThickness3DU
 Number of tracks in the board. More...
 
unsigned int m_trackCount
 Track average width. More...
 
float m_averageTrackWidth
 Number of through hole vias in the board. More...
 
unsigned int m_viaCount
 Computed average diameter of the via holes in 3D units. More...
 
float m_averageViaHoleDiameter
 Number of holes in the board. More...
 
unsigned int m_holeCount
 Computed average diameter of the holes in 3D units. More...
 
float m_averageHoleDiameter
 

Static Private Attributes

static const wxChar * m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" )
 Trace mask used to enable or disable the trace output of this class. More...
 

Detailed Description

Helper class to handle information needed to display 3D board.

Definition at line 68 of file board_adapter.h.

Constructor & Destructor Documentation

◆ BOARD_ADAPTER()

BOARD_ADAPTER::BOARD_ADAPTER ( )

Definition at line 69 of file board_adapter.cpp.

69  :
70  m_board( nullptr ),
71  m_3dModelManager( nullptr ),
72  m_colors( nullptr ),
75 {
76  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
77 
80  m_drawFlags.resize( FL_LAST, false );
81 
82  if( PgmOrNull() )
83  m_colors = Pgm().GetSettingsManager().GetColorSettings();
84 
87 
88  m_boardPos = wxPoint();
89  m_boardSize = wxSize();
90  m_boardCenter = SFVEC3F( 0.0f );
91 
93 
97 
99  m_epoxyThickness3DU = 0.0f;
100  m_copperThickness3DU = 0.0f;
103  m_biuTo3Dunits = 1.0;
104 
105  m_trackCount = 0;
106  m_viaCount = 0;
108  m_holeCount = 0;
109  m_averageHoleDiameter = 0.0f;
110  m_averageTrackWidth = 0.0f;
111 
114  SetFlag( FL_SHOW_BOARD_BODY, true );
119  SetFlag( FL_ZONE, true );
120  SetFlag( FL_SILKSCREEN, true );
121  SetFlag( FL_SOLDERMASK, true );
123 
129 
130  SetFlag( FL_USE_SELECTION, true );
132 
133  m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
134  m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );
135  m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 0.9 );
136  m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
137  m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
138  m_SolderPasteColor = SFVEC4F( 0.4, 0.4, 0.4, 1.0 );
139  m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
140  m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
141  m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
142 
143  m_platedPadsFront = nullptr;
144  m_platedPadsBack = nullptr;
145 
146  m_frontPlatedPadPolys = nullptr;
147  m_backPlatedPadPolys = nullptr;
148 
149  // Avoid raytracing options not initialized:
153 
154  m_RtSpreadShadows = 0.0;
155  m_RtSpreadReflections = 0.0;
156  m_RtSpreadRefractions = 0.0;
157 
160 
161  if( !g_ColorsLoaded )
162  {
163 #define ADD_COLOR( list, r, g, b, a, name ) \
164  list.push_back( CUSTOM_COLOR_ITEM( r/255.0, g/255.0, b/255.0, a, name ) )
165 
166  ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, NotSpecifiedPrm() ); // White
167  ADD_COLOR( g_SilkscreenColors, 20, 51, 36, 1.0, wxT( "Green" ) );
168  ADD_COLOR( g_SilkscreenColors, 181, 19, 21, 1.0, wxT( "Red" ) );
169  ADD_COLOR( g_SilkscreenColors, 2, 59, 162, 1.0, wxT( "Blue" ) );
170  ADD_COLOR( g_SilkscreenColors, 11, 11, 11, 1.0, wxT( "Black" ) );
171  ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, wxT( "White" ) );
172  ADD_COLOR( g_SilkscreenColors, 32, 2, 53, 1.0, wxT( "Purple" ) );
173  ADD_COLOR( g_SilkscreenColors, 194, 195, 0, 1.0, wxT( "Yellow" ) );
174 
175  ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, NotSpecifiedPrm() ); // Green
176  ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, wxT( "Green" ) );
177  ADD_COLOR( g_MaskColors, 91, 168, 12, 0.83, wxT( "Light Green" ) );
178  ADD_COLOR( g_MaskColors, 13, 104, 11, 0.83, wxT( "Saturated Green" ) );
179  ADD_COLOR( g_MaskColors, 181, 19, 21, 0.83, wxT( "Red" ) );
180  ADD_COLOR( g_MaskColors, 210, 40, 14, 0.83, wxT( "Light Red" ) );
181  ADD_COLOR( g_MaskColors, 239, 53, 41, 0.83, wxT( "Red/Orange" ) );
182  ADD_COLOR( g_MaskColors, 2, 59, 162, 0.83, wxT( "Blue" ) );
183  ADD_COLOR( g_MaskColors, 54, 79, 116, 0.83, wxT( "Light Blue 1" ) );
184  ADD_COLOR( g_MaskColors, 61, 85, 130, 0.83, wxT( "Light Blue 2" ) );
185  ADD_COLOR( g_MaskColors, 21, 70, 80, 0.83, wxT( "Green/Blue" ) );
186  ADD_COLOR( g_MaskColors, 11, 11, 11, 0.83, wxT( "Black" ) );
187  ADD_COLOR( g_MaskColors, 245, 245, 245, 0.83, wxT( "White" ) );
188  ADD_COLOR( g_MaskColors, 32, 2, 53, 0.83, wxT( "Purple" ) );
189  ADD_COLOR( g_MaskColors, 119, 31, 91, 0.83, wxT( "Light Purple" ) );
190  ADD_COLOR( g_MaskColors, 194, 195, 0, 0.83, wxT( "Yellow" ) );
191 
192  ADD_COLOR( g_PasteColors, 128, 128, 128, 1.0, wxT( "Grey" ) );
193  ADD_COLOR( g_PasteColors, 90, 90, 90, 1.0, wxT( "Dark Grey" ) );
194  ADD_COLOR( g_PasteColors, 213, 213, 213, 1.0, wxT( "Silver" ) );
195 
196  ADD_COLOR( g_FinishColors, 184, 115, 50, 1.0, wxT( "Copper" ) );
197  ADD_COLOR( g_FinishColors, 178, 156, 0, 1.0, wxT( "Gold" ) );
198  ADD_COLOR( g_FinishColors, 213, 213, 213, 1.0, wxT( "Silver" ) );
199  ADD_COLOR( g_FinishColors, 160, 160, 160, 1.0, wxT( "Tin" ) );
200 
201  ADD_COLOR( g_BoardColors, 51, 43, 22, 0.83, wxT( "FR4 natural, dark" ) );
202  ADD_COLOR( g_BoardColors, 109, 116, 75, 0.83, wxT( "FR4 natural" ) );
203  ADD_COLOR( g_BoardColors, 252, 252, 250, 0.90, wxT( "PTFE natural" ) );
204  ADD_COLOR( g_BoardColors, 205, 130, 0, 0.68, wxT( "Polyimide" ) );
205  ADD_COLOR( g_BoardColors, 92, 17, 6, 0.90, wxT( "Phenolic natural" ) );
206  ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, wxT( "Brown 1" ) );
207  ADD_COLOR( g_BoardColors, 160, 123, 54, 0.83, wxT( "Brown 2" ) );
208  ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, wxT( "Brown 3" ) );
209  ADD_COLOR( g_BoardColors, 213, 213, 213, 1.0, wxT( "Aluminum" ) );
210 
211  g_DefaultBackgroundTop = COLOR4D( 0.80, 0.80, 0.90, 1.0 );
212  g_DefaultBackgroundBot = COLOR4D( 0.40, 0.40, 0.50, 1.0 );
213 
214  g_DefaultSilkscreen = COLOR4D( 0.94, 0.94, 0.94, 1.0 );
215  g_DefaultSolderMask = COLOR4D( 0.08, 0.20, 0.14, 0.83 );
216  g_DefaultSolderPaste = COLOR4D( 0.50, 0.50, 0.50, 1.0 );
217  g_DefaultSurfaceFinish = COLOR4D( 0.75, 0.61, 0.23, 1.0 );
218  g_DefaultBoardBody = COLOR4D( 0.43, 0.45, 0.30, 0.90 );
219 
220  g_ColorsLoaded = true;
221  }
222 #undef ADD_COLOR
223 }
BVH_CONTAINER_2D * m_platedPadsFront
static bool g_ColorsLoaded
int m_RtShadowSampleCount
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
SHAPE_POLY_SET * m_backPlatedPadPolys
Polygon contours for hole outer diameters for each layer.
float m_solderPasteLayerThickness3DU
Number of tracks in the board.
BVH_CONTAINER_2D m_throughHoleIds
List of through hole vias with the radius of the hole inflated with the copper thickness.
float m_nonCopperLayerThickness3DU
solder paste layers thickness in 3D units.
SHAPE_POLY_SET * m_frontPlatedPadPolys
float m_averageHoleDiameter
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46
static KIGFX::COLOR4D g_DefaultSilkscreen
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
Set the status of a flag.
COLOR_SETTINGS * m_colors
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
static KIGFX::COLOR4D g_DefaultSurfaceFinish
BVH_CONTAINER_2D m_throughHoleOds
List of plated through hole annular rings.
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
float m_averageTrackWidth
Number of through hole vias in the board.
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
wxPoint m_boardPos
Board center position in board internal units.
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Copper thickness in 3D units.
float m_epoxyThickness3DU
Non copper layers thickness in 3D units.
static CUSTOM_COLORS_LIST g_BoardColors
float m_copperThickness3DU
Epoxy thickness in 3D units.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
static KIGFX::COLOR4D g_DefaultBackgroundBot
float m_RtSpreadRefractions
static CUSTOM_COLORS_LIST g_FinishColors
static CUSTOM_COLORS_LIST g_PasteColors
static KIGFX::COLOR4D g_DefaultSolderMask
static KIGFX::COLOR4D g_DefaultBoardBody
int m_RtRecursiveReflectionCount
float m_RtSpreadReflections
SFVEC4F m_BgColorTop
background top color
unsigned int m_trackCount
Track average width.
std::vector< bool > m_drawFlags
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Bottom (Start) Z position of each layer in 3D units.
#define ADD_COLOR(list, r, g, b, a, name)
GRID3D_TYPE m_gridType
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
Definition: cvpcb.cpp:125
BVH_CONTAINER_2D * m_platedPadsBack
The holes per each layer.
BBOX_3D m_boardBoundingBox
3D bounding box of the board in 3D units.
wxString NotSpecifiedPrm()
Use all material properties from model file.
static KIGFX::COLOR4D g_DefaultBackgroundTop
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
SFVEC4F m_BgColorBot
background bottom color
BVH_CONTAINER_2D m_throughHoleAnnularRings
List of through hole inner diameters.
unsigned int m_viaCount
Computed average diameter of the via holes in 3D units.
int m_RtRecursiveRefractionCount
int m_RtRefractionSampleCount
RENDER_ENGINE m_renderEngine
S3D_CACHE * m_3dModelManager
wxSize m_boardSize
Board size in board internal units.
MATERIAL_MODE m_materialMode
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
static KIGFX::COLOR4D g_DefaultSolderPaste
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
unsigned int m_copperLayersCount
Scale factor to convert board internal units to 3D units normalized between -1.0 and 1....
SFVEC4F m_CopperColor
in realistic mode: copper color
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
static CUSTOM_COLORS_LIST g_MaskColors
ANTIALIASING_MODE m_antiAliasingMode
static CUSTOM_COLORS_LIST g_SilkscreenColors
SFVEC3F m_boardCenter
3D center position of the board in 3D units.
float m_averageViaHoleDiameter
Number of holes in the board.
float m_RtSpreadShadows
void Clear() override
void Reset()
Reset the bounding box to zero and de-initialize it.
Definition: bbox_3d.cpp:95
int m_RtReflectionSampleCount
unsigned int m_holeCount
Computed average diameter of the holes in 3D units.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References AA_8X, ADD_COLOR, BVH_CONTAINER_2D::Clear(), FL_CLIP_SILK_ON_VIA_ANNULUS, FL_FP_ATTRIBUTES_NORMAL, FL_FP_ATTRIBUTES_NORMAL_INSERT, FL_FP_ATTRIBUTES_VIRTUAL, FL_HIGHLIGHT_ROLLOVER_ITEM, FL_LAST, FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, FL_RENDER_OPENGL_COPPER_THICKNESS, FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE, FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE, FL_SHOW_BOARD_BODY, FL_SILKSCREEN, FL_SOLDERMASK, FL_SUBTRACT_MASK_FROM_SILK, FL_USE_REALISTIC_MODE, FL_USE_SELECTION, FL_ZONE, g_BoardColors, g_ColorsLoaded, g_DefaultBackgroundBot, g_DefaultBackgroundTop, g_DefaultBoardBody, g_DefaultSilkscreen, g_DefaultSolderMask, g_DefaultSolderPaste, g_DefaultSurfaceFinish, g_FinishColors, g_MaskColors, g_PasteColors, g_SilkscreenColors, m_antiAliasingMode, m_averageHoleDiameter, m_averageTrackWidth, m_averageViaHoleDiameter, m_backPlatedPadPolys, m_BgColorBot, m_BgColorTop, m_biuTo3Dunits, m_BoardBodyColor, m_boardBoundingBox, m_boardCenter, m_boardPos, m_boardSize, m_colors, m_CopperColor, m_copperLayersCount, m_copperThickness3DU, m_drawFlags, m_epoxyThickness3DU, m_frontPlatedPadPolys, m_gridType, m_holeCount, m_logTrace, m_materialMode, m_nonCopperLayerThickness3DU, m_platedPadsBack, m_platedPadsFront, m_renderEngine, m_RtRecursiveReflectionCount, m_RtRecursiveRefractionCount, m_RtReflectionSampleCount, m_RtRefractionSampleCount, m_RtShadowSampleCount, m_RtSpreadReflections, m_RtSpreadRefractions, m_RtSpreadShadows, m_SilkScreenColorBot, m_SilkScreenColorTop, m_SolderMaskColorBot, m_SolderMaskColorTop, m_SolderPasteColor, m_solderPasteLayerThickness3DU, m_throughHoleAnnularRings, m_throughHoleIds, m_throughHoleOds, m_trackCount, m_viaCount, NONE, NORMAL, NotSpecifiedPrm(), OPENGL, Pgm(), PgmOrNull(), BBOX_3D::Reset(), and SetFlag().

◆ ~BOARD_ADAPTER()

BOARD_ADAPTER::~BOARD_ADAPTER ( )

Definition at line 226 of file board_adapter.cpp.

227 {
228  destroyLayers();
229 }

References destroyLayers().

Member Function Documentation

◆ addFootprintShapesWithClearance()

void BOARD_ADAPTER::addFootprintShapesWithClearance ( const FOOTPRINT aFootprint,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aInflateValue 
)
private

Definition at line 164 of file create_3Dgraphic_brd_items.cpp.

167 {
168  std::vector<FP_TEXT*> texts; // List of FP_TEXT to convert
169  FP_SHAPE* outline;
170 
171  for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
172  {
173  switch( item->Type() )
174  {
175  case PCB_FP_TEXT_T:
176  {
177  FP_TEXT* text = static_cast<FP_TEXT*>( item );
178 
179  if( text->GetLayer() == aLayerId && text->IsVisible() )
180  texts.push_back( text );
181  }
182  break;
183 
184 
185  case PCB_FP_SHAPE_T:
186  {
187  outline = (FP_SHAPE*) item;
188 
189  if( outline->GetLayer() != aLayerId )
190  break;
191 
192  addShapeWithClearance( (const PCB_SHAPE*) outline, aDstContainer, aLayerId, 0 );
193  }
194  break;
195 
196  default:
197  break;
198  }
199  }
200 
201  // Convert texts for footprints
202  if( aFootprint->Reference().GetLayer() == aLayerId && aFootprint->Reference().IsVisible() )
203  texts.push_back( &aFootprint->Reference() );
204 
205  if( aFootprint->Value().GetLayer() == aLayerId && aFootprint->Value().IsVisible() )
206  texts.push_back( &aFootprint->Value() );
207 
208  s_boardItem = (const BOARD_ITEM *)&aFootprint->Value();
209  s_dstcontainer = aDstContainer;
211 
212  for( FP_TEXT* text : texts )
213  {
214  s_textWidth = text->GetEffectiveTextPenWidth() + ( 2 * aInflateValue );
215  wxSize size = text->GetTextSize();
216  bool isBold = text->IsBold();
217  int penWidth = text->GetEffectiveTextPenWidth();
218 
219  if( text->IsMirrored() )
220  size.x = -size.x;
221 
222  GRText( nullptr, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(),
223  size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(),
224  isBold, addTextSegmToContainer );
225  }
226 }
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
static CONTAINER_2D_BASE * s_dstcontainer
void GRText(wxDC *aDC, const wxPoint &aPos, const COLOR4D &aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Draw a graphic text (like footprint texts).
Definition: gr_text.cpp:129
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
Definition: color4d.h:44
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:502
static int s_textWidth
FP_TEXT & Reference()
Definition: footprint.h:503
void addShapeWithClearance(const PCB_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
static float s_biuTo3Dunits
virtual bool IsVisible() const
Definition: eda_text.h:207
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
void addTextSegmToContainer(int x0, int y0, int xf, int yf, void *aData)
static const BOARD_ITEM * s_boardItem
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143

References addShapeWithClearance(), addTextSegmToContainer(), BLACK, BOARD_ITEM::GetLayer(), FOOTPRINT::GraphicalItems(), GRText(), EDA_TEXT::IsVisible(), m_biuTo3Dunits, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, FOOTPRINT::Reference(), s_biuTo3Dunits, s_boardItem, s_dstcontainer, s_textWidth, text, and FOOTPRINT::Value().

Referenced by createLayers().

◆ addPadsWithClearance()

void BOARD_ADAPTER::addPadsWithClearance ( const FOOTPRINT aFootprint,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aInflateValue,
bool  aSkipNPTHPadsWihNoCopper,
bool  aSkipPlatedPads,
bool  aSkipNonPlatedPads 
)
private

Definition at line 488 of file create_3Dgraphic_brd_items.cpp.

493 {
494  for( PAD* pad : aFootprint->Pads() )
495  {
496  if( !pad->FlashLayer( aLayerId ) )
497  continue;
498 
499  // NPTH pads are not drawn on layers if the shape size and pos is the same as their hole:
500  if( aSkipNPTHPadsWihNoCopper && ( pad->GetAttribute() == PAD_ATTRIB::NPTH ) )
501  {
502  if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == wxPoint( 0, 0 ) )
503  {
504  switch( pad->GetShape() )
505  {
506  case PAD_SHAPE::CIRCLE:
507  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
508  continue;
509 
510  break;
511 
512  case PAD_SHAPE::OVAL:
513  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
514  continue;
515 
516  break;
517 
518  default:
519  break;
520  }
521  }
522  }
523 
524  wxSize margin( aInflateValue, aInflateValue );
525 
526  switch( aLayerId )
527  {
528  case F_Cu:
529  if( aSkipPlatedPads && pad->FlashLayer( F_Mask ) )
530  continue;
531 
532  if( aSkipNonPlatedPads && !pad->FlashLayer( F_Mask ) )
533  continue;
534 
535  break;
536 
537  case B_Cu:
538  if( aSkipPlatedPads && pad->FlashLayer( B_Mask ) )
539  continue;
540 
541  if( aSkipNonPlatedPads && !pad->FlashLayer( B_Mask ) )
542  continue;
543 
544  break;
545 
546  case F_Mask:
547  case B_Mask:
548  margin.x += pad->GetSolderMaskMargin();
549  margin.y += pad->GetSolderMaskMargin();
550  break;
551 
552  case F_Paste:
553  case B_Paste:
554  margin += pad->GetSolderPasteMargin();
555  break;
556 
557  default:
558  break;
559  }
560 
561  createPadWithClearance( pad, aDstContainer, aLayerId, margin );
562  }
563 }
void createPadWithClearance(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, const wxSize &aClearanceValue) const
PADS & Pads()
Definition: footprint.h:169
like PAD_PTH, but not plated
Definition: layer_ids.h:71
Definition: pad.h:57

References B_Cu, B_Mask, B_Paste, CIRCLE, createPadWithClearance(), F_Cu, F_Mask, F_Paste, NPTH, OVAL, pad, PAD_DRILL_SHAPE_CIRCLE, and FOOTPRINT::Pads().

Referenced by createLayers().

◆ addShapeWithClearance() [1/3]

void BOARD_ADAPTER::addShapeWithClearance ( const PCB_TEXT aText,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 86 of file create_3Dgraphic_brd_items.cpp.

88 {
89  wxSize size = aText->GetTextSize();
90 
91  if( aText->IsMirrored() )
92  size.x = -size.x;
93 
94  s_boardItem = (const BOARD_ITEM *) &aText;
95  s_dstcontainer = aDstContainer;
96  s_textWidth = aText->GetEffectiveTextPenWidth() + ( 2 * aClearanceValue );
98 
99  // not actually used, but needed by GRText
100  const COLOR4D dummy_color;
101 
102  // Use the actual text width to generate segments. The segment position depend on
103  // text thickness and justification
104  bool isBold = aText->IsBold();
105  int penWidth = aText->GetEffectiveTextPenWidth();
106 
107  GRText( nullptr, aText->GetTextPos(), dummy_color, aText->GetShownText(),
108  aText->GetTextAngle(), size, aText->GetHorizJustify(), aText->GetVertJustify(),
109  penWidth, aText->IsItalic(), isBold, addTextSegmToContainer );
110 }
bool IsBold() const
Definition: eda_text.h:204
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:220
bool IsMirrored() const
Definition: eda_text.h:210
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
double GetTextAngle() const
Definition: eda_text.h:195
static CONTAINER_2D_BASE * s_dstcontainer
void GRText(wxDC *aDC, const wxPoint &aPos, const COLOR4D &aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Draw a graphic text (like footprint texts).
Definition: gr_text.cpp:129
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:159
static int s_textWidth
bool IsItalic() const
Definition: eda_text.h:201
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:56
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:219
static float s_biuTo3Dunits
const wxSize & GetTextSize() const
Definition: eda_text.h:259
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
void addTextSegmToContainer(int x0, int y0, int xf, int yf, void *aData)
const wxPoint & GetTextPos() const
Definition: eda_text.h:268
static const BOARD_ITEM * s_boardItem
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References addTextSegmToContainer(), EDA_TEXT::GetEffectiveTextPenWidth(), EDA_TEXT::GetHorizJustify(), PCB_TEXT::GetShownText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), GRText(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), m_biuTo3Dunits, s_biuTo3Dunits, s_boardItem, s_dstcontainer, and s_textWidth.

Referenced by addFootprintShapesWithClearance(), addShapeWithClearance(), and createLayers().

◆ addShapeWithClearance() [2/3]

void BOARD_ADAPTER::addShapeWithClearance ( const PCB_SHAPE aShape,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 637 of file create_3Dgraphic_brd_items.cpp.

640 {
641  // The full width of the lines to create
642  // The extra 1 protects the inner/outer radius values from degeneracy
643  const double linewidth = aShape->GetWidth() + ( 2 * aClearanceValue ) + 1;
644 
645  switch( aShape->GetShape() )
646  {
647  case SHAPE_T::CIRCLE:
648  {
649  const SFVEC2F center3DU( aShape->GetCenter().x * m_biuTo3Dunits,
650  -aShape->GetCenter().y * m_biuTo3Dunits );
651 
652  float inner_radius = ( aShape->GetRadius() - linewidth / 2 ) * m_biuTo3Dunits;
653  float outer_radius = ( aShape->GetRadius() + linewidth / 2 ) * m_biuTo3Dunits;
654 
655  if( inner_radius < 0 )
656  inner_radius = 0;
657 
658  if( aShape->IsFilled() )
659  aDstContainer->Add( new FILLED_CIRCLE_2D( center3DU, outer_radius, *aShape ) );
660  else
661  aDstContainer->Add( new RING_2D( center3DU, inner_radius, outer_radius, *aShape ) );
662  }
663  break;
664 
665  case SHAPE_T::RECT:
666  if( aShape->IsFilled() )
667  {
668  SHAPE_POLY_SET polyList;
669 
670  aShape->TransformShapeWithClearanceToPolygon( polyList, aLayerId, 0,
671  ARC_HIGH_DEF, ERROR_INSIDE );
672 
673  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
674 
675  ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aShape );
676  }
677  else
678  {
679  std::vector<wxPoint> pts = aShape->GetRectCorners();
680 
681  const SFVEC2F topLeft3DU( pts[0].x * m_biuTo3Dunits, -pts[0].y * m_biuTo3Dunits );
682  const SFVEC2F topRight3DU( pts[1].x * m_biuTo3Dunits, -pts[1].y * m_biuTo3Dunits );
683  const SFVEC2F botRight3DU( pts[2].x * m_biuTo3Dunits, -pts[2].y * m_biuTo3Dunits );
684  const SFVEC2F botLeft3DU( pts[3].x * m_biuTo3Dunits, -pts[3].y * m_biuTo3Dunits );
685 
686  aDstContainer->Add( new ROUND_SEGMENT_2D( topLeft3DU, topRight3DU,
687  linewidth * m_biuTo3Dunits, *aShape ) );
688  aDstContainer->Add( new ROUND_SEGMENT_2D( topRight3DU, botRight3DU,
689  linewidth * m_biuTo3Dunits, *aShape ) );
690  aDstContainer->Add( new ROUND_SEGMENT_2D( botRight3DU, botLeft3DU,
691  linewidth * m_biuTo3Dunits, *aShape ) );
692  aDstContainer->Add( new ROUND_SEGMENT_2D( botLeft3DU, topLeft3DU,
693  linewidth * m_biuTo3Dunits, *aShape ) );
694  }
695  break;
696 
697  case SHAPE_T::ARC:
698  {
699  unsigned int segCount = GetCircleSegmentCount( aShape->GetBoundingBox().GetSizeMax() );
700 
701  transformArcToSegments( aShape->GetCenter(), aShape->GetStart(), aShape->GetArcAngle(),
702  segCount, linewidth, aDstContainer, *aShape );
703  }
704  break;
705 
706  case SHAPE_T::SEGMENT:
707  {
708  const SFVEC2F start3DU( aShape->GetStart().x * m_biuTo3Dunits,
709  -aShape->GetStart().y * m_biuTo3Dunits );
710 
711  const SFVEC2F end3DU ( aShape->GetEnd().x * m_biuTo3Dunits,
712  -aShape->GetEnd().y * m_biuTo3Dunits );
713 
714  if( Is_segment_a_circle( start3DU, end3DU ) )
715  {
716  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( linewidth / 2 ) * m_biuTo3Dunits,
717  *aShape ) );
718  }
719  else
720  {
721  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, linewidth * m_biuTo3Dunits,
722  *aShape ) );
723  }
724  }
725  break;
726 
727  case SHAPE_T::BEZIER:
728  case SHAPE_T::POLY:
729  {
730  SHAPE_POLY_SET polyList;
731 
732  aShape->TransformShapeWithClearanceToPolygon( polyList, aLayerId, 0,
733  ARC_HIGH_DEF, ERROR_INSIDE );
734 
735  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
736 
737  if( polyList.IsEmpty() ) // Just for caution
738  break;
739 
740  ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aShape );
741  }
742  break;
743 
744  default:
745  wxFAIL_MSG( wxT( "BOARD_ADAPTER::addShapeWithClearance no implementation for " )
746  + aShape->SHAPE_T_asString() );
747  break;
748  }
749 }
int GetWidth() const
Definition: eda_shape.h:98
void ConvertPolygonToTriangles(SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:106
bool IsEmpty() const
void transformArcToSegments(const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM &aBoardItem)
double GetArcAngle() const
Definition: eda_shape.cpp:536
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
bool IsFilled() const
Definition: eda_shape.h:90
std::vector< wxPoint > GetRectCorners() const
Definition: eda_shape.cpp:981
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:131
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
Represent a set of closed polygons.
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:79
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
void Simplify(POLYGON_MODE aFastMode)
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Check if segment start and end is very close to each other.
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.h:102
SHAPE_T GetShape() const
Definition: eda_shape.h:101
int GetRadius() const
Definition: eda_shape.cpp:472
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
Definition: pcb_shape.cpp:236
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
int GetSizeMax() const
Definition: eda_rect.h:105

References CONTAINER_2D_BASE::Add(), ARC, BEZIER, CIRCLE, ConvertPolygonToTriangles(), ERROR_INSIDE, EDA_SHAPE::GetArcAngle(), PCB_SHAPE::GetBoundingBox(), PCB_SHAPE::GetCenter(), GetCircleSegmentCount(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetRectCorners(), EDA_SHAPE::GetShape(), EDA_RECT::GetSizeMax(), EDA_SHAPE::GetStart(), EDA_SHAPE::GetWidth(), Is_segment_a_circle(), SHAPE_POLY_SET::IsEmpty(), EDA_SHAPE::IsFilled(), m_biuTo3Dunits, SHAPE_POLY_SET::PM_FAST, POLY, RECT, SEGMENT, EDA_SHAPE::SHAPE_T_asString(), SHAPE_POLY_SET::Simplify(), transformArcToSegments(), and PCB_SHAPE::TransformShapeWithClearanceToPolygon().

◆ addShapeWithClearance() [3/3]

void BOARD_ADAPTER::addShapeWithClearance ( const PCB_DIMENSION_BASE aDimension,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 113 of file create_3Dgraphic_brd_items.cpp.

116 {
117  addShapeWithClearance( &aDimension->Text(), aDstContainer, aLayerId, aClearanceValue );
118 
119  const int linewidth = aDimension->GetLineThickness() + ( 2 * aClearanceValue );
120 
121  for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
122  {
123  switch( shape->Type() )
124  {
125  case SH_SEGMENT:
126  {
127  const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
128 
129  const SFVEC2F start3DU( seg.A.x * m_biuTo3Dunits, -seg.A.y * m_biuTo3Dunits );
130 
131  const SFVEC2F end3DU( seg.B.x * m_biuTo3Dunits, -seg.B.y * m_biuTo3Dunits );
132 
133  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, linewidth * m_biuTo3Dunits,
134  *aDimension ) );
135  break;
136  }
137 
138  case SH_CIRCLE:
139  {
140  int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
141  int deltar = aDimension->GetLineThickness();
142 
143  SFVEC2F center( shape->Centre().x * m_biuTo3Dunits,
144  shape->Centre().y * m_biuTo3Dunits );
145 
146  aDstContainer->Add( new RING_2D( center, ( radius - deltar ) * m_biuTo3Dunits,
147  ( radius + deltar ) * m_biuTo3Dunits, *aDimension ) );
148 
149  break;
150  }
151 
152  default:
153  break;
154  }
155 
156  }
157 
158 }
PCB_TEXT & Text()
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
void addShapeWithClearance(const PCB_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
circle
Definition: shape.h:46
Definition: seg.h:40
VECTOR2I A
Definition: seg.h:48
int GetLineThickness() const
line segment
Definition: shape.h:44
VECTOR2I B
Definition: seg.h:49

References SEG::A, CONTAINER_2D_BASE::Add(), addShapeWithClearance(), SEG::B, PCB_DIMENSION_BASE::GetLineThickness(), PCB_DIMENSION_BASE::GetShapes(), m_biuTo3Dunits, SH_CIRCLE, SH_SEGMENT, PCB_DIMENSION_BASE::Text(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ addSolidAreasShapes()

void BOARD_ADAPTER::addSolidAreasShapes ( const ZONE aZoneContainer,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayerId 
)
private

Definition at line 755 of file create_3Dgraphic_brd_items.cpp.

757 {
758  // Copy the polys list because we have to simplify it
759  SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList( aLayerId ) );
760 
761  // This convert the poly in outline and holes
762  ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aZoneContainer );
763 
764  // add filled areas outlines, which are drawn with thick lines segments
765  // but only if filled polygons outlines have thickness
766  if( !aZoneContainer->GetFilledPolysUseThickness() )
767  return;
768 
769  float line_thickness = aZoneContainer->GetMinThickness() * m_biuTo3Dunits;
770 
771  for( int i = 0; i < polyList.OutlineCount(); ++i )
772  {
773  // Add outline
774  const SHAPE_LINE_CHAIN& pathOutline = polyList.COutline( i );
775 
776  for( int j = 0; j < pathOutline.PointCount(); ++j )
777  {
778  const VECTOR2I& a = pathOutline.CPoint( j );
779  const VECTOR2I& b = pathOutline.CPoint( j + 1 );
780 
781  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
782  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
783 
784  if( Is_segment_a_circle( start3DU, end3DU ) )
785  {
786  float radius = line_thickness/2;
787 
788  if( radius > 0.0 ) // degenerated circles crash 3D viewer
789  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius, *aZoneContainer ) );
790  }
791  else
792  {
793  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, line_thickness,
794  *aZoneContainer ) );
795  }
796  }
797 
798  // Add holes (of the poly, ie: the open parts) for this outline
799  for( int h = 0; h < polyList.HoleCount( i ); ++h )
800  {
801  const SHAPE_LINE_CHAIN& pathHole = polyList.CHole( i, h );
802 
803  for( int j = 0; j < pathHole.PointCount(); j++ )
804  {
805  const VECTOR2I& a = pathHole.CPoint( j );
806  const VECTOR2I& b = pathHole.CPoint( j + 1 );
807 
808  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
809  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
810 
811  if( Is_segment_a_circle( start3DU, end3DU ) )
812  {
813  float radius = line_thickness/2;
814 
815  if( radius > 0.0 ) // degenerated circles crash 3D viewer
816  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius,
817  *aZoneContainer ) );
818  }
819  else
820  {
821  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, line_thickness,
822  *aZoneContainer ) );
823  }
824  }
825  }
826  }
827 }
void ConvertPolygonToTriangles(SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:637
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int PointCount() const
Return the number of points (vertices) in this line chain.
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
int GetMinThickness() const
Definition: zone.h:244
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
Represent a set of closed polygons.
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Check if segment start and end is very close to each other.
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
bool GetFilledPolysUseThickness() const
Definition: zone.h:691

References CONTAINER_2D_BASE::Add(), SHAPE_POLY_SET::CHole(), ConvertPolygonToTriangles(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), ZONE::GetFilledPolysList(), ZONE::GetFilledPolysUseThickness(), ZONE::GetMinThickness(), SHAPE_POLY_SET::HoleCount(), Is_segment_a_circle(), m_biuTo3Dunits, SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers().

◆ BiuTo3dUnits()

double BOARD_ADAPTER::BiuTo3dUnits ( ) const
inlinenoexcept

Board integer units To 3D units.

Returns
the conversion factor to transform a position from the board to 3D units.

Definition at line 159 of file board_adapter.h.

160  {
161  return m_biuTo3Dunits;
162  }
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.

References m_biuTo3Dunits.

Referenced by RENDER_3D_OPENGL::createBoard(), createLayers(), RENDER_3D_OPENGL::generate3dGrid(), RENDER_3D_OPENGL::generateHoles(), RENDER_3D_OPENGL::generateLayerList(), RENDER_3D_OPENGL::generateViasAndPads(), RENDER_3D_RAYTRACE::insertHole(), RENDER_3D_RAYTRACE::load3DModels(), RENDER_3D_RAYTRACE::Reload(), RENDER_3D_OPENGL::renderFootprint(), and RENDER_3D_RAYTRACE::setupMaterials().

◆ buildPadOutlineAsPolygon()

void BOARD_ADAPTER::buildPadOutlineAsPolygon ( const PAD aPad,
SHAPE_POLY_SET aCornerBuffer,
int  aWidth 
) const
private

Definition at line 37 of file create_layer_poly.cpp.

39 {
40  if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
41  {
42  TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(), aPad->GetSize().x / 2,
43  aWidth, ARC_HIGH_DEF, ERROR_INSIDE );
44  return;
45  }
46 
47  // For other shapes, add outlines as thick segments in polygon buffer
48  const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
49  const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
50 
51  for( int ii = 0; ii < path.PointCount(); ++ii )
52  {
53  const VECTOR2I& a = path.CPoint( ii );
54  const VECTOR2I& b = path.CPoint( ii + 1 );
55 
56  TransformOvalToPolygon( aCornerBuffer, (wxPoint) a, (wxPoint) b, aWidth, ARC_HIGH_DEF,
57  ERROR_INSIDE );
58  }
59 }
wxPoint ShapePos() const
Definition: pad.cpp:706
const wxSize & GetSize() const
Definition: pad.h:233
PAD_SHAPE GetShape() const
Definition: pad.h:170
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:300
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aCentre, int aRadius, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arcs to multiple straight segments.

References CIRCLE, ERROR_INSIDE, PAD::GetEffectivePolygon(), PAD::GetShape(), PAD::GetSize(), path, PAD::ShapePos(), TransformOvalToPolygon(), and TransformRingToPolygon().

Referenced by createLayers().

◆ buildPadOutlineAsSegments()

void BOARD_ADAPTER::buildPadOutlineAsSegments ( const PAD aPad,
CONTAINER_2D_BASE aDstContainer,
int  aWidth 
)
private

Definition at line 830 of file create_3Dgraphic_brd_items.cpp.

832 {
833  if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
834  {
835  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
836  -aPad->ShapePos().y * m_biuTo3Dunits );
837 
838  const double radius = aPad->GetSize().x / 2.0;
839  const float inner_radius = ( radius - aWidth / 2.0 ) * m_biuTo3Dunits;
840  const float outer_radius = ( radius + aWidth / 2.0 ) * m_biuTo3Dunits;
841 
842  aDstContainer->Add( new RING_2D( center3DU, inner_radius, outer_radius, *aPad ) );
843 
844  return;
845  }
846 
847  // For other shapes, add outlines as thick segments in polygon buffer
848  const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
849  const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
850 
851  for( int j = 0; j < path.PointCount(); j++ )
852  {
853  const VECTOR2I& a = path.CPoint( j );
854  const VECTOR2I& b = path.CPoint( j + 1 );
855 
856  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
857  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
858 
859  if( Is_segment_a_circle( start3DU, end3DU ) )
860  {
861  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
862  *aPad ) );
863  }
864  else
865  {
866  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
867  *aPad ) );
868  }
869  }
870 }
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
wxPoint ShapePos() const
Definition: pad.cpp:706
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
const wxSize & GetSize() const
Definition: pad.h:233
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
PAD_SHAPE GetShape() const
Definition: pad.h:170
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Check if segment start and end is very close to each other.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:300

References CONTAINER_2D_BASE::Add(), CIRCLE, PAD::GetEffectivePolygon(), PAD::GetShape(), PAD::GetSize(), Is_segment_a_circle(), m_biuTo3Dunits, path, PAD::ShapePos(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers().

◆ createBoardPolygon()

bool BOARD_ADAPTER::createBoardPolygon ( wxString *  aErrorMsg)
private

Create the board outline polygon.

Returns
false if the outline could not be created

Definition at line 698 of file board_adapter.cpp.

699 {
701 
702  if( !m_board )
703  return false;
704 
705  bool success;
706 
707  if( m_board->IsFootprintHolder() )
708  {
709  if( !m_board->GetFirstFootprint() )
710  {
711  if( aErrorMsg )
712  *aErrorMsg = _( "No footprint loaded." );
713 
714  return false;
715  }
716 
717  int chainingEpsilon = Millimeter2iu( 0.02 ); // max dist from one endPt to next startPt
718 
721  chainingEpsilon );
722 
723  // Make polygon strictly simple to avoid issues (especially in 3D viewer)
725 
726  if( !success && aErrorMsg )
727  {
728  *aErrorMsg = _( "Footprint outline is missing or malformed. Run Footprint Checker for "
729  "a full analysis." );
730  }
731  }
732  else
733  {
735 
736  if( !success && aErrorMsg )
737  *aErrorMsg = _( "Board outline is missing or malformed. Run DRC for a full analysis." );
738  }
739 
740  return success;
741 }
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
Definition: board.cpp:1835
bool BuildFootprintPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
This function is used to extract a board outline for a footprint view.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:222
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:318
SHAPE_POLY_SET m_board_poly
Board outline polygon.
#define _(s)
void Simplify(POLYGON_MODE aFastMode)
static constexpr int Millimeter2iu(double mm)

References _, BuildFootprintPolygonOutlines(), BOARD::GetBoardPolygonOutlines(), BOARD::GetDesignSettings(), BOARD::GetFirstFootprint(), BOARD::IsFootprintHolder(), m_board, m_board_poly, BOARD_DESIGN_SETTINGS::m_MaxError, Millimeter2iu(), SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, SHAPE_POLY_SET::RemoveAllContours(), and SHAPE_POLY_SET::Simplify().

Referenced by InitSettings().

◆ createLayers()

void BOARD_ADAPTER::createLayers ( REPORTER aStatusReporter)
private

Definition at line 127 of file create_layer_items.cpp.

128 {
129  destroyLayers();
130 
131  // Build Copper layers
132  // Based on:
133  // https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L692
134 
135 #ifdef PRINT_STATISTICS_3D_VIEWER
136  unsigned stats_startCopperLayersTime = GetRunningMicroSecs();
137 
138  unsigned start_Time = stats_startCopperLayersTime;
139 #endif
140 
141  PCB_LAYER_ID cu_seq[MAX_CU_LAYERS];
143 
144  m_trackCount = 0;
146  m_viaCount = 0;
148  m_holeCount = 0;
150 
151  if( !m_board )
152  return;
153 
154  // Prepare track list, convert in a vector. Calc statistic for the holes
155  std::vector<const PCB_TRACK*> trackList;
156  trackList.clear();
157  trackList.reserve( m_board->Tracks().size() );
158 
159  for( PCB_TRACK* track : m_board->Tracks() )
160  {
161  if( !Is3dLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
162  continue;
163 
164  // Note: a PCB_TRACK holds normal segment tracks and also vias circles (that have also
165  // drill values)
166  trackList.push_back( track );
167 
168  if( track->Type() == PCB_VIA_T )
169  {
170  const PCB_VIA *via = static_cast< const PCB_VIA*>( track );
171  m_viaCount++;
172  m_averageViaHoleDiameter += via->GetDrillValue() * m_biuTo3Dunits;
173  }
174  else
175  {
176  m_trackCount++;
177  }
178 
179  m_averageTrackWidth += track->GetWidth() * m_biuTo3Dunits;
180  }
181 
182  if( m_trackCount )
184 
185  if( m_viaCount )
187 
188  // Prepare copper layers index and containers
189  std::vector< PCB_LAYER_ID > layer_id;
190  layer_id.clear();
191  layer_id.reserve( m_copperLayersCount );
192 
193  for( unsigned i = 0; i < arrayDim( cu_seq ); ++i )
194  cu_seq[i] = ToLAYER_ID( B_Cu - i );
195 
196  for( LSEQ cu = cu_set.Seq( cu_seq, arrayDim( cu_seq ) ); cu; ++cu )
197  {
198  const PCB_LAYER_ID curr_layer_id = *cu;
199 
200  if( !Is3dLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
201  continue;
202 
203  layer_id.push_back( curr_layer_id );
204 
205  BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
206  m_layerMap[curr_layer_id] = layerContainer;
207 
209  {
210  SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET;
211  m_layers_poly[curr_layer_id] = layerPoly;
212  }
213  }
214 
216  {
219 
222 
223  }
224 
225  if( aStatusReporter )
226  aStatusReporter->Report( _( "Create tracks and vias" ) );
227 
228  // Create tracks as objects and add it to container
229  for( PCB_LAYER_ID curr_layer_id : layer_id )
230  {
231  wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
232 
233  BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
234 
235  // Add track segments shapes and via annulus shapes
236  unsigned int nTracks = trackList.size();
237 
238  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
239  {
240  const PCB_TRACK *track = trackList[trackIdx];
241 
242  // NOTE: Vias can be on multiple layers
243  if( !track->IsOnLayer( curr_layer_id ) )
244  continue;
245 
246  // Skip vias annulus when not connected on this layer (if removing is enabled)
247  const PCB_VIA *via = dyn_cast< const PCB_VIA*>( track );
248 
249  if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
250  continue;
251 
252  // Add object item to layer container
253  createTrack( track, layerContainer, 0.0f );
254  }
255  }
256 
257  // Create VIAS and THTs objects and add it to holes containers
258  for( PCB_LAYER_ID curr_layer_id : layer_id )
259  {
260  // ADD TRACKS
261  unsigned int nTracks = trackList.size();
262 
263  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
264  {
265  const PCB_TRACK *track = trackList[trackIdx];
266 
267  if( !track->IsOnLayer( curr_layer_id ) )
268  continue;
269 
270  // ADD VIAS and THT
271  if( track->Type() == PCB_VIA_T )
272  {
273  const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
274  const VIATYPE viatype = via->GetViaType();
275  const float holediameter = via->GetDrillValue() * BiuTo3dUnits();
276 
277  // holes and layer copper extend half info cylinder wall to hide transition
278  const float thickness = GetHolePlatingThickness() * BiuTo3dUnits() / 2.0f;
279  const float hole_inner_radius = holediameter / 2.0f;
280  const float ring_radius = via->GetWidth() * BiuTo3dUnits() / 2.0f;
281 
282  const SFVEC2F via_center( via->GetStart().x * m_biuTo3Dunits,
283  -via->GetStart().y * m_biuTo3Dunits );
284 
285  if( viatype != VIATYPE::THROUGH )
286  {
287 
288  // Add hole objects
289  BVH_CONTAINER_2D *layerHoleContainer = nullptr;
290 
291  // Check if the layer is already created
292  if( m_layerHoleMap.find( curr_layer_id ) == m_layerHoleMap.end() )
293  {
294  // not found, create a new container
295  layerHoleContainer = new BVH_CONTAINER_2D;
296  m_layerHoleMap[curr_layer_id] = layerHoleContainer;
297  }
298  else
299  {
300  // found
301  layerHoleContainer = m_layerHoleMap[curr_layer_id];
302  }
303 
304  // Add a hole for this layer
305  layerHoleContainer->Add( new FILLED_CIRCLE_2D( via_center,
306  hole_inner_radius + thickness,
307  *track ) );
308  }
309  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
310  {
311  // Add through hole object
312  m_throughHoleOds.Add( new FILLED_CIRCLE_2D( via_center,
313  hole_inner_radius + thickness,
314  *track ) );
315  m_throughHoleViaOds.Add( new FILLED_CIRCLE_2D( via_center,
316  hole_inner_radius + thickness,
317  *track ) );
318 
321  {
323  ring_radius,
324  *track ) );
325  }
326 
327  m_throughHoleIds.Add( new FILLED_CIRCLE_2D( via_center, hole_inner_radius,
328  *track ) );
329  }
330  }
331  }
332  }
333 
334  // Create VIAS and THTs objects and add it to holes containers
335  for( PCB_LAYER_ID curr_layer_id : layer_id )
336  {
337  // ADD TRACKS
338  const unsigned int nTracks = trackList.size();
339 
340  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
341  {
342  const PCB_TRACK *track = trackList[trackIdx];
343 
344  if( !track->IsOnLayer( curr_layer_id ) )
345  continue;
346 
347  // ADD VIAS and THT
348  if( track->Type() == PCB_VIA_T )
349  {
350  const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
351  const VIATYPE viatype = via->GetViaType();
352 
353  if( viatype != VIATYPE::THROUGH )
354  {
355  // Add PCB_VIA hole contours
356 
357  // Add outer holes of VIAs
358  SHAPE_POLY_SET *layerOuterHolesPoly = nullptr;
359  SHAPE_POLY_SET *layerInnerHolesPoly = nullptr;
360 
361  // Check if the layer is already created
362  if( m_layerHoleOdPolys.find( curr_layer_id ) ==
363  m_layerHoleOdPolys.end() )
364  {
365  // not found, create a new container
366  layerOuterHolesPoly = new SHAPE_POLY_SET;
367  m_layerHoleOdPolys[curr_layer_id] = layerOuterHolesPoly;
368 
369  wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) ==
370  m_layerHoleIdPolys.end() );
371 
372  layerInnerHolesPoly = new SHAPE_POLY_SET;
373  m_layerHoleIdPolys[curr_layer_id] = layerInnerHolesPoly;
374  }
375  else
376  {
377  // found
378  layerOuterHolesPoly = m_layerHoleOdPolys[curr_layer_id];
379 
380  wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) !=
381  m_layerHoleIdPolys.end() );
382 
383  layerInnerHolesPoly = m_layerHoleIdPolys[curr_layer_id];
384  }
385 
386  const int holediameter = via->GetDrillValue();
387  const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
388 
389  TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
390  hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
391 
392  TransformCircleToPolygon( *layerInnerHolesPoly, via->GetStart(),
393  holediameter / 2, ARC_HIGH_DEF, ERROR_INSIDE );
394  }
395  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
396  {
397  const int holediameter = via->GetDrillValue();
398  const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
399  const int hole_outer_ring_radius = via->GetWidth() / 2.0f;
400 
401  // Add through hole contours
403  hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
404 
405  // Add same thing for vias only
407  hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
408 
410  {
412  via->GetStart(), hole_outer_ring_radius,
413  ARC_HIGH_DEF, ERROR_INSIDE );
414  }
415  }
416  }
417  }
418  }
419 
420  // Creates vertical outline contours of the tracks and add it to the poly of the layer
422  {
423  for( PCB_LAYER_ID curr_layer_id : layer_id )
424  {
425  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
426 
427  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
428 
429  // ADD TRACKS
430  unsigned int nTracks = trackList.size();
431 
432  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
433  {
434  const PCB_TRACK *track = trackList[trackIdx];
435 
436  if( !track->IsOnLayer( curr_layer_id ) )
437  continue;
438 
439  // Skip vias annulus when not connected on this layer (if removing is enabled)
440  const PCB_VIA *via = dyn_cast<const PCB_VIA*>( track );
441 
442  if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
443  continue;
444 
445  // Add the track/via contour
446  track->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
447  ARC_HIGH_DEF, ERROR_INSIDE );
448  }
449  }
450  }
451 
452  // Add holes of footprints
453  for( FOOTPRINT* footprint : m_board->Footprints() )
454  {
455  for( PAD* pad : footprint->Pads() )
456  {
457  const wxSize padHole = pad->GetDrillSize();
458 
459  if( !padHole.x ) // Not drilled pad like SMD pad
460  continue;
461 
462  // The hole in the body is inflated by copper thickness, if not plated, no copper
463  const int inflate = ( pad->GetAttribute () != PAD_ATTRIB::NPTH ) ?
464  GetHolePlatingThickness() / 2 : 0;
465 
466  m_holeCount++;
467  m_averageHoleDiameter += ( ( pad->GetDrillSize().x +
468  pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
469 
471 
473  {
475  }
476 
478  }
479  }
480 
481  if( m_holeCount )
483 
484  // Add contours of the pad holes (pads can be Circle or Segment holes)
485  for( FOOTPRINT* footprint : m_board->Footprints() )
486  {
487  for( PAD* pad : footprint->Pads() )
488  {
489  const wxSize padHole = pad->GetDrillSize();
490 
491  if( !padHole.x ) // Not drilled pad like SMD pad
492  continue;
493 
494  // The hole in the body is inflated by copper thickness.
495  const int inflate = GetHolePlatingThickness();
496 
497  if( pad->GetAttribute () != PAD_ATTRIB::NPTH )
498  {
500  {
501  pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys,
502  inflate, ARC_HIGH_DEF, ERROR_INSIDE );
503  }
504 
505  pad->TransformHoleWithClearanceToPolygon( m_throughHoleOdPolys, inflate,
506  ARC_HIGH_DEF, ERROR_INSIDE );
507  }
508  else
509  {
510  // If not plated, no copper.
512  {
513  pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys, 0,
514  ARC_HIGH_DEF, ERROR_INSIDE );
515  }
516 
517  pad->TransformHoleWithClearanceToPolygon( m_nonPlatedThroughHoleOdPolys, 0,
518  ARC_HIGH_DEF, ERROR_INSIDE );
519  }
520  }
521  }
522 
523  const bool renderPlatedPadsAsPlated = GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) &&
525 
526  // Add footprints PADs objects to containers
527  for( PCB_LAYER_ID curr_layer_id : layer_id )
528  {
529  wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
530 
531  BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
532 
533  // ADD PADS
534  for( FOOTPRINT* footprint : m_board->Footprints() )
535  {
536  // Note: NPTH pads are not drawn on copper layers when the pad
537  // has same shape as its hole
538  addPadsWithClearance( footprint, layerContainer, curr_layer_id, 0,
539  true, renderPlatedPadsAsPlated, false );
540 
541  // Micro-wave footprints may have items on copper layers
542  addFootprintShapesWithClearance( footprint, layerContainer, curr_layer_id, 0 );
543  }
544  }
545 
546  if( renderPlatedPadsAsPlated )
547  {
548  // ADD PLATED PADS
549  for( FOOTPRINT* footprint : m_board->Footprints() )
550  {
551  addPadsWithClearance( footprint, m_platedPadsFront, F_Cu, 0, true, false, true );
552  addPadsWithClearance( footprint, m_platedPadsBack, B_Cu, 0, true, false, true );
553  }
554 
557  }
558 
559  // Add footprints PADs poly contours (vertical outlines)
561  {
562  for( PCB_LAYER_ID curr_layer_id : layer_id )
563  {
564  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
565 
566  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
567 
568  // Add pads to polygon list
569  for( FOOTPRINT* footprint : m_board->Footprints() )
570  {
571  // Note: NPTH pads are not drawn on copper layers when the pad has same shape as
572  // its hole
573  footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id,
574  0, ARC_HIGH_DEF, ERROR_INSIDE,
575  true, renderPlatedPadsAsPlated,
576  false );
577 
578  transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
579  }
580  }
581 
582  if( renderPlatedPadsAsPlated )
583  {
584  // ADD PLATED PADS contours
585  for( FOOTPRINT* footprint : m_board->Footprints() )
586  {
587  footprint->TransformPadsWithClearanceToPolygon( *m_frontPlatedPadPolys, F_Cu,
588  0, ARC_HIGH_DEF, ERROR_INSIDE,
589  true, false, true );
590 
591  footprint->TransformPadsWithClearanceToPolygon( *m_backPlatedPadPolys, B_Cu,
592  0, ARC_HIGH_DEF, ERROR_INSIDE,
593  true, false, true );
594  }
595  }
596  }
597 
598  // Add graphic item on copper layers to object containers
599  for( PCB_LAYER_ID curr_layer_id : layer_id )
600  {
601  wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
602 
603  BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
604 
605  // Add graphic items on copper layers (texts and other graphics)
606  for( BOARD_ITEM* item : m_board->Drawings() )
607  {
608  if( !item->IsOnLayer( curr_layer_id ) )
609  continue;
610 
611  switch( item->Type() )
612  {
613  case PCB_SHAPE_T:
614  addShapeWithClearance( static_cast<PCB_SHAPE*>( item ), layerContainer,
615  curr_layer_id, 0 );
616  break;
617 
618  case PCB_TEXT_T:
619  addShapeWithClearance( static_cast<PCB_TEXT*>( item ), layerContainer,
620  curr_layer_id, 0 );
621  break;
622 
623  case PCB_DIM_ALIGNED_T:
624  case PCB_DIM_CENTER_T:
626  case PCB_DIM_LEADER_T:
627  addShapeWithClearance( static_cast<PCB_DIMENSION_BASE*>( item ),
628  layerContainer, curr_layer_id, 0 );
629  break;
630 
631  default:
632  wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
633  item->Type() );
634  break;
635  }
636  }
637  }
638 
639  // Add graphic item on copper layers to poly contours (vertical outlines)
641  {
642  for( PCB_LAYER_ID cur_layer_id : layer_id )
643  {
644  wxASSERT( m_layers_poly.find( cur_layer_id ) != m_layers_poly.end() );
645 
646  SHAPE_POLY_SET *layerPoly = m_layers_poly[cur_layer_id];
647 
648  // Add graphic items on copper layers (texts and other )
649  for( BOARD_ITEM* item : m_board->Drawings() )
650  {
651  if( !item->IsOnLayer( cur_layer_id ) )
652  continue;
653 
654  switch( item->Type() )
655  {
656  case PCB_SHAPE_T:
657  item->TransformShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
658  ARC_HIGH_DEF, ERROR_INSIDE );
659  break;
660 
661  case PCB_TEXT_T:
662  {
663  PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
664 
665  text->TransformTextShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
666  ARC_HIGH_DEF, ERROR_INSIDE );
667  }
668  break;
669 
670  default:
671  wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
672  item->Type() );
673  break;
674  }
675  }
676  }
677  }
678 
679  if( GetFlag( FL_ZONE ) )
680  {
681  if( aStatusReporter )
682  aStatusReporter->Report( _( "Create zones" ) );
683 
684  std::vector<std::pair<ZONE*, PCB_LAYER_ID>> zones;
685  std::unordered_map<PCB_LAYER_ID, std::unique_ptr<std::mutex>> layer_lock;
686 
687  for( ZONE* zone : m_board->Zones() )
688  {
689  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
690  {
691  zones.emplace_back( std::make_pair( zone, layer ) );
692  layer_lock.emplace( layer, std::make_unique<std::mutex>() );
693  }
694  }
695 
696  // Add zones objects
697  std::atomic<size_t> nextZone( 0 );
698  std::atomic<size_t> threadsFinished( 0 );
699 
700  size_t parallelThreadCount = std::min<size_t>( zones.size(),
701  std::max<size_t>( std::thread::hardware_concurrency(), 2 ) );
702 
703  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
704  {
705  std::thread t = std::thread( [&]()
706  {
707  for( size_t areaId = nextZone.fetch_add( 1 );
708  areaId < zones.size();
709  areaId = nextZone.fetch_add( 1 ) )
710  {
711  ZONE* zone = zones[areaId].first;
712 
713  if( zone == nullptr )
714  break;
715 
716  PCB_LAYER_ID layer = zones[areaId].second;
717 
718  auto layerContainer = m_layerMap.find( layer );
719  auto layerPolyContainer = m_layers_poly.find( layer );
720 
721  if( layerContainer != m_layerMap.end() )
722  {
723  addSolidAreasShapes( zone, layerContainer->second, layer );
724  }
725 
728  && layerPolyContainer != m_layers_poly.end() )
729  {
730  auto mut_it = layer_lock.find( layer );
731 
732  std::lock_guard< std::mutex > lock( *( mut_it->second ) );
733  zone->TransformSolidAreasShapesToPolygon( layer, *layerPolyContainer->second );
734  }
735  }
736 
737  threadsFinished++;
738  } );
739 
740  t.detach();
741  }
742 
743  while( threadsFinished < parallelThreadCount )
744  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
745 
746  }
747 
748  // Simplify layer polygons
749 
750  if( aStatusReporter )
751  aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
752 
754  {
756  {
757  if( m_frontPlatedPadPolys && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) )
758  {
759  if( aStatusReporter )
760  aStatusReporter->Report( _( "Simplifying polygons on F_Cu" ) );
761 
762  SHAPE_POLY_SET *layerPoly_F_Cu = m_layers_poly[F_Cu];
764 
766  }
767 
768  if( m_backPlatedPadPolys && ( m_layers_poly.find( B_Cu ) != m_layers_poly.end() ) )
769  {
770  if( aStatusReporter )
771  aStatusReporter->Report( _( "Simplifying polygons on B_Cu" ) );
772 
773  SHAPE_POLY_SET *layerPoly_B_Cu = m_layers_poly[B_Cu];
775 
777  }
778  }
779 
780  std::vector< PCB_LAYER_ID > &selected_layer_id = layer_id;
781  std::vector< PCB_LAYER_ID > layer_id_without_F_and_B;
782 
784  {
785  layer_id_without_F_and_B.clear();
786  layer_id_without_F_and_B.reserve( layer_id.size() );
787 
788  for( size_t i = 0; i < layer_id.size(); ++i )
789  {
790  if( ( layer_id[i] != F_Cu ) && ( layer_id[i] != B_Cu ) )
791  layer_id_without_F_and_B.push_back( layer_id[i] );
792  }
793 
794  selected_layer_id = layer_id_without_F_and_B;
795  }
796 
797  if( selected_layer_id.size() > 0 )
798  {
799  if( aStatusReporter )
800  aStatusReporter->Report( wxString::Format(
801  _( "Simplifying %d copper layers" ),
802  (int)selected_layer_id.size() ) );
803 
804  std::atomic<size_t> nextItem( 0 );
805  std::atomic<size_t> threadsFinished( 0 );
806 
807  size_t parallelThreadCount = std::min<size_t>(
808  std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
809  selected_layer_id.size() );
810 
811  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
812  {
813  std::thread t = std::thread(
814  [&nextItem, &threadsFinished, &selected_layer_id, this]()
815  {
816  for( size_t i = nextItem.fetch_add( 1 );
817  i < selected_layer_id.size();
818  i = nextItem.fetch_add( 1 ) )
819  {
820  auto layerPoly = m_layers_poly.find( selected_layer_id[i] );
821 
822  if( layerPoly != m_layers_poly.end() )
823  // This will make a union of all added contours
824  layerPoly->second->Simplify( SHAPE_POLY_SET::PM_FAST );
825  }
826 
827  threadsFinished++;
828  } );
829 
830  t.detach();
831  }
832 
833  while( threadsFinished < parallelThreadCount )
834  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
835  }
836  }
837 
838  // Simplify holes polygon contours
839  if( aStatusReporter )
840  aStatusReporter->Report( _( "Simplify holes contours" ) );
841 
842  for( PCB_LAYER_ID layer : layer_id )
843  {
844  if( m_layerHoleOdPolys.find( layer ) != m_layerHoleOdPolys.end() )
845  {
846  // found
847  SHAPE_POLY_SET *polyLayer = m_layerHoleOdPolys[layer];
848  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
849 
850  wxASSERT( m_layerHoleIdPolys.find( layer ) != m_layerHoleIdPolys.end() );
851 
852  polyLayer = m_layerHoleIdPolys[layer];
853  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
854  }
855  }
856 
857  // End Build Copper layers
858 
859  // This will make a union of all added contours
864 
865  // Build Tech layers
866  // Based on:
867  // https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
868  if( aStatusReporter )
869  aStatusReporter->Report( _( "Build Tech layers" ) );
870 
871  // draw graphic items, on technical layers
872  static const PCB_LAYER_ID teckLayerList[] = {
873  B_Adhes,
874  F_Adhes,
875  B_Paste,
876  F_Paste,
877  B_SilkS,
878  F_SilkS,
879  B_Mask,
880  F_Mask,
881 
882  // Aux Layers
883  Dwgs_User,
884  Cmts_User,
885  Eco1_User,
886  Eco2_User,
887  Edge_Cuts,
888  Margin
889  };
890 
891  // User layers are not drawn here, only technical layers
892  for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, arrayDim( teckLayerList ) );
893  seq;
894  ++seq )
895  {
896  const PCB_LAYER_ID curr_layer_id = *seq;
897 
898  if( !Is3dLayerEnabled( curr_layer_id ) )
899  continue;
900 
901  if( aStatusReporter )
902  aStatusReporter->Report( wxString::Format(
903  _( "Build Tech layer %d" ), (int)curr_layer_id ) );
904 
905  BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
906  m_layerMap[curr_layer_id] = layerContainer;
907 
908  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
909  m_layers_poly[curr_layer_id] = layerPoly;
910 
911  // Add drawing objects
912  for( BOARD_ITEM* item : m_board->Drawings() )
913  {
914  if( !item->IsOnLayer( curr_layer_id ) )
915  continue;
916 
917  switch( item->Type() )
918  {
919  case PCB_SHAPE_T:
920  addShapeWithClearance( static_cast<PCB_SHAPE*>( item ), layerContainer,
921  curr_layer_id, 0 );
922  break;
923 
924  case PCB_TEXT_T:
925  addShapeWithClearance( static_cast<PCB_TEXT*>( item ), layerContainer,
926  curr_layer_id, 0 );
927  break;
928 
929  case PCB_DIM_ALIGNED_T:
930  case PCB_DIM_CENTER_T:
932  case PCB_DIM_LEADER_T:
933  addShapeWithClearance( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer,
934  curr_layer_id, 0 );
935  break;
936 
937  default:
938  break;
939  }
940  }
941 
942  // Add drawing contours
943  for( BOARD_ITEM* item : m_board->Drawings() )
944  {
945  if( !item->IsOnLayer( curr_layer_id ) )
946  continue;
947 
948  switch( item->Type() )
949  {
950  case PCB_SHAPE_T:
951  item->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
952  ARC_HIGH_DEF, ERROR_INSIDE );
953  break;
954 
955  case PCB_TEXT_T:
956  {
957  PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
958 
959  text->TransformTextShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
960  ARC_HIGH_DEF, ERROR_INSIDE );
961  }
962  break;
963 
964  default:
965  break;
966  }
967  }
968 
969  // Add footprints tech layers - objects
970  for( FOOTPRINT* footprint : m_board->Footprints() )
971  {
972  if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) )
973  {
975 
976  for( PAD* pad : footprint->Pads() )
977  {
978  if( !pad->IsOnLayer( curr_layer_id ) )
979  continue;
980 
981  buildPadOutlineAsSegments( pad, layerContainer, linewidth );
982  }
983  }
984  else
985  {
986  addPadsWithClearance( footprint, layerContainer, curr_layer_id, 0,
987  false, false, false );
988  }
989 
990  addFootprintShapesWithClearance( footprint, layerContainer, curr_layer_id, 0 );
991  }
992 
993 
994  // Add footprints tech layers - contours
995  for( FOOTPRINT* footprint : m_board->Footprints() )
996  {
997  if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) )
998  {
1000 
1001  for( PAD* pad : footprint->Pads() )
1002  {
1003  if( !pad->IsOnLayer( curr_layer_id ) )
1004  continue;
1005 
1006  buildPadOutlineAsPolygon( pad, *layerPoly, linewidth );
1007  }
1008  }
1009  else
1010  {
1011  footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
1012  ARC_HIGH_DEF, ERROR_INSIDE );
1013  }
1014 
1015  // On tech layers, use a poor circle approximation, only for texts (stroke font)
1016  footprint->TransformFPTextWithClearanceToPolygonSet( *layerPoly, curr_layer_id, 0,
1017  ARC_HIGH_DEF, ERROR_INSIDE );
1018 
1019  // Add the remaining things with dynamic seg count for circles
1020  transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
1021  }
1022 
1023 
1024  // Draw non copper zones
1025  if( GetFlag( FL_ZONE ) )
1026  {
1027  for( ZONE* zone : m_board->Zones() )
1028  {
1029  if( zone->IsOnLayer( curr_layer_id ) )
1030  addSolidAreasShapes( zone, layerContainer, curr_layer_id );
1031  }
1032 
1033  for( ZONE* zone : m_board->Zones() )
1034  {
1035  if( zone->IsOnLayer( curr_layer_id ) )
1036  zone->TransformSolidAreasShapesToPolygon( curr_layer_id, *layerPoly );
1037  }
1038  }
1039 
1040  // This will make a union of all added contours
1041  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1042  }
1043  // End Build Tech layers
1044 
1045  // Build BVH (Bounding volume hierarchy) for holes and vias
1046 
1047  if( aStatusReporter )
1048  aStatusReporter->Report( _( "Build BVH for holes and vias" ) );
1049 
1053 
1054  if( !m_layerHoleMap.empty() )
1055  {
1056  for( auto& hole : m_layerHoleMap )
1057  hole.second->BuildBVH();
1058  }
1059 
1060  // We only need the Solder mask to initialize the BVH
1061  // because..?
1062  if( m_layerMap[B_Mask] )
1063  m_layerMap[B_Mask]->BuildBVH();
1064 
1065  if( m_layerMap[F_Mask] )
1066  m_layerMap[F_Mask]->BuildBVH();
1067 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
BVH_CONTAINER_2D m_throughHoleViaOds
List of through hole via inner diameters.
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BVH_CONTAINER_2D * m_platedPadsFront
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:100
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
ZONES & Zones()
Definition: board.h:240
SHAPE_POLY_SET * m_backPlatedPadPolys
Polygon contours for hole outer diameters for each layer.
BVH_CONTAINER_2D m_throughHoleIds
List of through hole vias with the radius of the hole inflated with the copper thickness.
void buildPadOutlineAsSegments(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, int aWidth)
SHAPE_POLY_SET * m_frontPlatedPadPolys
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
OBJECT_2D * createPadWithDrill(const PAD *aPad, int aInflateValue)
float m_averageHoleDiameter
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:102
SHAPE_POLY_SET m_throughHoleAnnularRingPolys
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:782
MAP_CONTAINER_2D_BASE m_layerMap
2D elements for each layer.
void transformFPShapesToPolygon(const FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer) const
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
BVH_CONTAINER_2D m_throughHoleOds
List of plated through hole annular rings.
SHAPE_POLY_SET m_throughHoleViaOdPolys
Polygon contours for through hole via annular rings.
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:314
float m_averageTrackWidth
Number of through hole vias in the board.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
Definition: pcb_track.cpp:1032
void addFootprintShapesWithClearance(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue)
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
MAP_POLY m_layerHoleIdPolys
Polygon contours for non plated through hole outer diameters.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer) const
Check if a layer is enabled.
like PAD_PTH, but not plated
void addShapeWithClearance(const PCB_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:516
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:195
unsigned int m_trackCount
Track average width.
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
#define MAX_CU_LAYERS
Definition: layer_ids.h:147
BVH_CONTAINER_2D * m_platedPadsBack
The holes per each layer.
Represent a set of closed polygons.
MAP_POLY m_layerHoleOdPolys
Polygon contours for hole inner diameters for each layer.
FOOTPRINTS & Footprints()
Definition: board.h:234
void buildPadOutlineAsPolygon(const PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
MAP_CONTAINER_2D_BASE m_layerHoleMap
List of through holes with the radius of the hole inflated with the copper thickness.
void addSolidAreasShapes(const ZONE *aZoneContainer, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, const wxPoint &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
void addPadsWithClearance(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
#define _(s)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
void createTrack(const PCB_TRACK *aTrack, CONTAINER_2D_BASE *aDstContainer, int aClearanceValue)
void Simplify(POLYGON_MODE aFastMode)
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
BVH_CONTAINER_2D m_throughHoleAnnularRings
List of through hole inner diameters.
void TransformSolidAreasShapesToPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aError=ARC_HIGH_DEF) const
Convert solid areas full shapes to polygon set (the full shape is the polygon area with a thick outli...
Definition: zone.cpp:1377
unsigned int m_viaCount
Computed average diameter of the via holes in 3D units.
int m_LineThickness[LAYER_CLASS_COUNT]
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:477
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:808
MAP_POLY m_layers_poly
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
RENDER_ENGINE m_renderEngine
VIATYPE
Definition: pcb_track.h:60
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
unsigned int m_copperLayersCount
Scale factor to convert board internal units to 3D units normalized between -1.0 and 1....
Definition: layer_ids.h:71
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:103
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
Definition: pad.h:57
float m_averageViaHoleDiameter
Number of holes in the board.
SHAPE_POLY_SET m_throughHoleOdPolys
Polygon contours for through holes via outer diameters.
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
DRAWINGS & Drawings()
Definition: board.h:237
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:914
TRACKS & Tracks()
Definition: board.h:231
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys
Polygon contours for through hole outer diameters.
unsigned int m_holeCount
Computed average diameter of the holes in 3D units.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
int GetHolePlatingThickness() const noexcept
Get the current copper layer thickness.

References _, CONTAINER_2D_BASE::Add(), addFootprintShapesWithClearance(), addPadsWithClearance(), addShapeWithClearance(), addSolidAreasShapes(), LSET::AllCuMask(), LSET::AllNonCuMask(), arrayDim(), B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, BiuTo3dUnits(), SHAPE_POLY_SET::BooleanSubtract(), BVH_CONTAINER_2D::BuildBVH(), buildPadOutlineAsPolygon(), buildPadOutlineAsSegments(), Cmts_User, createPadWithDrill(), createTrack(), destroyLayers(), BOARD::Drawings(), Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, ERROR_INSIDE, F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, FL_CLIP_SILK_ON_VIA_ANNULUS, FL_RENDER_OPENGL_COPPER_THICKNESS, FL_RENDER_PLATED_PADS_AS_PLATED, FL_USE_REALISTIC_MODE, FL_ZONE, BOARD::Footprints(), Format(), BOARD::GetDesignSettings(), GetFlag(), GetHolePlatingThickness(), GetRunningMicroSecs(), Is3dLayerEnabled(), IsCopperLayer(), BOARD_ITEM::IsOnLayer(), LAYER_CLASS_SILK, m_averageHoleDiameter, m_averageTrackWidth, m_averageViaHoleDiameter, m_backPlatedPadPolys, m_biuTo3Dunits, m_board, m_copperLayersCount, m_frontPlatedPadPolys, m_holeCount, m_layerHoleIdPolys, m_layerHoleMap, m_layerHoleOdPolys, m_layerMap, m_layers_poly, BOARD_DESIGN_SETTINGS::m_LineThickness, m_logTrace, m_nonPlatedThroughHoleOdPolys, m_platedPadsBack, m_platedPadsFront, m_renderEngine, m_throughHoleAnnularRingPolys, m_throughHoleAnnularRings, m_throughHoleIds, m_throughHoleOdPolys, m_throughHoleOds, m_throughHoleViaOdPolys, m_throughHoleViaOds, m_trackCount, m_viaCount, Margin, MAX_CU_LAYERS, NPTH, OPENGL, pad, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_VIA_T, SHAPE_POLY_SET::PM_FAST, REPORTER::Report(), LSET::Seq(), SHAPE_POLY_SET::Simplify(), text, THROUGH, ToLAYER_ID(), BOARD::Tracks(), TransformCircleToPolygon(), transformFPShapesToPolygon(), PCB_TRACK::TransformShapeWithClearanceToPolygon(), ZONE::TransformSolidAreasShapesToPolygon(), EDA_ITEM::Type(), via, and BOARD::Zones().

Referenced by InitSettings().

◆ createPadWithClearance()

void BOARD_ADAPTER::createPadWithClearance ( const PAD aPad,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayer,
const wxSize &  aClearanceValue 
) const
private

Definition at line 308 of file create_3Dgraphic_brd_items.cpp.

311 {
312  SHAPE_POLY_SET poly;
313  wxSize clearance = aClearanceValue;
314 
315  // Our shape-based builder can't handle negative or differing x:y clearance values (the
316  // former are common for solder paste while the later get generated when a relative paste
317  // margin is used with an oblong pad). So we apply this huge hack and fake a larger pad to
318  // run the general-purpose polygon builder on.
319  // Of course being a hack it falls down when dealing with custom shape pads (where the size
320  // is only the size of the anchor), so for those we punt and just use aClearanceValue.x.
321 
322  if( ( clearance.x < 0 || clearance.x != clearance.y )
323  && aPad->GetShape() != PAD_SHAPE::CUSTOM )
324  {
325  wxSize dummySize = aPad->GetSize() + clearance + clearance;
326 
327  if( dummySize.x <= 0 || dummySize.y <= 0 )
328  return;
329 
330  PAD dummy( *aPad );
331  dummy.SetSize( dummySize );
332  dummy.TransformShapeWithClearanceToPolygon( poly, aLayer, 0, ARC_HIGH_DEF, ERROR_INSIDE );
333  clearance = { 0, 0 };
334  }
335  else
336  {
337  auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
338 
339  for( const SHAPE* shape : padShapes->Shapes() )
340  {
341  switch( shape->Type() )
342  {
343  case SH_SEGMENT:
344  {
345  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape;
346  const SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
347  -seg->GetSeg().A.y * m_biuTo3Dunits );
348  const SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
349  -seg->GetSeg().B.y * m_biuTo3Dunits );
350  const double width = seg->GetWidth() + clearance.x * 2;
351 
352  // Cannot add segments that have the same start and end point
353  if( Is_segment_a_circle( start3DU, end3DU ) )
354  {
355  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU,
356  ( width / 2 ) * m_biuTo3Dunits,
357  *aPad ) );
358  }
359  else
360  {
361  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU,
362  width * m_biuTo3Dunits,
363  *aPad ) );
364  }
365  }
366  break;
367 
368  case SH_CIRCLE:
369  {
370  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape;
371  const double radius = circle->GetRadius() + clearance.x;
372  const SFVEC2F center( circle->GetCenter().x * m_biuTo3Dunits,
373  -circle->GetCenter().y * m_biuTo3Dunits );
374 
375  aDstContainer->Add( new FILLED_CIRCLE_2D( center, radius * m_biuTo3Dunits,
376  *aPad ) );
377  }
378  break;
379 
380  case SH_RECT:
381  {
382  SHAPE_RECT* rect = (SHAPE_RECT*) shape;
383 
384  poly.NewOutline();
385  poly.Append( rect->GetPosition() );
386  poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y );
387  poly.Append( rect->GetPosition() + rect->GetSize() );
388  poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y );
389  }
390  break;
391 
392  case SH_SIMPLE:
393  poly.AddOutline( static_cast<const SHAPE_SIMPLE*>( shape )->Vertices() );
394  break;
395 
396  case SH_POLY_SET:
397  poly = *(SHAPE_POLY_SET*) shape;
398  break;
399 
400  case SH_ARC:
401  {
402  SHAPE_ARC* arc = (SHAPE_ARC*) shape;
404 
405  for( int i = 0; i < l.SegmentCount(); i++ )
406  {
407  SHAPE_SEGMENT seg( l.Segment( i ).A, l.Segment( i ).B, arc->GetWidth() );
408  const SFVEC2F start3DU( seg.GetSeg().A.x * m_biuTo3Dunits,
409  -seg.GetSeg().A.y * m_biuTo3Dunits );
410  const SFVEC2F end3DU( seg.GetSeg().B.x * m_biuTo3Dunits,
411  -seg.GetSeg().B.y * m_biuTo3Dunits );
412  const double width = arc->GetWidth() + clearance.x * 2;
413 
414  // Cannot add segments that have the same start and end point
415  if( Is_segment_a_circle( start3DU, end3DU ) )
416  {
417  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU,
418  ( width / 2 ) * m_biuTo3Dunits,
419  *aPad ) );
420  }
421  else
422  {
423  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU,
424  width * m_biuTo3Dunits,
425  *aPad ) );
426  }
427  }
428  }
429  break;
430 
431  default:
432  wxFAIL_MSG( wxT( "BOARD_ADAPTER::createPadWithClearance no implementation for " )
433  + SHAPE_TYPE_asString( shape->Type() ) );
434  break;
435  }
436  }
437  }
438 
439  if( !poly.IsEmpty() )
440  {
441  if( clearance.x )
442  poly.Inflate( clearance.x, 32 );
443 
444  // Add the PAD polygon
445  ConvertPolygonToTriangles( poly, *aDstContainer, m_biuTo3Dunits, *aPad );
446  }
447 }
void ConvertPolygonToTriangles(SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
int GetRadius() const
Definition: shape_circle.h:107
bool IsEmpty() const
const VECTOR2I GetCenter() const
Definition: shape_circle.h:112
const SEG & GetSeg() const
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
const VECTOR2I GetSize() const
Definition: shape_rect.h:124
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pad.cpp:309
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
Represent a set of closed polygons.
const VECTOR2I & GetPosition() const
Definition: shape_rect.h:116
const wxSize & GetSize() const
Definition: pad.h:233
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
PAD_SHAPE GetShape() const
Definition: pad.h:170
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
Definition: shape.h:55
circular arc
Definition: shape.h:50
An abstract shape on 2D plane.
Definition: shape.h:116
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Check if segment start and end is very close to each other.
int NewOutline()
Creates a new hole in a given outline.
int SegmentCount() const
Return the number of segments in this line chain.
circle
Definition: shape.h:46
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
SEG Segment(int aIndex)
Return a copy of the aIndex-th segment in the line chain.
int GetWidth() const
Definition: shape_arc.h:156
set of polygons (with holes, etc.)
Definition: shape.h:48
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:458
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
VECTOR2I A
Definition: seg.h:48
axis-aligned rectangle
Definition: shape.h:43
Definition: pad.h:57
int GetWidth() const
simple polygon
Definition: shape.h:47
line segment
Definition: shape.h:44
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
VECTOR2I B
Definition: seg.h:49

References SEG::A, CONTAINER_2D_BASE::Add(), SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::Append(), SEG::B, ConvertPolygonToTriangles(), SHAPE_ARC::ConvertToPolyline(), CUSTOM, dummy(), ERROR_INSIDE, SHAPE_CIRCLE::GetCenter(), PAD::GetEffectiveShape(), SHAPE_RECT::GetPosition(), SHAPE_CIRCLE::GetRadius(), SHAPE_SEGMENT::GetSeg(), PAD::GetShape(), SHAPE_RECT::GetSize(), PAD::GetSize(), SHAPE_SEGMENT::GetWidth(), SHAPE_ARC::GetWidth(), SHAPE_POLY_SET::Inflate(), Is_segment_a_circle(), SHAPE_POLY_SET::IsEmpty(), m_biuTo3Dunits, SHAPE_POLY_SET::NewOutline(), SHAPE_LINE_CHAIN::Segment(), SHAPE_LINE_CHAIN::SegmentCount(), SH_ARC, SH_CIRCLE, SH_POLY_SET, SH_RECT, SH_SEGMENT, SH_SIMPLE, SHAPE_TYPE_asString(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by addPadsWithClearance().

◆ createPadWithDrill()

OBJECT_2D * BOARD_ADAPTER::createPadWithDrill ( const PAD aPad,
int  aInflateValue 
)
private

Definition at line 450 of file create_3Dgraphic_brd_items.cpp.

451 {
452  wxSize drillSize = aPad->GetDrillSize();
453 
454  if( !drillSize.x || !drillSize.y )
455  {
456  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createPadWithDrill - found an invalid pad" ) );
457  return nullptr;
458  }
459 
460  if( drillSize.x == drillSize.y ) // usual round hole
461  {
462  const double radius = ( drillSize.x / 2.0 ) + aInflateValue;
463 
464  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
465  -aPad->GetPosition().y * m_biuTo3Dunits );
466 
467  return new FILLED_CIRCLE_2D( center, radius * m_biuTo3Dunits, *aPad );
468 
469  }
470  else // Oblong hole
471  {
472  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
473  double width = seg->GetWidth() + aInflateValue * 2;
474 
475  SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
476  -seg->GetSeg().A.y * m_biuTo3Dunits );
477 
478  SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
479  -seg->GetSeg().B.y * m_biuTo3Dunits );
480 
481  return new ROUND_SEGMENT_2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
482  }
483 
484  return nullptr;
485 }
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Return a SHAPE object representing the pad's hole.
Definition: pad.cpp:336
const SEG & GetSeg() const
const wxSize & GetDrillSize() const
Definition: pad.h:243
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
wxPoint GetPosition() const override
Definition: pad.h:178
VECTOR2I A
Definition: seg.h:48
int GetWidth() const
VECTOR2I B
Definition: seg.h:49

References SEG::A, SEG::B, PAD::GetDrillSize(), PAD::GetEffectiveHoleShape(), PAD::GetPosition(), SHAPE_SEGMENT::GetSeg(), SHAPE_SEGMENT::GetWidth(), m_biuTo3Dunits, m_logTrace, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers().

◆ createTrack()

void BOARD_ADAPTER::createTrack ( const PCB_TRACK aTrack,
CONTAINER_2D_BASE aDstContainer,
int  aClearanceValue 
)
private

Definition at line 229 of file create_3Dgraphic_brd_items.cpp.

231 {
232  SFVEC2F start3DU( aTrack->GetStart().x * m_biuTo3Dunits,
233  -aTrack->GetStart().y * m_biuTo3Dunits ); // y coord is inverted
234 
235  switch( aTrack->Type() )
236  {
237  case PCB_VIA_T:
238  {
239  const float radius = ( ( aTrack->GetWidth() / 2 ) + aClearanceValue ) * m_biuTo3Dunits;
240  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius, *aTrack ) );
241  break;
242  }
243 
244  case PCB_ARC_T:
245  {
246  const PCB_ARC* arc = static_cast<const PCB_ARC*>( aTrack );
247  VECTOR2D center( arc->GetCenter() );
248  double arc_angle = arc->GetAngle();
249  double radius = arc->GetRadius();
250  int arcsegcount = GetArcToSegmentCount( radius, Millimeter2iu( 0.005), arc_angle/10 );
251  int circlesegcount;
252 
253  // We need a circle to segment count. However, the arc angle can be small, and the
254  // radius very big. so we calculate a reasonable value for circlesegcount.
255  if( arcsegcount <= 1 ) // The arc will be approximated by a segment
256  circlesegcount = 1;
257  else
258  {
259  double cnt = arcsegcount * 3600/std::abs( arc_angle );
260 
261 #define SEG_CNT_MAX 128
262  if( cnt < SEG_CNT_MAX )
263  {
264  circlesegcount = (int)cnt;
265 
266  if( circlesegcount == 0 )
267  circlesegcount = 1;
268  }
269  else
270  {
271  circlesegcount = SEG_CNT_MAX;
272  }
273  }
274 
275  transformArcToSegments( wxPoint( center.x, center.y ), arc->GetStart(),
276  arc_angle, circlesegcount,
277  arc->GetWidth() + 2 * aClearanceValue, aDstContainer, *arc );
278  break;
279  }
280 
281  case PCB_TRACE_T: // Track is a usual straight segment
282  {
283  SFVEC2F end3DU( aTrack->GetEnd().x * m_biuTo3Dunits, -aTrack->GetEnd().y * m_biuTo3Dunits );
284 
285  // Cannot add segments that have the same start and end point
286  if( Is_segment_a_circle( start3DU, end3DU ) )
287  {
288  const float radius = ((aTrack->GetWidth() / 2) + aClearanceValue) * m_biuTo3Dunits;
289 
290  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius, *aTrack ) );
291  }
292  else
293  {
294  const float width = (aTrack->GetWidth() + 2 * aClearanceValue ) * m_biuTo3Dunits;
295 
296  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, width, *aTrack ) );
297  }
298 
299  break;
300  }
301 
302  default:
303  break;
304  }
305 }
virtual wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_track.h:281
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
#define SEG_CNT_MAX
void transformArcToSegments(const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM &aBoardItem)
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
int GetWidth() const
Definition: pcb_track.h:102
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
double GetRadius() const
Definition: pcb_track.cpp:946
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Check if segment start and end is very close to each other.
double GetAngle() const
Definition: pcb_track.cpp:952
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
static constexpr int Millimeter2iu(double mm)
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
const wxPoint & GetStart() const
Definition: pcb_track.h:108
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References CONTAINER_2D_BASE::Add(), PCB_ARC::GetAngle(), GetArcToSegmentCount(), PCB_ARC::GetCenter(), PCB_TRACK::GetEnd(), PCB_ARC::GetRadius(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), Is_segment_a_circle(), m_biuTo3Dunits, Millimeter2iu(), PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, SEG_CNT_MAX, transformArcToSegments(), and EDA_ITEM::Type().

Referenced by createLayers().

◆ destroyLayers()

void BOARD_ADAPTER::destroyLayers ( )
private

Definition at line 60 of file create_layer_items.cpp.

61 {
62  if( !m_layers_poly.empty() )
63  {
64  for( auto& poly : m_layers_poly )
65  delete poly.second;
66 
67  m_layers_poly.clear();
68  }
69 
70  delete m_frontPlatedPadPolys;
71  m_frontPlatedPadPolys = nullptr;
72 
73  delete m_backPlatedPadPolys;
74  m_backPlatedPadPolys = nullptr;
75 
76  if( !m_layerHoleIdPolys.empty() )
77  {
78  for( auto& poly : m_layerHoleIdPolys )
79  delete poly.second;
80 
81  m_layerHoleIdPolys.clear();
82  }
83 
84  if( !m_layerHoleOdPolys.empty() )
85  {
86  for( auto& poly : m_layerHoleOdPolys )
87  delete poly.second;
88 
89  m_layerHoleOdPolys.clear();
90  }
91 
92  if( !m_layerMap.empty() )
93  {
94  for( auto& poly : m_layerMap )
95  delete poly.second;
96 
97  m_layerMap.clear();
98  }
99 
100  delete m_platedPadsFront;
101  m_platedPadsFront = nullptr;
102 
103  delete m_platedPadsBack;
104  m_platedPadsBack = nullptr;
105 
106  if( !m_layerHoleMap.empty() )
107  {
108  for( auto& poly : m_layerHoleMap )
109  delete poly.second;
110 
111  m_layerHoleMap.clear();
112  }
113 
121 
124 }
BVH_CONTAINER_2D m_throughHoleViaOds
List of through hole via inner diameters.
BVH_CONTAINER_2D * m_platedPadsFront
SHAPE_POLY_SET * m_backPlatedPadPolys
Polygon contours for hole outer diameters for each layer.
BVH_CONTAINER_2D m_throughHoleIds
List of through hole vias with the radius of the hole inflated with the copper thickness.
SHAPE_POLY_SET * m_frontPlatedPadPolys
SHAPE_POLY_SET m_throughHoleAnnularRingPolys
MAP_CONTAINER_2D_BASE m_layerMap
2D elements for each layer.
BVH_CONTAINER_2D m_throughHoleOds
List of plated through hole annular rings.
SHAPE_POLY_SET m_throughHoleViaOdPolys
Polygon contours for through hole via annular rings.
MAP_POLY m_layerHoleIdPolys
Polygon contours for non plated through hole outer diameters.
BVH_CONTAINER_2D * m_platedPadsBack
The holes per each layer.
MAP_POLY m_layerHoleOdPolys
Polygon contours for hole inner diameters for each layer.
MAP_CONTAINER_2D_BASE m_layerHoleMap
List of through holes with the radius of the hole inflated with the copper thickness.
BVH_CONTAINER_2D m_throughHoleAnnularRings
List of through hole inner diameters.
MAP_POLY m_layers_poly
BVH_CONTAINER_2D m_throughHoleViaIds
Number of copper layers actually used by the board.
SHAPE_POLY_SET m_throughHoleOdPolys
Polygon contours for through holes via outer diameters.
void Clear() override
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys
Polygon contours for through hole outer diameters.

References BVH_CONTAINER_2D::Clear(), m_backPlatedPadPolys, m_frontPlatedPadPolys, m_layerHoleIdPolys, m_layerHoleMap, m_layerHoleOdPolys, m_layerMap, m_layers_poly, m_nonPlatedThroughHoleOdPolys, m_platedPadsBack, m_platedPadsFront, m_throughHoleAnnularRingPolys, m_throughHoleAnnularRings, m_throughHoleIds, m_throughHoleOdPolys, m_throughHoleOds, m_throughHoleViaIds, m_throughHoleViaOdPolys, m_throughHoleViaOds, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by createLayers(), and ~BOARD_ADAPTER().

◆ Get3dCacheManager()

S3D_CACHE* BOARD_ADAPTER::Get3dCacheManager ( ) const
inlinenoexcept

Return the 3D cache manager pointer.

Definition at line 88 of file board_adapter.h.

89  {
90  return m_3dModelManager;
91  }
S3D_CACHE * m_3dModelManager

References m_3dModelManager.

Referenced by RENDER_3D_RAYTRACE::load3DModels(), and RENDER_3D_OPENGL::load3dModels().

◆ GetAntiAliasingMode()

ANTIALIASING_MODE BOARD_ADAPTER::GetAntiAliasingMode ( ) const
inline

Get the current antialiasing mode value.

Returns
antialiasing mode value

Definition at line 275 of file board_adapter.h.

275 { return m_antiAliasingMode; }
ANTIALIASING_MODE m_antiAliasingMode

References m_antiAliasingMode.

Referenced by EDA_3D_VIEWER_FRAME::SaveSettings(), and PANEL_3D_OPENGL_OPTIONS::TransferDataToWindow().

◆ GetAverageHoleDiameter()

float BOARD_ADAPTER::GetAverageHoleDiameter ( ) const
inlinenoexcept

Average diameter of through holes.

Returns
the average diameter of through holes in 3D units.

Definition at line 500 of file board_adapter.h.

501  {
502  return m_averageHoleDiameter;
503  }
float m_averageHoleDiameter

References m_averageHoleDiameter.

Referenced by RENDER_3D_RAYTRACE::Reload().

◆ GetAverageTrackWidth()

float BOARD_ADAPTER::GetAverageTrackWidth ( ) const
inlinenoexcept

Average width of the tracks.

Returns
average track width in 3D units.

Definition at line 510 of file board_adapter.h.

511  {
512  return m_averageTrackWidth;
513  }
float m_averageTrackWidth
Number of through hole vias in the board.

References m_averageTrackWidth.

◆ GetAverageViaHoleDiameter()

float BOARD_ADAPTER::GetAverageViaHoleDiameter ( ) const
inlinenoexcept

Thee average diameter of the via holes.

Returns
via hole average diameter dimension in 3D units.

Definition at line 490 of file board_adapter.h.

491  {
493  }
float m_averageViaHoleDiameter
Number of holes in the board.

References m_averageViaHoleDiameter.

Referenced by RENDER_3D_OPENGL::generateViasAndPads(), and RENDER_3D_RAYTRACE::Reload().

◆ GetBackPlatedPadPolys()

const SHAPE_POLY_SET* BOARD_ADAPTER::GetBackPlatedPadPolys ( )
inline

Definition at line 542 of file board_adapter.h.

543  {
544  return m_backPlatedPadPolys;
545  }
SHAPE_POLY_SET * m_backPlatedPadPolys
Polygon contours for hole outer diameters for each layer.

References m_backPlatedPadPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetBBox()

const BBOX_3D& BOARD_ADAPTER::GetBBox ( ) const
inlinenoexcept

Get the board outling bounding box.

Returns
the board bounding box in 3D units.

Definition at line 169 of file board_adapter.h.

170  {
171  return m_boardBoundingBox;
172  }
BBOX_3D m_boardBoundingBox
3D bounding box of the board in 3D units.

References m_boardBoundingBox.

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position(), and RENDER_3D_RAYTRACE::Reload().

◆ GetBoard()

const BOARD* BOARD_ADAPTER::GetBoard ( ) const
inlinenoexcept

◆ GetBoardCenter()

const SFVEC3F& BOARD_ADAPTER::GetBoardCenter ( ) const
inlinenoexcept

The board center position in 3D units.

Returns
board center vector position in 3D units.

Definition at line 236 of file board_adapter.h.

237  {
238  return m_boardCenter;
239  }
SFVEC3F m_boardCenter
3D center position of the board in 3D units.

References m_boardCenter.

Referenced by RENDER_3D_RAYTRACE::Reload(), and RENDER_3D_OPENGL::reload().

◆ GetBoardPoly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetBoardPoly ( ) const
inlinenoexcept

Get the current polygon of the epoxy board.

Returns
the shape polygon

Definition at line 321 of file board_adapter.h.

322  {
323  return m_board_poly;
324  }
SHAPE_POLY_SET m_board_poly
Board outline polygon.

References m_board_poly.

Referenced by RENDER_3D_RAYTRACE::Reload(), and RENDER_3D_OPENGL::reload().

◆ GetBoardPos()

wxPoint BOARD_ADAPTER::GetBoardPos ( ) const
inlinenoexcept

Get the board center.

Returns
position in BIU units.

Definition at line 226 of file board_adapter.h.

227  {
228  return m_boardPos;
229  }
wxPoint m_boardPos
Board center position in board internal units.

References m_boardPos.

Referenced by RENDER_3D_OPENGL::generate3dGrid().

◆ GetBoardSize()

wxSize BOARD_ADAPTER::GetBoardSize ( ) const
inlinenoexcept

Get the board size.

Returns
size in BIU units.

Definition at line 216 of file board_adapter.h.

217  {
218  return m_boardSize;
219  }
wxSize m_boardSize
Board size in board internal units.

References m_boardSize.

Referenced by RENDER_3D_OPENGL::generate3dGrid().

◆ GetCircleSegmentCount() [1/2]

unsigned int BOARD_ADAPTER::GetCircleSegmentCount ( float  aDiameter3DU) const
Parameters
aDiameter3DUdiameter in 3DU.
Returns
number of sides that should be used in a circle with aDiameter3DU.

Definition at line 339 of file board_adapter.cpp.

340 {
341  wxASSERT( aDiameter3DU > 0.0f );
342 
343  return GetCircleSegmentCount( (int)( aDiameter3DU / m_biuTo3Dunits ) );
344 }
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
unsigned int GetCircleSegmentCount(float aDiameter3DU) const

References m_biuTo3Dunits.

Referenced by RENDER_3D_OPENGL::addObjectTriangles(), addShapeWithClearance(), and RENDER_3D_OPENGL::generateViasAndPads().

◆ GetCircleSegmentCount() [2/2]

unsigned int BOARD_ADAPTER::GetCircleSegmentCount ( int  aDiameterBIU) const
Parameters
aDiameterBIUdiameter in board internal units.
Returns
number of sides that should be used in circle with aDiameterBIU.

Definition at line 347 of file board_adapter.cpp.

348 {
349  wxASSERT( aDiameterBIU > 0 );
350 
351  return GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, 360.0 );
352 }
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)

References GetArcToSegmentCount().

◆ GetColor()

SFVEC4F BOARD_ADAPTER::GetColor ( const COLOR4D aColor) const
Parameters
[in]aColoris the color mapped.
Returns
the color in SFVEC3F format

Definition at line 779 of file board_adapter.cpp.

780 {
781  return SFVEC4F( aColor.r, aColor.g, aColor.b, aColor.a );
782 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
double a
Alpha component.
Definition: color4d.h:387
double r
Red component.
Definition: color4d.h:384

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, and KIGFX::COLOR4D::r.

Referenced by RENDER_3D_OPENGL::generate3dGrid(), GetItemColor(), and EDA_3D_VIEWER_FRAME::LoadSettings().

◆ GetCopperThickness()

float BOARD_ADAPTER::GetCopperThickness ( ) const
inlinenoexcept

Get the current copper layer thickness.

Returns
thickness in 3D units of copper layers.

Definition at line 199 of file board_adapter.h.

200  {
201  return m_copperThickness3DU;
202  }
float m_copperThickness3DU
Epoxy thickness in 3D units.

References m_copperThickness3DU.

Referenced by RENDER_3D_RAYTRACE::insertHole(), and RENDER_3D_RAYTRACE::Reload().

◆ GetEpoxyThickness()

float BOARD_ADAPTER::GetEpoxyThickness ( ) const
inlinenoexcept

Get the current epoxy thickness.

Returns
epoxy thickness in 3D units.

Definition at line 179 of file board_adapter.h.

180  {
181  return m_epoxyThickness3DU;
182  }
float m_epoxyThickness3DU
Non copper layers thickness in 3D units.

References m_epoxyThickness3DU.

Referenced by RENDER_3D_OPENGL::renderBoardBody().

◆ GetFlag()

bool BOARD_ADAPTER::GetFlag ( DISPLAY3D_FLG  aFlag) const

Get a configuration status of a flag.

Parameters
aFlagthe flag to get the status.
Returns
true if flag is set, false if not.

Definition at line 297 of file board_adapter.cpp.

298 {
299  wxASSERT( aFlag < FL_LAST );
300 
301  return m_drawFlags[aFlag];
302 }
std::vector< bool > m_drawFlags

References FL_LAST, and m_drawFlags.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), createLayers(), EDA_3D_CONDITIONS::flagFunction(), RENDER_3D_OPENGL::generateViasAndPads(), GetFootprintZPos(), RENDER_3D_OPENGL::getLayerColor(), RENDER_3D_RAYTRACE::getModelMaterial(), InitSettings(), RENDER_3D_RAYTRACE::insertHole(), Is3dLayerEnabled(), IsFootprintShown(), RENDER_3D_RAYTRACE::load3DModels(), RENDER_3D_OPENGL::load3dModels(), EDA_3D_CANVAS::OnMouseWheel(), RENDER_3D_RAYTRACE::postProcessBlurFinish(), RENDER_3D_RAYTRACE::postProcessShading(), RENDER_3D_OPENGL::Redraw(), RENDER_3D_RAYTRACE::Reload(), RENDER_3D_OPENGL::reload(), RENDER_3D_OPENGL::render3dModels(), RENDER_3D_OPENGL::render3dModelsSelected(), RENDER_3D_RAYTRACE::renderAntiAliasPackets(), RENDER_3D_RAYTRACE::renderBlockTracing(), RENDER_3D_OPENGL::renderFootprint(), RENDER_3D_RAYTRACE::renderTracing(), RENDER_3D_OPENGL::setLayerMaterial(), RENDER_3D_RAYTRACE::setupMaterials(), RENDER_3D_OPENGL::setupMaterials(), RENDER_3D_RAYTRACE::shadeHit(), EDA_3D_CONTROLLER::ToggleVisibility(), PANEL_3D_OPENGL_OPTIONS::TransferDataToWindow(), PANEL_3D_RAYTRACING_OPTIONS::TransferDataToWindow(), and PANEL_3D_DISPLAY_OPTIONS::TransferDataToWindow().

◆ GetFootprintZPos()

float BOARD_ADAPTER::GetFootprintZPos ( bool  aIsFlipped) const

Get the position of the footprint in 3d integer units considering if it is flipped or not.

Parameters
aIsFlippedtrue for use in footprints on Front (top) layer, false if footprint is on back (bottom) layer.
Returns
the Z position of 3D shapes, in 3D integer units.

Definition at line 744 of file board_adapter.cpp.

745 {
746  if( aIsFlipped )
747  {
748  if( GetFlag( FL_SOLDERPASTE ) )
750  else
752  }
753  else
754  {
755  if( GetFlag( FL_SOLDERPASTE ) )
756  return m_layerZcoordTop[F_SilkS];
757  else
758  return m_layerZcoordTop[F_Paste];
759  }
760 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Copper thickness in 3D units.
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Bottom (Start) Z position of each layer in 3D units.

References B_Paste, B_SilkS, F_Paste, F_SilkS, FL_SOLDERPASTE, GetFlag(), m_layerZcoordBottom, and m_layerZcoordTop.

Referenced by RENDER_3D_RAYTRACE::load3DModels(), and RENDER_3D_OPENGL::renderFootprint().

◆ GetFrontPlatedPadPolys()

const SHAPE_POLY_SET* BOARD_ADAPTER::GetFrontPlatedPadPolys ( )
inline

Definition at line 537 of file board_adapter.h.

538  {
539  return m_frontPlatedPadPolys;
540  }
SHAPE_POLY_SET * m_frontPlatedPadPolys

References m_frontPlatedPadPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetGridType()

GRID3D_TYPE BOARD_ADAPTER::GetGridType ( ) const
inlinenoexcept

Get the current grid.

Returns
space type of the grid.

Definition at line 255 of file board_adapter.h.

256  {
257  return m_gridType;
258  }
GRID3D_TYPE m_gridType

References m_gridType.

Referenced by EDA_3D_CONDITIONS::gridSizeFunction(), RENDER_3D_OPENGL::Redraw(), and EDA_3D_VIEWER_FRAME::SaveSettings().

◆ GetHoleCount()

unsigned int BOARD_ADAPTER::GetHoleCount ( ) const
inlinenoexcept

Get number of holes in this board.

Returns
number of holes.

Definition at line 480 of file board_adapter.h.

481  {
482  return m_holeCount;
483  }
unsigned int m_holeCount
Computed average diameter of the holes in 3D units.

References m_holeCount.

Referenced by RENDER_3D_OPENGL::generateViasAndPads(), and RENDER_3D_RAYTRACE::Reload().

◆ GetHoleIdPolysMap()

const MAP_POLY& BOARD_ADAPTER::GetHoleIdPolysMap ( ) const
inlinenoexcept

Definition at line 547 of file board_adapter.h.

548  {
549  return m_layerHoleIdPolys;
550  }
MAP_POLY m_layerHoleIdPolys
Polygon contours for non plated through hole outer diameters.

References m_layerHoleIdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetHoleOdPolysMap()

const MAP_POLY& BOARD_ADAPTER::GetHoleOdPolysMap ( ) const
inlinenoexcept

Definition at line 552 of file board_adapter.h.

553  {
554  return m_layerHoleOdPolys;
555  }
MAP_POLY m_layerHoleOdPolys
Polygon contours for hole inner diameters for each layer.

References m_layerHoleOdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetHolePlatingThickness()

int BOARD_ADAPTER::GetHolePlatingThickness ( ) const
noexcept

Get the current copper layer thickness.

Returns
thickness in board units.

Definition at line 332 of file board_adapter.cpp.

333 {
335  : 0.035 * PCB_IU_PER_MM;
336 }
int GetHolePlatingThickness() const
Pad & via drills are finish size.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
constexpr double PCB_IU_PER_MM

References BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetHolePlatingThickness(), m_board, and PCB_IU_PER_MM.

Referenced by createLayers(), RENDER_3D_OPENGL::generateViasAndPads(), and RENDER_3D_RAYTRACE::insertHole().

◆ GetItemColor()

SFVEC4F BOARD_ADAPTER::GetItemColor ( int  aItemId) const

Get the technical color of a layer.

Parameters
aItemIdthe item id to get the color information.
Returns
the color in SFVEC3F format.

Definition at line 773 of file board_adapter.cpp.

774 {
775  return GetColor( m_colors->GetColor( aItemId ) );
776 }
SFVEC4F GetColor(const COLOR4D &aColor) const
COLOR_SETTINGS * m_colors
COLOR4D GetColor(int aLayer) const

References COLOR_SETTINGS::GetColor(), GetColor(), and m_colors.

Referenced by RENDER_3D_RAYTRACE::insertHole().

◆ GetLayerBottomZPos()

float BOARD_ADAPTER::GetLayerBottomZPos ( PCB_LAYER_ID  aLayerId) const
inlinenoexcept

Get the bottom z position.

Parameters
aLayerIdlayer id.
Returns
position in 3D units.

Definition at line 365 of file board_adapter.h.

366  {
367  return m_layerZcoordBottom[aLayerId];
368  }
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Copper thickness in 3D units.

References m_layerZcoordBottom.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_OPENGL::getLayerZPos(), RENDER_3D_RAYTRACE::insertHole(), RENDER_3D_OPENGL::Redraw(), and RENDER_3D_RAYTRACE::Reload().

◆ GetLayerColor()

SFVEC4F BOARD_ADAPTER::GetLayerColor ( PCB_LAYER_ID  aLayerId) const

Get the technical color of a layer.

Parameters
aLayerIdthe layer to get the color information.
Returns
the color in SFVEC3F format.

Definition at line 763 of file board_adapter.cpp.

764 {
765  wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
766 
767  const COLOR4D color = m_colors->GetColor( aLayerId );
768 
769  return SFVEC4F( color.r, color.g, color.b, color.a );
770 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46
COLOR_SETTINGS * m_colors
int color
Definition: DXF_plotter.cpp:57
COLOR4D GetColor(int aLayer) const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color, COLOR_SETTINGS::GetColor(), m_colors, and PCB_LAYER_ID_COUNT.

Referenced by RENDER_3D_OPENGL::getLayerColor(), and RENDER_3D_RAYTRACE::Reload().

◆ GetLayerHoleMap()

const MAP_CONTAINER_2D_BASE& BOARD_ADAPTER::GetLayerHoleMap ( ) const
inlinenoexcept

Get the map of container that have the holes per layer.

Returns
the map containers of holes from this board.

Definition at line 395 of file board_adapter.h.

396  {
397  return m_layerHoleMap;
398  }
MAP_CONTAINER_2D_BASE m_layerHoleMap
List of through holes with the radius of the hole inflated with the copper thickness.

References m_layerHoleMap.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), and RENDER_3D_OPENGL::reload().

◆ GetLayerMap()

const MAP_CONTAINER_2D_BASE& BOARD_ADAPTER::GetLayerMap ( ) const
inlinenoexcept

Get the map of containers that have the objects per layer.

Returns
the map containers of this board.

Definition at line 375 of file board_adapter.h.

376  {
377  return m_layerMap;
378  }
MAP_CONTAINER_2D_BASE m_layerMap
2D elements for each layer.

References m_layerMap.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_RAYTRACE::Reload(), and RENDER_3D_OPENGL::reload().

◆ GetLayerTopZPos()

float BOARD_ADAPTER::GetLayerTopZPos ( PCB_LAYER_ID  aLayerId) const
inlinenoexcept

Get the top z position.

Parameters
aLayerIdlayer id.
Returns
position in 3D units.

Definition at line 354 of file board_adapter.h.

355  {
356  return m_layerZcoordTop[aLayerId];
357  }
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Bottom (Start) Z position of each layer in 3D units.

References m_layerZcoordTop.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_OPENGL::getLayerZPos(), RENDER_3D_OPENGL::Redraw(), and RENDER_3D_RAYTRACE::Reload().

◆ GetMaterialMode()

MATERIAL_MODE BOARD_ADAPTER::GetMaterialMode ( ) const
inlinenoexcept

◆ GetNonCopperLayerThickness()

float BOARD_ADAPTER::GetNonCopperLayerThickness ( ) const
inlinenoexcept

Get the current non copper layers thickness.

Returns
thickness in 3D units of non copper layers.

Definition at line 189 of file board_adapter.h.

190  {
192  }
float m_nonCopperLayerThickness3DU
solder paste layers thickness in 3D units.

References m_nonCopperLayerThickness3DU.

Referenced by RENDER_3D_OPENGL::renderSolderMaskLayer(), and RENDER_3D_RAYTRACE::shadeHit().

◆ GetOuterNonPlatedThroughHolePoly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetOuterNonPlatedThroughHolePoly ( ) const
inlinenoexcept

Definition at line 437 of file board_adapter.h.

438  {
440  }
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys
Polygon contours for through hole outer diameters.

References m_nonPlatedThroughHoleOdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetPlatedPadsBack()

const BVH_CONTAINER_2D* BOARD_ADAPTER::GetPlatedPadsBack ( ) const
inlinenoexcept

Definition at line 385 of file board_adapter.h.

386  {
387  return m_platedPadsBack;
388  }
BVH_CONTAINER_2D * m_platedPadsBack
The holes per each layer.

References m_platedPadsBack.

Referenced by RENDER_3D_RAYTRACE::Reload(), and RENDER_3D_OPENGL::reload().

◆ GetPlatedPadsFront()

const BVH_CONTAINER_2D* BOARD_ADAPTER::GetPlatedPadsFront ( ) const
inlinenoexcept

Definition at line 380 of file board_adapter.h.

381  {
382  return m_platedPadsFront;
383  }
BVH_CONTAINER_2D * m_platedPadsFront

References m_platedPadsFront.

Referenced by RENDER_3D_RAYTRACE::Reload(), and RENDER_3D_OPENGL::reload().

◆ GetPolyMap()

const MAP_POLY& BOARD_ADAPTER::GetPolyMap ( ) const
inlinenoexcept

Get map of polygon's layers.

Returns
the map with polygon's layers.

Definition at line 532 of file board_adapter.h.

533  {
534  return m_layers_poly;
535  }
MAP_POLY m_layers_poly

References m_layers_poly.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetRenderEngine()

◆ GetThroughHoleAnnularRingPolys()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHoleAnnularRingPolys ( ) const
inlinenoexcept

Definition at line 432 of file board_adapter.h.

433  {
435  }
SHAPE_POLY_SET m_throughHoleAnnularRingPolys

References m_throughHoleAnnularRingPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetThroughHoleAnnularRings()

const BVH_CONTAINER_2D& BOARD_ADAPTER::GetThroughHoleAnnularRings ( ) const
inlinenoexcept

Get the through hole annular rings container.

Returns
a container with through hole annular rings.

Definition at line 415 of file board_adapter.h.

416  {
418  }
BVH_CONTAINER_2D m_throughHoleAnnularRings
List of through hole inner diameters.

References m_throughHoleAnnularRings.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), and RENDER_3D_OPENGL::reload().

◆ GetThroughHoleIds()

const BVH_CONTAINER_2D& BOARD_ADAPTER::GetThroughHoleIds ( ) const
inlinenoexcept

Get the through hole inner diameter container.

Returns
a container with holes inner diameters.

Definition at line 460 of file board_adapter.h.

461  {
462  return m_throughHoleIds;
463  }
BVH_CONTAINER_2D m_throughHoleIds
List of through hole vias with the radius of the hole inflated with the copper thickness.

References m_throughHoleIds.

Referenced by RENDER_3D_RAYTRACE::insertHole(), and RENDER_3D_OPENGL::reload().

◆ GetThroughHoleOdPolys()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHoleOdPolys ( ) const
inlinenoexcept

Get through hole outside diameter 2D polygons.

The outside diameter 2D polygon is the hole diameter plus the plating thickness.

Returns
a container with through hold outside diameter 2D polygons.

Definition at line 427 of file board_adapter.h.

428  {
429  return m_throughHoleOdPolys;
430  }
SHAPE_POLY_SET m_throughHoleOdPolys
Polygon contours for through holes via outer diameters.

References m_throughHoleOdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetThroughHoleOds()

const BVH_CONTAINER_2D& BOARD_ADAPTER::GetThroughHoleOds ( ) const
inlinenoexcept

Get the inflated through hole outside diameters container.

Returns
a container with holes.

Definition at line 405 of file board_adapter.h.

406  {
407  return m_throughHoleOds;
408  }
BVH_CONTAINER_2D m_throughHoleOds
List of plated through hole annular rings.

References m_throughHoleOds.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_RAYTRACE::Reload(), and RENDER_3D_OPENGL::reload().

◆ GetThroughHoleViaOdPolys()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHoleViaOdPolys ( ) const
inlinenoexcept

Definition at line 450 of file board_adapter.h.

451  {
453  }
SHAPE_POLY_SET m_throughHoleViaOdPolys
Polygon contours for through hole via annular rings.

References m_throughHoleViaOdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetThroughHoleViaOds()

const BVH_CONTAINER_2D& BOARD_ADAPTER::GetThroughHoleViaOds ( ) const
inlinenoexcept
Returns
a container with through hole via hole outside diameters.

Definition at line 445 of file board_adapter.h.

446  {
447  return m_throughHoleViaOds;
448  }
BVH_CONTAINER_2D m_throughHoleViaOds
List of through hole via inner diameters.

References m_throughHoleViaOds.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetViaCount()

unsigned int BOARD_ADAPTER::GetViaCount ( ) const
inlinenoexcept

Get number of vias in this board.

Returns
number of vias.

Definition at line 470 of file board_adapter.h.

471  {
472  return m_viaCount;
473  }
unsigned int m_viaCount
Computed average diameter of the via holes in 3D units.

References m_viaCount.

Referenced by RENDER_3D_OPENGL::generateViasAndPads(), and RENDER_3D_RAYTRACE::Reload().

◆ InitSettings()

void BOARD_ADAPTER::InitSettings ( REPORTER aStatusReporter,
REPORTER aWarningReporter 
)

Function to be called by the render when it need to reload the settings for the board.

Parameters
aStatusReporterthe pointer for the status reporter.
aWarningReporterpointer for the warning reporter.

Definition at line 355 of file board_adapter.cpp.

356 {
357  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) );
358 
359  if( aStatusReporter )
360  aStatusReporter->Report( _( "Build board outline" ) );
361 
362  wxString msg;
363 
364  const bool succeedToGetBoardPolygon = createBoardPolygon( &msg );
365 
366  if( aWarningReporter )
367  {
368  if( !succeedToGetBoardPolygon )
369  aWarningReporter->Report( msg, RPT_SEVERITY_WARNING );
370  else
371  aWarningReporter->Report( wxEmptyString );
372  }
373 
374  // Calculates the board bounding box (board outlines + items)
375  // to ensure any item, even outside the board outlines can be seen
376  bool boardEdgesOnly = true;
377 
379  || !succeedToGetBoardPolygon )
380  {
381  boardEdgesOnly = false;
382  }
383 
384  EDA_RECT bbbox;
385 
386  if( m_board )
387  bbbox = m_board->ComputeBoundingBox( boardEdgesOnly );
388 
389  // Gives a non null size to avoid issues in zoom / scale calculations
390  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
391  bbbox.Inflate( Millimeter2iu( 10 ) );
392 
393  m_boardSize = bbbox.GetSize();
394  m_boardPos = bbbox.Centre();
395 
396  wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
397 
398  m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
399 
401 
402  // Ensure the board has 2 sides for 3D views, because it is hard to find
403  // a *really* single side board in the true life...
404  if( m_copperLayersCount < 2 )
406 
407  // Calculate the conversion to apply to all positions.
409 
412  : 1.6 * PCB_IU_PER_MM * m_biuTo3Dunits;
413 
414  // !TODO: use value defined by user (currently use default values by ctor
418 
419  // Init Z position of each layer
420  // calculate z position for each copper layer
421  // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
422  // Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
423  // all unused copper layer z position are set to 0
424 
425  // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
426  // | | Top = Bottom + m_copperThickness
427  // |__________________________________|
428  // == == == == <- Bottom = -m_epoxyThickness / 2.0,
429  // Top = Bottom - m_copperThickness
430 
431  unsigned int layer;
432 
433  for( layer = 0; layer < m_copperLayersCount; ++layer )
434  {
435  m_layerZcoordBottom[layer] = m_epoxyThickness3DU / 2.0f -
436  (m_epoxyThickness3DU * layer / (m_copperLayersCount - 1) );
437 
438  if( layer < (m_copperLayersCount / 2) )
440  else
442  }
443 
444  #define layerThicknessMargin 1.1
445  const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
446 
447  // Fill remaining unused copper layers and back layer zpos
448  // with -m_epoxyThickness / 2.0
449  for( ; layer < MAX_CU_LAYERS; layer++ )
450  {
451  m_layerZcoordBottom[layer] = -(m_epoxyThickness3DU / 2.0f);
453  }
454 
455  // This is the top of the copper layer thickness.
456  const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
457  const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
458 
459  // calculate z position for each non copper layer
460  // Solder mask and Solder paste have the same Z position
461  for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
462  {
463  float zposTop;
464  float zposBottom;
465 
466  switch( layer_id )
467  {
468  case B_Adhes:
469  zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
470  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
471  break;
472 
473  case F_Adhes:
474  zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
475  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
476  break;
477 
478  case B_Mask:
479  zposBottom = zpos_copperTop_back;
480  zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
481  break;
482 
483  case B_Paste:
484  zposBottom = zpos_copperTop_back;
485  zposTop = zpos_copperTop_back - m_solderPasteLayerThickness3DU;
486  break;
487 
488  case F_Mask:
489  zposBottom = zpos_copperTop_front;
490  zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
491  break;
492 
493  case F_Paste:
494  zposBottom = zpos_copperTop_front;
495  zposTop = zpos_copperTop_front + m_solderPasteLayerThickness3DU;
496  break;
497 
498  case B_SilkS:
499  zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
500  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
501  break;
502 
503  case F_SilkS:
504  zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
505  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
506  break;
507 
508  // !TODO: review
509  default:
510  zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
511  zposBottom = zposTop - m_nonCopperLayerThickness3DU;
512  break;
513  }
514 
515  m_layerZcoordTop[layer_id] = zposTop;
516  m_layerZcoordBottom[layer_id] = zposBottom;
517  }
518 
520 
522  0.0f );
523  boardSize /= 2.0f;
524 
525  SFVEC3F boardMin = ( m_boardCenter - boardSize );
526  SFVEC3F boardMax = ( m_boardCenter + boardSize );
527 
528  boardMin.z = m_layerZcoordTop[B_Adhes];
529  boardMax.z = m_layerZcoordTop[F_Adhes];
530 
531  m_boardBoundingBox = BBOX_3D( boardMin, boardMax );
532 
533 #ifdef PRINT_STATISTICS_3D_VIEWER
534  unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
535 #endif
536 
537  if( aStatusReporter )
538  aStatusReporter->Report( _( "Create layers" ) );
539 
540  createLayers( aStatusReporter );
541 
542  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
543 
544  auto to_SFVEC4F =
545  []( const COLOR4D& src )
546  {
547  return SFVEC4F( src.r, src.g, src.b, src.a );
548  };
549 
550  m_BgColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_TOP ) );
551  m_BgColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ) );
552 
553  m_SolderPasteColor = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERPASTE ) );
554 
555  if( m_board && colors->GetUseBoardStackupColors() )
556  {
558 
559  auto findColor =
560  []( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet )
561  {
562  if( aColorName.StartsWith( wxT( "#" ) ) )
563  {
564  return KIGFX::COLOR4D( aColorName );
565  }
566  else
567  {
568  for( const CUSTOM_COLOR_ITEM& color : aColorSet )
569  {
570  if( color.m_ColorName == aColorName )
571  return color.m_Color;
572  }
573  }
574 
575  return KIGFX::COLOR4D();
576  };
577 
582 
583  KIGFX::COLOR4D bodyColor( 0, 0, 0, 0 );
584 
585  for( const BOARD_STACKUP_ITEM* stackupItem : stackup.GetList() )
586  {
587  wxString colorName = stackupItem->GetColor();
588 
589  switch( stackupItem->GetType() )
590  {
592  if( stackupItem->GetBrdLayerId() == F_SilkS )
593  m_SilkScreenColorTop = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
594  else
595  m_SilkScreenColorBot = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
596  break;
597 
599  if( stackupItem->GetBrdLayerId() == F_Mask )
600  m_SolderMaskColorTop = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
601  else
602  m_SolderMaskColorBot = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
603 
604  break;
605 
607  {
608  KIGFX::COLOR4D layerColor = COLOR4D::UNSPECIFIED;
609  const wxString& materialName = stackupItem->GetMaterial();
610 
611  if( materialName.StartsWith( wxT( "FR4" ) ) )
612  {
613  layerColor = findColor( wxT( "FR4 natural" ), g_BoardColors );
614  }
615  else if( materialName.IsSameAs( wxT( "PTFE" ) )
616  || materialName.IsSameAs( wxT( "Teflon" ) ) )
617  {
618  layerColor = findColor( wxT( "PTFE natural" ), g_BoardColors );
619  }
620  else if( materialName.IsSameAs( wxT( "Polyimide" ) )
621  || materialName.IsSameAs( wxT( "Kapton" ) ) )
622  {
623  layerColor = findColor( wxT( "Polyimide" ), g_BoardColors );
624  }
625  else if( materialName.IsSameAs( wxT( "Al" ) ) )
626  {
627  layerColor = findColor( wxT( "Aluminum" ), g_BoardColors );
628  }
629  else // A default color value for unknown dielectric material
630  // (i.e. an exotic name entered by hand)
631  {
632  layerColor = findColor( wxT( "FR4 natural" ), g_BoardColors );
633  }
634 
635  if( bodyColor == COLOR4D( 0, 0, 0, 0 ) )
636  bodyColor = layerColor;
637  else
638  bodyColor = bodyColor.Mix( layerColor, 1.0 - layerColor.a );
639 
640  bodyColor.a += ( 1.0 - bodyColor.a ) * layerColor.a / 2;
641  break;
642  }
643 
644  default:
645  break;
646  }
647  }
648 
649  if( bodyColor != COLOR4D( 0, 0, 0, 0 ) )
650  m_BoardBodyColor = to_SFVEC4F( bodyColor );
651  else
652  m_BoardBodyColor = to_SFVEC4F( g_DefaultBoardBody );
653 
654  const wxString& finishName = stackup.m_FinishType;
655 
656  if( finishName.EndsWith( wxT( "OSP" ) ) )
657  {
658  m_CopperColor = to_SFVEC4F( findColor( wxT( "Copper" ), g_FinishColors ) );
659  }
660  else if( finishName.EndsWith( wxT( "IG" ) )
661  || finishName.EndsWith( wxT( "gold" ) ) )
662  {
663  m_CopperColor = to_SFVEC4F( findColor( wxT( "Gold" ), g_FinishColors ) );
664  }
665  else if( finishName.StartsWith( wxT( "HAL" ) )
666  || finishName.StartsWith( wxT( "HASL" ) )
667  || finishName.EndsWith( wxT( "tin" ) )
668  || finishName.EndsWith( wxT( "nickel" ) ) )
669  {
670  m_CopperColor = to_SFVEC4F( findColor( wxT( "Tin" ), g_FinishColors ) );
671  }
672  else if( finishName.EndsWith( wxT( "silver" ) ) )
673  {
674  m_CopperColor = to_SFVEC4F( findColor( wxT( "Silver" ), g_FinishColors ) );
675  }
676  else
677  {
678  m_CopperColor = to_SFVEC4F( g_DefaultSurfaceFinish );
679  }
680  }
681  else
682  {
683  m_SilkScreenColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ) );
684  m_SilkScreenColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ) );
685  m_SolderMaskColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_BOTTOM ) );
686  m_SolderMaskColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_TOP ) );
687  m_CopperColor = to_SFVEC4F( colors->GetColor( LAYER_3D_COPPER ) );
688  m_BoardBodyColor = to_SFVEC4F( colors->GetColor( LAYER_3D_BOARD ) );
689  }
690 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
#define TECH_LAYER_THICKNESS
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
bool GetUseBoardStackupColors() const
float m_solderPasteLayerThickness3DU
Number of tracks in the board.
Manage layers needed to make a physical board.
float m_nonCopperLayerThickness3DU
solder paste layers thickness in 3D units.
wxString m_FinishType
The name of external copper finish.
Manage a bounding box defined by two SFVEC3F min max points.
Definition: bbox_3d.h:41
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46
static KIGFX::COLOR4D g_DefaultSilkscreen
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
int color
Definition: DXF_plotter.cpp:57
static KIGFX::COLOR4D g_DefaultSurfaceFinish
int GetWidth() const
Definition: eda_rect.h:118
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
#define layerThicknessMargin
A class to handle a custom color (predefined color) for the color picker dialog.
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
wxPoint m_boardPos
Board center position in board internal units.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:222
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Copper thickness in 3D units.
float m_epoxyThickness3DU
Non copper layers thickness in 3D units.
static CUSTOM_COLORS_LIST g_BoardColors
float m_copperThickness3DU
Epoxy thickness in 3D units.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
static CUSTOM_COLORS_LIST g_FinishColors
static KIGFX::COLOR4D g_DefaultSolderMask
BOARD_STACKUP & GetStackupDescriptor()
double a
Alpha component.
Definition: color4d.h:387
static KIGFX::COLOR4D g_DefaultBoardBody
SFVEC4F m_BgColorTop
background top color
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Bottom (Start) Z position of each layer in 3D units.
#define MAX_CU_LAYERS
Definition: layer_ids.h:147
BBOX_3D m_boardBoundingBox
3D bounding box of the board in 3D units.
constexpr double PCB_IU_PER_MM
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
#define _(s)
SFVEC4F m_BgColorBot
background bottom color
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
void createLayers(REPORTER *aStatusReporter)
int GetHeight() const
Definition: eda_rect.h:119
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
#define SOLDERPASTE_LAYER_THICKNESS
COLOR4D GetColor(int aLayer) const
wxSize m_boardSize
Board size in board internal units.
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
unsigned int m_copperLayersCount
Scale factor to convert board internal units to 3D units normalized between -1.0 and 1....
bool createBoardPolygon(wxString *aErrorMsg)
Create the board outline polygon.
SFVEC4F m_CopperColor
in realistic mode: copper color
Definition: layer_ids.h:71
int GetCopperLayerCount() const
Definition: board.cpp:455
Handle the component boundary box.
Definition: eda_rect.h:42
wxPoint Centre() const
Definition: eda_rect.h:64
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1085
Color settings are a bit different than most of the settings objects in that there can be more than o...
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
static CUSTOM_COLORS_LIST g_MaskColors
static CUSTOM_COLORS_LIST g_SilkscreenColors
SFVEC3F m_boardCenter
3D center position of the board in 3D units.
#define COPPER_THICKNESS
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition: color4d.h:305
static constexpr int Millimeter2iu(double mm)
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: board_adapter.h:62
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364
const wxSize GetSize() const
Definition: eda_rect.h:100
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References _, KIGFX::COLOR4D::a, B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, BS_ITEM_TYPE_DIELECTRIC, BS_ITEM_TYPE_SILKSCREEN, BS_ITEM_TYPE_SOLDERMASK, EDA_RECT::Centre(), color, BOARD::ComputeBoundingBox(), COPPER_THICKNESS, createBoardPolygon(), createLayers(), F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, FL_USE_REALISTIC_MODE, g_BoardColors, g_DefaultBoardBody, g_DefaultSilkscreen, g_DefaultSolderMask, g_DefaultSurfaceFinish, g_FinishColors, g_MaskColors, g_SilkscreenColors, BOARD_DESIGN_SETTINGS::GetBoardThickness(), COLOR_SETTINGS::GetColor(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), GetFlag(), EDA_RECT::GetHeight(), BOARD_STACKUP::GetList(), GetRunningMicroSecs(), EDA_RECT::GetSize(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), COLOR_SETTINGS::GetUseBoardStackupColors(), EDA_RECT::GetWidth(), EDA_RECT::Inflate(), BOARD::IsFootprintHolder(), LAYER_3D_BACKGROUND_BOTTOM, LAYER_3D_BACKGROUND_TOP, LAYER_3D_BOARD, LAYER_3D_COPPER, LAYER_3D_SILKSCREEN_BOTTOM, LAYER_3D_SILKSCREEN_TOP, LAYER_3D_SOLDERMASK_BOTTOM, LAYER_3D_SOLDERMASK_TOP, LAYER_3D_SOLDERPASTE, layerThicknessMargin, m_BgColorBot, m_BgColorTop, m_biuTo3Dunits, m_board, m_BoardBodyColor, m_boardBoundingBox, m_boardCenter, m_boardPos, m_boardSize, m_CopperColor, m_copperLayersCount, m_copperThickness3DU, m_epoxyThickness3DU, BOARD_STACKUP::m_FinishType, m_layerZcoordBottom, m_layerZcoordTop, m_logTrace, m_nonCopperLayerThickness3DU, m_SilkScreenColorBot, m_SilkScreenColorTop, m_SolderMaskColorBot, m_SolderMaskColorTop, m_SolderPasteColor, m_solderPasteLayerThickness3DU, MAX_CU_LAYERS, Millimeter2iu(), KIGFX::COLOR4D::Mix(), PCB_IU_PER_MM, PCB_LAYER_ID_COUNT, Pgm(), RANGE_SCALE_3D, REPORTER::Report(), RPT_SEVERITY_WARNING, SOLDERPASTE_LAYER_THICKNESS, and TECH_LAYER_THICKNESS.

Referenced by RENDER_3D_RAYTRACE::Reload(), and RENDER_3D_OPENGL::reload().

◆ Is3dLayerEnabled()

bool BOARD_ADAPTER::Is3dLayerEnabled ( PCB_LAYER_ID  aLayer) const

Check if a layer is enabled.

Parameters
aLayerlayer ID to get status.

Definition at line 232 of file board_adapter.cpp.

233 {
234  wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
235 
236  if( m_board && !m_board->IsLayerEnabled( aLayer ) )
237  return false;
238 
239  // see if layer needs to be shown
240  // check the flags
241  switch( aLayer )
242  {
243  case B_Adhes:
244  case F_Adhes:
245  return GetFlag( FL_ADHESIVE );
246 
247  case B_Paste:
248  case F_Paste:
249  return GetFlag( FL_SOLDERPASTE );
250 
251  case B_SilkS:
252  case F_SilkS:
253  return GetFlag( FL_SILKSCREEN );
254 
255  case B_Mask:
256  case F_Mask:
257  return GetFlag( FL_SOLDERMASK );
258 
259  case Dwgs_User:
260  case Cmts_User:
262  return false;
263 
264  return GetFlag( FL_COMMENTS );
265 
266  case Eco1_User:
267  case Eco2_User:
269  return false;
270 
271  return GetFlag( FL_ECO );
272 
273  case Edge_Cuts:
275  return false;
276 
277  return true;
278 
279  case Margin:
281  return false;
282 
283  return true;
284 
285  case B_Cu:
286  case F_Cu:
288  : true;
289 
290  default:
291  // the layer is an internal copper layer, used the visibility
292  return m_board && m_board->IsLayerVisible( aLayer );
293  }
294 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:493
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:473
Definition: layer_ids.h:71

References B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, FL_ADHESIVE, FL_COMMENTS, FL_ECO, FL_SHOW_BOARD_BODY, FL_SILKSCREEN, FL_SOLDERMASK, FL_SOLDERPASTE, FL_USE_REALISTIC_MODE, GetFlag(), BOARD::IsLayerEnabled(), BOARD::IsLayerVisible(), m_board, Margin, and PCB_LAYER_ID_COUNT.

Referenced by createLayers(), and RENDER_3D_OPENGL::reload().

◆ IsFootprintShown()

bool BOARD_ADAPTER::IsFootprintShown ( FOOTPRINT_ATTR_T  aFPAttributes) const

Test if footprint should be displayed in relation to attributes and the flags.

Definition at line 313 of file board_adapter.cpp.

314 {
315  if( aFPAttributes & FP_SMD )
317  else if( aFPAttributes & FP_THROUGH_HOLE )
319  else
321 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.

References FL_FP_ATTRIBUTES_NORMAL, FL_FP_ATTRIBUTES_NORMAL_INSERT, FL_FP_ATTRIBUTES_VIRTUAL, FP_SMD, FP_THROUGH_HOLE, and GetFlag().

Referenced by RENDER_3D_RAYTRACE::load3DModels(), and RENDER_3D_OPENGL::render3dModelsSelected().

◆ Set3dCacheManager()

void BOARD_ADAPTER::Set3dCacheManager ( S3D_CACHE aCachePointer)
inlinenoexcept

Update the cache manager pointer.

Parameters
aCachePointerthe pointer to the 3D cache manager.

Definition at line 80 of file board_adapter.h.

81  {
82  m_3dModelManager = aCachePointer;
83  }
S3D_CACHE * m_3dModelManager

References m_3dModelManager.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ SetAntiAliasingMode()

void BOARD_ADAPTER::SetAntiAliasingMode ( ANTIALIASING_MODE  aAAmode)
inline

Set the current antialiasing mode value.

Parameters
aAAmodeantialiasing mode value.

Definition at line 282 of file board_adapter.h.

282 { m_antiAliasingMode = aAAmode; }
ANTIALIASING_MODE m_antiAliasingMode

References m_antiAliasingMode.

Referenced by EDA_3D_VIEWER_FRAME::LoadSettings(), and PANEL_3D_OPENGL_OPTIONS::TransferDataFromWindow().

◆ SetBoard()

void BOARD_ADAPTER::SetBoard ( BOARD aBoard)
inlinenoexcept

Set current board to be rendered.

Parameters
aBoardboard to process.

Definition at line 126 of file board_adapter.h.

127  {
128  m_board = aBoard;
129  }

References m_board.

Referenced by PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), and EDA_3D_CANVAS::ReloadRequest().

◆ SetColorSettings()

void BOARD_ADAPTER::SetColorSettings ( COLOR_SETTINGS aSettings)
inlinenoexcept

Definition at line 141 of file board_adapter.h.

142  {
143  m_colors = aSettings;
144  }
COLOR_SETTINGS * m_colors

References m_colors.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ SetFlag()

void BOARD_ADAPTER::SetFlag ( DISPLAY3D_FLG  aFlag,
bool  aState 
)

Set the status of a flag.

Parameters
aFlagthe flag to set the status
aStatestatus to set.

Definition at line 305 of file board_adapter.cpp.

306 {
307  wxASSERT( aFlag < FL_LAST );
308 
309  m_drawFlags[aFlag] = aState;
310 }
std::vector< bool > m_drawFlags

References FL_LAST, and m_drawFlags.

Referenced by BOARD_ADAPTER(), EDA_3D_VIEWER_FRAME::loadCommonSettings(), PANEL_PREVIEW_3D_MODEL::loadSettings(), PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), EDA_3D_CONTROLLER::ToggleVisibility(), PANEL_3D_OPENGL_OPTIONS::TransferDataFromWindow(), PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow(), and PANEL_3D_DISPLAY_OPTIONS::TransferDataFromWindow().

◆ SetGridType()

void BOARD_ADAPTER::SetGridType ( GRID3D_TYPE  aGridType)
inlinenoexcept

Set the current grid.

Parameters
aGridTypethe type space of the grid.

Definition at line 265 of file board_adapter.h.

266  {
267  m_gridType = aGridType;
268  }
GRID3D_TYPE m_gridType

References m_gridType.

Referenced by EDA_3D_VIEWER_FRAME::LoadSettings(), and EDA_3D_CONTROLLER::On3DGridSelection().

◆ SetMaterialMode()

void BOARD_ADAPTER::SetMaterialMode ( MATERIAL_MODE  aMaterialMode)
inlinenoexcept
Parameters
aMaterialModethe render material mode.

Definition at line 303 of file board_adapter.h.

304  {
305  m_materialMode = aMaterialMode;
306  }
MATERIAL_MODE m_materialMode

References m_materialMode.

Referenced by PANEL_PREVIEW_3D_MODEL::loadSettings(), EDA_3D_VIEWER_FRAME::LoadSettings(), EDA_3D_CONTROLLER::SetMaterial(), and PANEL_3D_DISPLAY_OPTIONS::TransferDataFromWindow().

◆ SetRenderEngine()

void BOARD_ADAPTER::SetRenderEngine ( RENDER_ENGINE  aRenderEngine)
inlinenoexcept
Parameters
aRenderEnginethe render engine mode selected.

Definition at line 287 of file board_adapter.h.

288  {
289  m_renderEngine = aRenderEngine;
290  }
RENDER_ENGINE m_renderEngine

References m_renderEngine.

Referenced by EDA_3D_CANVAS::DoRePaint(), PANEL_PREVIEW_3D_MODEL::loadSettings(), EDA_3D_VIEWER_FRAME::LoadSettings(), EDA_3D_VIEWER_FRAME::OnDisableRayTracing(), and EDA_3D_VIEWER_FRAME::OnRenderEngineSelection().

◆ transformArcToSegments()

void BOARD_ADAPTER::transformArcToSegments ( const wxPoint &  aCentre,
const wxPoint &  aStart,
double  aArcAngle,
int  aCircleToSegmentsCount,
int  aWidth,
CONTAINER_2D_BASE aDstContainer,
const BOARD_ITEM aBoardItem 
)
private

Definition at line 568 of file create_3Dgraphic_brd_items.cpp.

572 {
573  wxPoint arc_start, arc_end;
574  double delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
575 
576  arc_end = arc_start = aStart;
577 
578  if( aArcAngle != 3600 )
579  {
580  RotatePoint( &arc_end, aCentre, -aArcAngle );
581  }
582 
583  if( aArcAngle < 0 )
584  {
585  std::swap( arc_start, arc_end );
586  aArcAngle = -aArcAngle;
587  }
588 
589  // Compute the ends of segments and creates poly
590  wxPoint curr_end = arc_start;
591  wxPoint curr_start = arc_start;
592 
593  for( double ii = delta; ii < aArcAngle; ii += delta )
594  {
595  curr_end = arc_start;
596  RotatePoint( &curr_end, aCentre, -ii );
597 
598  const SFVEC2F start3DU( curr_start.x * m_biuTo3Dunits, -curr_start.y * m_biuTo3Dunits );
599  const SFVEC2F end3DU ( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
600 
601  if( Is_segment_a_circle( start3DU, end3DU ) )
602  {
603  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
604  aBoardItem ) );
605  }
606  else
607  {
608  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
609  aBoardItem ) );
610  }
611 
612  curr_start = curr_end;
613  }
614 
615  if( curr_end != arc_end )
616  {
617  const SFVEC2F start3DU( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
618  const SFVEC2F end3DU ( arc_end.x * m_biuTo3Dunits, -arc_end.y * m_biuTo3Dunits );
619 
620  if( Is_segment_a_circle( start3DU, end3DU ) )
621  {
622  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
623  aBoardItem ) );
624  }
625  else
626  {
627  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
628  aBoardItem ) );
629  }
630  }
631 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Check if segment start and end is very close to each other.
constexpr int delta

References CONTAINER_2D_BASE::Add(), delta, Is_segment_a_circle(), m_biuTo3Dunits, and RotatePoint().

Referenced by addShapeWithClearance(), and createTrack().

◆ transformFPShapesToPolygon()

void BOARD_ADAPTER::transformFPShapesToPolygon ( const FOOTPRINT aFootprint,
PCB_LAYER_ID  aLayer,
SHAPE_POLY_SET aCornerBuffer 
) const
private

Definition at line 62 of file create_layer_poly.cpp.

64 {
65  for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
66  {
67  if( item->Type() == PCB_FP_SHAPE_T )
68  {
69  FP_SHAPE* outline = (FP_SHAPE*) item;
70 
71  if( outline->GetLayer() == aLayer )
72  {
73  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0,
74  ARC_HIGH_DEF, ERROR_INSIDE );
75  }
76  }
77  }
78 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
Definition: pcb_shape.cpp:236
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143

References ERROR_INSIDE, BOARD_ITEM::GetLayer(), FOOTPRINT::GraphicalItems(), PCB_FP_SHAPE_T, and PCB_SHAPE::TransformShapeWithClearanceToPolygon().

Referenced by createLayers().

Member Data Documentation

◆ g_BoardColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_BoardColors
static

Definition at line 616 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultBackgroundBot

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBackgroundBot
static

Definition at line 619 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultBackgroundTop

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBackgroundTop
static

Definition at line 618 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultBoardBody

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBoardBody
static

Definition at line 624 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultSilkscreen

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSilkscreen
static

Definition at line 620 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultSolderMask

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderMask
static

Definition at line 621 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultSolderPaste

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderPaste
static

Definition at line 622 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultSurfaceFinish

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSurfaceFinish
static

Definition at line 623 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_FinishColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_FinishColors
static

Definition at line 615 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_MaskColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_MaskColors
static

Definition at line 613 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_PasteColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_PasteColors
static

Definition at line 614 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_SilkscreenColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_SilkscreenColors
static

Definition at line 612 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ m_3dModelManager

S3D_CACHE* BOARD_ADAPTER::m_3dModelManager
private

Definition at line 660 of file board_adapter.h.

Referenced by Get3dCacheManager(), and Set3dCacheManager().

◆ m_antiAliasingMode

ANTIALIASING_MODE BOARD_ADAPTER::m_antiAliasingMode
private

Definition at line 667 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetAntiAliasingMode(), and SetAntiAliasingMode().

◆ m_averageHoleDiameter

float BOARD_ADAPTER::m_averageHoleDiameter
private

Definition at line 766 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), and GetAverageHoleDiameter().

◆ m_averageTrackWidth

float BOARD_ADAPTER::m_averageTrackWidth
private

Number of through hole vias in the board.

Definition at line 754 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), and GetAverageTrackWidth().

◆ m_averageViaHoleDiameter

float BOARD_ADAPTER::m_averageViaHoleDiameter
private

Number of holes in the board.

Definition at line 760 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), and GetAverageViaHoleDiameter().

◆ m_backPlatedPadPolys

SHAPE_POLY_SET* BOARD_ADAPTER::m_backPlatedPadPolys
private

Polygon contours for hole outer diameters for each layer.

Definition at line 680 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), destroyLayers(), and GetBackPlatedPadPolys().

◆ m_BgColorBot

◆ m_BgColorTop

◆ m_biuTo3Dunits

◆ m_board

BOARD* BOARD_ADAPTER::m_board
private

◆ m_board_poly

SHAPE_POLY_SET BOARD_ADAPTER::m_board_poly
private

Board outline polygon.

Definition at line 700 of file board_adapter.h.

Referenced by createBoardPolygon(), and GetBoardPoly().

◆ m_BoardBodyColor

◆ m_boardBoundingBox

BBOX_3D BOARD_ADAPTER::m_boardBoundingBox
private

3D bounding box of the board in 3D units.

Polygon contours for each layer.

Definition at line 673 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBBox(), and InitSettings().

◆ m_boardCenter

SFVEC3F BOARD_ADAPTER::m_boardCenter
private

3D center position of the board in 3D units.

Definition at line 672 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBoardCenter(), and InitSettings().

◆ m_boardPos

wxPoint BOARD_ADAPTER::m_boardPos
private

Board center position in board internal units.

Definition at line 670 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBoardPos(), and InitSettings().

◆ m_boardSize

wxSize BOARD_ADAPTER::m_boardSize
private

Board size in board internal units.

Definition at line 671 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBoardSize(), and InitSettings().

◆ m_colors

COLOR_SETTINGS* BOARD_ADAPTER::m_colors
private

Definition at line