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 (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
 

Private Member Functions

bool createBoardPolygon (wxString *aErrorMsg)
 Create the board outline polygon. More...
 
void createLayers (REPORTER *aStatusReporter)
 
void destroyLayers ()
 
void createTrack (const TRACK *aTrack, CONTAINER_2D_BASE *aDstContainer, int aClearanceValue)
 
void createPadWithClearance (const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, 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 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
 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 67 of file board_adapter.h.

Constructor & Destructor Documentation

◆ BOARD_ADAPTER()

BOARD_ADAPTER::BOARD_ADAPTER ( )

Definition at line 52 of file board_adapter.cpp.

52  :
53  m_board( nullptr ),
54  m_3dModelManager( nullptr ),
55  m_colors( nullptr ),
58 {
59  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
60 
63  m_drawFlags.resize( FL_LAST, false );
64 
65  if( PgmOrNull() )
66  m_colors = Pgm().GetSettingsManager().GetColorSettings();
67 
70 
71  m_boardPos = wxPoint();
72  m_boardSize = wxSize();
73  m_boardCenter = SFVEC3F( 0.0f );
74 
76 
80 
82  m_epoxyThickness3DU = 0.0f;
83  m_copperThickness3DU = 0.0f;
85  m_biuTo3Dunits = 1.0;
86 
87  m_trackCount = 0;
88  m_viaCount = 0;
90  m_holeCount = 0;
91  m_averageHoleDiameter = 0.0f;
92  m_averageTrackWidth = 0.0f;
93 
96  SetFlag( FL_SHOW_BOARD_BODY, true );
101  SetFlag( FL_ZONE, true );
102  SetFlag( FL_SILKSCREEN, true );
103  SetFlag( FL_SOLDERMASK, true );
105 
111 
112  SetFlag( FL_USE_SELECTION, true );
113 
114  m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
115  m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );
116  m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 0.9 );
117  m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
118  m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
119  m_SolderPasteColor = SFVEC4F( 0.4, 0.4, 0.4, 1.0 );
120  m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
121  m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
122  m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
123 
124  m_platedPadsFront = nullptr;
125  m_platedPadsBack = nullptr;
126 
127  m_frontPlatedPadPolys = nullptr;
128  m_backPlatedPadPolys = nullptr;
129 
130  // Avoid raytracing options not initialized:
134 
135  m_RtSpreadShadows = 0.0;
136  m_RtSpreadReflections = 0.0;
137  m_RtSpreadRefractions = 0.0;
138 
141 }
BVH_CONTAINER_2D * m_platedPadsFront
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.
BVH_CONTAINER_2D m_throughHoleIds
List of through hole vias with the radius of the hole inflated with the copper thickness.
float m_nonCopperLayerThickness3DU
Number of tracks in the board.
SHAPE_POLY_SET * m_frontPlatedPadPolys
float m_averageHoleDiameter
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
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 )
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.
float m_copperThickness3DU
Epoxy thickness in 3D units.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
float m_RtSpreadRefractions
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.
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:112
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.
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.
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
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 )
ANTIALIASING_MODE m_antiAliasingMode
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-initialized it.
Definition: bbox_3d.cpp:95
int m_RtReflectionSampleCount
unsigned int m_holeCount
Computed average diameter of the holes in 3D units.

References AA_8X, BVH_CONTAINER_2D::Clear(), FL_CLIP_SILK_ON_VIA_ANNULUS, FL_FP_ATTRIBUTES_NORMAL, FL_FP_ATTRIBUTES_NORMAL_INSERT, FL_FP_ATTRIBUTES_VIRTUAL, 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, 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_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 144 of file board_adapter.cpp.

145 {
146  destroyLayers();
147 }

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

183 {
184  std::vector<FP_TEXT*> texts; // List of FP_TEXT to convert
185  FP_SHAPE* outline;
186 
187  for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
188  {
189  switch( item->Type() )
190  {
191  case PCB_FP_TEXT_T:
192  {
193  FP_TEXT* text = static_cast<FP_TEXT*>( item );
194 
195  if( text->GetLayer() == aLayerId && text->IsVisible() )
196  texts.push_back( text );
197  }
198  break;
199 
200 
201  case PCB_FP_SHAPE_T:
202  {
203  outline = (FP_SHAPE*) item;
204 
205  if( outline->GetLayer() != aLayerId )
206  break;
207 
208  addShapeWithClearance( (const PCB_SHAPE*) outline, aDstContainer, aLayerId, 0 );
209  }
210  break;
211 
212  default:
213  break;
214  }
215  }
216 
217  // Convert texts for footprints
218  if( aFootprint->Reference().GetLayer() == aLayerId && aFootprint->Reference().IsVisible() )
219  texts.push_back( &aFootprint->Reference() );
220 
221  if( aFootprint->Value().GetLayer() == aLayerId && aFootprint->Value().IsVisible() )
222  texts.push_back( &aFootprint->Value() );
223 
224  s_boardItem = (const BOARD_ITEM *)&aFootprint->Value();
225  s_dstcontainer = aDstContainer;
227 
228  for( FP_TEXT* text : texts )
229  {
230  s_textWidth = text->GetEffectiveTextPenWidth() + ( 2 * aInflateValue );
231  wxSize size = text->GetTextSize();
232  bool forceBold = true;
233  int penWidth = 0; // force max width for bold
234 
235  if( text->IsMirrored() )
236  size.x = -size.x;
237 
238  GRText( nullptr, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(),
239  size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(),
240  forceBold, addTextSegmToContainer );
241  }
242 }
virtual double GetDrawRotation() const override
Definition: fp_text.cpp:247
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:206
bool IsMirrored() const
Definition: eda_text.h:196
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:82
bool IsVisible() const
Definition: eda_text.h:193
static CONTAINER_2D_BASE * s_dstcontainer
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
Definition: color4d.h:44
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:482
static int s_textWidth
bool IsItalic() const
Definition: eda_text.h:187
FP_TEXT & Reference()
Definition: footprint.h:483
void addShapeWithClearance(const PCB_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
static float s_biuTo3Dunits
const wxSize & GetTextSize() const
Definition: eda_text.h:245
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
DRAWINGS & GraphicalItems()
Definition: footprint.h:185
void GRText(wxDC *aDC, const wxPoint &aPos, 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)
Function GRText Draw a graphic text (like footprint texts)
Definition: gr_text.cpp:131
void addTextSegmToContainer(int x0, int y0, int xf, int yf, void *aData)
const wxPoint & GetTextPos() const
Definition: eda_text.h:254
static const BOARD_ITEM * s_boardItem
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: fp_text.cpp:408
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:173

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

471 {
472  for( PAD* pad : aFootprint->Pads() )
473  {
474  if( !pad->IsOnLayer( aLayerId ) )
475  continue;
476 
477  // Skip pad annulus when not connected on this layer (if removing is enabled)
478  if( !pad->FlashLayer( aLayerId ) && IsCopperLayer( aLayerId ) )
479  continue;
480 
481  // NPTH pads are not drawn on layers if the
482  // shape size and pos is the same as their hole:
483  if( aSkipNPTHPadsWihNoCopper && ( pad->GetAttribute() == PAD_ATTRIB_NPTH ) )
484  {
485  if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == wxPoint( 0, 0 ) )
486  {
487  switch( pad->GetShape() )
488  {
489  case PAD_SHAPE_CIRCLE:
490  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
491  continue;
492  break;
493 
494  case PAD_SHAPE_OVAL:
495  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
496  continue;
497  break;
498 
499  default:
500  break;
501  }
502  }
503  }
504 
505  const bool isPlated = ( ( aLayerId == F_Cu ) && pad->FlashLayer( F_Mask ) ) ||
506  ( ( aLayerId == B_Cu ) && pad->FlashLayer( B_Mask ) );
507 
508  if( aSkipPlatedPads && isPlated )
509  continue;
510 
511  if( aSkipNonPlatedPads && !isPlated )
512  continue;
513 
514  wxSize margin( aInflateValue, aInflateValue );
515 
516  switch( aLayerId )
517  {
518  case F_Mask:
519  case B_Mask:
520  margin.x += pad->GetSolderMaskMargin();
521  margin.y += pad->GetSolderMaskMargin();
522  break;
523 
524  case F_Paste:
525  case B_Paste:
526  margin += pad->GetSolderPasteMargin();
527  break;
528 
529  default:
530  break;
531  }
532 
533  createPadWithClearance( pad, aDstContainer, aLayerId, margin );
534  }
535 }
void createPadWithClearance(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, wxSize aClearanceValue) const
static void isPlated(LIBEVAL::CONTEXT *aCtx, void *self)
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
PADS & Pads()
Definition: footprint.h:182
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: pad.h:60

