KiCad PCB EDA Suite
BOARD_ADAPTER Class Reference

Class BOARD_ADAPTER 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
 Set3DCacheManager - Update the Cache manager pointer. More...
 
S3D_CACHEGet3DCacheManager () const noexcept
 Get3DCacheManager - Return the 3d cache manager pointer. More...
 
bool GetFlag (DISPLAY3D_FLG aFlag) const
 GetFlag - get a configuration status of a flag. More...
 
void SetFlag (DISPLAY3D_FLG aFlag, bool aState)
 SetFlag - set the status of a flag. More...
 
bool Is3DLayerEnabled (PCB_LAYER_ID aLayer) const
 Is3DLayerEnabled - Check if a layer is enabled. More...
 
bool ShouldFPBeDisplayed (FOOTPRINT_ATTR_T aFPAttributes) const
 ShouldFPBeDisplayed - Test if footprint should be displayed in relation to attributes and the flags. More...
 
void SetBoard (BOARD *aBoard) noexcept
 SetBoard - Set current board to be rendered. More...
 
const BOARDGetBoard () const noexcept
 GetBoard - Get current board to be rendered. More...
 
void SetColorSettings (COLOR_SETTINGS *aSettings) noexcept
 
void InitSettings (REPORTER *aStatusReporter, REPORTER *aWarningReporter)
 InitSettings - Function to be called by the render when it need to reload the settings for the board. More...
 
double BiuTo3Dunits () const noexcept
 BiuTo3Dunits - Board integer units To 3D units. More...
 
const CBBOXGetBBox3DU () const noexcept
 GetBBox3DU - Get the bbox of the pcb board. More...
 
float GetEpoxyThickness3DU () const noexcept
 GetEpoxyThickness3DU - Get the current epoxy thickness. More...
 
float GetNonCopperLayerThickness3DU () const noexcept
 GetNonCopperLayerThickness3DU - Get the current non copper layers thickness. More...
 
float GetCopperThickness3DU () const noexcept
 GetCopperThickness3DU - Get the current copper layer thickness. More...
 
int GetHolePlatingThicknessBIU () const noexcept
 GetCopperThicknessBIU - Get the current copper layer thickness. More...
 
wxSize GetBoardSizeBIU () const noexcept
 GetBoardSizeBIU - Get the board size. More...
 
wxPoint GetBoardPosBIU () const noexcept
 GetBoardPosBIU - Get the board center. More...
 
const SFVEC3FGetBoardCenter3DU () const noexcept
 GetBoardCenter - the board center position in 3d units. More...
 
float GetModulesZcoord3DIU (bool aIsFlipped) const
 GetModulesZcoord3DIU - Get the position of the footprint in 3d integer units considering if it is flipped or not. More...
 
GRID3D_TYPE GridGet () const noexcept
 GridGet - get the current grid. More...
 
void GridSet (GRID3D_TYPE aGridType) noexcept
 GridSet - set the current grid. More...
 
ANTIALIASING_MODE AntiAliasingGet () const
 GridGet - get the current antialiasing mode value. More...
 
void AntiAliasingSet (ANTIALIASING_MODE aAAmode)
 AntiAliasingSet - set the current antialiasing mode value. More...
 
void RenderEngineSet (RENDER_ENGINE aRenderEngine) noexcept
 RenderEngineSet. More...
 
RENDER_ENGINE RenderEngineGet () const noexcept
 RenderEngineGet. More...
 
void MaterialModeSet (MATERIAL_MODE aMaterialMode) noexcept
 MaterialModeSet. More...
 
MATERIAL_MODE MaterialModeGet () const noexcept
 MaterialModeGet. More...
 
const SHAPE_POLY_SETGetBoardPoly () const noexcept
 GetBoardPoly - Get the current polygon of the epoxy board. More...
 
SFVEC4F GetLayerColor (PCB_LAYER_ID aLayerId) const
 GetLayerColor - get the technical color of a layer. More...
 
SFVEC4F GetItemColor (int aItemId) const
 GetItemColor - get the technical color of a layer. More...
 
SFVEC4F GetColor (COLOR4D aColor) const
 GetColor. More...
 
float GetLayerTopZpos3DU (PCB_LAYER_ID aLayerId) const noexcept
 GetLayerTopZpos3DU - Get the top z position. More...
 
float GetLayerBottomZpos3DU (PCB_LAYER_ID aLayerId) const noexcept
 GetLayerBottomZpos3DU - Get the bottom z position. More...
 
const MAP_CONTAINER_2DGetMapLayers () const noexcept
 GetMapLayers - Get the map of container that have the objects per layer. More...
 
const CBVHCONTAINER2DGetPlatedPads_Front () const noexcept
 
const CBVHCONTAINER2DGetPlatedPads_Back () const noexcept
 
const MAP_CONTAINER_2DGetMapLayersHoles () const noexcept
 GetMapLayersHoles -Get the map of container that have the holes per layer. More...
 
const CBVHCONTAINER2DGetThroughHole_Outer () const noexcept
 GetThroughHole_Outer - Get the inflated ThroughHole container. More...
 
const CBVHCONTAINER2DGetThroughHole_Outer_Ring () const noexcept
 GetThroughHole_Outer_Ring - Get the ThroughHole container that include the width of the annular ring. More...
 
const SHAPE_POLY_SETGetThroughHole_Outer_poly () const noexcept
 
const SHAPE_POLY_SETGetThroughHole_Outer_Ring_poly () const noexcept
 
const SHAPE_POLY_SETGetThroughHole_Outer_poly_NPTH () const noexcept
 
const CBVHCONTAINER2DGetThroughHole_Vias_Outer () const noexcept
 GetThroughHole_Vias_Outer -. More...
 
const SHAPE_POLY_SETGetThroughHole_Vias_Outer_poly () const noexcept
 
const CBVHCONTAINER2DGetThroughHole_Inner () const noexcept
 GetThroughHole_Inner - Get the ThroughHole container. More...
 
unsigned int GetStats_Nr_Vias () const noexcept
 GetStats_Nr_Vias - Get statistics of the nr of vias. More...
 
unsigned int GetStats_Nr_Holes () const noexcept
 GetStats_Nr_Holes - Get statistics of the nr of holes. More...
 
float GetStats_Med_Via_Hole_Diameter3DU () const noexcept
 GetStats_Med_Via_Hole_Diameter3DU - Average diameter of the via holes. More...
 
float GetStats_Med_Hole_Diameter3DU () const noexcept
 GetStats_Med_Hole_Diameter3DU - Average diameter of holes. More...
 
float GetStats_Med_Track_Width () const noexcept
 GetStats_Med_Track_Width - Average width of the tracks. More...
 
unsigned int GetNrSegmentsCircle (float aDiameter3DU) const
 GetNrSegmentsCircle. More...
 
unsigned int GetNrSegmentsCircle (int aDiameterBIU) const
 GetNrSegmentsCircle. More...
 
const MAP_POLYGetPolyMap () const noexcept
 GetPolyMap - Get maps of polygons's layers. More...
 
const SHAPE_POLY_SETGetPolyPlatedPads_Front ()
 
const SHAPE_POLY_SETGetPolyPlatedPads_Back ()
 
const MAP_POLYGetPolyMapHoles_Inner () const noexcept
 
const MAP_POLYGetPolyMapHoles_Outer () 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_opengl_selectionColor
 
SFVEC3F m_raytrace_lightColorCamera
 
SFVEC3F m_raytrace_lightColorTop
 
SFVEC3F m_raytrace_lightColorBottom
 
std::vector< SFVEC3Fm_raytrace_lightColor
 
std::vector< SFVEC2Fm_raytrace_lightSphericalCoords
 
int m_raytrace_nrsamples_shadows
 
int m_raytrace_nrsamples_reflections
 
int m_raytrace_nrsamples_refractions
 
float m_raytrace_spread_shadows
 
float m_raytrace_spread_reflections
 
float m_raytrace_spread_refractions
 
int m_raytrace_recursivelevel_reflections
 
int m_raytrace_recursivelevel_refractions
 

Private Member Functions

bool createBoardPolygon (wxString *aErrorMsg)
 Create the board outline polygon. More...
 
void createLayers (REPORTER *aStatusReporter)
 
void destroyLayers ()
 
void createNewTrack (const TRACK *aTrack, CGENERICCONTAINER2D *aDstContainer, int aClearanceValue)
 
void createNewPadWithClearance (const PAD *aPad, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayer, wxSize aClearanceValue) const
 
COBJECT2DcreateNewPadDrill (const PAD *aPad, int aInflateValue)
 
