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...
 
SFVEC3F GetLayerColor (PCB_LAYER_ID aLayerId) const
 GetLayerColor - get the technical color of a layer. More...
 
SFVEC3F GetItemColor (int aItemId) const
 GetItemColor - get the technical color of a layer. More...
 
SFVEC3F 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 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 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_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_Inner_poly () const noexcept
 GetThroughHole_Vias_Inner_poly -. More...
 
const CBVHCONTAINER2DGetThroughHole_Inner () const noexcept
 GetThroughHole_Inner - Get the ThroughHole container. More...
 
const SHAPE_POLY_SETGetThroughHole_Inner_poly () const noexcept
 GetThroughHole_Inner_poly -. 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...
 
double GetCircleCorrectionFactor (int aNrSides) const
 GetCircleCorrectionFactor - computes a angle correction factor used when creating circles. More...
 
const MAP_POLYGetPolyMap () const noexcept
 GetPolyMap - Get maps of polygons's layers. More...
 
const MAP_POLYGetPolyMapHoles_Inner () const noexcept
 
const MAP_POLYGetPolyMapHoles_Outer () const noexcept
 

Public Attributes

SFVEC3D m_BgColorBot
 background bottom color More...
 
SFVEC3D m_BgColorTop
 background top color More...
 
SFVEC3D m_BoardBodyColor
 in realistic mode: FR4 board color More...
 
SFVEC3D m_SolderMaskColorBot
 in realistic mode: solder mask color ( bot ) More...
 
SFVEC3D m_SolderMaskColorTop
 in realistic mode: solder mask color ( top ) More...
 
SFVEC3D m_SolderPasteColor
 in realistic mode: solder paste color More...
 
SFVEC3D m_SilkScreenColorBot
 in realistic mode: SilkScreen color ( bot ) More...
 
SFVEC3D m_SilkScreenColorTop
 in realistic mode: SilkScreen color ( top ) More...
 
SFVEC3D m_CopperColor
 in realistic mode: copper color More...
 

Private Member Functions

bool createBoardPolygon ()
 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, 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)
 
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...
 
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_inner_holes_poly
 It contains polygon contours for through holes (inner 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_inner_holes_vias_poly
 It contains polygon contours for through holes vias (inner cylinder) 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...
 
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_inner
 It contains the list of throughHoles of the board, the radius is the inner hole. More...
 
CBVHCONTAINER2D m_through_holes_vias_outer
 It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the copper tickness. More...
 
CBVHCONTAINER2D m_through_holes_vias_inner
 It contains the list of throughHoles vias of the board, the radius of the hole. More...
 
unsigned int m_copperLayersCount
 Number of copper layers actually used by the board. More...
 
double m_biuTo3Dunits
 Normalization scale to convert board internal units to 3D units to normalize 3D units between -1.0 and +1.0. More...
 
std::array< float, PCB_LAYER_ID_COUNTm_layerZcoordTop
 Top (End) Z position of each layer (normalized) More...
 
std::array< float, PCB_LAYER_ID_COUNTm_layerZcoordBottom
 Bottom (Start) Z position of each layer (normalized) More...
 
float m_copperThickness3DU
 Copper thickness (normalized) More...
 
float m_epoxyThickness3DU
 Epoxy thickness (normalized) More...
 
float m_nonCopperLayerThickness3DU
 Non copper layers thickness. More...
 
float m_calc_seg_min_factor3DU
 min factor used for cicle segment approximation calculation More...
 
float m_calc_seg_max_factor3DU
 max factor used for cicle segment approximation calculation More...
 
unsigned int m_stats_nr_tracks
 Number of tracks in the board. More...
 
float m_stats_track_med_width
 Track average width. More...
 
unsigned int m_stats_nr_vias
 Nr of vias. More...
 
float m_stats_via_med_hole_diameter
 Computed medium diameter of the via holes in 3D units. More...
 
unsigned int m_stats_nr_holes
 number of holes in the board More...
 
float m_stats_hole_med_diameter
 Computed medium diameter of the holes in 3D units. More...
 

Static Private Attributes

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

Detailed Description

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

Definition at line 68 of file board_adapter.h.

Constructor & Destructor Documentation

◆ BOARD_ADAPTER()

BOARD_ADAPTER::BOARD_ADAPTER ( )

Definition at line 50 of file board_adapter.cpp.

50  :
51  m_board( nullptr ),
52  m_3d_model_manager( nullptr ),
53  m_colors( nullptr ),
56 {
57  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
58 
61  m_drawFlags.resize( FL_LAST, false );
62 
63  if( PgmOrNull() )
64  m_colors = Pgm().GetSettingsManager().GetColorSettings();
65 
68 
69  m_boardPos = wxPoint();
70  m_boardSize = wxSize();
71  m_boardCenter = SFVEC3F( 0.0f );
72 
74 
77 
79  m_epoxyThickness3DU = 0.0f;
80  m_copperThickness3DU = 0.0f;
82  m_biuTo3Dunits = 1.0;
83 
85  m_stats_nr_vias = 0;
87  m_stats_nr_holes = 0;
90 
93 
96  SetFlag( FL_SHOW_BOARD_BODY, true );
100  SetFlag( FL_ZONE, true );
101  SetFlag( FL_SILKSCREEN, true );
102  SetFlag( FL_SOLDERMASK, true );
104 
110 
111  m_BgColorBot = SFVEC3D( 0.4, 0.4, 0.5 );
112  m_BgColorTop = SFVEC3D( 0.8, 0.8, 0.9 );
113  m_BoardBodyColor = SFVEC3D( 0.4, 0.4, 0.5 );
114  m_SolderMaskColorTop = SFVEC3D( 0.1, 0.2, 0.1 );
115  m_SolderMaskColorBot = SFVEC3D( 0.1, 0.2, 0.1 );
116  m_SolderPasteColor = SFVEC3D( 0.4, 0.4, 0.4 );
117  m_SilkScreenColorTop = SFVEC3D( 0.9, 0.9, 0.9 );
118  m_SilkScreenColorBot = SFVEC3D( 0.9, 0.9, 0.9 );
119  m_CopperColor = SFVEC3D( 0.75, 0.61, 0.23 );
120 }
GRID3D_TYPE m_3D_grid_type
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
float m_nonCopperLayerThickness3DU
Non copper layers thickness.
SFVEC3D m_SolderPasteColor
in realistic mode: solder paste color
SFVEC3D m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
COLOR_SETTINGS * m_colors
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.
unsigned int m_stats_nr_holes
number of holes in the board
wxPoint m_boardPos
center board actual position in board units
SFVEC3D m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
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)
SFVEC3D m_BgColorTop
background top color
RENDER_ENGINE m_render_engine
std::vector< bool > m_drawFlags
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
Use all material properties from model file.
float m_stats_track_med_width
Track average width.
glm::dvec3 SFVEC3D
Definition: xv3d_types.h:48
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....
SFVEC3D m_BgColorBot
background bottom color
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...
SFVEC3D m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
wxSize m_boardSize
board actual size in board units
SFVEC3D m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
unsigned int m_copperLayersCount
Number of copper layers actually used by the board.
SFVEC3D m_BoardBodyColor
in realistic mode: FR4 board color
SFVEC3D m_CopperColor
in realistic mode: copper color
float m_stats_via_med_hole_diameter
Computed medium diameter of the via holes in 3D units.
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...
ANTIALIASING_MODE m_antialiasing_mode
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.

References AA_8X, CGENERICCONTAINER2D::Clear(), 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_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_logTrace, m_material_mode, m_nonCopperLayerThickness3DU, 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, NONE, NORMAL, OPENGL_LEGACY, Pgm(), PgmOrNull(), CBBOX::Reset(), and SetFlag().

◆ ~BOARD_ADAPTER()

BOARD_ADAPTER::~BOARD_ADAPTER ( )

Definition at line 123 of file board_adapter.cpp.

124 {
125  destroyLayers();
126 }

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

173 {
174  std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
175  EDGE_MODULE* outline;
176 
177  for( auto item : aModule->GraphicalItems() )
178  {
179  switch( item->Type() )
180  {
181  case PCB_MODULE_TEXT_T:
182  {
183  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
184 
185  if( text->GetLayer() == aLayerId && text->IsVisible() )
186  texts.push_back( text );
187  }
188  break;
189 
190 
191  case PCB_MODULE_EDGE_T:
192  {
193  outline = (EDGE_MODULE*) item;
194 
195  if( outline->GetLayer() != aLayerId )
196  break;
197 
199  aDstContainer,
200  aLayerId, 0 );
201  }
202  break;
203 
204  default:
205  break;
206  }
207  }
208 
209  // Convert texts sur modules
210  if( aModule->Reference().GetLayer() == aLayerId && aModule->Reference().IsVisible() )
211  texts.push_back( &aModule->Reference() );
212 
213  if( aModule->Value().GetLayer() == aLayerId && aModule->Value().IsVisible() )
214  texts.push_back( &aModule->Value() );
215 
216  s_boardItem = (const BOARD_ITEM *)&aModule->Value();
217  s_dstcontainer = aDstContainer;
219 
220  for( TEXTE_MODULE* text : texts )
221  {
222  s_textWidth = text->GetEffectiveTextPenWidth() + ( 2 * aInflateValue );
223  wxSize size = text->GetTextSize();
224  bool forceBold = true;
225  int penWidth = 0; // force max width for bold
226 
227  if( text->IsMirrored() )
228  size.x = -size.x;
229 
230  GRText( NULL, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(),
231  size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(),
232  forceBold, addTextSegmToContainer );
233  }
234 }
TEXTE_MODULE & Reference()
Definition: class_module.h:474
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsMirrored() const
Definition: eda_text.h:188
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:185
Definition: color4d.h:44
DRAWINGS & GraphicalItems()
Definition: class_module.h:179
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:152
static int s_textWidth
bool IsItalic() const
Definition: eda_text.h:179
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
#define NULL
static float s_biuTo3Dunits
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:473
const wxSize & GetTextSize() const
Definition: eda_text.h:238
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:247
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 
)
private