References B_Cu, B_Mask, B_Paste, createPadWithClearance(), F_Cu, F_Mask, F_Paste, IsCopperLayer(), isPlated(), PAD_ATTRIB_NPTH, PAD_DRILL_SHAPE_CIRCLE, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, 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 85 of file create_3Dgraphic_brd_items.cpp.

87 {
88  wxSize size = aText->GetTextSize();
89 
90  if( aText->IsMirrored() )
91  size.x = -size.x;
92 
93  s_boardItem = (const BOARD_ITEM *) &aText;
94  s_dstcontainer = aDstContainer;
95  s_textWidth = aText->GetEffectiveTextPenWidth() + ( 2 * aClearanceValue );
97 
98  // not actually used, but needed by GRText
99  const COLOR4D dummy_color = COLOR4D::BLACK;
100  bool forceBold = true;
101  int penWidth = 0; // force max width for bold
102 
103  if( aText->IsMultilineAllowed() )
104  {
105  wxArrayString strings_list;
106  wxStringSplit( aText->GetShownText(), strings_list, '\n' );
107  std::vector<wxPoint> positions;
108  positions.reserve( strings_list.Count() );
109  aText->GetLinePositions( positions, strings_list.Count() );
110 
111  for( unsigned ii = 0; ii < strings_list.Count(); ++ii )
112  {
113  wxString txt = strings_list.Item( ii );
114 
115  GRText( nullptr, positions[ii], dummy_color, txt, aText->GetTextAngle(), size,
116  aText->GetHorizJustify(), aText->GetVertJustify(), penWidth,
117  aText->IsItalic(), forceBold, addTextSegmToContainer );
118  }
119  }
120  else
121  {
122  GRText( nullptr, aText->GetTextPos(), dummy_color, aText->GetShownText(),
123  aText->GetTextAngle(), size, aText->GetHorizJustify(), aText->GetVertJustify(),
124  penWidth, aText->IsItalic(), forceBold, addTextSegmToContainer );
125  }
126 }
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:206
bool IsMirrored() const
Definition: eda_text.h:196
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
double GetTextAngle() const
Definition: eda_text.h:181
static CONTAINER_2D_BASE * s_dstcontainer
Definition: color4d.h:44
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
static int s_textWidth
bool IsItalic() const
Definition: eda_text.h:187
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:52
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
static float s_biuTo3Dunits
const wxSize & GetTextSize() const
Definition: eda_text.h:245
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
bool IsMultilineAllowed() const
Definition: eda_text.h:203
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: string.cpp:807
void GRText(wxDC *aDC, const wxPoint &aPos, 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)
Function GRText Draw a graphic text (like footprint texts)
Definition: gr_text.cpp:131
void GetLinePositions(std::vector< wxPoint > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition: eda_text.cpp:424
void addTextSegmToContainer(int x0, int y0, int xf, int yf, void *aData)
const wxPoint & GetTextPos() const
Definition: eda_text.h:254
static const BOARD_ITEM * s_boardItem
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

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

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

612 {
613  // The full width of the lines to create
614  // The extra 1 protects the inner/outer radius values from degeneracy
615  const int linewidth = aShape->GetWidth() + ( 2 * aClearanceValue ) + 1;
616 
617  switch( aShape->GetShape() )
618  {
619  case S_CIRCLE:
620  {
621  const SFVEC2F center3DU( aShape->GetCenter().x * m_biuTo3Dunits,
622  -aShape->GetCenter().y * m_biuTo3Dunits );
623 
624  float inner_radius = ( aShape->GetRadius() - linewidth / 2 ) * m_biuTo3Dunits;
625  float outer_radius = ( aShape->GetRadius() + linewidth / 2 ) * m_biuTo3Dunits;
626 
627  if( inner_radius < 0 )
628  inner_radius = 0;
629 
630  if( aShape->IsFilled() )
631  aDstContainer->Add( new FILLED_CIRCLE_2D( center3DU, outer_radius, *aShape ) );
632  else
633  aDstContainer->Add( new RING_2D( center3DU, inner_radius, outer_radius, *aShape ) );
634  }
635  break;
636 
637  case S_RECT:
638  if( aShape->IsFilled() )
639  {
640  SHAPE_POLY_SET polyList;
641 
642  aShape->TransformShapeWithClearanceToPolygon( polyList, aLayerId, 0,
643  ARC_HIGH_DEF, ERROR_INSIDE );
644 
645  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
646 
647  ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aShape );
648  }
649  else
650  {
651  std::vector<wxPoint> pts = aShape->GetRectCorners();
652 
653  const SFVEC2F topLeft3DU( pts[0].x * m_biuTo3Dunits, -pts[0].y * m_biuTo3Dunits );
654  const SFVEC2F topRight3DU( pts[1].x * m_biuTo3Dunits, -pts[1].y * m_biuTo3Dunits );
655  const SFVEC2F botRight3DU( pts[2].x * m_biuTo3Dunits, -pts[2].y * m_biuTo3Dunits );
656  const SFVEC2F botLeft3DU( pts[3].x * m_biuTo3Dunits, -pts[3].y * m_biuTo3Dunits );
657 
658  aDstContainer->Add( new ROUND_SEGMENT_2D( topLeft3DU, topRight3DU,
659  linewidth * m_biuTo3Dunits, *aShape ) );
660  aDstContainer->Add( new ROUND_SEGMENT_2D( topRight3DU, botRight3DU,
661  linewidth * m_biuTo3Dunits, *aShape ) );
662  aDstContainer->Add( new ROUND_SEGMENT_2D( botRight3DU, botLeft3DU,
663  linewidth * m_biuTo3Dunits, *aShape ) );
664  aDstContainer->Add( new ROUND_SEGMENT_2D( botLeft3DU, topLeft3DU,
665  linewidth * m_biuTo3Dunits, *aShape ) );
666  }
667  break;
668 
669  case S_ARC:
670  {
671  unsigned int segCount = GetCircleSegmentCount( aShape->GetBoundingBox().GetSizeMax() );
672 
673  transformArcToSegments( aShape->GetCenter(), aShape->GetArcStart(), aShape->GetAngle(),
674  segCount, linewidth, aDstContainer, *aShape );
675  }
676  break;
677 
678  case S_SEGMENT:
679  {
680  const SFVEC2F start3DU( aShape->GetStart().x * m_biuTo3Dunits,
681  -aShape->GetStart().y * m_biuTo3Dunits );
682 
683  const SFVEC2F end3DU ( aShape->GetEnd().x * m_biuTo3Dunits,
684  -aShape->GetEnd().y * m_biuTo3Dunits );
685 
686  if( Is_segment_a_circle( start3DU, end3DU ) )
687  {
688  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( linewidth / 2 ) * m_biuTo3Dunits,
689  *aShape ) );
690  }
691  else
692  {
693  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, linewidth * m_biuTo3Dunits,
694  *aShape ) );
695  }
696  }
697  break;
698 
699  case S_CURVE:
700  case S_POLYGON:
701  {
702  SHAPE_POLY_SET polyList;
703 
704  aShape->TransformShapeWithClearanceToPolygon( polyList, aLayerId, 0,
705  ARC_HIGH_DEF, ERROR_INSIDE );
706 
707  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
708 
709  if( polyList.IsEmpty() ) // Just for caution
710  break;
711 
712  ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aShape );
713  }
714  break;
715 
716  default:
717  wxFAIL_MSG( "BOARD_ADAPTER::addShapeWithClearance no implementation for "
718  + PCB_SHAPE_TYPE_T_asString( aShape->GetShape() ) );
719  break;
720  }
721 }
bool IsFilled() const
Definition: pcb_shape.h:96
void ConvertPolygonToTriangles(SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Definition: pcb_shape.h:155
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Definition: pcb_shape.h:200
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:945
int GetWidth() const
Definition: pcb_shape.h:118
void transformArcToSegments(const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM &aBoardItem)
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:54
usual segment : line with rounded ends
Definition: board_item.h:50
Arcs (with rounded ends)
Definition: board_item.h:52
segment with non rounded ends
Definition: board_item.h:51
wxPoint GetArcStart() const
Definition: pcb_shape.h:178
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SHAPE_POLY_SET.
static wxString PCB_SHAPE_TYPE_T_asString(PCB_SHAPE_TYPE_T a)
Definition: board_item.h:59
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.cpp:343
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
Definition: pcb_shape.h:144
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Check if segment start and end is very close to each other.
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.cpp:547
double GetAngle() const
Definition: pcb_shape.h:126
ring
Definition: board_item.h:53
PCB_SHAPE_TYPE_T GetShape() const
Definition: pcb_shape.h:129
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 draw segment to a closed polygon Used in fi...
Bezier Curve.
Definition: board_item.h:55
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
int GetSizeMax() const
Definition: eda_rect.h:101

References CONTAINER_2D_BASE::Add(), ConvertPolygonToTriangles(), ERROR_INSIDE, PCB_SHAPE::GetAngle(), PCB_SHAPE::GetArcStart(), PCB_SHAPE::GetBoundingBox(), PCB_SHAPE::GetCenter(), GetCircleSegmentCount(), PCB_SHAPE::GetEnd(), PCB_SHAPE::GetRadius(), PCB_SHAPE::GetRectCorners(), PCB_SHAPE::GetShape(), EDA_RECT::GetSizeMax(), PCB_SHAPE::GetStart(), PCB_SHAPE::GetWidth(), Is_segment_a_circle(), SHAPE_POLY_SET::IsEmpty(), PCB_SHAPE::IsFilled(), m_biuTo3Dunits, PCB_SHAPE_TYPE_T_asString(), SHAPE_POLY_SET::PM_FAST, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, SHAPE_POLY_SET::Simplify(), transformArcToSegments(), and PCB_SHAPE::TransformShapeWithClearanceToPolygon().

◆ addShapeWithClearance() [3/3]

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

Definition at line 129 of file create_3Dgraphic_brd_items.cpp.

132 {
133  addShapeWithClearance( &aDimension->Text(), aDstContainer, aLayerId, aClearanceValue );
134 
135  const int linewidth = aDimension->GetLineThickness() + ( 2 * aClearanceValue );
136 
137  for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
138  {
139  switch( shape->Type() )
140  {
141  case SH_SEGMENT:
142  {
143  const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
144 
145  const SFVEC2F start3DU( seg.A.x * m_biuTo3Dunits, -seg.A.y * m_biuTo3Dunits );
146 
147  const SFVEC2F end3DU( seg.B.x * m_biuTo3Dunits, -seg.B.y * m_biuTo3Dunits );
148 
149  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, linewidth * m_biuTo3Dunits,
150  *aDimension ) );
151  break;
152  }
153 
154  case SH_CIRCLE:
155  {
156  int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
157  int deltar = aDimension->GetLineThickness();
158 
159  SFVEC2F center( shape->Centre().x * m_biuTo3Dunits,
160  shape->Centre().y * m_biuTo3Dunits );
161 
162  aDstContainer->Add( new RING_2D( center, ( radius - deltar ) * m_biuTo3Dunits,
163  ( radius + deltar ) * m_biuTo3Dunits, *aDimension ) );
164 
165  break;
166  }
167 
168  default:
169  break;
170  }
171 
172  }
173 
174 }
int GetLineThickness() const
Definition: dimension.h:187
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)
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
Definition: dimension.h:215
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
PCB_TEXT & Text()
Definition: dimension.h:209
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
line chain (polyline)
Definition: shape.h:46
Definition: seg.h:39
VECTOR2I A
Definition: seg.h:47
axis-aligned rectangle
Definition: shape.h:44
VECTOR2I B
Definition: seg.h:48