void AddPadsWithClearanceToContainer (const FOOTPRINT *aFootprint, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
 
void AddFPShapesWithClearanceToContainer (const FOOTPRINT *aFootprint, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue)
 
void AddShapeWithClearanceToContainer (const PCB_TEXT *aText, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void AddShapeWithClearanceToContainer (const PCB_SHAPE *aShape, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void AddShapeWithClearanceToContainer (const DIMENSION_BASE *aDimension, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void AddSolidAreasShapesToContainer (const ZONE *aZoneContainer, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId)
 
void TransformArcToSegments (const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CGENERICCONTAINER2D *aDstContainer, const BOARD_ITEM &aBoardItem)
 
void buildPadShapeThickOutlineAsSegments (const PAD *aPad, CGENERICCONTAINER2D *aDstContainer, int aWidth)
 
void buildPadShapeThickOutlineAsPolygon (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_3d_model_manager
 
COLOR_SETTINGSm_colors
 
std::vector< bool > m_drawFlags
 
GRID3D_TYPE m_3D_grid_type
 
RENDER_ENGINE m_render_engine
 
MATERIAL_MODE m_material_mode
 
ANTIALIASING_MODE m_antialiasing_mode
 
wxPoint m_boardPos
 center board actual position in board units More...
 
wxSize m_boardSize
 board actual size in board units More...
 
SFVEC3F m_boardCenter
 3d center position of the pcb board in 3d units More...
 
CBBOX m_boardBoundingBox
 3d bounding box of the pcb board in 3d units More...
 
MAP_POLY m_layers_poly
 It contains polygon contours for each layer. More...
 
SHAPE_POLY_SETm_F_Cu_PlatedPads_poly
 
SHAPE_POLY_SETm_B_Cu_PlatedPads_poly
 
MAP_POLY m_layers_outer_holes_poly
 It contains polygon contours for holes of each layer (outer holes) More...
 
MAP_POLY m_layers_inner_holes_poly
 It contains polygon contours for holes of each layer (inner holes) More...
 
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH
 It contains polygon contours for (just) non plated through holes (outer cylinder) More...
 
SHAPE_POLY_SET m_through_outer_holes_poly
 It contains polygon contours for through holes (outer cylinder) More...
 
SHAPE_POLY_SET m_through_outer_holes_vias_poly
 It contains polygon contours for through holes vias (outer cylinder) More...
 
SHAPE_POLY_SET m_through_outer_ring_holes_poly
 It contains polygon contours for through holes vias (outer annular ring) More...
 
SHAPE_POLY_SET m_board_poly
 PCB board outline polygon. More...
 
MAP_CONTAINER_2D m_layers_container2D
 It contains the 2d elements of each layer. More...
 
CBVHCONTAINER2Dm_platedpads_container2D_F_Cu
 
CBVHCONTAINER2Dm_platedpads_container2D_B_Cu
 
MAP_CONTAINER_2D m_layers_holes2D
 It contains the holes per each layer. More...
 
CBVHCONTAINER2D m_through_holes_outer
 It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper tickness. More...
 
CBVHCONTAINER2D m_through_holes_outer_ring
 It contains the list of throughHoles of the board, the radius of the hole is inflated with the annular ring size. More...
 
CBVHCONTAINER2D m_through_holes_inner
 It contains the list of throughHoles of the board, the radius is the inner hole. More...
 
CBVHCONTAINER2D m_through_holes_vias_outer
 It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the copper tickness. More...
 
CBVHCONTAINER2D m_through_holes_vias_inner
 It contains the list of throughHoles vias of the board, the radius of the hole. More...
 
unsigned int m_copperLayersCount
 Number of copper layers actually used by the board. More...
 
double m_biuTo3Dunits
 Normalization scale to convert board internal units to 3D units to normalize 3D units between -1.0 and +1.0. More...
 
std::array< float, PCB_LAYER_ID_COUNTm_layerZcoordTop
 Top (End) Z position of each layer (normalized) More...
 
std::array< float, PCB_LAYER_ID_COUNTm_layerZcoordBottom
 Bottom (Start) Z position of each layer (normalized) More...
 
float m_copperThickness3DU
 Copper thickness (normalized) More...
 
float m_epoxyThickness3DU
 Epoxy thickness (normalized) More...
 
float m_nonCopperLayerThickness3DU
 Non copper layers thickness. More...
 
float m_calc_seg_min_factor3DU
 min factor used for cicle segment approximation calculation More...
 
float m_calc_seg_max_factor3DU
 max factor used for cicle segment approximation calculation More...
 
unsigned int m_stats_nr_tracks
 Number of tracks in the board. More...
 
float m_stats_track_med_width
 Track average width. More...
 
unsigned int m_stats_nr_vias
 Nr of vias. More...
 
float m_stats_via_med_hole_diameter
 Computed medium diameter of the via holes in 3D units. More...
 
unsigned int m_stats_nr_holes
 number of holes in the board More...
 
float m_stats_hole_med_diameter
 Computed medium diameter of the holes in 3D units. More...
 

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

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

Definition at line 68 of file board_adapter.h.

Constructor & Destructor Documentation

◆ BOARD_ADAPTER()

BOARD_ADAPTER::BOARD_ADAPTER ( )

Definition at line 50 of file board_adapter.cpp.

50  :
51  m_board( nullptr ),
52  m_3d_model_manager( nullptr ),
53  m_colors( nullptr ),
56 {
57  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
58 
61  m_drawFlags.resize( FL_LAST, false );
62 
63  if( PgmOrNull() )
64  m_colors = Pgm().GetSettingsManager().GetColorSettings();
65 
68 
69  m_boardPos = wxPoint();
70  m_boardSize = wxSize();
71  m_boardCenter = SFVEC3F( 0.0f );
72 
74 
78 
80  m_epoxyThickness3DU = 0.0f;
81  m_copperThickness3DU = 0.0f;
83  m_biuTo3Dunits = 1.0;
84 
86  m_stats_nr_vias = 0;
88  m_stats_nr_holes = 0;
91 
94 
97  SetFlag( FL_SHOW_BOARD_BODY, true );
102  SetFlag( FL_ZONE, true );
103  SetFlag( FL_SILKSCREEN, true );
104  SetFlag( FL_SOLDERMASK, true );
106 
112 
113  SetFlag( FL_USE_SELECTION, true );
114 
115  m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
116  m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );
117  m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 0.9 );
118  m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
119  m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
120  m_SolderPasteColor = SFVEC4F( 0.4, 0.4, 0.4, 1.0 );
121  m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
122  m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
123  m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
124 
127 
128  m_F_Cu_PlatedPads_poly = nullptr;
129  m_B_Cu_PlatedPads_poly = nullptr;
130 
131  // Avoid raytracing options not initialized:
135 
139 
142 }
GRID3D_TYPE m_3D_grid_type
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
int m_raytrace_nrsamples_refractions
CBVHCONTAINER2D * m_platedpads_container2D_B_Cu
float m_nonCopperLayerThickness3DU
Non copper layers thickness.
float m_raytrace_spread_reflections
SHAPE_POLY_SET * m_B_Cu_PlatedPads_poly
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
COLOR_SETTINGS * m_colors
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
unsigned int m_stats_nr_holes
number of holes in the board
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
CBVHCONTAINER2D m_through_holes_outer_ring
It contains the list of throughHoles of the board, the radius of the hole is inflated with the annula...
wxPoint m_boardPos
center board actual position in board units
S3D_CACHE * m_3d_model_manager
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Bottom (Start) Z position of each layer (normalized)
float m_epoxyThickness3DU
Epoxy thickness (normalized)
unsigned int m_stats_nr_vias
Nr of vias.
float m_copperThickness3DU
Copper thickness (normalized)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
RENDER_ENGINE m_render_engine
SHAPE_POLY_SET * m_F_Cu_PlatedPads_poly
float m_raytrace_spread_shadows
SFVEC4F m_BgColorTop
background top color
std::vector< bool > m_drawFlags
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Top (End) Z position of each layer (normalized)
int m_raytrace_nrsamples_shadows
CBBOX m_boardBoundingBox
3d bounding box of the pcb board in 3d units
Use all material properties from model file.
float m_raytrace_spread_refractions
float m_stats_track_med_width
Track average width.
float m_calc_seg_max_factor3DU
max factor used for cicle segment approximation calculation
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
SFVEC4F m_BgColorBot
background bottom color
int m_raytrace_recursivelevel_reflections
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...
wxSize m_boardSize
board actual size in board units
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
unsigned int m_copperLayersCount
Number of copper layers actually used by the board.
SFVEC4F m_CopperColor
in realistic mode: copper color
float m_stats_via_med_hole_diameter
Computed medium diameter of the via holes in 3D units.
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
float m_stats_hole_med_diameter
Computed medium diameter of the holes in 3D units.
SFVEC3F m_boardCenter
3d center position of the pcb board in 3d units
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
MATERIAL_MODE m_material_mode
PGM_BASE * PgmOrNull()
similat to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
int m_raytrace_recursivelevel_refractions
ANTIALIASING_MODE m_antialiasing_mode
CBVHCONTAINER2D * m_platedpads_container2D_F_Cu
float m_calc_seg_min_factor3DU
min factor used for cicle segment approximation calculation
void Reset()
Function Reset reset the bounding box to zero and de-initialized it.
Definition: cbbox.cpp:99
unsigned int m_stats_nr_tracks
Number of tracks in the board.
void Clear() override
int m_raytrace_nrsamples_reflections

References AA_8X, CBVHCONTAINER2D::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_3D_grid_type, m_antialiasing_mode, m_B_Cu_PlatedPads_poly, m_BgColorBot, m_BgColorTop, m_biuTo3Dunits, m_BoardBodyColor, m_boardBoundingBox, m_boardCenter, m_boardPos, m_boardSize, m_calc_seg_max_factor3DU, m_calc_seg_min_factor3DU, m_colors, m_CopperColor, m_copperLayersCount, m_copperThickness3DU, m_drawFlags, m_epoxyThickness3DU, m_F_Cu_PlatedPads_poly, m_logTrace, m_material_mode, m_nonCopperLayerThickness3DU, m_platedpads_container2D_B_Cu, m_platedpads_container2D_F_Cu, m_raytrace_nrsamples_reflections, m_raytrace_nrsamples_refractions, m_raytrace_nrsamples_shadows, m_raytrace_recursivelevel_reflections, m_raytrace_recursivelevel_refractions, m_raytrace_spread_reflections, m_raytrace_spread_refractions, m_raytrace_spread_shadows, m_render_engine, m_SilkScreenColorBot, m_SilkScreenColorTop, m_SolderMaskColorBot, m_SolderMaskColorTop, m_SolderPasteColor, m_stats_hole_med_diameter, m_stats_nr_holes, m_stats_nr_tracks, m_stats_nr_vias, m_stats_track_med_width, m_stats_via_med_hole_diameter, m_through_holes_inner, m_through_holes_outer, m_through_holes_outer_ring, NONE, NORMAL, OPENGL_LEGACY, Pgm(), PgmOrNull(), CBBOX::Reset(), and SetFlag().

◆ ~BOARD_ADAPTER()

BOARD_ADAPTER::~BOARD_ADAPTER ( )

Definition at line 145 of file board_adapter.cpp.

146 {
147  destroyLayers();
148 }

References destroyLayers().

Member Function Documentation

◆ AddFPShapesWithClearanceToContainer()

void BOARD_ADAPTER::AddFPShapesWithClearanceToContainer ( const FOOTPRINT aFootprint,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aInflateValue 
)
private

Definition at line 188 of file create_3Dgraphic_brd_items.cpp.

192 {
193  std::vector<FP_TEXT*> texts; // List of FP_TEXT to convert
194  FP_SHAPE* outline;
195 
196  for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
197  {
198  switch( item->Type() )
199  {
200  case PCB_FP_TEXT_T:
201  {
202  FP_TEXT* text = static_cast<FP_TEXT*>( item );
203 
204  if( text->GetLayer() == aLayerId && text->IsVisible() )
205  texts.push_back( text );
206  }
207  break;
208 
209 
210  case PCB_FP_SHAPE_T:
211  {
212  outline = (FP_SHAPE*) item;
213 
214  if( outline->GetLayer() != aLayerId )
215  break;
216 
217  AddShapeWithClearanceToContainer( (const PCB_SHAPE*) outline, aDstContainer,
218  aLayerId, 0 );
219  }
220  break;
221 
222  default:
223  break;
224  }
225  }
226 
227  // Convert texts sur footprints
228  if( aFootprint->Reference().GetLayer() == aLayerId && aFootprint->Reference().IsVisible() )
229  texts.push_back( &aFootprint->Reference() );
230 
231  if( aFootprint->Value().GetLayer() == aLayerId && aFootprint->Value().IsVisible() )
232  texts.push_back( &aFootprint->Value() );
233 
234  s_boardItem = (const BOARD_ITEM *)&aFootprint->Value();
235  s_dstcontainer = aDstContainer;
237 
238  for( FP_TEXT* text : texts )
239  {
240  s_textWidth = text->GetEffectiveTextPenWidth() + ( 2 * aInflateValue );
241  wxSize size = text->GetTextSize();
242  bool forceBold = true;
243  int penWidth = 0; // force max width for bold
244 
245  if( text->IsMirrored() )
246  size.x = -size.x;
247 
248  GRText( NULL, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(),
249  size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(),
250  forceBold, addTextSegmToContainer );
251  }
252 }
virtual double GetDrawRotation() const override
Definition: fp_text.cpp:247
void AddShapeWithClearanceToContainer(const PCB_TEXT *aText, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:206
bool IsMirrored() const
Definition: eda_text.h:195
class FP_TEXT, text in a footprint
Definition: typeinfo.h:93
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
bool IsVisible() const
Definition: eda_text.h:192
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
Definition: color4d.h:45
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:473
static int s_textWidth
bool IsItalic() const
Definition: eda_text.h:186
FP_TEXT & Reference()
Definition: footprint.h:474
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
#define NULL
static float s_biuTo3Dunits
const wxSize & GetTextSize() const
Definition: eda_text.h:245
static CGENERICCONTAINER2D * s_dstcontainer
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
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:422
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
Definition: board_item.h:185

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

Referenced by createLayers().

◆ AddPadsWithClearanceToContainer()

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

Definition at line 476 of file create_3Dgraphic_brd_items.cpp.

483 {
484  for( PAD* pad : aFootprint->Pads() )
485  {
486  if( !pad->IsOnLayer( aLayerId ) )
487  continue;
488 
489  // Skip pad annulus when not connected on this layer (if removing is enabled)
490  if( !pad->FlashLayer( aLayerId ) && IsCopperLayer( aLayerId ) )
491  continue;
492 
493  // NPTH pads are not drawn on layers if the
494  // shape size and pos is the same as their hole:
495  if( aSkipNPTHPadsWihNoCopper && ( pad->GetAttribute() == PAD_ATTRIB_NPTH ) )
496  {
497  if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == wxPoint( 0, 0 ) )
498  {
499  switch( pad->GetShape() )
500  {
501  case PAD_SHAPE_CIRCLE:
502  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
503  continue;
504  break;
505 
506  case PAD_SHAPE_OVAL:
507  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
508  continue;
509  break;
510 
511  default:
512  break;
513  }
514  }
515  }
516 
517  const bool isPlated = ( ( aLayerId == F_Cu ) && pad->FlashLayer( F_Mask ) ) ||
518  ( ( aLayerId == B_Cu ) && pad->FlashLayer( B_Mask ) );
519 
520  if( aSkipPlatedPads && isPlated )
521  continue;
522 
523  if( aSkipNonPlatedPads && !isPlated )
524  continue;
525 
526  wxSize margin( aInflateValue, aInflateValue );
527 
528  switch( aLayerId )
529  {
530  case F_Mask:
531  case B_Mask:
532  margin.x += pad->GetSolderMaskMargin();
533  margin.y += pad->GetSolderMaskMargin();
534  break;
535 
536  case F_Paste:
537  case B_Paste:
538  margin += pad->GetSolderPasteMargin();
539  break;
540 
541  default:
542  break;
543  }
544 
545  createNewPadWithClearance( pad, aDstContainer, aLayerId, margin );
546  }
547 }
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.
void createNewPadWithClearance(const PAD *aPad, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayer, wxSize aClearanceValue) const
Definition: pad.h:59

References B_Cu, B_Mask, B_Paste, createNewPadWithClearance(), 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().

◆ AddShapeWithClearanceToContainer() [1/3]

void BOARD_ADAPTER::AddShapeWithClearanceToContainer ( const PCB_TEXT aText,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 87 of file create_3Dgraphic_brd_items.cpp.

91 {
92  wxSize size = aText->GetTextSize();
93 
94  if( aText->IsMirrored() )
95  size.x = -size.x;
96 
97  s_boardItem = (const BOARD_ITEM *) &aText;
98  s_dstcontainer = aDstContainer;
99  s_textWidth = aText->GetEffectiveTextPenWidth() + ( 2 * aClearanceValue );
101 
102  // not actually used, but needed by GRText
103  const COLOR4D dummy_color = COLOR4D::BLACK;
104  bool forceBold = true;
105  int penWidth = 0; // force max width for bold
106 
107  if( aText->IsMultilineAllowed() )
108  {
109  wxArrayString strings_list;
110  wxStringSplit( aText->GetShownText(), strings_list, '\n' );
111  std::vector<wxPoint> positions;
112  positions.reserve( strings_list.Count() );
113  aText->GetLinePositions( positions, strings_list.Count() );
114 
115  for( unsigned ii = 0; ii < strings_list.Count(); ++ii )
116  {
117  wxString txt = strings_list.Item( ii );
118 
119  GRText( nullptr, positions[ii], dummy_color, txt, aText->GetTextAngle(), size,
120  aText->GetHorizJustify(), aText->GetVertJustify(), penWidth,
121  aText->IsItalic(), forceBold, addTextSegmToContainer );
122  }
123  }
124  else
125  {
126  GRText( nullptr, aText->GetTextPos(), dummy_color, aText->GetShownText(),
127  aText->GetTextAngle(), size, aText->GetHorizJustify(), aText->GetVertJustify(),
128  penWidth, aText->IsItalic(), forceBold, addTextSegmToContainer );
129  }
130 }
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:206
bool IsMirrored() const
Definition: eda_text.h:195
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
double GetTextAngle() const
Definition: eda_text.h:180
Definition: color4d.h:45
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:186
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
static CGENERICCONTAINER2D * s_dstcontainer
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
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:796
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
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

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 AddFPShapesWithClearanceToContainer(), AddShapeWithClearanceToContainer(), and createLayers().

◆ AddShapeWithClearanceToContainer() [2/3]

void BOARD_ADAPTER::AddShapeWithClearanceToContainer ( const PCB_SHAPE aShape,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 625 of file create_3Dgraphic_brd_items.cpp.

629 {
630  // The full width of the lines to create
631  // The extra 1 protects the inner/outer radius values from degeneracy
632  const int linewidth = aShape->GetWidth() + ( 2 * aClearanceValue ) + 1;
633 
634  switch( aShape->GetShape() )
635  {
636  case S_CIRCLE:
637  {
638  const SFVEC2F center3DU( aShape->GetCenter().x * m_biuTo3Dunits,
639  -aShape->GetCenter().y * m_biuTo3Dunits );
640 
641  float inner_radius = ( aShape->GetRadius() - linewidth / 2 ) * m_biuTo3Dunits;
642  float outer_radius = ( aShape->GetRadius() + linewidth / 2 ) * m_biuTo3Dunits;
643 
644  if( inner_radius < 0 )
645  inner_radius = 0;
646 
647  if( aShape->IsFilled() )
648  aDstContainer->Add( new CFILLEDCIRCLE2D( center3DU, outer_radius, *aShape ) );
649  else
650  aDstContainer->Add( new CRING2D( center3DU, inner_radius, outer_radius, *aShape ) );
651  }
652  break;
653 
654  case S_RECT:
655  if( aShape->IsFilled() )
656  {
657  SHAPE_POLY_SET polyList;
658 
659  aShape->TransformShapeWithClearanceToPolygon( polyList, aLayerId, linewidth / 2,
660  ARC_HIGH_DEF, ERROR_INSIDE );
661 
662  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
663 
664  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
665  *aShape );
666  }
667  else
668  {
669  std::vector<wxPoint> pts = aShape->GetRectCorners();
670 
671  const SFVEC2F topLeft3DU( pts[0].x * m_biuTo3Dunits, -pts[0].y * m_biuTo3Dunits );
672  const SFVEC2F topRight3DU( pts[1].x * m_biuTo3Dunits, -pts[1].y * m_biuTo3Dunits );
673  const SFVEC2F botRight3DU( pts[2].x * m_biuTo3Dunits, -pts[2].y * m_biuTo3Dunits );
674  const SFVEC2F botLeft3DU( pts[3].x * m_biuTo3Dunits, -pts[3].y * m_biuTo3Dunits );
675 
676  aDstContainer->Add( new CROUNDSEGMENT2D( topLeft3DU, topRight3DU,
677  linewidth * m_biuTo3Dunits, *aShape ) );
678  aDstContainer->Add( new CROUNDSEGMENT2D( topRight3DU, botRight3DU,
679  linewidth * m_biuTo3Dunits, *aShape ) );
680  aDstContainer->Add( new CROUNDSEGMENT2D( botRight3DU, botLeft3DU,
681  linewidth * m_biuTo3Dunits, *aShape ) );
682  aDstContainer->Add( new CROUNDSEGMENT2D( botLeft3DU, topLeft3DU,
683  linewidth * m_biuTo3Dunits, *aShape ) );
684  }
685  break;
686 
687  case S_ARC:
688  {
689  unsigned int segCount = GetNrSegmentsCircle( aShape->GetBoundingBox().GetSizeMax() );
690 
691  TransformArcToSegments( aShape->GetCenter(), aShape->GetArcStart(), aShape->GetAngle(),
692  segCount, linewidth, aDstContainer, *aShape );
693  }
694  break;
695 
696  case S_SEGMENT:
697  {
698  const SFVEC2F start3DU( aShape->GetStart().x * m_biuTo3Dunits,
699  -aShape->GetStart().y * m_biuTo3Dunits );
700 
701  const SFVEC2F end3DU ( aShape->GetEnd().x * m_biuTo3Dunits,
702  -aShape->GetEnd().y * m_biuTo3Dunits );
703 
704  if( Is_segment_a_circle( start3DU, end3DU ) )
705  {
706  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, ( linewidth / 2 ) * m_biuTo3Dunits,
707  *aShape ) );
708  }
709  else
710  {
711  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, linewidth * m_biuTo3Dunits,
712  *aShape ) );
713  }
714  }
715  break;
716 
717  case S_CURVE:
718  case S_POLYGON:
719  {
720  SHAPE_POLY_SET polyList;
721 
722  aShape->TransformShapeWithClearanceToPolygon( polyList, aLayerId, linewidth / 2,
723  ARC_HIGH_DEF, ERROR_INSIDE );
724 
725  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
726 
727  if( polyList.IsEmpty() ) // Just for caution
728  break;
729 
730  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
731  *aShape );
732  }
733  break;
734 
735  default:
736  wxFAIL_MSG( "BOARD_ADAPTER::AddShapeWithClearanceToContainer no implementation for "
737  + PCB_SHAPE_TYPE_T_asString( aShape->GetShape() ) );
738  break;
739  }
740 }
bool IsFilled() const
Definition: pcb_shape.h:96
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
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
segment with non rounded ends
Definition: board_item.h:53
wxPoint GetArcStart() const
Definition: pcb_shape.h:178
void TransformArcToSegments(const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CGENERICCONTAINER2D *aDstContainer, const BOARD_ITEM &aBoardItem)
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
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:61
wxPoint GetCenter() const override
Function GetCenter()
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
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns 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:55
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:57
int GetSizeMax() const
GetSizeMax.
Definition: eda_rect.h:109
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)

