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 ShouldModuleBeDisplayed (MODULE_ATTR_T aModuleAttributs) const
 ShouldModuleBeDisplayed - Test if module should be displayed in relation to attributs 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 GetCopperThicknessBIU () 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 size. 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 module 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
 GetThroughHole_Outer_poly -. More...
 
const SHAPE_POLY_SETGetThroughHole_Outer_poly_NPTH () const noexcept
 GetThroughHole_Outer_poly_NPTH -. More...
 
const CBVHCONTAINER2DGetThroughHole_Vias_Outer () const noexcept
 GetThroughHole_Vias_Outer -. More...
 
const CBVHCONTAINER2DGetThroughHole_Vias_Outer_Ring () const noexcept
 GetThroughHole_Vias_Outer_Ring -. More...
 
const CBVHCONTAINER2DGetThroughHole_Vias_Inner () const noexcept
 GetThroughHole_Vias_Inner -. More...
 
const SHAPE_POLY_SETGetThroughHole_Vias_Outer_poly () const noexcept
 GetThroughHole_Vias_Outer_poly -. More...
 
const SHAPE_POLY_SETGetThroughHole_Vias_Outer_Ring_poly () const noexcept
 GetThroughHole_Vias_Outer_Ring_poly -. More...
 
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_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 D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayer, wxSize aClearanceValue) const
 
COBJECT2DcreateNewPadDrill (const D_PAD *aPad, int aInflateValue)
 
void AddPadsShapesWithClearanceToContainer (const MODULE *aModule, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
 
void AddGraphicsShapesWithClearanceToContainer (const MODULE *aModule, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue)
 
void AddShapeWithClearanceToContainer (const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void AddShapeWithClearanceToContainer (const DRAWSEGMENT *aDrawSegment, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void AddShapeWithClearanceToContainer (const DIMENSION *aDimension, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void AddSolidAreasShapesToContainer (const ZONE_CONTAINER *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 D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, int aWidth)
 
void buildPadShapeThickOutlineAsPolygon (const D_PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
 
void transformGraphicModuleEdgeToPolygonSet (const MODULE *aModule, 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_vias_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_outer_ring
 It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the annular ring size. 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  m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
114  m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );
115  m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 0.9 );
116  m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
117  m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
118  m_SolderPasteColor = SFVEC4F( 0.4, 0.4, 0.4, 1.0 );
119  m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
120  m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
121  m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
122 
125 
126  m_F_Cu_PlatedPads_poly = nullptr;
127  m_B_Cu_PlatedPads_poly = nullptr;
128 
129  // Avoid raytracing options not initialized:
133 
137 
140 }
GRID3D_TYPE m_3D_grid_type
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
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)
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:98
unsigned int m_stats_nr_tracks
Number of tracks in the board.
int m_raytrace_nrsamples_reflections

References AA_8X, CGENERICCONTAINER2D::Clear(), FL_CLIP_SILK_ON_VIA_ANNULUS, FL_LAST, FL_MODULE_ATTRIBUTES_NORMAL, FL_MODULE_ATTRIBUTES_NORMAL_INSERT, FL_MODULE_ATTRIBUTES_VIRTUAL, 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_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 143 of file board_adapter.cpp.

144 {
145  destroyLayers();
146 }

References destroyLayers().

Member Function Documentation

◆ AddGraphicsShapesWithClearanceToContainer()

void BOARD_ADAPTER::AddGraphicsShapesWithClearanceToContainer ( const MODULE aModule,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aInflateValue 
)
private

Definition at line 188 of file create_3Dgraphic_brd_items.cpp.

192 {
193  std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
194  EDGE_MODULE* outline;
195 
196  for( auto item : aModule->GraphicalItems() )
197  {
198  switch( item->Type() )
199  {
200  case PCB_MODULE_TEXT_T:
201  {
202  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
203 
204  if( text->GetLayer() == aLayerId && text->IsVisible() )
205  texts.push_back( text );
206  }
207  break;
208 
209 
210  case PCB_MODULE_EDGE_T:
211  {
212  outline = (EDGE_MODULE*) item;
213 
214  if( outline->GetLayer() != aLayerId )
215  break;
216 
218  aDstContainer,
219  aLayerId, 0 );
220  }
221  break;
222 
223  default:
224  break;
225  }
226  }
227 
228  // Convert texts sur modules
229  if( aModule->Reference().GetLayer() == aLayerId && aModule->Reference().IsVisible() )
230  texts.push_back( &aModule->Reference() );
231 
232  if( aModule->Value().GetLayer() == aLayerId && aModule->Value().IsVisible() )
233  texts.push_back( &aModule->Value() );
234 
235  s_boardItem = (const BOARD_ITEM *)&aModule->Value();
236  s_dstcontainer = aDstContainer;
238 
239  for( TEXTE_MODULE* text : texts )
240  {
241  s_textWidth = text->GetEffectiveTextPenWidth() + ( 2 * aInflateValue );
242  wxSize size = text->GetTextSize();
243  bool forceBold = true;
244  int penWidth = 0; // force max width for bold
245 
246  if( text->IsMirrored() )
247  size.x = -size.x;
248 
249  GRText( NULL, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(),
250  size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(),
251  forceBold, addTextSegmToContainer );
252  }
253 }
TEXTE_MODULE & Reference()
Definition: class_module.h:492
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:200
bool IsMirrored() const
Definition: eda_text.h:189
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
bool IsVisible() const
Definition: eda_text.h:186
Definition: color4d.h:44
DRAWINGS & GraphicalItems()
Definition: class_module.h:191
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
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:180
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:199
#define NULL
static float s_biuTo3Dunits
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:491
const wxSize & GetTextSize() const
Definition: eda_text.h:239
static CGENERICCONTAINER2D * s_dstcontainer
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....
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 module texts)
Definition: gr_text.cpp:134
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
void addTextSegmToContainer(int x0, int y0, int xf, int yf, void *aData)
const wxPoint & GetTextPos() const
Definition: eda_text.h:248
static const BOARD_ITEM * s_boardItem
double GetDrawRotation() const
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.

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

Referenced by createLayers().

◆ AddPadsShapesWithClearanceToContainer()

void BOARD_ADAPTER::AddPadsShapesWithClearanceToContainer ( const MODULE aModule,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aInflateValue,
bool  aSkipNPTHPadsWihNoCopper,
bool  aSkipPlatedPads,
bool  aSkipNonPlatedPads 
)
private

Definition at line 477 of file create_3Dgraphic_brd_items.cpp.

484 {
485  for( D_PAD* pad : aModule->Pads() )
486  {
487  if( !pad->IsOnLayer( aLayerId ) )
488  continue;
489 
490  // Skip pad annulus when not connected on this layer (if removing is enabled)
491  if( !pad->IsPadOnLayer( aLayerId ) && IsCopperLayer( aLayerId ) )
492  continue;
493 
494  // NPTH pads are not drawn on layers if the
495  // shape size and pos is the same as their hole:
496  if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
497  {
498  if( (pad->GetDrillSize() == pad->GetSize()) &&
499  (pad->GetOffset() == wxPoint( 0, 0 )) )
500  {
501  switch( pad->GetShape() )
502  {
503  case PAD_SHAPE_CIRCLE:
504  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
505  continue;
506  break;
507 
508  case PAD_SHAPE_OVAL:
509  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
510  continue;
511  break;
512 
513  default:
514  break;
515  }
516  }
517  }
518 
519  const bool isPlated = ( ( aLayerId == F_Cu ) && pad->IsPadOnLayer( F_Mask ) ) ||
520  ( ( aLayerId == B_Cu ) && pad->IsPadOnLayer( B_Mask ) );
521 
522  if( aSkipPlatedPads && isPlated )
523  continue;
524 
525  if( aSkipNonPlatedPads && !isPlated )
526  continue;
527 
528  wxSize margin( aInflateValue, aInflateValue );
529 
530  switch( aLayerId )
531  {
532  case F_Mask:
533  case B_Mask:
534  margin.x += pad->GetSolderMaskMargin();
535  margin.y += pad->GetSolderMaskMargin();
536  break;
537 
538  case F_Paste:
539  case B_Paste:
540  margin += pad->GetSolderPasteMargin();
541  break;
542 
543  default:
544  break;
545  }
546 
547  createNewPadWithClearance( pad, aDstContainer, aLayerId, margin );
548  }
549 }
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
PADS & Pads()
Definition: class_module.h:181
static void isPlated(LIBEVAL::CONTEXT *aCtx, void *self)
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
void createNewPadWithClearance(const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayer, wxSize aClearanceValue) const

References B_Cu, B_Mask, B_Paste, createNewPadWithClearance(), F_Cu, F_Mask, F_Paste, IsCopperLayer(), isPlated(), PAD_ATTRIB_HOLE_NOT_PLATED, PAD_DRILL_SHAPE_CIRCLE, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, and MODULE::Pads().

Referenced by createLayers().

◆ AddShapeWithClearanceToContainer() [1/3]