References SEG::A, CONTAINER_2D_BASE::Add(), addShapeWithClearance(), SEG::B, DIMENSION_BASE::GetLineThickness(), DIMENSION_BASE::GetShapes(), m_biuTo3Dunits, SH_CIRCLE, SH_SEGMENT, 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 727 of file create_3Dgraphic_brd_items.cpp.

729 {
730  // Copy the polys list because we have to simplify it
731  SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList( aLayerId ) );
732 
733  // This convert the poly in outline and holes
734  ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aZoneContainer );
735 
736  // add filled areas outlines, which are drawn with thick lines segments
737  // but only if filled polygons outlines have thickness
738  if( !aZoneContainer->GetFilledPolysUseThickness() )
739  return;
740 
741  float line_thickness = aZoneContainer->GetMinThickness() * m_biuTo3Dunits;
742 
743  for( int i = 0; i < polyList.OutlineCount(); ++i )
744  {
745  // Add outline
746  const SHAPE_LINE_CHAIN& pathOutline = polyList.COutline( i );
747 
748  for( int j = 0; j < pathOutline.PointCount(); ++j )
749  {
750  const VECTOR2I& a = pathOutline.CPoint( j );
751  const VECTOR2I& b = pathOutline.CPoint( j + 1 );
752 
753  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
754  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
755 
756  if( Is_segment_a_circle( start3DU, end3DU ) )
757  {
758  float radius = line_thickness/2;
759 
760  if( radius > 0.0 ) // degenerated circles crash 3D viewer
761  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius, *aZoneContainer ) );
762  }
763  else
764  {
765  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, line_thickness,
766  *aZoneContainer ) );
767  }
768  }
769 
770  // Add holes (of the poly, ie: the open parts) for this outline
771  for( int h = 0; h < polyList.HoleCount( i ); ++h )
772  {
773  const SHAPE_LINE_CHAIN& pathHole = polyList.CHole( i, h );
774 
775  for( int j = 0; j < pathHole.PointCount(); j++ )
776  {
777  const VECTOR2I& a = pathHole.CPoint( j );
778  const VECTOR2I& b = pathHole.CPoint( j + 1 );
779 
780  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
781  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
782 
783  if( Is_segment_a_circle( start3DU, end3DU ) )
784  {
785  float radius = line_thickness/2;
786 
787  if( radius > 0.0 ) // degenerated circles crash 3D viewer
788  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius,
789  *aZoneContainer ) );
790  }
791  else
792  {
793  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, line_thickness,
794  *aZoneContainer ) );
795  }
796  }
797  }
798  }
799 }
void ConvertPolygonToTriangles(SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
int OutlineCount() const
Returns the number of outlines in the set
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: zone.h:655
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int PointCount() const
Function PointCount()
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
const VECTOR2I & CPoint(int aIndex) const
Function Point()
int GetMinThickness() const
Definition: zone.h:247
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SHAPE_POLY_SET.
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
Returns the number of holes in a given outline
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
bool GetFilledPolysUseThickness() const
Definition: zone.h:712

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 158 of file board_adapter.h.

159  {
160  return m_biuTo3Dunits;
161  }
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::loadModels(), 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 }
PAD_SHAPE_T GetShape() const
Definition: pad.h:162
int PointCount() const
Function PointCount()
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
convert a oblong shape to a polygon, using multiple segments It is similar to TransformRoundedEndsSeg...
const VECTOR2I & CPoint(int aIndex) const
Function Point()
wxPoint ShapePos() const
Definition: pcbnew/pad.cpp:663
const wxSize & GetSize() const
Definition: pad.h:229
SHAPE_LINE_CHAIN.
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pcbnew/pad.cpp:274
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aWidth, int aError, ERROR_LOC aErrorLoc)
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segme...

References SHAPE_LINE_CHAIN::CPoint(), ERROR_INSIDE, PAD::GetEffectivePolygon(), PAD::GetShape(), PAD::GetSize(), PAD_SHAPE_CIRCLE, SHAPE_LINE_CHAIN::PointCount(), 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 802 of file create_3Dgraphic_brd_items.cpp.