References CGENERICCONTAINER2D::Add(), Convert_shape_line_polygon_to_triangles(), ERROR_INSIDE, PCB_SHAPE::GetAngle(), PCB_SHAPE::GetArcStart(), PCB_SHAPE::GetBoundingBox(), PCB_SHAPE::GetCenter(), PCB_SHAPE::GetEnd(), GetNrSegmentsCircle(), 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().

◆ AddShapeWithClearanceToContainer() [3/3]

void BOARD_ADAPTER::AddShapeWithClearanceToContainer ( const DIMENSION_BASE aDimension,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 133 of file create_3Dgraphic_brd_items.cpp.

136 {
137  AddShapeWithClearanceToContainer(&aDimension->Text(), aDstContainer, aLayerId, aClearanceValue);
138 
139  const int linewidth = aDimension->GetLineThickness() + (2 * aClearanceValue);
140 
141  for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
142  {
143  switch( shape->Type() )
144  {
145  case SH_SEGMENT:
146  {
147  const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
148 
149  const SFVEC2F start3DU( seg.A.x * m_biuTo3Dunits,
150  -seg.A.y * m_biuTo3Dunits );
151 
152  const SFVEC2F end3DU ( seg.B.x * m_biuTo3Dunits,
153  -seg.B.y * m_biuTo3Dunits );
154 
155  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
156  end3DU,
157  linewidth * m_biuTo3Dunits,
158  *aDimension ) );
159  break;
160  }
161 
162  case SH_CIRCLE:
163  {
164  int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
165  int deltar = aDimension->GetLineThickness();
166 
167  SFVEC2F center( shape->Centre().x * m_biuTo3Dunits,
168  shape->Centre().y * m_biuTo3Dunits );
169 
170  aDstContainer->Add( new CRING2D( center, ( radius - deltar ) * m_biuTo3Dunits,
171  ( radius + deltar ) * m_biuTo3Dunits, *aDimension ) );
172 
173  break;
174  }
175 
176  default:
177  break;
178  }
179 
180  }
181 
182 }
void AddShapeWithClearanceToContainer(const PCB_TEXT *aText, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
int GetLineThickness() const
Definition: dimension.h:187
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
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
line chain (polyline)
Definition: shape.h:46
Definition: seg.h:39
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
VECTOR2I A
Definition: seg.h:47
axis-aligned rectangle
Definition: shape.h:44
VECTOR2I B
Definition: seg.h:48

References SEG::A, CGENERICCONTAINER2D::Add(), AddShapeWithClearanceToContainer(), SEG::B, DIMENSION_BASE::GetLineThickness(), DIMENSION_BASE::GetShapes(), m_biuTo3Dunits, SH_CIRCLE, SH_SEGMENT, DIMENSION_BASE::Text(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ AddSolidAreasShapesToContainer()

void BOARD_ADAPTER::AddSolidAreasShapesToContainer ( const ZONE aZoneContainer,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId 
)
private

Definition at line 746 of file create_3Dgraphic_brd_items.cpp.

749 {
750  // Copy the polys list because we have to simplify it
751  SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList( aLayerId ) );
752 
753  // This convert the poly in outline and holes
754  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
755  *aZoneContainer );
756 
757  // add filled areas outlines, which are drawn with thick lines segments
758  // but only if filled polygons outlines have thickness
759  if( !aZoneContainer->GetFilledPolysUseThickness() )
760  return;
761 
762  float line_thickness = aZoneContainer->GetMinThickness() * m_biuTo3Dunits;
763 
764  for( int i = 0; i < polyList.OutlineCount(); ++i )
765  {
766  // Add outline
767  const SHAPE_LINE_CHAIN& pathOutline = polyList.COutline( i );
768 
769  for( int j = 0; j < pathOutline.PointCount(); ++j )
770  {
771  const VECTOR2I& a = pathOutline.CPoint( j );
772  const VECTOR2I& b = pathOutline.CPoint( j + 1 );
773 
774  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
775  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
776 
777  if( Is_segment_a_circle( start3DU, end3DU ) )
778  {
779  float radius = line_thickness/2;
780 
781  if( radius > 0.0 ) // degenerated circles crash 3D viewer
782  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius,
783  *aZoneContainer ) );
784  }
785  else
786  {
787  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, line_thickness,
788  *aZoneContainer ) );
789  }
790  }
791 
792  // Add holes (of the poly, ie: the open parts) for this outline
793  for( int h = 0; h < polyList.HoleCount( i ); ++h )
794  {
795  const SHAPE_LINE_CHAIN& pathHole = polyList.CHole( i, h );
796 
797  for( int j = 0; j < pathHole.PointCount(); j++ )
798  {
799  const VECTOR2I& a = pathHole.CPoint( j );
800  const VECTOR2I& b = pathHole.CPoint( j + 1 );
801 
802  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
803  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
804 
805  if( Is_segment_a_circle( start3DU, end3DU ) )
806  {
807  float radius = line_thickness/2;
808 
809  if( radius > 0.0 ) // degenerated circles crash 3D viewer
810  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius,
811  *aZoneContainer ) );
812  }
813  else
814  {
815  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, line_thickness,
816  *aZoneContainer ) );
817  }
818  }
819  }
820  }
821 }
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:647
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
int GetMinThickness() const
Definition: zone.h:242
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SHAPE_POLY_SET.
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
int HoleCount(int aOutline) const
Returns the number of holes in a given outline
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
bool GetFilledPolysUseThickness() const
Definition: zone.h:704

References CGENERICCONTAINER2D::Add(), SHAPE_POLY_SET::CHole(), Convert_shape_line_polygon_to_triangles(), 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().

◆ AntiAliasingGet()

ANTIALIASING_MODE BOARD_ADAPTER::AntiAliasingGet ( ) const
inline

GridGet - get the current antialiasing mode value.

Returns
antialiasing mode value

Definition at line 260 of file board_adapter.h.

260 { return m_antialiasing_mode; }
ANTIALIASING_MODE m_antialiasing_mode

References m_antialiasing_mode.

Referenced by EDA_3D_VIEWER::SaveSettings(), and DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow().

◆ AntiAliasingSet()

void BOARD_ADAPTER::AntiAliasingSet ( ANTIALIASING_MODE  aAAmode)
inline

AntiAliasingSet - set the current antialiasing mode value.

Parameters
aAAmode= antialiasing mode value

Definition at line 266 of file board_adapter.h.

266 { m_antialiasing_mode = aAAmode; }
ANTIALIASING_MODE m_antialiasing_mode

References m_antialiasing_mode.

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

◆ BiuTo3Dunits()

double BOARD_ADAPTER::BiuTo3Dunits ( ) const
inlinenoexcept

◆ buildPadShapeThickOutlineAsPolygon()

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

Definition at line 37 of file create_layer_poly.cpp.

40 {
41  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
42  {
43  TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(), aPad->GetSize().x / 2,
44  aWidth, ARC_HIGH_DEF, ERROR_INSIDE );
45  return;
46  }
47 
48  // For other shapes, add outlines as thick segments in polygon buffer
49  const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
50  const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
51 
52  for( int ii = 0; ii < path.PointCount(); ++ii )
53  {
54  const VECTOR2I& a = path.CPoint( ii );
55  const VECTOR2I& b = path.CPoint( ii + 1 );
56 
57  TransformOvalToPolygon( aCornerBuffer, (wxPoint) a, (wxPoint) b, aWidth, ARC_HIGH_DEF,
58  ERROR_INSIDE );
59  }
60 }
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID=UNDEFINED_LAYER) const
Definition: pcbnew/pad.cpp:252
PAD_SHAPE_T GetShape() const
Definition: pad.h:159
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:609
const wxSize & GetSize() const
Definition: pad.h:226
SHAPE_LINE_CHAIN.
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().

◆ buildPadShapeThickOutlineAsSegments()

void BOARD_ADAPTER::buildPadShapeThickOutlineAsSegments ( const PAD aPad,
CGENERICCONTAINER2D aDstContainer,
int  aWidth 
)
private

Definition at line 825 of file create_3Dgraphic_brd_items.cpp.

828 {
829  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
830  {
831  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
832  -aPad->ShapePos().y * m_biuTo3Dunits );
833 
834  const int radius = aPad->GetSize().x / 2;
835  const float inner_radius = ( radius - aWidth / 2 ) * m_biuTo3Dunits;
836  const float outer_radius = ( radius + aWidth / 2 ) * m_biuTo3Dunits;
837 
838  aDstContainer->Add( new CRING2D( center3DU, inner_radius, outer_radius, *aPad ) );
839 
840  return;
841  }
842 
843  // For other shapes, add outlines as thick segments in polygon buffer
844  const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
845  const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
846 
847  for( int j = 0; j < path.PointCount(); j++ )
848  {
849  const VECTOR2I& a = path.CPoint( j );
850  const VECTOR2I& b = path.CPoint( j + 1 );
851 
852  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
853  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
854 
855  if( Is_segment_a_circle( start3DU, end3DU ) )
856  {
857  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
858  *aPad ) );
859  }
860  else
861  {
862  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
863  *aPad ) );
864  }
865  }
866 }
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID=UNDEFINED_LAYER) const
Definition: pcbnew/pad.cpp:252
PAD_SHAPE_T GetShape() const
Definition: pad.h:159
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
wxPoint ShapePos() const
Definition: pcbnew/pad.cpp:609
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const wxSize & GetSize() const
Definition: pad.h:226
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
SHAPE_LINE_CHAIN.

References CGENERICCONTAINER2D::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 459 of file board_adapter.cpp.

460 {
462 
463  bool success;
464 
465  if( m_board->IsFootprintHolder() )
466  {
467  if( !m_board->GetFirstFootprint() )
468  {
469  if( aErrorMsg )
470  *aErrorMsg = _( "No footprint loaded." );
471 
472  return false;
473  }
474 
477 
478  // Make polygon strictly simple to avoid issues (especially in 3D viewer)
480 
481  if( !success && aErrorMsg )
482  {
483  *aErrorMsg = _( "Footprint outline is missing or malformed. Run Footprint Checker for "
484  "a full analysis." );
485  }
486  }
487  else
488  {
490 
491  if( !success && aErrorMsg )
492  *aErrorMsg = _( "Board outline is missing or malformed. Run DRC for a full analysis." );
493  }
494 
495  return success;
496 }
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:1845
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
Definition: board.h:348
SHAPE_POLY_SET m_board_poly
PCB board outline polygon.
bool BuildFootprintPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aTolerance, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
This function is used to extract a board outline for a footprint view.
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
bool IsFootprintHolder()
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:271
#define _(s)
Definition: 3d_actions.cpp:33
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.

References _, BuildFootprintPolygonOutlines(), BOARD::GetBoardPolygonOutlines(), BOARD::GetDesignSettings(), BOARD::GetFirstFootprint(), BOARD::IsFootprintHolder(), m_board, m_board_poly, BOARD_DESIGN_SETTINGS::m_MaxError, 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 124 of file create_layer_items.cpp.