void BOARD_ADAPTER::AddShapeWithClearanceToContainer ( const TEXTE_PCB aTextPCB,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 86 of file create_3Dgraphic_brd_items.cpp.

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

References addTextSegmToContainer(), BLACK, EDA_TEXT::GetEffectiveTextPenWidth(), EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetLinePositions(), TEXTE_PCB::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 AddGraphicsShapesWithClearanceToContainer(), AddShapeWithClearanceToContainer(), and createLayers().

◆ AddShapeWithClearanceToContainer() [2/3]

void BOARD_ADAPTER::AddShapeWithClearanceToContainer ( const DRAWSEGMENT aDrawSegment,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 629 of file create_3Dgraphic_brd_items.cpp.

633 {
634  // The full width of the lines to create
635  // The extra 1 protects the inner/outer radius values from degeneracy
636  const int linewidth = aDrawSegment->GetWidth() + (2 * aClearanceValue) + 1;
637 
638  switch( aDrawSegment->GetShape() )
639  {
640  case S_CIRCLE:
641  {
642  const SFVEC2F center3DU( aDrawSegment->GetCenter().x * m_biuTo3Dunits,
643  -aDrawSegment->GetCenter().y * m_biuTo3Dunits );
644 
645  float inner_radius = ( aDrawSegment->GetRadius() - linewidth / 2 ) * m_biuTo3Dunits;
646  float outer_radius = ( aDrawSegment->GetRadius() + linewidth / 2 ) * m_biuTo3Dunits;
647 
648  if( inner_radius < 0 )
649  inner_radius = 0;
650 
651  if( aDrawSegment->GetWidth() > 0 )
652  aDstContainer->Add( new CRING2D( center3DU, inner_radius, outer_radius, *aDrawSegment ) );
653  else
654  aDstContainer->Add( new CFILLEDCIRCLE2D( center3DU, outer_radius, *aDrawSegment ) );
655  }
656  break;
657 
658  case S_RECT:
659  {
660  if( aDrawSegment->GetWidth() > 0 )
661  {
662  std::vector<wxPoint> pts = aDrawSegment->GetRectCorners();
663 
664  const SFVEC2F topLeft3DU( pts[0].x * m_biuTo3Dunits, -pts[0].y * m_biuTo3Dunits );
665  const SFVEC2F topRight3DU( pts[1].x * m_biuTo3Dunits, -pts[1].y * m_biuTo3Dunits );
666  const SFVEC2F botRight3DU( pts[2].x * m_biuTo3Dunits, -pts[2].y * m_biuTo3Dunits );
667  const SFVEC2F botLeft3DU( pts[3].x * m_biuTo3Dunits, -pts[3].y * m_biuTo3Dunits );
668 
669  aDstContainer->Add( new CROUNDSEGMENT2D( topLeft3DU, topRight3DU,
670  linewidth * m_biuTo3Dunits,
671  *aDrawSegment ) );
672  aDstContainer->Add( new CROUNDSEGMENT2D( topRight3DU, botRight3DU,
673  linewidth * m_biuTo3Dunits,
674  *aDrawSegment ) );
675  aDstContainer->Add( new CROUNDSEGMENT2D( botRight3DU, botLeft3DU,
676  linewidth * m_biuTo3Dunits,
677  *aDrawSegment ) );
678  aDstContainer->Add( new CROUNDSEGMENT2D( botLeft3DU, topLeft3DU,
679  linewidth * m_biuTo3Dunits,
680  *aDrawSegment ) );
681  }
682  else
683  {
684  SHAPE_POLY_SET polyList;
685 
686  aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aLayerId,
687  aClearanceValue );
688 
689  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
690 
691  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
692  *aDrawSegment );
693  }
694  }
695  break;
696 
697  case S_ARC:
698  {
699  const unsigned int nr_segments =
700  GetNrSegmentsCircle( aDrawSegment->GetBoundingBox().GetSizeMax() );
701 
702  TransformArcToSegments( aDrawSegment->GetCenter(),
703  aDrawSegment->GetArcStart(),
704  aDrawSegment->GetAngle(),
705  nr_segments,
706  aDrawSegment->GetWidth(),
707  aDstContainer,
708  *aDrawSegment );
709  }
710  break;
711 
712  case S_SEGMENT:
713  {
714  const SFVEC2F start3DU( aDrawSegment->GetStart().x * m_biuTo3Dunits,
715  -aDrawSegment->GetStart().y * m_biuTo3Dunits );
716 
717  const SFVEC2F end3DU ( aDrawSegment->GetEnd().x * m_biuTo3Dunits,
718  -aDrawSegment->GetEnd().y * m_biuTo3Dunits );
719 
720  if( Is_segment_a_circle( start3DU, end3DU ) )
721  {
722  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
723  ( linewidth / 2 ) * m_biuTo3Dunits,
724  *aDrawSegment ) );
725  }
726  else
727  {
728  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
729  linewidth * m_biuTo3Dunits,
730  *aDrawSegment ) );
731  }
732  }
733  break;
734 
735  case S_CURVE:
736  case S_POLYGON:
737  {
738  SHAPE_POLY_SET polyList;
739 
740  aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aLayerId, aClearanceValue );
741 
742  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
743 
744  if( polyList.IsEmpty() ) // Just for caution
745  break;
746 
747  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
748  *aDrawSegment );
749  }
750  break;
751 
752  default:
753  wxFAIL_MSG( "BOARD_ADAPTER::AddShapeWithClearanceToContainer no implementation for "
754  + STROKE_T_asString( aDrawSegment->GetShape() ) );
755  break;
756  }
757 }
wxPoint GetArcStart() const
STROKE_T GetShape() const
polygon (not yet used for tracks, but could be in microwave apps)
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
usual segment : line with rounded ends
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
void TransformArcToSegments(const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CGENERICCONTAINER2D *aDstContainer, const BOARD_ITEM &aBoardItem)
segment with non rounded ends
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
std::vector< wxPoint > GetRectCorners() const
SHAPE_POLY_SET.
Arcs (with rounded ends)
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...
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Bezier Curve.
int GetWidth() const
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
static wxString STROKE_T_asString(STROKE_T a)
double GetAngle() const
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int GetSizeMax() const
GetSizeMax.
Definition: eda_rect.h:109
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
wxPoint GetCenter() const override
Function GetCenter()
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.

References CGENERICCONTAINER2D::Add(), Convert_shape_line_polygon_to_triangles(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetBoundingBox(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), GetNrSegmentsCircle(), DRAWSEGMENT::GetRadius(), DRAWSEGMENT::GetRectCorners(), DRAWSEGMENT::GetShape(), EDA_RECT::GetSizeMax(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), Is_segment_a_circle(), SHAPE_POLY_SET::IsEmpty(), m_biuTo3Dunits, SHAPE_POLY_SET::PM_FAST, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, SHAPE_POLY_SET::Simplify(), STROKE_T_asString(), TransformArcToSegments(), DRAWSEGMENT::TransformShapeWithClearanceToPolygon(), wxPoint::x, and wxPoint::y.

◆ AddShapeWithClearanceToContainer() [3/3]

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

Definition at line 132 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 }
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
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....
line chain (polyline)
Definition: shape.h:45
Definition: seg.h:39
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
TEXTE_PCB & Text()
VECTOR2I A
Definition: seg.h:47
int GetLineThickness() const
axis-aligned rectangle
Definition: shape.h:43
VECTOR2I B
Definition: seg.h:48

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

◆ AddSolidAreasShapesToContainer()

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

Definition at line 763 of file create_3Dgraphic_brd_items.cpp.

766 {
767  // Copy the polys list because we have to simplify it
768  SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList( aLayerId ) );
769 
770  // This convert the poly in outline and holes
771  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
772  *aZoneContainer );
773 
774  // add filled areas outlines, which are drawn with thick lines segments
775  // but only if filled polygons outlines have thickness
776  if( !aZoneContainer->GetFilledPolysUseThickness() )
777  return;
778 
779  float line_thickness = aZoneContainer->GetMinThickness() * m_biuTo3Dunits;
780 
781  for( int i = 0; i < polyList.OutlineCount(); ++i )
782  {
783  // Add outline
784  const SHAPE_LINE_CHAIN& pathOutline = polyList.COutline( i );
785 
786  for( int j = 0; j < pathOutline.PointCount(); ++j )
787  {
788  const VECTOR2I& a = pathOutline.CPoint( j );
789  const VECTOR2I& b = pathOutline.CPoint( j + 1 );
790 
791  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
792  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
793 
794  if( Is_segment_a_circle( start3DU, end3DU ) )
795  {
796  float radius = line_thickness/2;
797 
798  if( radius > 0.0 ) // degenerated circles crash 3D viewer
799  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius,
800  *aZoneContainer ) );
801  }
802  else
803  {
804  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, line_thickness,
805  *aZoneContainer ) );
806  }
807  }
808 
809  // Add holes (of the poly, ie: the open parts) for this outline
810  for( int h = 0; h < polyList.HoleCount( i ); ++h )
811  {
812  const SHAPE_LINE_CHAIN& pathHole = polyList.CHole( i, h );
813 
814  for( int j = 0; j < pathHole.PointCount(); j++ )
815  {
816  const VECTOR2I& a = pathHole.CPoint( j );
817  const VECTOR2I& b = pathHole.CPoint( j + 1 );
818 
819  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
820  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
821 
822  if( Is_segment_a_circle( start3DU, end3DU ) )
823  {
824  float radius = line_thickness/2;
825 
826  if( radius > 0.0 ) // degenerated circles crash 3D viewer
827  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius,
828  *aZoneContainer ) );
829  }
830  else
831  {
832  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, line_thickness,
833  *aZoneContainer ) );
834  }
835  }
836  }
837  }
838 }
int OutlineCount() const
Returns the number of outlines in the set
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:682
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:627
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...
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
int GetMinThickness() const
Definition: class_zone.h:224
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)

References CGENERICCONTAINER2D::Add(), SHAPE_POLY_SET::CHole(), Convert_shape_line_polygon_to_triangles(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), ZONE_CONTAINER::GetFilledPolysList(), ZONE_CONTAINER::GetFilledPolysUseThickness(), ZONE_CONTAINER::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 262 of file board_adapter.h.

262 { 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 268 of file board_adapter.h.

268 { 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 D_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  ARC_HIGH_DEF, aWidth );
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  }
59 }
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID=UNDEFINED_LAYER) const
Definition: class_pad.cpp:255
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aWidth, int aError)
convert a oblong shape to a polygon, using multiple segments It is similar to TransformRoundedEndsSeg...
SHAPE_LINE_CHAIN.
wxPoint ShapePos() const
Definition: class_pad.cpp:609
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aError, int aWidth)
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segme...
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:157
const wxSize & GetSize() const
Definition: class_pad.h:224

References SHAPE_LINE_CHAIN::CPoint(), D_PAD::GetEffectivePolygon(), D_PAD::GetShape(), D_PAD::GetSize(), PAD_SHAPE_CIRCLE, SHAPE_LINE_CHAIN::PointCount(), D_PAD::ShapePos(), TransformOvalToPolygon(), and TransformRingToPolygon().

Referenced by createLayers().

◆ buildPadShapeThickOutlineAsSegments()

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

Definition at line 842 of file create_3Dgraphic_brd_items.cpp.