804 {
805  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
806  {
807  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
808  -aPad->ShapePos().y * m_biuTo3Dunits );
809 
810  const int radius = aPad->GetSize().x / 2;
811  const float inner_radius = ( radius - aWidth / 2 ) * m_biuTo3Dunits;
812  const float outer_radius = ( radius + aWidth / 2 ) * m_biuTo3Dunits;
813 
814  aDstContainer->Add( new RING_2D( center3DU, inner_radius, outer_radius, *aPad ) );
815 
816  return;
817  }
818 
819  // For other shapes, add outlines as thick segments in polygon buffer
820  const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
821  const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
822 
823  for( int j = 0; j < path.PointCount(); j++ )
824  {
825  const VECTOR2I& a = path.CPoint( j );
826  const VECTOR2I& b = path.CPoint( j + 1 );
827 
828  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
829  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
830 
831  if( Is_segment_a_circle( start3DU, end3DU ) )
832  {
833  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
834  *aPad ) );
835  }
836  else
837  {
838  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
839  *aPad ) );
840  }
841  }
842 }
PAD_SHAPE_T GetShape() const
Definition: pad.h:162
int PointCount() const
Function PointCount()
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
const VECTOR2I & CPoint(int aIndex) const
Function Point()
wxPoint ShapePos() const
Definition: pcbnew/pad.cpp:663
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const wxSize & GetSize() const
Definition: pad.h:229
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.
SHAPE_LINE_CHAIN.
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pcbnew/pad.cpp:274

References CONTAINER_2D_BASE::Add(), SHAPE_LINE_CHAIN::CPoint(), PAD::GetEffectivePolygon(), PAD::GetShape(), PAD::GetSize(), Is_segment_a_circle(), m_biuTo3Dunits, PAD_SHAPE_CIRCLE, SHAPE_LINE_CHAIN::PointCount(), 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 457 of file board_adapter.cpp.

458 {
460 
461  bool success;
462 
463  if( m_board->IsFootprintHolder() )
464  {
465  if( !m_board->GetFirstFootprint() )
466  {
467  if( aErrorMsg )
468  *aErrorMsg = _( "No footprint loaded." );
469 
470  return false;
471  }
472 
473  int chainingEpsilon = Millimeter2iu( 0.02 ); // max dist from one endPt to next startPt
474 
477  chainingEpsilon );
478 
479  // Make polygon strictly simple to avoid issues (especially in 3D viewer)
481 
482  if( !success && aErrorMsg )
483  {
484  *aErrorMsg = _( "Footprint outline is missing or malformed. Run Footprint Checker for "
485  "a full analysis." );
486  }
487  }
488  else
489  {
491 
492  if( !success && aErrorMsg )
493  *aErrorMsg = _( "Board outline is missing or malformed. Run DRC for a full analysis." );
494  }
495 
496  return success;
497 }
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:1854
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.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:574
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:274
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
Definition: board.h:363
SHAPE_POLY_SET m_board_poly
Board outline polygon.
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
#define _(s)
Definition: 3d_actions.cpp:33
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
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 125 of file create_layer_items.cpp.

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

Referenced by InitSettings().

◆ createPadWithClearance()

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

Definition at line 324 of file create_3Dgraphic_brd_items.cpp.

326 {
327  SHAPE_POLY_SET poly;
328 
329  // Our shape-based builder can't handle negative or differing x:y clearance values (the
330  // former are common for solder paste while the later get generated when a relative paste
331  // margin is used with an oblong pad). So we apply this huge hack and fake a larger pad to
332  // run the general-purpose polygon builder on.
333  // Of course being a hack it falls down when dealing with custom shape pads (where the size
334  // is only the size of the anchor), so for those we punt and just use aClearanceValue.x.
335 
336  if( ( aClearanceValue.x < 0 || aClearanceValue.x != aClearanceValue.y )
337  && aPad->GetShape() != PAD_SHAPE_CUSTOM )
338  {
339  PAD dummy( *aPad );
340  dummy.SetSize( aPad->GetSize() + aClearanceValue + aClearanceValue );
341  dummy.TransformShapeWithClearanceToPolygon( poly, aLayer, 0, ARC_HIGH_DEF, ERROR_INSIDE );
342  aClearanceValue = { 0, 0 };
343  }
344  else
345  {
346  auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
347 
348  for( const SHAPE* shape : padShapes->Shapes() )
349  {
350  switch( shape->Type() )
351  {
352  case SH_SEGMENT:
353  {
354  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape;
355  const SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
356  -seg->GetSeg().A.y * m_biuTo3Dunits );
357  const SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
358  -seg->GetSeg().B.y * m_biuTo3Dunits );
359  const int width = seg->GetWidth() + aClearanceValue.x * 2;
360 
361  // Cannot add segments that have the same start and end point
362  if( Is_segment_a_circle( start3DU, end3DU ) )
363  {
364  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU,
365  ( width / 2) * m_biuTo3Dunits,
366  *aPad ) );
367  }
368  else
369  {
370  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU,
371  width * m_biuTo3Dunits,
372  *aPad ) );
373  }
374  }
375  break;
376 
377  case SH_CIRCLE:
378  {
379  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape;
380  const int radius = circle->GetRadius() + aClearanceValue.x;
381  const SFVEC2F center( circle->GetCenter().x * m_biuTo3Dunits,
382  -circle->GetCenter().y * m_biuTo3Dunits );
383 
384  aDstContainer->Add( new FILLED_CIRCLE_2D( center, radius * m_biuTo3Dunits,
385  *aPad ) );
386  }
387  break;
388 
389  case SH_RECT:
390  {
391  SHAPE_RECT* rect = (SHAPE_RECT*) shape;
392 
393  poly.NewOutline();
394  poly.Append( rect->GetPosition() );
395  poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y );
396  poly.Append( rect->GetPosition() + rect->GetSize() );
397  poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y );
398  }
399  break;
400 
401  case SH_SIMPLE:
402  poly.AddOutline( static_cast<const SHAPE_SIMPLE*>( shape )->Vertices() );
403  break;
404 
405  case SH_POLY_SET:
406  poly = *(SHAPE_POLY_SET*) shape;
407  break;
408 
409  default:
410  wxFAIL_MSG( "BOARD_ADAPTER::createPadWithClearance no implementation for "
411  + SHAPE_TYPE_asString( shape->Type() ) );
412  break;
413  }
414  }
415  }
416 
417  if( !poly.IsEmpty() )
418  {
419  if( aClearanceValue.x )
420  poly.Inflate( aClearanceValue.x, 32 );
421 
422  // Add the PAD polygon
423  ConvertPolygonToTriangles( poly, *aDstContainer, m_biuTo3Dunits, *aPad );
424  }
425 }
void ConvertPolygonToTriangles(SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
int GetRadius() const
Definition: shape_circle.h:102
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
PAD_SHAPE_T GetShape() const
Definition: pad.h:162
const VECTOR2I GetCenter() const
Definition: shape_circle.h:107
void Inflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Performs outline inflation/deflation.
const SEG & GetSeg() const
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
const VECTOR2I GetSize() const
Function GetSize()
Definition: shape_rect.h:131
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SHAPE_POLY_SET.
const VECTOR2I & GetPosition() const
Function GetPosition()
Definition: shape_rect.h:121
const wxSize & GetSize() const
Definition: pad.h:229
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
Definition: shape.h:55
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: pcbnew/pad.cpp:283
SHAPE.
Definition: shape.h:123
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 empty polygon in the set and returns its index
line chain (polyline)
Definition: shape.h:46
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
simple polygon
Definition: shape.h:48
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
VECTOR2I A
Definition: seg.h:47
Definition: shape.h:43
Definition: pad.h:60
int GetWidth() const
circle
Definition: shape.h:47
axis-aligned rectangle
Definition: shape.h:44
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
VECTOR2I B
Definition: seg.h:48

References SEG::A, CONTAINER_2D_BASE::Add(), SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::Append(), SEG::B, ConvertPolygonToTriangles(), 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_POLY_SET::Inflate(), Is_segment_a_circle(), SHAPE_POLY_SET::IsEmpty(), m_biuTo3Dunits, SHAPE_POLY_SET::NewOutline(), PAD_SHAPE_CUSTOM, 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 428 of file create_3Dgraphic_brd_items.cpp.

429 {
430  wxSize drillSize = aPad->GetDrillSize();
431 
432  if( !drillSize.x || !drillSize.y )
433  {
434  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createPadWithDrill - found an invalid pad" ) );
435  return nullptr;
436  }
437 
438  if( drillSize.x == drillSize.y ) // usual round hole
439  {
440  const int radius = ( drillSize.x / 2 ) + aInflateValue;
441 
442  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
443  -aPad->GetPosition().y * m_biuTo3Dunits );
444 
445  return new FILLED_CIRCLE_2D( center, radius * m_biuTo3Dunits, *aPad );
446 
447  }
448  else // Oblong hole
449  {
450  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
451  float width = seg->GetWidth() + aInflateValue * 2;
452 
453  SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
454  -seg->GetSeg().A.y * m_biuTo3Dunits );
455 
456  SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
457  -seg->GetSeg().B.y * m_biuTo3Dunits );
458 
459  return new ROUND_SEGMENT_2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
460  }
461 
462  return nullptr;
463 }
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a SHAPE object representing the pad's hole.
Definition: pcbnew/pad.cpp:292
const SEG & GetSeg() const
const wxSize & GetDrillSize() const
Definition: pad.h:239
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
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:170
VECTOR2I A
Definition: seg.h:47
int GetWidth() const
VECTOR2I B
Definition: seg.h:48

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 TRACK aTrack,
CONTAINER_2D_BASE aDstContainer,
int  aClearanceValue 
)
private