125 {
126  destroyLayers();
127 
128  // Build Copper layers
129  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L692
130  // /////////////////////////////////////////////////////////////////////////
131 
132 #ifdef PRINT_STATISTICS_3D_VIEWER
133  unsigned stats_startCopperLayersTime = GetRunningMicroSecs();
134 
135  unsigned start_Time = stats_startCopperLayersTime;
136 #endif
137 
138  PCB_LAYER_ID cu_seq[MAX_CU_LAYERS];
140 
141  m_stats_nr_tracks = 0;
143  m_stats_nr_vias = 0;
145  m_stats_nr_holes = 0;
147 
148  // Prepare track list, convert in a vector. Calc statistic for the holes
149  // /////////////////////////////////////////////////////////////////////////
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_stats_nr_vias++;
168  }
169  else
170  {
172  }
173 
174  m_stats_track_med_width += track->GetWidth() * m_biuTo3Dunits;
175  }
176 
177  if( m_stats_nr_tracks )
179 
180  if( m_stats_nr_vias )
182 
183  // Prepare copper layers index and containers
184  // /////////////////////////////////////////////////////////////////////////
185  std::vector< PCB_LAYER_ID > layer_id;
186  layer_id.clear();
187  layer_id.reserve( m_copperLayersCount );
188 
189  for( unsigned i = 0; i < arrayDim( cu_seq ); ++i )
190  cu_seq[i] = ToLAYER_ID( B_Cu - i );
191 
192  for( LSEQ cu = cu_set.Seq( cu_seq, arrayDim( cu_seq ) ); cu; ++cu )
193  {
194  const PCB_LAYER_ID curr_layer_id = *cu;
195 
196  if( !Is3DLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
197  continue;
198 
199  layer_id.push_back( curr_layer_id );
200 
201  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
202  m_layers_container2D[curr_layer_id] = layerContainer;
203 
206  {
207  SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET;
208  m_layers_poly[curr_layer_id] = layerPoly;
209  }
210  }
211 
214  {
217 
220 
221  }
222 
223  if( aStatusReporter )
224  aStatusReporter->Report( _( "Create tracks and vias" ) );
225 
226  // Create tracks as objects and add it to container
227  // /////////////////////////////////////////////////////////////////////////
228  for( PCB_LAYER_ID curr_layer_id : layer_id )
229  {
230  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
231 
232  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
233 
234  // Add track segments shapes and via annulus shapes
235  unsigned int nTracks = trackList.size();
236 
237  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
238  {
239  const TRACK *track = trackList[trackIdx];
240 
241  // NOTE: Vias can be on multiple layers
242  if( !track->IsOnLayer( curr_layer_id ) )
243  continue;
244 
245  // Skip vias annulus when not connected on this layer (if removing is enabled)
246  const VIA *via = dyn_cast< const VIA*>( track );
247 
248  if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
249  continue;
250 
251  // Add object item to layer container
252  createNewTrack( track, layerContainer, 0.0f );
253  }
254  }
255 
256  // Create VIAS and THTs objects and add it to holes containers
257  // /////////////////////////////////////////////////////////////////////////
258  for( PCB_LAYER_ID curr_layer_id : layer_id )
259  {
260  // ADD TRACKS
261  unsigned int nTracks = trackList.size();
262 
263  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
264  {
265  const TRACK *track = trackList[trackIdx];
266 
267  if( !track->IsOnLayer( curr_layer_id ) )
268  continue;
269 
270  // ADD VIAS and THT
271  if( track->Type() == PCB_VIA_T )
272  {
273  const VIA* via = static_cast<const VIA*>( track );
274  const VIATYPE viatype = via->GetViaType();
275  const float holediameter = via->GetDrillValue() * BiuTo3Dunits();
276  const float thickness = GetCopperThickness3DU();
277  const float hole_inner_radius = ( holediameter / 2.0f );
278  const float ring_radius = via->GetWidth() * BiuTo3Dunits() / 2.0f;
279 
280  const SFVEC2F via_center(
281  via->GetStart().x * m_biuTo3Dunits, -via->GetStart().y * m_biuTo3Dunits );
282 
283  if( viatype != VIATYPE::THROUGH )
284  {
285 
286  // Add hole objects
287  // /////////////////////////////////////////////////////////
288 
289  CBVHCONTAINER2D *layerHoleContainer = NULL;
290 
291  // Check if the layer is already created
292  if( m_layers_holes2D.find( curr_layer_id ) == m_layers_holes2D.end() )
293  {
294  // not found, create a new container
295  layerHoleContainer = new CBVHCONTAINER2D;
296  m_layers_holes2D[curr_layer_id] = layerHoleContainer;
297  }
298  else
299  {
300  // found
301  layerHoleContainer = m_layers_holes2D[curr_layer_id];
302  }
303 
304  // Add a hole for this layer
305  layerHoleContainer->Add( new CFILLEDCIRCLE2D( via_center,
306  hole_inner_radius + thickness,
307  *track ) );
308  }
309  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
310  {
311  // Add through hole object
312  // /////////////////////////////////////////////////////////
313  m_through_holes_outer.Add( new CFILLEDCIRCLE2D( via_center,
314  hole_inner_radius + thickness,
315  *track ) );
317  new CFILLEDCIRCLE2D( via_center,
318  hole_inner_radius + thickness,
319  *track ) );
320 
323  {
325  ring_radius,
326  *track ) );
327  }
328 
329  m_through_holes_inner.Add( new CFILLEDCIRCLE2D( via_center,
330  hole_inner_radius,
331  *track ) );
332 
333  //m_through_holes_vias_inner.Add( new CFILLEDCIRCLE2D( via_center,
334  // hole_inner_radius,
335  // *track ) );
336  }
337  }
338  }
339  }
340 
341  // Create VIAS and THTs objects and add it to holes containers
342  // /////////////////////////////////////////////////////////////////////////
343  for( PCB_LAYER_ID curr_layer_id : layer_id )
344  {
345  // ADD TRACKS
346  const unsigned int nTracks = trackList.size();
347 
348  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
349  {
350  const TRACK *track = trackList[trackIdx];
351 
352  if( !track->IsOnLayer( curr_layer_id ) )
353  continue;
354 
355  // ADD VIAS and THT
356  if( track->Type() == PCB_VIA_T )
357  {
358  const VIA *via = static_cast< const VIA*>( track );
359  const VIATYPE viatype = via->GetViaType();
360 
361  if( viatype != VIATYPE::THROUGH )
362  {
363  // Add VIA hole contourns
364 
365  // Add outer holes of VIAs
366  SHAPE_POLY_SET *layerOuterHolesPoly = NULL;
367  SHAPE_POLY_SET *layerInnerHolesPoly = NULL;
368 
369  // Check if the layer is already created
370  if( m_layers_outer_holes_poly.find( curr_layer_id ) ==
372  {
373  // not found, create a new container
374  layerOuterHolesPoly = new SHAPE_POLY_SET;
375  m_layers_outer_holes_poly[curr_layer_id] = layerOuterHolesPoly;
376 
377  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) ==
379 
380  layerInnerHolesPoly = new SHAPE_POLY_SET;
381  m_layers_inner_holes_poly[curr_layer_id] = layerInnerHolesPoly;
382  }
383  else
384  {
385  // found
386  layerOuterHolesPoly = m_layers_outer_holes_poly[curr_layer_id];
387 
388  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
390 
391  layerInnerHolesPoly = m_layers_inner_holes_poly[curr_layer_id];
392  }
393 
394  const int holediameter = via->GetDrillValue();
395  const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThicknessBIU();
396 
397  TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
398  hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
399 
400  TransformCircleToPolygon( *layerInnerHolesPoly, via->GetStart(),
401  holediameter / 2, ARC_HIGH_DEF, ERROR_INSIDE );
402  }
403  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
404  {
405  const int holediameter = via->GetDrillValue();
406  const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThicknessBIU();
407  const int hole_outer_ring_radius = via->GetWidth() / 2.0f;
408 
409  // Add through hole contourns
410  // /////////////////////////////////////////////////////////
412  hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
413 
414  // Add same thing for vias only
415 
417  hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
418 
421  {
423  via->GetStart(), hole_outer_ring_radius,
424  ARC_HIGH_DEF, ERROR_INSIDE );
425  }
426  }
427  }
428  }
429  }
430 
431  // Creates vertical outline contours of the tracks and add it to the poly of the layer
432  // /////////////////////////////////////////////////////////////////////////
435  {
436  for( PCB_LAYER_ID curr_layer_id : layer_id )
437  {
438  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
439 
440  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
441 
442  // ADD TRACKS
443  unsigned int nTracks = trackList.size();
444 
445  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
446  {
447  const TRACK *track = trackList[trackIdx];
448 
449  if( !track->IsOnLayer( curr_layer_id ) )
450  continue;
451 
452  // Skip vias annulus when not connected on this layer (if removing is enabled)
453  const VIA *via = dyn_cast< const VIA*>( track );
454 
455  if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
456  continue;
457 
458  // Add the track/via contour
459  track->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
460  ARC_HIGH_DEF, ERROR_INSIDE );
461  }
462  }
463  }
464 
465  // Add holes of footprints
466  // /////////////////////////////////////////////////////////////////////////
467  for( FOOTPRINT* footprint : m_board->Footprints() )
468  {
469  for( PAD* pad : footprint->Pads() )
470  {
471  const wxSize padHole = pad->GetDrillSize();
472 
473  if( !padHole.x ) // Not drilled pad like SMD pad
474  continue;
475 
476  // The hole in the body is inflated by copper thickness, if not plated, no copper
477  const int inflate = ( pad->GetAttribute () != PAD_ATTRIB_NPTH ) ?
479 
481  m_stats_hole_med_diameter += ( ( pad->GetDrillSize().x +
482  pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
483 
484  m_through_holes_outer.Add( createNewPadDrill( pad, inflate ) );
485 
488  {
490  }
491 
493  }
494  }
495 
496  if( m_stats_nr_holes )
498 
499  // Add contours of the pad holes (pads can be Circle or Segment holes)
500  // /////////////////////////////////////////////////////////////////////////
501  for( FOOTPRINT* footprint : m_board->Footprints() )
502  {
503  for( PAD* pad : footprint->Pads() )
504  {
505  const wxSize padHole = pad->GetDrillSize();
506 
507  if( !padHole.x ) // Not drilled pad like SMD pad
508  continue;
509 
510  // The hole in the body is inflated by copper thickness.
511  const int inflate = GetHolePlatingThicknessBIU();
512 
513  if( pad->GetAttribute () != PAD_ATTRIB_NPTH )
514  {
517  {
518  pad->TransformHoleWithClearanceToPolygon( m_through_outer_ring_holes_poly,
519  inflate,
520  ARC_HIGH_DEF, ERROR_INSIDE );
521  }
522 
523  pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly, inflate,
524  ARC_HIGH_DEF, ERROR_INSIDE );
525  }
526  else
527  {
528  // If not plated, no copper.
531  {
532  pad->TransformHoleWithClearanceToPolygon( m_through_outer_ring_holes_poly, 0,
533  ARC_HIGH_DEF, ERROR_INSIDE );
534  }
535 
536  pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly_NPTH, 0,
537  ARC_HIGH_DEF, ERROR_INSIDE );
538  }
539  }
540  }
541 
542  const bool renderPlatedPadsAsPlated = GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) &&
544 
545  // Add footprints PADs objects to containers
546  for( PCB_LAYER_ID curr_layer_id : layer_id )
547  {
548  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
549 
550  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
551 
552  // ADD PADS
553  for( FOOTPRINT* footprint : m_board->Footprints() )
554  {
555  // Note: NPTH pads are not drawn on copper layers when the pad
556  // has same shape as its hole
557  AddPadsWithClearanceToContainer( footprint, layerContainer, curr_layer_id, 0,
558  true, renderPlatedPadsAsPlated, false );
559 
560  // Micro-wave footprints may have items on copper layers
561  AddFPShapesWithClearanceToContainer( footprint, layerContainer, curr_layer_id, 0 );
562  }
563  }
564 
565  if( renderPlatedPadsAsPlated )
566  {
567  // ADD PLATED PADS
568  for( FOOTPRINT* footprint : m_board->Footprints() )
569  {
571  0, true, false, true );
572 
574  0, true, false, true );
575  }
576 
579  }
580 
581  // Add footprints PADs poly contourns (vertical outlines)
584  {
585  for( PCB_LAYER_ID curr_layer_id : layer_id )
586  {
587  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
588 
589  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
590 
591  // Add pads to polygon list
592  for( FOOTPRINT* footprint : m_board->Footprints() )
593  {
594  // Note: NPTH pads are not drawn on copper layers when the pad
595  // has same shape as its hole
596  footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id,
597  0, ARC_HIGH_DEF, ERROR_INSIDE,
598  true, renderPlatedPadsAsPlated,
599  false );
600 
601  transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
602  }
603  }
604 
605  if( renderPlatedPadsAsPlated )
606  {
607  // ADD PLATED PADS contourns
608  for( FOOTPRINT* footprint : m_board->Footprints() )
609  {
610  footprint->TransformPadsWithClearanceToPolygon( *m_F_Cu_PlatedPads_poly, F_Cu,
611  0, ARC_HIGH_DEF, ERROR_INSIDE,
612  true, false, true );
613 
614  //transformFPShapesToPolygon( footprint, F_Cu, *m_F_Cu_PlatedPads_poly );
615 
616  footprint->TransformPadsWithClearanceToPolygon( *m_B_Cu_PlatedPads_poly, B_Cu,
617  0, ARC_HIGH_DEF, ERROR_INSIDE,
618  true, false, true );
619 
620  //transformFPShapesToPolygon( footprint, B_Cu, *m_B_Cu_PlatedPads_poly );
621  }
622  }
623  }
624 
625 
626  // Add graphic item on copper layers to object containers
627  for( PCB_LAYER_ID curr_layer_id : layer_id )
628  {
629  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
630 
631  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
632 
633  // Add graphic items on copper layers (texts and other graphics)
634  for( auto item : m_board->Drawings() )
635  {
636  if( !item->IsOnLayer( curr_layer_id ) )
637  continue;
638 
639  switch( item->Type() )
640  {
641  case PCB_SHAPE_T:
642  AddShapeWithClearanceToContainer( static_cast<PCB_SHAPE*>( item ), layerContainer,
643  curr_layer_id, 0 );
644  break;
645 
646  case PCB_TEXT_T:
647  AddShapeWithClearanceToContainer( static_cast<PCB_TEXT*>( item ), layerContainer,
648  curr_layer_id, 0 );
649  break;
650 
651  case PCB_DIM_ALIGNED_T:
652  case PCB_DIM_CENTER_T:
654  case PCB_DIM_LEADER_T:
655  AddShapeWithClearanceToContainer( static_cast<DIMENSION_BASE*>( item ),
656  layerContainer, curr_layer_id, 0 );
657  break;
658 
659  default:
660  wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
661  item->Type() );
662  break;
663  }
664  }
665  }
666 
667  // Add graphic item on copper layers to poly contourns (vertical outlines)
670  {
671  for( PCB_LAYER_ID cur_layer_id : layer_id )
672  {
673  wxASSERT( m_layers_poly.find( cur_layer_id ) != m_layers_poly.end() );
674 
675  SHAPE_POLY_SET *layerPoly = m_layers_poly[cur_layer_id];
676 
677  // Add graphic items on copper layers (texts and other )
678  for( BOARD_ITEM* item : m_board->Drawings() )
679  {
680  if( !item->IsOnLayer( cur_layer_id ) )
681  continue;
682 
683  switch( item->Type() )
684  {
685  case PCB_SHAPE_T:
686  case PCB_TEXT_T:
687  item->TransformShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
688  ARC_HIGH_DEF, ERROR_INSIDE );
689  break;
690 
691  default:
692  wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
693  item->Type() );
694  break;
695  }
696  }
697  }
698  }
699 
700  if( GetFlag( FL_ZONE ) )
701  {
702  if( aStatusReporter )
703  aStatusReporter->Report( _( "Create zones" ) );
704 
705  std::vector<std::pair<const ZONE*, PCB_LAYER_ID>> zones;
706 
707  for( ZONE* zone : m_board->Zones() )
708  {
709  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
710  zones.emplace_back( std::make_pair( zone, layer ) );
711  }
712 
713  // Add zones objects
714  // /////////////////////////////////////////////////////////////////////
715  std::atomic<size_t> nextZone( 0 );
716  std::atomic<size_t> threadsFinished( 0 );
717 
718  size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency(), 2 );
719  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
720  {
721  std::thread t = std::thread( [&]()
722  {
723  for( size_t areaId = nextZone.fetch_add( 1 );
724  areaId < zones.size();
725  areaId = nextZone.fetch_add( 1 ) )
726  {
727  const ZONE* zone = zones[areaId].first;
728 
729  if( zone == nullptr )
730  break;
731 
732  PCB_LAYER_ID layer = zones[areaId].second;
733 
734  auto layerContainer = m_layers_container2D.find( layer );
735 
736  if( layerContainer != m_layers_container2D.end() )
737  AddSolidAreasShapesToContainer( zone, layerContainer->second, layer );
738  }
739 
740  threadsFinished++;
741  } );
742 
743  t.detach();
744  }
745 
746  while( threadsFinished < parallelThreadCount )
747  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
748 
749  }
750 
753  {
754  // Add copper zones
755  for( ZONE* zone : m_board->Zones() )
756  {
757  if( zone == nullptr )
758  break;
759 
760  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
761  {
762  auto layerContainer = m_layers_poly.find( layer );
763 
764  if( layerContainer != m_layers_poly.end() )
765  zone->TransformSolidAreasShapesToPolygon( layer, *layerContainer->second );
766  }
767  }
768  }
769 
770  // Simplify layer polygons
771 
772  if( aStatusReporter )
773  aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
774 
777  {
780  {
781  if( m_F_Cu_PlatedPads_poly && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) )
782  {
783  SHAPE_POLY_SET *layerPoly_F_Cu = m_layers_poly[F_Cu];
784  layerPoly_F_Cu->BooleanSubtract( *m_F_Cu_PlatedPads_poly, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
785 
787  }
788 
789  if( m_B_Cu_PlatedPads_poly && ( m_layers_poly.find( B_Cu ) != m_layers_poly.end() ) )
790  {
791  SHAPE_POLY_SET *layerPoly_B_Cu = m_layers_poly[B_Cu];
792  layerPoly_B_Cu->BooleanSubtract( *m_B_Cu_PlatedPads_poly, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
793 
795  }
796  }
797 
798  std::vector< PCB_LAYER_ID > &selected_layer_id = layer_id;
799  std::vector< PCB_LAYER_ID > layer_id_without_F_and_B;
800 
803  {
804  layer_id_without_F_and_B.clear();
805  layer_id_without_F_and_B.reserve( layer_id.size() );
806 
807  for( size_t i = 0; i < layer_id.size(); ++i )
808  {
809  if( ( layer_id[i] != F_Cu ) &&
810  ( layer_id[i] != B_Cu ) )
811  layer_id_without_F_and_B.push_back( layer_id[i] );
812  }
813 
814  selected_layer_id = layer_id_without_F_and_B;
815  }
816 
817  if( selected_layer_id.size() > 0 )
818  {
819  std::atomic<size_t> nextItem( 0 );
820  std::atomic<size_t> threadsFinished( 0 );
821 
822  size_t parallelThreadCount = std::min<size_t>(
823  std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
824  selected_layer_id.size() );
825  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
826  {
827  std::thread t = std::thread( [&nextItem, &threadsFinished, &selected_layer_id, this]()
828  {
829  for( size_t i = nextItem.fetch_add( 1 );
830  i < selected_layer_id.size();
831  i = nextItem.fetch_add( 1 ) )
832  {
833  auto layerPoly = m_layers_poly.find( selected_layer_id[i] );
834 
835  if( layerPoly != m_layers_poly.end() )
836  // This will make a union of all added contours
837  layerPoly->second->Simplify( SHAPE_POLY_SET::PM_FAST );
838  }
839 
840  threadsFinished++;
841  } );
842 
843  t.detach();
844  }
845 
846  while( threadsFinished < parallelThreadCount )
847  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
848  }
849  }
850 
851  // Simplify holes polygon contours
852  // /////////////////////////////////////////////////////////////////////////
853  if( aStatusReporter )
854  aStatusReporter->Report( _( "Simplify holes contours" ) );
855 
856  for( PCB_LAYER_ID layer : layer_id )
857  {
858  if( m_layers_outer_holes_poly.find( layer ) != m_layers_outer_holes_poly.end() )
859  {
860  // found
861  SHAPE_POLY_SET *polyLayer = m_layers_outer_holes_poly[layer];
862  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
863 
864  wxASSERT( m_layers_inner_holes_poly.find( layer ) != m_layers_inner_holes_poly.end() );
865 
866  polyLayer = m_layers_inner_holes_poly[layer];
867  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
868  }
869  }
870 
871  // End Build Copper layers
872 
873  // This will make a union of all added contourns
878 
879  // Build Tech layers
880  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
881  // /////////////////////////////////////////////////////////////////////////
882  if( aStatusReporter )
883  aStatusReporter->Report( _( "Build Tech layers" ) );
884 
885  // draw graphic items, on technical layers
886  static const PCB_LAYER_ID teckLayerList[] = {
887  B_Adhes,
888  F_Adhes,
889  B_Paste,
890  F_Paste,
891  B_SilkS,
892  F_SilkS,
893  B_Mask,
894  F_Mask,
895 
896  // Aux Layers
897  Dwgs_User,
898  Cmts_User,
899  Eco1_User,
900  Eco2_User,
901  Edge_Cuts,
902  Margin
903  };
904 
905  // User layers are not drawn here, only technical layers
906  for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, arrayDim( teckLayerList ) );
907  seq;
908  ++seq )
909  {
910  const PCB_LAYER_ID curr_layer_id = *seq;
911 
912  if( !Is3DLayerEnabled( curr_layer_id ) )
913  continue;
914 
915  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
916  m_layers_container2D[curr_layer_id] = layerContainer;
917 
918  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
919  m_layers_poly[curr_layer_id] = layerPoly;
920 
921  // Add drawing objects
922  for( BOARD_ITEM* item : m_board->Drawings() )
923  {
924  if( !item->IsOnLayer( curr_layer_id ) )
925  continue;
926 
927  switch( item->Type() )
928  {
929  case PCB_SHAPE_T:
931  layerContainer,
932  curr_layer_id,
933  0 );
934  break;
935 
936  case PCB_TEXT_T:
938  layerContainer,
939  curr_layer_id,
940  0 );
941  break;
942 
943  case PCB_DIM_ALIGNED_T:
944  case PCB_DIM_CENTER_T:
946  case PCB_DIM_LEADER_T:
948  layerContainer,
949  curr_layer_id,
950  0 );
951  break;
952 
953  default:
954  break;
955  }
956  }
957 
958 
959  // Add drawing contours
960  for( BOARD_ITEM* item : m_board->Drawings() )
961  {
962  if( !item->IsOnLayer( curr_layer_id ) )
963  continue;
964 
965  switch( item->Type() )
966  {
967  case PCB_SHAPE_T:
968  case PCB_TEXT_T:
969  item->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
970  ARC_HIGH_DEF, ERROR_INSIDE );
971  break;
972 
973  default:
974  break;
975  }
976  }
977 
978 
979  // Add footprints tech layers - objects
980  // /////////////////////////////////////////////////////////////////////
981  for( FOOTPRINT* footprint : m_board->Footprints() )
982  {
983  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
984  {
985  int linewidth = g_DrawDefaultLineThickness;
986 
987  for( PAD* pad : footprint->Pads() )
988  {
989  if( !pad->IsOnLayer( curr_layer_id ) )
990  continue;
991 
992  buildPadShapeThickOutlineAsSegments( pad, layerContainer, linewidth );
993  }
994  }
995  else
996  {
997  AddPadsWithClearanceToContainer( footprint, layerContainer, curr_layer_id, 0,
998  false, false, false );
999  }
1000 
1001  AddFPShapesWithClearanceToContainer( footprint, layerContainer, curr_layer_id, 0 );
1002  }
1003 
1004 
1005  // Add footprints tech layers - contours
1006  for( FOOTPRINT* footprint : m_board->Footprints() )
1007  {
1008  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
1009  {
1010  const int linewidth = g_DrawDefaultLineThickness;
1011 
1012  for( PAD* pad : footprint->Pads() )
1013  {
1014  if( !pad->IsOnLayer( curr_layer_id ) )
1015  continue;
1016 
1017  buildPadShapeThickOutlineAsPolygon( pad, *layerPoly, linewidth );
1018  }
1019  }
1020  else
1021  {
1022  footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
1023  ARC_HIGH_DEF, ERROR_INSIDE );
1024  }
1025 
1026  // On tech layers, use a poor circle approximation, only for texts (stroke font)
1027  footprint->TransformFPTextWithClearanceToPolygonSet( *layerPoly, curr_layer_id, 0,
1028  ARC_HIGH_DEF, ERROR_INSIDE );
1029 
1030  // Add the remaining things with dynamic seg count for circles
1031  transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
1032  }
1033 
1034 
1035  // Draw non copper zones
1036  if( GetFlag( FL_ZONE ) )
1037  {
1038  for( ZONE* zone : m_board->Zones() )
1039  {
1040  if( zone->IsOnLayer( curr_layer_id ) )
1041  AddSolidAreasShapesToContainer( zone, layerContainer, curr_layer_id );
1042  }
1043 
1044  for( ZONE* zone : m_board->Zones() )
1045  {
1046  if( zone->IsOnLayer( curr_layer_id ) )
1047  zone->TransformSolidAreasShapesToPolygon( curr_layer_id, *layerPoly );
1048  }
1049  }
1050 
1051  // This will make a union of all added contours
1052  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1053  }
1054  // End Build Tech layers
1055 
1056  // Build BVH (Bounding volume hierarchy) for holes and vias
1057 
1058  if( aStatusReporter )
1059  aStatusReporter->Report( _( "Build BVH for holes and vias" ) );
1060 
1064 
1065  if( !m_layers_holes2D.empty() )
1066  {
1067  for( auto& hole : m_layers_holes2D )
1068  hole.second->BuildBVH();
1069  }
1070 
1071  // We only need the Solder mask to initialize the BVH
1072  // because..?
1074  m_layers_container2D[B_Mask]->BuildBVH();
1075 
1077  m_layers_container2D[F_Mask]->BuildBVH();
1078 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
double BiuTo3Dunits() const noexcept
BiuTo3Dunits - Board integer units To 3D units.
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
Definition: track.h:354
void AddShapeWithClearanceToContainer(const PCB_TEXT *aText, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:101
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
ZONES & Zones()
Definition: board.h:289
CBVHCONTAINER2D * m_platedpads_container2D_B_Cu
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH
It contains polygon contours for (just) non plated through holes (outer cylinder)
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
MAP_POLY m_layers_outer_holes_poly
It contains polygon contours for holes of each layer (outer holes)
const wxPoint & GetStart() const
Definition: track.h:116
SHAPE_POLY_SET * m_B_Cu_PlatedPads_poly
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:103
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.
MAP_POLY m_layers_inner_holes_poly
It contains polygon contours for holes of each layer (inner holes)
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:773
void transformFPShapesToPolygon(const FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer) const
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.
Definition: zone.cpp:288
float GetCopperThickness3DU() const noexcept
GetCopperThickness3DU - Get the current copper layer thickness.
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
void buildPadShapeThickOutlineAsPolygon(const PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: zone.cpp:313
unsigned int m_stats_nr_holes
number of holes in the board
CBVHCONTAINER2D m_through_holes_outer_ring
It contains the list of throughHoles of the board, the radius of the hole is inflated with the annula...
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
SHAPE_POLY_SET m_through_outer_ring_holes_poly
It contains polygon contours for through holes vias (outer annular ring)
unsigned int m_stats_nr_vias
Nr of vias.
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
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
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...
RENDER_ENGINE m_render_engine
SHAPE_POLY_SET * m_F_Cu_PlatedPads_poly
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
Definition: board_item.h:239
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
#define NULL
int GetHolePlatingThicknessBIU() const noexcept
GetCopperThicknessBIU - Get the current copper layer thickness.
MAP_CONTAINER_2D m_layers_holes2D
It contains the holes per each layer.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: track.cpp:170
COBJECT2D * createNewPadDrill(const PAD *aPad, int aInflateValue)
SHAPE_POLY_SET.
bool FlashLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
Definition: track.cpp:481
FOOTPRINTS & Footprints()
Definition: board.h:283
int g_DrawDefaultLineThickness
Default line thickness in internal units used to draw or plot items using a default thickness line va...
SHAPE_POLY_SET m_through_outer_holes_vias_poly
It contains polygon contours for through holes vias (outer cylinder)
float m_stats_track_med_width
Track average width.
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
bool Is3DLayerEnabled(PCB_LAYER_ID aLayer) const
Is3DLayerEnabled - Check if a layer is enabled.
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
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 ...
void AddPadsWithClearanceToContainer(const FOOTPRINT *aFootprint, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
MAP_POLY m_layers_poly
It contains polygon contours for each layer.
CBVHCONTAINER2D m_through_holes_vias_outer
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the c...
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
void AddFPShapesWithClearanceToContainer(const FOOTPRINT *aFootprint, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue)
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
SHAPE_POLY_SET m_through_outer_holes_poly
It contains polygon contours for through holes (outer cylinder)
int GetWidth() const
Definition: track.h:110
#define _(s)
Definition: 3d_actions.cpp:33
unsigned GetRunningMicroSecs()
Function GetRunningMicroSecs An alternate way to calculate an elapset time (in microsecondes) to clas...
unsigned int m_copperLayersCount
Number of copper layers actually used by the board.
void buildPadShapeThickOutlineAsSegments(const PAD *aPad, CGENERICCONTAINER2D *aDstContainer, int aWidth)
VIATYPE GetViaType() const
Definition: track.h:384
float m_stats_via_med_hole_diameter
Computed medium diameter of the via holes in 3D units.
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
void createNewTrack(const TRACK *aTrack, CGENERICCONTAINER2D *aDstContainer, int aClearanceValue)
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
Definition: typeinfo.h:104
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
float m_stats_hole_med_diameter
Computed medium diameter of the holes in 3D units.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset difference For aFastMode meaning, see function booleanOp
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
MAP_CONTAINER_2D m_layers_container2D
It contains the 2d elements of each layer.
VIATYPE
Definition: track.h:68
Definition: pad.h:59
CBVHCONTAINER2D * m_platedpads_container2D_F_Cu
Abstract dimension API.
Definition: dimension.h:95
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91
DRAWINGS & Drawings()
Definition: board.h:286
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:898
unsigned int m_stats_nr_tracks
Number of tracks in the board.
TRACKS & Tracks()
Definition: board.h:280
Definition: track.h:83
void AddSolidAreasShapesToContainer(const ZONE *aZoneContainer, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId)
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References _, CGENERICCONTAINER2D::Add(), AddFPShapesWithClearanceToContainer(), AddPadsWithClearanceToContainer(), AddShapeWithClearanceToContainer(), AddSolidAreasShapesToContainer(), LSET::AllCuMask(), LSET::AllNonCuMask(), arrayDim(), B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, BiuTo3Dunits(), SHAPE_POLY_SET::BooleanSubtract(), CBVHCONTAINER2D::BuildBVH(), buildPadShapeThickOutlineAsPolygon(), buildPadShapeThickOutlineAsSegments(), Cmts_User, createNewPadDrill(), createNewTrack(), 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, GetCopperThickness3DU(), VIA::GetDrillValue(), GetFlag(), GetHolePlatingThicknessBIU(), GetRunningMicroSecs(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), Is3DLayerEnabled(), IsCopperLayer(), BOARD_ITEM::IsOnLayer(), m_B_Cu_PlatedPads_poly, m_biuTo3Dunits, m_board, m_copperLayersCount, m_F_Cu_PlatedPads_poly, m_layers_container2D, m_layers_holes2D, m_layers_inner_holes_poly, m_layers_outer_holes_poly, m_layers_poly, m_logTrace, m_platedpads_container2D_B_Cu, m_platedpads_container2D_F_Cu, m_render_engine, m_stats_hole_med_diameter, m_stats_nr_holes, m_stats_nr_tracks, m_stats_nr_vias, m_stats_track_med_width, m_stats_via_med_hole_diameter, m_through_holes_inner, m_through_holes_outer, m_through_holes_outer_ring, m_through_holes_vias_outer, m_through_outer_holes_poly, m_through_outer_holes_poly_NPTH, m_through_outer_holes_vias_poly, m_through_outer_ring_holes_poly, Margin, MAX_CU_LAYERS, NULL, 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(), EDA_ITEM::Type(), and BOARD::Zones().

Referenced by InitSettings().

◆ createNewPadDrill()

COBJECT2D * BOARD_ADAPTER::createNewPadDrill ( const PAD aPad,
int  aInflateValue 
)
private

Definition at line 438 of file create_3Dgraphic_brd_items.cpp.

439 {
440  wxSize drillSize = aPad->GetDrillSize();
441 
442  if( !drillSize.x || !drillSize.y )
443  {
444  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createNewPadDrill - found an invalid pad" ) );
445  return NULL;
446  }
447 
448  if( drillSize.x == drillSize.y ) // usual round hole
449  {
450  const int radius = (drillSize.x / 2) + aInflateValue;
451 
452  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
453  -aPad->GetPosition().y * m_biuTo3Dunits );
454 
455  return new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad );
456 
457  }
458  else // Oblong hole
459  {
460  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
461  float width = seg->GetWidth() + aInflateValue * 2;
462 
463  SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
464  -seg->GetSeg().A.y * m_biuTo3Dunits );
465 
466  SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
467  -seg->GetSeg().B.y * m_biuTo3Dunits );
468 
469  return new CROUNDSEGMENT2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
470  }
471 
472  return NULL;
473 }
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a SHAPE object representing the pad's hole.
Definition: pcbnew/pad.cpp:270
const SEG & GetSeg() const
const wxSize & GetDrillSize() const
Definition: pad.h:236
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
#define NULL
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
wxPoint GetPosition() const override
Definition: pad.h:167
VECTOR2I A
Definition: seg.h:47
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
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, NULL, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers().

◆ createNewPadWithClearance()

void BOARD_ADAPTER::createNewPadWithClearance ( const PAD aPad,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayer,
wxSize  aClearanceValue 
) const
private

Definition at line 333 of file create_3Dgraphic_brd_items.cpp.

337 {
338  SHAPE_POLY_SET poly;
339 
340  // Our shape-based builder can't handle negative or differing x:y clearance values (the
341  // former are common for solder paste whiel the later get generated when a relative paste
342  // margin is used with an oblong pad). So we apply this huge hack and fake a larger pad to
343  // run the general-purpose polygon builder on.
344  // Of course being a hack it falls down when dealing with custom shape pads (where the size
345  // is only the size of the anchor), so for those we punt and just use aClearanceValue.x.
346 
347  if( ( aClearanceValue.x < 0 || aClearanceValue.x != aClearanceValue.y )
348  && aPad->GetShape() != PAD_SHAPE_CUSTOM )
349  {
350  PAD dummy( *aPad );
351  dummy.SetSize( aPad->GetSize() + aClearanceValue + aClearanceValue );
352  dummy.TransformShapeWithClearanceToPolygon( poly, aLayer, 0, ARC_HIGH_DEF, ERROR_INSIDE );
353  aClearanceValue = { 0, 0 };
354  }
355  else
356  {
357  auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
358 
359  for( const SHAPE* shape : padShapes->Shapes() )
360  {
361  switch( shape->Type() )
362  {
363  case SH_SEGMENT:
364  {
365  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape;
366  const SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
367  -seg->GetSeg().A.y * m_biuTo3Dunits );
368  const SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
369  -seg->GetSeg().B.y * m_biuTo3Dunits );
370  const int width = seg->GetWidth() + aClearanceValue.x * 2;
371 
372  // Cannot add segments that have the same start and end point
373  if( Is_segment_a_circle( start3DU, end3DU ) )
374  {
375  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
376  ( width / 2) * m_biuTo3Dunits,
377  *aPad ) );
378  }
379  else
380  {
381  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
382  width * m_biuTo3Dunits,
383  *aPad ) );
384  }
385  }
386  break;
387 
388  case SH_CIRCLE:
389  {
390  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape;
391  const int radius = circle->GetRadius() + aClearanceValue.x;
392  const SFVEC2F center( circle->GetCenter().x * m_biuTo3Dunits,
393  -circle->GetCenter().y * m_biuTo3Dunits );
394 
395  aDstContainer->Add( new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad ) );
396  }
397  break;
398 
399  case SH_RECT:
400  {
401  SHAPE_RECT* rect = (SHAPE_RECT*) shape;
402 
403  poly.NewOutline();
404  poly.Append( rect->GetPosition() );
405  poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y );
406  poly.Append( rect->GetPosition() + rect->GetSize() );
407  poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y );
408  }
409  break;
410 
411  case SH_SIMPLE:
412  poly.AddOutline( static_cast<const SHAPE_SIMPLE*>( shape )->Vertices() );
413  break;
414 
415  case SH_POLY_SET:
416  poly = *(SHAPE_POLY_SET*) shape;
417  break;
418 
419  default:
420  wxFAIL_MSG( "BOARD_ADAPTER::createNewPadWithClearance no implementation for "
421  + SHAPE_TYPE_asString( shape->Type() ) );
422  break;
423  }
424  }
425  }
426 
427  if( !poly.IsEmpty() )
428  {
429  if( aClearanceValue.x )
430  poly.Inflate( aClearanceValue.x, 32 );
431 
432  // Add the PAD polygon
433  Convert_shape_line_polygon_to_triangles( poly, *aDstContainer, m_biuTo3Dunits, *aPad );
434  }
435 }
int GetRadius() const
Definition: shape_circle.h:99
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
PAD_SHAPE_T GetShape() const
Definition: pad.h:159
const VECTOR2I GetCenter() const
Definition: shape_circle.h:104
void Inflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Performs outline inflation/deflation.
const SEG & GetSeg() const
const VECTOR2I GetSize() const
Function GetSize()
Definition: shape_rect.h:123
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SHAPE_POLY_SET.
const VECTOR2I & GetPosition() const
Function GetPosition()
Definition: shape_rect.h:113
const wxSize & GetSize() const
Definition: pad.h:226
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
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
Function GetEffectiveShape Some pad shapes can be complex (rounded/chamfered rectangle),...
Definition: pcbnew/pad.cpp:261
SHAPE.
Definition: shape.h:122
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
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
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:59
int GetWidth() const
circle
Definition: shape.h:47
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
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, CGENERICCONTAINER2D::Add(), SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::Append(), SEG::B, Convert_shape_line_polygon_to_triangles(), 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 AddPadsWithClearanceToContainer().