Definition at line 449 of file create_3Dgraphic_brd_items.cpp.

454 {
455  wxSize margin;
456 
457  for( auto pad : aModule->Pads() )
458  {
459  if( !pad->IsOnLayer( aLayerId ) )
460  continue;
461 
462  // NPTH pads are not drawn on layers if the
463  // shape size and pos is the same as their hole:
464  if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
465  {
466  if( (pad->GetDrillSize() == pad->GetSize()) &&
467  (pad->GetOffset() == wxPoint( 0, 0 )) )
468  {
469  switch( pad->GetShape() )
470  {
471  case PAD_SHAPE_CIRCLE:
472  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
473  continue;
474  break;
475 
476  case PAD_SHAPE_OVAL:
477  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
478  continue;
479  break;
480 
481  default:
482  break;
483  }
484  }
485  }
486 
487  switch( aLayerId )
488  {
489  case F_Mask:
490  case B_Mask:
491  margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
492  break;
493 
494  case F_Paste:
495  case B_Paste:
496  margin = pad->GetSolderPasteMargin();
497  margin.x += aInflateValue;
498  margin.y += aInflateValue;
499  break;
500 
501  default:
502  margin.x = margin.y = aInflateValue;
503  break;
504  }
505 
506  createNewPadWithClearance( pad, aDstContainer, margin );
507  }
508 }
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
PADS & Pads()
Definition: class_module.h:169
void createNewPadWithClearance(const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, wxSize aClearanceValue) const

References B_Mask, B_Paste, createNewPadWithClearance(), F_Mask, F_Paste, 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:341
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 588 of file create_3Dgraphic_brd_items.cpp.

592 {
593  // The full width of the lines to create
594  // The extra 1 protects the inner/outer radius values from degeneracy
595  const int linewidth = aDrawSegment->GetWidth() + (2 * aClearanceValue) + 1;
596 
597  switch( aDrawSegment->GetShape() )
598  {
599  case S_CIRCLE:
600  {
601  const SFVEC2F center3DU( aDrawSegment->GetCenter().x * m_biuTo3Dunits,
602  -aDrawSegment->GetCenter().y * m_biuTo3Dunits );
603 
604  float inner_radius = ( aDrawSegment->GetRadius() - linewidth / 2 ) * m_biuTo3Dunits;
605  float outer_radius = ( aDrawSegment->GetRadius() + linewidth / 2 ) * m_biuTo3Dunits;
606 
607  if( inner_radius < 0 )
608  inner_radius = 0;
609 
610  if( aDrawSegment->GetWidth() > 0 )
611  aDstContainer->Add( new CRING2D( center3DU, inner_radius, outer_radius, *aDrawSegment ) );
612  else
613  aDstContainer->Add( new CFILLEDCIRCLE2D( center3DU, outer_radius, *aDrawSegment ) );
614  }
615  break;
616 
617  case S_RECT:
618  {
619  if( aDrawSegment->GetWidth() > 0 )
620  {
621  std::vector<wxPoint> pts;
622  aDrawSegment->GetRectCorners( &pts );
623 
624  const SFVEC2F topLeft3DU( pts[0].x * m_biuTo3Dunits, -pts[0].y * m_biuTo3Dunits );
625  const SFVEC2F topRight3DU( pts[1].x * m_biuTo3Dunits, -pts[1].y * m_biuTo3Dunits );
626  const SFVEC2F botRight3DU( pts[2].x * m_biuTo3Dunits, -pts[2].y * m_biuTo3Dunits );
627  const SFVEC2F botLeft3DU( pts[3].x * m_biuTo3Dunits, -pts[3].y * m_biuTo3Dunits );
628 
629  aDstContainer->Add( new CROUNDSEGMENT2D( topLeft3DU, topRight3DU,
630  linewidth * m_biuTo3Dunits,
631  *aDrawSegment ) );
632  aDstContainer->Add( new CROUNDSEGMENT2D( topRight3DU, botRight3DU,
633  linewidth * m_biuTo3Dunits,
634  *aDrawSegment ) );
635  aDstContainer->Add( new CROUNDSEGMENT2D( botRight3DU, botLeft3DU,
636  linewidth * m_biuTo3Dunits,
637  *aDrawSegment ) );
638  aDstContainer->Add( new CROUNDSEGMENT2D( botLeft3DU, topLeft3DU,
639  linewidth * m_biuTo3Dunits,
640  *aDrawSegment ) );
641  }
642  else
643  {
644  SHAPE_POLY_SET polyList;
645 
646  aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aClearanceValue );
647 
648  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
649 
650  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
651  *aDrawSegment );
652  }
653  }
654  break;
655 
656  case S_ARC:
657  {
658  const unsigned int nr_segments =
659  GetNrSegmentsCircle( aDrawSegment->GetBoundingBox().GetSizeMax() );
660 
661  TransformArcToSegments( aDrawSegment->GetCenter(),
662  aDrawSegment->GetArcStart(),
663  aDrawSegment->GetAngle(),
664  nr_segments,
665  aDrawSegment->GetWidth(),
666  aDstContainer,
667  *aDrawSegment );
668  }
669  break;
670 
671  case S_SEGMENT:
672  {
673  const SFVEC2F start3DU( aDrawSegment->GetStart().x * m_biuTo3Dunits,
674  -aDrawSegment->GetStart().y * m_biuTo3Dunits );
675 
676  const SFVEC2F end3DU ( aDrawSegment->GetEnd().x * m_biuTo3Dunits,
677  -aDrawSegment->GetEnd().y * m_biuTo3Dunits );
678 
679  if( Is_segment_a_circle( start3DU, end3DU ) )
680  {
681  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
682  ( linewidth / 2 ) * m_biuTo3Dunits,
683  *aDrawSegment ) );
684  }
685  else
686  {
687  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
688  linewidth * m_biuTo3Dunits,
689  *aDrawSegment ) );
690  }
691  }
692  break;
693 
694  case S_CURVE:
695  case S_POLYGON:
696  {
697  SHAPE_POLY_SET polyList;
698 
699  aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aClearanceValue );
700 
701  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
702 
703  if( polyList.IsEmpty() ) // Just for caution
704  break;
705 
706  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
707  *aDrawSegment );
708  }
709  break;
710 
711  default:
712  wxFAIL_MSG( "BOARD_ADAPTER::AddShapeWithClearanceToContainer no implementation for "
713  + STROKE_T_asString( aDrawSegment->GetShape() ) );
714  break;
715  }
716 }
wxPoint GetArcStart() const
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, 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...
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
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.
void GetRectCorners(std::vector< wxPoint > *pts) const
int GetSizeMax() const
GetSizeMax.
Definition: eda_rect.h:109
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
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->GetWidth() + (2 * aClearanceValue);
140 
141  std::pair<wxPoint const *, wxPoint const *> segs[] = {
142  {&aDimension->m_crossBarO, &aDimension->m_crossBarF},
143  {&aDimension->m_featureLineGO, &aDimension->m_featureLineGF},
144  {&aDimension->m_featureLineDO, &aDimension->m_featureLineDF},
145  {&aDimension->m_crossBarF, &aDimension->m_arrowD1F},
146  {&aDimension->m_crossBarF, &aDimension->m_arrowD2F},
147  {&aDimension->m_crossBarO, &aDimension->m_arrowG1F},
148  {&aDimension->m_crossBarO, &aDimension->m_arrowG2F}};
149 
150  for( auto const & ii : segs )
151  {
152  const SFVEC2F start3DU( ii.first->x * m_biuTo3Dunits,
153  -ii.first->y * m_biuTo3Dunits );
154 
155  const SFVEC2F end3DU ( ii.second->x * m_biuTo3Dunits,
156  -ii.second->y * m_biuTo3Dunits );
157 
158  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
159  end3DU,
160  linewidth * m_biuTo3Dunits,
161  *aDimension ) );
162  }
163 }
int GetWidth() const
wxPoint m_crossBarF
wxPoint m_arrowD1F
wxPoint m_featureLineDF
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
wxPoint m_featureLineGO
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
wxPoint m_arrowG1F
wxPoint m_arrowD2F
wxPoint m_arrowG2F
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
TEXTE_PCB & Text()
wxPoint m_crossBarO
wxPoint m_featureLineDO
wxPoint m_featureLineGF

References CGENERICCONTAINER2D::Add(), AddShapeWithClearanceToContainer(), DIMENSION::GetWidth(), DIMENSION::m_arrowD1F, DIMENSION::m_arrowD2F, DIMENSION::m_arrowG1F, DIMENSION::m_arrowG2F, m_biuTo3Dunits, DIMENSION::m_crossBarF, DIMENSION::m_crossBarO, DIMENSION::m_featureLineDF, DIMENSION::m_featureLineDO, DIMENSION::m_featureLineGF, DIMENSION::m_featureLineGO, and DIMENSION::Text().

◆ AddSolidAreasShapesToContainer()

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

Definition at line 722 of file create_3Dgraphic_brd_items.cpp.

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

BiuTo3Dunits - Board integer units To 3D units.

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

Definition at line 157 of file board_adapter.h.

158  {
159  return m_biuTo3Dunits;
160  }
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1....

References m_biuTo3Dunits.

Referenced by createLayers(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), C3D_RENDER_OGL_LEGACY::generate_holes_display_list(), C3D_RENDER_OGL_LEGACY::generate_new_3DGrid(), C3D_RENDER_RAYTRACING::insert3DPadHole(), C3D_RENDER_RAYTRACING::insert3DViaHole(), C3D_RENDER_RAYTRACING::load_3D_models(), C3D_RENDER_OGL_LEGACY::reload(), C3D_RENDER_RAYTRACING::reload(), C3D_RENDER_OGL_LEGACY::render_3D_module(), and C3D_RENDER_RAYTRACING::setupMaterials().

◆ 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  SHAPE_POLY_SET corners;
50  aPad->TransformShapeWithClearanceToPolygon( corners, 0 );
51 
52  const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
53 
54  for( int ii = 0; ii < path.PointCount(); ++ii )
55  {
56  const VECTOR2I& a = path.CPoint( ii );
57  const VECTOR2I& b = path.CPoint( ii + 1 );
58 
59  TransformSegmentToPolygon( aCornerBuffer, wxPoint( a.x, a.y ), wxPoint( b.x, b.y ),
60  ARC_HIGH_DEF, aWidth );
61  }
62 }
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
SHAPE_POLY_SET.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
wxPoint ShapePos() const
Definition: class_pad.cpp:491
void TransformSegmentToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aError, int aWidth)
Function TransformRoundedEndsSegmentToPolygon convert a segment with rounded ends to a polygon Conver...
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:154
const wxSize & GetSize() const
Definition: class_pad.h:221

References SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), D_PAD::GetShape(), D_PAD::GetSize(), PAD_SHAPE_CIRCLE, SHAPE_LINE_CHAIN::PointCount(), D_PAD::ShapePos(), TransformRingToPolygon(), TransformSegmentToPolygon(), D_PAD::TransformShapeWithClearanceToPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers().

◆ buildPadShapeThickOutlineAsSegments()

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

Definition at line 801 of file create_3Dgraphic_brd_items.cpp.

804 {
805  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
806  {
807  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
808  -aPad->ShapePos().y * m_biuTo3Dunits );
809 
810  const int radius = aPad->GetSize().x / 2;
811  const float inner_radius = ( radius - aWidth / 2 ) * m_biuTo3Dunits;
812  const float outer_radius = ( radius + aWidth / 2 ) * m_biuTo3Dunits;
813 
814  aDstContainer->Add( new CRING2D( center3DU, inner_radius, outer_radius, *aPad ) );
815 
816  return;
817  }
818 
819  // For other shapes, add outlines as thick segments in polygon buffer
820  SHAPE_POLY_SET corners;
821  aPad->TransformShapeWithClearanceToPolygon( corners, 0 );
822 
823  const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
824 
825  for( int j = 0; j < path.PointCount(); j++ )
826  {
827  const VECTOR2I& a = path.CPoint( j );
828  const VECTOR2I& b = path.CPoint( j + 1 );
829 
830  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
831  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
832 
833  if( Is_segment_a_circle( start3DU, end3DU ) )
834  {
835  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, ( aWidth / 2 ) * m_biuTo3Dunits,
836  *aPad ) );
837  }
838  else
839  {
840  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, aWidth * m_biuTo3Dunits,
841  *aPad ) );
842  }
843  }
844 }
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....
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
wxPoint ShapePos() const
Definition: class_pad.cpp:491
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:154
const wxSize & GetSize() const
Definition: class_pad.h:221

References CGENERICCONTAINER2D::Add(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), D_PAD::GetShape(), D_PAD::GetSize(), Is_segment_a_circle(), m_biuTo3Dunits, PAD_SHAPE_CIRCLE, SHAPE_LINE_CHAIN::PointCount(), D_PAD::ShapePos(), D_PAD::TransformShapeWithClearanceToPolygon(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by createLayers().

◆ createBoardPolygon()

bool BOARD_ADAPTER::createBoardPolygon ( )
private

Create the board outline polygon.

Returns
false if the outline could not be created

Definition at line 455 of file board_adapter.cpp.

456 {
458 
459  wxString errmsg;
460 
461  return m_board->GetBoardPolygonOutlines( m_board_poly, &errmsg );
462 }
SHAPE_POLY_SET m_board_poly
PCB board outline polygon.
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, wxString *aErrorText=nullptr, wxPoint *aErrorLocation=nullptr)
Function GetBoardPolygonOutlines Extracts the board outlines and build a closed polygon from lines,...
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 111 of file create_layer_items.cpp.

112 {
113  destroyLayers();
114 
115  // Build Copper layers
116  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L692
117  // /////////////////////////////////////////////////////////////////////////
118 
119 #ifdef PRINT_STATISTICS_3D_VIEWER
120  unsigned stats_startCopperLayersTime = GetRunningMicroSecs();
121 
122  unsigned start_Time = stats_startCopperLayersTime;
123 #endif
124 
125  PCB_LAYER_ID cu_seq[MAX_CU_LAYERS];
127 
128  m_stats_nr_tracks = 0;
130  m_stats_nr_vias = 0;
132  m_stats_nr_holes = 0;
134 
135  // Prepare track list, convert in a vector. Calc statistic for the holes
136  // /////////////////////////////////////////////////////////////////////////
137  std::vector< const TRACK *> trackList;
138  trackList.clear();
139  trackList.reserve( m_board->Tracks().size() );
140 
141  for( TRACK* track : m_board->Tracks() )
142  {
143  if( !Is3DLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
144  continue;
145 
146  // Note: a TRACK holds normal segment tracks and
147  // also vias circles (that have also drill values)
148  trackList.push_back( track );
149 
150  if( track->Type() == PCB_VIA_T )
151  {
152  const VIA *via = static_cast< const VIA*>( track );
153  m_stats_nr_vias++;
155  }
156  else
157  {
159  }
160 
161  m_stats_track_med_width += track->GetWidth() * m_biuTo3Dunits;
162  }
163 
164  if( m_stats_nr_tracks )
166 
167  if( m_stats_nr_vias )
169 
170 #ifdef PRINT_STATISTICS_3D_VIEWER
171  printf( "T01: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
172  start_Time = GetRunningMicroSecs();
173 #endif
174 
175  // Prepare copper layers index and containers
176  // /////////////////////////////////////////////////////////////////////////
177  std::vector< PCB_LAYER_ID > layer_id;
178  layer_id.clear();
179  layer_id.reserve( m_copperLayersCount );
180 
181  for( unsigned i = 0; i < arrayDim( cu_seq ); ++i )
182  cu_seq[i] = ToLAYER_ID( B_Cu - i );
183 
184  for( LSEQ cu = cu_set.Seq( cu_seq, arrayDim( cu_seq ) ); cu; ++cu )
185  {
186  const PCB_LAYER_ID curr_layer_id = *cu;
187 
188  if( !Is3DLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
189  continue;
190 
191  layer_id.push_back( curr_layer_id );
192 
193  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
194  m_layers_container2D[curr_layer_id] = layerContainer;
195 
198  {
199  SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET;
200  m_layers_poly[curr_layer_id] = layerPoly;
201  }
202  }
203 
204 #ifdef PRINT_STATISTICS_3D_VIEWER
205  printf( "T02: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
206  start_Time = GetRunningMicroSecs();
207 #endif
208 
209  if( aStatusReporter )
210  aStatusReporter->Report( _( "Create tracks and vias" ) );
211 
212  // Create tracks as objects and add it to container
213  // /////////////////////////////////////////////////////////////////////////
214  for( PCB_LAYER_ID curr_layer_id : layer_id )
215  {
216  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
217 
218  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
219 
220  // ADD TRACKS
221  unsigned int nTracks = trackList.size();
222 
223  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
224  {
225  const TRACK *track = trackList[trackIdx];
226 
227  // NOTE: Vias can be on multiple layers
228  if( !track->IsOnLayer( curr_layer_id ) )
229  continue;
230 
231  // Add object item to layer container
232  createNewTrack( track, layerContainer, 0.0f );
233  }
234  }
235 
236 #ifdef PRINT_STATISTICS_3D_VIEWER
237  printf( "T03: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
238  start_Time = GetRunningMicroSecs();
239 #endif
240 
241  // Create VIAS and THTs objects and add it to holes containers
242  // /////////////////////////////////////////////////////////////////////////
243  for( PCB_LAYER_ID curr_layer_id : layer_id )
244  {
245  // ADD TRACKS
246  unsigned int nTracks = trackList.size();
247 
248  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
249  {
250  const TRACK *track = trackList[trackIdx];
251 
252  if( !track->IsOnLayer( curr_layer_id ) )
253  continue;
254 
255  // ADD VIAS and THT
256  if( track->Type() == PCB_VIA_T )
257  {
258  const VIA* via = static_cast<const VIA*>( track );
259  const VIATYPE viatype = via->GetViaType();
260  const float holediameter = via->GetDrillValue() * BiuTo3Dunits();
261  const float thickness = GetCopperThickness3DU();
262  const float hole_inner_radius = ( holediameter / 2.0f );
263 
264  const SFVEC2F via_center(
265  via->GetStart().x * m_biuTo3Dunits, -via->GetStart().y * m_biuTo3Dunits );
266 
267  if( viatype != VIATYPE::THROUGH )
268  {
269 
270  // Add hole objects
271  // /////////////////////////////////////////////////////////
272 
273  CBVHCONTAINER2D *layerHoleContainer = NULL;
274 
275  // Check if the layer is already created
276  if( m_layers_holes2D.find( curr_layer_id ) == m_layers_holes2D.end() )
277  {
278  // not found, create a new container
279  layerHoleContainer = new CBVHCONTAINER2D;
280  m_layers_holes2D[curr_layer_id] = layerHoleContainer;
281  }
282  else
283  {
284  // found
285  layerHoleContainer = m_layers_holes2D[curr_layer_id];
286  }
287 
288  // Add a hole for this layer
289  layerHoleContainer->Add( new CFILLEDCIRCLE2D( via_center,
290  hole_inner_radius + thickness,
291  *track ) );
292  }
293  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
294  {
295  // Add through hole object
296  // /////////////////////////////////////////////////////////
297  m_through_holes_outer.Add( new CFILLEDCIRCLE2D( via_center,
298  hole_inner_radius + thickness,
299  *track ) );
300 
302  new CFILLEDCIRCLE2D( via_center,
303  hole_inner_radius + thickness,
304  *track ) );
305 
306  m_through_holes_inner.Add( new CFILLEDCIRCLE2D( via_center,
307  hole_inner_radius,
308  *track ) );
309 
310  //m_through_holes_vias_inner.Add( new CFILLEDCIRCLE2D( via_center,
311  // hole_inner_radius,
312  // *track ) );
313  }
314  }
315  }
316  }
317 
318 #ifdef PRINT_STATISTICS_3D_VIEWER
319  printf( "T04: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
320  start_Time = GetRunningMicroSecs();
321 #endif
322 
323  // Create VIAS and THTs objects and add it to holes containers
324  // /////////////////////////////////////////////////////////////////////////
325  for( PCB_LAYER_ID curr_layer_id : layer_id )
326  {
327  // ADD TRACKS
328  const unsigned int nTracks = trackList.size();
329 
330  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
331  {
332  const TRACK *track = trackList[trackIdx];
333 
334  if( !track->IsOnLayer( curr_layer_id ) )
335  continue;
336 
337  // ADD VIAS and THT
338  if( track->Type() == PCB_VIA_T )
339  {
340  const VIA *via = static_cast< const VIA*>( track );
341  const VIATYPE viatype = via->GetViaType();
342 
343  if( viatype != VIATYPE::THROUGH )
344  {
345 
346  // Add VIA hole contourns
347  // /////////////////////////////////////////////////////////
348 
349  // Add outer holes of VIAs
350  SHAPE_POLY_SET *layerOuterHolesPoly = NULL;
351  SHAPE_POLY_SET *layerInnerHolesPoly = NULL;
352 
353  // Check if the layer is already created
354  if( m_layers_outer_holes_poly.find( curr_layer_id ) ==
356  {
357  // not found, create a new container
358  layerOuterHolesPoly = new SHAPE_POLY_SET;
359  m_layers_outer_holes_poly[curr_layer_id] = layerOuterHolesPoly;
360 
361  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) ==
363 
364  layerInnerHolesPoly = new SHAPE_POLY_SET;
365  m_layers_inner_holes_poly[curr_layer_id] = layerInnerHolesPoly;
366  }
367  else
368  {
369  // found
370  layerOuterHolesPoly = m_layers_outer_holes_poly[curr_layer_id];
371 
372  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
374 
375  layerInnerHolesPoly = m_layers_inner_holes_poly[curr_layer_id];
376  }
377 
378  const int holediameter = via->GetDrillValue();
379  const int hole_outer_radius = (holediameter / 2) + GetCopperThicknessBIU();
380 
381  TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
382  hole_outer_radius, ARC_HIGH_DEF );
383 
384  TransformCircleToPolygon( *layerInnerHolesPoly, via->GetStart(),
385  holediameter / 2, ARC_HIGH_DEF );
386  }
387  else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
388  {
389  const int holediameter = via->GetDrillValue();
390  const int hole_outer_radius = (holediameter / 2)+ GetCopperThicknessBIU();
391 
392  // Add through hole contourns
393  // /////////////////////////////////////////////////////////
395  hole_outer_radius, ARC_HIGH_DEF );
396 
398  holediameter / 2, ARC_HIGH_DEF );
399 
400  // Add samething for vias only
401 
403  hole_outer_radius, ARC_HIGH_DEF );
404 
405  //TransformCircleToPolygon( m_through_inner_holes_vias_poly,
406  // via->GetStart(),
407  // holediameter / 2,
408  // GetNrSegmentsCircle( holediameter ) );
409  }
410  }
411  }
412  }
413 
414 #ifdef PRINT_STATISTICS_3D_VIEWER
415  printf( "T05: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
416  start_Time = GetRunningMicroSecs();
417 #endif
418 
419  // Creates outline contours of the tracks and add it to the poly of the layer
420  // /////////////////////////////////////////////////////////////////////////
423  {
424  for( PCB_LAYER_ID curr_layer_id : layer_id )
425  {
426  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
427 
428  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
429 
430  // ADD TRACKS
431  unsigned int nTracks = trackList.size();
432 
433  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
434  {
435  const TRACK *track = trackList[trackIdx];
436 
437  if( !track->IsOnLayer( curr_layer_id ) )
438  continue;
439 
440  // Add the track contour
441  track->TransformShapeWithClearanceToPolygon( *layerPoly, 0 );
442  }
443  }
444  }
445 
446 #ifdef PRINT_STATISTICS_3D_VIEWER
447  printf( "T06: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
448  start_Time = GetRunningMicroSecs();
449 #endif
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 ) );
473  }
474  }
475  if( m_stats_nr_holes )
477 
478 #ifdef PRINT_STATISTICS_3D_VIEWER
479  printf( "T07: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
480  start_Time = GetRunningMicroSecs();
481 #endif
482 
483  // Add contours of the pad holes (pads can be Circle or Segment holes)
484  // /////////////////////////////////////////////////////////////////////////
485  for( MODULE* module : m_board->Modules() )
486  {
487  for( D_PAD* pad : module->Pads() )
488  {
489  const wxSize padHole = pad->GetDrillSize();
490 
491  if( !padHole.x ) // Not drilled pad like SMD pad
492  continue;
493 
494  // The hole in the body is inflated by copper thickness.
495  const int inflate = GetCopperThicknessBIU();
496 
497  if( pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED )
498  {
499  pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly, inflate );
500  pad->TransformHoleWithClearanceToPolygon( m_through_inner_holes_poly, 0 );
501  }
502  else
503  {
504  // If not plated, no copper.
505  pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly_NPTH, inflate );
506  }
507  }
508  }
509 
510 #ifdef PRINT_STATISTICS_3D_VIEWER
511  printf( "T08: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
512  start_Time = GetRunningMicroSecs();
513 #endif
514 
515  // Add modules PADs objects to containers
516  // /////////////////////////////////////////////////////////////////////////
517  for( PCB_LAYER_ID curr_layer_id : layer_id )
518  {
519  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
520 
521  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
522 
523  // ADD PADS
524  for( MODULE* module : m_board->Modules() )
525  {
526  // Note: NPTH pads are not drawn on copper layers when the pad
527  // has same shape as its hole
529  layerContainer,
530  curr_layer_id,
531  0,
532  true );
533 
534  // Micro-wave modules may have items on copper layers
536  layerContainer,
537  curr_layer_id,
538  0 );
539  }
540  }
541 
542 #ifdef PRINT_STATISTICS_3D_VIEWER
543  printf( "T09: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
544  start_Time = GetRunningMicroSecs();
545 #endif
546 
547  // Add modules PADs poly contourns
548  // /////////////////////////////////////////////////////////////////////////
551  {
552  for( PCB_LAYER_ID curr_layer_id : layer_id )
553  {
554  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
555 
556  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
557 
558  // ADD PADS
559  for( auto module : m_board->Modules() )
560  {
561  // Construct polys
562  // /////////////////////////////////////////////////////////////
563 
564  // Note: NPTH pads are not drawn on copper layers when the pad
565  // has same shape as its hole
566  module->TransformPadsShapesWithClearanceToPolygon( curr_layer_id,
567  *layerPoly,
568  0,
569  true );
570 
571  // Micro-wave modules may have items on copper layers
572  module->TransformGraphicTextWithClearanceToPolygonSet( curr_layer_id,
573  *layerPoly,
574  0 );
575 
576  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
577  }
578  }
579  }
580 
581 #ifdef PRINT_STATISTICS_3D_VIEWER
582  printf( "T10: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
583  start_Time = GetRunningMicroSecs();
584 #endif
585 
586  // Add graphic item on copper layers to object containers
587  // /////////////////////////////////////////////////////////////////////////
588  for( PCB_LAYER_ID curr_layer_id : layer_id )
589  {
590  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
591 
592  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
593 
594  // ADD GRAPHIC ITEMS ON COPPER LAYERS (texts)
595  for( auto item : m_board->Drawings() )
596  {
597  if( !item->IsOnLayer( curr_layer_id ) )
598  continue;
599 
600  switch( item->Type() )
601  {
602  case PCB_LINE_T:
603  {
605  layerContainer,
606  curr_layer_id,
607  0 );
608  }
609  break;
610 
611  case PCB_TEXT_T:
613  layerContainer,
614  curr_layer_id,
615  0 );
616  break;
617 
618  case PCB_DIMENSION_T:
620  layerContainer,
621  curr_layer_id,
622  0 );
623  break;
624 
625  default:
626  wxLogTrace( m_logTrace,
627  wxT( "createLayers: item type: %d not implemented" ),
628  item->Type() );
629  break;
630  }
631  }
632  }
633 
634 #ifdef PRINT_STATISTICS_3D_VIEWER
635  printf( "T11: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
636  start_Time = GetRunningMicroSecs();
637 #endif
638 
639  // Add graphic item on copper layers to poly contourns
640  // /////////////////////////////////////////////////////////////////////////
643  {
644  for( PCB_LAYER_ID cur_layer_id : layer_id )
645  {
646  wxASSERT( m_layers_poly.find( cur_layer_id ) != m_layers_poly.end() );
647 
648  SHAPE_POLY_SET *layerPoly = m_layers_poly[cur_layer_id];
649 
650  // ADD GRAPHIC ITEMS ON COPPER LAYERS (texts)
651  for( BOARD_ITEM* item : m_board->Drawings() )
652  {
653  if( !item->IsOnLayer( cur_layer_id ) )
654  continue;
655 
656  switch( item->Type() )
657  {
658  case PCB_LINE_T:
659  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( *layerPoly, 0 );
660  break;
661 
662  case PCB_TEXT_T:
663  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet( *layerPoly, 0 );
664  break;
665 
666  default:
667  wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
668  item->Type() );
669  break;
670  }
671  }
672  }
673  }
674 
675 #ifdef PRINT_STATISTICS_3D_VIEWER
676  printf( "T12: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
677  start_Time = GetRunningMicroSecs();
678 #endif
679 
680  if( GetFlag( FL_ZONE ) )
681  {
682  if( aStatusReporter )
683  aStatusReporter->Report( _( "Create zones" ) );
684 
685  std::vector<std::pair<const ZONE_CONTAINER*, PCB_LAYER_ID>> zones;
686 
687  for( int i = 0; i < m_board->GetAreaCount(); i++ )
688  {
689  const ZONE_CONTAINER* zone = m_board->GetArea( i );
690 
691  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
692  zones.emplace_back( std::make_pair( zone, layer ) );
693  }
694 
695  // Add zones objects
696  // /////////////////////////////////////////////////////////////////////
697  std::atomic<size_t> nextZone( 0 );
698  std::atomic<size_t> threadsFinished( 0 );
699 
700  size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency(), 2 );
701  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
702  {
703  std::thread t = std::thread( [&]()
704  {
705  for( size_t areaId = nextZone.fetch_add( 1 );
706  areaId < zones.size();
707  areaId = nextZone.fetch_add( 1 ) )
708  {
709  const ZONE_CONTAINER* zone = zones[areaId].first;
710 
711  if( zone == nullptr )
712  break;
713 
714  PCB_LAYER_ID layer = zones[areaId].second;
715 
716  auto layerContainer = m_layers_container2D.find( layer );
717 
718  if( layerContainer != m_layers_container2D.end() )
719  AddSolidAreasShapesToContainer( zone, layerContainer->second, layer );
720  }
721 
722  threadsFinished++;
723  } );
724 
725  t.detach();
726  }
727 
728  while( threadsFinished < parallelThreadCount )
729  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
730 
731  }
732 
733 #ifdef PRINT_STATISTICS_3D_VIEWER
734  printf( "fill zones T13: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
735  start_Time = GetRunningMicroSecs();
736 #endif
737 
740  {
741  // ADD COPPER ZONES
742  for( ZONE_CONTAINER* zone : m_board->Zones() )
743  {
744  if( zone == nullptr )
745  break;
746 
747  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
748  {
749  auto layerContainer = m_layers_poly.find( layer );
750 
751  if( layerContainer != m_layers_poly.end() )
752  zone->TransformSolidAreasShapesToPolygonSet( layer, *layerContainer->second );
753  }
754  }
755  }
756 
757 #ifdef PRINT_STATISTICS_3D_VIEWER
758  printf( "T14: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
759  start_Time = GetRunningMicroSecs();
760 #endif
761 
762  // Simplify layer polygons
763  // /////////////////////////////////////////////////////////////////////////
764 
765  if( aStatusReporter )
766  aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
767 
770  {
771  std::atomic<size_t> nextItem( 0 );
772  std::atomic<size_t> threadsFinished( 0 );
773 
774  size_t parallelThreadCount = std::min<size_t>(
775  std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
776  layer_id.size() );
777  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
778  {
779  std::thread t = std::thread( [&nextItem, &threadsFinished, &layer_id, this]()
780  {
781  for( size_t i = nextItem.fetch_add( 1 );
782  i < layer_id.size();
783  i = nextItem.fetch_add( 1 ) )
784  {
785  auto layerPoly = m_layers_poly.find( layer_id[i] );
786 
787  if( layerPoly != m_layers_poly.end() )
788  // This will make a union of all added contours
789  layerPoly->second->Simplify( SHAPE_POLY_SET::PM_FAST );
790  }
791 
792  threadsFinished++;
793  } );
794 
795  t.detach();
796  }
797 
798  while( threadsFinished < parallelThreadCount )
799  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
800  }
801 
802 #ifdef PRINT_STATISTICS_3D_VIEWER
803  printf( "T15: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
804  start_Time = GetRunningMicroSecs();
805 #endif
806 
807  // Simplify holes polygon contours
808  // /////////////////////////////////////////////////////////////////////////
809  if( aStatusReporter )
810  aStatusReporter->Report( _( "Simplify holes contours" ) );
811 
812  for( PCB_LAYER_ID layer : layer_id )
813  {
814  if( m_layers_outer_holes_poly.find( layer ) != m_layers_outer_holes_poly.end() )
815  {
816  // found
817  SHAPE_POLY_SET *polyLayer = m_layers_outer_holes_poly[layer];
818  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
819 
820  wxASSERT( m_layers_inner_holes_poly.find( layer ) != m_layers_inner_holes_poly.end() );
821 
822  polyLayer = m_layers_inner_holes_poly[layer];
823  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
824  }
825  }
826 
827 #ifdef PRINT_STATISTICS_3D_VIEWER
828  printf( "T16: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
829 #endif
830  // End Build Copper layers
831 
832 
833  // This will make a union of all added contourns
838  //m_through_inner_holes_vias_poly.Simplify( SHAPE_POLY_SET::PM_FAST ); // Not in use
839 
840 #ifdef PRINT_STATISTICS_3D_VIEWER
841  unsigned stats_endCopperLayersTime = GetRunningMicroSecs();
842 #endif
843 
844  // Build Tech layers
845  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
846  // /////////////////////////////////////////////////////////////////////////
847 #ifdef PRINT_STATISTICS_3D_VIEWER
848  unsigned stats_startTechLayersTime = GetRunningMicroSecs();
849 #endif
850 
851  if( aStatusReporter )
852  aStatusReporter->Report( _( "Build Tech layers" ) );
853 
854  // draw graphic items, on technical layers
855  static const PCB_LAYER_ID teckLayerList[] = {
856  B_Adhes,
857  F_Adhes,
858  B_Paste,
859  F_Paste,
860  B_SilkS,
861  F_SilkS,
862  B_Mask,
863  F_Mask,
864 
865  // Aux Layers
866  Dwgs_User,
867  Cmts_User,
868  Eco1_User,
869  Eco2_User,
870  Edge_Cuts,
871  Margin
872  };
873 
874  // User layers are not drawn here, only technical layers
875 
876  for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, arrayDim( teckLayerList ) );
877  seq;
878  ++seq )
879  {
880  const PCB_LAYER_ID curr_layer_id = *seq;
881 
882  if( !Is3DLayerEnabled( curr_layer_id ) )
883  continue;
884 
885  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
886  m_layers_container2D[curr_layer_id] = layerContainer;
887 
888  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
889  m_layers_poly[curr_layer_id] = layerPoly;
890 
891  // Add drawing objects
892  // /////////////////////////////////////////////////////////////////////
893  for( BOARD_ITEM* item : m_board->Drawings() )
894  {
895  if( !item->IsOnLayer( curr_layer_id ) )
896  continue;
897 
898  switch( item->Type() )
899  {
900  case PCB_LINE_T:
902  layerContainer,
903  curr_layer_id,
904  0 );
905  break;
906 
907  case PCB_TEXT_T:
909  layerContainer,
910  curr_layer_id,
911  0 );
912  break;
913 
914  case PCB_DIMENSION_T:
916  layerContainer,
917  curr_layer_id,
918  0 );
919  break;
920 
921  default:
922  break;
923  }
924  }
925 
926 
927  // Add drawing contours
928  // /////////////////////////////////////////////////////////////////////
929  for( BOARD_ITEM* item : m_board->Drawings() )
930  {
931  if( !item->IsOnLayer( curr_layer_id ) )
932  continue;
933 
934  switch( item->Type() )
935  {
936  case PCB_LINE_T:
937  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( *layerPoly, 0 );
938  break;
939 
940  case PCB_TEXT_T:
941  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet( *layerPoly, 0 );
942  break;
943 
944  default:
945  break;
946  }
947  }
948 
949 
950  // Add modules tech layers - objects
951  // /////////////////////////////////////////////////////////////////////
952  for( MODULE* module : m_board->Modules() )
953  {
954  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
955  {
956  int linewidth = g_DrawDefaultLineThickness;
957 
958  for( D_PAD* pad : module->Pads() )
959  {
960  if( !pad->IsOnLayer( curr_layer_id ) )
961  continue;
962 
963  buildPadShapeThickOutlineAsSegments( pad, layerContainer, linewidth );
964  }
965  }
966  else
967  {
969  module, layerContainer, curr_layer_id, 0, false );
970  }
971 
972  AddGraphicsShapesWithClearanceToContainer( module, layerContainer, curr_layer_id, 0 );
973  }
974 
975 
976  // Add modules tech layers - contours
977  // /////////////////////////////////////////////////////////////////////
978  for( MODULE* module : m_board->Modules() )
979  {
980  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
981  {
982  const int linewidth = g_DrawDefaultLineThickness;
983 
984  for( D_PAD* pad : module->Pads() )
985  {
986  if( !pad->IsOnLayer( curr_layer_id ) )
987  continue;
988 
989  buildPadShapeThickOutlineAsPolygon( pad, *layerPoly, linewidth );
990  }
991  }
992  else
993  {
994  module->TransformPadsShapesWithClearanceToPolygon( curr_layer_id, *layerPoly, 0,
995  false );
996  }
997 
998  // On tech layers, use a poor circle approximation, only for texts (stroke font)
999  module->TransformGraphicTextWithClearanceToPolygonSet( curr_layer_id, *layerPoly, 0 );
1000 
1001  // Add the remaining things with dynamic seg count for circles
1002  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
1003  }
1004 
1005 
1006  // Draw non copper zones
1007  // /////////////////////////////////////////////////////////////////////
1008  if( GetFlag( FL_ZONE ) )
1009  {
1010  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
1011  {
1012  ZONE_CONTAINER* zone = m_board->GetArea( ii );
1013 
1014  if( !zone->IsOnLayer( curr_layer_id ) )
1015  continue;
1016 
1017  AddSolidAreasShapesToContainer( zone, layerContainer, curr_layer_id );
1018  }
1019 
1020  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
1021  {
1022  ZONE_CONTAINER* zone = m_board->GetArea( ii );
1023 
1024  if( !zone->IsOnLayer( curr_layer_id ) )
1025  continue;
1026 
1027  zone->TransformSolidAreasShapesToPolygonSet( curr_layer_id, *layerPoly );
1028  }
1029  }
1030 
1031  // This will make a union of all added contours
1032  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1033  }
1034  // End Build Tech layers
1035 
1036 #ifdef PRINT_STATISTICS_3D_VIEWER
1037  unsigned stats_endTechLayersTime = GetRunningMicroSecs();
1038 #endif
1039 
1040 
1041  // Build BVH for holes and vias
1042  // /////////////////////////////////////////////////////////////////////////
1043 
1044 #ifdef PRINT_STATISTICS_3D_VIEWER
1045  unsigned stats_startHolesBVHTime = GetRunningMicroSecs();
1046 #endif
1047  if( aStatusReporter )
1048  aStatusReporter->Report( _( "Build BVH for holes and vias" ) );
1049 
1052 
1053  if( !m_layers_holes2D.empty() )
1054  {
1055  for( auto& hole : m_layers_holes2D)
1056  hole.second->BuildBVH();
1057  }
1058 
1059  // We only need the Solder mask to initialize the BVH
1060  // because..?
1062  m_layers_container2D[B_Mask]->BuildBVH();
1063 
1065  m_layers_container2D[F_Mask]->BuildBVH();
1066 
1067 #ifdef PRINT_STATISTICS_3D_VIEWER
1068  unsigned stats_endHolesBVHTime = GetRunningMicroSecs();
1069 
1070  printf( "BOARD_ADAPTER::createLayers times\n" );
1071  printf( " Copper Layers: %.3f ms\n",
1072  (float)( stats_endCopperLayersTime - stats_startCopperLayersTime ) / 1e3 );
1073  printf( " Holes BVH creation: %.3f ms\n",
1074  (float)( stats_endHolesBVHTime - stats_startHolesBVHTime ) / 1e3 );
1075  printf( " Tech Layers: %.3f ms\n",
1076  (float)( stats_endTechLayersTime - stats_startTechLayersTime ) / 1e3 );
1077  printf( "Statistics:\n" );
1078  printf( " m_stats_nr_tracks %u\n", m_stats_nr_tracks );
1079  printf( " m_stats_nr_vias %u\n", m_stats_nr_vias );
1080  printf( " m_stats_nr_holes %u\n", m_stats_nr_holes );
1081  printf( " m_stats_via_med_hole_diameter (3DU) %f\n", m_stats_via_med_hole_diameter );
1082  printf( " m_stats_hole_med_diameter (3DU) %f\n", m_stats_hole_med_diameter );
1083  printf( " m_calc_seg_min_factor3DU (3DU) %f\n", m_calc_seg_min_factor3DU );
1084  printf( " m_calc_seg_max_factor3DU (3DU) %f\n", m_calc_seg_max_factor3DU );
1085 #endif
1086 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:712
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
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
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:118
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:329
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()
Function AllNonCuMask returns a mask holding all layer minus CU layers.
Definition: lset.cpp:735
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, 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...
float GetCopperThickness3DU() const noexcept
GetCopperThickness3DU - Get the current copper layer thickness.
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
unsigned int m_stats_nr_holes
number of holes in the board
unsigned int m_stats_nr_vias
Nr of vias.
SHAPE_POLY_SET m_through_inner_holes_poly
It contains polygon contours for through holes (inner cylinder)
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:377
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 TransformSolidAreasShapesToPolygonSet(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aError=ARC_HIGH_DEF) const
Function TransformSolidAreasShapesToPolygonSet Convert solid areas full shapes to polygon set (the fu...
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:312
RENDER_ENGINE m_render_engine
PCB_LAYER_ID
A quick note on layer IDs:
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:932
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.
void AddPadsShapesWithClearanceToContainer(const MODULE *aModule, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper)
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:266
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.
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....
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...
void buildPadShapeThickOutlineAsPolygon(const D_PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
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:280
SHAPE_POLY_SET m_through_outer_holes_poly
It contains polygon contours for through holes (outer cylinder)
#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:373
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.
void createNewTrack(const TRACK *aTrack, CGENERICCONTAINER2D *aDstContainer, int aClearanceValue)
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.
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:897
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
float m_calc_seg_min_factor3DU
min factor used for cicle segment approximation calculation
DRAWINGS & Drawings()
Definition: class_board.h:275
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
unsigned int m_stats_nr_tracks
Number of tracks in the board.
DIMENSION.
TRACKS & Tracks()
Definition: class_board.h:257
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References _, CGENERICCONTAINER2D::Add(), AddGraphicsShapesWithClearanceToContainer(), AddPadsShapesWithClearanceToContainer(), AddShapeWithClearanceToContainer(), AddSolidAreasShapesToContainer(), LSET::AllCuMask(), LSET::AllNonCuMask(), arrayDim(), B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, BiuTo3Dunits(), CBVHCONTAINER2D::BuildBVH(), buildPadShapeThickOutlineAsPolygon(), buildPadShapeThickOutlineAsSegments(), Cmts_User, createNewPadDrill(), createNewTrack(), destroyLayers(), BOARD::Drawings(), Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Mask, F_Paste, F_SilkS, FL_RENDER_OPENGL_COPPER_THICKNESS, FL_ZONE, g_DrawDefaultLineThickness, BOARD::GetArea(), BOARD::GetAreaCount(), GetCopperThickness3DU(), GetCopperThicknessBIU(), VIA::GetDrillValue(), GetFlag(), ZONE_CONTAINER::GetLayerSet(), GetRunningMicroSecs(), TRACK::GetStart(), VIA::GetViaType(), Is3DLayerEnabled(), ZONE_CONTAINER::IsOnLayer(), BOARD_ITEM::IsOnLayer(), m_biuTo3Dunits, m_board, m_calc_seg_max_factor3DU, m_calc_seg_min_factor3DU, m_copperLayersCount, m_layers_container2D, m_layers_holes2D, m_layers_inner_holes_poly, m_layers_outer_holes_poly, m_layers_poly, m_logTrace, 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_vias_outer, m_through_inner_holes_poly, m_through_outer_holes_poly, m_through_outer_holes_poly_NPTH, m_through_outer_holes_vias_poly, Margin, MAX_CU_LAYERS, BOARD::Modules(), NULL, OPENGL_LEGACY, PAD_ATTRIB_HOLE_NOT_PLATED, PCB_DIMENSION_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(), ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(), 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 411 of file create_3Dgraphic_brd_items.cpp.

412 {
413  wxSize drillSize = aPad->GetDrillSize();
414 
415  if( !drillSize.x || !drillSize.y )
416  {
417  wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createNewPadDrill - found an invalid pad" ) );
418  return NULL;
419  }
420 
421  if( drillSize.x == drillSize.y ) // usual round hole
422  {
423  const int radius = (drillSize.x / 2) + aInflateValue;
424 
425  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
426  -aPad->GetPosition().y * m_biuTo3Dunits );
427 
428  return new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad );
429 
430  }
431  else // Oblong hole
432  {
433  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
434  float width = seg->GetWidth() + aInflateValue * 2;
435 
436  SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
437  -seg->GetSeg().A.y * m_biuTo3Dunits );
438 
439  SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
440  -seg->GetSeg().B.y * m_biuTo3Dunits );
441 
442  return new CROUNDSEGMENT2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
443  }
444 
445  return NULL;
446 }
wxPoint GetPosition() const override
Definition: class_pad.h:162
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a list of SHAPE objects representing the pad's hole.
Definition: class_pad.cpp:203
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:227
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,
wxSize  aClearanceValue 
) const
private

Definition at line 315 of file create_3Dgraphic_brd_items.cpp.

318 {
319  SHAPE_POLY_SET poly;
320 
321  if( aClearanceValue.x != aClearanceValue.y )
322  {
323  // Our shape-based builder can't handle differing x:y clearance values (which
324  // get generated when relative paste margin is used with an oblong pad). So
325  // we fake a larger pad and run the general-purpose polygon builder on it.
326  D_PAD dummy( *aPad );
327  dummy.SetSize( aPad->GetSize() + aClearanceValue + aClearanceValue );
328  dummy.TransformShapeWithClearanceToPolygon( poly, 0 );
329  }
330  else
331  {
332  for( const std::shared_ptr<SHAPE>& shape : aPad->GetEffectiveShapes() )
333  {
334  switch( shape->Type() )
335  {
336  case SH_SEGMENT:
337  {
338  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape.get();
339  const SFVEC2F start3DU( seg->GetSeg().A.x * m_biuTo3Dunits,
340  -seg->GetSeg().A.y * m_biuTo3Dunits );
341  const SFVEC2F end3DU ( seg->GetSeg().B.x * m_biuTo3Dunits,
342  -seg->GetSeg().B.y * m_biuTo3Dunits );
343  const int width = seg->GetWidth() + aClearanceValue.x * 2;
344 
345  // Cannot add segments that have the same start and end point
346  if( Is_segment_a_circle( start3DU, end3DU ) )
347  {
348  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
349  ( width / 2) * m_biuTo3Dunits,
350  *aPad ) );
351  }
352  else
353  {
354  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
355  width * m_biuTo3Dunits,
356  *aPad ) );
357  }
358  }
359  break;
360 
361  case SH_CIRCLE:
362  {
363  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape.get();
364  const int radius = circle->GetRadius() + aClearanceValue.x;
365  const SFVEC2F center( circle->GetCenter().x * m_biuTo3Dunits,
366  -circle->GetCenter().y * m_biuTo3Dunits );
367 
368  aDstContainer->Add( new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad ) );
369  }
370  break;
371 
372  case SH_RECT:
373  {
374  SHAPE_RECT* rect = (SHAPE_RECT*) shape.get();
375 
376  poly.NewOutline();
377  poly.Append( rect->GetPosition() );
378  poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y );
379  poly.Append( rect->GetPosition() + rect->GetSize() );
380  poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y );
381  }
382  break;
383 
384  case SH_SIMPLE:
385  poly.AddOutline( static_cast<SHAPE_SIMPLE*>( shape.get() )->Vertices() );
386  break;
387 
388  case SH_POLY_SET:
389  poly = *(SHAPE_POLY_SET*) shape.get();
390  break;
391 
392  default:
393  wxFAIL_MSG( "BOARD_ADAPTER::createNewPadWithClearance no implementation for "
394  + SHAPE_TYPE_asString( shape->Type() ) );
395  break;
396  }
397  }
398  }
399 
400  if( !poly.IsEmpty() )
401  {
402  if( aClearanceValue.x )
403  poly.Inflate( aClearanceValue.x, 32 );
404 
405  // Add the PAD polygon
406  Convert_shape_line_polygon_to_triangles( poly, *aDstContainer, m_biuTo3Dunits, *aPad );
407  }
408 }
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 std::vector< std::shared_ptr< SHAPE > > & GetEffectiveShapes() const
Function GetEffectiveShapes Some pad shapes can be complex (rounded/chamfered rectangle),...
Definition: class_pad.cpp:194
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:51
int NewOutline()
Creates a new empty polygon in the set and returns its index
line chain (polyline)
Definition: shape.h:44
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:46
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:41
const wxSize & GetSize() const
Definition: class_pad.h:221
int GetWidth() const
circle
Definition: shape.h:45
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:42
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::GetEffectiveShapes(), SHAPE_RECT::GetPosition(), SHAPE_CIRCLE::GetRadius(), SHAPE_SEGMENT::GetSeg(), 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(), 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 237 of file create_3Dgraphic_brd_items.cpp.

239 {
240  SFVEC2F start3DU( aTrack->GetStart().x * m_biuTo3Dunits,
241  -aTrack->GetStart().y * m_biuTo3Dunits ); // y coord is inverted
242 
243  switch( aTrack->Type() )
244  {
245  case PCB_VIA_T:
246  {
247  const float radius = ( ( aTrack->GetWidth() / 2 ) + aClearanceValue ) * m_biuTo3Dunits;
248  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius, *aTrack ) );
249  }
250  break;
251 
252  case PCB_ARC_T:
253  {
254  const ARC* arc = static_cast<const ARC*>( aTrack );
255  VECTOR2D center( arc->GetCenter() );
256  double arc_angle = arc->GetAngle();
257  double radius = arc->GetRadius();
258  int arcsegcount = GetArcToSegmentCount( radius, Millimeter2iu( 0.005), arc_angle/10 );
259  int circlesegcount;
260 
261  // We need a circle to segment count. However, the arc angle can be small, and the
262  // radius very big. so we calculate a reasonable value for circlesegcount.
263  if( arcsegcount <= 1 ) // The arc will be approximated by a segment
264  circlesegcount = 1;
265  else
266  {
267  double cnt = arcsegcount * 3600/std::abs( arc_angle );
268 
269  #define SEG_CNT_MAX 128
270  if( cnt < SEG_CNT_MAX )
271  {
272  circlesegcount = (int)cnt;
273 
274  if( circlesegcount == 0 )
275  circlesegcount = 1;
276  }
277  else
278  circlesegcount = SEG_CNT_MAX;
279  }
280 
281  TransformArcToSegments( wxPoint( center.x, center.y ), arc->GetStart(),
282  arc_angle, circlesegcount,
283  arc->GetWidth() + 2 * aClearanceValue, aDstContainer,
284  *arc );
285  }
286  break;
287 
288  case PCB_TRACE_T: // Track is a usual straight segment
289  {
290  SFVEC2F end3DU ( aTrack->GetEnd().x * m_biuTo3Dunits,
291  -aTrack->GetEnd().y * m_biuTo3Dunits );
292 
293  // Cannot add segments that have the same start and end point
294  if( Is_segment_a_circle( start3DU, end3DU ) )
295  {
296  const float radius = ((aTrack->GetWidth() / 2) + aClearanceValue) * m_biuTo3Dunits;
297 
298  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius, *aTrack ) );
299  }
300  else
301  {
302  const float width = (aTrack->GetWidth() + 2 * aClearanceValue ) * m_biuTo3Dunits;
303 
304  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU, width, *aTrack ) );
305  }
306  }
307  break;
308 
309  default:
310  break;
311  }
312 }
#define SEG_CNT_MAX
const wxPoint & GetStart() const
Definition: class_track.h:118
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:112
const wxPoint & GetEnd() const
Definition: class_track.h:115
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
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, 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 
66  if( !m_layers_inner_holes_poly.empty() )
67  {
68  for( auto& poly : m_layers_inner_holes_poly )
69  delete poly.second;
70 
72  }
73 
74  if( !m_layers_outer_holes_poly.empty() )
75  {
76  for( auto& poly : m_layers_outer_holes_poly )
77  delete poly.second;
78 
80  }
81 
82  if( !m_layers_container2D.empty() )
83  {
84  for( auto& poly : m_layers_container2D )
85  delete poly.second;
86 
87  m_layers_container2D.clear();
88  }
89 
90  if( !m_layers_holes2D.empty() )
91  {
92  for( auto& poly : m_layers_holes2D )
93  delete poly.second;
94 
95  m_layers_holes2D.clear();
96  }
97 
104  //m_through_inner_holes_poly.RemoveAllContours();
105 
108 }
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)
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_inner_holes_vias_poly
It contains polygon contours for through holes vias (inner cylinder)
MAP_CONTAINER_2D m_layers_holes2D
It contains the holes per each layer.
SHAPE_POLY_SET m_through_outer_holes_vias_poly
It contains polygon contours for through holes vias (outer cylinder)
MAP_POLY m_layers_poly
It contains polygon contours for each layer.
CBVHCONTAINER2D m_through_holes_vias_outer
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the c...
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...
SHAPE_POLY_SET m_through_outer_holes_poly
It contains polygon contours for through holes (outer cylinder)
CBVHCONTAINER2D m_through_holes_vias_inner
It contains the list of throughHoles vias of the board, the radius of the hole.
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
MAP_CONTAINER_2D m_layers_container2D
It contains the 2d elements of each layer.

References CGENERICCONTAINER2D::Clear(), m_layers_container2D, m_layers_holes2D, m_layers_inner_holes_poly, m_layers_outer_holes_poly, m_layers_poly, m_through_holes_inner, m_through_holes_outer, m_through_holes_vias_inner, m_through_holes_vias_outer, m_through_inner_holes_vias_poly, m_through_outer_holes_poly, m_through_outer_holes_poly_NPTH, m_through_outer_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().

◆ GetCircleCorrectionFactor()

double BOARD_ADAPTER::GetCircleCorrectionFactor ( int  aNrSides) const

GetCircleCorrectionFactor - computes a angle correction factor used when creating circles.

Parameters
aNrSidesthe number of segments sides of the circle
Returns
a factor to apply to contour creation

Definition at line 268 of file board_adapter.cpp.

269 {
270  wxASSERT( aNrSides >= 3 );
271 
272  return GetCircletoPolyCorrectionFactor( aNrSides );
273 }
double GetCircletoPolyCorrectionFactor(int aSegCountforCircle)

References GetCircletoPolyCorrectionFactor().

Referenced by C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads().

◆ GetColor()

SFVEC3F BOARD_ADAPTER::GetColor ( COLOR4D  aColor) const

GetColor.

Parameters
aColorthe color mapped
Returns
the color in SFVEC3F format

Definition at line 500 of file board_adapter.cpp.

501 {
502  return SFVEC3F( aColor.r, aColor.g, aColor.b );
503 }
double g
Green component.
Definition: color4d.h:367
double b
Blue component.
Definition: color4d.h:368
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
double r
Red component.
Definition: color4d.h:366

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

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

◆ 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(), and C3D_RENDER_RAYTRACING::insert3DViaHole().

◆ GetCopperThicknessBIU()

int BOARD_ADAPTER::GetCopperThicknessBIU ( ) const
noexcept

GetCopperThicknessBIU - Get the current copper layer thickness.

Returns
thickness in board unities

Definition at line 246 of file board_adapter.cpp.

247 {
248  return COPPER_THICKNESS;
249 }
#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::Redraw().

◆ GetFlag()

◆ GetItemColor()

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

495 {
496  return GetColor( m_colors->GetColor( aItemId ) );
497 }
COLOR_SETTINGS * m_colors
COLOR4D GetColor(int aLayer) const
SFVEC3F GetColor(COLOR4D aColor) const
GetColor.

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

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

485 {
486  wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
487 
488  const COLOR4D color = m_colors->GetColor( aLayerId );
489 
490  return SFVEC3F( color.r, color.g, color.b );
491 }
COLOR_SETTINGS * m_colors
int color
Definition: DXF_plotter.cpp:61
COLOR4D GetColor(int aLayer) const
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
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_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_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 369 of file board_adapter.h.

370  {
371  return m_layers_holes2D;
372  }
MAP_CONTAINER_2D m_layers_holes2D
It contains the holes per each layer.

References m_layers_holes2D.

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

466 {
467  if( aIsFlipped )
468  {
469  if( GetFlag( FL_SOLDERPASTE ) )
471  else
473  }
474  else
475  {
476  if( GetFlag( FL_SOLDERPASTE ) )
477  return m_layerZcoordTop[F_SilkS];
478  else
479  return m_layerZcoordTop[F_Paste];
480  }
481 }
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 251 of file board_adapter.cpp.

252 {
253  wxASSERT( aDiameter3DU > 0.0f );
254 
255  return GetNrSegmentsCircle( (int)( aDiameter3DU / m_biuTo3Dunits ) );
256 }
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 259 of file board_adapter.cpp.

260 {
261  wxASSERT( aDiameterBIU > 0 );
262 
263  // Require at least 3 segments for a circle
264  return std::max( GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, 360.0 ), 3 );
265 }
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)

References GetArcToSegmentCount().

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

525  {
526  return m_layers_poly;
527  }
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 529 of file board_adapter.h.

530  {
532  }
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 534 of file board_adapter.h.

535  {
537  }
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().

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

485  {
487  }
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 493 of file board_adapter.h.

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

476  {
478  }
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 466 of file board_adapter.h.

467  {
468  return m_stats_nr_holes;
469  }
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 457 of file board_adapter.h.

458  {
459  return m_stats_nr_vias;
460  }
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 439 of file board_adapter.h.

440  {
441  return m_through_holes_inner;
442  }
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_Inner_poly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHole_Inner_poly ( ) const
inlinenoexcept

GetThroughHole_Inner_poly -.

Returns

Definition at line 448 of file board_adapter.h.

449  {
451  }
SHAPE_POLY_SET m_through_inner_holes_poly
It contains polygon contours for through holes (inner cylinder)

References m_through_inner_holes_poly.

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

379  {
380  return m_through_holes_outer;
381  }
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_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 387 of file board_adapter.h.

388  {
390  }
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 396 of file board_adapter.h.

397  {
399  }
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_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 414 of file board_adapter.h.

415  {
417  }
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_Inner_poly()

const SHAPE_POLY_SET& BOARD_ADAPTER::GetThroughHole_Vias_Inner_poly ( ) const
inlinenoexcept

GetThroughHole_Vias_Inner_poly -.

Definition at line 430 of file board_adapter.h.

431  {
433  }
SHAPE_POLY_SET m_through_inner_holes_vias_poly
It contains polygon contours for through holes vias (inner cylinder)

References m_through_inner_holes_vias_poly.

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

406  {
408  }
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 422 of file board_adapter.h.

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

References m_through_outer_holes_vias_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

◆ GridGet()

GRID3D_TYPE BOARD_ADAPTER::GridGet ( ) const
inlinenoexcept

GridGet - get the current grid.

Returns
space type of the grid

Definition at line 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_VIEWER::CreateMenuBar(), 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 276 of file board_adapter.cpp.

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

130 {
131  wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
132 
133  DISPLAY3D_FLG flg;
134 
135  // see if layer needs to be shown
136  // check the flags
137  switch( aLayer )
138  {
139  case B_Adhes:
140  case F_Adhes:
141  flg = FL_ADHESIVE;
142  break;
143 
144  case B_Paste:
145  case F_Paste:
146  flg = FL_SOLDERPASTE;
147  break;
148 
149  case B_SilkS:
150  case F_SilkS:
151  flg = FL_SILKSCREEN;
152  break;
153 
154  case B_Mask:
155  case F_Mask:
156  flg = FL_SOLDERMASK;
157  break;
158 
159  case Dwgs_User:
160  case Cmts_User:
162  return false;
163 
164  flg = FL_COMMENTS;
165  break;
166 
167  case Eco1_User:
168  case Eco2_User:
170  return false;
171 
172  flg = FL_ECO;
173  break;
174 
175  case Edge_Cuts:
177  return false;
178 
179  return true;
180  break;
181 
182  case Margin:
184  return false;
185 
186  return true;
187  break;
188 
189  case B_Cu:
190  case F_Cu:
191  return m_board->IsLayerVisible( aLayer ) || GetFlag( FL_USE_REALISTIC_MODE );
192  break;
193 
194  default:
195  // the layer is an internal copper layer, used the visibility
197  {
198  // Do not render internal layers if it is overlap with the board
199  // (on OpenGL render)
200  return false;
201  }
202 
203  return m_board->IsLayerVisible( aLayer );
204  }
205 
206  // The layer has a flag, return the flag
207  return GetFlag( flg );
208 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
RENDER_ENGINE m_render_engine
DISPLAY3D_FLG
Flags used in rendering options.
Definition: 3d_enums.h:34
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...

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, m_render_engine, Margin, OPENGL_LEGACY, 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(), EDA_3D_VIEWER::CreateMenuBar(), C3D_RENDER_OGL_LEGACY::load_3D_models(), EDA_3D_VIEWER::OnUpdateUIMaterial(), 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_VIEWER::Process_Special_Functions().

◆ 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_VIEWER::LoadSettings(), EDA_3D_VIEWER::OnDisableRayTracing(), EDA_3D_CANVAS::OnPaint(), 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 219 of file board_adapter.cpp.

220 {
221  wxASSERT( aFlag < FL_LAST );
222 
223  m_drawFlags[aFlag] = aState;
224 }
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 226 of file board_adapter.cpp.

227 {
228  if( ( ( aModuleAttributs == MOD_DEFAULT ) &&
230  ( ( ( aModuleAttributs & MOD_CMS) == MOD_CMS ) &&
232  ( ( ( aModuleAttributs & MOD_VIRTUAL) == MOD_VIRTUAL ) &&
234  {
235  return true;
236  }
237 
238  return false;
239 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
Set for modules listed in the automatic insertion list (usually SMD footprints)
Definition: class_module.h:68
default
Definition: class_module.h:67
Virtual component: when created by copper shapes on board (Like edge card connectors,...
Definition: class_module.h:70

References FL_MODULE_ATTRIBUTES_NORMAL, FL_MODULE_ATTRIBUTES_NORMAL_INSERT, FL_MODULE_ATTRIBUTES_VIRTUAL, GetFlag(), MOD_CMS, MOD_DEFAULT, and MOD_VIRTUAL.

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

519 {
520  wxPoint arc_start, arc_end;
521  int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
522 
523  arc_end = arc_start = aStart;
524 
525  if( aArcAngle != 3600 )
526  {
527  RotatePoint( &arc_end, aCentre, -aArcAngle );
528  }
529 
530  if( aArcAngle < 0 )
531  {
532  std::swap( arc_start, arc_end );
533  aArcAngle = -aArcAngle;
534  }
535 
536  // Compute the ends of segments and creates poly
537  wxPoint curr_end = arc_start;
538  wxPoint curr_start = arc_start;
539 
540  for( int ii = delta; ii < aArcAngle; ii += delta )
541  {
542  curr_end = arc_start;
543  RotatePoint( &curr_end, aCentre, -ii );
544 
545  const SFVEC2F start3DU( curr_start.x * m_biuTo3Dunits, -curr_start.y * m_biuTo3Dunits );
546  const SFVEC2F end3DU ( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
547 
548  if( Is_segment_a_circle( start3DU, end3DU ) )
549  {
550  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
551  ( aWidth / 2 ) * m_biuTo3Dunits,
552  aBoardItem ) );
553  }
554  else
555  {
556  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
557  aWidth * m_biuTo3Dunits,
558  aBoardItem ) );
559  }
560 
561  curr_start = curr_end;
562  }
563 
564  if( curr_end != arc_end )
565  {
566  const SFVEC2F start3DU( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
567  const SFVEC2F end3DU ( arc_end.x * m_biuTo3Dunits, -arc_end.y * m_biuTo3Dunits );
568 
569  if( Is_segment_a_circle( start3DU, end3DU ) )
570  {
571  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
572  ( aWidth / 2 ) * m_biuTo3Dunits,
573  aBoardItem ) );
574  }
575  else
576  {
577  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
578  end3DU,
579  aWidth * m_biuTo3Dunits,
580  aBoardItem ) );
581  }
582  }
583 }
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 65 of file create_layer_poly.cpp.

68 {
69  for( BOARD_ITEM* item : aModule->GraphicalItems() )
70  {
71  if( item->Type() == PCB_MODULE_EDGE_T )
72  {
73  EDGE_MODULE* outline = (EDGE_MODULE*) item;
74 
75  if( outline->GetLayer() == aLayer )
76  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, 0 );
77  }
78  }
79 }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, 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...
DRAWINGS & GraphicalItems()
Definition: class_module.h:179
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.

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

Referenced by Get3DCacheManager(), and Set3DCacheManager().

◆ m_antialiasing_mode

ANTIALIASING_MODE BOARD_ADAPTER::m_antialiasing_mode
private

Definition at line 634 of file board_adapter.h.

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

◆ 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 679 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 652 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 646 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 640 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 643 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 735 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and createLayers().

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

Referenced by BOARD_ADAPTER(), and createLayers().

◆ m_colors

COLOR_SETTINGS* BOARD_ADAPTER::m_colors
private

Definition at line 626 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 710 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 723 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 630 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 726 of file board_adapter.h.

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

◆ m_layers_container2D

MAP_CONTAINER_2D BOARD_ADAPTER::m_layers_container2D
private

It contains the 2d elements of each layer.

Definition at line 685 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 688 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 661 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 658 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 655 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 720 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 717 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 764 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 633 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 729 of file board_adapter.h.

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

◆ m_render_engine

RENDER_ENGINE BOARD_ADAPTER::m_render_engine
private

◆ 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 756 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 753 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 741 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 747 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 744 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 750 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 696 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 692 of file board_adapter.h.

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

◆ m_through_holes_vias_inner

CBVHCONTAINER2D BOARD_ADAPTER::m_through_holes_vias_inner
private

It contains the list of throughHoles vias of the board, the radius of the hole.

Definition at line 704 of file board_adapter.h.

Referenced by destroyLayers(), and GetThroughHole_Vias_Inner().

◆ m_through_holes_vias_outer

CBVHCONTAINER2D BOARD_ADAPTER::m_through_holes_vias_outer
private

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

Definition at line 700 of file board_adapter.h.

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

◆ m_through_inner_holes_poly

SHAPE_POLY_SET BOARD_ADAPTER::m_through_inner_holes_poly
private

It contains polygon contours for through holes (inner cylinder)

Definition at line 670 of file board_adapter.h.

Referenced by createLayers(), and GetThroughHole_Inner_poly().

◆ m_through_inner_holes_vias_poly

SHAPE_POLY_SET BOARD_ADAPTER::m_through_inner_holes_vias_poly
private

It contains polygon contours for through holes vias (inner cylinder)

Definition at line 676 of file board_adapter.h.

Referenced by destroyLayers(), and GetThroughHole_Vias_Inner_poly().

◆ m_through_outer_holes_poly

SHAPE_POLY_SET BOARD_ADAPTER::m_through_outer_holes_poly
private

It contains polygon contours for through holes (outer cylinder)

Definition at line 667 of file board_adapter.h.

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

◆ m_through_outer_holes_poly_NPTH

SHAPE_POLY_SET BOARD_ADAPTER::m_through_outer_holes_poly_NPTH
private

It contains polygon contours for (just) non plated through holes (outer cylinder)

Definition at line 664 of file board_adapter.h.

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

◆ m_through_outer_holes_vias_poly

SHAPE_POLY_SET BOARD_ADAPTER::m_through_outer_holes_vias_poly
private

It contains polygon contours for through holes vias (outer cylinder)

Definition at line 673 of file board_adapter.h.

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


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