Definition at line 245 of file create_3Dgraphic_brd_items.cpp.

247 {
248  SFVEC2F start3DU( aTrack->GetStart().x * m_biuTo3Dunits,
249  -aTrack->GetStart().y * m_biuTo3Dunits ); // y coord is inverted
250 
251  switch( aTrack->Type() )
252  {
253  case PCB_VIA_T:
254  {
255  const float radius = ( ( aTrack->GetWidth() / 2 ) + aClearanceValue ) * m_biuTo3Dunits;
256  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius, *aTrack ) );
257  break;
258  }
259 
260  case PCB_ARC_T:
261  {
262  const ARC* arc = static_cast<const ARC*>( aTrack );
263  VECTOR2D center( arc->GetCenter() );
264  double arc_angle = arc->GetAngle();
265  double radius = arc->GetRadius();
266  int arcsegcount = GetArcToSegmentCount( radius, Millimeter2iu( 0.005), arc_angle/10 );
267  int circlesegcount;
268 
269  // We need a circle to segment count. However, the arc angle can be small, and the
270  // radius very big. so we calculate a reasonable value for circlesegcount.
271  if( arcsegcount <= 1 ) // The arc will be approximated by a segment
272  circlesegcount = 1;
273  else
274  {
275  double cnt = arcsegcount * 3600/std::abs( arc_angle );
276 
277 #define SEG_CNT_MAX 128
278  if( cnt < SEG_CNT_MAX )
279  {
280  circlesegcount = (int)cnt;
281 
282  if( circlesegcount == 0 )
283  circlesegcount = 1;
284  }
285  else
286  {
287  circlesegcount = SEG_CNT_MAX;
288  }
289  }
290 
291  transformArcToSegments( wxPoint( center.x, center.y ), arc->GetStart(),
292  arc_angle, circlesegcount,
293  arc->GetWidth() + 2 * aClearanceValue, aDstContainer, *arc );
294  break;
295  }
296 
297  case PCB_TRACE_T: // Track is a usual straight segment
298  {
299  SFVEC2F end3DU( aTrack->GetEnd().x * m_biuTo3Dunits, -aTrack->GetEnd().y * m_biuTo3Dunits );
300 
301  // Cannot add segments that have the same start and end point
302  if( Is_segment_a_circle( start3DU, end3DU ) )
303  {
304  const float radius = ((aTrack->GetWidth() / 2) + aClearanceValue) * m_biuTo3Dunits;
305 
306  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius, *aTrack ) );
307  }
308  else
309  {
310  const float width = (aTrack->GetWidth() + 2 * aClearanceValue ) * m_biuTo3Dunits;
311 
312  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, width, *aTrack ) );
313  }
314 
315  break;
316  }
317 
318  default:
319  break;
320  }
321 }
virtual wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: track.h:302
#define SEG_CNT_MAX
const wxPoint & GetStart() const
Definition: track.h:116
void transformArcToSegments(const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM &aBoardItem)
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class 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:45
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
double GetRadius() const
Definition: track.cpp:894
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: track.cpp:900
int GetWidth() const
Definition: track.h:110
Definition: track.h:262
const wxPoint & GetEnd() const
Definition: track.h:113
class 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)
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:161

References CONTAINER_2D_BASE::Add(), ARC::GetAngle(), GetArcToSegmentCount(), ARC::GetCenter(), TRACK::GetEnd(), ARC::GetRadius(), TRACK::GetStart(), 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 58 of file create_layer_items.cpp.

59 {
60  if( !m_layers_poly.empty() )
61  {
62  for( auto& poly : m_layers_poly )
63  delete poly.second;
64 
65  m_layers_poly.clear();
66  }
67 
68  delete m_frontPlatedPadPolys;
69  m_frontPlatedPadPolys = nullptr;
70 
71  delete m_backPlatedPadPolys;
72  m_backPlatedPadPolys = nullptr;
73 
74  if( !m_layerHoleIdPolys.empty() )
75  {
76  for( auto& poly : m_layerHoleIdPolys )
77  delete poly.second;
78 
79  m_layerHoleIdPolys.clear();
80  }
81 
82  if( !m_layerHoleOdPolys.empty() )
83  {
84  for( auto& poly : m_layerHoleOdPolys )
85  delete poly.second;
86 
87  m_layerHoleOdPolys.clear();
88  }
89 
90  if( !m_layerMap.empty() )
91  {
92  for( auto& poly : m_layerMap )
93  delete poly.second;
94 
95  m_layerMap.clear();
96  }
97 
98  delete m_platedPadsFront;
99  m_platedPadsFront = nullptr;
100 
101  delete m_platedPadsBack;
102  m_platedPadsBack = nullptr;
103 
104  if( !m_layerHoleMap.empty() )
105  {
106  for( auto& poly : m_layerHoleMap )
107  delete poly.second;
108 
109  m_layerHoleMap.clear();
110  }
111 
119 
122 }
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
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
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 87 of file board_adapter.h.

88  {
89  return m_3dModelManager;
90  }
S3D_CACHE * m_3dModelManager

References m_3dModelManager.

Referenced by RENDER_3D_LEGACY::load3dModels(), and RENDER_3D_RAYTRACE::loadModels().

◆ GetAntiAliasingMode()

ANTIALIASING_MODE BOARD_ADAPTER::GetAntiAliasingMode ( ) const
inline

Get the current antialiasing mode value.

Returns
antialiasing mode value

Definition at line 274 of file board_adapter.h.

274 { return m_antiAliasingMode; }
ANTIALIASING_MODE m_antiAliasingMode

References m_antiAliasingMode.

Referenced by EDA_3D_VIEWER::SaveSettings(), and DIALOG_3D_VIEW_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 499 of file board_adapter.h.

500  {
501  return m_averageHoleDiameter;
502  }
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 509 of file board_adapter.h.

510  {
511  return m_averageTrackWidth;
512  }
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 489 of file board_adapter.h.

490  {
492  }
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 541 of file board_adapter.h.

542  {
543  return m_backPlatedPadPolys;
544  }
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 168 of file board_adapter.h.

169  {
170  return m_boardBoundingBox;
171  }
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 235 of file board_adapter.h.

236  {
237  return m_boardCenter;
238  }
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 320 of file board_adapter.h.

321  {
322  return m_board_poly;
323  }
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 225 of file board_adapter.h.

226  {
227  return m_boardPos;
228  }
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 215 of file board_adapter.h.

216  {
217  return m_boardSize;
218  }
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 263 of file board_adapter.cpp.

264 {
265  wxASSERT( aDiameter3DU > 0.0f );
266 
267  return GetCircleSegmentCount( (int)( aDiameter3DU / m_biuTo3Dunits ) );
268 }
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 271 of file board_adapter.cpp.

272 {
273  wxASSERT( aDiameterBIU > 0 );
274 
275  return GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, 360.0 );
276 }
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)

References GetArcToSegmentCount().

◆ GetColor()

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

Definition at line 535 of file board_adapter.cpp.