◆ createNewTrack()

void BOARD_ADAPTER::createNewTrack ( const TRACK aTrack,
CGENERICCONTAINER2D aDstContainer,
int  aClearanceValue 
)
private

Definition at line 255 of file create_3Dgraphic_brd_items.cpp.

257 {
258  SFVEC2F start3DU( aTrack->GetStart().x * m_biuTo3Dunits,
259  -aTrack->GetStart().y * m_biuTo3Dunits ); // y coord is inverted
260 
261  switch( aTrack->Type() )
262  {
263  case PCB_VIA_T:
264  {
265  const float radius = ( ( aTrack->GetWidth() / 2 ) + aClearanceValue ) * m_biuTo3Dunits;
266  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius, *aTrack ) );
267  }
268  break;
269 
270  case PCB_ARC_T:
271  {
272  const ARC* arc = static_cast<const ARC*>( aTrack );
273  VECTOR2D center( arc->GetCenter() );
274  double arc_angle = arc->GetAngle();
275  double radius = arc->GetRadius();
276  int arcsegcount = GetArcToSegmentCount( radius, Millimeter2iu( 0.005), arc_angle/10 );
277  int circlesegcount;
278 
279  // We need a circle to segment count. However, the arc angle can be small, and the
280  // radius very big. so we calculate a reasonable value for circlesegcount.
281  if( arcsegcount <= 1 ) // The arc will be approximated by a segment
282  circlesegcount = 1;
283  else
284  {
285  double cnt = arcsegcount * 3600/std::abs( arc_angle );
286 
287  #define SEG_CNT_MAX 128
288  if( cnt < SEG_CNT_MAX )
289  {
290  circlesegcount = (int)cnt;
291 
292  if( circlesegcount == 0 )
293  circlesegcount = 1;
294  }
295  else
296  circlesegcount = SEG_CNT_MAX;
297  }
298 
299  TransformArcToSegments( wxPoint( center.x, center.y ), arc->GetStart(),
300  arc_angle, circlesegcount,
301  arc->GetWidth() + 2 * aClearanceValue, aDstContainer,
302  *arc );
303  }
304  break;
305 
306  case PCB_TRACE_T: // Track is a usual straight segment
307  {
308  SFVEC2F end3DU ( aTrack->GetEnd().x * m_biuTo3Dunits,
309  -aTrack->GetEnd().y * m_biuTo3Dunits );
310 
311  // Cannot add segments that have the same start and end point
312  if( Is_segment_a_circle( start3DU, end3DU ) )
313  {
314  const float radius = ((aTrack->GetWidth() / 2) + aClearanceValue) * m_biuTo3Dunits;
315 
316  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius, *aTrack ) );
317  }
318  else
319  {
320  const float width = (aTrack->GetWidth() + 2 * aClearanceValue ) * m_biuTo3Dunits;
321 
322  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, width, *aTrack ) );
323  }
324  }
325  break;
326 
327  default:
328  break;
329  }
330 }
virtual wxPoint GetCenter() const override
Function GetCenter()
Definition: track.h:312
#define SEG_CNT_MAX
const wxPoint & GetStart() const
Definition: track.h:116
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
void TransformArcToSegments(const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CGENERICCONTAINER2D *aDstContainer, const BOARD_ITEM &aBoardItem)
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
double GetRadius() const
Definition: track.cpp:918
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
double GetAngle() const
Definition: track.cpp:924
int GetWidth() const
Definition: track.h:110
Definition: track.h:272
const wxPoint & GetEnd() const
Definition: track.h:113
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
static constexpr int Millimeter2iu(double mm)
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References CGENERICCONTAINER2D::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 57 of file create_layer_items.cpp.

58 {
59  if( !m_layers_poly.empty() )
60  {
61  for( auto& poly : m_layers_poly )
62  delete poly.second;
63 
64  m_layers_poly.clear();
65  }
66 
68  m_F_Cu_PlatedPads_poly = nullptr;
69 
71  m_B_Cu_PlatedPads_poly = nullptr;
72 
73  if( !m_layers_inner_holes_poly.empty() )
74  {
75  for( auto& poly : m_layers_inner_holes_poly )
76  delete poly.second;
77 
79  }
80 
81  if( !m_layers_outer_holes_poly.empty() )
82  {
83  for( auto& poly : m_layers_outer_holes_poly )
84  delete poly.second;
85 
87  }
88 
89  if( !m_layers_container2D.empty() )
90  {
91  for( auto& poly : m_layers_container2D )
92  delete poly.second;
93 
94  m_layers_container2D.clear();
95  }
96 
99 
102 
103  if( !m_layers_holes2D.empty() )
104  {
105  for( auto& poly : m_layers_holes2D )
106  delete poly.second;
107 
108  m_layers_holes2D.clear();
109  }
110 
118 
121 }
CBVHCONTAINER2D * m_platedpads_container2D_B_Cu
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH
It contains polygon contours for (just) non plated through holes (outer cylinder)
MAP_POLY m_layers_outer_holes_poly
It contains polygon contours for holes of each layer (outer holes)
SHAPE_POLY_SET * m_B_Cu_PlatedPads_poly
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.
MAP_POLY m_layers_inner_holes_poly
It contains polygon contours for holes of each layer (inner holes)
CBVHCONTAINER2D m_through_holes_outer_ring
It contains the list of throughHoles of the board, the radius of the hole is inflated with the annula...
SHAPE_POLY_SET m_through_outer_ring_holes_poly
It contains polygon contours for through holes vias (outer annular ring)
SHAPE_POLY_SET * m_F_Cu_PlatedPads_poly
MAP_CONTAINER_2D m_layers_holes2D
It contains the holes per each layer.
SHAPE_POLY_SET m_through_outer_holes_vias_poly
It contains polygon contours for through holes vias (outer cylinder)
MAP_POLY m_layers_poly
It contains polygon contours for each layer.
CBVHCONTAINER2D m_through_holes_vias_outer
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the c...
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...
SHAPE_POLY_SET m_through_outer_holes_poly
It contains polygon contours for through holes (outer cylinder)
CBVHCONTAINER2D m_through_holes_vias_inner
It contains the list of throughHoles vias of the board, the radius of the hole.
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
MAP_CONTAINER_2D m_layers_container2D
It contains the 2d elements of each layer.
CBVHCONTAINER2D * m_platedpads_container2D_F_Cu
void Clear() override

References CBVHCONTAINER2D::Clear(), m_B_Cu_PlatedPads_poly, m_F_Cu_PlatedPads_poly, m_layers_container2D, m_layers_holes2D, m_layers_inner_holes_poly, m_layers_outer_holes_poly, m_layers_poly, m_platedpads_container2D_B_Cu, m_platedpads_container2D_F_Cu, m_through_holes_inner, m_through_holes_outer, m_through_holes_outer_ring, m_through_holes_vias_inner, m_through_holes_vias_outer, m_through_outer_holes_poly, m_through_outer_holes_poly_NPTH, m_through_outer_holes_vias_poly, m_through_outer_ring_holes_poly, and SHAPE_POLY_SET::RemoveAllContours().

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

◆ Get3DCacheManager()

S3D_CACHE* BOARD_ADAPTER::Get3DCacheManager ( ) const
inlinenoexcept

Get3DCacheManager - Return the 3d cache manager pointer.

Returns

Definition at line 89 of file board_adapter.h.

90  {
91  return m_3d_model_manager;
92  }
S3D_CACHE * m_3d_model_manager

References m_3d_model_manager.

Referenced by C3D_RENDER_OGL_LEGACY::load_3D_models(), and C3D_RENDER_RAYTRACING::load_3D_models().

◆ GetBBox3DU()

const CBBOX& BOARD_ADAPTER::GetBBox3DU ( ) const
inlinenoexcept

GetBBox3DU - Get the bbox of the pcb board.

Returns
the board bbox in 3d units

Definition at line 164 of file board_adapter.h.

165  {
166  return m_boardBoundingBox;
167  }
CBBOX m_boardBoundingBox
3d bounding box of the pcb board in 3d units

References m_boardBoundingBox.

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

◆ GetBoard()

◆ GetBoardCenter3DU()

const SFVEC3F& BOARD_ADAPTER::GetBoardCenter3DU ( ) const
inlinenoexcept

GetBoardCenter - the board center position in 3d units.

Returns
board center vector position in 3d units

Definition at line 224 of file board_adapter.h.

225  {
226  return m_boardCenter;
227  }
SFVEC3F m_boardCenter
3d center position of the pcb board in 3d units

References m_boardCenter.

Referenced by C3D_RENDER_RAYTRACING::Reload(), and C3D_RENDER_OGL_LEGACY::reload().

◆ GetBoardPoly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetBoardPoly ( ) const
inlinenoexcept

GetBoardPoly - Get the current polygon of the epoxy board.

Returns
the shape polygon

Definition at line 308 of file board_adapter.h.

309  {
310  return m_board_poly;
311  }
SHAPE_POLY_SET m_board_poly
PCB board outline polygon.

References m_board_poly.

Referenced by C3D_RENDER_RAYTRACING::Reload(), and C3D_RENDER_OGL_LEGACY::reload().

◆ GetBoardPosBIU()

wxPoint BOARD_ADAPTER::GetBoardPosBIU ( ) const
inlinenoexcept

GetBoardPosBIU - Get the board center.

Returns
position in BIU units

Definition at line 215 of file board_adapter.h.

216  {
217  return m_boardPos;
218  }
wxPoint m_boardPos
center board actual position in board units

References m_boardPos.

Referenced by C3D_RENDER_OGL_LEGACY::generate_new_3DGrid().

◆ GetBoardSizeBIU()

wxSize BOARD_ADAPTER::GetBoardSizeBIU ( ) const
inlinenoexcept

GetBoardSizeBIU - Get the board size.

Returns
size in BIU units

Definition at line 206 of file board_adapter.h.

207  {
208  return m_boardSize;
209  }
wxSize m_boardSize
board actual size in board units

References m_boardSize.

Referenced by C3D_RENDER_OGL_LEGACY::generate_new_3DGrid().

◆ GetColor()

SFVEC4F BOARD_ADAPTER::GetColor ( COLOR4D  aColor) const

GetColor.

Parameters
aColorthe color mapped
Returns
the color in SFVEC3F format

Definition at line 534 of file board_adapter.cpp.