845 {
846  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
847  {
848  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
849  -aPad->ShapePos().y * m_biuTo3Dunits );
850 
851  const int radius = aPad->GetSize().x / 2;
852  const float inner_radius = ( radius - aWidth / 2 ) * m_biuTo3Dunits;
853  const float outer_radius = ( radius + aWidth / 2 ) * m_biuTo3Dunits;
854 
855  aDstContainer->Add( new CRING2D( center3DU, inner_radius, outer_radius, *aPad ) );
856 
857  return;
858  }
859 
860  // For other shapes, add outlines as thick segments in polygon buffer
861  const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
862  const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
863 
864  for( int j = 0; j < path.PointCount(); j++ )
865  {
866  const VECTOR2I& a = path.CPoint( j );
867  const VECTOR2I& b = path.CPoint( j + 1 );
868 
869  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
870  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
871 
872  if( Is_segment_a_circle( start3DU, end3DU ) )
873  {
874  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
875  *aPad ) );
876  }
877  else
878  {
879  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
880  *aPad ) );
881  }
882  }
883 }
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID=UNDEFINED_LAYER) const
Definition: class_pad.cpp:255
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...
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
SHAPE_LINE_CHAIN.
wxPoint ShapePos() const
Definition: class_pad.cpp:609
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:157
const wxSize & GetSize() const
Definition: class_pad.h:224