536 {
537  return SFVEC4F( aColor.r, aColor.g, aColor.b, aColor.a );
538 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
double g
Green component.
Definition: color4d.h:359
double b
Blue component.
Definition: color4d.h:360
double a
Alpha component.
Definition: color4d.h:361
double r
Red component.
Definition: color4d.h:358

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::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 198 of file board_adapter.h.

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

References m_copperThickness3DU.

Referenced by createLayers(), RENDER_3D_LEGACY::generateViasAndPads(), 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 178 of file board_adapter.h.

179  {
180  return m_epoxyThickness3DU;
181  }
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

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

501 {
502  if( aIsFlipped )
503  {
504  if( GetFlag( FL_SOLDERPASTE ) )
506  else
508  }
509  else
510  {
511  if( GetFlag( FL_SOLDERPASTE ) )
512  return m_layerZcoordTop[F_SilkS];
513  else
514  return m_layerZcoordTop[F_Paste];
515  }
516 }
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::loadModels(), and RENDER_3D_LEGACY::renderFootprint().

◆ GetFrontPlatedPadPolys()

const SHAPE_POLY_SET* BOARD_ADAPTER::GetFrontPlatedPadPolys ( )
inline

Definition at line 536 of file board_adapter.h.

537  {
538  return m_frontPlatedPadPolys;
539  }
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 254 of file board_adapter.h.

255  {
256  return m_gridType;
257  }
GRID3D_TYPE m_gridType

References m_gridType.

Referenced by EDA_3D_CONDITIONS::gridSizeFunction(), RENDER_3D_LEGACY::Redraw(), and EDA_3D_VIEWER::SaveSettings().

◆ GetHoleCount()

unsigned int BOARD_ADAPTER::GetHoleCount ( ) const
inlinenoexcept

Get number of holes in this board.

Returns
number of holes.

Definition at line 479 of file board_adapter.h.

480  {
481  return m_holeCount;
482  }
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 546 of file board_adapter.h.

547  {
548  return m_layerHoleIdPolys;
549  }
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 551 of file board_adapter.h.

552  {
553  return m_layerHoleOdPolys;
554  }
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 257 of file board_adapter.cpp.

258 {
260 }
int GetHolePlatingThickness() const
Pad & via drills are finish size.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:574

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

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

530 {
531  return GetColor( m_colors->GetColor( aItemId ) );
532 }
SFVEC4F GetColor(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 364 of file board_adapter.h.

365  {
366  return m_layerZcoordBottom[aLayerId];
367  }
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 519 of file board_adapter.cpp.

520 {
521  wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
522 
523  const COLOR4D color = m_colors->GetColor( aLayerId );
524 
525  return SFVEC4F( color.r, color.g, color.b, color.a );
526 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
COLOR_SETTINGS * m_colors
int color
Definition: DXF_plotter.cpp:60
COLOR4D GetColor(int aLayer) const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

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 394 of file board_adapter.h.

395  {
396  return m_layerHoleMap;
397  }
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 374 of file board_adapter.h.

375  {
376  return m_layerMap;
377  }
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 353 of file board_adapter.h.

354  {
355  return m_layerZcoordTop[aLayerId];
356  }
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 188 of file board_adapter.h.

189  {
191  }
float m_nonCopperLayerThickness3DU
Number of tracks in the board.

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 436 of file board_adapter.h.

437  {
439  }
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 384 of file board_adapter.h.

385  {
386  return m_platedPadsBack;
387  }
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 379 of file board_adapter.h.

380  {
381  return m_platedPadsFront;
382  }
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 531 of file board_adapter.h.

532  {
533  return m_layers_poly;
534  }
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 431 of file board_adapter.h.

432  {
434  }
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 414 of file board_adapter.h.

415  {
417  }
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 459 of file board_adapter.h.

460  {
461  return m_throughHoleIds;
462  }
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 426 of file board_adapter.h.

427  {
428  return m_throughHoleOdPolys;
429  }
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 404 of file board_adapter.h.

405  {
406  return m_throughHoleOds;
407  }
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 449 of file board_adapter.h.

450  {
452  }
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 444 of file board_adapter.h.

445  {
446  return m_throughHoleViaOds;
447  }
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 469 of file board_adapter.h.

470  {
471  return m_viaCount;
472  }
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 279 of file board_adapter.cpp.

280 {
281  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) );
282 
283  if( aStatusReporter )
284  aStatusReporter->Report( _( "Build board outline" ) );
285 
286  wxString msg;
287 
288  const bool succeedToGetBoardPolygon = createBoardPolygon( &msg );
289 
290  if( aWarningReporter )
291  {
292  if( !succeedToGetBoardPolygon )
293  aWarningReporter->Report( msg, RPT_SEVERITY_WARNING );
294  else
295  aWarningReporter->Report( wxEmptyString );
296  }
297 
298  // Calculates the board bounding box (board outlines + items)
299  // to ensure any item, even outside the board outlines can be seen
300  bool boardEdgesOnly = true;
301 
303  || !succeedToGetBoardPolygon )
304  boardEdgesOnly = false;
305 
306  EDA_RECT bbbox = m_board->ComputeBoundingBox( boardEdgesOnly );
307 
308  // Gives a non null size to avoid issues in zoom / scale calculations
309  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
310  bbbox.Inflate( Millimeter2iu( 10 ) );
311 
312  m_boardSize = bbbox.GetSize();
313  m_boardPos = bbbox.Centre();
314 
315  wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
316 
317  m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
318 
320 
321  // Ensure the board has 2 sides for 3D views, because it is hard to find
322  // a *really* single side board in the true life...
323  if( m_copperLayersCount < 2 )
325 
326  // Calculate the conversion to apply to all positions.
328 
330 
331  // !TODO: use value defined by user (currently use default values by ctor
334 
335  // Init Z position of each layer
336  // calculate z position for each copper layer
337  // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
338  // Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
339  // all unused copper layer z position are set to 0
340 
341  // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
342  // | | Top = Bottom + m_copperThickness
343  // |__________________________________|
344  // == == == == <- Bottom = -m_epoxyThickness / 2.0,
345  // Top = Bottom - m_copperThickness
346 
347  unsigned int layer;
348 
349  for( layer = 0; layer < m_copperLayersCount; ++layer )
350  {
351  m_layerZcoordBottom[layer] = m_epoxyThickness3DU / 2.0f -
352  (m_epoxyThickness3DU * layer / (m_copperLayersCount - 1) );
353 
354  if( layer < (m_copperLayersCount / 2) )
356  else
358  }
359 
360  #define layerThicknessMargin 1.1
361  const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
362 
363  // Fill remaining unused copper layers and back layer zpos
364  // with -m_epoxyThickness / 2.0
365  for( ; layer < MAX_CU_LAYERS; layer++ )
366  {
367  m_layerZcoordBottom[layer] = -(m_epoxyThickness3DU / 2.0f);
369  }
370 
371  // This is the top of the copper layer thickness.
372  const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
373  const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
374 
375  // calculate z position for each non copper layer
376  // Solder mask and Solder paste have the same Z position
377  for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
378  {
379  float zposTop;
380  float zposBottom;
381 
382  switch( layer_id )
383  {
384  case B_Adhes:
385  zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
386  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
387  break;
388 
389  case F_Adhes:
390  zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
391  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
392  break;
393 
394  case B_Mask:
395  case B_Paste:
396  zposBottom = zpos_copperTop_back;
397  zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
398  break;
399 
400  case F_Mask:
401  case F_Paste:
402  zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
403  zposBottom = zpos_copperTop_front;
404  break;
405 
406  case B_SilkS:
407  zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
408  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
409  break;
410 
411  case F_SilkS:
412  zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
413  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
414  break;
415 
416  // !TODO: review
417  default:
418  zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
419  zposBottom = zposTop - m_nonCopperLayerThickness3DU;
420  break;
421  }
422 
423  m_layerZcoordTop[layer_id] = zposTop;
424  m_layerZcoordBottom[layer_id] = zposBottom;
425  }
426 
428 
430  0.0f );
431  boardSize /= 2.0f;
432 
433  SFVEC3F boardMin = ( m_boardCenter - boardSize );
434  SFVEC3F boardMax = ( m_boardCenter + boardSize );
435 
436  boardMin.z = m_layerZcoordTop[B_Adhes];
437  boardMax.z = m_layerZcoordTop[F_Adhes];
438 
439  m_boardBoundingBox = BBOX_3D( boardMin, boardMax );
440 
441 #ifdef PRINT_STATISTICS_3D_VIEWER
442  unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
443 #endif
444 
445  if( aStatusReporter )
446  aStatusReporter->Report( _( "Create layers" ) );
447 
448  createLayers( aStatusReporter );
449 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
#define TECH_LAYER_THICKNESS
float m_nonCopperLayerThickness3DU
Number of tracks in the board.
Manage a bounding box defined by two SFVEC3F min max points.
Definition: bbox_3d.h:41
int GetWidth() const
Definition: eda_rect.h:114
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:574
#define layerThicknessMargin
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:274
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Copper thickness in 3D units.
float m_epoxyThickness3DU
Non copper layers thickness in 3D units.
float m_copperThickness3DU
Epoxy thickness in 3D units.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Bottom (Start) Z position of each layer in 3D units.
BBOX_3D m_boardBoundingBox
3D bounding box of the board in 3D units.
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
void createLayers(REPORTER *aStatusReporter)
int GetHeight() const
Definition: eda_rect.h:115
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.
#define _(s)
Definition: 3d_actions.cpp:33
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapset time (in microsecondes) to class PROF_COUNTER.
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
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.
int GetCopperLayerCount() const
Definition: board.cpp:435
Handle the component boundary box.
Definition: eda_rect.h:42
wxPoint Centre() const
Definition: eda_rect.h:60
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1022
SFVEC3F m_boardCenter
3D center position of the board in 3D units.
#define COPPER_THICKNESS
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:61
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363
const wxSize GetSize() const
Definition: eda_rect.h:96