535 {
536  return SFVEC4F( aColor.r, aColor.g, aColor.b, aColor.a );
537 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
double g
Green component.
Definition: color4d.h:375
double b
Blue component.
Definition: color4d.h:376
double a
Alpha component.
Definition: color4d.h:377
double r
Red component.
Definition: color4d.h:374

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

Referenced by C3D_RENDER_OGL_LEGACY::generate_new_3DGrid(), GetItemColor(), and EDA_3D_VIEWER::LoadSettings().

◆ GetCopperThickness3DU()

float BOARD_ADAPTER::GetCopperThickness3DU ( ) const
inlinenoexcept

GetCopperThickness3DU - Get the current copper layer thickness.

Returns
thickness in 3d units of copperlayers

Definition at line 191 of file board_adapter.h.

192  {
193  return m_copperThickness3DU;
194  }
float m_copperThickness3DU
Copper thickness (normalized)

References m_copperThickness3DU.

Referenced by createLayers(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), C3D_RENDER_RAYTRACING::insert3DPadHole(), C3D_RENDER_RAYTRACING::insert3DViaHole(), and C3D_RENDER_RAYTRACING::Reload().

◆ GetEpoxyThickness3DU()

float BOARD_ADAPTER::GetEpoxyThickness3DU ( ) const
inlinenoexcept

GetEpoxyThickness3DU - Get the current epoxy thickness.

Returns
thickness in 3d units

Definition at line 173 of file board_adapter.h.

174  {
175  return m_epoxyThickness3DU;
176  }
float m_epoxyThickness3DU
Epoxy thickness (normalized)

References m_epoxyThickness3DU.

Referenced by C3D_RENDER_OGL_LEGACY::render_board_body().

◆ GetFlag()

bool BOARD_ADAPTER::GetFlag ( DISPLAY3D_FLG  aFlag) const

GetFlag - get a configuration status of a flag.

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

Definition at line 226 of file board_adapter.cpp.

227 {
228  wxASSERT( aFlag < FL_LAST );
229 
230  return m_drawFlags[aFlag];
231 }
std::vector< bool > m_drawFlags

References FL_LAST, and m_drawFlags.

Referenced by C3D_RENDER_RAYTRACING::createItemsFromContainer(), createLayers(), EDA_3D_CONDITIONS::flagFunction(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), C3D_RENDER_RAYTRACING::get_3D_model_material(), C3D_RENDER_OGL_LEGACY::get_layer_color(), GetModulesZcoord3DIU(), InitSettings(), C3D_RENDER_RAYTRACING::insert3DPadHole(), C3D_RENDER_RAYTRACING::insert3DViaHole(), Is3DLayerEnabled(), C3D_RENDER_OGL_LEGACY::load_3D_models(), EDA_3D_CANVAS::OnMouseWheel(), C3D_RENDER_OGL_LEGACY::Redraw(), C3D_RENDER_RAYTRACING::Reload(), C3D_RENDER_OGL_LEGACY::reload(), C3D_RENDER_OGL_LEGACY::render_3D_footprint(), C3D_RENDER_OGL_LEGACY::render_3D_models(), C3D_RENDER_OGL_LEGACY::render_3D_models_selected(), C3D_RENDER_RAYTRACING::rt_render_post_process_blur_finish(), C3D_RENDER_RAYTRACING::rt_render_post_process_shade(), C3D_RENDER_RAYTRACING::rt_render_trace_block(), C3D_RENDER_RAYTRACING::rt_render_tracing(), C3D_RENDER_RAYTRACING::rt_trace_AA_packet(), C3D_RENDER_OGL_LEGACY::set_layer_material(), C3D_RENDER_RAYTRACING::setupMaterials(), C3D_RENDER_OGL_LEGACY::setupMaterials(), C3D_RENDER_RAYTRACING::shadeHit(), ShouldFPBeDisplayed(), EDA_3D_CONTROLLER::ToggleVisibility(), and DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow().

◆ GetHolePlatingThicknessBIU()

int BOARD_ADAPTER::GetHolePlatingThicknessBIU ( ) const
noexcept

GetCopperThicknessBIU - Get the current copper layer thickness.

Returns
thickness in board units

Definition at line 256 of file board_adapter.cpp.

257 {
259 }
int GetHolePlatingThickness() const
Pad & via drills are finish size.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559

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

Referenced by createLayers(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), C3D_RENDER_RAYTRACING::insert3DPadHole(), and C3D_RENDER_RAYTRACING::insert3DViaHole().

◆ GetItemColor()

SFVEC4F BOARD_ADAPTER::GetItemColor ( int  aItemId) const

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

529 {
530  return GetColor( m_colors->GetColor( aItemId ) );
531 }
SFVEC4F GetColor(COLOR4D aColor) const
GetColor.
COLOR_SETTINGS * m_colors
COLOR4D GetColor(int aLayer) const

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

Referenced by C3D_RENDER_RAYTRACING::insert3DPadHole(), and C3D_RENDER_RAYTRACING::insert3DViaHole().

◆ GetLayerBottomZpos3DU()

float BOARD_ADAPTER::GetLayerBottomZpos3DU ( PCB_LAYER_ID  aLayerId) const
inlinenoexcept

GetLayerBottomZpos3DU - Get the bottom z position.

Parameters
aLayerIdlayer id
Returns
position in 3D units

Definition at line 349 of file board_adapter.h.

350  {
351  return m_layerZcoordBottom[aLayerId];
352  }
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Bottom (Start) Z position of each layer (normalized)

References m_layerZcoordBottom.

Referenced by C3D_RENDER_RAYTRACING::createItemsFromContainer(), C3D_RENDER_OGL_LEGACY::get_layer_z_pos(), C3D_RENDER_RAYTRACING::insert3DPadHole(), C3D_RENDER_RAYTRACING::insert3DViaHole(), C3D_RENDER_OGL_LEGACY::Redraw(), and C3D_RENDER_RAYTRACING::Reload().

◆ GetLayerColor()

SFVEC4F BOARD_ADAPTER::GetLayerColor ( PCB_LAYER_ID  aLayerId) const

GetLayerColor - get the technical color of a layer.

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

Definition at line 518 of file board_adapter.cpp.

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

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

Referenced by C3D_RENDER_OGL_LEGACY::get_layer_color(), and C3D_RENDER_RAYTRACING::Reload().

◆ GetLayerTopZpos3DU()

float BOARD_ADAPTER::GetLayerTopZpos3DU ( PCB_LAYER_ID  aLayerId) const
inlinenoexcept

GetLayerTopZpos3DU - Get the top z position.

Parameters
aLayerIdlayer id
Returns
position in 3D units

Definition at line 339 of file board_adapter.h.

340  {
341  return m_layerZcoordTop[aLayerId];
342  }
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Top (End) Z position of each layer (normalized)

References m_layerZcoordTop.

Referenced by C3D_RENDER_RAYTRACING::createItemsFromContainer(), C3D_RENDER_OGL_LEGACY::get_layer_z_pos(), C3D_RENDER_OGL_LEGACY::Redraw(), and C3D_RENDER_RAYTRACING::Reload().

◆ GetMapLayers()

const MAP_CONTAINER_2D& BOARD_ADAPTER::GetMapLayers ( ) const
inlinenoexcept

GetMapLayers - Get the map of container that have the objects per layer.

Returns
the map containers of this board

Definition at line 358 of file board_adapter.h.

359  {
360  return m_layers_container2D;
361  }
MAP_CONTAINER_2D m_layers_container2D
It contains the 2d elements of each layer.

References m_layers_container2D.

Referenced by C3D_RENDER_RAYTRACING::createItemsFromContainer(), C3D_RENDER_RAYTRACING::Reload(), and C3D_RENDER_OGL_LEGACY::reload().

◆ GetMapLayersHoles()

const MAP_CONTAINER_2D& BOARD_ADAPTER::GetMapLayersHoles ( ) const
inlinenoexcept

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

Returns
the map containers of holes from this board

Definition at line 377 of file board_adapter.h.

378  {
379  return m_layers_holes2D;
380  }
MAP_CONTAINER_2D m_layers_holes2D
It contains the holes per each layer.

References m_layers_holes2D.

Referenced by C3D_RENDER_RAYTRACING::createItemsFromContainer(), and C3D_RENDER_OGL_LEGACY::reload().

◆ GetModulesZcoord3DIU()

float BOARD_ADAPTER::GetModulesZcoord3DIU ( bool  aIsFlipped) const

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

500 {
501  if( aIsFlipped )
502  {
503  if( GetFlag( FL_SOLDERPASTE ) )
505  else
507  }
508  else
509  {
510  if( GetFlag( FL_SOLDERPASTE ) )
511  return m_layerZcoordTop[F_SilkS];
512  else
513  return m_layerZcoordTop[F_Paste];
514  }
515 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Bottom (Start) Z position of each layer (normalized)
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Top (End) Z position of each layer (normalized)

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

Referenced by C3D_RENDER_RAYTRACING::load_3D_models(), and C3D_RENDER_OGL_LEGACY::render_3D_footprint().

◆ GetNonCopperLayerThickness3DU()

float BOARD_ADAPTER::GetNonCopperLayerThickness3DU ( ) const
inlinenoexcept

GetNonCopperLayerThickness3DU - Get the current non copper layers thickness.

Returns
thickness in 3d units of non copperlayers

Definition at line 182 of file board_adapter.h.

183  {
185  }
float m_nonCopperLayerThickness3DU
Non copper layers thickness.

References m_nonCopperLayerThickness3DU.

Referenced by C3D_RENDER_OGL_LEGACY::render_solder_mask_layer(), and C3D_RENDER_RAYTRACING::shadeHit().

◆ GetNrSegmentsCircle() [1/2]

unsigned int BOARD_ADAPTER::GetNrSegmentsCircle ( float  aDiameter3DU) const

GetNrSegmentsCircle.

Parameters
aDiameter3DUdiameter in 3DU
Returns
number of sides that should be used in that circle

Definition at line 261 of file board_adapter.cpp.

262 {
263  wxASSERT( aDiameter3DU > 0.0f );
264 
265  return GetNrSegmentsCircle( (int)( aDiameter3DU / m_biuTo3Dunits ) );
266 }
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....

References m_biuTo3Dunits.

Referenced by C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer(), AddShapeWithClearanceToContainer(), and C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads().

◆ GetNrSegmentsCircle() [2/2]

unsigned int BOARD_ADAPTER::GetNrSegmentsCircle ( int  aDiameterBIU) const

GetNrSegmentsCircle.

Parameters
aDiameterBIUdiameter in board internal units
Returns
number of sides that should be used in that circle

Definition at line 269 of file board_adapter.cpp.

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

References GetArcToSegmentCount().

◆ GetPlatedPads_Back()

const CBVHCONTAINER2D* BOARD_ADAPTER::GetPlatedPads_Back ( ) const
inlinenoexcept

Definition at line 368 of file board_adapter.h.

369  {
371  }
CBVHCONTAINER2D * m_platedpads_container2D_B_Cu

References m_platedpads_container2D_B_Cu.

Referenced by C3D_RENDER_RAYTRACING::Reload(), and C3D_RENDER_OGL_LEGACY::reload().

◆ GetPlatedPads_Front()

const CBVHCONTAINER2D* BOARD_ADAPTER::GetPlatedPads_Front ( ) const
inlinenoexcept

Definition at line 363 of file board_adapter.h.

364  {
366  }
CBVHCONTAINER2D * m_platedpads_container2D_F_Cu

References m_platedpads_container2D_F_Cu.

Referenced by C3D_RENDER_RAYTRACING::Reload(), and C3D_RENDER_OGL_LEGACY::reload().

◆ GetPolyMap()

const MAP_POLY& BOARD_ADAPTER::GetPolyMap ( ) const
inlinenoexcept

GetPolyMap - Get maps of polygons's layers.

Returns
the map with polygons's layers

Definition at line 502 of file board_adapter.h.

503  {
504  return m_layers_poly;
505  }
MAP_POLY m_layers_poly
It contains polygon contours for each layer.

References m_layers_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetPolyMapHoles_Inner()

const MAP_POLY& BOARD_ADAPTER::GetPolyMapHoles_Inner ( ) const
inlinenoexcept

Definition at line 517 of file board_adapter.h.

518  {
520  }
MAP_POLY m_layers_inner_holes_poly
It contains polygon contours for holes of each layer (inner holes)

References m_layers_inner_holes_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetPolyMapHoles_Outer()

const MAP_POLY& BOARD_ADAPTER::GetPolyMapHoles_Outer ( ) const
inlinenoexcept

Definition at line 522 of file board_adapter.h.

523  {
525  }
MAP_POLY m_layers_outer_holes_poly
It contains polygon contours for holes of each layer (outer holes)

References m_layers_outer_holes_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetPolyPlatedPads_Back()

const SHAPE_POLY_SET* BOARD_ADAPTER::GetPolyPlatedPads_Back ( )
inline

Definition at line 512 of file board_adapter.h.

513  {
514  return m_B_Cu_PlatedPads_poly;
515  }
SHAPE_POLY_SET * m_B_Cu_PlatedPads_poly

References m_B_Cu_PlatedPads_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetPolyPlatedPads_Front()

const SHAPE_POLY_SET* BOARD_ADAPTER::GetPolyPlatedPads_Front ( )
inline

Definition at line 507 of file board_adapter.h.

508  {
509  return m_F_Cu_PlatedPads_poly;
510  }
SHAPE_POLY_SET * m_F_Cu_PlatedPads_poly

References m_F_Cu_PlatedPads_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetStats_Med_Hole_Diameter3DU()

float BOARD_ADAPTER::GetStats_Med_Hole_Diameter3DU ( ) const
inlinenoexcept

GetStats_Med_Hole_Diameter3DU - Average diameter of holes.

Returns
dimension in 3D units

Definition at line 470 of file board_adapter.h.

471  {
473  }
float m_stats_hole_med_diameter
Computed medium diameter of the holes in 3D units.

References m_stats_hole_med_diameter.

Referenced by C3D_RENDER_RAYTRACING::Reload().

◆ GetStats_Med_Track_Width()

float BOARD_ADAPTER::GetStats_Med_Track_Width ( ) const
inlinenoexcept

GetStats_Med_Track_Width - Average width of the tracks.

Returns
dimensions in 3D units

Definition at line 479 of file board_adapter.h.

480  {
482  }
float m_stats_track_med_width
Track average width.

References m_stats_track_med_width.

◆ GetStats_Med_Via_Hole_Diameter3DU()

float BOARD_ADAPTER::GetStats_Med_Via_Hole_Diameter3DU ( ) const
inlinenoexcept

GetStats_Med_Via_Hole_Diameter3DU - Average diameter of the via holes.

Returns
dimension in 3D units

Definition at line 461 of file board_adapter.h.

462  {
464  }
float m_stats_via_med_hole_diameter
Computed medium diameter of the via holes in 3D units.

References m_stats_via_med_hole_diameter.

Referenced by C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), and C3D_RENDER_RAYTRACING::Reload().

◆ GetStats_Nr_Holes()

unsigned int BOARD_ADAPTER::GetStats_Nr_Holes ( ) const
inlinenoexcept

GetStats_Nr_Holes - Get statistics of the nr of holes.

Returns
number of holes

Definition at line 452 of file board_adapter.h.

453  {
454  return m_stats_nr_holes;
455  }
unsigned int m_stats_nr_holes
number of holes in the board

References m_stats_nr_holes.

Referenced by C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), and C3D_RENDER_RAYTRACING::Reload().

◆ GetStats_Nr_Vias()

unsigned int BOARD_ADAPTER::GetStats_Nr_Vias ( ) const
inlinenoexcept

GetStats_Nr_Vias - Get statistics of the nr of vias.

Returns
number of vias

Definition at line 443 of file board_adapter.h.

444  {
445  return m_stats_nr_vias;
446  }
unsigned int m_stats_nr_vias
Nr of vias.

References m_stats_nr_vias.

Referenced by C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), and C3D_RENDER_RAYTRACING::Reload().

◆ GetThroughHole_Inner()

const CBVHCONTAINER2D& BOARD_ADAPTER::GetThroughHole_Inner ( ) const
inlinenoexcept

GetThroughHole_Inner - Get the ThroughHole container.

Returns
a container with holes

Definition at line 434 of file board_adapter.h.

435  {
436  return m_through_holes_inner;
437  }
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.

References m_through_holes_inner.

Referenced by C3D_RENDER_RAYTRACING::insert3DPadHole(), and C3D_RENDER_OGL_LEGACY::reload().

◆ GetThroughHole_Outer()

const CBVHCONTAINER2D& BOARD_ADAPTER::GetThroughHole_Outer ( ) const
inlinenoexcept

GetThroughHole_Outer - Get the inflated ThroughHole container.

Returns
a container with holes

Definition at line 386 of file board_adapter.h.

387  {
388  return m_through_holes_outer;
389  }
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...

References m_through_holes_outer.

Referenced by C3D_RENDER_RAYTRACING::createItemsFromContainer(), C3D_RENDER_RAYTRACING::Reload(), and C3D_RENDER_OGL_LEGACY::reload().

◆ GetThroughHole_Outer_poly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHole_Outer_poly ( ) const
inlinenoexcept

Definition at line 401 of file board_adapter.h.

402  {
404  }
SHAPE_POLY_SET m_through_outer_holes_poly
It contains polygon contours for through holes (outer cylinder)

References m_through_outer_holes_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetThroughHole_Outer_poly_NPTH()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHole_Outer_poly_NPTH ( ) const
inlinenoexcept

Definition at line 411 of file board_adapter.h.

412  {
414  }
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH
It contains polygon contours for (just) non plated through holes (outer cylinder)

References m_through_outer_holes_poly_NPTH.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetThroughHole_Outer_Ring()

const CBVHCONTAINER2D& BOARD_ADAPTER::GetThroughHole_Outer_Ring ( ) const
inlinenoexcept

GetThroughHole_Outer_Ring - Get the ThroughHole container that include the width of the annular ring.

Returns
a container with holes.

Definition at line 396 of file board_adapter.h.

397  {
399  }
CBVHCONTAINER2D m_through_holes_outer_ring
It contains the list of throughHoles of the board, the radius of the hole is inflated with the annula...

References m_through_holes_outer_ring.

Referenced by C3D_RENDER_RAYTRACING::createItemsFromContainer(), and C3D_RENDER_OGL_LEGACY::reload().

◆ GetThroughHole_Outer_Ring_poly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHole_Outer_Ring_poly ( ) const
inlinenoexcept

Definition at line 406 of file board_adapter.h.

407  {
409  }
SHAPE_POLY_SET m_through_outer_ring_holes_poly
It contains polygon contours for through holes vias (outer annular ring)

References m_through_outer_ring_holes_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetThroughHole_Vias_Outer()

const CBVHCONTAINER2D& BOARD_ADAPTER::GetThroughHole_Vias_Outer ( ) const
inlinenoexcept

GetThroughHole_Vias_Outer -.

Returns
a container with via THT holes only

Definition at line 420 of file board_adapter.h.

421  {
423  }
CBVHCONTAINER2D m_through_holes_vias_outer
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the c...

References m_through_holes_vias_outer.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetThroughHole_Vias_Outer_poly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHole_Vias_Outer_poly ( ) const
inlinenoexcept

Definition at line 425 of file board_adapter.h.

426  {
428  }
SHAPE_POLY_SET m_through_outer_holes_vias_poly
It contains polygon contours for through holes vias (outer cylinder)

References m_through_outer_holes_vias_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GridGet()

GRID3D_TYPE BOARD_ADAPTER::GridGet ( ) const
inlinenoexcept

GridGet - get the current grid.

Returns
space type of the grid

Definition at line 242 of file board_adapter.h.

243  {
244  return m_3D_grid_type;
245  }
GRID3D_TYPE m_3D_grid_type

References m_3D_grid_type.

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

◆ GridSet()

void BOARD_ADAPTER::GridSet ( GRID3D_TYPE  aGridType)
inlinenoexcept

GridSet - set the current grid.

Parameters
aGridType= the type space of the grid

Definition at line 251 of file board_adapter.h.

252  {
253  m_3D_grid_type = aGridType;
254  }
GRID3D_TYPE m_3D_grid_type

References m_3D_grid_type.

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

◆ InitSettings()

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

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

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

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 C3D_RENDER_RAYTRACING::Reload(), and C3D_RENDER_OGL_LEGACY::reload().

◆ Is3DLayerEnabled()

bool BOARD_ADAPTER::Is3DLayerEnabled ( PCB_LAYER_ID  aLayer) const

Is3DLayerEnabled - Check if a layer is enabled.

Parameters
aLayerlayer ID to get status

Definition at line 151 of file board_adapter.cpp.

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

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 C3D_RENDER_OGL_LEGACY::reload().

◆ MaterialModeGet()

MATERIAL_MODE BOARD_ADAPTER::MaterialModeGet ( ) const
inlinenoexcept

◆ MaterialModeSet()

void BOARD_ADAPTER::MaterialModeSet ( MATERIAL_MODE  aMaterialMode)
inlinenoexcept

MaterialModeSet.

Parameters
aMaterialMode= the render material mode

Definition at line 290 of file board_adapter.h.

291  {
292  m_material_mode = aMaterialMode;
293  }
MATERIAL_MODE m_material_mode

References m_material_mode.

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

◆ RenderEngineGet()

◆ RenderEngineSet()

void BOARD_ADAPTER::RenderEngineSet ( RENDER_ENGINE  aRenderEngine)
inlinenoexcept

RenderEngineSet.

Parameters
aRenderEngine= the render engine mode selected

Definition at line 272 of file board_adapter.h.

273  {
274  m_render_engine = aRenderEngine;
275  }
RENDER_ENGINE m_render_engine

References m_render_engine.

Referenced by EDA_3D_CANVAS::DoRePaint(), EDA_3D_VIEWER::LoadSettings(), EDA_3D_VIEWER::OnDisableRayTracing(), and EDA_3D_VIEWER::OnRenderEngineSelection().

◆ Set3DCacheManager()

void BOARD_ADAPTER::Set3DCacheManager ( S3D_CACHE aCachePointer)
inlinenoexcept

Set3DCacheManager - Update the Cache manager pointer.

Parameters
aCachePointerthe pointer to the 3d cache manager

Definition at line 80 of file board_adapter.h.

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

References m_3d_model_manager.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ SetBoard()

void BOARD_ADAPTER::SetBoard ( BOARD aBoard)
inlinenoexcept

SetBoard - Set current board to be rendered.

Parameters
aBoardboard to process

Definition at line 124 of file board_adapter.h.

125  {
126  m_board = aBoard;
127  }

References m_board.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ SetColorSettings()

void BOARD_ADAPTER::SetColorSettings ( COLOR_SETTINGS aSettings)
inlinenoexcept

Definition at line 138 of file board_adapter.h.

139  {
140  m_colors = aSettings;
141  }
COLOR_SETTINGS * m_colors

References m_colors.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ SetFlag()

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

SetFlag - set the status of a flag.

Parameters
aFlagthe flag to get the status
aStatestatus to set

Definition at line 234 of file board_adapter.cpp.

235 {
236  wxASSERT( aFlag < FL_LAST );
237 
238  m_drawFlags[aFlag] = aState;
239 }
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().

◆ ShouldFPBeDisplayed()

bool BOARD_ADAPTER::ShouldFPBeDisplayed ( FOOTPRINT_ATTR_T  aFPAttributes) const

ShouldFPBeDisplayed - 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
GetFlag - 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 C3D_RENDER_RAYTRACING::load_3D_models(), and C3D_RENDER_OGL_LEGACY::render_3D_models_selected().

◆ TransformArcToSegments()

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

Definition at line 551 of file create_3Dgraphic_brd_items.cpp.

558 {
559  wxPoint arc_start, arc_end;
560  int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
561 
562  arc_end = arc_start = aStart;
563 
564  if( aArcAngle != 3600 )
565  {
566  RotatePoint( &arc_end, aCentre, -aArcAngle );
567  }
568 
569  if( aArcAngle < 0 )
570  {
571  std::swap( arc_start, arc_end );
572  aArcAngle = -aArcAngle;
573  }
574 
575  // Compute the ends of segments and creates poly
576  wxPoint curr_end = arc_start;
577  wxPoint curr_start = arc_start;
578 
579  for( int ii = delta; ii < aArcAngle; ii += delta )
580  {
581  curr_end = arc_start;
582  RotatePoint( &curr_end, aCentre, -ii );
583 
584  const SFVEC2F start3DU( curr_start.x * m_biuTo3Dunits, -curr_start.y * m_biuTo3Dunits );
585  const SFVEC2F end3DU ( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
586 
587  if( Is_segment_a_circle( start3DU, end3DU ) )
588  {
589  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
590  aBoardItem ) );
591  }
592  else
593  {
594  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
595  aBoardItem ) );
596  }
597 
598  curr_start = curr_end;
599  }
600 
601  if( curr_end != arc_end )
602  {
603  const SFVEC2F start3DU( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
604  const SFVEC2F end3DU ( arc_end.x * m_biuTo3Dunits, -arc_end.y * m_biuTo3Dunits );
605 
606  if( Is_segment_a_circle( start3DU, end3DU ) )
607  {
608  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
609  ( aWidth / 2 ) * m_biuTo3Dunits,
610  aBoardItem ) );
611  }
612  else
613  {
614  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
615  end3DU,
616  aWidth * m_biuTo3Dunits,
617  aBoardItem ) );
618  }
619  }
620 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52

References CGENERICCONTAINER2D::Add(), Is_segment_a_circle(), m_biuTo3Dunits, and RotatePoint().

Referenced by AddShapeWithClearanceToContainer(), and createNewTrack().

◆ transformFPShapesToPolygon()

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

Definition at line 63 of file create_layer_poly.cpp.

65 {
66  for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
67  {
68  if( item->Type() == PCB_FP_SHAPE_T )
69  {
70  FP_SHAPE* outline = (FP_SHAPE*) item;
71 
72  if( outline->GetLayer() == aLayer )
73  {
74  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0,
75  ARC_HIGH_DEF, ERROR_INSIDE );
76  }
77  }
78  }
79 }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
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
Function GetLayer returns the primary layer this item is on.
Definition: board_item.h:185

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

Referenced by createLayers().

Member Data Documentation

◆ m_3D_grid_type

GRID3D_TYPE BOARD_ADAPTER::m_3D_grid_type
private

Definition at line 629 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GridGet(), and GridSet().

◆ m_3d_model_manager

S3D_CACHE* BOARD_ADAPTER::m_3d_model_manager
private

Definition at line 623 of file board_adapter.h.

Referenced by Get3DCacheManager(), and Set3DCacheManager().

◆ m_antialiasing_mode

ANTIALIASING_MODE BOARD_ADAPTER::m_antialiasing_mode
private

Definition at line 632 of file board_adapter.h.

Referenced by AntiAliasingGet(), AntiAliasingSet(), and BOARD_ADAPTER().

◆ m_B_Cu_PlatedPads_poly

SHAPE_POLY_SET* BOARD_ADAPTER::m_B_Cu_PlatedPads_poly
private

◆ m_BgColorBot

◆ m_BgColorTop

◆ m_biuTo3Dunits

double BOARD_ADAPTER::m_biuTo3Dunits
private

◆ m_board

BOARD* BOARD_ADAPTER::m_board
private

◆ m_board_poly

SHAPE_POLY_SET BOARD_ADAPTER::m_board_poly
private

PCB board outline polygon.

Definition at line 677 of file board_adapter.h.

Referenced by createBoardPolygon(), and GetBoardPoly().

◆ m_BoardBodyColor

◆ m_boardBoundingBox

CBBOX BOARD_ADAPTER::m_boardBoundingBox
private

3d bounding box of the pcb board in 3d units

Definition at line 650 of file board_adapter.h.

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

◆ m_boardCenter

SFVEC3F BOARD_ADAPTER::m_boardCenter
private

3d center position of the pcb board in 3d units

Definition at line 644 of file board_adapter.h.

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

◆ m_boardPos

wxPoint BOARD_ADAPTER::m_boardPos
private

center board actual position in board units

Definition at line 638 of file board_adapter.h.

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

◆ m_boardSize

wxSize BOARD_ADAPTER::m_boardSize
private

board actual size in board units

Definition at line 641 of file board_adapter.h.

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

◆ m_calc_seg_max_factor3DU

float BOARD_ADAPTER::m_calc_seg_max_factor3DU
private

max factor used for cicle segment approximation calculation

Definition at line 740 of file board_adapter.h.

Referenced by BOARD_ADAPTER().

◆ m_calc_seg_min_factor3DU

float BOARD_ADAPTER::m_calc_seg_min_factor3DU
private

min factor used for cicle segment approximation calculation

Definition at line 737 of file board_adapter.h.

Referenced by BOARD_ADAPTER().

◆ m_colors

COLOR_SETTINGS* BOARD_ADAPTER::m_colors
private

Definition at line 624 of file board_adapter.h.

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

◆ m_CopperColor

◆ m_copperLayersCount

unsigned int BOARD_ADAPTER::m_copperLayersCount
private

Number of copper layers actually used by the board.

Definition at line 715 of file board_adapter.h.

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

◆ m_copperThickness3DU

float BOARD_ADAPTER::m_copperThickness3DU
private

Copper thickness (normalized)

Definition at line 728 of file board_adapter.h.

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

◆ m_drawFlags

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

Definition at line 628 of file board_adapter.h.

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

◆ m_epoxyThickness3DU

float BOARD_ADAPTER::m_epoxyThickness3DU
private

Epoxy thickness (normalized)

Definition at line 731 of file board_adapter.h.

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

◆ m_F_Cu_PlatedPads_poly

SHAPE_POLY_SET* BOARD_ADAPTER::m_F_Cu_PlatedPads_poly
private

◆ m_layers_container2D

MAP_CONTAINER_2D BOARD_ADAPTER::m_layers_container2D
private

It contains the 2d elements of each layer.

Definition at line 683 of file board_adapter.h.

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

◆ m_layers_holes2D

MAP_CONTAINER_2D BOARD_ADAPTER::m_layers_holes2D
private

It contains the holes per each layer.

Definition at line 689 of file board_adapter.h.

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

◆ m_layers_inner_holes_poly

MAP_POLY BOARD_ADAPTER::m_layers_inner_holes_poly
private

It contains polygon contours for holes of each layer (inner holes)

Definition at line 662 of file board_adapter.h.

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

◆ m_layers_outer_holes_poly

MAP_POLY BOARD_ADAPTER::m_layers_outer_holes_poly
private

It contains polygon contours for holes of each layer (outer holes)

Definition at line 659 of file board_adapter.h.

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

◆ m_layers_poly

MAP_POLY BOARD_ADAPTER::m_layers_poly
private

It contains polygon contours for each layer.

Definition at line 653 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

Bottom (Start) Z position of each layer (normalized)

Definition at line 725 of file board_adapter.h.

Referenced by GetLayerBottomZpos3DU(), GetModulesZcoord3DIU(), and InitSettings().

◆ m_layerZcoordTop

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

Top (End) Z position of each layer (normalized)

Definition at line 722 of file board_adapter.h.

Referenced by GetLayerTopZpos3DU(), GetModulesZcoord3DIU(), and InitSettings().

◆ m_logTrace

const wxChar * BOARD_ADAPTER::m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" )
staticprivate

Trace mask used to enable or disable the trace output of this class.

The debug output can be turned on by setting the WXTRACE environment variable to "KI_TRACE_EDA_CINFO3D_VISU". See the wxWidgets documentation on wxLogTrace for more information.

Definition at line 769 of file board_adapter.h.

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

◆ m_material_mode

MATERIAL_MODE BOARD_ADAPTER::m_material_mode
private

Definition at line 631 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), MaterialModeGet(), and MaterialModeSet().

◆ m_nonCopperLayerThickness3DU

float BOARD_ADAPTER::m_nonCopperLayerThickness3DU
private

Non copper layers thickness.

Definition at line 734 of file board_adapter.h.

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

◆ m_opengl_selectionColor

◆ m_platedpads_container2D_B_Cu

CBVHCONTAINER2D* BOARD_ADAPTER::m_platedpads_container2D_B_Cu
private

Definition at line 686 of file board_adapter.h.

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

◆ m_platedpads_container2D_F_Cu

CBVHCONTAINER2D* BOARD_ADAPTER::m_platedpads_container2D_F_Cu
private

Definition at line 685 of file board_adapter.h.

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

◆ m_raytrace_lightColor

◆ m_raytrace_lightColorBottom

◆ m_raytrace_lightColorCamera

◆ m_raytrace_lightColorTop

◆ m_raytrace_lightSphericalCoords

◆ m_raytrace_nrsamples_reflections

◆ m_raytrace_nrsamples_refractions

◆ m_raytrace_nrsamples_shadows

◆ m_raytrace_recursivelevel_reflections

◆ m_raytrace_recursivelevel_refractions

◆ m_raytrace_spread_reflections

◆ m_raytrace_spread_refractions

◆ m_raytrace_spread_shadows

◆ m_render_engine

RENDER_ENGINE BOARD_ADAPTER::m_render_engine
private

Definition at line 630 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), RenderEngineGet(), and RenderEngineSet().

◆ m_SilkScreenColorBot

◆ m_SilkScreenColorTop

◆ m_SolderMaskColorBot

◆ m_SolderMaskColorTop

SFVEC4F BOARD_ADAPTER::m_SolderMaskColorTop

in realistic mode: solder mask color ( top )

Definition at line