References CGENERICCONTAINER2D::Add(), SHAPE_LINE_CHAIN::CPoint(), D_PAD::GetEffectivePolygon(), D_PAD::GetShape(), D_PAD::GetSize(), Is_segment_a_circle(), m_biuTo3Dunits, PAD_SHAPE_CIRCLE, SHAPE_LINE_CHAIN::PointCount(), D_PAD::ShapePos(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, 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 440 of file board_adapter.cpp.

441 {
443 
444  wxString errmsg;
445 
446  return m_board->GetBoardPolygonOutlines( m_board_poly, aErrorMsg );
447 }
SHAPE_POLY_SET m_board_poly
PCB board outline polygon.
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, wxString *aErrorText=nullptr, wxPoint *aErrorLocation=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.

References BOARD::GetBoardPolygonOutlines(), m_board, m_board_poly, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by InitSettings().

◆ createLayers()

void BOARD_ADAPTER::createLayers ( REPORTER aStatusReporter)
private

Definition at line 118 of file create_layer_items.cpp.

119 {
120  destroyLayers();
121 
122  // Build Copper layers
123  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L692
124  // /////////////////////////////////////////////////////////////////////////
125 
126 #ifdef PRINT_STATISTICS_3D_VIEWER
127  unsigned stats_startCopperLayersTime = GetRunningMicroSecs();
128 
129  unsigned start_Time = stats_startCopperLayersTime;
130 #endif
131 
132  PCB_LAYER_ID cu_seq[MAX_CU_LAYERS];
134 
135  m_stats_nr_tracks = 0;
137  m_stats_nr_vias = 0;
139  m_stats_nr_holes = 0;
141 
142  // Prepare track list, convert in a vector. Calc statistic for the holes
143  // /////////////////////////////////////////////////////////////////////////
144  std::vector< const TRACK *> trackList;
145  trackList.clear();
146  trackList.reserve( m_board->Tracks().size() );
147 
148  for( TRACK* track : m_board->Tracks() )
149  {
150  if( !Is3DLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
151  continue;
152 
153  // Note: a TRACK holds normal segment tracks and
154  // also vias circles (that have also drill values)
155  trackList.push_back( track );
156 
157  if( track->Type() == PCB_VIA_T )
158  {
159  const VIA *via = static_cast< const VIA*>( track );
160  m_stats_nr_vias++;
162  }
163  else
164  {
166  }
167 
168  m_stats_track_med_width += track->GetWidth() * m_biuTo3Dunits;
169  }
170 
171  if( m_stats_nr_tracks )
173 
174  if( m_stats_nr_vias )
176 
177  // Prepare copper layers index and containers
178  // /////////////////////////////////////////////////////////////////////////
179  std::vector< PCB_LAYER_ID > layer_id;
180  layer_id.clear();
181  layer_id.reserve( m_copperLayersCount );
182 
183  for( unsigned i = 0; i < arrayDim( cu_seq ); ++i )
184  cu_seq[i] = ToLAYER_ID( B_Cu - i );
185 
186  for( LSEQ cu = cu_set.Seq( cu_seq, arrayDim( cu_seq ) ); cu; ++cu )
187  {
188  const PCB_LAYER_ID curr_layer_id = *cu;
189 
190  if( !Is3DLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
191  continue;
192 
193  layer_id.push_back( curr_layer_id );
194 
195  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
196  m_layers_container2D[curr_layer_id] = layerContainer;
197 
200  {
201  SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET;
202  m_layers_poly[curr_layer_id] = layerPoly;
203  }
204  }
205 
208 
211 
212  if( aStatusReporter )
213  aStatusReporter->Report( _( "Create tracks and vias" ) );
214 
215  // Create tracks as objects and add it to container
216  // /////////////////////////////////////////////////////////////////////////
217  for( PCB_LAYER_ID curr_layer_id : layer_id )
218  {
219  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
220 
221  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
222 
223  // Add track segments shapes and via annulus shapes
224  unsigned int nTracks = trackList.size();
225 
226  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
227  {
228  const TRACK *track = trackList[trackIdx];
229 
230  // NOTE: Vias can be on multiple layers
231  if( !track->IsOnLayer( curr_layer_id ) )
232  continue;
233 
234  // Skip vias annulus when not connected on this layer (if removing is enabled)
235  const VIA *via = dyn_cast< const VIA*>( track );
236 
237  if( via && !via->IsPadOnLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
238  continue;
239 
240  // Add object item to layer container
241  createNewTrack( track, layerContainer, 0.0f );
242  }
243  }
244 
245  // Create VIAS and THTs objects and add it to holes containers
246  // /////////////////////////////////////////////////////////////////////////
247  for( PCB_LAYER_ID curr_layer_id : layer_id )
248  {
249  // ADD TRACKS
250  unsigned int nTracks = trackList.size();
251 
252  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
253  {
254  const TRACK *track = trackList[trackIdx];
255 
256  if( !track->IsOnLayer( curr_layer_id ) )
257  continue;
258 
259  // ADD VIAS and THT
260  if( track->Type() == PCB_VIA_T )
261  {
262  const VIA* via = static_cast<const VIA*>( track );
263  const VIATYPE viatype = via->GetViaType();
264  const float holediameter = via->GetDrillValue() * BiuTo3Dunits();
265  const float thickness = GetCopperThickness3DU();
266  const float hole_inner_radius = ( holediameter / 2.0f );
267  const float ring_radius = via->GetWidth() * BiuTo3Dunits() / 2.0f;
268 
269  const SFVEC2F via_center(
270  via->GetStart().x * m_biuTo3Dunits, -via->GetStart().y * m_biuTo3Dunits );
271 
272  if( viatype != VIATYPE::THROUGH )
273  {
274 
275  // Add hole objects
276  // /////////////////////////////////////////////////////////
277 
278  CBVHCONTAINER2D *layerHoleContainer = NULL;
279 
280  // Check if the layer is already created
281  if( m_layers_holes2D.find( curr_layer_id ) == m_layers_holes2D.end() )
282  {
283  // not found, create a new container
284  layerHoleContainer = new CBVHCONTAINER2D;
285  m_layers_holes2D[curr_layer_id] = layerHoleContainer;
286  }
287  else
288  {
289  // found
290  layerHoleContainer = m_layers_holes2D[curr_layer_id];
291  }
292 
293  // Add a hole for this layer
294  layerHoleContainer->Add( new CFILLEDCIRCLE2D( via_center,
295  hole_inner_radius + thickness,
296  *track ) );
297  }
298  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
299  {
300  // Add through hole object
301  // /////////////////////////////////////////////////////////
302  m_through_holes_outer.Add( new CFILLEDCIRCLE2D( via_center,
303  hole_inner_radius + thickness,
304  *track ) );
306  new CFILLEDCIRCLE2D( via_center,
307  hole_inner_radius + thickness,
308  *track ) );
309 
311  {
313  new CFILLEDCIRCLE2D( via_center, ring_radius, *track ) );
315  new CFILLEDCIRCLE2D( via_center, ring_radius, *track ) );
316  }
317 
318  m_through_holes_inner.Add( new CFILLEDCIRCLE2D( via_center,
319  hole_inner_radius,
320  *track ) );
321 
322  //m_through_holes_vias_inner.Add( new CFILLEDCIRCLE2D( via_center,
323  // hole_inner_radius,
324  // *track ) );
325  }
326  }
327  }
328  }
329 
330  // Create VIAS and THTs objects and add it to holes containers
331  // /////////////////////////////////////////////////////////////////////////
332  for( PCB_LAYER_ID curr_layer_id : layer_id )
333  {
334  // ADD TRACKS
335  const unsigned int nTracks = trackList.size();
336 
337  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
338  {
339  const TRACK *track = trackList[trackIdx];
340 
341  if( !track->IsOnLayer( curr_layer_id ) )
342  continue;
343 
344  // ADD VIAS and THT
345  if( track->Type() == PCB_VIA_T )
346  {
347  const VIA *via = static_cast< const VIA*>( track );
348  const VIATYPE viatype = via->GetViaType();
349 
350  if( viatype != VIATYPE::THROUGH )
351  {
352  // Add VIA hole contourns
353 
354  // Add outer holes of VIAs
355  SHAPE_POLY_SET *layerOuterHolesPoly = NULL;
356  SHAPE_POLY_SET *layerInnerHolesPoly = NULL;
357 
358  // Check if the layer is already created
359  if( m_layers_outer_holes_poly.find( curr_layer_id ) ==
361  {
362  // not found, create a new container
363  layerOuterHolesPoly = new SHAPE_POLY_SET;
364  m_layers_outer_holes_poly[curr_layer_id] = layerOuterHolesPoly;
365 
366  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) ==
368 
369  layerInnerHolesPoly = new SHAPE_POLY_SET;
370  m_layers_inner_holes_poly[curr_layer_id] = layerInnerHolesPoly;
371  }
372  else
373  {
374  // found
375  layerOuterHolesPoly = m_layers_outer_holes_poly[curr_layer_id];
376 
377  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
379 
380  layerInnerHolesPoly = m_layers_inner_holes_poly[curr_layer_id];
381  }
382 
383  const int holediameter = via->GetDrillValue();
384  const int hole_outer_radius = (holediameter / 2) + GetCopperThicknessBIU();
385 
386  TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
387  hole_outer_radius, ARC_HIGH_DEF );
388 
389  TransformCircleToPolygon( *layerInnerHolesPoly, via->GetStart(),
390  holediameter / 2, ARC_HIGH_DEF );
391  }
392  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
393  {
394  const int holediameter = via->GetDrillValue();
395  const int hole_outer_radius = (holediameter / 2)+ GetCopperThicknessBIU();
396  const int hole_outer_ring_radius = via->GetWidth() / 2.0f;
397 
398  // Add through hole contourns
399  // /////////////////////////////////////////////////////////
401  hole_outer_radius, ARC_HIGH_DEF );
402 
403  // Add same thing for vias only
404 
406  via->GetStart(), hole_outer_radius, ARC_HIGH_DEF );
407 
409  {
411  via->GetStart(), hole_outer_ring_radius, ARC_HIGH_DEF );
412  }
413  }
414  }
415  }
416  }
417 
418  // Creates vertical outline contours of the tracks and add it to the poly of the layer
419  // /////////////////////////////////////////////////////////////////////////
422  {
423  for( PCB_LAYER_ID curr_layer_id : layer_id )
424  {
425  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
426 
427  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
428 
429  // ADD TRACKS
430  unsigned int nTracks = trackList.size();
431 
432  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
433  {
434  const TRACK *track = trackList[trackIdx];
435 
436  if( !track->IsOnLayer( curr_layer_id ) )
437  continue;
438 
439  // Skip vias annulus when not connected on this layer (if removing is enabled)
440  const VIA *via = dyn_cast< const VIA*>( track );
441 
442  if( via && !via->IsPadOnLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
443  continue;
444 
445  // Add the track/via contour
446  track->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0 );
447  }
448  }
449  }
450 
451  // Add holes of modules
452  // /////////////////////////////////////////////////////////////////////////
453  for( MODULE* module : m_board->Modules() )
454  {
455  for( D_PAD* pad : module->Pads() )
456  {
457  const wxSize padHole = pad->GetDrillSize();
458 
459  if( !padHole.x ) // Not drilled pad like SMD pad
460  continue;
461 
462  // The hole in the body is inflated by copper thickness,
463  // if not plated, no copper
464  const int inflate = (pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED) ?
465  GetCopperThicknessBIU() : 0;
466 
468  m_stats_hole_med_diameter += ( ( pad->GetDrillSize().x +
469  pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
470 
471  m_through_holes_outer.Add( createNewPadDrill( pad, inflate ) );
472 
474  {
476  }
477 
479  }
480  }
481 
482  if( m_stats_nr_holes )
484 
485  // Add contours of the pad holes (pads can be Circle or Segment holes)
486  // /////////////////////////////////////////////////////////////////////////
487  for( MODULE* module : m_board->Modules() )
488  {
489  for( D_PAD* pad : module->Pads() )
490  {
491  const wxSize padHole = pad->GetDrillSize();
492 
493  if( !padHole.x ) // Not drilled pad like SMD pad
494  continue;
495 
496  // The hole in the body is inflated by copper thickness.
497  const int inflate = GetCopperThicknessBIU();
498 
499  if( pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED )
500  {
501  pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly, inflate );
502  }
503  else
504  {
505  // If not plated, no copper.
506  pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly_NPTH, inflate );
507  }
508  }
509  }
510 
511  // Add modules PADs objects to containers
512  for( PCB_LAYER_ID curr_layer_id : layer_id )
513  {
514  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
515 
516  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
517 
518  // ADD PADS
519  for( MODULE* module : m_board->Modules() )
520  {
521  // Note: NPTH pads are not drawn on copper layers when the pad
522  // has same shape as its hole
524  layerContainer,
525  curr_layer_id,
526  0,
527  true,
528  true,
529  false );
530 
531  // Micro-wave modules may have items on copper layers
533  layerContainer,
534  curr_layer_id,
535  0 );
536  }
537  }
538 
539  // ADD PLATED PADS
540  for( MODULE* module : m_board->Modules() )
541  {
544  F_Cu,
545  0,
546  true,
547  false,
548  true );
549 
552  B_Cu,
553  0,
554  true,
555  false,
556  true );
557  }
558 
559  // Add modules PADs poly contourns (vertical outlines)
562  {
563  for( PCB_LAYER_ID curr_layer_id : layer_id )
564  {
565  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
566 
567  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
568 
569  // Add pads to polygon list
570  for( auto module : m_board->Modules() )
571  {
572  // Note: NPTH pads are not drawn on copper layers when the pad
573  // has same shape as its hole
574  module->TransformPadsShapesWithClearanceToPolygon( curr_layer_id, *layerPoly,
575  0, ARC_HIGH_DEF, true,
576  true, false );
577 
578  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
579  }
580  }
581 
582  // ADD PLATED PADS contourns
583  for( auto module : m_board->Modules() )
584  {
585  module->TransformPadsShapesWithClearanceToPolygon( F_Cu, *m_F_Cu_PlatedPads_poly,
586  0, ARC_HIGH_DEF, true,
587  false, true );
588 
589  //transformGraphicModuleEdgeToPolygonSet( module, F_Cu, *m_F_Cu_PlatedPads_poly );
590 
591  module->TransformPadsShapesWithClearanceToPolygon( B_Cu, *m_B_Cu_PlatedPads_poly,
592  0, ARC_HIGH_DEF, true,
593  false, true );
594 
595  //transformGraphicModuleEdgeToPolygonSet( module, B_Cu, *m_B_Cu_PlatedPads_poly );
596  }
597  }
598 
599 
600  // Add graphic item on copper layers to object containers
601  for( PCB_LAYER_ID curr_layer_id : layer_id )
602  {
603  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
604 
605  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
606 
607  // Add graphic items on copper layers (texts and other graphics)
608  for( auto item : m_board->Drawings() )
609  {
610  if( !item->IsOnLayer( curr_layer_id ) )
611  continue;
612 
613  switch( item->Type() )
614  {
615  case PCB_LINE_T:
616  {
618  layerContainer,
619  curr_layer_id,
620  0 );
621  }
622  break;
623 
624  case PCB_TEXT_T:
626  layerContainer,
627  curr_layer_id,
628  0 );
629  break;
630 
631  case PCB_DIM_ALIGNED_T:
632  case PCB_DIM_CENTER_T:
634  case PCB_DIM_LEADER_T:
636  layerContainer,
637  curr_layer_id,
638  0 );
639  break;
640 
641  default:
642  wxLogTrace( m_logTrace,
643  wxT( "createLayers: item type: %d not implemented" ),
644  item->Type() );
645  break;
646  }
647  }
648  }
649 
650  // Add graphic item on copper layers to poly contourns (vertical outlines)
653  {
654  for( PCB_LAYER_ID cur_layer_id : layer_id )
655  {
656  wxASSERT( m_layers_poly.find( cur_layer_id ) != m_layers_poly.end() );
657 
658  SHAPE_POLY_SET *layerPoly = m_layers_poly[cur_layer_id];
659 
660  // Add graphic items on copper layers (texts and other )
661  for( BOARD_ITEM* item : m_board->Drawings() )
662  {
663  if( !item->IsOnLayer( cur_layer_id ) )
664  continue;
665 
666  switch( item->Type() )
667  {
668  case PCB_LINE_T:
669  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( *layerPoly,
670  cur_layer_id, 0 );
671  break;
672 
673  case PCB_TEXT_T:
674  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet( *layerPoly, 0 );
675  break;
676 
677  default:
678  wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
679  item->Type() );
680  break;
681  }
682  }
683  }
684  }
685 
686  if( GetFlag( FL_ZONE ) )
687  {
688  if( aStatusReporter )
689  aStatusReporter->Report( _( "Create zones" ) );
690 
691  std::vector<std::pair<const ZONE_CONTAINER*, PCB_LAYER_ID>> zones;
692 
693  for( ZONE_CONTAINER* zone : m_board->Zones() )
694  {
695  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
696  zones.emplace_back( std::make_pair( zone, layer ) );
697  }
698 
699  // Add zones objects
700  // /////////////////////////////////////////////////////////////////////
701  std::atomic<size_t> nextZone( 0 );
702  std::atomic<size_t> threadsFinished( 0 );
703 
704  size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency(), 2 );
705  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
706  {
707  std::thread t = std::thread( [&]()
708  {
709  for( size_t areaId = nextZone.fetch_add( 1 );
710  areaId < zones.size();
711  areaId = nextZone.fetch_add( 1 ) )
712  {
713  const ZONE_CONTAINER* zone = zones[areaId].first;
714 
715  if( zone == nullptr )
716  break;
717 
718  PCB_LAYER_ID layer = zones[areaId].second;
719 
720  auto layerContainer = m_layers_container2D.find( layer );
721 
722  if( layerContainer != m_layers_container2D.end() )
723  AddSolidAreasShapesToContainer( zone, layerContainer->second, layer );
724  }
725 
726  threadsFinished++;
727  } );
728 
729  t.detach();
730  }
731 
732  while( threadsFinished < parallelThreadCount )
733  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
734 
735  }
736 
739  {
740  // Add copper zones
741  for( ZONE_CONTAINER* zone : m_board->Zones() )
742  {
743  if( zone == nullptr )
744  break;
745 
746  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
747  {
748  auto layerContainer = m_layers_poly.find( layer );
749 
750  if( layerContainer != m_layers_poly.end() )
751  zone->TransformSolidAreasShapesToPolygon( layer, *layerContainer->second );
752  }
753  }
754  }
755 
756  // Simplify layer polygons
757 
758  if( aStatusReporter )
759  aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
760 
763  {
764  if( m_F_Cu_PlatedPads_poly && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) )
765  {
766  SHAPE_POLY_SET *layerPoly_F_Cu = m_layers_poly[F_Cu];
767  layerPoly_F_Cu->BooleanSubtract( *m_F_Cu_PlatedPads_poly, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
768 
770  }
771 
772  if( m_B_Cu_PlatedPads_poly && ( m_layers_poly.find( B_Cu ) != m_layers_poly.end() ) )
773  {
774  SHAPE_POLY_SET *layerPoly_B_Cu = m_layers_poly[B_Cu];
775  layerPoly_B_Cu->BooleanSubtract( *m_B_Cu_PlatedPads_poly, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
776 
778  }
779 
780  std::vector< PCB_LAYER_ID > layer_id_without_F_and_B;
781  layer_id_without_F_and_B.clear();
782  layer_id_without_F_and_B.reserve( layer_id.size() );
783 
784  for( size_t i = 0; i < layer_id.size(); ++i )
785  {
786  if( ( layer_id[i] != F_Cu ) &&
787  ( layer_id[i] != B_Cu ) )
788  layer_id_without_F_and_B.push_back( layer_id[i] );
789  }
790 
791  if( layer_id_without_F_and_B.size() > 0 )
792  {
793  std::atomic<size_t> nextItem( 0 );
794  std::atomic<size_t> threadsFinished( 0 );
795 
796  size_t parallelThreadCount = std::min<size_t>(
797  std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
798  layer_id_without_F_and_B.size() );
799  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
800  {
801  std::thread t = std::thread( [&nextItem, &threadsFinished, &layer_id_without_F_and_B, this]()
802  {
803  for( size_t i = nextItem.fetch_add( 1 );
804  i < layer_id_without_F_and_B.size();
805  i = nextItem.fetch_add( 1 ) )
806  {
807  auto layerPoly = m_layers_poly.find( layer_id_without_F_and_B[i] );
808 
809  if( layerPoly != m_layers_poly.end() )
810  // This will make a union of all added contours
811  layerPoly->second->Simplify( SHAPE_POLY_SET::PM_FAST );
812  }
813 
814  threadsFinished++;
815  } );
816 
817  t.detach();
818  }
819 
820  while( threadsFinished < parallelThreadCount )
821  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
822  }
823  }
824 
825  // Simplify holes polygon contours
826  // /////////////////////////////////////////////////////////////////////////
827  if( aStatusReporter )
828  aStatusReporter->Report( _( "Simplify holes contours" ) );
829 
830  for( PCB_LAYER_ID layer : layer_id )
831  {
832  if( m_layers_outer_holes_poly.find( layer ) != m_layers_outer_holes_poly.end() )
833  {
834  // found
835  SHAPE_POLY_SET *polyLayer = m_layers_outer_holes_poly[layer];
836  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
837 
838  wxASSERT( m_layers_inner_holes_poly.find( layer ) != m_layers_inner_holes_poly.end() );
839 
840  polyLayer = m_layers_inner_holes_poly[layer];
841  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
842  }
843  }
844 
845  // End Build Copper layers
846 
847  // This will make a union of all added contourns
852 
853  // Build Tech layers
854  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
855  // /////////////////////////////////////////////////////////////////////////
856  if( aStatusReporter )
857  aStatusReporter->Report( _( "Build Tech layers" ) );
858 
859  // draw graphic items, on technical layers
860  static const PCB_LAYER_ID teckLayerList[] = {
861  B_Adhes,
862  F_Adhes,
863  B_Paste,
864  F_Paste,
865  B_SilkS,
866  F_SilkS,
867  B_Mask,
868  F_Mask,
869 
870  // Aux Layers
871  Dwgs_User,
872  Cmts_User,
873  Eco1_User,
874  Eco2_User,
875  Edge_Cuts,
876  Margin
877  };
878 
879  // User layers are not drawn here, only technical layers
880  for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, arrayDim( teckLayerList ) );
881  seq;
882  ++seq )
883  {
884  const PCB_LAYER_ID curr_layer_id = *seq;
885 
886  if( !Is3DLayerEnabled( curr_layer_id ) )
887  continue;
888 
889  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
890  m_layers_container2D[curr_layer_id] = layerContainer;
891 
892  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
893  m_layers_poly[curr_layer_id] = layerPoly;
894 
895  // Add drawing objects
896  for( BOARD_ITEM* item : m_board->Drawings() )
897  {
898  if( !item->IsOnLayer( curr_layer_id ) )
899  continue;
900 
901  switch( item->Type() )
902  {
903  case PCB_LINE_T:
905  layerContainer,
906  curr_layer_id,
907  0 );
908  break;
909 
910  case PCB_TEXT_T:
912  layerContainer,
913  curr_layer_id,
914  0 );
915  break;
916 
917  case PCB_DIM_ALIGNED_T:
918  case PCB_DIM_CENTER_T:
920  case PCB_DIM_LEADER_T:
922  layerContainer,
923  curr_layer_id,
924  0 );
925  break;
926 
927  default:
928  break;
929  }
930  }
931 
932 
933  // Add drawing contours
934  for( BOARD_ITEM* item : m_board->Drawings() )
935  {
936  if( !item->IsOnLayer( curr_layer_id ) )
937  continue;
938 
939  switch( item->Type() )
940  {
941  case PCB_LINE_T:
942  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( *layerPoly,
943  curr_layer_id, 0 );
944  break;
945 
946  case PCB_TEXT_T:
947  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet( *layerPoly, 0 );
948  break;
949 
950  default:
951  break;
952  }
953  }
954 
955 
956  // Add modules tech layers - objects
957  // /////////////////////////////////////////////////////////////////////
958  for( MODULE* module : m_board->Modules() )
959  {
960  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
961  {
962  int linewidth = g_DrawDefaultLineThickness;
963 
964  for( D_PAD* pad : module->Pads() )
965  {
966  if( !pad->IsOnLayer( curr_layer_id ) )
967  continue;
968 
969  buildPadShapeThickOutlineAsSegments( pad, layerContainer, linewidth );
970  }
971  }
972  else
973  {
974  AddPadsShapesWithClearanceToContainer( module, layerContainer, curr_layer_id, 0,
975  false,
976  false,
977  false );
978  }
979 
980  AddGraphicsShapesWithClearanceToContainer( module, layerContainer, curr_layer_id, 0 );
981  }
982 
983 
984  // Add modules tech layers - contours
985  for( MODULE* module : m_board->Modules() )
986  {
987  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
988  {
989  const int linewidth = g_DrawDefaultLineThickness;
990 
991  for( D_PAD* pad : module->Pads() )
992  {
993  if( !pad->IsOnLayer( curr_layer_id ) )
994  continue;
995 
996  buildPadShapeThickOutlineAsPolygon( pad, *layerPoly, linewidth );
997  }
998  }
999  else
1000  {
1001  module->TransformPadsShapesWithClearanceToPolygon( curr_layer_id, *layerPoly, 0 );
1002  }
1003 
1004  // On tech layers, use a poor circle approximation, only for texts (stroke font)
1005  module->TransformGraphicTextWithClearanceToPolygonSet( curr_layer_id, *layerPoly, 0 );
1006 
1007  // Add the remaining things with dynamic seg count for circles
1008  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
1009  }
1010 
1011 
1012  // Draw non copper zones
1013  if( GetFlag( FL_ZONE ) )
1014  {
1015  for( ZONE_CONTAINER* zone : m_board->Zones() )
1016  {
1017  if( zone->IsOnLayer( curr_layer_id ) )
1018  AddSolidAreasShapesToContainer( zone, layerContainer, curr_layer_id );
1019  }
1020 
1021  for( ZONE_CONTAINER* zone : m_board->Zones() )
1022  {
1023  if( zone->IsOnLayer( curr_layer_id ) )
1024  zone->TransformSolidAreasShapesToPolygon( curr_layer_id, *layerPoly );
1025  }
1026  }
1027 
1028  // This will make a union of all added contours
1029  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1030  }
1031  // End Build Tech layers
1032 
1033  // Build BVH (Bounding volume hierarchy) for holes and vias
1034 
1035  if( aStatusReporter )
1036  aStatusReporter->Report( _( "Build BVH for holes and vias" ) );
1037 
1041 
1042  if( !m_layers_holes2D.empty() )
1043  {
1044  for( auto& hole : m_layers_holes2D)
1045  hole.second->BuildBVH();
1046  }
1047 
1048  // We only need the Solder mask to initialize the BVH
1049  // because..?
1051  m_layers_container2D[B_Mask]->BuildBVH();
1052 
1054  m_layers_container2D[F_Mask]->BuildBVH();
1055 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:749
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.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:101
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
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,...
MAP_POLY m_layers_outer_holes_poly
It contains polygon contours for holes of each layer (outer holes)
const wxPoint & GetStart() const
Definition: class_track.h:116
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 ...
SHAPE_POLY_SET * m_B_Cu_PlatedPads_poly
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:103
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_zone.cpp:311
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.
void AddGraphicsShapesWithClearanceToContainer(const MODULE *aModule, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue)
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:772
float GetCopperThickness3DU() const noexcept
GetCopperThickness3DU - Get the current copper layer thickness.
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
SHAPE_POLY_SET m_through_outer_ring_holes_vias_poly
It contains polygon contours for through holes vias (outer annular ring)
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...
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:410
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 buildPadShapeThickOutlineAsSegments(const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, int aWidth)
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.
Definition: class_zone.cpp:286
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.
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
#define NULL
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 ...
MODULES & Modules()
Definition: class_board.h:247
int GetCopperThicknessBIU() const noexcept
GetCopperThicknessBIU - Get the current copper layer thickness.
SHAPE_POLY_SET.
VIATYPE
Definition: class_track.h:68
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....
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...
CBVHCONTAINER2D m_through_holes_vias_outer_ring
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the a...
void buildPadShapeThickOutlineAsPolygon(const D_PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
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...
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
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 transformGraphicModuleEdgeToPolygonSet(const MODULE *aModule, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer) const
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
ZONE_CONTAINERS & Zones()
Definition: class_board.h:252
SHAPE_POLY_SET m_through_outer_holes_poly
It contains polygon contours for through holes (outer cylinder)
int GetWidth() const
Definition: class_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 TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aError)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
VIATYPE GetViaType() const
Definition: class_track.h:381
void AddSolidAreasShapesToContainer(const ZONE_CONTAINER *aZoneContainer, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId)
COBJECT2D * createNewPadDrill(const D_PAD *aPad, int aInflateValue)
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.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
CBVHCONTAINER2D * m_platedpads_container2D_F_Cu
DRAWINGS & Drawings()
Definition: class_board.h:250
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:904
unsigned int m_stats_nr_tracks
Number of tracks in the board.
Abstract dimension API.
TRACKS & Tracks()
Definition: class_board.h:244
void AddPadsShapesWithClearanceToContainer(const MODULE *aModule, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
bool IsPadOnLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...

References _, CGENERICCONTAINER2D::Add(), AddGraphicsShapesWithClearanceToContainer(), AddPadsShapesWithClearanceToContainer(), 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, F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, FL_CLIP_SILK_ON_VIA_ANNULUS, FL_RENDER_OPENGL_COPPER_THICKNESS, FL_ZONE, g_DrawDefaultLineThickness, GetCopperThickness3DU(), GetCopperThicknessBIU(), VIA::GetDrillValue(), GetFlag(), GetRunningMicroSecs(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), Is3DLayerEnabled(), IsCopperLayer(), BOARD_ITEM::IsOnLayer(), VIA::IsPadOnLayer(), 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_holes_vias_outer_ring, m_through_outer_holes_poly, m_through_outer_holes_poly_NPTH, m_through_outer_holes_vias_poly, m_through_outer_ring_holes_vias_poly, Margin, MAX_CU_LAYERS, BOARD::Modules(), NULL, OPENGL_LEGACY, PAD_ATTRIB_HOLE_NOT_PLATED, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_LINE_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(), transformGraphicModuleEdgeToPolygonSet(), TRACK::TransformShapeWithClearanceToPolygon(), EDA_ITEM::Type(), wxPoint::x, wxPoint::y, and BOARD::Zones().

Referenced by InitSettings().

◆ createNewPadDrill()

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

Definition at line 439 of file create_3Dgraphic_brd_items.cpp.

440 {
441  wxSize drillSize = aPad->GetDrillSize();
442 
443  if( !drillSize.x || !drillSize.y )
444  {
445  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createNewPadDrill - found an invalid pad" ) );
446  return NULL;
447  }
448 
449  if( drillSize.x == drillSize.y ) // usual round hole
450  {
451  const int radius = (drillSize.x / 2) + aInflateValue;
452 
453  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
454  -aPad->GetPosition().y * m_biuTo3Dunits );
455 
456  return new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad );
457 
458  }
459  else // Oblong hole
460  {
461  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
462  float width = seg->GetWidth() + aInflateValue * 2;
463 
464  SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
465  -seg->GetSeg().A.y * m_biuTo3Dunits );
466 
467  SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
468  -seg->GetSeg().B.y * m_biuTo3Dunits );
469 
470  return new CROUNDSEGMENT2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
471  }
472 
473  return NULL;
474 }
wxPoint GetPosition() const override
Definition: class_pad.h:165
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a SHAPE object representing the pad's hole.
Definition: class_pad.cpp:273
const SEG & GetSeg() const
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....
const wxSize & GetDrillSize() const
Definition: class_pad.h:230
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, D_PAD::GetDrillSize(), D_PAD::GetEffectiveHoleShape(), D_PAD::GetPosition(), SHAPE_SEGMENT::GetSeg(), SHAPE_SEGMENT::GetWidth(), m_biuTo3Dunits, m_logTrace, NULL, wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by createLayers().

◆ createNewPadWithClearance()

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

Definition at line 334 of file create_3Dgraphic_brd_items.cpp.

338 {
339  SHAPE_POLY_SET poly;
340 
341  // Our shape-based builder can't handle negative or differing x:y clearance values (the
342  // former are common for solder paste whiel the later get generated when a relative paste
343  // margin is used with an oblong pad). So we apply this huge hack and fake a larger pad to
344  // run the general-purpose polygon builder on.
345  // Of course being a hack it falls down when dealing with custom shape pads (where the size
346  // is only the size of the anchor), so for those we punt and just use aClearanceValue.x.
347 
348  if( ( aClearanceValue.x < 0 || aClearanceValue.x != aClearanceValue.y )
349  && aPad->GetShape() != PAD_SHAPE_CUSTOM )
350  {
351  D_PAD dummy( *aPad );
352  dummy.SetSize( aPad->GetSize() + aClearanceValue + aClearanceValue );
353  dummy.TransformShapeWithClearanceToPolygon( poly, aLayer, 0 );
354  aClearanceValue = { 0, 0 };
355  }
356  else
357  {
358  auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
359 
360  for( const SHAPE* shape : padShapes->Shapes() )
361  {
362  switch( shape->Type() )
363  {
364  case SH_SEGMENT:
365  {
366  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape;
367  const SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
368  -seg->GetSeg().A.y * m_biuTo3Dunits );
369  const SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
370  -seg->GetSeg().B.y * m_biuTo3Dunits );
371  const int width = seg->GetWidth() + aClearanceValue.x * 2;
372 
373  // Cannot add segments that have the same start and end point
374  if( Is_segment_a_circle( start3DU, end3DU ) )
375  {
376  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
377  ( width / 2) * m_biuTo3Dunits,
378  *aPad ) );
379  }
380  else
381  {
382  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
383  width * m_biuTo3Dunits,
384  *aPad ) );
385  }
386  }
387  break;
388 
389  case SH_CIRCLE:
390  {
391  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape;
392  const int radius = circle->GetRadius() + aClearanceValue.x;
393  const SFVEC2F center( circle->GetCenter().x * m_biuTo3Dunits,
394  -circle->GetCenter().y * m_biuTo3Dunits );
395 
396  aDstContainer->Add( new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad ) );
397  }
398  break;
399 
400  case SH_RECT:
401  {
402  SHAPE_RECT* rect = (SHAPE_RECT*) shape;
403 
404  poly.NewOutline();
405  poly.Append( rect->GetPosition() );
406  poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y );
407  poly.Append( rect->GetPosition() + rect->GetSize() );
408  poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y );
409  }
410  break;
411 
412  case SH_SIMPLE:
413  poly.AddOutline( static_cast<const SHAPE_SIMPLE*>( shape )->Vertices() );
414  break;
415 
416  case SH_POLY_SET:
417  poly = *(SHAPE_POLY_SET*) shape;
418  break;
419 
420  default:
421  wxFAIL_MSG( "BOARD_ADAPTER::createNewPadWithClearance no implementation for "
422  + SHAPE_TYPE_asString( shape->Type() ) );
423  break;
424  }
425  }
426  }
427 
428  if( !poly.IsEmpty() )
429  {
430  if( aClearanceValue.x )
431  poly.Inflate( aClearanceValue.x, 32 );
432 
433  // Add the PAD polygon
434  Convert_shape_line_polygon_to_triangles( poly, *aDstContainer, m_biuTo3Dunits, *aPad );
435  }
436 }
int GetRadius() const
Definition: shape_circle.h:94
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
const VECTOR2I GetCenter() const
Definition: shape_circle.h:99
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:121
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:111
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:54
SHAPE.
Definition: shape.h:120
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: class_pad.cpp:264
int NewOutline()
Creates a new empty polygon in the set and returns its index
line chain (polyline)
Definition: shape.h:45
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:47
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:42
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:157
const wxSize & GetSize() const
Definition: class_pad.h:224
int GetWidth() const
circle
Definition: shape.h:46
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:43
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(), SHAPE_CIRCLE::GetCenter(), D_PAD::GetEffectiveShape(), SHAPE_RECT::GetPosition(), SHAPE_CIRCLE::GetRadius(), SHAPE_SEGMENT::GetSeg(), D_PAD::GetShape(), SHAPE_RECT::GetSize(), D_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 AddPadsShapesWithClearanceToContainer().

◆ createNewTrack()

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

Definition at line 256 of file create_3Dgraphic_brd_items.cpp.

258 {
259  SFVEC2F start3DU( aTrack->GetStart().x * m_biuTo3Dunits,
260  -aTrack->GetStart().y * m_biuTo3Dunits ); // y coord is inverted
261 
262  switch( aTrack->Type() )
263  {
264  case PCB_VIA_T:
265  {
266  const float radius = ( ( aTrack->GetWidth() / 2 ) + aClearanceValue ) * m_biuTo3Dunits;
267  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius, *aTrack ) );
268  }
269  break;
270 
271  case PCB_ARC_T:
272  {
273  const ARC* arc = static_cast<const ARC*>( aTrack );
274  VECTOR2D center( arc->GetCenter() );
275  double arc_angle = arc->GetAngle();
276  double radius = arc->GetRadius();
277  int arcsegcount = GetArcToSegmentCount( radius, Millimeter2iu( 0.005), arc_angle/10 );
278  int circlesegcount;
279 
280  // We need a circle to segment count. However, the arc angle can be small, and the
281  // radius very big. so we calculate a reasonable value for circlesegcount.
282  if( arcsegcount <= 1 ) // The arc will be approximated by a segment
283  circlesegcount = 1;
284  else
285  {
286  double cnt = arcsegcount * 3600/std::abs( arc_angle );
287 
288  #define SEG_CNT_MAX 128
289  if( cnt < SEG_CNT_MAX )
290  {
291  circlesegcount = (int)cnt;
292 
293  if( circlesegcount == 0 )
294  circlesegcount = 1;
295  }
296  else
297  circlesegcount = SEG_CNT_MAX;
298  }
299 
300  TransformArcToSegments( wxPoint( center.x, center.y ), arc->GetStart(),
301  arc_angle, circlesegcount,
302  arc->GetWidth() + 2 * aClearanceValue, aDstContainer,
303  *arc );
304  }
305  break;
306 
307  case PCB_TRACE_T: // Track is a usual straight segment
308  {
309  SFVEC2F end3DU ( aTrack->GetEnd().x * m_biuTo3Dunits,
310  -aTrack->GetEnd().y * m_biuTo3Dunits );
311 
312  // Cannot add segments that have the same start and end point
313  if( Is_segment_a_circle( start3DU, end3DU ) )
314  {
315  const float radius = ((aTrack->GetWidth() / 2) + aClearanceValue) * m_biuTo3Dunits;
316 
317  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius, *aTrack ) );
318  }
319  else
320  {
321  const float width = (aTrack->GetWidth() + 2 * aClearanceValue ) * m_biuTo3Dunits;
322 
323  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, width, *aTrack ) );
324  }
325  }
326  break;
327 
328  default:
329  break;
330  }
331 }
#define SEG_CNT_MAX
const wxPoint & GetStart() const
Definition: class_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....
virtual wxPoint GetCenter() const
Function GetCenter()
double GetRadius() const
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
double GetAngle() const
int GetWidth() const
Definition: class_track.h:110
const wxPoint & GetEnd() const
Definition: class_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: base_struct.h:193

References CGENERICCONTAINER2D::Add(), ARC::GetAngle(), GetArcToSegmentCount(), BOARD_ITEM::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(), EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by createLayers().

◆ destroyLayers()

void BOARD_ADAPTER::destroyLayers ( )
private

Definition at line 56 of file create_layer_items.cpp.

57 {
58  if( !m_layers_poly.empty() )
59  {
60  for( auto& poly : m_layers_poly )
61  delete poly.second;
62 
63  m_layers_poly.clear();
64  }
65 
68 
69  if( !m_layers_inner_holes_poly.empty() )
70  {
71  for( auto& poly : m_layers_inner_holes_poly )
72  delete poly.second;
73 
75  }
76 
77  if( !m_layers_outer_holes_poly.empty() )
78  {
79  for( auto& poly : m_layers_outer_holes_poly )
80  delete poly.second;
81 
83  }
84 
85  if( !m_layers_container2D.empty() )
86  {
87  for( auto& poly : m_layers_container2D )
88  delete poly.second;
89 
90  m_layers_container2D.clear();
91  }
92 
95 
96  if( !m_layers_holes2D.empty() )
97  {
98  for( auto& poly : m_layers_holes2D )
99  delete poly.second;
100 
101  m_layers_holes2D.clear();
102  }
103 
112 
115 }
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)
SHAPE_POLY_SET m_through_outer_ring_holes_vias_poly
It contains polygon contours for through holes vias (outer annular ring)
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_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)
CBVHCONTAINER2D m_through_holes_vias_outer_ring
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the a...
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

References CGENERICCONTAINER2D::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_holes_vias_outer_ring, m_through_outer_holes_poly, m_through_outer_holes_poly_NPTH, m_through_outer_holes_vias_poly, m_through_outer_ring_holes_vias_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 166 of file board_adapter.h.

167  {
168  return m_boardBoundingBox;
169  }
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()

const BOARD* BOARD_ADAPTER::GetBoard ( ) const
inlinenoexcept

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

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

References m_boardCenter.

Referenced by C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::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 310 of file board_adapter.h.

311  {
312  return m_board_poly;
313  }
SHAPE_POLY_SET m_board_poly
PCB board outline polygon.

References m_board_poly.

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

◆ GetBoardPosBIU()

wxPoint BOARD_ADAPTER::GetBoardPosBIU ( ) const
inlinenoexcept

GetBoardPosBIU - Get the board size.

Returns
size in BIU unities

Definition at line 217 of file board_adapter.h.

218  {
219  return m_boardPos;
220  }
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 unities

Definition at line 208 of file board_adapter.h.

209  {
210  return m_boardSize;
211  }
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 485 of file board_adapter.cpp.

486 {
487  return SFVEC4F( aColor.r, aColor.g, aColor.b, aColor.a );
488 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
double g
Green component.
Definition: color4d.h:367
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
double r
Red component.
Definition: color4d.h:366

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 unities of copperlayers

Definition at line 193 of file board_adapter.h.

194  {
195  return m_copperThickness3DU;
196  }
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().

◆ GetCopperThicknessBIU()

int BOARD_ADAPTER::GetCopperThicknessBIU ( ) const
noexcept

GetCopperThicknessBIU - Get the current copper layer thickness.

Returns
thickness in board unities

Definition at line 254 of file board_adapter.cpp.

255 {
256  return COPPER_THICKNESS;
257 }
#define COPPER_THICKNESS

References COPPER_THICKNESS.

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

◆ GetEpoxyThickness3DU()

float BOARD_ADAPTER::GetEpoxyThickness3DU ( ) const
inlinenoexcept

GetEpoxyThickness3DU - Get the current epoxy thickness.

Returns
thickness in 3d unities

Definition at line 175 of file board_adapter.h.

176  {
177  return m_epoxyThickness3DU;
178  }
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 224 of file board_adapter.cpp.

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

References FL_LAST, and m_drawFlags.

Referenced by C3D_RENDER_RAYTRACING::add_3D_models(), C3D_RENDER_RAYTRACING::createItemsFromContainer(), createLayers(), EDA_3D_CONDITIONS::flagFunction(), C3D_RENDER_OGL_LEGACY::get_layer_color(), GetModulesZcoord3DIU(), 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_OGL_LEGACY::reload(), C3D_RENDER_RAYTRACING::reload(), C3D_RENDER_OGL_LEGACY::render_3D_module(), 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(), ShouldModuleBeDisplayed(), EDA_3D_CONTROLLER::ToggleVisibility(), and DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow().

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

480 {
481  return GetColor( m_colors->GetColor( aItemId ) );
482 }
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 unities

Definition at line 351 of file board_adapter.h.

352  {
353  return m_layerZcoordBottom[aLayerId];
354  }
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 469 of file board_adapter.cpp.

470 {
471  wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
472 
473  const COLOR4D color = m_colors->GetColor( aLayerId );
474 
475  return SFVEC4F( color.r, color.g, color.b, color.a );
476 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
COLOR_SETTINGS * m_colors
int color
Definition: DXF_plotter.cpp:61
COLOR4D GetColor(int aLayer) const
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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 unities

Definition at line 341 of file board_adapter.h.

342  {
343  return m_layerZcoordTop[aLayerId];
344  }
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 360 of file board_adapter.h.

361  {
362  return m_layers_container2D;
363  }
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_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::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 379 of file board_adapter.h.

380  {
381  return m_layers_holes2D;
382  }
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 module in 3d integer units considering if it is flipped or not.

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

Definition at line 450 of file board_adapter.cpp.

451 {
452  if( aIsFlipped )
453  {
454  if( GetFlag( FL_SOLDERPASTE ) )
456  else
458  }
459  else
460  {
461  if( GetFlag( FL_SOLDERPASTE ) )
462  return m_layerZcoordTop[F_SilkS];
463  else
464  return m_layerZcoordTop[F_Paste];
465  }
466 }
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_module().

◆ GetNonCopperLayerThickness3DU()

float BOARD_ADAPTER::GetNonCopperLayerThickness3DU ( ) const
inlinenoexcept

GetNonCopperLayerThickness3DU - Get the current non copper layers thickness.

Returns
thickness in 3d unities of non copperlayers

Definition at line 184 of file board_adapter.h.

185  {
187  }
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 259 of file board_adapter.cpp.

260 {
261  wxASSERT( aDiameter3DU > 0.0f );
262 
263  return GetNrSegmentsCircle( (int)( aDiameter3DU / m_biuTo3Dunits ) );
264 }
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 267 of file board_adapter.cpp.

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

References GetArcToSegmentCount().

◆ GetPlatedPads_Back()

const CBVHCONTAINER2D* BOARD_ADAPTER::GetPlatedPads_Back ( ) const
inlinenoexcept

Definition at line 370 of file board_adapter.h.

371  {
373  }
CBVHCONTAINER2D * m_platedpads_container2D_B_Cu

References m_platedpads_container2D_B_Cu.

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

◆ GetPlatedPads_Front()

const CBVHCONTAINER2D* BOARD_ADAPTER::GetPlatedPads_Front ( ) const
inlinenoexcept

Definition at line 365 of file board_adapter.h.

366  {
368  }
CBVHCONTAINER2D * m_platedpads_container2D_F_Cu

References m_platedpads_container2D_F_Cu.

Referenced by C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::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 536 of file board_adapter.h.

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

552  {
554  }
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 556 of file board_adapter.h.

557  {
559  }
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 546 of file board_adapter.h.

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

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

505  {
507  }
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 513 of file board_adapter.h.

514  {
516  }
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 495 of file board_adapter.h.

496  {
498  }
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 486 of file board_adapter.h.

487  {
488  return m_stats_nr_holes;
489  }
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 477 of file board_adapter.h.

478  {
479  return m_stats_nr_vias;
480  }
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 468 of file board_adapter.h.

469  {
470  return m_through_holes_inner;
471  }
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().

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

389  {
390  return m_through_holes_outer;
391  }
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_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

◆ GetThroughHole_Outer_poly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHole_Outer_poly ( ) const
inlinenoexcept

GetThroughHole_Outer_poly -.

Returns

Definition at line 407 of file board_adapter.h.

408  {
410  }
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

GetThroughHole_Outer_poly_NPTH -.

Returns

Definition at line 416 of file board_adapter.h.

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

399  {
401  }
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().

◆ GetThroughHole_Vias_Inner()

const CBVHCONTAINER2D& BOARD_ADAPTER::GetThroughHole_Vias_Inner ( ) const
inlinenoexcept

GetThroughHole_Vias_Inner -.

Returns
a container with via THT holes only

Definition at line 443 of file board_adapter.h.

444  {
446  }
CBVHCONTAINER2D m_through_holes_vias_inner
It contains the list of throughHoles vias of the board, the radius of the hole.

References m_through_holes_vias_inner.

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

426  {
428  }
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

GetThroughHole_Vias_Outer_poly -.

Definition at line 451 of file board_adapter.h.

452  {
454  }
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().

◆ GetThroughHole_Vias_Outer_Ring()

const CBVHCONTAINER2D& BOARD_ADAPTER::GetThroughHole_Vias_Outer_Ring ( ) const
inlinenoexcept

GetThroughHole_Vias_Outer_Ring -.

Returns
a container with via THT holes only, including annular ring size

Definition at line 434 of file board_adapter.h.

435  {
437  }
CBVHCONTAINER2D m_through_holes_vias_outer_ring
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the a...

References m_through_holes_vias_outer_ring.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GetThroughHole_Vias_Outer_Ring_poly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHole_Vias_Outer_Ring_poly ( ) const
inlinenoexcept

GetThroughHole_Vias_Outer_Ring_poly -.

Definition at line 459 of file board_adapter.h.

460  {
462  }
SHAPE_POLY_SET m_through_outer_ring_holes_vias_poly
It contains polygon contours for through holes vias (outer annular ring)

References m_through_outer_ring_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 244 of file board_adapter.h.

245  {
246  return m_3D_grid_type;
247  }
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 253 of file board_adapter.h.

254  {
255  m_3D_grid_type = aGridType;
256  }
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 275 of file board_adapter.cpp.

276 {
277  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) );
278 
279  // Calculates the board bounding box (board outlines + items)
280  // to ensure any item, even outside the board outlines can be seen
281  EDA_RECT bbbox = m_board->ComputeBoundingBox( false );
282 
283  // Gives a non null size to avoid issues in zoom / scale calculations
284  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
285  bbbox.Inflate( Millimeter2iu( 10 ) );
286 
287  m_boardSize = bbbox.GetSize();
288  m_boardPos = bbbox.Centre();
289 
290  wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
291 
292  m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
293 
295 
296  // Ensure the board has 2 sides for 3D views, because it is hard to find
297  // a *really* single side board in the true life...
298  if( m_copperLayersCount < 2 )
300 
301  // Calculate the convertion to apply to all positions.
303 
305 
306  // !TODO: use value defined by user (currently use default values by ctor
309 
310  // Init Z position of each layer
311  // calculate z position for each copper layer
312  // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
313  // Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
314  // all unused copper layer z position are set to 0
315 
316  // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
317  // | | Top = Bottom + m_copperThickness
318  // |__________________________________|
319  // == == == == <- Bottom = -m_epoxyThickness / 2.0,
320  // Top = Bottom - m_copperThickness
321 
322  unsigned int layer;
323 
324  for( layer = 0; layer < m_copperLayersCount; ++layer )
325  {
326  m_layerZcoordBottom[layer] = m_epoxyThickness3DU / 2.0f -
327  (m_epoxyThickness3DU * layer / (m_copperLayersCount - 1) );
328 
329  if( layer < (m_copperLayersCount / 2) )
331  else
333  }
334 
335  #define layerThicknessMargin 1.1
336  const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
337 
338  // Fill remaining unused copper layers and back layer zpos
339  // with -m_epoxyThickness / 2.0
340  for( ; layer < MAX_CU_LAYERS; layer++ )
341  {
342  m_layerZcoordBottom[layer] = -(m_epoxyThickness3DU / 2.0f);
344  }
345 
346  // This is the top of the copper layer thickness.
347  const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
348  const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
349 
350  // calculate z position for each non copper layer
351  // Solder mask and Solder paste have the same Z position
352  for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
353  {
354  float zposTop;
355  float zposBottom;
356 
357  switch( layer_id )
358  {
359  case B_Adhes:
360  zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
361  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
362  break;
363 
364  case F_Adhes:
365  zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
366  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
367  break;
368 
369  case B_Mask:
370  case B_Paste:
371  zposBottom = zpos_copperTop_back;
372  zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
373  break;
374 
375  case F_Mask:
376  case F_Paste:
377  zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
378  zposBottom = zpos_copperTop_front;
379  break;
380 
381  case B_SilkS:
382  zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
383  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
384  break;
385 
386  case F_SilkS:
387  zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
388  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
389  break;
390 
391  // !TODO: review
392  default:
393  zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
394  zposBottom = zposTop - m_nonCopperLayerThickness3DU;
395  break;
396  }
397 
398  m_layerZcoordTop[layer_id] = zposTop;
399  m_layerZcoordBottom[layer_id] = zposBottom;
400  }
401 
404  0.0f );
405 
406  SFVEC3F boardSize = SFVEC3F( m_boardSize.x * m_biuTo3Dunits,
408  0.0f );
409  boardSize /= 2.0f;
410 
411  SFVEC3F boardMin = (m_boardCenter - boardSize);
412  SFVEC3F boardMax = (m_boardCenter + boardSize);
413 
414  boardMin.z = m_layerZcoordTop[B_Adhes];
415  boardMax.z = m_layerZcoordTop[F_Adhes];
416 
417  m_boardBoundingBox = CBBOX( boardMin, boardMax );
418 
419 #ifdef PRINT_STATISTICS_3D_VIEWER
420  unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
421 #endif
422 
423  if( aStatusReporter )
424  aStatusReporter->Report( _( "Build board body" ) );
425 
426  wxString msg;
427 
428  if( !createBoardPolygon( &msg ) )
429  aWarningReporter->Report( _( "Board outline is not closed: " ) + msg, RPT_SEVERITY_WARNING );
430  else
431  aWarningReporter->Report( wxEmptyString );
432 
433  if( aStatusReporter )
434  aStatusReporter->Report( _( "Create layers" ) );
435 
436  createLayers( aStatusReporter );
437 }
#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: class_board.h:514
#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....
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
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).
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:40
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
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, BOARD_DESIGN_SETTINGS::GetBoardThickness(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), EDA_RECT::GetHeight(), GetRunningMicroSecs(), EDA_RECT::GetSize(), EDA_RECT::GetWidth(), EDA_RECT::Inflate(), 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, TECH_LAYER_THICKNESS, wxPoint::x, and wxPoint::y.

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

◆ Is3DLayerEnabled()

bool BOARD_ADAPTER::Is3DLayerEnabled ( PCB_LAYER_ID  aLayer) const

Is3DLayerEnabled - Check if a layer is enabled.

Parameters
aLayerlayer ID to get status
Returns
true if layer should be displayed, false if not

Definition at line 149 of file board_adapter.cpp.

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

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

MaterialModeGet.

Returns
material rendering mode

Definition at line 301 of file board_adapter.h.

302  {
303  return m_material_mode;
304  }
MATERIAL_MODE m_material_mode

References m_material_mode.

Referenced by C3D_RENDER_RAYTRACING::add_3D_models(), C3D_RENDER_OGL_LEGACY::load_3D_models(), EDA_3D_CONDITIONS::materialModeFunction(), and EDA_3D_VIEWER::SaveSettings().

◆ MaterialModeSet()

void BOARD_ADAPTER::MaterialModeSet ( MATERIAL_MODE  aMaterialMode)
inlinenoexcept

MaterialModeSet.

Parameters
aMaterialMode= the render material mode

Definition at line 292 of file board_adapter.h.

293  {
294  m_material_mode = aMaterialMode;
295  }
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 274 of file board_adapter.h.

275  {
276  m_render_engine = aRenderEngine;
277  }
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 126 of file board_adapter.h.

127  {
128  m_board = aBoard;
129  }

References m_board.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ SetColorSettings()

void BOARD_ADAPTER::SetColorSettings ( COLOR_SETTINGS aSettings)
inlinenoexcept

Definition at line 140 of file board_adapter.h.

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

References m_colors.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ SetFlag()

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

SetFlag - set the status of a flag.

Parameters
aFlagthe flag to get the status
aStatestatus to set

Definition at line 232 of file board_adapter.cpp.

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

References FL_LAST, and m_drawFlags.

Referenced by BOARD_ADAPTER(), PANEL_PREV_3D::loadCommonSettings(), EDA_3D_VIEWER::loadCommonSettings(), EDA_3D_CONTROLLER::ToggleVisibility(), and DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow().

◆ ShouldModuleBeDisplayed()

bool BOARD_ADAPTER::ShouldModuleBeDisplayed ( MODULE_ATTR_T  aModuleAttributs) const

ShouldModuleBeDisplayed - Test if module should be displayed in relation to attributs and the flags.

Returns
true if module should be displayed, false if not

Definition at line 239 of file board_adapter.cpp.

240 {
241  if( aModuleAttributs & MOD_SMD )
243  else if( aModuleAttributs & MOD_THROUGH_HOLE )
245  else
247 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.

References FL_MODULE_ATTRIBUTES_NORMAL, FL_MODULE_ATTRIBUTES_NORMAL_INSERT, FL_MODULE_ATTRIBUTES_VIRTUAL, GetFlag(), MOD_SMD, and MOD_THROUGH_HOLE.

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

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

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

Referenced by AddShapeWithClearanceToContainer(), and createNewTrack().

◆ transformGraphicModuleEdgeToPolygonSet()

void BOARD_ADAPTER::transformGraphicModuleEdgeToPolygonSet ( const MODULE aModule,
PCB_LAYER_ID  aLayer,
SHAPE_POLY_SET aCornerBuffer 
) const
private

Definition at line 62 of file create_layer_poly.cpp.

65 {
66  for( BOARD_ITEM* item : aModule->GraphicalItems() )
67  {
68  if( item->Type() == PCB_MODULE_EDGE_T )
69  {
70  EDGE_MODULE* outline = (EDGE_MODULE*) item;
71 
72  if( outline->GetLayer() == aLayer )
73  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0 );
74  }
75  }
76 }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
DRAWINGS & GraphicalItems()
Definition: class_module.h:191
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...

References BOARD_ITEM::GetLayer(), MODULE::GraphicalItems(), PCB_MODULE_EDGE_T, and DRAWSEGMENT::TransformShapeWithClearanceToPolygon().

Referenced by createLayers().

Member Data Documentation

◆ m_3D_grid_type

GRID3D_TYPE BOARD_ADAPTER::m_3D_grid_type
private

Definition at line 676 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 670 of file board_adapter.h.

Referenced by Get3DCacheManager(), and Set3DCacheManager().

◆ m_antialiasing_mode

ANTIALIASING_MODE BOARD_ADAPTER::m_antialiasing_mode
private

Definition at line 679 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 724 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 697 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 691 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 685 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 688 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 791 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 788 of file board_adapter.h.

Referenced by BOARD_ADAPTER().

◆ m_colors

COLOR_SETTINGS* BOARD_ADAPTER::m_colors
private

Definition at line 671 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 766 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 779 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 675 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 782 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 730 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 736 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 709 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 706 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 700 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 776 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 773 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 820 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 678 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 785 of file board_adapter.h.

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

◆ m_platedpads_container2D_B_Cu

CBVHCONTAINER2D* BOARD_ADAPTER::m_platedpads_container2D_B_Cu
private

Definition at line 733 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 732 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 677 of file board_adapter.h.

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

◆ m_SilkScreenColorBot

◆ m_SilkScreenColorTop

◆ m_SolderMaskColorBot

◆ m_SolderMaskColorTop

◆ m_SolderPasteColor

◆ m_stats_hole_med_diameter

float BOARD_ADAPTER::m_stats_hole_med_diameter
private

Computed medium diameter of the holes in 3D units.

Definition at line 812 of file board_adapter.h.

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

◆ m_stats_nr_holes

unsigned int BOARD_ADAPTER::m_stats_nr_holes
private

number of holes in the board

Definition at line 809 of file board_adapter.h.

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

◆ m_stats_nr_tracks

unsigned int BOARD_ADAPTER::m_stats_nr_tracks
private

Number of tracks in the board.

Definition at line 797 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and createLayers().

◆ m_stats_nr_vias

unsigned int BOARD_ADAPTER::m_stats_nr_vias
private

Nr of vias.

Definition at line 803 of file board_adapter.h.

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

◆ m_stats_track_med_width

float BOARD_ADAPTER::m_stats_track_med_width
private

Track average width.

Definition at line 800 of file board_adapter.h.

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

◆ m_stats_via_med_hole_diameter

float BOARD_ADAPTER::m_stats_via_med_hole_diameter
private

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

Definition at line 806 of file board_adapter.h.

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

◆ m_through_holes_inner

CBVHCONTAINER2D BOARD_ADAPTER::m_through_holes_inner
private

It contains the list of throughHoles of the board, the radius is the inner hole.

Definition at line 748 of file board_adapter.h.

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

◆ m_through_holes_outer

CBVHCONTAINER2D BOARD_ADAPTER::m_through_holes_outer
private

It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper tickness.

Definition at line 740 of file board_adapter.h.