References _, B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, EDA_RECT::Centre(), BOARD::ComputeBoundingBox(), COPPER_THICKNESS, createBoardPolygon(), createLayers(), F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, FL_USE_REALISTIC_MODE, BOARD_DESIGN_SETTINGS::GetBoardThickness(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), GetFlag(), EDA_RECT::GetHeight(), GetRunningMicroSecs(), EDA_RECT::GetSize(), EDA_RECT::GetWidth(), EDA_RECT::Inflate(), BOARD::IsFootprintHolder(), layerThicknessMargin, m_biuTo3Dunits, m_board, m_boardBoundingBox, m_boardCenter, m_boardPos, m_boardSize, m_copperLayersCount, m_copperThickness3DU, m_epoxyThickness3DU, m_layerZcoordBottom, m_layerZcoordTop, m_logTrace, m_nonCopperLayerThickness3DU, MAX_CU_LAYERS, Millimeter2iu(), PCB_LAYER_ID_COUNT, RANGE_SCALE_3D, REPORTER::Report(), RPT_SEVERITY_WARNING, 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 150 of file board_adapter.cpp.

151 {
152  wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
153 
154  DISPLAY3D_FLG flg;
155 
156  // see if layer needs to be shown
157  // check the flags
158  switch( aLayer )
159  {
160  case B_Adhes:
161  case F_Adhes:
162  flg = FL_ADHESIVE;
163  break;
164 
165  case B_Paste:
166  case F_Paste:
167  flg = FL_SOLDERPASTE;
168  break;
169 
170  case B_SilkS:
171  case F_SilkS:
172  flg = FL_SILKSCREEN;
173  break;
174 
175  case B_Mask:
176  case F_Mask:
177  flg = FL_SOLDERMASK;
178  break;
179 
180  case Dwgs_User:
181  case Cmts_User:
183  return false;
184 
185  flg = FL_COMMENTS;
186  break;
187 
188  case Eco1_User:
189  case Eco2_User:
191  return false;
192 
193  flg = FL_ECO;
194  break;
195 
196  case Edge_Cuts:
198  return false;
199 
200  return true;
201  break;
202 
203  case Margin:
205  return false;
206 
207  return true;
208  break;
209 
210  case B_Cu:
211  case F_Cu:
212  return m_board->IsLayerVisible( aLayer ) || GetFlag( FL_USE_REALISTIC_MODE );
213  break;
214 
215  default:
216  // the layer is an internal copper layer, used the visibility
217  return m_board->IsLayerVisible( aLayer );
218  }
219 
220  // The layer has a flag, return the flag
221  return GetFlag( flg );
222 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
DISPLAY3D_FLG
Flags used in rendering options.
Definition: 3d_enums.h:34
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:453

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

242 {
243  if( aFPAttributes & FP_SMD )
245  else if( aFPAttributes & FP_THROUGH_HOLE )
247  else
249 }
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::loadModels(), 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 79 of file board_adapter.h.

80  {
81  m_3dModelManager = aCachePointer;
82  }
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 281 of file board_adapter.h.

281 { m_antiAliasingMode = aAAmode; }
ANTIALIASING_MODE m_antiAliasingMode

References m_antiAliasingMode.

Referenced by EDA_3D_VIEWER::LoadSettings(), and DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow().

◆ SetBoard()

void BOARD_ADAPTER::SetBoard ( BOARD aBoard)
inlinenoexcept

Set current board to be rendered.

Parameters
aBoardboard to process.

Definition at line 125 of file board_adapter.h.

126  {
127  m_board = aBoard;
128  }

References m_board.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ SetColorSettings()

void BOARD_ADAPTER::SetColorSettings ( COLOR_SETTINGS aSettings)
inlinenoexcept

Definition at line 140 of file board_adapter.h.

141  {
142  m_colors = aSettings;
143  }
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 233 of file board_adapter.cpp.

234 {
235  wxASSERT( aFlag < FL_LAST );
236 
237  m_drawFlags[aFlag] = aState;
238 }
std::vector< bool > m_drawFlags

References FL_LAST, and m_drawFlags.

Referenced by BOARD_ADAPTER(), PANEL_PREV_3D::loadCommonSettings(), EDA_3D_VIEWER::loadCommonSettings(), PANEL_PREV_3D::PANEL_PREV_3D(), EDA_3D_CONTROLLER::ToggleVisibility(), and DIALOG_3D_VIEW_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 264 of file board_adapter.h.

265  {
266  m_gridType = aGridType;
267  }
GRID3D_TYPE m_gridType

References m_gridType.

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

◆ SetMaterialMode()

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

Definition at line 302 of file board_adapter.h.

303  {
304  m_materialMode = aMaterialMode;
305  }
MATERIAL_MODE m_materialMode

References m_materialMode.

Referenced by EDA_3D_VIEWER::LoadSettings(), and EDA_3D_CONTROLLER::SetMaterial().

◆ SetRenderEngine()

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

Definition at line 286 of file board_adapter.h.

287  {
288  m_renderEngine = aRenderEngine;
289  }
RENDER_ENGINE m_renderEngine

References m_renderEngine.

Referenced by EDA_3D_CANVAS::DoRePaint(), EDA_3D_VIEWER::LoadSettings(), EDA_3D_VIEWER::OnDisableRayTracing(), and EDA_3D_VIEWER::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 540 of file create_3Dgraphic_brd_items.cpp.

544 {
545  wxPoint arc_start, arc_end;
546  int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
547 
548  arc_end = arc_start = aStart;
549 
550  if( aArcAngle != 3600 )
551  {
552  RotatePoint( &arc_end, aCentre, -aArcAngle );
553  }
554 
555  if( aArcAngle < 0 )
556  {
557  std::swap( arc_start, arc_end );
558  aArcAngle = -aArcAngle;
559  }
560 
561  // Compute the ends of segments and creates poly
562  wxPoint curr_end = arc_start;
563  wxPoint curr_start = arc_start;
564 
565  for( int ii = delta; ii < aArcAngle; ii += delta )
566  {
567  curr_end = arc_start;
568  RotatePoint( &curr_end, aCentre, -ii );
569 
570  const SFVEC2F start3DU( curr_start.x * m_biuTo3Dunits, -curr_start.y * m_biuTo3Dunits );
571  const SFVEC2F end3DU ( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
572 
573  if( Is_segment_a_circle( start3DU, end3DU ) )
574  {
575  aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
576  aBoardItem ) );
577  }
578  else
579  {
580  aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
581  aBoardItem ) );
582  }
583 
584  curr_start = curr_end;
585  }
586 
587  if( curr_end != arc_end )
588  {
589  const SFVEC2F start3DU( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
590  const SFVEC2F end3DU ( arc_end.x * m_biuTo3Dunits, -arc_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 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
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.

References CONTAINER_2D_BASE::Add(), 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:82
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
DRAWINGS & GraphicalItems()
Definition: footprint.h:185
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 draw segment to a closed polygon Used in fi...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:173

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

Referenced by createLayers().

Member Data Documentation

◆ m_3dModelManager

S3D_CACHE* BOARD_ADAPTER::m_3dModelManager
private

Definition at line 642 of file board_adapter.h.

Referenced by Get3dCacheManager(), and Set3dCacheManager().

◆ m_antiAliasingMode

ANTIALIASING_MODE BOARD_ADAPTER::m_antiAliasingMode
private

Definition at line 649 of file board_adapter.h.

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

◆ m_averageHoleDiameter

float BOARD_ADAPTER::m_averageHoleDiameter
private

Definition at line 745 of file board_adapter.h.

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

◆ m_averageTrackWidth

float BOARD_ADAPTER::m_averageTrackWidth
private

Number of through hole vias in the board.

Definition at line 733 of file board_adapter.h.

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

◆ m_averageViaHoleDiameter

float BOARD_ADAPTER::m_averageViaHoleDiameter
private

Number of holes in the board.

Definition at line 739 of file board_adapter.h.

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

◆ m_backPlatedPadPolys

SHAPE_POLY_SET* BOARD_ADAPTER::m_backPlatedPadPolys
private

Polygon contours for hole outer diameters for each layer.

Definition at line 662 of file board_adapter.h.

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

◆ m_BgColorBot

◆ m_BgColorTop

◆ m_biuTo3Dunits

◆ m_board

BOARD* BOARD_ADAPTER::m_board
private

◆ m_board_poly

SHAPE_POLY_SET BOARD_ADAPTER::m_board_poly
private

Board outline polygon.

Definition at line 682 of file board_adapter.h.

Referenced by createBoardPolygon(), and GetBoardPoly().

◆ m_BoardBodyColor

◆ m_boardBoundingBox

BBOX_3D BOARD_ADAPTER::m_boardBoundingBox
private

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

Polygon contours for each layer.

Definition at line 655 of file board_adapter.h.

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

◆ m_boardCenter

SFVEC3F BOARD_ADAPTER::m_boardCenter
private

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

Definition at line 654 of file board_adapter.h.

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

◆ m_boardPos

wxPoint BOARD_ADAPTER::m_boardPos
private

Board center position in board internal units.

Definition at line 652 of file board_adapter.h.

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

◆ m_boardSize

wxSize BOARD_ADAPTER::m_boardSize
private

Board size in board internal units.

Definition at line 653 of file board_adapter.h.

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

◆ m_colors

COLOR_SETTINGS* BOARD_ADAPTER::m_colors
private

Definition at line 643 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetItemColor(), GetLayerColor(), and SetColorSettings().

◆ m_CopperColor

◆ m_copperLayersCount

unsigned int BOARD_ADAPTER::m_copperLayersCount
private

Scale factor to convert board internal units to 3D units normalized between -1.0 and 1.0.

Definition at line 709 of file board_adapter.h.

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

◆ m_copperThickness3DU

float BOARD_ADAPTER::m_copperThickness3DU
private

Epoxy thickness in 3D units.

Definition at line 721 of file board_adapter.h.

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

◆ m_drawFlags

std::vector< bool > BOARD_ADAPTER::m_drawFlags
private

Definition at line 645 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetFlag(), and SetFlag().

◆ m_epoxyThickness3DU

float BOARD_ADAPTER::m_epoxyThickness3DU
private

Non copper layers thickness in 3D units.

Definition at line 724 of file board_adapter.h.

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

◆ m_frontPlatedPadPolys

SHAPE_POLY_SET* BOARD_ADAPTER::m_frontPlatedPadPolys
private

◆ m_gridType

GRID3D_TYPE BOARD_ADAPTER::m_gridType
private

Definition at line 646 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetGridType(), and SetGridType().

◆ m_holeCount

unsigned int BOARD_ADAPTER::m_holeCount
private

Computed average diameter of the holes in 3D units.

Definition at line 742 of file board_adapter.h.

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

◆ m_layerHoleIdPolys

MAP_POLY BOARD_ADAPTER::m_layerHoleIdPolys
private

Polygon contours for non plated through hole outer diameters.

Definition at line 668 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetHoleIdPolysMap().

◆ m_layerHoleMap

MAP_CONTAINER_2D_BASE BOARD_ADAPTER::m_layerHoleMap
private

List of through holes with the radius of the hole inflated with the copper thickness.

Definition at line 691 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetLayerHoleMap().

◆ m_layerHoleOdPolys

MAP_POLY BOARD_ADAPTER::m_layerHoleOdPolys
private

Polygon contours for hole inner diameters for each layer.

Definition at line 665 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetHoleOdPolysMap().

◆ m_layerMap

MAP_CONTAINER_2D_BASE BOARD_ADAPTER::m_layerMap
private

2D elements for each layer.

Definition at line 684 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetLayerMap().

◆ m_layers_poly

MAP_POLY BOARD_ADAPTER::m_layers_poly
private

Definition at line 659 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetPolyMap().

◆ m_layerZcoordBottom

std::array<float, PCB_LAYER_ID_COUNT> BOARD_ADAPTER::m_layerZcoordBottom
private

Copper thickness in 3D units.

Definition at line 718 of file board_adapter.h.

Referenced by GetFootprintZPos(), GetLayerBottomZPos(), and InitSettings().

◆ m_layerZcoordTop

std::array<float, PCB_LAYER_ID_COUNT> BOARD_ADAPTER::m_layerZcoordTop
private

Bottom (Start) Z position of each layer in 3D units.

Definition at line 715 of file board_adapter.h.

Referenced by GetFootprintZPos(), GetLayerTopZPos(), and InitSettings().

◆ m_materialMode

MATERIAL_MODE BOARD_ADAPTER::m_materialMode
private

Definition at line 648 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetMaterialMode(), and SetMaterialMode().

◆ m_nonCopperLayerThickness3DU

float BOARD_ADAPTER::m_nonCopperLayerThickness3DU
private

Number of tracks in the board.

Definition at line 727 of file board_adapter.h.

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

◆ m_nonPlatedThroughHoleOdPolys

SHAPE_POLY_SET BOARD_ADAPTER::m_nonPlatedThroughHoleOdPolys
private

Polygon contours for through hole outer diameters.

Definition at line 671 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetOuterNonPlatedThroughHolePoly().

◆ m_OpenGlSelectionColor

◆ m_platedPadsBack

BVH_CONTAINER_2D* BOARD_ADAPTER::m_platedPadsBack
private

The holes per each layer.

Definition at line 688 of file board_adapter.h.

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

◆ m_platedPadsFront

BVH_CONTAINER_2D* BOARD_ADAPTER::m_platedPadsFront
private

Definition at line 687 of file board_adapter.h.

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

◆ m_renderEngine

RENDER_ENGINE BOARD_ADAPTER::m_renderEngine
private

Definition at line 647 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), GetRenderEngine(), and SetRenderEngine().

◆ m_RtCameraLightColor

◆ m_RtLightColor

◆ m_RtLightColorBottom

◆ m_RtLightColorTop

◆ m_RtLightSphericalCoords

◆ 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_throughHoleAnnularRingPolys

SHAPE_POLY_SET BOARD_ADAPTER::m_throughHoleAnnularRingPolys
private

Definition at line 680 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetThroughHoleAnnularRingPolys().

◆ m_throughHoleAnnularRings

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleAnnularRings
private

List of through hole inner diameters.

Definition at line 697 of file board_adapter.h.

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

◆ m_throughHoleIds

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleIds
private

List of through hole vias with the radius of the hole inflated with the copper thickness.

Definition at line 700 of file board_adapter.h.

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

◆ m_throughHoleOdPolys

SHAPE_POLY_SET BOARD_ADAPTER::m_throughHoleOdPolys
private

Polygon contours for through holes via outer diameters.

Definition at line 674 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetThroughHoleOdPolys().

◆ m_throughHoleOds

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleOds
private

List of plated through hole annular rings.

Definition at line 694 of file board_adapter.h.

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

◆ m_throughHoleViaIds

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleViaIds
private

Number of copper layers actually used by the board.

Definition at line 706 of file board_adapter.h.

Referenced by destroyLayers().

◆ m_throughHoleViaOdPolys

SHAPE_POLY_SET BOARD_ADAPTER::m_throughHoleViaOdPolys
private

Polygon contours for through hole via annular rings.

Definition at line 677 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetThroughHoleViaOdPolys().

◆ m_throughHoleViaOds

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleViaOds
private

List of through hole via inner diameters.

Definition at line 703 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetThroughHoleViaOds().

◆ m_trackCount

unsigned int BOARD_ADAPTER::m_trackCount
private

Track average width.

Definition at line 730 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and createLayers().

◆ m_viaCount

unsigned int BOARD_ADAPTER::m_viaCount
private

Computed average diameter of the via holes in 3D units.

Definition at line 736 of file board_adapter.h.

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


The documentation for this class was generated from the following files: