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 68 of file board_adapter.cpp.

68  :
69  m_board( nullptr ),
70  m_3dModelManager( nullptr ),
71  m_colors( nullptr ),
74 {
75  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
76 
79  m_drawFlags.resize( FL_LAST, false );
80 
81  if( PgmOrNull() )
82  m_colors = Pgm().GetSettingsManager().GetColorSettings();
83 
86 
87  m_boardPos = wxPoint();
88  m_boardSize = wxSize();
89  m_boardCenter = SFVEC3F( 0.0f );
90 
92 
96 
98  m_epoxyThickness3DU = 0.0f;
99  m_copperThickness3DU = 0.0f;
102  m_biuTo3Dunits = 1.0;
103 
104  m_trackCount = 0;
105  m_viaCount = 0;
107  m_holeCount = 0;
108  m_averageHoleDiameter = 0.0f;
109  m_averageTrackWidth = 0.0f;
110 
113  SetFlag( FL_SHOW_BOARD_BODY, true );
118  SetFlag( FL_ZONE, true );
119  SetFlag( FL_SILKSCREEN, true );
120  SetFlag( FL_SOLDERMASK, true );
122 
128 
129  SetFlag( FL_USE_SELECTION, true );
131 
132  m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
133  m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );
134  m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 0.9 );
135  m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
136  m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
137  m_SolderPasteColor = SFVEC4F( 0.4, 0.4, 0.4, 1.0 );
138  m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
139  m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
140  m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
141 
142  m_platedPadsFront = nullptr;
143  m_platedPadsBack = nullptr;
144 
145  m_frontPlatedPadPolys = nullptr;
146  m_backPlatedPadPolys = nullptr;
147 
148  // Avoid raytracing options not initialized:
152 
153  m_RtSpreadShadows = 0.0;
154  m_RtSpreadReflections = 0.0;
155  m_RtSpreadRefractions = 0.0;
156 
159 
160  if( !g_ColorsLoaded )
161  {
162 #define ADD_COLOR( list, r, g, b, a, name ) \
163  list.push_back( CUSTOM_COLOR_ITEM( r/255.0, g/255.0, b/255.0, a, name ) )
164 
165  ADD_COLOR( g_SilkscreenColors, 20, 51, 36, 1.0, "Green" );
166  ADD_COLOR( g_SilkscreenColors, 181, 19, 21, 1.0, "Red" );
167  ADD_COLOR( g_SilkscreenColors, 2, 59, 162, 1.0, "Blue" );
168  ADD_COLOR( g_SilkscreenColors, 11, 11, 11, 1.0, "Black" );
169  ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, "White" );
170  ADD_COLOR( g_SilkscreenColors, 32, 2, 53, 1.0, "Purple" );
171  ADD_COLOR( g_SilkscreenColors, 194, 195, 0, 1.0, "Yellow" );
172 
173  ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, "Green" );
174  ADD_COLOR( g_MaskColors, 91, 168, 12, 0.83, "Light Green" );
175  ADD_COLOR( g_MaskColors, 13, 104, 11, 0.83, "Saturated Green" );
176  ADD_COLOR( g_MaskColors, 181, 19, 21, 0.83, "Red" );
177  ADD_COLOR( g_MaskColors, 210, 40, 14, 0.83, "Light Red" );
178  ADD_COLOR( g_MaskColors, 239, 53, 41, 0.83, "Red/Orange" );
179  ADD_COLOR( g_MaskColors, 2, 59, 162, 0.83, "Blue" );
180  ADD_COLOR( g_MaskColors, 54, 79, 116, 0.83, "Light Blue 1" );
181  ADD_COLOR( g_MaskColors, 61, 85, 130, 0.83, "Light Blue 2" );
182  ADD_COLOR( g_MaskColors, 21, 70, 80, 0.83, "Green/Blue" );
183  ADD_COLOR( g_MaskColors, 11, 11, 11, 0.83, "Black" );
184  ADD_COLOR( g_MaskColors, 245, 245, 245, 0.83, "White" );
185  ADD_COLOR( g_MaskColors, 32, 2, 53, 0.83, "Purple" );
186  ADD_COLOR( g_MaskColors, 119, 31, 91, 0.83, "Light Purple" );
187  ADD_COLOR( g_MaskColors, 194, 195, 0, 0.83, "Yellow" );
188 
189  ADD_COLOR( g_PasteColors, 128, 128, 128, 1.0, "Grey" );
190  ADD_COLOR( g_PasteColors, 90, 90, 90, 1.0, "Dark Grey" );
191  ADD_COLOR( g_PasteColors, 213, 213, 213, 1.0, "Silver" );
192 
193  ADD_COLOR( g_FinishColors, 184, 115, 50, 1.0, "Copper" );
194  ADD_COLOR( g_FinishColors, 178, 156, 0, 1.0, "Gold" );
195  ADD_COLOR( g_FinishColors, 213, 213, 213, 1.0, "Silver" );
196  ADD_COLOR( g_FinishColors, 160, 160, 160, 1.0, "Tin" );
197 
198  ADD_COLOR( g_BoardColors, 51, 43, 22, 0.83, "FR4 natural, dark" );
199  ADD_COLOR( g_BoardColors, 109, 116, 75, 0.83, "FR4 natural" );
200  ADD_COLOR( g_BoardColors, 252, 252, 250, 0.90, "PTFE natural" );
201  ADD_COLOR( g_BoardColors, 205, 130, 0, 0.68, "Polyimide" );
202  ADD_COLOR( g_BoardColors, 92, 17, 6, 0.90, "Phenolic natural" );
203  ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, "Brown 1" );
204  ADD_COLOR( g_BoardColors, 160, 123, 54, 0.83, "Brown 2" );
205  ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, "Brown 3" );
206  ADD_COLOR( g_BoardColors, 213, 213, 213, 1.0, "Aluminum" );
207 
208  g_DefaultBackgroundTop = COLOR4D( 0.80, 0.80, 0.90, 1.0 );
209  g_DefaultBackgroundBot = COLOR4D( 0.40, 0.40, 0.50, 1.0 );
210 
211  g_DefaultSilkscreen = COLOR4D( 0.94, 0.94, 0.94, 1.0 );
212  g_DefaultSolderMask = COLOR4D( 0.08, 0.20, 0.14, 0.83 );
213  g_DefaultSolderPaste = COLOR4D( 0.50, 0.50, 0.50, 1.0 );
214  g_DefaultSurfaceFinish = COLOR4D( 0.75, 0.61, 0.23, 1.0 );
215  g_DefaultBoardBody = COLOR4D( 0.43, 0.45, 0.30, 0.90 );
216 
217  g_ColorsLoaded = true;
218  }
219 #undef ADD_COLOR
220 }
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.
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, OPENGL_LEGACY, Pgm(), PgmOrNull(), BBOX_3D::Reset(), and SetFlag().

◆ ~BOARD_ADAPTER()

BOARD_ADAPTER::~BOARD_ADAPTER ( )

Definition at line 223 of file board_adapter.cpp.

224 {
225  destroyLayers();
226 }

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:485
static int s_textWidth
FP_TEXT & Reference()
Definition: footprint.h:486
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:186
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
DRAWINGS & GraphicalItems()
Definition: footprint.h:171
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:140

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 483 of file create_3Dgraphic_brd_items.cpp.

488 {
489  for( PAD* pad : aFootprint->Pads() )
490  {
491  if( !pad->IsOnLayer( aLayerId ) )
492  continue;
493 
494  // Skip pad annulus when not connected on this layer (if removing is enabled)
495  if( !pad->FlashLayer( aLayerId ) && IsCopperLayer( aLayerId ) )
496  continue;
497 
498  // NPTH pads are not drawn on layers if the
499  // 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  const bool isPlated = ( ( aLayerId == F_Cu ) && pad->FlashLayer( F_Mask ) ) ||
525  ( ( aLayerId == B_Cu ) && pad->FlashLayer( B_Mask ) );
526 
527  if( aSkipPlatedPads && isPlated )
528  continue;
529 
530  if( aSkipNonPlatedPads && !isPlated )
531  continue;
532 
533  wxSize margin( aInflateValue, aInflateValue );
534 
535  switch( aLayerId )
536  {
537  case F_Mask:
538  case B_Mask:
539  margin.x += pad->GetSolderMaskMargin();
540  margin.y += pad->GetSolderMaskMargin();
541  break;
542 
543  case F_Paste:
544  case B_Paste:
545  margin += pad->GetSolderPasteMargin();
546  break;
547 
548  default:
549  break;
550  }
551 
552  createPadWithClearance( pad, aDstContainer, aLayerId, margin );
553  }
554 }
void createPadWithClearance(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, const wxSize &aClearanceValue) const
static void isPlated(LIBEVAL::CONTEXT *aCtx, void *self)
PADS & Pads()
Definition: footprint.h:168
like PAD_PTH, but not plated
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:796
Definition: layer_ids.h:71
Definition: pad.h:57

References B_Cu, B_Mask, B_Paste, CIRCLE, createPadWithClearance(), F_Cu, F_Mask, F_Paste, IsCopperLayer(), isPlated(), 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:183
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsMirrored() const
Definition: eda_text.h:189
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:174
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:149
static int s_textWidth
bool IsItalic() const
Definition: eda_text.h:180
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:198
static float s_biuTo3Dunits
const wxSize & GetTextSize() const
Definition: eda_text.h:238
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:247
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 628 of file create_3Dgraphic_brd_items.cpp.

631 {
632  // The full width of the lines to create
633  // The extra 1 protects the inner/outer radius values from degeneracy
634  const int linewidth = aShape->GetWidth() + ( 2 * aClearanceValue ) + 1;
635 
636  switch( aShape->GetShape() )
637  {
638  case SHAPE_T::CIRCLE:
639  {
640  const SFVEC2F center3DU( aShape->GetCenter().x * m_biuTo3Dunits,
641  -aShape->GetCenter().y * m_biuTo3Dunits );
642 
643  float inner_radius = ( aShape->GetRadius() - linewidth / 2 ) * m_biuTo3Dunits;
644  float outer_radius = ( aShape->GetRadius() + linewidth / 2 ) * m_biuTo3Dunits;
645 
646  if( inner_radius < 0 )
647  inner_radius = 0;
648 
649  if( aShape->IsFilled() )
650  aDstContainer->Add( new FILLED_CIRCLE_2D( center3DU, outer_radius, *aShape ) );
651  else
652  aDstContainer->Add( new RING_2D( center3DU, inner_radius, outer_radius, *aShape ) );
653  }
654  break;
655 
656  case SHAPE_T::RECT:
657  if( aShape->IsFilled() )
658  {
659  SHAPE_POLY_SET polyList;
660 
661  aShape->TransformShapeWithClearanceToPolygon( polyList, aLayerId, 0,
662  ARC_HIGH_DEF, ERROR_INSIDE );
663 
664  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
665 
666  ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aShape );
667  }
668  else
669  {
670  std::vector<wxPoint> pts = aShape->GetRectCorners();
671 
672  const SFVEC2F topLeft3DU( pts[0].x * m_biuTo3Dunits, -pts[0].y * m_biuTo3Dunits );
673  const SFVEC2F topRight3DU( pts[1].x * m_biuTo3Dunits, -pts[1].y * m_biuTo3Dunits );
674  const SFVEC2F botRight3DU( pts[2].x * m_biuTo3Dunits, -pts[2].y * m_biuTo3Dunits );
675  const SFVEC2F botLeft3DU( pts[3].x * m_biuTo3Dunits, -pts[3].y * m_biuTo3Dunits );
676 
677  aDstContainer->Add( new ROUND_SEGMENT_2D( topLeft3DU, topRight3DU,
678  linewidth * m_biuTo3Dunits, *aShape ) );
679  aDstContainer->Add( new ROUND_SEGMENT_2D( topRight3DU, botRight3DU,
680  linewidth * m_biuTo3Dunits, *aShape ) );
681  aDstContainer->Add( new ROUND_SEGMENT_2D( botRight3DU, botLeft3DU,
682  linewidth * m_biuTo3Dunits, *aShape ) );
683  aDstContainer->Add( new ROUND_SEGMENT_2D( botLeft3DU, topLeft3DU,
684  linewidth * m_biuTo3Dunits, *aShape ) );
685  }
686  break;
687 
688  case SHAPE_T::ARC:
689  {
690  unsigned int segCount = GetCircleSegmentCount( aShape->GetBoundingBox().GetSizeMax() );
691 
692  transformArcToSegments( aShape->GetCenter(), aShape->GetStart(), aShape->GetArcAngle(),
693  segCount, linewidth, aDstContainer, *aShape );
694  }
695  break;
696 
697  case SHAPE_T::SEGMENT:
698  {
699  const SFVEC2F start3DU( aShape->GetStart().x * m_biuTo3Dunits,
700  -aShape->GetStart().y * m_biuTo3Dunits );
701 
702  const SFVEC2F end3DU ( aShape->GetEnd().x * m_biuTo3Dunits,
703  -aShape->GetEnd().y * m_biuTo3Dunits );
704 
705  if( Is_segment_a_circle( start3DU, end3DU ) )
706  {
707  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( linewidth / 2 ) * m_biuTo3Dunits,
708  *aShape ) );
709  }
710  else
711  {
712  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, linewidth * m_biuTo3Dunits,
713  *aShape ) );
714  }
715  }
716  break;
717 
718  case SHAPE_T::BEZIER:
719  case SHAPE_T::POLY:
720  {
721  SHAPE_POLY_SET polyList;
722 
723  aShape->TransformShapeWithClearanceToPolygon( polyList, aLayerId, 0,
724  ARC_HIGH_DEF, ERROR_INSIDE );
725 
726  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
727 
728  if( polyList.IsEmpty() ) // Just for caution
729  break;
730 
731  ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aShape );
732  }
733  break;
734 
735  default:
736  wxFAIL_MSG( "BOARD_ADAPTER::addShapeWithClearance no implementation for "
737  + aShape->SHAPE_T_asString() );
738  break;
739  }
740 }
int GetWidth() const
Definition: eda_shape.h:89
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:97
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:495
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
bool IsFilled() const
Definition: eda_shape.h:81
std::vector< wxPoint > GetRectCorners() const
Definition: eda_shape.cpp:932
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
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:68
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.h:101
SHAPE_T GetShape() const
Definition: eda_shape.h:92
int GetRadius() const
Definition: eda_shape.cpp:463
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.
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
int GetSizeMax() const
Definition: eda_rect.h:96

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 746 of file create_3Dgraphic_brd_items.cpp.

748 {
749  // Copy the polys list because we have to simplify it
750  SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList( aLayerId ) );
751 
752  // This convert the poly in outline and holes
753  ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aZoneContainer );
754 
755  // add filled areas outlines, which are drawn with thick lines segments
756  // but only if filled polygons outlines have thickness
757  if( !aZoneContainer->GetFilledPolysUseThickness() )
758  return;
759 
760  float line_thickness = aZoneContainer->GetMinThickness() * m_biuTo3Dunits;
761 
762  for( int i = 0; i < polyList.OutlineCount(); ++i )
763  {
764  // Add outline
765  const SHAPE_LINE_CHAIN& pathOutline = polyList.COutline( i );
766 
767  for( int j = 0; j < pathOutline.PointCount(); ++j )
768  {
769  const VECTOR2I& a = pathOutline.CPoint( j );
770  const VECTOR2I& b = pathOutline.CPoint( j + 1 );
771 
772  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
773  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
774 
775  if( Is_segment_a_circle( start3DU, end3DU ) )
776  {
777  float radius = line_thickness/2;
778 
779  if( radius > 0.0 ) // degenerated circles crash 3D viewer
780  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius, *aZoneContainer ) );
781  }
782  else
783  {
784  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, line_thickness,
785  *aZoneContainer ) );
786  }
787  }
788 
789  // Add holes (of the poly, ie: the open parts) for this outline
790  for( int h = 0; h < polyList.HoleCount( i ); ++h )
791  {
792  const SHAPE_LINE_CHAIN& pathHole = polyList.CHole( i, h );
793 
794  for( int j = 0; j < pathHole.PointCount(); j++ )
795  {
796  const VECTOR2I& a = pathHole.CPoint( j );
797  const VECTOR2I& b = pathHole.CPoint( j + 1 );
798 
799  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
800  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
801 
802  if( Is_segment_a_circle( start3DU, end3DU ) )
803  {
804  float radius = line_thickness/2;
805 
806  if( radius > 0.0 ) // degenerated circles crash 3D viewer
807  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius,
808  *aZoneContainer ) );
809  }
810  else
811  {
812  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, line_thickness,
813  *aZoneContainer ) );
814  }
815  }
816  }
817  }
818 }
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:635
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 (an zero-thickness chain of connected line segments).
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
bool GetFilledPolysUseThickness() const
Definition: zone.h:689

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_LEGACY::createBoard(), createLayers(), RENDER_3D_LEGACY::generate3dGrid(), RENDER_3D_LEGACY::generateHoles(), RENDER_3D_LEGACY::generateLayerList(), RENDER_3D_LEGACY::generateViasAndPads(), RENDER_3D_RAYTRACE::insertHole(), RENDER_3D_RAYTRACE::load3DModels(), RENDER_3D_RAYTRACE::Reload(), RENDER_3D_LEGACY::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:673
const wxSize & GetSize() const
Definition: pad.h:233
PAD_SHAPE GetShape() const
Definition: pad.h:170
Represent a polyline (an zero-thickness chain of connected line segments).
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:288
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 821 of file create_3Dgraphic_brd_items.cpp.

823 {
824  if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
825  {
826  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
827  -aPad->ShapePos().y * m_biuTo3Dunits );
828 
829  const int radius = aPad->GetSize().x / 2;
830  const float inner_radius = ( radius - aWidth / 2 ) * m_biuTo3Dunits;
831  const float outer_radius = ( radius + aWidth / 2 ) * m_biuTo3Dunits;
832 
833  aDstContainer->Add( new RING_2D( center3DU, inner_radius, outer_radius, *aPad ) );
834 
835  return;
836  }
837 
838  // For other shapes, add outlines as thick segments in polygon buffer
839  const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
840  const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
841 
842  for( int j = 0; j < path.PointCount(); j++ )
843  {
844  const VECTOR2I& a = path.CPoint( j );
845  const VECTOR2I& b = path.CPoint( j + 1 );
846 
847  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
848  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
849 
850  if( Is_segment_a_circle( start3DU, end3DU ) )
851  {
852  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
853  *aPad ) );
854  }
855  else
856  {
857  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
858  *aPad ) );
859  }
860  }
861 }
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
wxPoint ShapePos() const
Definition: pad.cpp:673
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 (an zero-thickness chain of connected line segments).
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:288

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 695 of file board_adapter.cpp.

696 {
698 
699  if( !m_board )
700  return false;
701 
702  bool success;
703 
704  if( m_board->IsFootprintHolder() )
705  {
706  if( !m_board->GetFirstFootprint() )
707  {
708  if( aErrorMsg )
709  *aErrorMsg = _( "No footprint loaded." );
710 
711  return false;
712  }
713 
714  int chainingEpsilon = Millimeter2iu( 0.02 ); // max dist from one endPt to next startPt
715 
718  chainingEpsilon );
719 
720  // Make polygon strictly simple to avoid issues (especially in 3D viewer)
722 
723  if( !success && aErrorMsg )
724  {
725  *aErrorMsg = _( "Footprint outline is missing or malformed. Run Footprint Checker for "
726  "a full analysis." );
727  }
728  }
729  else
730  {
732 
733  if( !success && aErrorMsg )
734  *aErrorMsg = _( "Board outline is missing or malformed. Run DRC for a full analysis." );
735  }
736 
737  return success;
738 }
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:1880
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:221
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:317
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 
210  {
211  SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET;
212  m_layers_poly[curr_layer_id] = layerPoly;
213  }
214  }
215 
217  {
220 
223 
224  }
225 
226  if( aStatusReporter )
227  aStatusReporter->Report( _( "Create tracks and vias" ) );
228 
229  // Create tracks as objects and add it to container
230  for( PCB_LAYER_ID curr_layer_id : layer_id )
231  {
232  wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
233 
234  BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
235 
236  // Add track segments shapes and via annulus shapes
237  unsigned int nTracks = trackList.size();
238 
239  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
240  {
241  const PCB_TRACK *track = trackList[trackIdx];
242 
243  // NOTE: Vias can be on multiple layers
244  if( !track->IsOnLayer( curr_layer_id ) )
245  continue;
246 
247  // Skip vias annulus when not connected on this layer (if removing is enabled)
248  const PCB_VIA *via = dyn_cast< const PCB_VIA*>( track );
249 
250  if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
251  continue;
252 
253  // Add object item to layer container
254  createTrack( track, layerContainer, 0.0f );
255  }
256  }
257 
258  // Create VIAS and THTs objects and add it to holes containers
259  for( PCB_LAYER_ID curr_layer_id : layer_id )
260  {
261  // ADD TRACKS
262  unsigned int nTracks = trackList.size();
263 
264  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
265  {
266  const PCB_TRACK *track = trackList[trackIdx];
267 
268  if( !track->IsOnLayer( curr_layer_id ) )
269  continue;
270 
271  // ADD VIAS and THT
272  if( track->Type() == PCB_VIA_T )
273  {
274  const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
275  const VIATYPE viatype = via->GetViaType();
276  const float holediameter = via->GetDrillValue() * BiuTo3dUnits();
277 
278  // holes and layer copper extend half info cylinder wall to hide transition
279  const float thickness = GetHolePlatingThickness() * BiuTo3dUnits() / 2.0f;
280  const float hole_inner_radius = holediameter / 2.0f;
281  const float ring_radius = via->GetWidth() * BiuTo3dUnits() / 2.0f;
282 
283  const SFVEC2F via_center( via->GetStart().x * m_biuTo3Dunits,
284  -via->GetStart().y * m_biuTo3Dunits );
285 
286  if( viatype != VIATYPE::THROUGH )
287  {
288 
289  // Add hole objects
290  BVH_CONTAINER_2D *layerHoleContainer = nullptr;
291 
292  // Check if the layer is already created
293  if( m_layerHoleMap.find( curr_layer_id ) == m_layerHoleMap.end() )
294  {
295  // not found, create a new container
296  layerHoleContainer = new BVH_CONTAINER_2D;
297  m_layerHoleMap[curr_layer_id] = layerHoleContainer;
298  }
299  else
300  {
301  // found
302  layerHoleContainer = m_layerHoleMap[curr_layer_id];
303  }
304 
305  // Add a hole for this layer
306  layerHoleContainer->Add( new FILLED_CIRCLE_2D( via_center,
307  hole_inner_radius + thickness,
308  *track ) );
309  }
310  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
311  {
312  // Add through hole object
313  m_throughHoleOds.Add( new FILLED_CIRCLE_2D( via_center,
314  hole_inner_radius + thickness,
315  *track ) );
316  m_throughHoleViaOds.Add( new FILLED_CIRCLE_2D( via_center,
317  hole_inner_radius + thickness,
318  *track ) );
319 
322  {
324  ring_radius,
325  *track ) );
326  }
327 
328  m_throughHoleIds.Add( new FILLED_CIRCLE_2D( via_center, hole_inner_radius,
329  *track ) );
330  }
331  }
332  }
333  }
334 
335  // Create VIAS and THTs objects and add it to holes containers
336  for( PCB_LAYER_ID curr_layer_id : layer_id )
337  {
338  // ADD TRACKS
339  const unsigned int nTracks = trackList.size();
340 
341  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
342  {
343  const PCB_TRACK *track = trackList[trackIdx];
344 
345  if( !track->IsOnLayer( curr_layer_id ) )
346  continue;
347 
348  // ADD VIAS and THT
349  if( track->Type() == PCB_VIA_T )
350  {
351  const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
352  const VIATYPE viatype = via->GetViaType();
353 
354  if( viatype != VIATYPE::THROUGH )
355  {
356  // Add PCB_VIA hole contours
357 
358  // Add outer holes of VIAs
359  SHAPE_POLY_SET *layerOuterHolesPoly = nullptr;
360  SHAPE_POLY_SET *layerInnerHolesPoly = nullptr;
361 
362  // Check if the layer is already created
363  if( m_layerHoleOdPolys.find( curr_layer_id ) ==
364  m_layerHoleOdPolys.end() )
365  {
366  // not found, create a new container
367  layerOuterHolesPoly = new SHAPE_POLY_SET;
368  m_layerHoleOdPolys[curr_layer_id] = layerOuterHolesPoly;
369 
370  wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) ==
371  m_layerHoleIdPolys.end() );
372 
373  layerInnerHolesPoly = new SHAPE_POLY_SET;
374  m_layerHoleIdPolys[curr_layer_id] = layerInnerHolesPoly;
375  }
376  else
377  {
378  // found
379  layerOuterHolesPoly = m_layerHoleOdPolys[curr_layer_id];
380 
381  wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) !=
382  m_layerHoleIdPolys.end() );
383 
384  layerInnerHolesPoly = m_layerHoleIdPolys[curr_layer_id];
385  }
386 
387  const int holediameter = via->GetDrillValue();
388  const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
389 
390  TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
391  hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
392 
393  TransformCircleToPolygon( *layerInnerHolesPoly, via->GetStart(),
394  holediameter / 2, ARC_HIGH_DEF, ERROR_INSIDE );
395  }
396  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
397  {
398  const int holediameter = via->GetDrillValue();
399  const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
400  const int hole_outer_ring_radius = via->GetWidth() / 2.0f;
401 
402  // Add through hole contours
404  hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
405 
406  // Add same thing for vias only
408  hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
409 
411  {
413  via->GetStart(), hole_outer_ring_radius,
414  ARC_HIGH_DEF, ERROR_INSIDE );
415  }
416  }
417  }
418  }
419  }
420 
421  // Creates vertical outline contours of the tracks and add it to the poly of the layer
424  {
425  for( PCB_LAYER_ID curr_layer_id : layer_id )
426  {
427  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
428 
429  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
430 
431  // ADD TRACKS
432  unsigned int nTracks = trackList.size();
433 
434  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
435  {
436  const PCB_TRACK *track = trackList[trackIdx];
437 
438  if( !track->IsOnLayer( curr_layer_id ) )
439  continue;
440 
441  // Skip vias annulus when not connected on this layer (if removing is enabled)
442  const PCB_VIA *via = dyn_cast<const PCB_VIA*>( track );
443 
444  if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
445  continue;
446 
447  // Add the track/via contour
448  track->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
449  ARC_HIGH_DEF, ERROR_INSIDE );
450  }
451  }
452  }
453 
454  // Add holes of footprints
455  for( FOOTPRINT* footprint : m_board->Footprints() )
456  {
457  for( PAD* pad : footprint->Pads() )
458  {
459  const wxSize padHole = pad->GetDrillSize();
460 
461  if( !padHole.x ) // Not drilled pad like SMD pad
462  continue;
463 
464  // The hole in the body is inflated by copper thickness, if not plated, no copper
465  const int inflate = ( pad->GetAttribute () != PAD_ATTRIB::NPTH ) ?
466  GetHolePlatingThickness() / 2 : 0;
467 
468  m_holeCount++;
469  m_averageHoleDiameter += ( ( pad->GetDrillSize().x +
470  pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
471 
473 
475  {
477  }
478 
480  }
481  }
482 
483  if( m_holeCount )
485 
486  // Add contours of the pad holes (pads can be Circle or Segment holes)
487  for( FOOTPRINT* footprint : m_board->Footprints() )
488  {
489  for( PAD* pad : footprint->Pads() )
490  {
491  const wxSize padHole = pad->GetDrillSize();
492 
493  if( !padHole.x ) // Not drilled pad like SMD pad
494  continue;
495 
496  // The hole in the body is inflated by copper thickness.
497  const int inflate = GetHolePlatingThickness();
498 
499  if( pad->GetAttribute () != PAD_ATTRIB::NPTH )
500  {
502  {
503  pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys,
504  inflate, ARC_HIGH_DEF, ERROR_INSIDE );
505  }
506 
507  pad->TransformHoleWithClearanceToPolygon( m_throughHoleOdPolys, inflate,
508  ARC_HIGH_DEF, ERROR_INSIDE );
509  }
510  else
511  {
512  // If not plated, no copper.
514  {
515  pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys, 0,
516  ARC_HIGH_DEF, ERROR_INSIDE );
517  }
518 
519  pad->TransformHoleWithClearanceToPolygon( m_nonPlatedThroughHoleOdPolys, 0,
520  ARC_HIGH_DEF, ERROR_INSIDE );
521  }
522  }
523  }
524 
525  const bool renderPlatedPadsAsPlated = GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) &&
527 
528  // Add footprints PADs objects to containers
529  for( PCB_LAYER_ID curr_layer_id : layer_id )
530  {
531  wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
532 
533  BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
534 
535  // ADD PADS
536  for( FOOTPRINT* footprint : m_board->Footprints() )
537  {
538  // Note: NPTH pads are not drawn on copper layers when the pad
539  // has same shape as its hole
540  addPadsWithClearance( footprint, layerContainer, curr_layer_id, 0,
541  true, renderPlatedPadsAsPlated, false );
542 
543  // Micro-wave footprints may have items on copper layers
544  addFootprintShapesWithClearance( footprint, layerContainer, curr_layer_id, 0 );
545  }
546  }
547 
548  if( renderPlatedPadsAsPlated )
549  {
550  // ADD PLATED PADS
551  for( FOOTPRINT* footprint : m_board->Footprints() )
552  {
553  addPadsWithClearance( footprint, m_platedPadsFront, F_Cu, 0, true, false, true );
554 
555  addPadsWithClearance( footprint, m_platedPadsBack, B_Cu, 0, true, false, true );
556  }
557 
560  }
561 
562  // Add footprints PADs poly contours (vertical outlines)
565  {
566  for( PCB_LAYER_ID curr_layer_id : layer_id )
567  {
568  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
569 
570  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
571 
572  // Add pads to polygon list
573  for( FOOTPRINT* footprint : m_board->Footprints() )
574  {
575  // Note: NPTH pads are not drawn on copper layers when the pad
576  // has same shape as its hole
577  footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id,
578  0, ARC_HIGH_DEF, ERROR_INSIDE,
579  true, renderPlatedPadsAsPlated,
580  false );
581 
582  transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
583  }
584  }
585 
586  if( renderPlatedPadsAsPlated )
587  {
588  // ADD PLATED PADS contours
589  for( FOOTPRINT* footprint : m_board->Footprints() )
590  {
591  footprint->TransformPadsWithClearanceToPolygon( *m_frontPlatedPadPolys, F_Cu,
592  0, ARC_HIGH_DEF, ERROR_INSIDE,
593  true, false, true );
594 
595  footprint->TransformPadsWithClearanceToPolygon( *m_backPlatedPadPolys, B_Cu,
596  0, ARC_HIGH_DEF, ERROR_INSIDE,
597  true, false, true );
598  }
599  }
600  }
601 
602  // Add graphic item on copper layers to object containers
603  for( PCB_LAYER_ID curr_layer_id : layer_id )
604  {
605  wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
606 
607  BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
608 
609  // Add graphic items on copper layers (texts and other graphics)
610  for( BOARD_ITEM* item : m_board->Drawings() )
611  {
612  if( !item->IsOnLayer( curr_layer_id ) )
613  continue;
614 
615  switch( item->Type() )
616  {
617  case PCB_SHAPE_T:
618  addShapeWithClearance( static_cast<PCB_SHAPE*>( item ), layerContainer,
619  curr_layer_id, 0 );
620  break;
621 
622  case PCB_TEXT_T:
623  addShapeWithClearance( static_cast<PCB_TEXT*>( item ), layerContainer,
624  curr_layer_id, 0 );
625  break;
626 
627  case PCB_DIM_ALIGNED_T:
628  case PCB_DIM_CENTER_T:
630  case PCB_DIM_LEADER_T:
631  addShapeWithClearance( static_cast<PCB_DIMENSION_BASE*>( item ),
632  layerContainer, curr_layer_id, 0 );
633  break;
634 
635  default:
636  wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
637  item->Type() );
638  break;
639  }
640  }
641  }
642 
643  // Add graphic item on copper layers to poly contours (vertical outlines)
646  {
647  for( PCB_LAYER_ID cur_layer_id : layer_id )
648  {
649  wxASSERT( m_layers_poly.find( cur_layer_id ) != m_layers_poly.end() );
650 
651  SHAPE_POLY_SET *layerPoly = m_layers_poly[cur_layer_id];
652 
653  // Add graphic items on copper layers (texts and other )
654  for( BOARD_ITEM* item : m_board->Drawings() )
655  {
656  if( !item->IsOnLayer( cur_layer_id ) )
657  continue;
658 
659  switch( item->Type() )
660  {
661  case PCB_SHAPE_T:
662  item->TransformShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
663  ARC_HIGH_DEF, ERROR_INSIDE );
664  break;
665 
666  case PCB_TEXT_T:
667  {
668  PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
669 
670  text->TransformTextShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
671  ARC_HIGH_DEF, ERROR_INSIDE );
672  }
673  break;
674 
675  default:
676  wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
677  item->Type() );
678  break;
679  }
680  }
681  }
682  }
683 
684  if( GetFlag( FL_ZONE ) )
685  {
686  if( aStatusReporter )
687  aStatusReporter->Report( _( "Create zones" ) );
688 
689  std::vector<std::pair<ZONE*, PCB_LAYER_ID>> zones;
690  std::unordered_map<PCB_LAYER_ID, std::unique_ptr<std::mutex>> layer_lock;
691 
692  for( ZONE* zone : m_board->Zones() )
693  {
694  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
695  {
696  zones.emplace_back( std::make_pair( zone, layer ) );
697  layer_lock.emplace( layer, std::make_unique<std::mutex>() );
698  }
699  }
700 
701  // Add zones objects
702  std::atomic<size_t> nextZone( 0 );
703  std::atomic<size_t> threadsFinished( 0 );
704 
705  size_t parallelThreadCount = std::min<size_t>( zones.size(),
706  std::max<size_t>( std::thread::hardware_concurrency(), 2 ) );
707 
708  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
709  {
710  std::thread t = std::thread( [&]()
711  {
712  for( size_t areaId = nextZone.fetch_add( 1 );
713  areaId < zones.size();
714  areaId = nextZone.fetch_add( 1 ) )
715  {
716  ZONE* zone = zones[areaId].first;
717 
718  if( zone == nullptr )
719  break;
720 
721  PCB_LAYER_ID layer = zones[areaId].second;
722 
723  auto layerContainer = m_layerMap.find( layer );
724  auto layerPolyContainer = m_layers_poly.find( layer );
725 
726  if( layerContainer != m_layerMap.end() )
727  {
728  addSolidAreasShapes( zone, layerContainer->second, layer );
729  }
730 
733  && layerPolyContainer != m_layers_poly.end() )
734  {
735  auto mut_it = layer_lock.find( layer );
736 
737  std::lock_guard< std::mutex > lock( *( mut_it->second ) );
738  zone->TransformSolidAreasShapesToPolygon( layer, *layerPolyContainer->second );
739  }
740  }
741 
742  threadsFinished++;
743  } );
744 
745  t.detach();
746  }
747 
748  while( threadsFinished < parallelThreadCount )
749  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
750 
751  }
752 
753  // Simplify layer polygons
754 
755  if( aStatusReporter )
756  aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
757 
760  {
762  {
763  if( m_frontPlatedPadPolys && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) )
764  {
765  if( aStatusReporter )
766  aStatusReporter->Report( _( "Simplifying polygons on F_Cu" ) );
767 
768  SHAPE_POLY_SET *layerPoly_F_Cu = m_layers_poly[F_Cu];
770 
772  }
773 
774  if( m_backPlatedPadPolys && ( m_layers_poly.find( B_Cu ) != m_layers_poly.end() ) )
775  {
776  if( aStatusReporter )
777  aStatusReporter->Report( _( "Simplifying polygons on B_Cu" ) );
778 
779  SHAPE_POLY_SET *layerPoly_B_Cu = m_layers_poly[B_Cu];
781 
783  }
784  }
785 
786  std::vector< PCB_LAYER_ID > &selected_layer_id = layer_id;
787  std::vector< PCB_LAYER_ID > layer_id_without_F_and_B;
788 
790  {
791  layer_id_without_F_and_B.clear();
792  layer_id_without_F_and_B.reserve( layer_id.size() );
793 
794  for( size_t i = 0; i < layer_id.size(); ++i )
795  {
796  if( ( layer_id[i] != F_Cu ) && ( layer_id[i] != B_Cu ) )
797  layer_id_without_F_and_B.push_back( layer_id[i] );
798  }
799 
800  selected_layer_id = layer_id_without_F_and_B;
801  }
802 
803  if( selected_layer_id.size() > 0 )
804  {
805  if( aStatusReporter )
806  aStatusReporter->Report( wxString::Format(
807  _( "Simplifying %d copper layers" ),
808  (int)selected_layer_id.size() ) );
809 
810  std::atomic<size_t> nextItem( 0 );
811  std::atomic<size_t> threadsFinished( 0 );
812 
813  size_t parallelThreadCount = std::min<size_t>(
814  std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
815  selected_layer_id.size() );
816 
817  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
818  {
819  std::thread t = std::thread(
820  [&nextItem, &threadsFinished, &selected_layer_id, this]()
821  {
822  for( size_t i = nextItem.fetch_add( 1 );
823  i < selected_layer_id.size();
824  i = nextItem.fetch_add( 1 ) )
825  {
826  auto layerPoly = m_layers_poly.find( selected_layer_id[i] );
827 
828  if( layerPoly != m_layers_poly.end() )
829  // This will make a union of all added contours
830  layerPoly->second->Simplify( SHAPE_POLY_SET::PM_FAST );
831  }
832 
833  threadsFinished++;
834  } );
835 
836  t.detach();
837  }
838 
839  while( threadsFinished < parallelThreadCount )
840  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
841  }
842  }
843 
844  // Simplify holes polygon contours
845  if( aStatusReporter )
846  aStatusReporter->Report( _( "Simplify holes contours" ) );
847 
848  for( PCB_LAYER_ID layer : layer_id )
849  {
850  if( m_layerHoleOdPolys.find( layer ) != m_layerHoleOdPolys.end() )
851  {
852  // found
853  SHAPE_POLY_SET *polyLayer = m_layerHoleOdPolys[layer];
854  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
855 
856  wxASSERT( m_layerHoleIdPolys.find( layer ) != m_layerHoleIdPolys.end() );
857 
858  polyLayer = m_layerHoleIdPolys[layer];
859  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
860  }
861  }
862 
863  // End Build Copper layers
864 
865  // This will make a union of all added contours
870 
871  // Build Tech layers
872  // Based on:
873  // https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
874  if( aStatusReporter )
875  aStatusReporter->Report( _( "Build Tech layers" ) );
876 
877  // draw graphic items, on technical layers
878  static const PCB_LAYER_ID teckLayerList[] = {
879  B_Adhes,
880  F_Adhes,
881  B_Paste,
882  F_Paste,
883  B_SilkS,
884  F_SilkS,
885  B_Mask,
886  F_Mask,
887 
888  // Aux Layers
889  Dwgs_User,
890  Cmts_User,
891  Eco1_User,
892  Eco2_User,
893  Edge_Cuts,
894  Margin
895  };
896 
897  // User layers are not drawn here, only technical layers
898  for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, arrayDim( teckLayerList ) );
899  seq;
900  ++seq )
901  {
902  const PCB_LAYER_ID curr_layer_id = *seq;
903 
904  if( !Is3dLayerEnabled( curr_layer_id ) )
905  continue;
906 
907  if( aStatusReporter )
908  aStatusReporter->Report( wxString::Format(
909  _( "Build Tech layer %d" ), (int)curr_layer_id ) );
910 
911  BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
912  m_layerMap[curr_layer_id] = layerContainer;
913 
914  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
915  m_layers_poly[curr_layer_id] = layerPoly;
916 
917  // Add drawing objects
918  for( BOARD_ITEM* item : m_board->Drawings() )
919  {
920  if( !item->IsOnLayer( curr_layer_id ) )
921  continue;
922 
923  switch( item->Type() )
924  {
925  case PCB_SHAPE_T:
926  addShapeWithClearance( static_cast<PCB_SHAPE*>( item ), layerContainer,
927  curr_layer_id, 0 );
928  break;
929 
930  case PCB_TEXT_T:
931  addShapeWithClearance( static_cast<PCB_TEXT*>( item ), layerContainer,
932  curr_layer_id, 0 );
933  break;
934 
935  case PCB_DIM_ALIGNED_T:
936  case PCB_DIM_CENTER_T:
938  case PCB_DIM_LEADER_T:
939  addShapeWithClearance( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer,
940  curr_layer_id, 0 );
941  break;
942 
943  default:
944  break;
945  }
946  }
947 
948  // Add drawing contours
949  for( BOARD_ITEM* item : m_board->Drawings() )
950  {
951  if( !item->IsOnLayer( curr_layer_id ) )
952  continue;
953 
954  switch( item->Type() )
955  {
956  case PCB_SHAPE_T:
957  item->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
958  ARC_HIGH_DEF, ERROR_INSIDE );
959  break;
960 
961  case PCB_TEXT_T:
962  {
963  PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
964 
965  text->TransformTextShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
966  ARC_HIGH_DEF, ERROR_INSIDE );
967  }
968  break;
969 
970  default:
971  break;
972  }
973  }
974 
975  // Add footprints tech layers - objects
976  for( FOOTPRINT* footprint : m_board->Footprints() )
977  {
978  if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) )
979  {
981 
982  for( PAD* pad : footprint->Pads() )
983  {
984  if( !pad->IsOnLayer( curr_layer_id ) )
985  continue;
986 
987  buildPadOutlineAsSegments( pad, layerContainer, linewidth );
988  }
989  }
990  else
991  {
992  addPadsWithClearance( footprint, layerContainer, curr_layer_id, 0,
993  false, false, false );
994  }
995 
996  addFootprintShapesWithClearance( footprint, layerContainer, curr_layer_id, 0 );
997  }
998 
999 
1000  // Add footprints tech layers - contours
1001  for( FOOTPRINT* footprint : m_board->Footprints() )
1002  {
1003  if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) )
1004  {
1006 
1007  for( PAD* pad : footprint->Pads() )
1008  {
1009  if( !pad->IsOnLayer( curr_layer_id ) )
1010  continue;
1011 
1012  buildPadOutlineAsPolygon( pad, *layerPoly, linewidth );
1013  }
1014  }
1015  else
1016  {
1017  footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
1018  ARC_HIGH_DEF, ERROR_INSIDE );
1019  }
1020 
1021  // On tech layers, use a poor circle approximation, only for texts (stroke font)
1022  footprint->TransformFPTextWithClearanceToPolygonSet( *layerPoly, curr_layer_id, 0,
1023  ARC_HIGH_DEF, ERROR_INSIDE );
1024 
1025  // Add the remaining things with dynamic seg count for circles
1026  transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
1027  }
1028 
1029 
1030  // Draw non copper zones
1031  if( GetFlag( FL_ZONE ) )
1032  {
1033  for( ZONE* zone : m_board->Zones() )
1034  {
1035  if( zone->IsOnLayer( curr_layer_id ) )
1036  addSolidAreasShapes( zone, layerContainer, curr_layer_id );
1037  }
1038 
1039  for( ZONE* zone : m_board->Zones() )
1040  {
1041  if( zone->IsOnLayer( curr_layer_id ) )
1042  zone->TransformSolidAreasShapesToPolygon( curr_layer_id, *layerPoly );
1043  }
1044  }
1045 
1046  // This will make a union of all added contours
1047  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1048  }
1049  // End Build Tech layers
1050 
1051  // Build BVH (Bounding volume hierarchy) for holes and vias
1052 
1053  if( aStatusReporter )
1054  aStatusReporter->Report( _( "Build BVH for holes and vias" ) );
1055 
1059 
1060  if( !m_layerHoleMap.empty() )
1061  {
1062  for( auto& hole : m_layerHoleMap )
1063  hole.second->BuildBVH();
1064  }
1065 
1066  // We only need the Solder mask to initialize the BVH
1067  // because..?
1068  if( m_layerMap[B_Mask] )
1069  m_layerMap[B_Mask]->BuildBVH();
1070 
1071  if( m_layerMap[F_Mask] )
1072  m_layerMap[F_Mask]->BuildBVH();
1073 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
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:239
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:773
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:320
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...
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:504
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:198
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:233
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...
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:465
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:796
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 elapset 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:236
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905
TRACKS & Tracks()
Definition: board.h:230
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:113
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_LEGACY, 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  PAD dummy( *aPad );
326  dummy.SetSize( aPad->GetSize() + clearance + clearance );
327  dummy.TransformShapeWithClearanceToPolygon( poly, aLayer, 0, ARC_HIGH_DEF, ERROR_INSIDE );
328  clearance = { 0, 0 };
329  }
330  else
331  {
332  auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
333 
334  for( const SHAPE* shape : padShapes->Shapes() )
335  {
336  switch( shape->Type() )
337  {
338  case SH_SEGMENT:
339  {
340  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape;
341  const SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
342  -seg->GetSeg().A.y * m_biuTo3Dunits );
343  const SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
344  -seg->GetSeg().B.y * m_biuTo3Dunits );
345  const int width = seg->GetWidth() + clearance.x * 2;
346 
347  // Cannot add segments that have the same start and end point
348  if( Is_segment_a_circle( start3DU, end3DU ) )
349  {
350  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU,
351  ( width / 2 ) * m_biuTo3Dunits,
352  *aPad ) );
353  }
354  else
355  {
356  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU,
357  width * m_biuTo3Dunits,
358  *aPad ) );
359  }
360  }
361  break;
362 
363  case SH_CIRCLE:
364  {
365  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape;
366  const int radius = circle->GetRadius() + clearance.x;
367  const SFVEC2F center( circle->GetCenter().x * m_biuTo3Dunits,
368  -circle->GetCenter().y * m_biuTo3Dunits );
369 
370  aDstContainer->Add( new FILLED_CIRCLE_2D( center, radius * m_biuTo3Dunits,
371  *aPad ) );
372  }
373  break;
374 
375  case SH_RECT:
376  {
377  SHAPE_RECT* rect = (SHAPE_RECT*) shape;
378 
379  poly.NewOutline();
380  poly.Append( rect->GetPosition() );
381  poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y );
382  poly.Append( rect->GetPosition() + rect->GetSize() );
383  poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y );
384  }
385  break;
386 
387  case SH_SIMPLE:
388  poly.AddOutline( static_cast<const SHAPE_SIMPLE*>( shape )->Vertices() );
389  break;
390 
391  case SH_POLY_SET:
392  poly = *(SHAPE_POLY_SET*) shape;
393  break;
394 
395  case SH_ARC:
396  {
397  SHAPE_ARC* arc = (SHAPE_ARC*) shape;
399 
400  for( int i = 0; i < l.SegmentCount(); i++ )
401  {
402  SHAPE_SEGMENT seg( l.Segment( i ).A, l.Segment( i ).B, arc->GetWidth() );
403  const SFVEC2F start3DU( seg.GetSeg().A.x * m_biuTo3Dunits,
404  -seg.GetSeg().A.y * m_biuTo3Dunits );
405  const SFVEC2F end3DU( seg.GetSeg().B.x * m_biuTo3Dunits,
406  -seg.GetSeg().B.y * m_biuTo3Dunits );
407  const int width = arc->GetWidth() + clearance.x * 2;
408 
409  // Cannot add segments that have the same start and end point
410  if( Is_segment_a_circle( start3DU, end3DU ) )
411  {
412  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU,
413  ( width / 2 ) * m_biuTo3Dunits,
414  *aPad ) );
415  }
416  else
417  {
418  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU,
419  width * m_biuTo3Dunits,
420  *aPad ) );
421  }
422  }
423  }
424  break;
425 
426  default:
427  wxFAIL_MSG( "BOARD_ADAPTER::createPadWithClearance no implementation for "
428  + SHAPE_TYPE_asString( shape->Type() ) );
429  break;
430  }
431  }
432  }
433 
434  if( !poly.IsEmpty() )
435  {
436  if( clearance.x )
437  poly.Inflate( clearance.x, 32 );
438 
439  // Add the PAD polygon
440  ConvertPolygonToTriangles( poly, *aDstContainer, m_biuTo3Dunits, *aPad );
441  }
442 }
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
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
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pad.cpp:297
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:498
Represent a polyline (an zero-thickness chain of connected line segments).
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 445 of file create_3Dgraphic_brd_items.cpp.

446 {
447  wxSize drillSize = aPad->GetDrillSize();
448 
449  if( !drillSize.x || !drillSize.y )
450  {
451  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createPadWithDrill - found an invalid pad" ) );
452  return nullptr;
453  }
454 
455  if( drillSize.x == drillSize.y ) // usual round hole
456  {
457  const int radius = ( drillSize.x / 2 ) + aInflateValue;
458 
459  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
460  -aPad->GetPosition().y * m_biuTo3Dunits );
461 
462  return new FILLED_CIRCLE_2D( center, radius * m_biuTo3Dunits, *aPad );
463 
464  }
465  else // Oblong hole
466  {
467  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
468  float width = seg->GetWidth() + aInflateValue * 2;
469 
470  SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
471  -seg->GetSeg().A.y * m_biuTo3Dunits );
472 
473  SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
474  -seg->GetSeg().B.y * m_biuTo3Dunits );
475 
476  return new ROUND_SEGMENT_2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
477  }
478 
479  return nullptr;
480 }
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Return a SHAPE object representing the pad's hole.
Definition: pad.cpp:306
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:282
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:963
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:969
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:113

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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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 336 of file board_adapter.cpp.

337 {
338  wxASSERT( aDiameter3DU > 0.0f );
339 
340  return GetCircleSegmentCount( (int)( aDiameter3DU / m_biuTo3Dunits ) );
341 }
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_LEGACY::addObjectTriangles(), addShapeWithClearance(), and RENDER_3D_LEGACY::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 344 of file board_adapter.cpp.

345 {
346  wxASSERT( aDiameterBIU > 0 );
347 
348  return GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, 360.0 );
349 }
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 776 of file board_adapter.cpp.

777 {
778  return SFVEC4F( aColor.r, aColor.g, aColor.b, aColor.a );
779 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
double a
Alpha component.
Definition: color4d.h:380
double r
Red component.
Definition: color4d.h:377

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

Referenced by RENDER_3D_LEGACY::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_LEGACY::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 294 of file board_adapter.cpp.

295 {
296  wxASSERT( aFlag < FL_LAST );
297 
298  return m_drawFlags[aFlag];
299 }
std::vector< bool > m_drawFlags

References FL_LAST, and m_drawFlags.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), createLayers(), EDA_3D_CONDITIONS::flagFunction(), RENDER_3D_LEGACY::generateViasAndPads(), GetFootprintZPos(), RENDER_3D_LEGACY::getLayerColor(), RENDER_3D_RAYTRACE::getModelMaterial(), InitSettings(), RENDER_3D_RAYTRACE::insertHole(), Is3dLayerEnabled(), IsFootprintShown(), RENDER_3D_RAYTRACE::load3DModels(), RENDER_3D_LEGACY::load3dModels(), EDA_3D_CANVAS::OnMouseWheel(), RENDER_3D_RAYTRACE::postProcessBlurFinish(), RENDER_3D_RAYTRACE::postProcessShading(), RENDER_3D_LEGACY::Redraw(), RENDER_3D_RAYTRACE::Reload(), RENDER_3D_LEGACY::reload(), RENDER_3D_LEGACY::render3dModels(), RENDER_3D_LEGACY::render3dModelsSelected(), RENDER_3D_RAYTRACE::renderAntiAliasPackets(), RENDER_3D_RAYTRACE::renderBlockTracing(), RENDER_3D_LEGACY::renderFootprint(), RENDER_3D_RAYTRACE::renderTracing(), RENDER_3D_LEGACY::setLayerMaterial(), RENDER_3D_RAYTRACE::setupMaterials(), RENDER_3D_LEGACY::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 741 of file board_adapter.cpp.

742 {
743  if( aIsFlipped )
744  {
745  if( GetFlag( FL_SOLDERPASTE ) )
747  else
749  }
750  else
751  {
752  if( GetFlag( FL_SOLDERPASTE ) )
753  return m_layerZcoordTop[F_SilkS];
754  else
755  return m_layerZcoordTop[F_Paste];
756  }
757 }
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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::reload().

◆ GetHolePlatingThickness()

int BOARD_ADAPTER::GetHolePlatingThickness ( ) const
noexcept

Get the current copper layer thickness.

Returns
thickness in board units.

Definition at line 329 of file board_adapter.cpp.

330 {
332  : 0.035 * PCB_IU_PER_MM;
333 }
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_LEGACY::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 770 of file board_adapter.cpp.

771 {
772  return GetColor( m_colors->GetColor( aItemId ) );
773 }
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_LEGACY::getLayerZPos(), RENDER_3D_RAYTRACE::insertHole(), RENDER_3D_LEGACY::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 760 of file board_adapter.cpp.

761 {
762  wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
763 
764  const COLOR4D color = m_colors->GetColor( aLayerId );
765 
766  return SFVEC4F( color.r, color.g, color.b, color.a );
767 }
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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::getLayerZPos(), RENDER_3D_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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_LEGACY::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 352 of file board_adapter.cpp.

353 {
354  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) );
355 
356  if( aStatusReporter )
357  aStatusReporter->Report( _( "Build board outline" ) );
358 
359  wxString msg;
360 
361  const bool succeedToGetBoardPolygon = createBoardPolygon( &msg );
362 
363  if( aWarningReporter )
364  {
365  if( !succeedToGetBoardPolygon )
366  aWarningReporter->Report( msg, RPT_SEVERITY_WARNING );
367  else
368  aWarningReporter->Report( wxEmptyString );
369  }
370 
371  // Calculates the board bounding box (board outlines + items)
372  // to ensure any item, even outside the board outlines can be seen
373  bool boardEdgesOnly = true;
374 
376  || !succeedToGetBoardPolygon )
377  {
378  boardEdgesOnly = false;
379  }
380 
381  EDA_RECT bbbox;
382 
383  if( m_board )
384  bbbox = m_board->ComputeBoundingBox( boardEdgesOnly );
385 
386  // Gives a non null size to avoid issues in zoom / scale calculations
387  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
388  bbbox.Inflate( Millimeter2iu( 10 ) );
389 
390  m_boardSize = bbbox.GetSize();
391  m_boardPos = bbbox.Centre();
392 
393  wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
394 
395  m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
396 
398 
399  // Ensure the board has 2 sides for 3D views, because it is hard to find
400  // a *really* single side board in the true life...
401  if( m_copperLayersCount < 2 )
403 
404  // Calculate the conversion to apply to all positions.
406 
409  : 1.6 * PCB_IU_PER_MM * m_biuTo3Dunits;
410 
411  // !TODO: use value defined by user (currently use default values by ctor
415 
416  // Init Z position of each layer
417  // calculate z position for each copper layer
418  // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
419  // Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
420  // all unused copper layer z position are set to 0
421 
422  // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
423  // | | Top = Bottom + m_copperThickness
424  // |__________________________________|
425  // == == == == <- Bottom = -m_epoxyThickness / 2.0,
426  // Top = Bottom - m_copperThickness
427 
428  unsigned int layer;
429 
430  for( layer = 0; layer < m_copperLayersCount; ++layer )
431  {
432  m_layerZcoordBottom[layer] = m_epoxyThickness3DU / 2.0f -
433  (m_epoxyThickness3DU * layer / (m_copperLayersCount - 1) );
434 
435  if( layer < (m_copperLayersCount / 2) )
437  else
439  }
440 
441  #define layerThicknessMargin 1.1
442  const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
443 
444  // Fill remaining unused copper layers and back layer zpos
445  // with -m_epoxyThickness / 2.0
446  for( ; layer < MAX_CU_LAYERS; layer++ )
447  {
448  m_layerZcoordBottom[layer] = -(m_epoxyThickness3DU / 2.0f);
450  }
451 
452  // This is the top of the copper layer thickness.
453  const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
454  const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
455 
456  // calculate z position for each non copper layer
457  // Solder mask and Solder paste have the same Z position
458  for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
459  {
460  float zposTop;
461  float zposBottom;
462 
463  switch( layer_id )
464  {
465  case B_Adhes:
466  zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
467  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
468  break;
469 
470  case F_Adhes:
471  zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
472  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
473  break;
474 
475  case B_Mask:
476  zposBottom = zpos_copperTop_back;
477  zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
478  break;
479 
480  case B_Paste:
481  zposBottom = zpos_copperTop_back;
482  zposTop = zpos_copperTop_back - m_solderPasteLayerThickness3DU;
483  break;
484 
485  case F_Mask:
486  zposBottom = zpos_copperTop_front;
487  zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
488  break;
489 
490  case F_Paste:
491  zposBottom = zpos_copperTop_front;
492  zposTop = zpos_copperTop_front + m_solderPasteLayerThickness3DU;
493  break;
494 
495  case B_SilkS:
496  zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
497  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
498  break;
499 
500  case F_SilkS:
501  zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
502  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
503  break;
504 
505  // !TODO: review
506  default:
507  zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
508  zposBottom = zposTop - m_nonCopperLayerThickness3DU;
509  break;
510  }
511 
512  m_layerZcoordTop[layer_id] = zposTop;
513  m_layerZcoordBottom[layer_id] = zposBottom;
514  }
515 
517 
519  0.0f );
520  boardSize /= 2.0f;
521 
522  SFVEC3F boardMin = ( m_boardCenter - boardSize );
523  SFVEC3F boardMax = ( m_boardCenter + boardSize );
524 
525  boardMin.z = m_layerZcoordTop[B_Adhes];
526  boardMax.z = m_layerZcoordTop[F_Adhes];
527 
528  m_boardBoundingBox = BBOX_3D( boardMin, boardMax );
529 
530 #ifdef PRINT_STATISTICS_3D_VIEWER
531  unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
532 #endif
533 
534  if( aStatusReporter )
535  aStatusReporter->Report( _( "Create layers" ) );
536 
537  createLayers( aStatusReporter );
538 
539  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
540 
541  auto to_SFVEC4F =
542  []( const COLOR4D& src )
543  {
544  return SFVEC4F( src.r, src.g, src.b, src.a );
545  };
546 
547  m_BgColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_TOP ) );
548  m_BgColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ) );
549 
550  m_SolderPasteColor = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERPASTE ) );
551 
552  if( m_board && colors->GetUseBoardStackupColors() )
553  {
555 
556  auto findColor =
557  []( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet )
558  {
559  if( aColorName.StartsWith( "#" ) )
560  {
561  return KIGFX::COLOR4D( wxColour( aColorName ) );
562  }
563  else
564  {
565  for( const CUSTOM_COLOR_ITEM& color : aColorSet )
566  {
567  if( color.m_ColorName == aColorName )
568  return color.m_Color;
569  }
570  }
571 
572  return KIGFX::COLOR4D();
573  };
574 
579 
580  KIGFX::COLOR4D bodyColor( 0, 0, 0, 0 );
581 
582  for( const BOARD_STACKUP_ITEM* stackupItem : stackup.GetList() )
583  {
584  wxString colorName = stackupItem->GetColor();
585 
586  switch( stackupItem->GetType() )
587  {
589  if( stackupItem->GetBrdLayerId() == F_SilkS )
590  m_SilkScreenColorTop = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
591  else
592  m_SilkScreenColorBot = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
593  break;
594 
596  if( stackupItem->GetBrdLayerId() == F_Mask )
597  m_SolderMaskColorTop = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
598  else
599  m_SolderMaskColorBot = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
600 
601  break;
602 
604  {
605  KIGFX::COLOR4D layerColor = COLOR4D::UNSPECIFIED;
606  const wxString& materialName = stackupItem->GetMaterial();
607 
608  if( materialName.StartsWith( "FR4" ) )
609  {
610  layerColor = findColor( "FR4 natural", g_BoardColors );
611  }
612  else if( materialName.IsSameAs( "PTFE" )
613  || materialName.IsSameAs( "Teflon" ) )
614  {
615  layerColor = findColor( "PTFE natural", g_BoardColors );
616  }
617  else if( materialName.IsSameAs( "Polyimide" )
618  || materialName.IsSameAs( "Kapton" ) )
619  {
620  layerColor = findColor( "Polyimide", g_BoardColors );
621  }
622  else if( materialName.IsSameAs( "Al" ) )
623  {
624  layerColor = findColor( "Aluminum", g_BoardColors );
625  }
626  else // A default color value for unknown dielectric material
627  // (i.e. an exotic name entered by hand)
628  {
629  layerColor = findColor( "FR4 natural", g_BoardColors );
630  }
631 
632  if( bodyColor == COLOR4D( 0, 0, 0, 0 ) )
633  bodyColor = layerColor;
634  else
635  bodyColor = bodyColor.Mix( layerColor, 1.0 - layerColor.a );
636 
637  bodyColor.a += ( 1.0 - bodyColor.a ) * layerColor.a / 2;
638  break;
639  }
640 
641  default:
642  break;
643  }
644  }
645 
646  if( bodyColor != COLOR4D( 0, 0, 0, 0 ) )
647  m_BoardBodyColor = to_SFVEC4F( bodyColor );
648  else
649  m_BoardBodyColor = to_SFVEC4F( g_DefaultBoardBody );
650 
651  const wxString& finishName = stackup.m_FinishType;
652 
653  if( finishName.EndsWith( "OSP" ) )
654  {
655  m_CopperColor = to_SFVEC4F( findColor( "Copper", g_FinishColors ) );
656  }
657  else if( finishName.EndsWith( "IG" )
658  || finishName.EndsWith( "gold" ) )
659  {
660  m_CopperColor = to_SFVEC4F( findColor( "Gold", g_FinishColors ) );
661  }
662  else if( finishName.StartsWith( "HAL" )
663  || finishName.StartsWith( "HASL" )
664  || finishName.EndsWith( "tin" )
665  || finishName.EndsWith( "nickel" ) )
666  {
667  m_CopperColor = to_SFVEC4F( findColor( "Tin", g_FinishColors ) );
668  }
669  else if( finishName.EndsWith( "silver" ) )
670  {
671  m_CopperColor = to_SFVEC4F( findColor( "Silver", g_FinishColors ) );
672  }
673  else
674  {
675  m_CopperColor = to_SFVEC4F( g_DefaultSurfaceFinish );
676  }
677  }
678  else
679  {
680  m_SilkScreenColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ) );
681  m_SilkScreenColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ) );
682  m_SolderMaskColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_BOTTOM ) );
683  m_SolderMaskColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_TOP ) );
684  m_CopperColor = to_SFVEC4F( colors->GetColor( LAYER_3D_COPPER ) );
685  m_BoardBodyColor = to_SFVEC4F( colors->GetColor( LAYER_3D_BOARD ) );
686  }
687 }
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:109
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:221
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:380
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:110
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 elapset 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:55
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1082
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:298
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:91
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_LEGACY::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 229 of file board_adapter.cpp.

230 {
231  wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
232 
233  if( m_board && !m_board->IsLayerEnabled( aLayer ) )
234  return false;
235 
236  // see if layer needs to be shown
237  // check the flags
238  switch( aLayer )
239  {
240  case B_Adhes:
241  case F_Adhes:
242  return GetFlag( FL_ADHESIVE );
243 
244  case B_Paste:
245  case F_Paste:
246  return GetFlag( FL_SOLDERPASTE );
247 
248  case B_SilkS:
249  case F_SilkS:
250  return GetFlag( FL_SILKSCREEN );
251 
252  case B_Mask:
253  case F_Mask:
254  return GetFlag( FL_SOLDERMASK );
255 
256  case Dwgs_User:
257  case Cmts_User:
259  return false;
260 
261  return GetFlag( FL_COMMENTS );
262 
263  case Eco1_User:
264  case Eco2_User:
266  return false;
267 
268  return GetFlag( FL_ECO );
269 
270  case Edge_Cuts:
272  return false;
273 
274  return true;
275 
276  case Margin:
278  return false;
279 
280  return true;
281 
282  case B_Cu:
283  case F_Cu:
285  : true;
286 
287  default:
288  // the layer is an internal copper layer, used the visibility
289  return m_board && m_board->IsLayerVisible( aLayer );
290  }
291 }
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_LEGACY::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 310 of file board_adapter.cpp.

311 {
312  if( aFPAttributes & FP_SMD )
314  else if( aFPAttributes & FP_THROUGH_HOLE )
316  else
318 }
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_LEGACY::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 302 of file board_adapter.cpp.

303 {
304  wxASSERT( aFlag < FL_LAST );
305 
306  m_drawFlags[aFlag] = aState;
307 }
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 559 of file create_3Dgraphic_brd_items.cpp.

563 {
564  wxPoint arc_start, arc_end;
565  int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
566 
567  arc_end = arc_start = aStart;
568 
569  if( aArcAngle != 3600 )
570  {
571  RotatePoint( &arc_end, aCentre, -aArcAngle );
572  }
573 
574  if( aArcAngle < 0 )
575  {
576  std::swap( arc_start, arc_end );
577  aArcAngle = -aArcAngle;
578  }
579 
580  // Compute the ends of segments and creates poly
581  wxPoint curr_end = arc_start;
582  wxPoint curr_start = arc_start;
583 
584  for( int ii = delta; ii < aArcAngle; ii += delta )
585  {
586  curr_end = arc_start;
587  RotatePoint( &curr_end, aCentre, -ii );
588 
589  const SFVEC2F start3DU( curr_start.x * m_biuTo3Dunits, -curr_start.y * m_biuTo3Dunits );
590  const SFVEC2F end3DU ( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
591 
592  if( Is_segment_a_circle( start3DU, end3DU ) )
593  {
594  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
595  aBoardItem ) );
596  }
597  else
598  {
599  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
600  aBoardItem ) );
601  }
602 
603  curr_start = curr_end;
604  }
605 
606  if( curr_end != arc_end )
607  {
608  const SFVEC2F start3DU( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
609  const SFVEC2F end3DU ( arc_end.x * m_biuTo3Dunits, -arc_end.y * m_biuTo3Dunits );
610 
611  if( Is_segment_a_circle( start3DU, end3DU ) )
612  {
613  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
614  aBoardItem ) );
615  }
616  else
617  {
618  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
619  aBoardItem ) );
620  }
621  }
622 }
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:171